Showing large RenderTargetBitmap in the Image element - high memory consumption

Viewed 34

I have a quite large bitmap (5760x3600px) - a RenderTargetBitmap instance and I need to show it in a window - in a Canvas element. So I used an Image element where I assign the RenderTargetBitmap to the Source property. The bitmap should be shown not stretched. The user can see a middle part of the bitmap in the window and he can drag the image and move the visible part of the image by mouse. The function is OK but the memory consumption is too high.

I know that the bitmap needs cca 160 MB of memory (5760x3600x8) and when I have one RenderTargetBitmap instance only - without showing in the Image element, I really see it takes cca 160 MB of native memory. But when I assign the RenderTargetBitmap to Image.Source, the next 160 MB of RAM is taken. It looks like that the Image element has its own copy of the bitmap.

Is there a way to render the RenderTargetBitmap some way in the canvas without this doubling of memory consumption?

Update:

RenderTargetBitmap rtb = new RenderTargetBitmap(5760, 3600, 96, 96, PixelFormats.Pbgra32);
myImage.Source = rtb;
0 Answers
Related