如何将bmp图像转换为char数组 [英] how to convert bmp image to char array

查看:165
本文介绍了如何将bmp图像转换为char数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道使用c ++从bmp到char * arr []的转换



I want to know conversion from bmp to char *arr[] using c++

bitmap_type pBmp(new ClSimpleBitmap);
            std::auto_ptr<std::string> pFileName(LoadFile(TRUE
                                                         ,_T("BMP files (*.bmp)|*.bmp|PNG files (*.png)|*.png|WSQ files (*.wsq)|*.wsq|JPEG2000 files (*.jp2)|*.jp2|"
                                                         )));







pBmp->加载(pFileName-> c_str())

BITMAPINFOHEADER * header = pBmp-> BI();

现在我掌握了所有图像信息。

现在我在pBmp和HEADER图像中有图像(在标题中)。现在我想将它转换为char * arr []。




pBmp->Load(pFileName->c_str())
BITMAPINFOHEADER* header=pBmp->BI();
Now I have all information of image.
Now I have image in pBmp and HEADER of image(in header). And now I want to convert it to char *arr[].

推荐答案

看看在GDI +中使用LockBits [ ^ ]



祝你好运

Espen Harlinn
Have a look at Using LockBits in GDI+[^]

Best regards
Espen Harlinn


另一个参考是



http://www.bobpowell.net/ lockingbits.htm [ ^ ]


访问char *或更好地访问位图的 byte 数据只是第一部分。您必须正确解释BITMAPINFOHEADER才能对数据进行解码以进行进一步处理。请阅读 Microsoft文档以了解数据结构及其信息。要获取位图数据,请 GetDibits



阅读位图基础知识文章,以了解所需的见解。我也喜欢 CXImage 文章,但它更适合高级操作。



提示:玩一些简单的示例图片直到所有运行正常
The access to the char* or better to the byte data of your bitmap is only the first part. You must correctly interpret the BITMAPINFOHEADER to decode the data for further processing. Please read the Microsoft documentation to understand the data structure and its information. For fetching the bitmap data is the GetDibits.

Read the Bitmap Basics article to learn the needed insights. I also like the CXImage article but it is more for advanced manipulation.

Tip: play around with some simple example pics til all is runnning fine


这篇关于如何将bmp图像转换为char数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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