目前我在畫布上有一個圖像,可以在我的應用程序中隨意移動,其中繪製了6層DrawingVisuals,但它看起來很慢。我正在使用RenderTargetBitmap來渲染視覺效果。有沒有更快的方法來顯示圖像上的視覺效果或其他任何可以在畫布上自由移動的框架元素?在WPF中快速渲染drawingviews
XAML:
<Canvas>
<Image Height="505" HorizontalAlignment="Left" Margin="0,0,0,0" Name="_MapImage" Stretch="Fill" VerticalAlignment="Top" Width="700" MouseLeftButtonDown="_MapImage_MouseDown" MouseWheel="_MapImage_MouseWheel" MouseLeftButtonUp="_MapImage_MouseUp" MouseMove="_MapImage_MouseMove" />
</Canvas>
代碼:
_renderRoutesBitmap = new RenderTargetBitmap((int)(_MapImage.Width), (int)(_MapImage.Height), 96, 96, PixelFormats.Default);
for (int i = 6; i < 8; ++i)
{
if((layerCode/(int)Math.Pow(10,i) % 2) == 1)
_renderRoutesBitmap.Render(_layers[i]); //takes too much time
}
_RouteImage.Source = _renderRoutesBitmap;
你能詳細描述一下你在_layers裏有什麼? – 2012-05-01 14:51:26
_layers數組包含可視圖形,它們實際上是我繪製的地圖的不同類型的道路,在單個圖像上呈現。 – 2012-05-05 14:40:28