在内存中将 BMP 文件转换为 PNG 文件
可能的重复:
在 C++ (win32) 中将位图转换为内存中的 PNG
我有一个 BMP 文件作为 char*
缓冲区。我想在内存中将此 BMP 文件转换为 PNG 文件。我已经尝试过,并进行了一些搜索,但我找不到任何有用的东西。
我可以假设 Windows XP 或更高版本,没有 .NET 和 C99。
Possible Duplicate:
Convert bitmap to PNG in-memory in C++ (win32)
I have a BMP file as a char*
buffer. I want to convert this BMP file to a PNG file in-memory. I have tried it, and searched around a bit, but I couldn't find anything useful.
I can assume Windows XP or later, no .NET and C99.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
ImageMagick 有一个 C API。我认为,由于它允许您对图像执行各种转换,因此这些图像保存在内存中,因此您应该能够将其加载为 BMP 并最终将其保存为 PNG。
ImageMagick has a C API. I would assume, since it lets you perform various transformations on images, that those images are kept in memory, so you should be able to just load it as BMP and eventually save it as PNG.
在记忆中,你可能必须自己做。您必须了解 BMP 和 PNG 文件的标题。成功创建标题后,您可以复制数据,但 BMP 和 PNG 中的数据不以相同的形式存储,因此这是一项相当耗时的任务。
另一种方法是使用外部工具并从 C 代码调用它来进行转换。然而内存问题将会受到质疑。
In memory means, you probably have to do it yourself. You have to understand the headers of both BMP and PNG files. After you successfully create the header, you can copy data but data is not stored in the same form in BMP and PNG so it is quite time consuming task.
Another way to do it, is use an external tool and call it from C code to do the conversion. However the in-memory problem will be in question.