Rendering WPF DrawingGroup for Single ImageSource

I am currently using System.Windows.Media.DrawingGroup to store some tiled images (ImageDrawing) in the Children-DrawingCollection property. The problem is that now this method becomes very slow if you display the entire DrawingGroup in the Image control, because my DrawingGroup can contain hundreds or even thousands of small images, which can really ruin the performance.

So, my first thought was to somehow display one image from all the small ones inside the DrawingGroup, and then only display that image, which would be much faster. But, as you could understand, I did not find any solution, so just combine multiple images with WPF Imaging.

It would be great if someone could help with this problem or tell me how I can improve performance using DrawingGroup or even use a different approach.

Last, I am currently using RenderTargetBitmap to create one BitmapSource from a DrawingGroup, this approach is not very fast, but it makes scrolling and working with the image control at least a little smoother.

+3
source share
2 answers

I'm not sure if this applies to your problem, but I will post it here, as this may help someone:

If not all the images in the drawing group are visible at the same time, you can set ClipGeometry so that everything you want to draw. This actually tells WPF that parts outside the geometry are not needed and will be skipped during rendering.

A few other things you can experiment with:

  • Freeze a group of drawings before applying it to the image source. At least this could not hurt (unless you really need to modify the instance, but remember that you can always just create a new one instead of changing the old one).
  • . , DrawingVisual ( ) DrawingBrush, , .
  • , . , , .
+2

, , , .

- (, , , , 100 .), Freeze DrawingImage. "Freeze the DrawingImage ".

Freeze DrawingGroup. , ?

+1

Source: https://habr.com/ru/post/1716305/


All Articles