CroppedBitmap 建構函式
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
初始化 CroppedBitmap 類別的新執行個體。
多載
| 名稱 | Description |
|---|---|
| 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
例外狀況
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 使用此建構器建立的物件會自動初始化。 初始化後,屬性變更會被忽略。