1个回答
展开全部
可以用 java.awt.geom.AffineTransform , 具体方法如下.
(width是新的长度,height是新的高度,image是改变大小之后的图片,source是原本从文件中读入的图片)
int width = 640;
int height = 380;
BufferedImage image = new BufferedImage(width, height,
BufferedImage.TYPE_INT_RGB);
Graphics2D g = image.createGraphics();
AffineTransform at = AffineTransform.getScaleInstance(
(double) width / source.getWidth(),
(double) height / source.getHeight());
g.drawRenderedImage(source, at);
(width是新的长度,height是新的高度,image是改变大小之后的图片,source是原本从文件中读入的图片)
int width = 640;
int height = 380;
BufferedImage image = new BufferedImage(width, height,
BufferedImage.TYPE_INT_RGB);
Graphics2D g = image.createGraphics();
AffineTransform at = AffineTransform.getScaleInstance(
(double) width / source.getWidth(),
(double) height / source.getHeight());
g.drawRenderedImage(source, at);
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询