如何改进WPF绘图应用程序?

时间:2011-03-02 10:27:32

标签: wpf performance image bmp

下面是我绘制图像作为边框对象背景的代码。

   void DrawImage()
   {     
        MemoryStream ms = new MemoryStream();
        bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
        System.Windows.Media.Imaging.BitmapImage chartBitmapImage = new System.Windows.Media.Imaging.BitmapImage();
        chartBitmapImage.BeginInit();
        chartBitmapImage.StreamSource = new MemoryStream(ms.ToArray());
        chartBitmapImage.EndInit();
        imageBrush.ImageSource = chartBitmapImage;            
        aBorder.Background = imageBrush;
        ...
   }

每秒调用上面的DrawImage()方法。 所有操作都运行良好但速度太慢。

我想改善表现。 有什么意义可以改善吗? 也许,我猜任何bmp图像处理方法都比我使用的解决方案更好。 帮帮我...

1 个答案:

答案 0 :(得分:0)

  1. 配置代码以查找最慢的代码行。
  2. 让那部分变得更快。
  3. 重复直到表演可以接受。
相关问题