Jump to content
  • Advertisement
Sign in to follow this  
fathom88

Question on creating bitmap class

This topic is 4712 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

I'm trying to draw into a bitmap. Currently, I use CBitmap's CreateCompatibleBitmap. However, I do not need the full range of colors that it produces. The bitmap object in memory is larger than I need. I only wish to display 256 colors at most, maybe even less. I tried using CreateBitmap, but it would give me an error. CreateBitmap(50, 50, 1, 8) would generate an error once I tried to draw to it. CreateBitmap(50, 50, 1, 1) works fine but gives me shades of black. A black and white image. Basically, I need a way to define a smaller bit count for my pixel color, thus limiting number of colors I can paint. How can I go about this?

Share this post


Link to post
Share on other sites
Advertisement
I can't find anything in MFC to do this, but you can create a Device Independent Bitmap (DIB) using the Win32 function CreateDIBitmap(). The bitmaps supported by MFC seem to all be Device Dependent Bitmaps (DDBs), and apparently DDBs don't support palettized bitmaps. DIBs, however, do support palettes. Copying the DIBs to/from DDBs might take a bit of programmer and CPU effort, but I believe that as far as GDI goes, DIBs are a common way to handle things like this. I think. [smile]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!