How can you display a jpeg image in C++? I am using Windows XP and the IDE is Dev-C++.
How can you display a jpeg image in C++? I am using Windows XP and the IDE is Dev-C++.
Which end of the spectrum of answers are you looking for?
Easy - I don't care what libraries I need, I'd be happy with just supplying a filename and a place to draw it, and let it do all the hard work.
Hard - I want to decode all the bits in the file myself, and put each pixel on screen how I want to.
Can you even do pixel bashing anyway?
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
This is a very common question.
Displaying graphics is platform specific, because there are no standard libraries for this.
You need to use an API or a wrapper to display JPEG images. (Win32 API is good)
"The Internet treats censorship as damage and routes around it." - John Gilmore
I'm interested in the same thing. Can you post some links for both methods?
The windows board seems a more appropriate place for this question.
The simplest solution is usually to use gdiplus but some people have difficulty converting the headers for use with dev-cpp, so the next simplest approach would be to use OleLoadPicturePath(or OleLoadPicture), since you've only specified jpeg as an image type.
As others have pointed out already, you could use other libraries or you could spend a lot of time working out how to do the whole thing for yourself.
edit: There's a method suggested by anonytmouse in this thread which uses a listview control to display the image.
CProgramming FAQ
Caution: this person may be a carrier of the misinformation virus.
I will be placing the jpeg image at a specific location on the screen.
Text will be displayed simutaneously next to the jpeg image using the string variable with cout >>.
Can you present the code with Easy and Hard? What is pixel bashing?
Originally Posted by Salem
There's an example by JaWiB in this thread which demonstrates how for bitmaps (windows native image format): please note that this example, while functional after a fashion, was intended as a curiosity and an amusing one at that.Originally Posted by C2beginner
A rhetorical question, methinks - your response implies you still have a great deal yet to learn before you could competently attempt anything like this.What is pixel bashing?
I'd suggest switching to gui programming and using the listview example previously described as the most expedient - and realistic - approach to accomplish what you intend.
See the Windows Programming Links sticky at the top of this board to get started with winapi (win32) programming, if you wish to follow this route.
CProgramming FAQ
Caution: this person may be a carrier of the misinformation virus.
You are making my head ache, IMAGES ARE FOR GUI AND FOR GUI ONLY. You need to learn WIN32 API as Ken Fitlike already said.Originally Posted by C2beginner
"The Internet treats censorship as damage and routes around it." - John Gilmore