2016-08-15 66 views
0

我有以下類如何將分辨率降低到沒有寬鬆dpi的圖像?

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(); 
} 

,但最終的結果,我輸在1 DPI我怎麼能保持dpi的圖像中?

回答

1

Dpi是每英寸點數的縮寫,並且支持圖像的質量。所以,當你改變圖像的分辨率時,你會失去該圖像原始尺寸的圖像的dpi(每英寸點數)(因爲你失去了質量!)。 因此,這是不可能的!