Επεξεργασία

Κοινή χρήση μέσω


CroppedBitmap Constructors

Definition

Initializes a new instance of the CroppedBitmap class.

Overloads

CroppedBitmap()

Initializes a new instance of the CroppedBitmap class.

CroppedBitmap(BitmapSource, Int32Rect)

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

CroppedBitmap()

Initializes a new instance of the CroppedBitmap class.

public:
 CroppedBitmap();
public CroppedBitmap ();
Public Sub New ()

Remarks

CroppedBitmap implements the ISupportInitialize interface to optimize initialization on multiple properties. To initialize a CroppedBitmap created using this constructor, you must perform property initialization between BeginInit and EndInit calls.

Applies to

CroppedBitmap(BitmapSource, Int32Rect)

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

public:
 CroppedBitmap(System::Windows::Media::Imaging::BitmapSource ^ source, System::Windows::Int32Rect sourceRect);
public CroppedBitmap (System.Windows.Media.Imaging.BitmapSource source, System.Windows.Int32Rect sourceRect);
new System.Windows.Media.Imaging.CroppedBitmap : System.Windows.Media.Imaging.BitmapSource * System.Windows.Int32Rect -> System.Windows.Media.Imaging.CroppedBitmap
Public Sub New (source As BitmapSource, sourceRect As Int32Rect)

Parameters

source
BitmapSource

The Source of the new CroppedBitmap instance.

sourceRect
Int32Rect

The SourceRect of the new CroppedBitmap instance.

Exceptions

source is null.

sourceRect is outside the boundaries of source.

Examples

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;
' Create an Image element.
Dim chainImage As New Image()
chainImage.Width = 200
chainImage.Margin = New Thickness(5)

' Create the cropped image based on previous CroppedBitmap.
Dim chained As New CroppedBitmap(cb, New Int32Rect(30, 0, CType(cb.Width, Integer) - 30, CType(cb.Height, Integer)))
' Set the image's source.
chainImage.Source = chained

Remarks

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

Applies to