保存位图的C ++ [英] Save BITMAP C++

查看:117
本文介绍了保存位图的C ++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要保存BITMAPINFO使用从非托管code到buffer(流)(连载)GDI32位图,以及缓冲传递给管理code,反之亦然。

I need to save (serialize) gdi32 Bitmap using BITMAPINFO from unmanaged code into buffer (Stream), and pass that buffer to managed code, and vice versa.

图像不gdiplus,但本土GDI32,和.NET Bitmap.From ...方法不起作用...

The Image is not gdiplus, but native gdi32, and .NET Bitmap.From... methods don't work...

这问题不是封送处理,它是关于几个参数WINDOWS32 API

This question is not about Marshaling, it's about Windows32 API with several parameters

是这样的:

(serialize) int m_Size SaveBitmapToMemory(HBITMAP hBmp, GUID FormatBMP, **buffer); 
(deserialize) HBITMAP bmp LoadBitmapFromMemory(*buffer, int size);

你知不知道这样的事情?
我再说一遍,有没有这样的API,我只是看看4类似的东西。

Do you know something like that? I repeat, there are no such APIs, I'm just looking 4 something like that.

感谢

推荐答案

我想你需要只写了 BITMAPFILEHEADER 您的信息流,那么就复制 HBITMAP DIB 直接。似乎有很多在网络上这样的例子,例如,在这里

I think you need to just write a BITMAPFILEHEADER to your stream, then just copy the HBITMAP's DIB directly. There seem to be plenty of examples of this on the web, for example, here.

这是创建一个.bmp文件,这是我所期待的流格式要求的方式。

That's the way of creating a .BMP file, which is what I'd expect your stream format requires.

这篇关于保存位图的C ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆