How to obtain the right 256 color pallette for the blend of two colors...?  
Author Message
SammyBar





PostPosted: 2006-10-20 21:41:00 Top

java-programmer, How to obtain the right 256 color pallette for the blend of two colors...? Hi all,

I have the following problem: I need to generate dynamically an image with
IndexColorModel (256 color PNG) of a text over a solid color. The parameters
are color foreground for the text and background. The problem is how to
select the most appropriate 256 color pallette for the text to look best. I
mean the text should be antialiased and any other hint applied. For example,
If I pick black on yellow image I think it should have all the tones of
black and yellow. Any red color will be useless and it will be lost space on
the reduced 256 color pallette. But in this example the red could be a good
choice for the transparent color...
How to solve this problem?
I guess I need some background on colors (theory of colors?) Any hint is
welcomed.
Thanks in advance
Sammy


 
Oliver Wong





PostPosted: 2006-10-20 23:22:00 Top

java-programmer >> How to obtain the right 256 color pallette for the blend of two colors...?
"SammyBar" <email***@***.com> wrote in message
news:4538d1e7$0$97215$email***@***.com...
> Hi all,
>
> I have the following problem: I need to generate dynamically an image
> with IndexColorModel (256 color PNG) of a text over a solid color. The
> parameters are color foreground for the text and background. The problem
> is how to select the most appropriate 256 color pallette for the text to
> look best. I mean the text should be antialiased and any other hint
> applied. For example, If I pick black on yellow image I think it should
> have all the tones of black and yellow. Any red color will be useless and
> it will be lost space on the reduced 256 color pallette. But in this
> example the red could be a good choice for the transparent color...
> How to solve this problem?
> I guess I need some background on colors (theory of colors?) Any hint is
> welcomed.

256 colour PNGs only support single bit transparency (as opposed to
alpha transparancy). If you need a transparent colour, then assign any
arbitrary colour to the transparent one (e.g. colour 0 in the palette
index), and then you have the exact same problem as before, except you need
to assign 255 colours, instead of 256.

If it's a single colour text on a single colour background (e.g. black
on yellow), then simply assign the 255 colours to be a steady gradient from
black to yellow.

- Oliver