Solved

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

Posted on 2003-12-01
5
1,230 Views
Last Modified: 2012-05-04
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
0
Comment
Question by:Shifeng
5 Comments
 
LVL 4

Accepted Solution

by:
skypalae earned 63 total points
ID: 9856241
what about http://www.smalleranimals.com/jpegfile.htm ?? is it suitable enough?
S.
0
 
LVL 2

Assisted Solution

by:JensUniweb
JensUniweb earned 62 total points
ID: 9856612
Unother alternative is http://www.ijg.org/. It's a widly spread library first made for for UNIX systems. But are now available on Windwos and other platforms to.
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 9856663
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
0
 
LVL 5

Expert Comment

by:migoEX
ID: 10331438
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
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now