ImageIO: write(RenderedImage im, String formatName, File output) : ImageIO « javax.imageio « Java by API






ImageIO: write(RenderedImage im, String formatName, File output)

  


import java.awt.Color;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.File;

import javax.imageio.ImageIO;

public class Main {
  final static int WIDTH = 50;
  final static int HEIGHT = 50;
  final static int NUM_ITER = 1500;

  public static void main(String[] args) throws Exception {
    BufferedImage bi;
    bi = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_RGB);
    Graphics g = bi.getGraphics();
    for (int i = 0; i < NUM_ITER; i++) {
      g.setColor(Color.RED);
      g.drawLine(1, 2, i, i + 1);
    }
    g.dispose();
    ImageIO.write(bi, "gif", new File("image.gif"));
  }
}

   
    
  








Related examples in the same category

1.ImageIO: createImageInputStream(Object input)
2.ImageIO: getImageReaders(Object input)
3.ImageIO: getImageReadersByFormatName(String formatName)
4.ImageIO: getImageReadersByMIMEType(String MIMEType)
5.ImageIO: getImageReadersBySuffix(String fileSuffix)
6.ImageIO: getImageWritersByFormatName(String formatName)
7.ImageIO: getImageWritersByMIMEType(String MIMEType)
8.ImageIO: getImageWritersBySuffix(String fileSuffix)
9.ImageIO: getReaderFormatNames()
10.ImageIO: getReaderMIMETypes()
11.ImageIO: getWriterFormatNames()
12.ImageIO: getWriterMIMETypes()
13.ImageIO: read(File input)
14.ImageIO: read(URL input)