changeset 854:ca5b4696be21

Add some code for parsing crop mode option, but the logic itself is not yet implemented (nor the option visible).
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 23 Oct 2014 02:12:54 +0300
parents b2140d41785a
children f70d6f9532cd
files tools/gfxconv.c
diffstat 1 files changed, 45 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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;