How to edit a WritableBitmap.BackBuffer in non UI thread?

前端 未结 5 779
旧时难觅i
旧时难觅i 2020-12-03 15:37

My application runs CPU-heavy algorythms to edit an Image placed at a WPF window. I need the edition to be done in a background thread. However trying to edit the BackBuffer

5条回答
  •  再見小時候
    2020-12-03 16:26

    As Clemens said, this is impossible.

    You have three choices:

    1) Do your editing in a buffer and blit when finished as Clemens suggests.

    2) Do the editing in very small chunks and schedule them at a nice priority on the GUI thread. If you keep your work chunks small enough, the GUI will remain responsive, but obviously this complicates the edit code.

    3) Combine 1 & 2. Edit small chunks in another thread, then blit each chunk as it completes. This keeps GUI responsive without using memory for a full back buffer.

提交回复
热议问题