从Windows :: Storage :: Streams :: IBuffer获取一个字节数组 [英] Getting an array of bytes out of Windows::Storage::Streams::IBuffer
问题描述
我有一个实现接口 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;
}
从http://cm-bloggers.blogspot.fi/2012/09/accessing-image-pixel- data-in-ccx.html
这篇关于从Windows :: Storage :: Streams :: IBuffer获取一个字节数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!