Posted September 1, 20159 yr Hello, I have the following code //bitmap HMODULE hModule = GetModuleHandle(NULL); HRSRC hRes = FindResource(hModule, pBitmapName, RT_BITMAP); if (hRes == NULL) return; HGLOBAL hGlb = LoadResource(hModule, hRes); if (hGlb == NULL) return; BITMAPINFO * pDIB = (BITMAPINFO *)LockResource(hGlb); if (pDIB == NULL) return; textbmi = *pDIB; textDC = CreateCompatibleDC(mDC->GetSafeHdc()); textbmp = CreateDIBSection(textDC, &textbmi, DIB_RGB_COLORS, (LPVOID *)&lpTextBuffer, 0, 0); SelectObject(textDC, textbmp);Everything looks to execute properly without API null returns - however, lpTextBuffer points to an array of zeros, no my image is not a black bitmap.
September 1, 20159 yr Cast to BITMAPINFO* is wrong, it's actually a BITMAPFILEHEADER* . See https://www.opengl.org/discussion_boards/showthread.php/139720-problem-with-loading-textures-from-a-resource-VC, http://stackoverflow.com/questions/1651531/loading-an-image-from-memory-gdi and corresponding topics in MSDN.
September 1, 20159 yr Author Hello and thank you for the answer. I ended up accessing the data after the structure BITMAPINFOHEADER to find out it was my pixel data. Edited September 1, 20159 yr by xSRTsect
Create an account or sign in to comment