Loading JPEG

Started by
4 comments, last by ReKlipz 18 years, 8 months ago
Hy! I am using VC++ 6.0, how can I load .JPG files? Just loading is required for me, the data must be in the memory in RGB (decoded) format, what is the easyest way? Is there a built-in library in the Visual C 6.0, with I can do that? Please send source code, or good links for me. I'm beginner, the simplest way would be the best. Please help me!
Advertisement
Try looking at this site: http://nehe.gamedev.net/ Here he has some code I believe is called IPicture. It is pretty simple to use.
There are plenty of image handling libraries out there which are capable of handling JPEG compressed images, a popular one is DevIL which works well with OpenGL. If you want to get down and dirty with the internals of the format you can use the Jpeglib for decoding the files which is available here.
Spudder's second recommendation (the IJG's library) is the easiest way to get pixel data in memory. However, if you're able to work with a bit of COM (no extra libraries needed), my favorite way is using OLELoadPicture and the IPicture interface. For example code, see this article on MSDN. (Note that you don't really have to be building an "MFC application" to use this -- my SimpleView program is straight Win32 except for this tiny portion.)

Cheers,
Twilight Dragon
{[JohnE, Chief Architect and Senior Programmer, Twilight Dragon Media{[+++{GCC/MinGW}+++{Code::Blocks IDE}+++{wxWidgets Cross-Platform Native UI Framework}+++
There are also other easy options for loading jpeg files depending upon the context of your program. If you are using Direct3D, you can use its image loading utility in D3DX, D3DXLoadSurfaceFromFile. If you are only targeting WinXP and Win2003 or later, you can use GDI+ and use its Bitmap::FromFile function. (GDI+ can also be used on older versions of Windows, but only if you include the library in your distribution.)
.
heh, i just wrote a JPG loader using the jpeglib

simple stuff really

just use their built in functions and its about 6 or so calls to them, and your done, one for loop to build the data, couldnt be simpler, or faster

This topic is closed to new replies.

Advertisement