This discussion is archived
3 Replies Latest reply: Aug 15, 2011 8:54 PM by DarrylBurke RSS

Controlling dpi with BufferedImage

ibibby Newbie
Currently Being Moderated
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;
ImageIO.write(bi,”png”, f))
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?



  • Correct Answers - 10 points
  • Helpful Answers - 5 points