Question on creating bitmap class
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?
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]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement