Quantcast
Viewing all articles
Browse latest Browse all 18858

How to handle duplicate Drawing Visuals/Icons to save memory

For some background.

I have a group of DrawingVisuals that represent a vehicle. 

Each vehicle consists a single "main" DrawingVisual with several child DrawingVisual's each with one polygon.

In this way I can move all the Drawing Visuals with a single offset and still control the color and sub positions of the internal polygons by using their Drawing Visual.

I have a little over 200 of them displayed at any one time on top of a FrameWorkElement image.

Using JetCrains dotTrace at my memory allocation I now over 25,000 objects that are System.Windows.Media.Color objects which made we want to rethink this.

Could I optimized this.

Could I have only one Vehicle DrawingVisual for each type and using some properties for each to display the 200 vehicles and just manipulate them when I render? Seems like a good idea but I don't know how to do that with WPF.

When I render all I do is offset, rotate and or alter the color of the pens or brushes. I never open the background or any of the child DrawingVisuals to re-render. Looking at the 25,000 System.Windows.Media.Color objects is making me rethink this.

The question being can I use just ONE drawing visual tree to represent the 200 tree's I currently have now?

Thanks for any idea's


bfxtech.com


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>