我正在使用RenderedImage在我的应用中的DisplayJAI中显示tiff。
有人知道如何调整RenderedImage实例的大小?
答案 0 :(得分:3)
我用JAI做了很长时间,但"Scale"或"Affine"操作不够吗?
修改:以下是指向Programmer's Guide和"Scale"的"Affine"的几个链接。
答案 1 :(得分:3)
public static RenderedImage scale(RenderedImage image, float scaleFactor)
RenderingHints hints = new RenderingHints(RenderingHints.KEY_RENDERING,
RenderingHints.VALUE_RENDER_QUALITY);
RenderedOp resizeOp = SubsampleAverageDescriptor.create(image,
Double.valueOf(scaleFactor), Double.valueOf(scaleFactor), hints);
BufferedImage bufferedResizedImage = resizeOp.getAsBufferedImage();
return bufferedResizedImage;
}
答案 2 :(得分:-1)
这里有一个示例代码: http://answers.yahoo.com/question/index?qid=20090827075608AA12kEZ
相关代码:
BufferedImage img = ImageIO.read(new File("~/your/file/system/example.jpeg"));
BufferedImage thumb = new BufferedImage(w2, h2, BufferedImage.TYPE_INT_RGB);
thumb.createGraphics().drawImage(
img.getScaledInstance(w2, h2, java.awt.Image.SCALE_SMOOTH), 0, 0, null);
File file = new File(fullpath + filename);
ImageIO.write(thumb, "png", file);