My company has an image redaction program which opens PNG files, edits the images by drawing shapes on them, and then saves the result back out to file. Most of the images we open are in 300 dpi, and when we save them, it is important for our purposes that we maintain the dpi setting of the original image. In order to save the edited image back out to file, we use the (undocumented) Scene.renderToImage() method, and the ImageIO.Write() method. The code looks like this:
var bi: BufferedImage = Main.stage.scene.renderToImage(null) as BufferedImage;
The problem is, this always results in a PNG file with dpi set to 96 (the Windows screen setting, in other words), although the actual pixel resolution stays the same as the original image. Is there any way of controlling the dpi of the output image in JavaFX so that we can ensure that it stays the same as the original image?