Main MRPT website > C++ reference for MRPT 1.9.9
transupp.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 /* If you happen not to want the image transform support, disable it here */
11 #ifndef TRANSFORMS_SUPPORTED
12 #define TRANSFORMS_SUPPORTED 1 /* 0 disables transform code */
13 #endif
14 
15 /* Short forms of external names for systems with brain-damaged linkers. */
16 
17 #ifdef NEED_SHORT_EXTERNAL_NAMES
18 #define jtransform_request_workspace jTrRequest
19 #define jtransform_adjust_parameters jTrAdjust
20 #define jtransform_execute_transformation jTrExec
21 #define jcopy_markers_setup jCMrkSetup
22 #define jcopy_markers_execute jCMrkExec
23 #endif /* NEED_SHORT_EXTERNAL_NAMES */
24 
25 /*
26  * Codes for supported types of image transformations.
27  */
28 
29 typedef enum {
30  JXFORM_NONE, /* no transformation */
31  JXFORM_FLIP_H, /* horizontal flip */
32  JXFORM_FLIP_V, /* vertical flip */
33  JXFORM_TRANSPOSE, /* transpose across UL-to-LR axis */
34  JXFORM_TRANSVERSE, /* transpose across UR-to-LL axis */
35  JXFORM_ROT_90, /* 90-degree clockwise rotation */
36  JXFORM_ROT_180, /* 180-degree rotation */
37  JXFORM_ROT_270 /* 270-degree clockwise (or 90 ccw) */
38 } JXFORM_CODE;
39 
40 /*
41  * Although rotating and flipping data expressed as DCT coefficients is not
42  * hard, there is an asymmetry in the JPEG format specification for images
43  * whose dimensions aren't multiples of the iMCU size. The right and bottom
44  * image edges are padded out to the next iMCU boundary with junk data; but
45  * no padding is possible at the top and left edges. If we were to flip
46  * the whole image including the pad data, then pad garbage would become
47  * visible at the top and/or left, and real pixels would disappear into the
48  * pad margins --- perhaps permanently, since encoders & decoders may not
49  * bother to preserve DCT blocks that appear to be completely outside the
50  * nominal image area. So, we have to exclude any partial iMCUs from the
51  * basic transformation.
52  *
53  * Transpose is the only transformation that can handle partial iMCUs at the
54  * right and bottom edges completely cleanly. flip_h can flip partial iMCUs
55  * at the bottom, but leaves any partial iMCUs at the right edge untouched.
56  * Similarly flip_v leaves any partial iMCUs at the bottom edge untouched.
57  * The other transforms are defined as combinations of these basic transforms
58  * and process edge blocks in a way that preserves the equivalence.
59  *
60  * The "trim" option causes untransformable partial iMCUs to be dropped;
61  * this is not strictly lossless, but it usually gives the best-looking
62  * result for odd-size images. Note that when this option is active,
63  * the expected mathematical equivalences between the transforms may not hold.
64  * (For example, -rot 270 -trim trims only the bottom edge, but -rot 90 -trim
65  * followed by -rot 180 -trim trims both edges.)
66  *
67  * We also offer a "force to grayscale" option, which simply discards the
68  * chrominance channels of a YCbCr image. This is lossless in the sense that
69  * the luminance channel is preserved exactly. It's not the same kind of
70  * thing as the rotate/flip transformations, but it's convenient to handle it
71  * as part of this package, mainly because the transformation routines have to
72  * be aware of the option to know how many components to work on.
73  */
74 
75 typedef struct
76 {
77  /* Options: set by caller */
78  JXFORM_CODE transform; /* image transform operator */
79  boolean trim; /* if TRUE, trim partial MCUs as needed */
80  boolean force_grayscale; /* if TRUE, convert color image to grayscale */
81 
82  /* Internal workspace: caller should not touch these */
83  int num_components; /* # of components in workspace */
84  jvirt_barray_ptr* workspace_coef_arrays; /* workspace for transformations */
86 
87 #if TRANSFORMS_SUPPORTED
88 
89 /* Request any required workspace */
90 EXTERN(void)
91 jtransform_request_workspace JPP(
92  (j_decompress_ptr srcinfo, jpeg_transform_info* info));
93 /* Adjust output image parameters */
95 jtransform_adjust_parameters JPP(
96  (j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
97  jvirt_barray_ptr* src_coef_arrays, jpeg_transform_info* info));
98 /* Execute the actual transformation, if any */
99 EXTERN(void)
100 jtransform_execute_transformation JPP(
101  (j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
102  jvirt_barray_ptr* src_coef_arrays, jpeg_transform_info* info));
103 
104 #endif /* TRANSFORMS_SUPPORTED */
105 
106 /*
107  * Support for copying optional markers from source to destination file.
108  */
109 
110 typedef enum {
111  JCOPYOPT_NONE, /* copy no optional markers */
112  JCOPYOPT_COMMENTS, /* copy only comment (COM) markers */
113  JCOPYOPT_ALL /* copy all optional markers */
114 } JCOPY_OPTION;
115 
116 #define JCOPYOPT_DEFAULT JCOPYOPT_COMMENTS /* recommended default */
117 
118 /* Setup decompression object to save desired markers in memory */
119 EXTERN(void)
121 /* Copy markers saved in the given source object to the destination object */
122 EXTERN(void)
124  (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, JCOPY_OPTION option));
#define EXTERN(type)
Definition: jmorecfg.h:179
boolean force_grayscale
Definition: transupp.h:80
JXFORM_CODE transform
Definition: transupp.h:78
JXFORM_CODE
Definition: transupp.h:29
jcopy_markers_setup(j_decompress_ptr srcinfo, JCOPY_OPTION option)
Definition: transupp.cpp:984
jcopy_markers_setup JPP((j_decompress_ptr srcinfo, JCOPY_OPTION option))
jvirt_barray_ptr * workspace_coef_arrays
Definition: transupp.h:84
JCOPY_OPTION
Definition: transupp.h:110
jcopy_markers_execute(j_decompress_ptr srcinfo, j_compress_ptr dstinfo, JCOPY_OPTION)
Definition: transupp.cpp:1011



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019