I am using JavaFX to create preview images of my Android application scores.
However, the quality of the output is not as good as I would like, ie fuzzy around the edges.
Here is an example :
To produce this, I create a canvas with a specific size -
Canvas cv = new Canvas(iWidth, iHeight);
I then get the score to draw itself -
score.draw(cv);
and then write out the image to a jpeg file -
Image fxImage = cv.getJavaFxCanvas().snapshot(new SnapshotParameters(), null);
BufferedImage bufimg = SwingFXUtils.fromFXImage(fxImage, null);
BufferedImage bufImgRgb = new BufferedImage(bufimg.getWidth(), bufimg.getHeight(), BufferedImage.OPAQUE);
Graphics2D graphics = bufImgRgb.createGraphics();
graphics.drawImage(bufimg, 0, 0, null);
ImageIO.write(bufImgRgb, "jpg", new File(m_strDefaultOutputDir + "\\test.jpg"));
graphics.dispose();
I have searched, but have not be able to see what is necessary to do to increase the crispness of the drawn image.
To draw text, for example, I am calling
graphicscontext.fillText(m_strText, x, y);
If I add a call to strokeText, the text gets bloated without any clear improvement in crispness.
Lines are drawn with
graphicscontext.strokeLine(fX1, fY1, fX2, fY2);
after having set the stroke width to 1 and still the lines are not crisp.
How can I create good, high quality image generation ?