WriteableBitmap 類別

定義

提供可寫入並更新的 BitmapSource

public ref class WriteableBitmap sealed : BitmapSource
/// [Windows.Foundation.Metadata.Activatable(Microsoft.UI.Xaml.Media.Imaging.IWriteableBitmapFactory, 65536, "Microsoft.UI.Xaml.WinUIContract")]
/// [Windows.Foundation.Metadata.ContractVersion(Microsoft.UI.Xaml.WinUIContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class WriteableBitmap final : BitmapSource
[Windows.Foundation.Metadata.Activatable(typeof(Microsoft.UI.Xaml.Media.Imaging.IWriteableBitmapFactory), 65536, "Microsoft.UI.Xaml.WinUIContract")]
[Windows.Foundation.Metadata.ContractVersion(typeof(Microsoft.UI.Xaml.WinUIContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class WriteableBitmap : BitmapSource
Public NotInheritable Class WriteableBitmap
Inherits BitmapSource
繼承
Object Platform::Object IInspectable DependencyObject ImageSource BitmapSource WriteableBitmap
屬性

範例

關於 C# 和 C++/WinRT 的程式碼範例,請參見 WriteableBitmap.PixelBuffer

備註

可寫位圖的影像來源資料是一個底層的像素緩衝區。

WriteableBitmap.PixelBuffer 回傳的 IBuffer 無法直接寫入。 但你可以用語言特定的技術寫入緩衝區底層的像素內容。 詳情請參閱 WriteableBitmap.PixelBuffer備註區段。

過去 XAML 框架中可能使用 WriteableBitmap 類別的某些情境,在 Windows 執行階段 中可改用 RenderTargetBitmap 類別來實現。 更多資訊請參見 RenderTargetBitmap

建構函式

名稱 Description
WriteableBitmap(Int32, Int32)

初始化 WriteableBitmap 類別的新實例。

屬性

名稱 Description
Dispatcher

它總是在 Windows 應用程式 SDK 應用程式中回傳 null 。 改用 DispatcherQueue

(繼承來源 DependencyObject)
DispatcherQueue

得到 DispatcherQueue 這個物件所關聯的那個。 代表 DispatcherQueue 一個功能,即使程式碼是由非 UI 執行緒發起,也能存取 UI DependencyObject 執行緒。

(繼承來源 DependencyObject)
PixelBuffer

取得可 寫位圖 每個像素所寫入的直接緩衝區存取權。

PixelHeight

它會取得點陣圖的高度(像素單位)。

(繼承來源 BitmapSource)
PixelWidth

會得到點陣圖的寬度(像素數)。

(繼承來源 BitmapSource)

方法

名稱 Description
ClearValue(DependencyProperty)

清除依賴性財產的局部價值。

(繼承來源 DependencyObject)
GetAnimationBaseValue(DependencyProperty)

回傳任何為相依屬性建立的基礎值,適用於動畫未啟用時。

(繼承來源 DependencyObject)
GetValue(DependencyProperty)

回傳 DependencyObject 中相依屬性的當前有效值。

(繼承來源 DependencyObject)
Invalidate()

請求繪製或重繪整個位圖。

ReadLocalValue(DependencyProperty)

若設定了本地值,則回傳依賴性質的局部值。

(繼承來源 DependencyObject)
RegisterPropertyChangedCallback(DependencyProperty, DependencyPropertyChangedCallback)

註冊一個通知函式,用於監聽此 DependencyObject 實例中特定 DependencyProperty 的變更。

(繼承來源 DependencyObject)
SetSource(IRandomAccessStream)

透過存取串流來設定 BitmapSource 的原始影像。 大多數呼叫者應該改用 SetSourceAsync

(繼承來源 BitmapSource)
SetSourceAsync(IRandomAccessStream)

透過存取串流並非同步處理結果,設定 BitmapSource 的原始影像。

(繼承來源 BitmapSource)
SetValue(DependencyProperty, Object)

將相依屬性的局部值設定在 DependencyObject 上。

(繼承來源 DependencyObject)
UnregisterPropertyChangedCallback(DependencyProperty, Int64)

取消先前透過呼叫 RegisterPropertyChangedCallback 註冊的變更通知。

(繼承來源 DependencyObject)

適用於

另請參閱