Copies the contents of a rectangular area
(x_src, y_src, width, height)
to a destination area, whose anchor point identified by anchor is located at
(x_dest, y_dest)
. The effect must be that the destination area contains an exact copy of the contents of the source area immediately prior to the invocation of this method. This result must occur even if the source and destination areas overlap.
The points (x_src, y_src)
and (x_dest, y_dest)
are both specified relative to the coordinate system of the Graphics
object. It is illegal for the source region to extend beyond the bounds of the graphic object. This requires that:
x_src + tx >= 0 y_src + ty >= 0 x_src + tx + width <= width of Graphics object's destination y_src + ty + height <= height of Graphics object's destination |
where tx
and ty
represent the X and Y coordinates of the translated origin of this graphics object, as returned by getTranslateX()
and getTranslateY()
, respectively.
However, it is legal for the destination area to extend beyond the bounds of the Graphics
object. Pixels outside of the bounds of the Graphics
object will not be drawn.
The copyArea
method is allowed on all Graphics
objects except those whose destination is the actual display device. This restriction is necessary because allowing a copyArea
method on the display would adversely impact certain techniques for implementing double-buffering.
Like other graphics operations, the copyArea
method uses the Source Over Destination rule for combining pixels. However, since it is defined only for mutable images, which can contain only fully opaque pixels, this is effectively the same as pixel replacement.
@param x_src the x coordinate of upper left corner of source area
@param y_src the y coordinate of upper left corner of source area
@param width the width of the source area
@param height the height of the source area
@param x_dest the x coordinate of the destination anchor point
@param y_dest the y coordinate of the destination anchor point
@param anchor the anchor point for positioning the region withinthe destination image
@throws IllegalStateException if the destination of this
Graphics
object is the display device
@throws IllegalArgumentException if the region to be copied exceedsthe bounds of the source image