Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
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
)
You cannot use constructors in XAML.

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.

ExceptionCondition
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;

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0

Community Additions

ADD
Show:
© 2015 Microsoft