xSRTsect Posted September 1, 2015 Share Posted September 1, 2015 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. Link to comment
kao Posted September 1, 2015 Share Posted September 1, 2015 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. Link to comment
xSRTsect Posted September 1, 2015 Author Share Posted September 1, 2015 (edited) 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, 2015 by xSRTsect Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now