# HG changeset patch # User Matti Hamalainen # Date 1400108753 -10800 # Node ID cbe263ad963cd91b3e68c838bdd1c811cc420a6c # Parent eba3b87f3f84240ead3e9a5868ac9dbd2a81b8ed Some work on charset conversion. diff -r eba3b87f3f84 -r cbe263ad963c lib64gfx.c --- a/lib64gfx.c Wed May 14 21:28:14 2014 +0300 +++ b/lib64gfx.c Thu May 15 02:05:53 2014 +0300 @@ -703,9 +703,7 @@ int dmC64ConvertGenericBMP2Image(DMImage *dst, const DMC64Image *src, const BOOL doubleMC) { Uint8 *dp = dst->data; - int divisor = doubleMC ? 4 : 8, - wdivisor = doubleMC ? 2 : 1, - yc; + int yc; // Sanity check arguments if (dst == NULL || src == NULL) @@ -740,6 +738,10 @@ } else { + const int + wdivisor = doubleMC ? 2 : 1, + divisor = doubleMC ? 4 : 8; + for (xc = 0; xc < dst->width / wdivisor; xc++) { const int x = xc / divisor; @@ -765,19 +767,22 @@ } c = dmC64GetMCColor(src, (src->bitmap[0][bmoffs] >> v) & 3, 0, vbank, scroffs); *d++ = c; - *d++ = c; + if (doubleMC) + *d++ = c; } else if (src->type & D64_FMT_ILACE) { *d++ = dmC64GetMCColor(src, (src->bitmap[0][bmoffs] >> v) & 3, 0, src->laceBank1, scroffs); - *d++ = dmC64GetMCColor(src, (src->bitmap[1][bmoffs] >> v) & 3, 0, src->laceBank2, scroffs); + if (doubleMC) + *d++ = dmC64GetMCColor(src, (src->bitmap[1][bmoffs] >> v) & 3, 0, src->laceBank2, scroffs); } else { c = dmC64GetMCColor(src, (src->bitmap[0][bmoffs] >> v) & 3, 0, 0, scroffs); *d++ = c; - *d++ = c; + if (doubleMC) + *d++ = c; } } } diff -r eba3b87f3f84 -r cbe263ad963c tools/gfxconv.c --- a/tools/gfxconv.c Wed May 14 21:28:14 2014 +0300 +++ b/tools/gfxconv.c Thu May 15 02:05:53 2014 +0300 @@ -1618,14 +1618,14 @@ if (optOutFilename == NULL) { - dmError("Output filename not set, required for image formats.\n"); + dmError("Output filename not set, required for bitmap formats.\n"); goto error; } switch (optOutFormat) { case FFMT_IMAGE: - res = dmC64ConvertBMP2Image(&outImage, &cimage, cfmt, TRUE); + res = dmC64ConvertBMP2Image(&outImage, &cimage, cfmt, FALSE); if (res != DMERR_OK || outImage == NULL) { @@ -1643,6 +1643,14 @@ case FFMT_CHAR: case FFMT_SPRITE: + res = dmC64ConvertBMP2Image(&outImage, &cimage, cfmt, TRUE); + + if (res != DMERR_OK || outImage == NULL) + { + dmError("Error in bitmap to template image conversion.\n"); + goto error; + } + res = dmWriteSpritesAndChars(optOutFilename, outImage, optOutFormat, optInMulticolor); break;