Mail Archives: djgpp/1998/02/12/22:28:58
At 07:02 2/12/1998 GMT, Keith Bonawitz wrote:
>I am using Allegro in a project that processes a bitmap to extract
>information from it. After writing the majority of the code to deal
>with 256 color bitmaps, the bitmap source changed and now they come as
>either 24-bit. How can I convert these 24-bit images to 256 color
>images? I understand that an palette has to be created that matches
>most of the colors reasonably well, but how would I go about doing
>this? I would appreciate either ready-to-use allegro extensions or a
>reference to an algorithm that could be used.
>
>The only approach I came up with on my own would be to interpret each
>color component (RGB) as a coordinated in 3-space. Then I could do a
>simulated gravitation, where two colors that are close together attract
>more strongly. This would cause similar colors to group together. If I
>left "gravity" act until there were 256 or fewer groups, I could assign
>each group an entry in the palette... Is this a feasible approach, or
>is their a better algorithm i could use?
I think you would be more likely to get a good answer if you ask on
comp.graphics.algorithms. However, I do know that the program `display' has
several 24->8 conversion algorithms, and I *think* the source is available.
Check the `graphics' directory of a Simtelnet site.
Nate Eldredge
eldredge AT ap DOT net
- Raw text -