Hi Chris, Very sorry I wasn't able to get back online for the last few days and respond to this.
I just wanted to let you know that your solution works perfectly and in as little code as I had expected to have to write before I ran into the BufferedImage mess. Many thanks for your help. I wonder why all my googling failed to turn up the Java2D faq as the answer is plainly there? Oh well. Thanks, Doug > Hi Doug, > > First, it's best to avoid getScaledInstance(); there > are better/faster > ways to do what you want (see the Java 2D FAQ [1]). > Second, in order to > preserve the transparency from your original image, > you'll need to call > g2d.setComposite(AlphaComposite.Src) before copying > the original into > the new image. > > Allow me to suggest some code that will resolve both > of the above issues > in fewer steps: > > BufferedImage in = ImageIO.read(srcFile); > GraphicsConfiguration gc = > > in.createGraphics().getDeviceConfiguration(); > BufferedImage out = > gc.createCompatibleImage(targetWidth, > getWidth, targetHeight, BITMASK); > Graphics2D g2d = out.createGraphics(); > g2d.setComposite(AlphaComposite.Src); > g2d.drawImage(in, 0, 0, targetWidth, > idth, targetHeight, null); > g2d.dispose(); > ImageIO.write(out, "png", destFile); > > Thanks, > Chris > > [1] > http://java.sun.com/products/java-media/2D/reference/f > aqs/index.html#Q_How_do_I_create_a_resized_copy > [Message sent by forum member 'seattledoug' (seattledoug)] http://forums.java.net/jive/thread.jspa?messageID=119026 =========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA2D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".
