BitmapDataExtensionsClip(IWritableBitmapData, Rectangle, Boolean) Method

Clips the specified source using the specified clippingRegion. Unlike the Clone methods, this one returns a wrapper, providing access only to the specified region of the original source.

Definition

Namespace: KGySoft.Drawing.Imaging
Assembly: KGySoft.Drawing.Core (in KGySoft.Drawing.Core.dll) Version: 8.2.0
C#
public static IWritableBitmapData Clip(
	this IWritableBitmapData source,
	Rectangle clippingRegion,
	bool disposeSource
)

Parameters

source  IWritableBitmapData
The source bitmap data to be clipped.
clippingRegion  Rectangle
A Rectangle that specifies a region within the source.
disposeSource  Boolean
to dispose source when the result is disposed; otherwise, .

Return Value

IWritableBitmapData
An IWritableBitmapData that provides access only to the specified region withing the source.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IWritableBitmapData. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Remarks

The RowSize property of the returned instance can be 0, indicating that the WriteRaw method cannot be used. It can occur if the left edge of the clipping is not zero.

Even if RowSize property of the returned instance is a nonzero value it can happen that it is too low to access all columns by the WriteRaw method. It can occur with indexed PixelFormats if the right edge of the clipping is not on byte boundary.

Exceptions

ArgumentNullExceptionsource is .
ArgumentOutOfRangeExceptionclippingRegion has no overlapping region with source bounds.

See Also