View RSS Feed

Java AWT

Drawing an Image

Rate this Entry
by , 03-07-2012 at 05:00 PM (498 Views)
Graphics.drawImage method is used to draw the images at a specific location:
Java Code:
boolean Graphics.drawImage(Image img,
                           int x, int y,
                           ImageObserver observer);
Top left position of an image is specified by x,y location. Observer parameters are usually null as they are not used frequently or directly & is also not required for BufferedImage.

This method is used just when there is a need to draw the entire image or mapping the image pixels. Sometimes just a portion of image needs to be drawn or scale the image or filter the image.

The drawImage() methodís overloads perform these actions and operations. E.g. the given overload makes you able to draw specified area of specified image as much as it is available currently.
Java Code:
boolean Graphics.drawImage(Image img,
           int dstx1, int dsty1, int dstx2, int dsty2,
           int srcx1, int srcy1, int srcx2, int srcy2,
           ImageObserver observer);

Submit "Drawing an Image" to Facebook Submit "Drawing an Image" to Digg Submit "Drawing an Image" to del.icio.us Submit "Drawing an Image" to StumbleUpon Submit "Drawing an Image" to Google

Categories
Graphics

Comments