C++ Windows JPEG 到字节流
我有一个 HENHMETAFILE
。我想构造一个具有给定宽度和高度的 JPEG,并将其发送到某个服务器。为此,我需要获取 JPEG 的字节流以及该流的大小(以字节为单位)。
目前,我使用 CImage::Save 来将元文件作为 JPEG 保存到磁盘,然后读取创建的文件以获取字节流,然后删除 JPEG。这显然是一种相当尴尬的做法。
有谁知道如何跳过将图像存储到磁盘的过程吗?如果可能的话,我宁愿不使用外部库。我正在使用 MSVC++ 2010。
I have a HENHMETAFILE
. I want to construct a JPEG with given width and height out of it, and send it to some server. For doing this I need to get a bytestream of the JPEG, and the size of the stream in bytes.
Currently I do this with CImage::Save
to save the meta file to disk as JPEG, then read the created file to get my bytestream, and delete the JPEG afterwards. This obviously is quite an awkward approach.
Does anyone have a hint how to skip the process of storing the image to disk? I would prefer to not use external libraries if possible. I am using MSVC++ 2010.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
CImage::Save() 有用于保存到 IStream。
本文展示了如何在内存中使用图像压缩:
http://www.codeproject.com/KB/GDI-plus/MemImage.aspx
它使用 GDI+ 图像代替,但应该足以让您入门。
CImage::Save() has a second overload for saving to an IStream.
This article shows how to use in memory image compression:
http://www.codeproject.com/KB/GDI-plus/MemImage.aspx
It uses the GDI+ Image instead, but should be enough to get you started.