# HG changeset patch # User Matti Hamalainen # Date 1414019574 -10800 # Node ID ca5b4696be21a8e865591a84cab743576f53b6f0 # Parent b2140d41785a7676208ee35c6a898b9f471566cf Add some code for parsing crop mode option, but the logic itself is not yet implemented (nor the option visible). diff -r b2140d41785a -r ca5b4696be21 tools/gfxconv.c --- a/tools/gfxconv.c Thu Oct 23 02:11:44 2014 +0300 +++ b/tools/gfxconv.c Thu Oct 23 02:12:54 2014 +0300 @@ -36,6 +36,14 @@ }; +enum +{ + CROP_NONE = 0, + CROP_AUTO, + CROP_SIZE, +}; + + typedef struct { char *name; @@ -120,6 +128,10 @@ optForcedFormat = -1, optInSkip = 0; +int optCropMode = CROP_NONE, + optCropX0, optCropY0, + optCropW, optCropH; + BOOL optInMulticolor = FALSE, optSequential = FALSE, optRemapColors = FALSE, @@ -687,6 +699,39 @@ optRemapColors = TRUE; break; + case 19: + { + int tx0, ty0, tx1, ty1; + if (strcasecmp(optArg, "auto") == 0) + { + optCropMode = CROP_AUTO; + } + else + if (sscanf(optArg, "%d:%d-%d:%d", &tx0, &ty0, &tx1, &ty1) == 4) + { + optCropMode = CROP_SIZE; + optCropX0 = tx0; + optCropY0 = ty0; + optCropW = tx1 - tx0 + 1; + optCropH = ty1 - ty0 + 1; + } + else + if (sscanf(optArg, "%d:%d:%d:%d", &tx0, &ty0, &tx1, &ty1) == 4) + { + optCropMode = CROP_SIZE; + optCropX0 = tx0; + optCropY0 = ty0; + optCropW = tx1; + optCropH = ty1; + } + else + { + dmError("Invalid crop mode / argument '%s'.\n", optArg); + return FALSE; + } + } + break; + default: dmError("Unknown option '%s'.\n", currArg); return FALSE;