[Magick-bugs] TransparentImage
Marko Mahnic
marko.mahnic at email.si
Tue May 8 02:12:30 PDT 2007
Hi.
I am using ImageMagick++. There seems to be a change in
the behaviour of Image.transparent(color) between the
versions 6.2.? and 6.3.0.
Here is an example that reads a template tiff image, creates
a transparent background and changes the color of content
(which is black in the template image test.tif) to the desired color.
The pixel(0,0) defines the BG/transparent color.
Image img;
img.read("test.tif");
Color coTrans = img.pixelColor(0, 0);
img.transparent(coTrans);
Color coContent("black");
Color coDesired("red");
img.opaque(coContent, coDesired);
img.write("painted.tif");
This used to work in 6.2, but in 6.3 transparent() converts
all pixels to black. Since this might be handy sometimes,
I am OK with that. So I tried a differnt approach:
Color coMakeTrans = coTrans;
coMakeTrans.alpha(1.0);
img.opaque(coTrans, coMakeTrans);
Now this is what I consider a bug: instead of just setting the
alpha channel for transparent pixels, all the background pixels
are turned to transparent AND black. Afterwards the complete image
becomes red.
So I had to find this workaround, but I do not like it:
Color coMakeTrans = coTrans;
coMakeTrans.alpha(0.999);
img.opaque(coTrans, coMakeTrans);
Marko
More information about the Magick-bugs
mailing list