InteropBitmap Sync

WPF InteropBitmap can be created from shared memory, i.e.

Imaging.CreateBitmapSourceFromMemorySection()

In this case, we can update the shared memory in another thread or process, and then after the update call InteropBitmap.Invalidate () to represent the changes.

From the WPF source code, InteropBitmap is only an IWICBitmap shell, but it does not provide IWICBitmap :: lock , which is used for an exceptional document.

So, how do I synchronize write and read WPF InteropBitmap?

thank

+5
source share
1 answer

You can create a WrapperClass that opened the lock object and methods for managing the image. Is some kind of work, but will work 100%

sort of:

class InteropBitmapSyncWrapper
{

    public InteropBitmapSyncWrapper(InteropBitmap wrappedBitmap)
    {
        WrappedBitmap = wrappedBitmap;
        this.Lock = new Object();
    }

    public InteropBitmap WrappedBitmap
    {
        get;
        set;
    }

    public Object Lock
    {
        get;
        private set;
    }
}
-2
source

All Articles