Mercurial > hg > dmlib
diff tools/gfxconv.c @ 1931:410679d2fe8a
"Enable" the image->c64 bitmap conversion path in gfxconv. It does not work
without the necessary bits elsewhere, though. Also add DMC64ImageConvSpec
structure for delivering conversion parameters, though it is not yet used
either.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 28 Jun 2018 17:26:30 +0300 |
parents | b49814dd8469 |
children | c5a46cb4cce5 |
line wrap: on
line diff
--- a/tools/gfxconv.c Thu Jun 28 14:49:52 2018 +0300 +++ b/tools/gfxconv.c Thu Jun 28 17:26:30 2018 +0300 @@ -1786,6 +1786,7 @@ int main(int argc, char *argv[]) { FILE *inFile = NULL; + DMC64ImageConvSpec imageSpecC64; const DMC64ImageFormat *inC64Fmt = NULL; DMConvFormat inFormat, outFormat; DMC64Image *inC64Image = NULL, *outC64Image = NULL; @@ -1797,6 +1798,9 @@ for (i = 0; i < C64_NCOLORS; i++) optColorMap[i] = i; + // Initialize c64 image conversion spec + memset(&imageSpecC64, 0, sizeof(imageSpecC64)); + // Initialize list of additional conversion formats dmC64InitializeFormats(); nconvFormatList = ndmImageFormatList + nbaseFormatList; @@ -1983,7 +1987,7 @@ case FFMT_IMAGE: case FFMT_CHAR: case FFMT_SPRITE: - res = dmC64ConvertBMP2Image(&outImage, inC64Image, inC64Fmt); + res = dmC64ConvertBMP2Image(&outImage, inC64Image, inC64Fmt, &imageSpecC64); if (res != DMERR_OK || outImage == NULL) { @@ -2069,7 +2073,36 @@ case FFMT_CHAR: case FFMT_SPRITE: - res = dmWriteSpritesAndChars(optOutFilename, inImage, optOutType, optInMulticolor); + res = dmWriteSpritesAndChars(optOutFilename, inImage, + optOutType, optInMulticolor); + break; + + case FFMT_BITMAP: + { + DMC64Image *tmpC64Image = NULL; + res = dmC64ConvertImage2BMP(&tmpC64Image, inImage, + &dmC64ImageFormats[optOutFormat], &imageSpecC64); + + if (res != DMERR_OK || tmpC64Image == NULL) + { + dmC64ImageFree(tmpC64Image); + dmErrorMsg("Error in image to bitmap conversion: %s\n", + dmErrorStr(res)); + goto error; + } + + if ((res = dmConvertC64Bitmap(&outC64Image, tmpC64Image, + &dmC64ImageFormats[optOutFormat], &dmC64ImageFormats[optOutFormat])) != DMERR_OK) + { + dmC64ImageFree(tmpC64Image); + dmErrorMsg("Error in bitmap format conversion: %s\n", + dmErrorStr(res)); + goto error; + } + + res = dmWriteBitmap(optOutFilename, outC64Image, &dmC64ImageFormats[optOutFormat]); + dmC64ImageFree(tmpC64Image); + } break; default: