Re:Saving 256+ color Bitmaps
Demian:
Quote
Demian Lessa wrote in message <74kb4g$a...@forums.borland.com>...
>I've been having problems writing bitmaps with more than 256 colors to
>a database table. I compile my project with the VCL source and noticed that
>TBitmap.WriteStream messes up with the number of colors and writes the bitmap
>header incorrectly to the database table. Has anyone experienced the same
>problem?
Without seeing what you're doing, the following is just a guess.
If you're working in 256 color mode, and create a bitmap without specifying a PixelFormat, the bitmap has PixelFormat of pfDevice,
which is 256 color. If you have high color or true color bitmaps, these bitmap do not have palettes since each pixel contains all
the necessary color information. If you want to display a high color or true color bitmap in 256 color mode, you need a palette.
For an example of how to get a palette (for display only), take a look at the Show Demo One Lab Report:
www.efg2.com/lab/Graphics/Colors/ShowDemoOne.htm
While the above program allows you to display a pf24bit bitmap in 256 color mode, it does not take the next step of converting the
pf24bit Scanline to a pf8bit Scanline -- which are just indices into the palette table. For such a conversion, you might want to
take a look at Section B, Color Quantization, at www.efg2.com/lab/library/color.htm. In particular, look for "Octree Color
Quantization" for a C++ program that actually reduces 24-bit bitmaps to 8-bit bitmaps with the appropriate palettes.
But, your problems may go away if you just use high color or true color display modes with your monitor. I'd get away from palettes
as soon as possible. They're unnecessary complex, and someday all the palette operations will become "No ops" when high color and
true color becomes the "low end."
If you have a specific problem, you might want to post a small code fragment showing the problem.
efg
_________________________________
efg's Computer Lab: www.efg2.com/lab
Delphi Books: www.efg2.com/lab/TechBooks/Delphi.htm
Earl F. Glynn E-Mail: EarlGl...@att.net
Overland Park, KS USA