How can I manipulate/rotate a JPEG image in C++?

2019-09-27 16:00发布

问题:

I'd like to use the compiled libjpeg-9 example.c and transupp.c code and libraries to rotate a .jpg image in an Eclipse project.

Working progress on achieving this from the start: Compiling/using libjpeg in Windows for Eclipse

Trying to integrate do_rot_180 and read/write functions into one location: Need help compiling jpegtran.c code from libjpeg

回答1:

do_rot_180 function in transupp.c in libjpeg (you are aware of it as the Q has the tag) is doing exactly what you want.

LOCAL(void)
do_rot_180 (j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
        jvirt_barray_ptr *src_coef_arrays,
        jvirt_barray_ptr *dst_coef_arrays)
/* 180 degree rotation is equivalent to
 *   1. Vertical mirroring;
 *   2. Horizontal mirroring.
 * These two steps are merged into a single processing routine.
 */

The function is used by jtransform_execute_transformation/JXFORM_ROT_180 and loslessy reorders JPEG's internals to achieve rotation effect. This function demonstrates the use and rotates a given file and writes a new modified file using specified transformation (angle).



回答2:

Have you get a look at the imagemagick library? it's free and very powerful tool