-
java创建一张图片Demo.rar下载
资源介绍
java创建一张图片Demo,主要代码:
int width = 200, height = 250;
//创建图片对象
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR);
//基于图片对象打开绘图
Graphics2D graphics = image.createGraphics();
//绘制圆形
graphics.setColor(Color.BLUE);
Ellipse2D.Double ellipse = new Ellipse2D.Double(10, 10, 50, 50);
graphics.draw(ellipse);
graphics.dispose();
//将绘制好的图片写入到图片
ImageIO.write(image, "png", new File("D:/temp/1.png"));