locked
convert BitmapImage to writeableBitmap

    Question

  • how to solute it.

    who can give me some sample code, thanks


    winRT



    • Edited by King Star Monday, July 02, 2012 3:16 AM
    Thursday, June 28, 2012 7:22 AM

Answers

  • You need to keep track of the source for the BitmapImage and create the WriteableBitmap from the same source.

    --Rob

    Thursday, June 28, 2012 4:54 PM
    Owner
  • we can use the source for the BitmapImage and create the WriteableBitmap from the same source.

    the source is bytes, we can create WriteableBitmap with IBufferByteAccess. following:

    IUnknown* pUnknown = reinterpret_cast<IUnknown*>(wb->PixelBuffer);
    IBufferByteAccess* pBufferByteAccess = nullptr;
    HRESULT hr = pUnknown->QueryInterface(IID_PPV_ARGS(&pBufferByteAccess));
    pUnknown->Release();

    byte* pBuffCopy = nullptr;
    pBufferByteAccess->Buffer(&pBuffCopy);

    now set pixelArray to pBuffCopy, Then we can create WriteableBitmap with pixelArray.

    We can use WriteableBitmap .

    ---King Star.


    winRT

    • Marked as answer by King Star Friday, July 27, 2012 4:04 AM
    Friday, July 27, 2012 4:04 AM

All replies

  • You need to keep track of the source for the BitmapImage and create the WriteableBitmap from the same source.

    --Rob

    Thursday, June 28, 2012 4:54 PM
    Owner
  • we can use the source for the BitmapImage and create the WriteableBitmap from the same source.

    the source is bytes, we can create WriteableBitmap with IBufferByteAccess. following:

    IUnknown* pUnknown = reinterpret_cast<IUnknown*>(wb->PixelBuffer);
    IBufferByteAccess* pBufferByteAccess = nullptr;
    HRESULT hr = pUnknown->QueryInterface(IID_PPV_ARGS(&pBufferByteAccess));
    pUnknown->Release();

    byte* pBuffCopy = nullptr;
    pBufferByteAccess->Buffer(&pBuffCopy);

    now set pixelArray to pBuffCopy, Then we can create WriteableBitmap with pixelArray.

    We can use WriteableBitmap .

    ---King Star.


    winRT

    • Marked as answer by King Star Friday, July 27, 2012 4:04 AM
    Friday, July 27, 2012 4:04 AM