PNG transparent image would not show correct color
I am trying to draw some colored string on an transparent png image (24 bit color). I tried to draw red, blue and green color
string. The string using blue and green color showed ok. But string drew in red color showed as black. Any idea what's wrong?
My test png file is saved from photoshop with transparency checked
and png-24.
Here is my test program
import java.io.*;
import java.awt.*;
import java.awt.image.*;
import javax.swing.*;
import javax.imageio.*;
public class TestPng {
public static void main(String args[]) {
try {
String imageFileName = args[0];
BufferedImage bi = ImageIO.read(new File(imageFileName));
Graphics2D g = (Graphics2D)bi.getGraphics();
g.setColor(Color.red);
g.drawString("Testing1", 10, 10);
g.setColor(Color.green);
g.drawString("Testing2", 10, 25);
g.setColor(Color.blue);
g.drawString("Testing3",10,45);
ImageIO.write(bi, "png", new FileOutputStream(args[1]));
} catch (IOException e) {
e.printStackTrace();
}
}
}

