Sign in to follow this  
fathom88

Question on creating bitmap class

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this