Share via


Overview | Methods | This Package | All Packages

OverviewMethodsThis PackageAll Packages

Graphics.drawImage

Draws an image at the specified location.

Syntax

public final void drawImage( Image i**, Point** pt )

public final void drawImage( Image i**, int** x**, int** y )

public final void drawImage( Image i**, Point** pt**, RasterOp** op )

public final void drawImage( Image i**, int** x**, int** y**, RasterOp** op )

public final void drawImage( Image i**, Rectangle** r**, boolean** scale )

public final void drawImage( Image i**, int** x**, int** y**, int** width**, int** height**, boolean** scale )

public final void drawImage( Image i**, Rectangle** r**, boolean** scale**, RasterOp** op )

public final void drawImage( Image i**, int** x**, int** y**, int** width**, int** height**, boolean** scale**, RasterOp** op )

public final void drawImage( Image i**, Rectangle** imageRect**, Rectangle** targetRect**, boolean** scale )

public final void drawImage( Image i**, Rectangle** imageRect**, Rectangle** targetRect**, boolean** scale**, RasterOp** op )

Parameters

i

An Image object that specifies the image to draw.

pt

A Point object that specifies the location at which to draw the image.

x

The x-coordinate of the location at which to draw the image.

y

The y-coordinate of the location at which to draw the image.

width

The width of the rectangle in which to draw the image.

height

The height of the rectangle in which to draw the image.

op

A RasterOp object that specifies how to draw the image.

r

A Rectangle object that specifies the coordinates to which to draw the image.

scale

A boolean value that specifies whether the image should be stretched or shrunk to fit the specified rectangle. If true, the image is stretched or shrunk. If false, the image is cropped.

imageRect

A Rectangle object that specifies the coordinates of the source rectangle in the image.

targetRect

A Rectangle object that specifies the coordinates of the target rectangle.

Remarks

Three factors affect the approach that the drawImage method takes to rendering an image on the display.

The first factor is scale. The scale parameter indicates whether the image should be drawn or stretched to fill a specified rectangle. If this parameter is true, the image is scaled or shrunk, depending on the comparative size of the image and the target rectangle. If this parameter is false, the image is cropped.

The second factor affecting display is the raster operation used to render the image. The value that you specify in the RasterOp object of drawImage causes drawImage to perform one or more logical operations on the image.

The third factor affecting display is bitmap transparency. You determine which colors of a bitmap will be rendered transparent by using the setTransparent method on the Bitmap object.