import java.io.*;
import java.awt.*;
import java.awt.image.*;
import javax.imageio.*;
public class Java2DTest1
{
public static void main(String args[])
throws Exception
{
/* 以下のコードだとVMごと落ちる。。
http://bugs.sun.com/bugdatabase/view_bug.do;jsessionid=f12925b11cbbb174e5ed576d2149?bug_id=4886506
BufferedImage img = ImageIO.read(new File("sf.jpg"));
RescaleOp ro = new RescaleOp(0.5f, 0.0f, null);
BufferedImage img2 = ro.filter(img, img2);
ImageIO.write(img, "png", new File("sample474a.png"));
*/
BufferedImage img = ImageIO.read(new File("sf.jpg"));
BufferedImage img2 = new BufferedImage(
img.getWidth(), img.getHeight(), BufferedImage.TYPE_INT_BGR
);
Graphics2D gr = img2.createGraphics();
gr.drawImage(img,0,0,null);
gr.dispose();
RescaleOp ro = new RescaleOp(0.5f, 0.0f, null);
BufferedImage img3 = ro.filter(img2, null);
ImageIO.write(img3, "png", new File("sample474a.png"));
}
}
元画像(sf.jpg)
出力画像(sample474a.png)
環境
JDK6 Upadate6(JDK1.6.0_06)
No comments:
Post a Comment