我有一个实现接口 Windows :: Storage :: Streams :: IBuffer 的对象,我想要一个字节数组,看看文档这个界面看起来很无用,文档不提供任何其他类可以与此接口结合实现我的目的的任何引用。所有我到目前为止已经找到的google是引用.Net类 WindowsRuntimeBufferExtensions ,但我使用C ++,所以这也是一个死胡同。
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 documentation this interface looks pretty useless, and the documentation does not offer any reference to any other class that could be combined with this interface to achieve my purpose. All I have found so far with google is a reference to the .Net class WindowsRuntimeBufferExtensions but I am using C++ so this is also a dead end.
有人可以提供如何从获取一个字节数组的提示Windows :: Storage :: Streams :: IBuffer
推荐答案您可以通过异常COM转型使用IBufferByteAccess:
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<IInspectable> insp(reinterpret_cast<IInspectable*>(obj)); // Query the IBufferByteAccess interface. ComPtr<IBufferByteAccess> bufferByteAccess; ThrowIfFailed(insp.As(&bufferByteAccess)); // Retrieve the buffer data. byte* pixels = nullptr; ThrowIfFailed(bufferByteAccess->Buffer(&pixels)); return pixels; }从cm-bloggers.blogspot.fi/2012/09/accessing-image-pixel- data-in-ccx.html
更多推荐
从Windows :: Storage :: Streams :: IBuffer获取一个字节数组
发布评论