Here is a string representation of the ColorModel linked image when loading through ImageIO :
IndexColorModel: #pixelBits = 1 numComponents = 4 color space = java.awt.color.ICC_ColorSpace@1572e449 transparency = 2 transIndex = 1 has alpha = true isAlphaPre = false
If I understand this correctly, you have one bit per pixel, where bit 0 opaque and bit 1 is transparent. Your BufferedImage initially all black, so applying a mixture of black and transparent pixels to it will have no effect.
Although you use AlphaComposite.Src , this will not help, since the R / G / B values ββfor writing a transparent palette are considered to be zero (I'm not sure if this is encoded in GIF or just by default in JDK.)
You can get around this:
- Initializing a
BufferedImage with All White Pixels - Using
AlphaComposite.SrcOver
So, the last part of your resize2D implementation will look like this:
// Paint image. Graphics2D g2d = bi.createGraphics(); g2d.setColor(Color.WHITE); g2d.fillRect(0, 0, size, size); g2d.setComposite(AlphaComposite.SrcOver); g2d.drawImage(srcImage, tx, null);
finnw source share