Solved

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

Posted on 2003-12-01
5
1,237 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PDF library for Delphi 2 128
Grammars for C C++ and java 1 131
Exception thrown at 0x00007FFD5BC81F28 7 49
gdb doesn't stop on breakpoint 2 93
Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
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 additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

809 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