【发布时间】:2023-03-09 10:13:01
【问题描述】:
我想知道如何使用 C# 在 UWP 中获取缩略图
我想在我的文件夹中获取图像文件(gif、jpg 等)的所有缩略图
我阅读了很多关于获取缩略图的代码,并参考了this 和其他示例
但我无法完全理解 Xaml 的过程
您能告诉我如何从我的库文件夹中获取缩略图吗?
【问题讨论】:
标签: c# xaml uwp thumbnails
我想知道如何使用 C# 在 UWP 中获取缩略图
我想在我的文件夹中获取图像文件(gif、jpg 等)的所有缩略图
我阅读了很多关于获取缩略图的代码,并参考了this 和其他示例
但我无法完全理解 Xaml 的过程
您能告诉我如何从我的库文件夹中获取缩略图吗?
【问题讨论】:
标签: c# xaml uwp thumbnails
一旦您通过用户选择使用FolderPicker 访问文件夹后,您就可以从系统中检索缩略图。您可以为此使用GetScaledImageAsThumbnailAsync()。
例如:
private async Task<BitmapImage> GetThumbnail(StorageFile file)
{
if (file != null)
{
StorageItemThumbnail thumb = await file.GetScaledImageAsThumbnailAsync(ThumbnailMode.VideosView);
if (thumb != null)
{
BitmapImage img = new BitmapImage();
await img.SetSourceAsync(thumb);
return img;
}
}
return null;
}
【讨论】: