跟随javadocs,我尝试扩展a BufferedImage而不成功,这是我的代码:
javadocs
a BufferedImage
BufferedImage image = MatrixToImageWriter.getBufferedImage(encoded); Graphics2D grph = image.createGraphics(); grph.scale(2.0, 2.0); grph.dispose();
我不明白为什么它不起作用,有帮助吗?
AffineTransformOp 提供了选择插值类型的额外灵活性。
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);
显示的片段说明了重采样,而不是裁剪 ; 这个相关的答案解决了这个问题 ; 这里考察一些相关的例子。