Click here to Skip to main content
15,906,329 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to know conversion from bmp to char *arr[] using c++

XML
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->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[].
Posted
Updated 20-Apr-17 22:59pm
v5

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

Best regards
Espen Harlinn
 
Share this answer
 
Comments
Prasad_Kulkarni 11-Jul-12 9:16am    
Good reference +5
Espen Harlinn 11-Jul-12 9:16am    
Thank you, Prasad :-D
Sergey Alexandrovich Kryukov 22-Jul-12 14:44pm    
Good reference, a 5.
--SA
Espen Harlinn 22-Jul-12 14:47pm    
Thank you, Sergey :-D
Yet another reference is

http://www.bobpowell.net/lockingbits.htm[^]
 
Share this answer
 
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
 
Share this answer
 
Comments
CHill60 21-Apr-17 5:17am    
Nearly 5 years old question with an accepted solution ... was it worth resurrecting?
enhzflep 28-Apr-17 4:25am    
Well, given the fact that the questions and answer exist to serve the purposes of not only the asker, but also that of others with the same problem the time since the question was asked is not relevant, imho.
What is a far more important yard-stick by which to judge usefullness I think, is the quality of the answer. In my opinion, this answer surpasses the others (I've not followed the off-site links).

As such, the answer to your question is a resounding YES. Unfortunately, some miserable soul has seen fit to hit it with the down-vote hammer.

I'm curious - what are your thoughts?
CHill60 28-Apr-17 4:46am    
I'm usually of the view that the external information and/or articles on the subject would appear in a(n undirected) Google search before solutions to an old post. I'm guessing the post reappeared because "Solution 3" was an inappropriate response (spam, a question or a comment).
I agree that this solution is the best here - that doesn't surprise me from KarstenK :-)
As to the down-vote - I think there is someone who just goes around the forums downvoting for the sake of it. I do downvote sometimes but I prefer to comment as to why - how else do we learn?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900