Drawing an Image
by, 03-07-2012 at 06:00 PM (448 Views)
Graphics.drawImage method is used to draw the images at a specific location:
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.Java Code:boolean Graphics.drawImage(Image img, int x, int y, ImageObserver observer);
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);