At 8:22 AM +0100 16-03-00, David Oakley wrote:
>Do something like
>
>red = (red/51)*51;
>green = (green/51)*51;
>blue = (blue/51)*51;
>
>as long as the vars are integers, and things go a whole lot faster. The
>price is that you'll miss the opportunity to use some of the intermediate
>greys and other extra colours.


This should work great as long as you're sure you're using the the default
8-bpp palette.

To get the rest intermediate grays, you could first check if red = green
and red = blue, then do the same rounding trick only with 17 instead of 51.
(The grays are 0x00, 0x11, 0x22, 0x33, 0x44, ... 0xFF)

Also you'll get slightly better results if you round instead of truncate.
That is:

        red = ((red+25)/51)*51

If you don't do this, then you'll always lean towards brighter colors.
e.g. only real black will ever translate to RGB 0xFF/0xFF/0xFF = index 255.


                        --Bob



-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palm.com/devzone/mailinglists.html

Reply via email to