如何缩放缓冲图像在javadocs之后,我尝试将BufferedImage没有成功,这是我的代码:BufferedImage image = MatrixToImageWriter.getBufferedImage(encoded);Graphics2D grph = image.createGraphics();grph.scale(2.0, 2.0);grph.dispose();我不明白它为什么不起作用,有什么帮助吗?
3 回答
慕少森
TA贡献2019条经验 获得超9个赞
AffineTransformOp
BufferedImage before = getBufferedImage(encoded);int w = before.getWidth();int h = before.getHeight();BufferedImage after = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);AffineTransform at = new AffineTransform();at.scale(2.0, 2.0);AffineTransformOp scaleOp = new AffineTransformOp(at, AffineTransformOp.TYPE_BILINEAR);after = scaleOp.filter(before, after);
慕哥6287543
TA贡献1831条经验 获得超10个赞
BufferedImage resized = new BufferedImage(newWidth, newHeight, original.getType());Graphics2D g = resized.createGraphics();g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);g.drawImage(original, 0, 0, newWidth, newHeight, 0, 0, original.getWidth(), original.getHeight(), null);g.dispose();
int newWidth = new Double(original.getWidth() * widthFactor).intValue();int newHeight = new Double(original.getHeight() * heightFactor).intValue();
编辑
添加回答
举报
0/150
提交
取消