If you want to compare don't forget to include the lines: g.setColor(g.getColor()); g.fillRect(0,0,image.getWidth(),image.getHeight());
that are present in iText but not in the jframe. You'll have transparency in iText if you omit those lines. Paulo > -----Original Message----- > From: Peter van Raamsdonk [mailto:[EMAIL PROTECTED] > Sent: Wednesday, March 22, 2006 4:08 PM > To: Paulo Soares > Subject: RE: [iText-questions] Graphics2d + transparency > > Dear Paulo, > > I've read your code. > > Please check this code down below with JFrame. You can see > that the image is clearly transparent (background). Using > itext this is turned into black. > > Will you look into it? > > Greetings Peter > > public class Test { > > public static void main(String[] args) > > { > > //Test2(args); > > new Test(args); > > } > > Test(String[] args) { > > // Create a frame > > JFrame frame = new JFrame(); > > // Add a component with a custom paint method > > frame.getContentPane().add(new MyComponent()); > > // Display the frame > > int frameWidth = 300; > > int frameHeight = 300; > > frame.setSize(frameWidth, frameHeight); > > frame.setVisible(true); > > } > > class MyComponent extends JComponent { > > public void paint(Graphics g) { > > Graphics2D g2d = (Graphics2D)g; > > int x = 0; > > int y = 0; > > int width = getSize().width-1; > > int height = getSize().height-1; > > FileInputStream fileInputStream; > > try { > > fileInputStream = new FileInputStream("C:/tux.png"); > > BufferedImage image = ImageIO.read(fileInputStream); > > if (image != null && (image.getType() == > BufferedImage.TYPE_BYTE_INDEXED || image.getType() == > BufferedImage.TYPE_CUSTOM)) { > > BufferedImage bufferedImage = new > BufferedImage(image.getWidth(), image.getHeight(), > BufferedImage.TYPE_INT_ARGB); > > Graphics2D g2 = bufferedImage.createGraphics(); > > g2.drawImage(image, 0, 0, null); > > g2.dispose(); > > image = bufferedImage; > > } > > if (image != null) { > > g2d.drawImage(image, x, y, width, height, null); > > } > > } catch (Exception e) { > > e.printStackTrace(); > > } > > } > > } > > } > > > > > ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642 _______________________________________________ iText-questions mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/itext-questions
