c# - "The Image passed to the ImageVisualManager cannot be frozen" WPF exception -
I am trying to present the view for a WPF RenderTargetBitmap I cache in the window view.
Renderizitbuiltmapmart RTB;
In my window constructor,
public FooWindow () {rtb = new RenderTargetBitmap (500, 500, 96, 96, pixelformats.pibra32); }
The user-request code (request for a screenshot) -
// ... window window = window.getwindow (this) ; Rtb.Render (window); Rtb.Freeze (); // rtb Next bitmapFrame bmpFrame = BitmapFrame. Create (renderTargetBitmap) used; // ...
However, I get the following exception (.)
on RTB.render [System.ArgumentException]: {Image ImageVisualManager This can be done for the first time though.
The problem is freeing RenderTargetBitmap and then trying to reuse it, you can do one of two things to fix
- A new render target for each request Create another bitmap
- Do not render target static bitmap ( 'rtb.Freeze (Remove)) line and keep using the same example). By trying to cache an example and reuse it, you do not want to freeze it at all.
Solution # 1 is not recommended in sensitive code because RenderTargetBitmap is expensive if you expect it to be used again, there is no real need to freeze it.
Comments
Post a Comment