Stoic Developer
Stoic Developer

Reputation: 101

Using CompositionTarget.SurfaceContentsLost Event in UWP for managing RenderTargetBitmap?

I was reading up on RenderTargetBitmap for a bug in one of my UWPs where a captured image wasn't displaying correctly. Came across a remark from Microsoft stating RenderTargetBitmap can lose data for some reason or another and that we should be attempting to render the bitmap a second time using CompositionTarget.SurfaceContentsLost event. But I haven't been able to find an example of this event online. And I can't seem to request feedback from Microsoft at this time on their Knowledge base site. Does anyone have some sample code they would be willing to share?

Thank you.

Upvotes: 0

Views: 126

Answers (1)

Xie Steven
Xie Steven

Reputation: 8601

But I haven't been able to find an example of this event online.

There's a ImageSourceUpdateRegion sample in Win2D-UWP-Samples. It registers the CompositionTarget.SurfaceContentsLost event in UserControl_Loaded. You could check this sample to learn how to use this event for your UWP app.

Upvotes: 0

Related Questions