3

I am evaluating WPF for use in an application which will need to render tens of thousands of elements (rectangles, lines, circles). The rendering needs to be fast but can be done once and cached - so I've found BitmapCacheBrush is the recommended way of doing this.

However, it seems that when I render to a DrawingVisual and update BitmapCacheBrush.Target to use this, the memory of DrawingVisual is retained.

Is there a way to drop the DrawingVisual once it has been cached as a bitmap? or another way of doing this? (I looked at RenderTargetBitmap but apparently that does not use hardware accelerated rendering)

Thank-you AnonDev

AnonDev
  • 172
  • 3
  • 7
  • Another idea is to use [WriteableBitmap](http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.writeablebitmap.aspx). But you could also use BitmapCache, which is a property on almost any UI control in WPF. BitmapCacheBrush is just an extension. I think BitmapCache is more what you are looking for. – dowhilefor Dec 03 '12 at 15:37
  • thanks - I think WriteableBitmap is possibly unsuitable as I can't use a DrawingContext to write to it. Using a BitmapCache and VisualBrush seems to work but with the same problem - the VisualBrush references my DrawingVisual which contains 10s of thousands of elements - this retention is what I'm trying to avoid - I'd like the bitmap to be rendered and the Visual discarded if at all possible. – AnonDev Dec 03 '12 at 17:17

0 Answers0