How to write about an image [closed]

0

I found this code on the internet and made some changes, but I'm not sure what's going wrong.

Code:

public class main 
{
    public static void main(String[] args) throws IOException
    {
        String key = "Lucas Caresia";
        BufferedImage bufferedImage = ImageIO.read(new File("recibo.png"));
        Graphics graphics = bufferedImage.getGraphics();
        graphics.setColor(Color.BLACK);
        graphics.setFont(new Font("Arial Black", Font.PLAIN, 15));
        graphics.drawString(key, 420, 560);
        ImageIO.write(bufferedImage, "png", new File("recibo.jpg"));
        System.out.println("Image Created");
    }
}

Previous image:

Imageafter(viewedbyeclipse):

    
asked by anonymous 29.11.2016 / 19:49

1 answer

1

I was able to resolve only by correcting

ImageIO.write(bufferedImage, "png", new File("recibo.jpg"));

To

ImageIO.write(bufferedImage, "png", new File("recibo.png"));
    
29.11.2016 / 21:28