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

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 使用此建構函式建立的物件會自動初始化。 初始化之後,會忽略屬性變更。

適用於