[Image-SIG] Please help - Overlaying image with transparent color over anothe
Wed, 6 Jun 2001 17:22:57 +0200
I am trying to overlay two images on top of each other. None of them have
transparency (normally they are RGB images) but I know which RGB color on
the top image I want to make transparent. What I have done that works most
of the time, is convert the top image to P (paletted), then search in the
palette for the color matching my RGB value, change that to black in the
palette and all the other colors in the palette to white, thus making a mask
image. Then using paste to paste the top image over the bottom image, using
my mask. This works perfect IF the top image has a valid palette.
Now sometimes the top image does not have a palette (it is equal to None).
Ho do I create a palette for it? I don't want to step through each and
every pixel in the image and build a palette from that as it is very slow.
After consulting the documentation, I have tried using histogram, but I
can't seem to get it right. It seems to me histogram gives you a list saying
color number 1 is used 10 times, color number 2 is used 13 times, etc. But
there is not even a palette, so what color is color number 1!!??. I have
tried using point, but was even more confused as to what value of the pixel
it (point) works on (it seemed to me it also works on the color number,
rather than the RGB value)!
Please, any help would be greatly appreciated!