Skip to main content
gamedev.net
🔒 Locked

8Bit Bitmap from resource

Started by kts78 Feb 5, 2002 at 4:07 AM 1 replies 450+ views
Original Post
kts78
kts78
When loading a bitmap from resource I can simply do that this way:
  
HINSTANCE hInstance = GetModuleHandle(NULL);
HANDLE hBitmap = LoadBitmap(hInstance, MAKEINTRESOURCE (iResource));
	
BITMAPINFO bmInfo;
if(bmInfo.bmiHeader.biBitCount <= 8)
	bmInfo.bmiHeader.biBitCount = 8;

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

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.
outRider
outRider
I think you need a palette to go with that, look into how to generate one. You need to pass that to OGL as well, I''m assuming.

------------
- outRider -
veredz
veredz
Hello,

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

If it helps, tell me. I will send it.
zvivered@zahav.net.il

Zvika Vered.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.