All About Class Image in AWT in Java

0
189
Spread the love
  • 24
  • 34
  • 28
  • 35
  •  
  •  
  •  
  • 12
  •  
  •  
    133
    Shares

Class Image in AWT in Java:

Please read this article on Image basics here. The abstract class Image is the superclass of all classes that represent graphical images. With Image class, we can load an image object that obtains its pixel data from a specified URL.

Image abstract class represents a displayable image in a platform-independent way. An Image object may not be instantiated directly through a constructor, it must be obtained through a call like Applet.getImage() or Component.createImage().getSource() method returns the ImageProducer object that produces the image data.

getGraphics() returns a Graphics object that can be used for drawing into offscreen images (but not images that offscreen are downloaded or generated by an ImageProducer).

The structure of the class is given below:

public abstract class java.awt.Image extends java.lang.Object{
//member element:
public static final int SCALE_AREA_AVERAGING;
public static final int SCAL_DEFAULT;
public static final int SCALE_FAST;
public static final int SCALE_REPLICATE;
public static final int SCALE_SMOOTH;
public final static Object UndefinedProperty;
//The UndefinedProperty Object should be returned whenever a property which was defined for a particular
//image is fetched.
//constructor
public Image();//default constructor
//Methods:
public abstract void flush();
public abstract Graphics getGraphics();
public abstract int getHeight(ImageObserver observer);
public abstract Object getProperty(String name,ImageObserver observer);
public abstract ImageProducer getSource();
public abstract int getWidth(ImageObserver observer);
public Image getScaledInstance (int width, int height, int hints);
}
 

Applet class has the following methods to work with images:


public image getImage(URL url);//returns an image object given an URL
public image getImage(URL url,String name);//Returns an image object with the URL and the name specified.
 
Don't miss out!
Subscribe To Newsletter

Receive top technical news, lesson ideas, travel tips and more!

Invalid email address
Give it a try. You can unsubscribe at any time.

Spread the love
  • 24
  • 34
  • 28
  • 35
  •  
  •  
  •  
  • 12
  •  
  •  
    133
    Shares

LEAVE A REPLY

Please enter your comment!
Please enter your name here