Share via


CroppedBitmap 构造函数

定义

初始化 CroppedBitmap 类的新实例。

重载

CroppedBitmap()

初始化 CroppedBitmap 类的新实例。

CroppedBitmap(BitmapSource, Int32Rect)

初始化 CroppedBitmap 类的具有指定 SourceSourceRect 的新实例。

CroppedBitmap()

初始化 CroppedBitmap 类的新实例。

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

注解

CroppedBitmap 实现 ISupportInitialize 接口,以对多个属性的初始化进行优化。 若要初始化CroppedBitmap使用此构造函数创建的 ,必须在 和 EndInit 调用之间BeginInit执行属性初始化。

适用于

CroppedBitmap(BitmapSource, Int32Rect)

初始化 CroppedBitmap 类的具有指定 SourceSourceRect 的新实例。

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)

参数

source
BitmapSource

CroppedBitmap 实例的 Source

sourceRect
Int32Rect

CroppedBitmap 实例的 SourceRect

例外

sourcenull

sourceRectsource 的界限外。

示例

以下示例演示如何使用 CroppedBitmap(BitmapSource, Int32Rect) 初始化 类的新实例 CroppedBitmap

// 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

注解

CroppedBitmap 使用此构造函数创建的对象会自动初始化。 初始化后,将忽略属性更改。

适用于