When taking a screenshot of my scene in JavaFx, I save the BufferedImage to a file as a PNG/JPG. When I try to maximize the image size to its full length, I get Black borders on the picture from the left of the image to the bottom without the image increasing its size at all. The size of the image only increases until I set my dimensions to 1300x700 as shown below.
BufferedImage image = new BufferedImage(1300, 700, BufferedImage.TYPE_INT_RGB);
However once I increase the dimensions greater than 1300x700, the black borders appear.
The following picture is set to
BufferedImage image = new BufferedImage(1500, 900, BufferedImage.TYPE_INT_RGB);
As you can see, part of the image is still cut off and there is now a big black border next to the image rather than the actual full sized image.
The following picture is set to
BufferedImage image = new BufferedImage(1300, 700, BufferedImage.TYPE_INT_RGB);
As you can see, the image is still cut off at the same spot as before but there is no black border along side with it.
How can I fit the whole snapshot of my current scene into one file without these borders and without any of the content getting cut off?
Here is my code:
File fa = new File("test.jpg");
snapshot = quotes.getScene().snapshot(null);
RenderedImage renderedImage = SwingFXUtils.fromFXImage(snapshot, null);
BufferedImage image = new BufferedImage(1300, 700, BufferedImage.TYPE_INT_RGB);
image.setData(renderedImage.getData());
ImageIO.write(image, "jpg", fa);