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();

}

}

}

[1129 byte] By [wendxya] at [2007-11-27 3:08:20]
# 1
Found the problem. The color pallate of the original png image does not include the red color. Once added the red to the original png image color pallate. The program can show the correct colors.
wendxya at 2007-7-12 3:56:19 > top of Java-index,Security,Cryptography...