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
You can use IBufferByteAccess, through exotic COM casts:
byte* GetPointerToPixelData(IBuffer^ buffer)
{
// Cast to Object^, then to its underlying IInspectable interface.
Object^ obj = buffer;
ComPtr insp(reinterpret_cast(obj));
// Query the IBufferByteAccess interface.
ComPtr bufferByteAccess;
ThrowIfFailed(insp.As(&bufferByteAccess));
// Retrieve the buffer data.
byte* pixels = nullptr;
ThrowIfFailed(bufferByteAccess->Buffer(&pixels));
return pixels;
}
Code sample copied from http://cm-bloggers.blogspot.fi/2012/09/accessing-image-pixel-data-in-ccx.html