Mercurial > hg > dmlib
comparison tools/gfxconv.c @ 1288:6c8b19d1d196
More work on libgfx.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 18 Aug 2017 17:32:19 +0300 |
parents | 300a51e98fc3 |
children | e7dc9bb9777e |
comparison
equal
deleted
inserted
replaced
1287:32051ad352c8 | 1288:6c8b19d1d196 |
---|---|
143 DMImageSpec optSpec = | 143 DMImageSpec optSpec = |
144 { | 144 { |
145 .scaleX = 1, | 145 .scaleX = 1, |
146 .scaleY = 1, | 146 .scaleY = 1, |
147 .nplanes = 4, | 147 .nplanes = 4, |
148 .bpp = 8, | |
148 .interleave = FALSE, | 149 .interleave = FALSE, |
149 .paletted = FALSE, | 150 .paletted = FALSE, |
150 .format = 0, | 151 .format = 0, |
151 }; | 152 }; |
152 | 153 |
165 { 7, 'n', "numitems", "How many 'items' to output (default: all)", OPT_ARGREQ }, | 166 { 7, 'n', "numitems", "How many 'items' to output (default: all)", OPT_ARGREQ }, |
166 { 11, 'w', "width", "Item width (number of items per row, min 1)", OPT_ARGREQ }, | 167 { 11, 'w', "width", "Item width (number of items per row, min 1)", OPT_ARGREQ }, |
167 { 9, 'S', "scale", "Scale output image by <n> or <x>:<y> integer factor(s). " | 168 { 9, 'S', "scale", "Scale output image by <n> or <x>:<y> integer factor(s). " |
168 "-S <n> scales both height and width by <n>.", OPT_ARGREQ }, | 169 "-S <n> scales both height and width by <n>.", OPT_ARGREQ }, |
169 { 12, 'P', "paletted", "Use indexed/paletted output IF possible.", OPT_NONE }, | 170 { 12, 'P', "paletted", "Use indexed/paletted output IF possible.", OPT_NONE }, |
170 { 13, 'B', "bplanes", "Bits per pixel OR # of bitplanes (certain output formats)", OPT_ARGREQ }, | 171 { 13, 'N', "nplanes", "# of bitplanes (certain output formats)", OPT_ARGREQ }, |
172 { 18, 'B', "bpp", "Bits per pixel (certain output formats)", OPT_ARGREQ }, | |
171 { 14, 'I', "interleave", "Interleave output image scanlines (default: output whole planes)", OPT_NONE }, | 173 { 14, 'I', "interleave", "Interleave output image scanlines (default: output whole planes)", OPT_NONE }, |
172 { 16, 'R', "remap", "Remap output image colors (-R <(#RRGGBB|index):index>[,<..>][+remove] | -R @map.txt[+remove])", OPT_ARGREQ }, | 174 { 16, 'R', "remap", "Remap output image colors (-R <(#RRGGBB|index):index>[,<..>][+remove] | -R @map.txt[+remove])", OPT_ARGREQ }, |
173 }; | 175 }; |
174 | 176 |
175 static const int optListN = sizeof(optList) / sizeof(optList[0]); | 177 static const int optListN = sizeof(optList) / sizeof(optList[0]); |
664 case 13: | 666 case 13: |
665 { | 667 { |
666 int tmp = atoi(optArg); | 668 int tmp = atoi(optArg); |
667 if (tmp < 1 || tmp > 8) | 669 if (tmp < 1 || tmp > 8) |
668 { | 670 { |
669 dmErrorMsg("Invalid bitplanes/bpp value '%s'.\n", optArg); | 671 dmErrorMsg("Invalid number of bitplanes value '%s'.\n", optArg); |
672 return FALSE; | |
673 } | |
674 optSpec.nplanes = tmp; | |
675 } | |
676 break; | |
677 | |
678 case 18: | |
679 { | |
680 int tmp = atoi(optArg); | |
681 if (tmp < 1 || tmp > 32) | |
682 { | |
683 dmErrorMsg("Invalid number of bits per pixel value '%s'.\n", optArg); | |
670 return FALSE; | 684 return FALSE; |
671 } | 685 } |
672 optSpec.nplanes = tmp; | 686 optSpec.nplanes = tmp; |
673 } | 687 } |
674 break; | 688 break; |
1443 { | 1457 { |
1444 dmErrorMsg("Sequential image output requires filename template.\n"); | 1458 dmErrorMsg("Sequential image output requires filename template.\n"); |
1445 goto error; | 1459 goto error; |
1446 } | 1460 } |
1447 | 1461 |
1448 outImage = dmImageAlloc(outWidthPX, outHeight); | 1462 outImage = dmImageAlloc(outWidthPX, outHeight, DM_IFMT_PALETTE, -1); |
1449 dmMsg(1, "Outputting sequence of %d images @ %d x %d -> %d x %d.\n", | 1463 dmMsg(1, "Outputting sequence of %d images @ %d x %d -> %d x %d.\n", |
1450 optItemCount, | 1464 optItemCount, |
1451 outImage->width, outImage->height, | 1465 outImage->width, outImage->height, |
1452 outImage->width * optSpec.scaleX, outImage->height * optSpec.scaleY); | 1466 outImage->width * optSpec.scaleX, outImage->height * optSpec.scaleY); |
1453 } | 1467 } |
1463 outIWidth = optPlanedWidth; | 1477 outIWidth = optPlanedWidth; |
1464 outIHeight = (optItemCount / optPlanedWidth); | 1478 outIHeight = (optItemCount / optPlanedWidth); |
1465 if (optItemCount % optPlanedWidth) | 1479 if (optItemCount % optPlanedWidth) |
1466 outIHeight++; | 1480 outIHeight++; |
1467 | 1481 |
1468 outImage = dmImageAlloc(outWidthPX * outIWidth, outIHeight * outHeight); | 1482 outImage = dmImageAlloc(outWidthPX * outIWidth, outIHeight * outHeight, DM_IFMT_PALETTE, -1); |
1469 } | 1483 } |
1470 | 1484 |
1471 outImage->constpal = TRUE; | 1485 outImage->constpal = TRUE; |
1472 outImage->pal = dmC64Palette; | 1486 outImage->pal = dmC64Palette; |
1473 outImage->ncolors = C64_NCOLORS; | 1487 outImage->ncolors = C64_NCOLORS; |