【发布时间】:2015-05-31 08:31:45
【问题描述】:
我在 windows phone 8.1 中编写了一个函数来显示文件夹上的图像(假设我在这个文件夹中有大约 60 张图像)。问题是当我创建流以获取位图图像时,函数 GetThumbnailAsync() 需要很长时间。 这是我的代码
//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
}
我进行了测试,发现问题是函数 GetThumbnailAsync 需要很长时间。 如果我有大约 60 张图片,完成此功能大约需要 15 秒(我在 lumia 730 中测试)。 有人遇到这个问题吗?如何让这段代码运行得更快?。
非常感谢您的支持
【问题讨论】:
标签: c# image-processing optimization winrt-xaml