import java.io.*;
import java.awt.*;
import java.awt.image.*;
import javax.imageio.*;
public class Java2DTest2
{
public static void main(String args[])
throws Exception
{
/* 画像をリサイズ */
BufferedImage img = ImageIO.read(new File("sf.jpg"));
BufferedImage img2 = new BufferedImage(
110, 110, BufferedImage.TYPE_INT_BGR
);
Graphics2D gr = img2.createGraphics();
gr.drawImage(img, 0, 0, img2.getWidth(), img2.getHeight(), null);
gr.dispose();
ImageIO.write(img2, "png", new File("sample482a.png"));
}
}
元画像(sf.jpg)
出力画像(sample482a.png)
環境
JDK6 Upadate6(JDK1.6.0_06)
No comments:
Post a Comment