0

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 :

enter image description here

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 ?

Simon
  • 2,208
  • 4
  • 32
  • 47
  • 1
    jpg is lossy have you tried a png? Also see [How to draw a crisp, opaque hairline in JavaFX 2.2?(http://stackoverflow.com/questions/11886230/how-to-draw-a-crisp-opaque-hairline-in-javafx-2-2) – jewelsea Aug 12 '14 at 12:30
  • yes @jewelsea, I had seen this, but could not find how to adapt it to raw GraphicsContext calls. – Simon Aug 12 '14 at 14:59

0 Answers0