delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/02/12/22:28:58

Date: Thu, 12 Feb 1998 19:27:56 -0800 (PST)
Message-Id: <199802130327.TAA12223@adit.ap.net>
Mime-Version: 1.0
To: Keith Bonawitz <aule AT geocities DOT com>, djgpp AT delorie DOT com
From: Nate Eldredge <eldredge AT ap DOT net>
Subject: Re: Allegro BMP Color Depth Conversion

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019