Jump to content
  • Advertisement

Archived

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

kts78

8Bit Bitmap from resource

This topic is 5849 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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));
	
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.

Share this post


Link to post
Share on other sites
Advertisement
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 -

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!