语言

CroppedBitmap 构造函数

定义

初始化 CroppedBitmap 类的新实例。

重载

名称 说明
CroppedBitmap()

初始化 CroppedBitmap 类的新实例。

CroppedBitmap(BitmapSource, Int32Rect)

初始化具有指定CroppedBitmap和 Source. 的类的新实例SourceRect。

CroppedBitmap()

初始化 CroppedBitmap 类的新实例。

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

注解

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

适用于

CroppedBitmap(BitmapSource, Int32Rect)

初始化具有指定CroppedBitmap和 Source. 的类的新实例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)

参数

source
BitmapSource

Source新CroppedBitmap实例。

sourceRect
Int32Rect

SourceRect新CroppedBitmap实例。

例外

source 是 null。

sourceRect 位于 . 的 source边界之外。

示例

以下示例演示如何用于 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 使用此构造函数创建的对象会自动初始化。 初始化后,将忽略属性更改。

适用于