AnimationImage.WinUI
3.0.0
dotnet add package AnimationImage.WinUI --version 3.0.0
NuGet\Install-Package AnimationImage.WinUI -Version 3.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AnimationImage.WinUI" Version="3.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AnimationImage.WinUI" Version="3.0.0" />
<PackageReference Include="AnimationImage.WinUI" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add AnimationImage.WinUI --version 3.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: AnimationImage.WinUI, 3.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package AnimationImage.WinUI@3.0.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=AnimationImage.WinUI&version=3.0.0
#tool nuget:?package=AnimationImage.WinUI&version=3.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
AnimationImage.WinUI
基于 SkiaSharp + D3D12 的 WinUI 极简动图播放方案
🚀 简介
AnimationImage.WinUI 支持播放 Lottie(JSON)、GIF、WebP、APNG 格式,通过 Composition API 直接渲染,Lottie 默认走 D3D12 GPU 加速管线(零拷贝直渲到合成层),动图走 CPU 解码 + Win2D 呈现,兼顾性能与兼容性。
✨ 核心特性
- GPU 加速:Lottie 走 D3D12 + Skia GPU 管线,复杂矢量动画丝滑流畅。
- 三级降级:GPU 零拷贝 ↘ GPU 光栅+ReadPixels ↘ 纯 CPU 光栅,自动降级无需干预。
- 多格式:Lottie、GIF、WebP、APNG 一站式支持。
- 智能缓存:MMF 内存映射,大分辨率动图无压力播放,跨实例复用。
- Composition 原生:通过
SpriteVisual+CompositionDrawingSurface呈现,支持任意FrameworkElement作为宿主。 - 全可控:自动播放、循环次数、进度跳转、
Play/Pause/Stop命令,开箱即用。
🚝 使用方法
引入命名空间:xmlns:ani="using:AnimationImage"
<Border ani:AnimatableBitmap.Source="{ani:AnimatableBitmap Source='ms-appx:///Assets/animation.json'}"
ani:AnimatableBitmap.AutoStart="True"
ani:AnimatableBitmap.RepeatBehavior="Forever" />
<Border ani:AnimatableBitmap.Source="{ani:AnimatableBitmap Source='ms-appx:///Assets/lottie.json', UseGPU=True}" />
<Border ani:AnimatableBitmap.Source="{ani:AnimatableBitmap Source='ms-appx:///Assets/cat.gif', Preload=True}" />
<Slider Maximum="{Binding ElementName=img, Path=(ani:AnimatableBitmap.Source).Metadata.Duration, Mode=OneWay}"
Value="{Binding ElementName=img, Path=(ani:AnimatableBitmap.AnimationTime), Mode=TwoWay}" />
<StackPanel DataContext="{Binding ElementName=img, Path=(ani:AnimatableBitmap.Source)}"
Orientation="Horizontal">
<Button Command="{Binding BeginCommand, Mode=OneTime}" Content="Play" />
<Button Command="{Binding PauseCommand, Mode=OneTime}" Content="Pause" />
<Button Command="{Binding StopCommand, Mode=OneTime}" Content="Stop" />
</StackPanel>
<Border ani:AnimatableBitmap.Stretch="Uniform" />
代码创建:
var options = new AnimatableBitmapOptions(filePath, useGPU: true, preload: false);
var bitmap = AnimatableBitmapFactory.Default.Create(options);
AnimatableBitmap.SetSource(hostElement, bitmap);
修改默认配置:
AnimatableBitmapOptions.Default = new AnimatableBitmapOptions()
{
UseGPU = true, // Lottie 显卡加速(默认开启)
Preload = false, // 预加载缓存
};
📋 附加属性一览
| 属性 | 类型 | 说明 |
|---|---|---|
Source |
AnimatableBitmap |
动图数据模型 |
AnimationTime |
double |
当前播放时间(毫秒),支持双向绑定 |
AutoStart |
bool |
是否自动播放(默认 True) |
RepeatBehavior |
RepeatBehavior? |
循环行为(Forever / 指定次数) |
Stretch |
Stretch |
拉伸模式(Uniform/Fill/UniformToFill/None) |
⚙️ 系统要求
- Windows 10 1809 (Build 17763) 及以上
- .NET 8.0
- WinUI 3 / Windows App SDK
✈️ 更新日志
v3.0.0
🚀 首个 WinUI 版本发布。基于 D3D12 + Composition API 的全新 GPU 加速管线。
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0-windows10.0.19041 is compatible. net9.0-windows was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0-windows10.0.19041
- Microsoft.Graphics.Win2D (>= 1.3.2)
- Microsoft.Windows.SDK.BuildTools (>= 10.0.28000.2270)
- Microsoft.WindowsAppSDK (>= 2.2.0)
- Silk.NET.Direct3D12 (>= 2.22.0)
- Silk.NET.DXGI (>= 2.22.0)
- SkiaSharp (>= 3.119.2)
- SkiaSharp.Skottie (>= 3.119.2)
- SkiaSharp.Views.WinUI (>= 3.119.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.0.0 | 124 | 7/17/2026 |