Click here to Skip to main content
15,868,141 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I wanna want to write a program which can rotate image, substract, add two image but I don't know how to read and write to JPEG file, and I do not know the format of JPEG file. Can someone help me?
Posted
Updated 27-Jun-13 9:37am
v3

You don't need to know the format of the JPEG files for manipulating them. You may, for instance load (and manipulate) them using GDI+ (see, for instance "Rotating, Reflecting, and Skewing Images"[^]).
 
Share this answer
 
If GDI+ is not an option for you, then I would recommend to use one of the many libraries for converting image formats. For example this one:

CxImage[^]

That doesn't mean you should not have a look at the JPEG specification, as Harvey suggested in Solution 2. It just means that the JPEG standard is not trivial to understand implement and you might end up with a couple thousand line of C++ code. So for faster results you might want to use a good library.

A word about rotation. You can rotate a JPEG image by converting it into a bitmap, then rotate it (which is quite easy) and then re-encode it as a JPEG. This process is however not absolutely lossless, because JPEG is a lossy compression method. There is however a way of rotating a JPEG image without converting it into a bitmap, just by manipulating the internal data structures. Some libraries support lossles JPEG rotation. Just google for "jpegtran".
 
Share this answer
 
The file format for JPEG and how to build/manipulate one can be found here[^].
 
Share this answer
 

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