none
InteropBitmap synchronization

    Question

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

    Imaging.CreateBitmapSourceFromMemorySection()

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

    From the WPF source code, InteropBitmap is just a wrapper of IWICBitmap, but it doesn't exposeIWICBitmap::lock which is used for exclusive writing (there is a unofficial way to expose this interface).

    So, how do I sync writing and reading of WPF InteropBitmap?

    1. Updating occurs in user's thread.
    2. Reading always occurs in WPF internal render thread via IWICBitmapSource::CopyPixels

    Thanks

    Wednesday, June 01, 2011 1:55 AM

Answers

  • Hi Chang Chen,

    No I am afraid there is not such a straightforward way to make synchronization of InteropBitmap in WPF. The possible workaround may be converting the InteropBitmap to WritableBitmap which has a Lock method. Please kindly check if this could meet your requirements.

    Best regards


    Yves Zhang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, June 03, 2011 7:05 AM