WPF在Windows XP上加载图像的性能很差

时间:2013-04-18 06:43:14

标签: wpf performance bitmapimage

我有一些代码可以加载图片大拇指并在列表框中显示它们。它在Win7上正常工作。在Windows XP上,我需要大约七到十分钟来加载一些大图像,而七分钟需要几秒钟。我怎样才能加快速度?

    public static string AddImage(string file)
    {
        string key = "IMG_" + (++_counter).ToString("00000");
        ImageInfo inf = new ImageInfo();
        inf.OriginalPath = file;
        inf.ID = key;
        inf.OriginalPath = file;

        BitmapImage bi = new BitmapImage();
        bi.BeginInit();
        bi.DecodePixelWidth = THUMB_SIZE;
        bi.CacheOption = BitmapCacheOption.OnLoad;
        bi.UriSource = new Uri(file);
        bi.EndInit();
        inf.ThumbBitmap = bi;

        _storedImageInfo.Add(key, inf);

        return key;
    }

ImageInfo是我自己的类,包含对BitmapImages和图像路径的引用。我不认为它对装载时间有重大影响。

0 个答案:

没有答案
相关问题