Getting an array of bytes out of Windows::Storage::Streams::IBuffer(从 Windows::Storage::Streams::IBuffer 中获取字节数组)
问题描述
我有一个实现接口 Windows::Storage::Streams::IBuffer
的对象,我想从中获取一个字节数组,但是在查看此接口的文档时看起来很没用,并且文档没有提供对可以与此接口结合以实现我的目的的任何其他类的任何参考.到目前为止,我在谷歌上发现的所有内容都是对 .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.
有人可以提示一下如何从 C++ 中的 Windows::Storage::Streams::IBuffer
获取字节数组吗?
Can someone give a hint on how to get an array of bytes from Windows::Storage::Streams::IBuffer
in C++?
推荐答案
您可以使用 IBufferByteAccess,通过异国情调的 COM 转换:
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 中获取字节数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:从 Windows::Storage::Streams::IBuffer 中获取字节数组


基础教程推荐
- 如何在 C++ 中初始化静态常量成员? 2022-01-01
- 在 C++ 中计算滚动/移动平均值 2021-01-01
- 如何通过C程序打开命令提示符Cmd 2022-12-09
- 我有静态或动态 boost 库吗? 2021-01-01
- 这个宏可以转换成函数吗? 2022-01-01
- C++结构和函数声明。为什么它不能编译? 2022-11-07
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
- 常量变量在标题中不起作用 2021-01-01
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01