M
M
MOWS2017-03-28 13:47:03
Java
MOWS, 2017-03-28 13:47:03

Adding text on photo in java?

You need to add a caption to the photo. I run the code

InputStream ismain = ManagerService.class.getClassLoader().getResourceAsStream("img/Chrysanthemum.jpg");
        BufferedImage read = ImageIO.read(ismain);
        Graphics g = read.getGraphics();
        g.setFont(timesRoman1);
        g.setColor(Color.WHITE);
        g.drawString("Hellow world ",7, 55);
        g.dispose();
        ImageIO.write(read, "jpg", new File("image.jpg"));

And I get text of VERY bad quality. For example, I added text in Photoshop, and below in Java.
efc6f91c885e4b9692683bde20081bd1.png
Why are pixels so visible in Java? And when adding photoshop, no. And how to achieve smooth and beautiful text in java?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Labunsky, 2017-03-28
@MOWS

Why are pixels so visible in Java? And when adding photoshop, no. And how to achieve smooth and beautiful text in java?
Because by default drawString does not use anti-aliasing. How to enable it, you can see in the official documentation

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question