2011-08-23 54 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