Blazor Canvas Double Buffering

asked 2021-11-18T10:05:24.61+00:00
Bruno 1 Reputation point

Hi all
I'm writing a 2D graphics application with Blazor Canvas Extension.
I started with an Blazor Server application for easy debugging and later want to change to Blazor WebAssembly.
My problem is flickering when I update some parts of my graphics.
I first clear the affected region by ClearRectAsync and draw the new graphic in it.
All drawing is done between BeginBatchAsync and EndBatchAsync.

My questions are:

  1. How can I realize double buffering with Blazor Canvas Extension? What options do I have?
  2. My idea was to first draw into a bitmap with some other library and then copy it into the canvas with Blazor Canvas Extension? What library can I use for that, so that it also runs in a Blazor WebAssembly application? I guess that Microsoft.Drawing.Common only runs on Windows.

Thanks, Bruno

Blazor
Blazor
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
782 questions
No comments
{count} votes

1 answer

Sort by: Most helpful
  1. answered 2021-11-18T16:14:23.557+00:00
    Bruce (SqlWork.com) 27,936 Reputation points

    You easiest fix is to use a hidden canvas, then copy to visible canvas

    https://stackoverflow.com/questions/4405336/how-to-copy-contents-of-one-canvas-to-another-canvas-locally

    No comments