Write Image with different types
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.geom.Ellipse2D;
import java.awt.image.BufferedImage;
import java.io.File;
import javax.imageio.ImageIO;
public class Main {
static public void main(String args[]) throws Exception {
int width = 200, height = 200;
BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
Graphics2D g2d = bi.createGraphics();
g2d.fillRect(0, 0, width - 1, height - 1);
BasicStroke stroke = new BasicStroke(10, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
g2d.setPaint(Color.lightGray);
g2d.setStroke(stroke);
g2d.draw(new Ellipse2D.Double(0, 0, 100, 100));
ImageIO.write(bi, "GIF", new File("a.gif"));
}
}
Related examples in the same category