Solved

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

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

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…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

747 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

13 Experts available now in Live!

Get 1:1 Help Now