Click here to Skip to main content
15,910,773 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear All,

I need C program to a JPG formated image, and i have convert it to uncompressed image, please help me to the same.
Posted

I've read that there is about 1 man-year's worth of work to create a jpeg encoder/decoder.

Must you use C, or can you use C++?

GdiPlus(C++) will allow you to open/save files with a small addition of code to your project. This is a included part of Windows since XP. (gdiplus.h gdiplus.lib)

Steps:
  • Create gdiPlus::Bitmap, load it with your image file
  • Create a HBITMAP from this bitmap
  • GetDibBits on this HBITMAP
  • Clean-up result, removing padding bytes (if present) from end of each scan-line.

Note: init/shutdown of gdiPlus ommited for brevity


Failing that, you may choose to review jpegLib (dunno if it's c or c++)
 
Share this answer
 
There is an excellent library here on CodeProject that lets you read JPEG files and convert it into almost anything. This link

CxImage

will get you there. It is a C++ library, though. If you need pure C code, you could try to extract the essential parts and back-convert them to C.

Hope that helps.
 
Share this answer
 
Comments
enhzflep 8-Apr-12 8:39am    
Just checked, the CxImage package actually includes jpegLib.

jpegLib is itself plain ol' C. :)
nv3 8-Apr-12 9:18am    
Oh, good. In that case jpeglib should do the job. Got my 5.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900