0

What I want to do is take a screenshot of the scene, I achieved this with the following code

    WritableImage snapshot = stage.getScene().snapshot(null);
    File file = new File("src//HE//Utilidades//Imagenes//consul.png");
    try {
        ImageIO.write(SwingFXUtils.fromFXImage(snapshot, null), "png", file);
        //this is for open the screenshot
        Desktop dt = Desktop.getDesktop();
        dt.open(file);

    } catch (IOException e) {
        e.printStackTrace();
    }

The screenshot is perfect the problem I have is with the quality of the screenshot , which i dont know of what dependents , I try to make the scene bigger but the quality of dpi remains the same (70) creating a very unpleasant image, i'm looking a way to improve the dpi of the screenshot at least 300dpi for printing

this is the quality that i get

CorrOrtiz
  • 168
  • 1
  • 2
  • 17

1 Answers1

2

A simple sceenshot is a screenshot and not a high-resolution rendering of your scene. You will not be able to get more pixels into your image than there are on your screen. So unless you have a 300 DPI screen, then what you want is not possible with a simple screenshot.

If you want a higher resolution image of your scene then you have to use other techniques like offscreen rendering. An example can be found here:

http://www.ambracode.com/index/show/1217604

pfried
  • 5,000
  • 2
  • 38
  • 71
mipa
  • 10,369
  • 2
  • 16
  • 35
  • offscreen rendering result in the same quality in dpi of the snapshot it has something to do with the snapshot method it occurs to me that maybe working with the WritableImage i can improve the quality but i don't know how – CorrOrtiz Mar 14 '16 at 03:13
  • No, with offscreen rendering you can achieve any DPI you like but you have to up-scale your scene accordingly of course. – mipa Mar 14 '16 at 07:39
  • @mipa The link is broken. – MikaelF Oct 04 '17 at 22:48