mrfangzheng

Hope and fear are useless. Be confident, and always be prepared for the worst.
  首页  :: 新随笔  :: 联系 :: 管理

WPF : 性能调整

Posted on 2009-09-23 12:51  mrfangzheng  阅读(437)  评论(0编辑  收藏  举报
  1. 2D Graphics and Imaging
    1. 尽量使用Drawing来代替Shape. 因为Drawing不用支持Layout和Event
    2. 尽量使用DrawingVisual来绘制背景等不需要Layout和Event的地方
    3. 使用图形时, 尽量decode到最小的size
    4. 在动画时, 调用RenderOptions.SetBitmapScalingMode()把图片设置到LowQuality
    5. 缓存Brush.
      // Set the minimum and maximum relative sizes for regenerating the tiled brush. RenderOptions.SetCacheInvalidationThresholdMinimum(drawingBrush, 0.5); RenderOptions.SetCacheInvalidationThresholdMaximum(drawingBrush, 2.0); // The tiled brush will be regenerated when the size is // 0.5x, 0.25x (and so forth) // and // 2x, 4x, 8x (and so forth) // of the original size. // Set the caching hint option for the brush. RenderOptions.SetCachingHint(drawingBrush, CachingHint.Cache);