This topic is now archived and is closed to further replies.


8Bit Bitmap from resource

Recommended Posts

When loading a bitmap from resource I can simply do that this way:
HINSTANCE hInstance = GetModuleHandle(NULL);
HANDLE hBitmap = LoadBitmap(hInstance, MAKEINTRESOURCE (iResource));
if(bmInfo.bmiHeader.biBitCount <= 8)
	bmInfo.bmiHeader.biBitCount = 8;

GetObject(hBitmap, sizeof(BITMAPINFO), &bmInfo);

hBitmap = LoadResource(hInstance, FindResource(hInstance,MAKEINTRESOURCE(iResource), RT_BITMAP));

	BYTE* pTextureImage = (BYTE*)LockResource(hBitmap);
		pTextureImage += sizeof(BITMAPINFO)-1;
	*iTextureWidth = bmInfo.bmiHeader.biWidth; 
	*iTextureHeight = bmInfo.bmiHeader.biHeight;
return pTextureImage;
It is no problem to create a OpenGL texture from pTextureImage, but - you guess it - only with a 24 Bit Bitmap. But I want to use 8 Bit Bitmaps (256 colors) instead. Has anyone suggestions or maybe some exmples for me? thanks.

Share this post

Link to post
Share on other sites

We have a routine for loading 8 bits BMP and then displaying it with glDrawPixels.

If it helps, tell me. I will send it.

Zvika Vered.

Share this post

Link to post
Share on other sites