Images

Java images are bitmapped GIF or JPEG files that can contain pictures of just about anything. You can use any program at all to create them as long as that program can save in GIF or JPEG format.

Once loaded into Java, images, whether GIF or JPEG, become instances of the abstract java.awt.Image class. The Image class has these eight methods:

  public Image()
  public abstract int getWidth(ImageObserver observer)
  public abstract int getHeight(ImageObserver observer)
  public abstract ImageProducer getSource()
  public abstract Graphics getGraphics()
  public abstract Object getProperty(String name, ImageObserver observer)
  public Image getScaledInstance(int width, int height, int hints)
  public abstract void flush()
However, most of the work with images takes place in other classes, particularly java.awt.Graphics, java.awt.Component, and java.awt.Toolkit. You pass to an Image object to methods in these classes to load and display the image.


Previous | Next | Top
Last Modified March 31, 1997
Copyright 1997 Elliotte Rusty Harold
elharo@metalab.unc.edu