Reputation: 31
it is can by see pdf.png in the new Picture, but can't see the String "Hello" in the new Picture
public void generateImage() throws Exception{
int width = 220;
int height = 50;
BufferedImage image = new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB);
Graphics g = image.getGraphics();
g.setColor(new Color(255,255,255));
g.fillRect(0, 0, width, height);
Font font = new Font("宋体",Font.BOLD,10);
g.setFont(font);
BufferedImage image2 = ImageIO.read(new File("data/icon/pdf.png"));
g.drawImage(image2, 0, 0, 44, 42, null);
g.drawString("Hello", 50, 5);
g.dispose();
File f = new File("data/icon/"+fileName+".png");
FileOutputStream fos = new FileOutputStream(f);
ImageIO.write(image,"PNG",fos);
fos.close();
}
Upvotes: 0
Views: 307
Reputation: 205875
It looks like you are setting the color to white and never setting any other color. The result is extremely low contrast.
Upvotes: 2
Reputation: 25950
g.drawString("Hello", 50, 5);
On this line manipulate the coordinate values, i.e. 50 and 5, and test whether the text "Hello" appears.
Upvotes: 2