delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/02/12/14:15:37

Message-ID: <34E34724.BC1D0B5D@geocities.com>
From: Keith Bonawitz <aule AT geocities DOT com>
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
Subject: Allegro BMP Color Depth Conversion
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

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

- Raw text -


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