ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

transupp.h
Go to the documentation of this file.
00001 /*
00002  * transupp.h
00003  *
00004  * Copyright (C) 1997-2009, Thomas G. Lane, Guido Vollbeding.
00005  * This file is part of the Independent JPEG Group's software.
00006  * For conditions of distribution and use, see the accompanying README file.
00007  *
00008  * This file contains declarations for image transformation routines and
00009  * other utility code used by the jpegtran sample application.  These are
00010  * NOT part of the core JPEG library.  But we keep these routines separate
00011  * from jpegtran.c to ease the task of maintaining jpegtran-like programs
00012  * that have other user interfaces.
00013  *
00014  * NOTE: all the routines declared here have very specific requirements
00015  * about when they are to be executed during the reading and writing of the
00016  * source and destination files.  See the comments in transupp.c, or see
00017  * jpegtran.c for an example of correct usage.
00018  */
00019 
00020 /* If you happen not to want the image transform support, disable it here */
00021 #ifndef TRANSFORMS_SUPPORTED
00022 #define TRANSFORMS_SUPPORTED 1      /* 0 disables transform code */
00023 #endif
00024 
00025 /*
00026  * Although rotating and flipping data expressed as DCT coefficients is not
00027  * hard, there is an asymmetry in the JPEG format specification for images
00028  * whose dimensions aren't multiples of the iMCU size.  The right and bottom
00029  * image edges are padded out to the next iMCU boundary with junk data; but
00030  * no padding is possible at the top and left edges.  If we were to flip
00031  * the whole image including the pad data, then pad garbage would become
00032  * visible at the top and/or left, and real pixels would disappear into the
00033  * pad margins --- perhaps permanently, since encoders & decoders may not
00034  * bother to preserve DCT blocks that appear to be completely outside the
00035  * nominal image area.  So, we have to exclude any partial iMCUs from the
00036  * basic transformation.
00037  *
00038  * Transpose is the only transformation that can handle partial iMCUs at the
00039  * right and bottom edges completely cleanly.  flip_h can flip partial iMCUs
00040  * at the bottom, but leaves any partial iMCUs at the right edge untouched.
00041  * Similarly flip_v leaves any partial iMCUs at the bottom edge untouched.
00042  * The other transforms are defined as combinations of these basic transforms
00043  * and process edge blocks in a way that preserves the equivalence.
00044  *
00045  * The "trim" option causes untransformable partial iMCUs to be dropped;
00046  * this is not strictly lossless, but it usually gives the best-looking
00047  * result for odd-size images.  Note that when this option is active,
00048  * the expected mathematical equivalences between the transforms may not hold.
00049  * (For example, -rot 270 -trim trims only the bottom edge, but -rot 90 -trim
00050  * followed by -rot 180 -trim trims both edges.)
00051  *
00052  * We also offer a lossless-crop option, which discards data outside a given
00053  * image region but losslessly preserves what is inside.  Like the rotate and
00054  * flip transforms, lossless crop is restricted by the JPEG format: the upper
00055  * left corner of the selected region must fall on an iMCU boundary.  If this
00056  * does not hold for the given crop parameters, we silently move the upper left
00057  * corner up and/or left to make it so, simultaneously increasing the region
00058  * dimensions to keep the lower right crop corner unchanged.  (Thus, the
00059  * output image covers at least the requested region, but may cover more.)
00060  *
00061  * We also provide a lossless-resize option, which is kind of a lossless-crop
00062  * operation in the DCT coefficient block domain - it discards higher-order
00063  * coefficients and losslessly preserves lower-order coefficients of a
00064  * sub-block.
00065  *
00066  * Rotate/flip transform, resize, and crop can be requested together in a
00067  * single invocation.  The crop is applied last --- that is, the crop region
00068  * is specified in terms of the destination image after transform/resize.
00069  *
00070  * We also offer a "force to grayscale" option, which simply discards the
00071  * chrominance channels of a YCbCr image.  This is lossless in the sense that
00072  * the luminance channel is preserved exactly.  It's not the same kind of
00073  * thing as the rotate/flip transformations, but it's convenient to handle it
00074  * as part of this package, mainly because the transformation routines have to
00075  * be aware of the option to know how many components to work on.
00076  */
00077 
00078 
00079 /* Short forms of external names for systems with brain-damaged linkers. */
00080 
00081 #ifdef NEED_SHORT_EXTERNAL_NAMES
00082 #define jtransform_parse_crop_spec  jTrParCrop
00083 #define jtransform_request_workspace    jTrRequest
00084 #define jtransform_adjust_parameters    jTrAdjust
00085 #define jtransform_execute_transform    jTrExec
00086 #define jtransform_perfect_transform    jTrPerfect
00087 #define jcopy_markers_setup     jCMrkSetup
00088 #define jcopy_markers_execute       jCMrkExec
00089 #endif /* NEED_SHORT_EXTERNAL_NAMES */
00090 
00091 
00092 /*
00093  * Codes for supported types of image transformations.
00094  */
00095 
00096 typedef enum {
00097     JXFORM_NONE,        /* no transformation */
00098     JXFORM_FLIP_H,      /* horizontal flip */
00099     JXFORM_FLIP_V,      /* vertical flip */
00100     JXFORM_TRANSPOSE,   /* transpose across UL-to-LR axis */
00101     JXFORM_TRANSVERSE,  /* transpose across UR-to-LL axis */
00102     JXFORM_ROT_90,      /* 90-degree clockwise rotation */
00103     JXFORM_ROT_180,     /* 180-degree rotation */
00104     JXFORM_ROT_270      /* 270-degree clockwise (or 90 ccw) */
00105 } JXFORM_CODE;
00106 
00107 /*
00108  * Codes for crop parameters, which can individually be unspecified,
00109  * positive, or negative.  (Negative width or height makes no sense, though.)
00110  */
00111 
00112 typedef enum {
00113     JCROP_UNSET,
00114     JCROP_POS,
00115     JCROP_NEG
00116 } JCROP_CODE;
00117 
00118 /*
00119  * Transform parameters struct.
00120  * NB: application must not change any elements of this struct after
00121  * calling jtransform_request_workspace.
00122  */
00123 
00124 typedef struct {
00125   /* Options: set by caller */
00126   JXFORM_CODE transform;    /* image transform operator */
00127   boolean perfect;      /* if TRUE, fail if partial MCUs are requested */
00128   boolean trim;         /* if TRUE, trim partial MCUs as needed */
00129   boolean force_grayscale;  /* if TRUE, convert color image to grayscale */
00130   boolean crop;         /* if TRUE, crop source image */
00131 
00132   /* Crop parameters: application need not set these unless crop is TRUE.
00133    * These can be filled in by jtransform_parse_crop_spec().
00134    */
00135   JDIMENSION crop_width;    /* Width of selected region */
00136   JCROP_CODE crop_width_set;
00137   JDIMENSION crop_height;   /* Height of selected region */
00138   JCROP_CODE crop_height_set;
00139   JDIMENSION crop_xoffset;  /* X offset of selected region */
00140   JCROP_CODE crop_xoffset_set;  /* (negative measures from right edge) */
00141   JDIMENSION crop_yoffset;  /* Y offset of selected region */
00142   JCROP_CODE crop_yoffset_set;  /* (negative measures from bottom edge) */
00143 
00144   /* Internal workspace: caller should not touch these */
00145   int num_components;       /* # of components in workspace */
00146   jvirt_barray_ptr * workspace_coef_arrays; /* workspace for transformations */
00147   JDIMENSION output_width;  /* cropped destination dimensions */
00148   JDIMENSION output_height;
00149   JDIMENSION x_crop_offset; /* destination crop offsets measured in iMCUs */
00150   JDIMENSION y_crop_offset;
00151   int iMCU_sample_width;    /* destination iMCU size */
00152   int iMCU_sample_height;
00153 } jpeg_transform_info;
00154 
00155 
00156 #if TRANSFORMS_SUPPORTED
00157 
00158 /* Parse a crop specification (written in X11 geometry style) */
00159 EXTERN(boolean) jtransform_parse_crop_spec
00160     JPP((jpeg_transform_info *info, const char *spec));
00161 /* Request any required workspace */
00162 EXTERN(boolean) jtransform_request_workspace
00163     JPP((j_decompress_ptr srcinfo, jpeg_transform_info *info));
00164 /* Adjust output image parameters */
00165 EXTERN(jvirt_barray_ptr *) jtransform_adjust_parameters
00166     JPP((j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
00167          jvirt_barray_ptr *src_coef_arrays,
00168          jpeg_transform_info *info));
00169 /* Execute the actual transformation, if any */
00170 EXTERN(void) jtransform_execute_transform
00171     JPP((j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
00172          jvirt_barray_ptr *src_coef_arrays,
00173          jpeg_transform_info *info));
00174 /* Determine whether lossless transformation is perfectly
00175  * possible for a specified image and transformation.
00176  */
00177 EXTERN(boolean) jtransform_perfect_transform
00178     JPP((JDIMENSION image_width, JDIMENSION image_height,
00179          int MCU_width, int MCU_height,
00180          JXFORM_CODE transform));
00181 
00182 /* jtransform_execute_transform used to be called
00183  * jtransform_execute_transformation, but some compilers complain about
00184  * routine names that long.  This macro is here to avoid breaking any
00185  * old source code that uses the original name...
00186  */
00187 #define jtransform_execute_transformation   jtransform_execute_transform
00188 
00189 #endif /* TRANSFORMS_SUPPORTED */
00190 
00191 
00192 /*
00193  * Support for copying optional markers from source to destination file.
00194  */
00195 
00196 typedef enum {
00197     JCOPYOPT_NONE,      /* copy no optional markers */
00198     JCOPYOPT_COMMENTS,  /* copy only comment (COM) markers */
00199     JCOPYOPT_ALL        /* copy all optional markers */
00200 } JCOPY_OPTION;
00201 
00202 #define JCOPYOPT_DEFAULT  JCOPYOPT_COMMENTS /* recommended default */
00203 
00204 /* Setup decompression object to save desired markers in memory */
00205 EXTERN(void) jcopy_markers_setup
00206     JPP((j_decompress_ptr srcinfo, JCOPY_OPTION option));
00207 /* Copy markers saved in the given source object to the destination object */
00208 EXTERN(void) jcopy_markers_execute
00209     JPP((j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
00210          JCOPY_OPTION option));

Generated on Mon May 28 2012 04:32:58 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.