I have an object that implements the interface Windows::Storage::Streams::IBuffer, and I want to get an array of bytes out of it, however while looking at the d
Since this question is tagged c++, here's a solution using C++/WinRT. It essentially does the same as this answer under the hood, but is way more accessible. The (undocumented) data() helper on the IBuffer projection does all the heavy lifting:
uint8_t* GetPointerToPixelData(::winrt::Windows::Storage::Streams::IBuffer const& buffer)
{
return buffer.data();
}
There is unfortunately no official documentation (yet), and I only stumbled across this in the sample code for the WritableBitmap.PixelBuffer property (make sure to select "C++/WinRT" from the language dropdown at the top right).
An identical solution (querying for the IBufferByteAccess interface) is also available from that documentation entry when selecting "C++/CX" from the language dropdown.