Method DrawRegion
DrawRegion(ImageBuffer, int, int, int, int, int, int)
Copies a rectangular region of the source image onto this image
at the specified destination coordinates. Both images must share the same pixel format.
public void DrawRegion(ImageBuffer source, int srcX, int srcY, int srcWidth, int srcHeight, int dstX, int dstY)
Parameters
sourceImageBufferThe source image to copy pixels from.
srcXintLeft edge of the source rectangle (inclusive).
srcYintTop edge of the source rectangle (inclusive).
srcWidthintWidth of the source rectangle in pixels.
srcHeightintHeight of the source rectangle in pixels.
dstXintX coordinate in this image where the top-left corner of the source rectangle will be placed. Negative values and out-of-bounds regions are clipped automatically.
dstYintY coordinate in this image where the top-left corner of the source rectangle will be placed. Negative values and out-of-bounds regions are clipped automatically.
Remarks
All coordinates are automatically clipped to both the source and destination image boundaries. If the clipped region is empty, the method returns without error.
// Draw the entire source onto destination at (100, 50)
destination.Draw(source, dstX: 100, dstY: 50);
// Draw only a 200x100 sub-region starting at (10, 20) in the source
destination.DrawRegion(source, srcX: 10, srcY: 20, srcWidth: 200, srcHeight: 100,
dstX: 0, dstY: 0);
Exceptions
- ArgumentNullException
Thrown if
sourceisnull.- ArgumentException
Thrown if
sourcehas a different pixel format than this image.