CroppedBitmap 建構函式

定義

初始化 CroppedBitmap 類別的新執行個體。Initializes a new instance of the CroppedBitmap class.

多載

CroppedBitmap()

初始化 CroppedBitmap 類別的新執行個體。Initializes a new instance of the CroppedBitmap class.

CroppedBitmap(BitmapSource, Int32Rect)

初始化 CroppedBitmap 類別的新執行個體,這個執行個體具有指定的 SourceSourceRectInitializes a new instance of the CroppedBitmap class that has the specified Source and SourceRect.

CroppedBitmap()

初始化 CroppedBitmap 類別的新執行個體。Initializes a new instance of the CroppedBitmap class.

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

備註

CroppedBitmap會執行ISupportInitialize介面, 以優化多個屬性的初始化。CroppedBitmap implements the ISupportInitialize interface to optimize initialization on multiple properties. 若要初始化CroppedBitmap使用此函式所建立的, 您必須在BeginInitEndInit呼叫之間執行屬性初始化。To initialize a CroppedBitmap created using this constructor, you must perform property initialization between BeginInit and EndInit calls.

CroppedBitmap(BitmapSource, Int32Rect)

初始化 CroppedBitmap 類別的新執行個體,這個執行個體具有指定的 SourceSourceRectInitializes 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)

參數

source
BitmapSource

CroppedBitmap 執行個體的 SourceThe Source of the new CroppedBitmap instance.

sourceRect
Int32Rect

CroppedBitmap 執行個體的 SourceRectThe SourceRect of the new CroppedBitmap instance.

例外狀況

sourcenullsource is null.

sourceRect 不在 source 範圍內。sourceRect is outside the boundaries of source.

範例

下列範例顯示如何使用CroppedBitmap(BitmapSource, Int32Rect)初始化CroppedBitmap類別的新實例。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

備註

CroppedBitmap使用此函數建立的物件會自動初始化。CroppedBitmap objects created using this constructor are automatically initialized. 初始化之後, 會忽略屬性變更。After initialization, property changes are ignored.

適用於