Mercurial > hg > dmlib
diff gfxconv.c @ 534:fbfdc9e4fe2b
Begin preparations for improved bitmap conversion support. Breaks lib64gfx API.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 22 Nov 2012 21:09:15 +0200 |
parents | 5b37a2e427b7 |
children | e74a0e027681 |
line wrap: on
line diff
--- a/gfxconv.c Thu Nov 22 17:56:25 2012 +0200 +++ b/gfxconv.c Thu Nov 22 21:09:15 2012 +0200 @@ -79,8 +79,8 @@ }, { - "C64 bitmap image file", NULL, TRUE, FALSE, - FFMT_BITMAP , 0, + "C64 bitmap image file", NULL, TRUE, TRUE, + FFMT_BITMAP , -1, }, { @@ -162,10 +162,10 @@ { int i; - printf("\n" + printf( "Available input/output formats:\n" - " EXT | I | O | Description\n" - "------+---+---+--------------------------------\n" + " Ext | I | O | Description\n" + "------+---+---+-----------------------------------------------\n" ); for (i = 0; i < nconvFormatList; i++) @@ -178,13 +178,21 @@ fmt->name); } - printf("\nAvailable bitmap formats:\n"); + printf( + "\n" + "(Not all input->output combinations are actually supported.)\n" + "\n" + "Available bitmap formats:\n" + " Ext | Type | Description\n" + "------+-----------------+-------------------------------------\n" + ); + for (i = 0; i < ndmC64ImageFormats; i++) { const DMC64ImageFormat *fmt = &dmC64ImageFormats[i]; char buf[64]; - printf("%3d | %-5s | %-15s | %s\n", - i, fmt->extension, + printf("%-5s | %-15s | %s\n", + fmt->fext, dmC64GetImageTypeString(buf, sizeof(buf), fmt->type), fmt->name); } @@ -240,6 +248,19 @@ return TRUE; } } + + for (i = 0; i < ndmC64ImageFormats; i++) + { + const DMC64ImageFormat *fmt = &dmC64ImageFormats[i]; + if (fmt->fext != NULL && + strcasecmp(fext, fmt->fext) == 0) + { + *format = FFMT_BITMAP; + *subformat = i; + return TRUE; + } + } + return FALSE; } @@ -908,6 +929,12 @@ } +int dmWriteBitmap(const char *filename, DMC64Image *image, int iformat) +{ + return DMERR_OK; +} + + int dmWriteImage(const char *filename, DMImage *image, DMImageSpec *spec, int iformat, BOOL info) { if (info) @@ -1177,6 +1204,7 @@ return -1; } + int dmDumpSpritesAndChars(FILE *inFile) { int dataOffs, itemCount, outWidth, outWidthPX, outHeight; @@ -1430,14 +1458,14 @@ { forced = &dmC64ImageFormats[optForcedFormat]; dmMsg(0,"Forced %s format image, type %d, %s\n", - forced->name, forced->type, forced->extension); + forced->name, forced->type, forced->fext); } res = dmC64DecodeBMP(&cimage, dataBuf, dataSize, optInSkip, optInSkip + 2, &cfmt, forced); if (forced == NULL && cfmt != NULL) { dmMsg(1,"Probed %s format image, type %d, %s\n", - cfmt->name, cfmt->type, cfmt->extension); + cfmt->name, cfmt->type, cfmt->fext); } if (res == 0) @@ -1535,6 +1563,11 @@ res = dmWriteImage(optOutFilename, outImage, &optSpec, optOutSubFormat, TRUE); break; + + case FFMT_BITMAP: + res = dmWriteBitmap(optOutFilename, &cimage, optOutSubFormat); + break; + default: dmError("Unsupported output format for bitmap/image conversion.\n"); break;