Graphics.drawImage

Graphics.drawImage

Class Overview | Class Members | This Package | All Packages

Syntax 1
public abstract boolean drawImage( Image img, int x, int y, ImageObserver observer )
Parameters
img
the specified image to be drawn.
x
the x coordinate.
y
the y coordinate.
observer
object to be notified as more of the image is converted.
Description
Draws as much of the specified image as is currently available. The image is drawn with its top-left corner at (xy) in this graphics context's coordinate space. Transparent pixels in the image do not affect whatever pixels are already there.

This method returns immediately in all cases, even if the complete image has not yet been loaded, and it has not been dithered and converted for the current output device.

If the image has not yet been completely loaded, then drawImage returns false. As more of the image becomes available, the process that draws the image notifies the specified image observer.

See Also
Image, ImageObserver, imageUpdate



Syntax 2
public abstract boolean drawImage( Image img, int x, int y, int width, int height, ImageObserver observer )
Parameters
img
the specified image to be drawn.
x
the x coordinate.
y
the y coordinate.
width
the width of the rectangle.
height
the height of the rectangle.
observer
object to be notified as more of the image is converted.
Description
Draws as much of the specified image as has already been scaled to fit inside the specified rectangle.

The image is drawn inside the specified rectangle of this graphics context's coordinate space, and is scaled if necessary. Transparent pixels do not affect whatever pixels are already there.

This method returns immediately in all cases, even if the entire image has not yet been scaled, dithered, and converted for the current output device. If the current output representation is not yet complete, then drawImage returns false. As more of the image becomes available, the process that draws the image notifies the image observer by calling its imageUpdate method.

A scaled version of an image will not necessarily be available immediately just because an unscaled version of the image has been constructed for this output device. Each size of the image may be cached separately and generated from the original data in a separate image production sequence.

See Also
Image, ImageObserver, imageUpdate



Syntax 3
public abstract boolean drawImage( Image img, int x, int y, Color bgcolor, ImageObserver observer )
Parameters
img
the specified image to be drawn.
x
the x coordinate.
y
the y coordinate.
bgcolor
the background color to paint under the non-opaque portions of the image.
observer
object to be notified as more of the image is converted.
Description
Draws as much of the specified image as is currently available. The image is drawn with its top-left corner at (xy) in this graphics context's coordinate space. Transparent pixels are drawn in the specified background color.

This operation is equivalent to filling a rectangle of the width and height of the specified image with the given color and then drawing the image on top of it, but possibly more efficient.

This method returns immediately in all cases, even if the complete image has not yet been loaded, and it has not been dithered and converted for the current output device.

If the image has not yet been completely loaded, then drawImage returns false. As more of the image becomes available, the process that draws the image notifies the specified image observer.

See Also
Image, ImageObserver, imageUpdate



Syntax 4
public abstract boolean drawImage( Image img, int x, int y, int width, int height, Color bgcolor, ImageObserver observer )
Parameters
img
the specified image to be drawn.
x
the x coordinate.
y
the y coordinate.
width
the width of the rectangle.
height
the height of the rectangle.
bgcolor
the background color to paint under the non-opaque portions of the image.
observer
object to be notified as more of the image is converted.
Description
Draws as much of the specified image as has already been scaled to fit inside the specified rectangle.

The image is drawn inside the specified rectangle of this graphics context's coordinate space, and is scaled if necessary. Transparent pixels are drawn in the specified background color. This operation is equivalent to filling a rectangle of the width and height of the specified image with the given color and then drawing the image on top of it, but possibly more efficient.

This method returns immediately in all cases, even if the entire image has not yet been scaled, dithered, and converted for the current output device. If the current output representation is not yet complete then drawImage returns false. As more of the image becomes available, the process that draws the image notifies the specified image observer.

A scaled version of an image will not necessarily be available immediately just because an unscaled version of the image has been constructed for this output device. Each size of the image may be cached separately and generated from the original data in a separate image production sequence.

See Also
Image, ImageObserver, imageUpdate



Syntax 5
public abstract boolean drawImage( Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer )
Parameters
img
the specified image to be drawn
dx1
the x coordinate of the first corner of the destination rectangle.
dy1
the y coordinate of the first corner of the destination rectangle.
dx2
the x coordinate of the second corner of the destination rectangle.
dy2
the y coordinate of the second corner of the destination rectangle.
sx1
the x coordinate of the first corner of the source rectangle.
sy1
the y coordinate of the first corner of the source rectangle.
sx2
the x coordinate of the second corner of the source rectangle.
sy2
the y coordinate of the second corner of the source rectangle.
observer
object to be notified as more of the image is scaled and converted.
Description
Draws as much of the specified area of the specified image as is currently available, scaling it on the fly to fit inside the specified area of the destination drawable surface. Transparent pixels do not affect whatever pixels are already there.

This method returns immediately in all cases, even if the image area to be drawn has not yet been scaled, dithered, and converted for the current output device. If the current output representation is not yet complete then drawImage returns false. As more of the image becomes available, the process that draws the image notifies the specified image observer.

This method always uses the unscaled version of the image to render the scaled rectangle and performs the required scaling on the fly. It does not use a cached, scaled version of the image for this operation. Scaling of the image from source to destination is performed such that the first coordinate of the source rectangle is mapped to the first coordinate of the destination rectangle, and the second source coordinate is mapped to the second destination coordinate. The subimage is scaled and flipped as needed to preserve those mappings.

See Also
Image, ImageObserver, imageUpdate



Syntax 6
public abstract boolean drawImage( Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color bgcolor, ImageObserver observer )
Parameters
img
the specified image to be drawn
dx1
the x coordinate of the first corner of the destination rectangle.
dy1
the y coordinate of the first corner of the destination rectangle.
dx2
the x coordinate of the second corner of the destination rectangle.
dy2
the y coordinate of the second corner of the destination rectangle.
sx1
the x coordinate of the first corner of the source rectangle.
sy1
the y coordinate of the first corner of the source rectangle.
sx2
the x coordinate of the second corner of the source rectangle.
sy2
the y coordinate of the second corner of the source rectangle.
bgcolor
the background color to paint under the non-opaque portions of the image.
observer
object to be notified as more of the image is scaled and converted.
Description
Draws as much of the specified area of the specified image as is currently available, scaling it on the fly to fit inside the specified area of the destination drawable surface.

Transparent pixels are drawn in the specified background color. This operation is equivalent to filling a rectangle of the width and height of the specified image with the given color and then drawing the image on top of it, but possibly more efficient.

This method returns immediately in all cases, even if the image area to be drawn has not yet been scaled, dithered, and converted for the current output device. If the current output representation is not yet complete then drawImage returns false. As more of the image becomes available, the process that draws the image notifies the specified image observer.

This method always uses the unscaled version of the image to render the scaled rectangle and performs the required scaling on the fly. It does not use a cached, scaled version of the image for this operation. Scaling of the image from source to destination is performed such that the first coordinate of the source rectangle is mapped to the first coordinate of the destination rectangle, and the second source coordinate is mapped to the second destination coordinate. The subimage is scaled and flipped as needed to preserve those mappings.

See Also
Image, ImageObserver, imageUpdate