From: Matan Ziv-Av (matan@svgalib.org)
Date: Thu 18 Jul 2002 - 09:51:11 IDT
On Wed, 17 Jul 2002, [BIG5] §º¥K¤¯ wrote:
> If I use 16M color mode.
> How I convert 16M color to 256 color.
> I know use gl_getpixelrgb serial function to get rgc color.
> Then I don't how to do.
Sergio answered this. I'll just add that doing this is not a simple
matter, and unless you are willing to learn a lot about this
(quantizing, dithering), I suggest using someone else's code.
The easiest is ImageMagick, which is available as a library, and has
code for this (see man 5 quantize). If you don't want this library, try
looking in libjpeg at jquant1.c and jquant2.c, where the code is pretty
much self explanatory.
> Convert 16M color to 256 gray I average rgb color (ex : gray = (r+g+b)/3 ).
> Is it a right method?
This is not correct since the colors have different brightness (maximum
green is brighter than maximum blue). The usual equation is
gray=(30*r+59*g+11*b)/100
--
Matan Ziv-Av. matan@svgalib.org
------------------------------------------------------------------
Unsubscribe: To: listbot@svgalib.org
Body: unsubscribe linux-svgalib
This archive was generated by hypermail 2.1.4 : Wed 21 Jan 2004 - 22:10:25 IST