2011-08-23 55 views
1

我想調整一個BufferedImage的大小,這個BufferedImage是使用帶有AffineTransform對象的圖形繪製方法繪製的。Resizing BufferedImage

 AffineTransform at = new AffineTransform(); 
     at.scale(1, -1); 
     at.translate((int) xPos - xIncr, -(int)yPos); 
     ((Graphics2D) g).drawImage(line, at, null); 

我怎樣才能調整圖像大小,比我想要繪製的區域小? 感謝您的幫助。

回答

0

鑑於您已經在使用AffineTransform繪製圖像,爲什麼不直接應用另一個scale將圖像展開所需的量?

AffineTransform at = new AffineTransform(); 
at.scale(1, -1); 
at.scale(2.5, 3.0); // replace these with more appropriate scale factors 
at.translate((int) xPos - xIncr, -(int)yPos); 
((Graphics2D) g).drawImage(line, at, null); 
+0

好的,謝謝你,我想避免計算比例因子,但我想沒有選擇。謝謝。 – wotan2009