When I add a partially transparent image to a PDF, I'm getting grey/black edges along the mask border. Am I missing something to help guide the calculations? (Something document-level along the lines of PdfWriter.setRGBTransparency, but not that?)
In this example, I add a yellow oval as a raw image, and then add it to a white document. The background of the image is transparent black, and I see gray or black (depending on scale) border in the resulting PDF. (I could change the background to transparent white in this case, but won't always be adding my images over a solid color.) // create image, transparent black BufferedImage bi = new BufferedImage(400, 400, BufferedImage.TYPE_INT_ARGB); // draw pale yellow oval Graphics2D g = bi.createGraphics(); g.setColor(new Color(255, 255, 128, 255)); g.fillOval(0, 0, 400, 400); g.dispose(); // add to PDF Image i = Image.getInstance(bi, null); i.setAbsolutePosition(100, 400); writer.getDirectContent().addImage(i); The resulting PDF shows the yellow oval with the mentioned border. The data contains the RGB image and the grayscale smask: 1 0 obj <</Type/XObject/ColorSpace/DeviceGray/Subtype/Image/BitsPerComponent 8/Width 400/Length 1555/Height 400/Filter/FlateDecode>>stream 2 0 obj <</Type/XObject/ColorSpace/DeviceRGB/SMask 1 0 R/Subtype/Image/BitsPerComponent 8/Width 400/Length 2593/Height 400/Filter/FlateDecode>>stream I came across the following thread on implementing this feature: http://www.mail-archive.com/[email protected]/msg42290.html but it doesn't appear that these images are getting JPG compressed, so there shouldn't be any loss of alpha data? Any pointers greatly appreciated. Thanks, Michael Brewer-Davis ------------------------------------------------------------------------------ This SF.net email is sponsored by Make an app they can't live without Enter the BlackBerry Developer Challenge http://p.sf.net/sfu/RIM-dev2dev _______________________________________________ iText-questions mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.itextpdf.com/book/ Check the site with examples before you ask questions: http://www.1t3xt.info/examples/ You can also search the keywords list: http://1t3xt.info/tutorials/keywords/
