您在使用.net程序时使用了哪些分析器,您会特别推荐哪些?
我正在编写一个WPF图像查看器,显示一个图像网格.由于性能低下,我感到困惑:即使是一个11 x 11的网格,也会让VM在长时间内没有响应,缓慢而缓慢.即使在功能强大的主机上也能表现得非常活泼.
该程序基于SO WPF中的设计:在网格中安排集合项:ItemsControl绑定到Items,一个ObservableCollection.每个Item包含一个文件系统绝对URI.ItemsControl的DataTemplate包含一个Image元素,其Source绑定到URI.
似乎问题不能是磁盘(SSD),内存(8GB VM,24GB主机)或CPU(i750).此外,大部分工作都是由WPF完成的,因此我甚至不能在我的代码中找到问题:我的代码只是将URI(即图像的路径,而不是图像)加载到集合中并快速返回.然后有一个等待,WPF显示图像.
我能想到的唯一问题是图像处理 - WPF缩小比例.但即使在拥有"足够好"的5850 ATI Radeon HD卡的主机上,性能也不是很好.
所以,我的问题是:如何在WPF上显示图像更加"活泼"?
编辑:图像是从HD m2ts视频捕获的1920x1080 22位HD JPEG.我尝试将它们(使用FFmpeg)预缩放到'ega'640x350.有是提高性能,但FFmpeg的按比例缩小的图像看起来比WPF的糟糕得多.
编辑:感谢David Osborne,代码现在以x64运行.仍然低迷.
编辑真正改善了这种情况的是MatějZábský所谓的scalling图像:降低分辨率.为了未来读者的利益:
fullPath = new Uri(path, UriKind.Absolute);
BitmapImage smallerBitmapImage = new BitmapImage();
smallerBitmapImage.BeginInit();
smallerBitmapImage.DecodePixelWidth = (int) (theWidthOfTheGrid / theNumberOfColumns);
smallerBitmapImage.UriSource = fullPath;
smallerBitmapImage.EndInit();
FormatConvertedBitmap formatConvertedBitmap = new FormatConvertedBitmap();
formatConvertedBitmap.BeginInit();
formatConvertedBitmap.Source = smallerBitmapImage;
formatConvertedBitmap.DestinationFormat = PixelFormats.Gray16;
formatConvertedBitmap.EndInit();
formatConvertedBitmap.Freeze();
this.ImageSource = formatConvertedBitmap;
Run Code Online (Sandbox Code Playgroud)