如何将 BYTE* 转换为 gdi+ 图像对象?

发布于 2024-07-09 00:52:26 字数 297 浏览 4 评论 0原文

我想将 BYTE* 转换为 gdi+ Image 对象。

我怎样才能做到这一点?

BYTE* 似乎是一个 Dib 点。

我发现 Image 有一个名为 Image::FromStream() 的方法可能会有所帮助, 但我找不到任何有关如何将 BYTE* 转换为 IStream 对象的参考。 我怎样才能做到这一点?

提前致谢!

实际上,很难相信MS提供了IStream接口,但没有提供任何实现该接口的c++ MemoryStream类。

I want to convert a BYTE* into an gdi+ Image object.

How can I do this?

The BYTE* seems a Dib point.

I found Image has a method named Image::FromStream() which may help,
But I can not find any reference about how to convert a BYTE* into a IStream object.
How can I do this?

Thanks in advance!

Actually, it is hard to believe MS provide a IStream interface, but do not provide any c++ MemoryStream class which implements the interface.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

ˉ厌 2024-07-16 00:52:26

CreateStreamOnHGlobal 将采用 HGLOBAL 并为您提供IStream 指针。 您需要使用 GlobalAlloc 分配足够的内存,然后将 BYTE 数组复制到 HGLOBAL 中。

如果您知道您获得的图像数据是 GDI DIB,则可以使用 GdipCreateBitmapFromGdiDib 或相应的 Bitmap::Bitmap 构造函数。

CreateStreamOnHGlobal will take an HGLOBAL and give you an IStream pointer. You'll need to allocate enough memory with GlobalAlloc, and then copy your BYTE array into the HGLOBAL.

If you know that the image data you've got is a GDI DIB, you can use GdipCreateBitmapFromGdiDib or the corresponding Bitmap::Bitmap constructor.

嘿哥们儿 2024-07-16 00:52:26

你知道BYTE指针指向的图像数据的格式吗? 为了使 Image 能够从流中构建自身,数据必须采用受支持的标准图像格式之一(GIF、PNG、JPEG 等)。

IStream 界面看起来足够简单如果没有合适的“内存流”或类似的,请自行实现。

Do you know the format of the image data the BYTE pointer points at? For Image to be able to construct itself from a stream, the data must be in one of the supported standard image formats (GIF, PNG, JPEG etc).

The IStream interface looks to be simple enough to implement on your own, if there's no suitable "memory stream" or similiar.

茶色山野 2024-07-16 00:52:26

使用 SHCreateMemStream< /a>,

IStream* stream = ::SHCreateMemStream({your BYTE array}, {size of the array});
Gdiplus::Image *img = Gdiplus::Image::FromStream(stream);

Using SHCreateMemStream,

IStream* stream = ::SHCreateMemStream({your BYTE array}, {size of the array});
Gdiplus::Image *img = Gdiplus::Image::FromStream(stream);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文