diff options
author | DRC <dcommander@users.sourceforge.net> | 2013-01-01 10:44:00 +0000 |
---|---|---|
committer | DRC <dcommander@users.sourceforge.net> | 2013-01-01 10:44:00 +0000 |
commit | 8cbf8939bbd08cc99205249f01f31b3c3c28294d (patch) | |
tree | f8bbcfd4b71cae32c359c8c194d846644eb41808 /transupp.c | |
parent | f73a27ca5be914a1a1288a587e9535af7b88b290 (diff) | |
parent | 5829cb23983cd241c48abd8ed70ff3627560c453 (diff) | |
download | libjpeg-turbo-8cbf8939bbd08cc99205249f01f31b3c3c28294d.tar.gz |
Port the width/height force feature from jpegtran v8d.
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@881 632fc199-4ca6-4c93-a231-07263d6284db
Diffstat (limited to 'transupp.c')
-rw-r--r-- | transupp.c | 32 |
1 files changed, 23 insertions, 9 deletions
@@ -2,7 +2,7 @@ * transupp.c * * This file was part of the Independent JPEG Group's software: - * Copyright (C) 1997-2009, Thomas G. Lane, Guido Vollbeding. + * Copyright (C) 1997-2011, Thomas G. Lane, Guido Vollbeding. * Modifications: * Copyright (C) 2010, D. R. Commander. * For conditions of distribution and use, see the accompanying README file. @@ -783,7 +783,7 @@ jt_read_integer (const char ** strptr, JDIMENSION * result) * The routine returns TRUE if the spec string is valid, FALSE if not. * * The crop spec string should have the format - * <width>x<height>{+-}<xoffset>{+-}<yoffset> + * <width>[f]x<height>[f]{+-}<xoffset>{+-}<yoffset> * where width, height, xoffset, and yoffset are unsigned integers. * Each of the elements can be omitted to indicate a default value. * (A weakness of this style is that it is not possible to omit xoffset @@ -805,14 +805,22 @@ jtransform_parse_crop_spec (jpeg_transform_info *info, const char *spec) /* fetch width */ if (! jt_read_integer(&spec, &info->crop_width)) return FALSE; - info->crop_width_set = JCROP_POS; + if (*spec == 'f' || *spec == 'F') { + spec++; + info->crop_width_set = JCROP_FORCE; + } else + info->crop_width_set = JCROP_POS; } - if (*spec == 'x' || *spec == 'X') { + if (*spec == 'x' || *spec == 'X') { /* fetch height */ spec++; if (! jt_read_integer(&spec, &info->crop_height)) return FALSE; - info->crop_height_set = JCROP_POS; + if (*spec == 'f' || *spec == 'F') { + spec++; + info->crop_height_set = JCROP_FORCE; + } else + info->crop_height_set = JCROP_POS; } if (*spec == '+' || *spec == '-') { /* fetch xoffset */ @@ -997,10 +1005,16 @@ jtransform_request_workspace (j_decompress_ptr srcinfo, else yoffset = info->crop_yoffset; /* Now adjust so that upper left corner falls at an iMCU boundary */ - info->output_width = - info->crop_width + (xoffset % info->iMCU_sample_width); - info->output_height = - info->crop_height + (yoffset % info->iMCU_sample_height); + if (info->crop_width_set == JCROP_FORCE) + info->output_width = info->crop_width; + else + info->output_width = + info->crop_width + (xoffset % info->iMCU_sample_width); + if (info->crop_height_set == JCROP_FORCE) + info->output_height = info->crop_height; + else + info->output_height = + info->crop_height + (yoffset % info->iMCU_sample_height); /* Save x/y offsets measured in iMCUs */ info->x_crop_offset = xoffset / info->iMCU_sample_width; info->y_crop_offset = yoffset / info->iMCU_sample_height; |