Main MRPT website > C++ reference for MRPT 1.5.7
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 /*
27  * Codes for supported types of image transformations.
28  */
29 
30 typedef enum {
31  JXFORM_NONE, /* no transformation */
32  JXFORM_FLIP_H, /* horizontal flip */
33  JXFORM_FLIP_V, /* vertical flip */
34  JXFORM_TRANSPOSE, /* transpose across UL-to-LR axis */
35  JXFORM_TRANSVERSE, /* transpose across UR-to-LL axis */
36  JXFORM_ROT_90, /* 90-degree clockwise rotation */
37  JXFORM_ROT_180, /* 180-degree rotation */
38  JXFORM_ROT_270 /* 270-degree clockwise (or 90 ccw) */
39 } JXFORM_CODE;
40 
41 /*
42  * Although rotating and flipping data expressed as DCT coefficients is not
43  * hard, there is an asymmetry in the JPEG format specification for images
44  * whose dimensions aren't multiples of the iMCU size. The right and bottom
45  * image edges are padded out to the next iMCU boundary with junk data; but
46  * no padding is possible at the top and left edges. If we were to flip
47  * the whole image including the pad data, then pad garbage would become
48  * visible at the top and/or left, and real pixels would disappear into the
49  * pad margins --- perhaps permanently, since encoders & decoders may not
50  * bother to preserve DCT blocks that appear to be completely outside the
51  * nominal image area. So, we have to exclude any partial iMCUs from the
52  * basic transformation.
53  *
54  * Transpose is the only transformation that can handle partial iMCUs at the
55  * right and bottom edges completely cleanly. flip_h can flip partial iMCUs
56  * at the bottom, but leaves any partial iMCUs at the right edge untouched.
57  * Similarly flip_v leaves any partial iMCUs at the bottom edge untouched.
58  * The other transforms are defined as combinations of these basic transforms
59  * and process edge blocks in a way that preserves the equivalence.
60  *
61  * The "trim" option causes untransformable partial iMCUs to be dropped;
62  * this is not strictly lossless, but it usually gives the best-looking
63  * result for odd-size images. Note that when this option is active,
64  * the expected mathematical equivalences between the transforms may not hold.
65  * (For example, -rot 270 -trim trims only the bottom edge, but -rot 90 -trim
66  * followed by -rot 180 -trim trims both edges.)
67  *
68  * We also offer a "force to grayscale" option, which simply discards the
69  * chrominance channels of a YCbCr image. This is lossless in the sense that
70  * the luminance channel is preserved exactly. It's not the same kind of
71  * thing as the rotate/flip transformations, but it's convenient to handle it
72  * as part of this package, mainly because the transformation routines have to
73  * be aware of the option to know how many components to work on.
74  */
75 
76 typedef struct {
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 
88 #if TRANSFORMS_SUPPORTED
89 
90 /* Request any required workspace */
91 EXTERN(void) jtransform_request_workspace
93 /* Adjust output image parameters */
94 EXTERN(jvirt_barray_ptr *) jtransform_adjust_parameters
96  jvirt_barray_ptr *src_coef_arrays,
98 /* Execute the actual transformation, if any */
99 EXTERN(void) jtransform_execute_transformation
101  jvirt_barray_ptr *src_coef_arrays,
103 
104 #endif /* TRANSFORMS_SUPPORTED */
105 
106 
107 /*
108  * Support for copying optional markers from source to destination file.
109  */
110 
111 typedef enum {
112  JCOPYOPT_NONE, /* copy no optional markers */
113  JCOPYOPT_COMMENTS, /* copy only comment (COM) markers */
114  JCOPYOPT_ALL /* copy all optional markers */
115 } JCOPY_OPTION;
116 
117 #define JCOPYOPT_DEFAULT JCOPYOPT_COMMENTS /* recommended default */
118 
119 /* Setup decompression object to save desired markers in memory */
122 /* Copy markers saved in the given source object to the destination object */
JCOPY_OPTION option
Definition: transupp.h:121
j_compress_ptr dstinfo
Definition: transupp.h:124
boolean force_grayscale
Definition: transupp.h:80
JXFORM_CODE transform
Definition: transupp.h:78
#define JPP(arglist)
Definition: mrpt_jpeglib.h:815
backing_store_ptr info
Definition: jmemsys.h:170
JXFORM_CODE
Definition: transupp.h:30
EXTERN(void) jcopy_markers_setup JPP((j_decompress_ptr srcinfo
jcopy_markers_setup(j_decompress_ptr srcinfo, JCOPY_OPTION option)
Definition: transupp.cpp:856
jvirt_barray_ptr * workspace_coef_arrays
Definition: transupp.h:84
JCOPY_OPTION
Definition: transupp.h:111
jcopy_markers_execute(j_decompress_ptr srcinfo, j_compress_ptr dstinfo, JCOPY_OPTION)
Definition: transupp.cpp:881



Page generated by Doxygen 1.8.14 for MRPT 1.5.7 Git: 5902e14cc Wed Apr 24 15:04:01 2019 +0200 at lun oct 28 01:39:17 CET 2019