Board index » delphi » A 24bit Color bitmap

A 24bit Color bitmap


I need to have a DC with a 24bit color bitmat in any windows screen modes
(16 Color, 256 Color, 16bit color, ...) then draw my drawing (with 24bit
color pens) in it. I can create a 24bit color bitmat and select it for any
DC (CreateBitmap, SelectObject). But when I finish my drawing and save this
bitmat to disk, there is no drawing in it! I don't want this DC be visible.
Drawings is in background.

I mean, how can a program produce a 24bit color image file while is running
under 256 colors Windows mode?

Thanks very much.

Bob Daneshfar


Re:A 24bit Color bitmap


bob wrote in message <>...
>I mean, how can a program produce a 24bit color image file while is running
>under 256 colors Windows mode?

It's easy to create a pf24bit TBitmap in memory in any color mode, but it's a bit of a pain to display such a bitmap in 256 color

A 24-bit bitmap has all the color information stored in each pixel -- it doesn't need a palette.  A 24-bit image can have thousands
of colors in it.  So the challenge is to pick the best 236 colors for display in 256 color mode.  (In 256 color mode, Windows
normally reserves 20 colors for its use.)

So you need a palette to display your pf24bit bitmap in 256 color mode.  See the Show Demo One Lab Report for an example of how to
do this.  This only create a palette for display of the 24-bit bitmap, it doesn't reduce the pf24bit bitmap to a pf8bit bitmap.

For other info about palettes in Delphi, look for "Palettes" in the Color section of

For general info about palettes in Windows, look at the "Palettes" section of   In particular, look at the links to the Microsoft "Q" reports "Palette Manager:  How and
Why It Does What it Does" and "Palettes Self-Study Module."

Happy Holidays,
efg's Computer Lab:
Delphi Books:

Earl F. Glynn     E-Mail:
Overland Park, KS  USA

Other Threads