JAvaコード生成ピクチャ
6358 ワード
JAVAの画像生成方法
public class Tast001 {
public static void main(String[] args) throws FileNotFoundException, IOException {
//
BufferedImage bi = new BufferedImage
(500,800,BufferedImage.TYPE_INT_RGB);//INT ,RGB , 70, 150
// ( )
Graphics2D g2 = (Graphics2D) bi.getGraphics();
g2.fillRect(0,0,500,800);// (0,0), 70, 150;
//
g2.setColor(Color.WHITE);
g2.fillRect(0,0,500,800);// ( )
g2.setColor(Color.black);
g2.drawRect(0,0,500-1,800-1); //
g2.setFont(new Font(" ",Font.BOLD,18)); // : 、 、
g2.setColor(Color.BLACK);//
g2.drawString("HelloWorld",200,50); //
ImageIO.write(bi,"JPEG",new FileOutputStream("F:/a.jpg"));// JPEG
}
}