changing pixel depth in bitmaps
Posted on 1998-04-08
The problem is that when I'm in 16-bit+ color modes and I want to create a bitmap that has a color format of 8 bits per pixel, the bitmap created is drawn with colors that I do not want. The way i create an 8 bit per pixel bitmap is to first create a bitmap in the current color mode i am in, then I use GetDibits to transform the bitmap into an 8 bits per pixel bitmap. However, the documentation for GetDibits says that when it does this transformation, it will synthesize its own color table from a general mix of 256 colors including the 20 static colors defined in the default logical palette. This is clearly NOT the color table i want. I want the 8 bits per pixel bitmap to use the same colors as the original bitmap was drawn in. (The original bitmap is definitely not drawn with more than 256 colors - it's drawn with just like 20 different colors.) The bitmap is a picture of the view within my application.
I've also thought of BitBltting from a 16+ bit bitmap to an 8-bit bitmap, but that means I have to create an 8-bit bitmap and select it into my destination device context. The documentation says that when i do a SelectObject for a bitmap, the bitmap color format must be the same as the device context color format. And, I am not sure how to create a device context that is in an 8-bit color format when my system is in a 16-bit+ color mode. How do i do this?
In short, when I am in 16-bit+ color resolution modes, I want to create an 8 bits per pixel bitmap (of my current view) that uses a 256 color palette that i specify. How do i do this? Thanks for your response(s).