1

I'm trying to save a snapshot of my application to disk using JavaFX 2, which should be easy considering FX comes with a built-in snapshot function. It does work, however, the image is fuzzy. The application I'm building relies greatly on getting these images to save clear and crisp. Anyone know why this happens? Or how to fix it so it saves what I'm actually seeing when the app runs?

The top image is what saved to disk, the bottom is my app running:

The top image is what saved to disk, the bottom is my app running.

My code for saving the scene is below:

try 
{
  WritableImage wi = new WritableImage((int) scene.getWidth(), (int) scene.getHeight());
  WritableImage snapshot = scene.snapshot(wi);
  File output = new File("Full.png");
  ImageIO.write(SwingFXUtils.fromFXImage(snapshot, null), "png", output);
} catch (IOException ex) {
  ex.printStackTrace();
}
Katie
  • 307
  • 1
  • 5
  • 16

1 Answers1

1

It looks as if you are running your code on a Mac with Retina display. If that is the case, the answer is here: How to save a high DPI snapshot of a JavaFX Canvas

Community
  • 1
  • 1
mipa
  • 10,369
  • 2
  • 16
  • 35
  • Ah, sorry about that. Yes, this answer works great. New to Macs, didn't realize there was such a big difference! – Katie Dec 12 '15 at 04:45