Mercurial > hg > dmlib
diff tools/gfxconv.c @ 902:c6c480e8e1c8
Add separate X and Y scaling to gfxconv and libgfx outputters.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 23 Feb 2015 20:45:31 +0200 |
parents | 9541ea963e75 |
children | bc6c338295e5 |
line wrap: on
line diff
--- a/tools/gfxconv.c Mon Feb 23 20:18:34 2015 +0200 +++ b/tools/gfxconv.c Mon Feb 23 20:45:31 2015 +0200 @@ -142,7 +142,8 @@ DMImageSpec optSpec = { - .scale = 1, + .scaleX = 1, + .scaleY = 1, .nplanes = 4, .interleave = FALSE, .paletted = FALSE, @@ -620,26 +621,38 @@ break; case 9: + if (sscanf(optArg, "%d:%d", &optSpec.scaleX, &optSpec.scaleY) != 2) { - int tmp = atoi(optArg); - if (tmp < 1 || tmp > 50) + if (sscanf(optArg, "%d", &optSpec.scaleX) == 1) + optSpec.scaleY = optSpec.scaleX; + else { - dmError("Invalid scale value '%s'.\n", optArg); + dmError("Invalid scale option value '%s', should be <n> or <w>:<h>.\n", optArg); return FALSE; } - optSpec.scale = tmp; + } + if (optSpec.scaleX < 1 || optSpec.scaleX > 50) + { + dmError("Invalid X scale value '%d'.\n", optSpec.scaleX); + return FALSE; + } + if (optSpec.scaleY < 1 || optSpec.scaleY > 50) + { + dmError("Invalid Y scale value '%d'.\n", optSpec.scaleY); + return FALSE; } break; case 11: + if (sscanf(optArg, "%d", &optPlanedWidth) != 1) { - int tmp = atoi(optArg); - if (tmp < 1 || tmp > 512) - { - dmError("Invalid width value '%s'.\n", optArg); - return FALSE; - } - optPlanedWidth = tmp; + dmError("Invalid planed width value argument '%s'.\n", optArg); + return FALSE; + } + if (optPlanedWidth < 1 || optPlanedWidth > 512) + { + dmError("Invalid planed width value '%d' [1..512].\n", optPlanedWidth); + return FALSE; } break; @@ -1052,11 +1065,11 @@ { if (info) { - dmMsg(1, "Outputting %s image %d x %d -> %d x %d [%d]\n", + dmMsg(1, "Outputting %s image %d x %d -> %d x %d [%d x %d]\n", dmImageFormatList[iformat].fext, image->width, image->height, - image->width * spec->scale, image->height * spec->scale, - spec->scale); + image->width * spec->scaleX, image->height * spec->scaleY, + spec->scaleX, spec->scaleY); } // Perform color remapping @@ -1425,7 +1438,7 @@ dmMsg(1, "Outputting sequence of %d images @ %d x %d -> %d x %d.\n", optItemCount, outImage->width, outImage->height, - outImage->width * optSpec.scale, outImage->height * optSpec.scale); + outImage->width * optSpec.scaleX, outImage->height * optSpec.scaleY); } else {