Link to home
Start Free TrialLog in
Avatar of Shifeng
Shifeng

asked on

how to convert a jpeg file into a c++ matrix ?

hi, i need to convert a jpeg file into a c++ 2D matrix, with each value representing the pixel's greyscale value of the jpeg file. Please help ? Thank you in advance ! =P
ASKER CERTIFIED SOLUTION
Avatar of skypalae
skypalae

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DanRollins
Convert the JPG into a Bitmap (DIB Section).  Then you can access the pixel data:

    C++ Q&A: Displaying a JPG in your MFC Application -- MSDN Magazine, October 2001
    http://msdn.microsoft.com/msdnmag/issues/01/10/c/default.aspx
    http://msdn.microsoft.com/msdnmag/issues/01/10/c

    OleLoadPicture API call
    http://msdn.microsoft.com/library/en-us/com/htm/ofn_ol2z_0k4l.asp

    SAMPLE: How to Load and Display Graphics Files with LOADPIC.EXE
    http://support.microsoft.com/support/kb/articles/Q218/9/72.ASP

After you have converted it (in memory) and have an HBITMAP, I'll show you how to access the grayscale pixels as (X,Y) of a 2-D array.

-- Dan
Avatar of migoEX
migoEX

No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Split between skypalae,  JensUniweb and DanRollins.

Please leave any comments here within the next four days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

migoEX
EE Cleanup Volunteer