In case anyone needs the answer, iText doesn't seem to have
a way to identify colors in a Gif and set the transparency by
color.
I used an awt image and fed it to iText through the
following....
private
static
java.awt.Image makeColorTransparent(
java.awt.Image im,
final Color color) {ImageFilter filter =
new RGBImageFilter() { // the color we are looking for... Alpha bits are set to opaque public int markerRGB = color.getRGB() | 0xFF000000; public final int filterRGB(int x, int y, int rgb) { if ((rgb | 0xFF000000) == markerRGB) { // Mark the alpha bits as zero - transparent return 0x00FFFFFF & rgb;}
else { // nothing to do return rgb;}
}
};
ImageProducer ip =
new FilteredImageSource(im.getSource(), filter); return Toolkit.getDefaultToolkit().createImage(ip);}
Jim Sloey
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Sloey, James
Sent: Tuesday, May 24, 2005 1:31 PM
To: itext-questions@lists.sourceforge.net
Subject: [iText-questions] Get Image color and set Image transparent color.
Thanks to all for
the recent help.
I have one last
question regarding images.
The PDF template
I've been given has a colored background image.
Scanned gifs of
signatures on a white background are overlaid onto the PDF template.
The index number of white in
the signature.gif color map changes from image to image.
How can I find out
the color index of white so I can set white transparent?
image = Image.getInstance("/signature.gif");
image.setTransparency(/* What Goes Here? */);
I've asked a lot of questions recently and you've all offered excellent solutions.Thanks for all your help.
Jim
Sloey