comparison tools/gfxconv.c @ 2099:dac89484f143

Fix nplanes and bpp in gfxconv.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 05 Mar 2019 14:51:02 +0200
parents f43011ea9b9f
children 81fb21dd3265
comparison
equal deleted inserted replaced
2098:e38705223ce4 2099:dac89484f143
136 136
137 DMImageConvSpec optSpec = 137 DMImageConvSpec optSpec =
138 { 138 {
139 .scaleX = 1, 139 .scaleX = 1,
140 .scaleY = 1, 140 .scaleY = 1,
141 .nplanes = 4, 141 .nplanes = 0,
142 .bpp = 8, 142 .bpp = 8,
143 .planar = FALSE, 143 .planar = FALSE,
144 .format = 0, 144 .format = 0,
145 .compression = FCMP_BEST, 145 .compression = FCMP_BEST,
146 }; 146 };
863 { 863 {
864 dmErrorMsg("Invalid number of bits per pixel value '%s' [1 .. 32]\n", 864 dmErrorMsg("Invalid number of bits per pixel value '%s' [1 .. 32]\n",
865 optArg); 865 optArg);
866 return FALSE; 866 return FALSE;
867 } 867 }
868 optSpec.nplanes = tmpUInt; 868 optSpec.bpp = tmpUInt;
869 break; 869 break;
870 870
871 case 14: 871 case 14:
872 optSpec.planar = TRUE; 872 optSpec.planar = TRUE;
873 break; 873 break;
1421 1421
1422 allocated = TRUE; 1422 allocated = TRUE;
1423 } 1423 }
1424 1424
1425 // Determine number of planes, if paletted 1425 // Determine number of planes, if paletted
1426 if (spec->format == DM_COLFMT_PALETTE) 1426 if (spec->format == DM_COLFMT_PALETTE &&
1427 { 1427 spec->nplanes == 0)
1428 spec->nplanes = 0; 1428 {
1429 for (int n = 8; n >= 0;) 1429 for (int n = 8; n >= 0;)
1430 { 1430 {
1431 if ((image->pal->ncolors - 1) & (1 << n)) 1431 if ((image->pal->ncolors - 1) & (1 << n))
1432 { 1432 {
1433 spec->nplanes = n + 1; 1433 spec->nplanes = n + 1;
1435 } 1435 }
1436 else 1436 else
1437 n--; 1437 n--;
1438 } 1438 }
1439 } 1439 }
1440
1441 if (spec->nplanes == 0)
1442 spec->nplanes = 4;
1440 1443
1441 spec->fmtid = fmt->fmtid; 1444 spec->fmtid = fmt->fmtid;
1442 1445
1443 // Do some format-specific adjustments and other things 1446 // Do some format-specific adjustments and other things
1444 switch (fmt->fmtid) 1447 switch (fmt->fmtid)