Reputation: 181
BufferedImage for some reason produces black output when I write scaled Image, however Image scales it correctly. I assume here are some problems with painting components. Thank you!
Upvotes: 2
Views: 1791
Reputation: 168795
BufferedImage newImage = new BufferedImage(400, 400, BufferedImage.TYPE_INT_RGB);
If putting a PNG or GIF with transparency over it, the transparent parts will become black. It should be:
BufferedImage newImage = new BufferedImage(400, 400, BufferedImage.TYPE_INT_ARGB);
But then, I recommend:
ImageIcon
to load an Image
, instead use ImageIO
to load a BufferedImage
.getType()
as the parameter instead of BufferedImage.TYPE_..
getScaledInstance(..)
like the plague, but if using it, specify Image.SCALE_SMOOTH
.Upvotes: 4