从Windows :: Storage :: Streams :: IBuffer获取一个字节数组

编程入门 行业动态 更新时间:2024-10-11 11:20:43
本文介绍了从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; }

从cm-bloggers.blogspot.fi/2012/09/accessing-image-pixel- data-in-ccx.html

更多推荐

从Windows :: Storage :: Streams :: IBuffer获取一个字节数组

本文发布于:2023-11-07 15:56:44,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1566869.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数组   字节   Storage   Windows   IBuffer

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!