简体   繁体   中英

Increase PPI on BufferedImage

Is it possible to control the PPI (I want to increase it) on a BufferedImage? I use ImageIO.write to write the BufferedImage to a ByteArrayOutputStream.

No, not directly. A BufferedImage consists of only pixel data (raster), a sample model and a color model. It has no knowledge of PPI/DPI.

But if the format you are writing supports setting PPI/DPI, you can typically control this by passing the proper IIOMetadata along with the image to the ImageWriter when writing.

See this answer for how to do this for JPEG.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM