Message-ID: <34E34724.BC1D0B5D@geocities.com> From: Keith Bonawitz MIME-Version: 1.0 Newsgroups: comp.os.msdos.djgpp Subject: Allegro BMP Color Depth Conversion Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 27 Date: Thu, 12 Feb 1998 19:02:07 GMT NNTP-Posting-Host: cs1-01.lan.ptd.net NNTP-Posting-Date: Thu, 12 Feb 1998 14:02:07 EST To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk 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? Thanks, Keith Bonawitz