语言

SoftwareBitmapSource 类

定义

为使用位图格式图像源的属性提供 由 SoftwareBitmap 支持的源对象。

public ref class SoftwareBitmapSource sealed : ImageSource, IClosable
/// [Windows.Foundation.Metadata.Activatable(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 SoftwareBitmapSource final : ImageSource, IClosable
[Windows.Foundation.Metadata.Activatable(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 SoftwareBitmapSource : ImageSource, System.IDisposable
Public NotInheritable Class SoftwareBitmapSource
Inherits ImageSource
Implements IDisposable
继承
Object Platform::Object IInspectable DependencyObject ImageSource SoftwareBitmapSource
属性
实现

注解

SoftwareBitmapSource 允许你将 SoftwareBitmap 用作图像源,以便使用 ImageBrush 或直接在 图像 控件中显示。 例如,可以使用 SoftwareBitmapSource 通过 LowLagPhotoCapture 类显示设备相机刚拍摄的照片、使用 BitmapDecoder.GetSoftwareBitmapAsync 方法手动解码的图像,或在想要手动管理图像内存的高级 C++ 方案中显示自定义 IWICBitmap 。

XAML 应用中显示的 SoftwareBitmap 必须采用 BGRA 像素格式,且具有预乘 alpha 值。

SoftwareBitmap 通常存储未压缩的图像数据。 这意味着,与可移植网络图形(PNG)或 JPEG 文件等压缩格式相比,可能需要大量的系统内存。 因此,使用 SoftwareBitmap 可以增加应用正在使用的系统内存量,这可能会影响应用的性能。 由于存储未压缩的图像数据可以使用大量内存,因此可以调用 Dispose (C#/VB) 或 Close (C++) 方法,以减少 在需要 SoftwareBitmap 的时间更长时使用的内存。 这会导致关联的系统资源立即释放,而不是等待垃圾回收。

构造函数

名称 说明
SoftwareBitmapSource()

初始化 SoftwareBitmapSource 类的新实例。

属性

名称 说明
Dispatcher

始终在 Windows 应用 SDK 应用中返回 null 。 请改用 DispatcherQueue 。

(继承自 DependencyObject)
DispatcherQueue

获取 DispatcherQueue 与此对象关联的对象。 表示 DispatcherQueue 即使代码是由非 UI 线程启动,也可以访问 DependencyObject UI 线程上的设施。

(继承自 DependencyObject)

方法

名称 说明
ClearValue(DependencyProperty)

清除依赖属性的本地值。

(继承自 DependencyObject)
Close()

释放对象和关联的资源。

Dispose()

执行与释放、释放或重置非托管资源关联的应用程序定义任务。

GetAnimationBaseValue(DependencyProperty)

返回为依赖属性建立的任何基值,在动画未处于活动状态的情况下,该属性将适用。

(继承自 DependencyObject)
GetValue(DependencyProperty)

从 DependencyObject 返回依赖属性的当前有效值。

(继承自 DependencyObject)
ReadLocalValue(DependencyProperty)

如果设置了本地值,则返回依赖属性的本地值。

(继承自 DependencyObject)
RegisterPropertyChangedCallback(DependencyProperty, DependencyPropertyChangedCallback)

注册一个通知函数,用于侦听此 DependencyObject 实例上对特定 DependencyProperty 所做的更改。

(继承自 DependencyObject)
SetBitmapAsync(SoftwareBitmap)

设置要用作图像源的 source SoftwareBitmap 。

SetValue(DependencyProperty, Object)

设置 DependencyObject 上的依赖属性的本地值。

(继承自 DependencyObject)
UnregisterPropertyChangedCallback(DependencyProperty, Int64)

取消以前通过调用 RegisterPropertyChangedCallback 注册的更改通知。

(继承自 DependencyObject)

适用于

另请参阅