comparison 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
comparison
equal deleted inserted replaced
901:f532262f90b1 902:c6c480e8e1c8
140 DMMapValue optRemapTable[DM_MAX_COLORS]; 140 DMMapValue optRemapTable[DM_MAX_COLORS];
141 int optColors[C64_MAX_COLORS]; 141 int optColors[C64_MAX_COLORS];
142 142
143 DMImageSpec optSpec = 143 DMImageSpec optSpec =
144 { 144 {
145 .scale = 1, 145 .scaleX = 1,
146 .scaleY = 1,
146 .nplanes = 4, 147 .nplanes = 4,
147 .interleave = FALSE, 148 .interleave = FALSE,
148 .paletted = FALSE, 149 .paletted = FALSE,
149 .format = 0, 150 .format = 0,
150 }; 151 };
618 case 8: 619 case 8:
619 optSequential = TRUE; 620 optSequential = TRUE;
620 break; 621 break;
621 622
622 case 9: 623 case 9:
623 { 624 if (sscanf(optArg, "%d:%d", &optSpec.scaleX, &optSpec.scaleY) != 2)
624 int tmp = atoi(optArg); 625 {
625 if (tmp < 1 || tmp > 50) 626 if (sscanf(optArg, "%d", &optSpec.scaleX) == 1)
626 { 627 optSpec.scaleY = optSpec.scaleX;
627 dmError("Invalid scale value '%s'.\n", optArg); 628 else
629 {
630 dmError("Invalid scale option value '%s', should be <n> or <w>:<h>.\n", optArg);
628 return FALSE; 631 return FALSE;
629 } 632 }
630 optSpec.scale = tmp; 633 }
634 if (optSpec.scaleX < 1 || optSpec.scaleX > 50)
635 {
636 dmError("Invalid X scale value '%d'.\n", optSpec.scaleX);
637 return FALSE;
638 }
639 if (optSpec.scaleY < 1 || optSpec.scaleY > 50)
640 {
641 dmError("Invalid Y scale value '%d'.\n", optSpec.scaleY);
642 return FALSE;
631 } 643 }
632 break; 644 break;
633 645
634 case 11: 646 case 11:
635 { 647 if (sscanf(optArg, "%d", &optPlanedWidth) != 1)
636 int tmp = atoi(optArg); 648 {
637 if (tmp < 1 || tmp > 512) 649 dmError("Invalid planed width value argument '%s'.\n", optArg);
638 { 650 return FALSE;
639 dmError("Invalid width value '%s'.\n", optArg); 651 }
640 return FALSE; 652 if (optPlanedWidth < 1 || optPlanedWidth > 512)
641 } 653 {
642 optPlanedWidth = tmp; 654 dmError("Invalid planed width value '%d' [1..512].\n", optPlanedWidth);
655 return FALSE;
643 } 656 }
644 break; 657 break;
645 658
646 case 12: 659 case 12:
647 optSpec.paletted = TRUE; 660 optSpec.paletted = TRUE;
1050 1063
1051 int dmWriteImage(const char *filename, DMImage *image, DMImageSpec *spec, int iformat, BOOL info) 1064 int dmWriteImage(const char *filename, DMImage *image, DMImageSpec *spec, int iformat, BOOL info)
1052 { 1065 {
1053 if (info) 1066 if (info)
1054 { 1067 {
1055 dmMsg(1, "Outputting %s image %d x %d -> %d x %d [%d]\n", 1068 dmMsg(1, "Outputting %s image %d x %d -> %d x %d [%d x %d]\n",
1056 dmImageFormatList[iformat].fext, 1069 dmImageFormatList[iformat].fext,
1057 image->width, image->height, 1070 image->width, image->height,
1058 image->width * spec->scale, image->height * spec->scale, 1071 image->width * spec->scaleX, image->height * spec->scaleY,
1059 spec->scale); 1072 spec->scaleX, spec->scaleY);
1060 } 1073 }
1061 1074
1062 // Perform color remapping 1075 // Perform color remapping
1063 if (optRemapColors) 1076 if (optRemapColors)
1064 { 1077 {
1423 1436
1424 outImage = dmImageAlloc(outWidthPX, outHeight); 1437 outImage = dmImageAlloc(outWidthPX, outHeight);
1425 dmMsg(1, "Outputting sequence of %d images @ %d x %d -> %d x %d.\n", 1438 dmMsg(1, "Outputting sequence of %d images @ %d x %d -> %d x %d.\n",
1426 optItemCount, 1439 optItemCount,
1427 outImage->width, outImage->height, 1440 outImage->width, outImage->height,
1428 outImage->width * optSpec.scale, outImage->height * optSpec.scale); 1441 outImage->width * optSpec.scaleX, outImage->height * optSpec.scaleY);
1429 } 1442 }
1430 else 1443 else
1431 { 1444 {
1432 int outIWidth, outIHeight; 1445 int outIWidth, outIHeight;
1433 if (optItemCount <= 0) 1446 if (optItemCount <= 0)