简体   繁体   English

如何在不降低dpi分辨率的情况下降低图像分辨率?

[英]how to reduce the resolution to an image without loose dpi?

I have the following class 我有以下课程

public void resize(InputStream input, OutputStream output, int width, int height) throws IOException {
    BufferedImage src = ImageIO.read(input);
    BufferedImage dest = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
    Graphics2D g = dest.createGraphics();

    AffineTransform at = AffineTransform.getScaleInstance((double)width / src.getWidth(), (double)height / src.getHeight());
    g.drawRenderedImage(src, at);
    ImageIO.write(dest, "tif", output);
    output.close();
}

but in the final result, I lose dpi at 1. how i can keep the dpi in the image? 但最终结果是,我的dpi丢失了1.如何保持图像中的dpi?

Dpi is abbreviate of dot per inch and backs to the quality of an image. Dpi是每英寸点数的缩写,表示图像的质量。 So, when you change the resolution of an image, you'll loose dpi (dot per inch) of the image in the original size of that image (because you loose the quality!). 因此,当您更改图像的分辨率时,您将以该图像的原始大小放宽图像的dpi(每英寸点数)(因为会降低质量!)。 Hence, it's not possible! 因此, 这是不可能的!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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