【问题标题】:How can i get thumbnails from my folder?如何从我的文件夹中获取缩略图?
【发布时间】:2023-03-09 10:13:01
【问题描述】:

我想知道如何使用 C# 在 UWP 中获取缩略图

我想在我的文件夹中获取图像文件(gif、jpg 等)的所有缩略图

我阅读了很多关于获取缩略图的代码,并参考了this 和其他示例

但我无法完全理解 Xaml 的过程

您能告诉我如何从我的库文件夹中获取缩略图吗?

【问题讨论】:

    标签: c# xaml uwp thumbnails


    【解决方案1】:

    一旦您通过用户选择使用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;
    }
    

    【讨论】:

      猜你喜欢
      • 2013-02-02
      • 2020-10-27
      • 2020-08-03
      • 2013-10-18
      • 1970-01-01
      • 2014-03-08
      • 2018-10-28
      • 2015-11-09
      • 1970-01-01
      相关资源
      最近更新 更多