小编Pha*_*Luc的帖子

如何在窗口电话8.1中改进性能方法GetThumbnailAsync

我在窗口电话8.1中写了一个函数来显示文件夹上的图像(假设我在这个文件夹中有大约60个图像).问题是函数GetThumbnailAsync()在创建流来获取bitmapImage时需要很长时间.这是我的代码

       //getFileInPicture is function get all file in picture folder 
       List<StorageFile> lstPicture = await getFileInPicture();
       foreach (var file in lstPicture)
       {
            var thumbnail = await        file.GetThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode.PicturesView,50);
            var bitmapImage = new BitmapImage();
            bitmapImage.DecodePixelWidth = (int)(ScreenWidth / 4);
            await bitmapImage.SetSourceAsync(thumbnail);
            g_listBitmapImage.Add(bitmapImage);
           //g_listBitmapImage is a list of bitmapImage
        }
Run Code Online (Sandbox Code Playgroud)

我是测试,发现问题是函数GetThumbnailAsync花了这么长时间.如果我有大约60张图片,则需要大约15秒来完成此功能(我在lumia 730中测试). 有没有人遇到这个问题以及如何让这段代码运行得更快?.

非常感谢您的支持

c# optimization image-processing winrt-xaml

1
推荐指数
1
解决办法
1053
查看次数

标签 统计

c# ×1

image-processing ×1

optimization ×1

winrt-xaml ×1