CroppedBitmap Constructor (BitmapSource, Int32Rect)
Collapse the table of content
Expand the table of content

CroppedBitmap Constructor (BitmapSource, Int32Rect)

 

Initializes a new instance of the CroppedBitmap class that has the specified Source and SourceRect.

Namespace:   System.Windows.Media.Imaging
Assembly:  PresentationCore (in PresentationCore.dll)

public CroppedBitmap(
	BitmapSource source,
	Int32Rect sourceRect
)

Parameters

source
Type: System.Windows.Media.Imaging.BitmapSource

The Source of the new CroppedBitmap instance.

sourceRect
Type: System.Windows.Int32Rect

The SourceRect of the new CroppedBitmap instance.

Exception Condition
ArgumentNullException

Occurs when source is null.

CroppedBitmap objects created using this constructor are automatically initialized. After initialization, property changes are ignored.

The following example shows how to use CroppedBitmap(BitmapSource, Int32Rect) to initialize a new instance of the CroppedBitmap class.

// Create an Image element.
Image chainImage = new Image();
chainImage.Width = 200;
chainImage.Margin = new Thickness(5);

// Create the cropped image based on previous CroppedBitmap.
CroppedBitmap chained = new CroppedBitmap(cb,
   new Int32Rect(30, 0, (int)cb.Width-30, (int)cb.Height)); 
// Set the image's source.
chainImage.Source = chained;

.NET Framework
Available since 3.0
Return to top
Show:
© 2016 Microsoft