Board index » delphi » 16 million colors to 256 colors

16 million colors to 256 colors

I need to convert a TBitmap from a 16 million colors file to a 256 colors
file.
More than that, I need to know how to create a palette from a 16 million
color file, since this palette isn't the system palete, how to choose the
best colors for this palette?

Padu

 

Re:16 million colors to 256 colors


Padu - Paulo Eduardo Merloti wrote in message <753fn1$mf...@forums.borland.com>...

Quote
>I need to convert a TBitmap from a 16 million colors file to a 256 colors
>file.
>More than that, I need to know how to create a palette from a 16 million
>color file, since this palette isn't the system palete, how to choose the
>best colors for this palette?

I can directly help you with the second part:  creating a palettes for a 24-bit color bitmap for display in 256 color mode.  This is
explained in the ShowDemoOne Lab Report:
www.efg2.com/lab/Graphics/Colors/ShowDemoOne.htm

A separate Lab Report shows what to do get get the best palette for display of multiple images:
www.efg2.com/lab/Graphics/Colors/ShowDemoMany.htm

If you want to create a pf8bit bitmap from a pf24bit bitmap, there is C code to do this via a link.  In Section B, Color
Quantization, look for the Octree Color Quantization article by I. Ashdown:
www.efg2.com/lab/library/Color.htm

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

Re:16 million colors to 256 colors


If you have the time (in the app) find which 256 colors are the most used.
If the pic is not flat (in this case if 256 colors covers most of the colors
in the pic 1:1) then your sitting pretty. If not then you have to decide how
to convert colors which are not in the palette. One method is to use only
200 or so colors and assign the rest as blend colors, or you can go to the
"trouble" to find the best color in the palette that matches the color not
in the pallet. For example, a RGB of 200, 200, 200 is pretty close to 200,
201, 200. This though can differ if you want to use a color model other than
straight RGB (like LUV, etc.). An advanced method would be find a blending
palette which is some defined color distance from a mid point of a color
which covers more points than a single color would. All methods are of
course approx and the data of pic your converting has a big efect on the
map. (if the pic has 100s of shades of a color you might waste palette
colors, same if there are many shades of any primary color). This is not
easy, but good luck.
Padu - Paulo Eduardo Merloti <p...@axiomabr.com> wrote in message
news:753fn1$mfo13@forums.borland.com...
Quote
>I need to convert a TBitmap from a 16 million colors file to a 256 colors
>file.
>More than that, I need to know how to create a palette from a 16 million
>color file, since this palette isn't the system palete, how to choose the
>best colors for this palette?

>Padu

Re:16 million colors to 256 colors


I would download the rx library.  It has a unit called rxgraphics which
contains the code for dithering colours down to 256.

Quote
> Padu - Paulo Eduardo Merloti <p...@axiomabr.com> wrote in message
> news:753fn1$mfo13@forums.borland.com...
> >I need to convert a TBitmap from a 16 million colors file to a 256
colors
> >file.
> >More than that, I need to know how to create a palette from a 16 million
> >color file, since this palette isn't the system palete, how to choose
the
> >best colors for this palette?

> >Padu

Other Threads