ImageIO: read(File input) : ImageIO « javax.imageio « Java by API






ImageIO: read(File input)

  

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

import javax.imageio.ImageIO;
import javax.swing.JFrame;

public class Main extends JFrame {

  private BufferedImage bi;

  public static void main(String[] args) {
      new Main ().setVisible(true);
  }

  public Main () {
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    try {
      bi = ImageIO.read(new File("your.jpg"));
    } catch (Exception e) {
      e.printStackTrace();
    }

    setSize(bi.getWidth(), bi.getHeight());
  }

  public void paint(Graphics g) {
    g.drawImage(bi, 0, 0, getWidth(), getHeight(), this);
  }
}

   
    
  








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(URL input)
14.ImageIO: write(RenderedImage im, String formatName, File output)