changeset 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 91e2d0d74e2f
children ab8d9696225c 45c46bfa03bd
files gfxconv.c lib64gfx.c lib64gfx.h view64.c
diffstat 4 files changed, 62 insertions(+), 28 deletions(-) [+]
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;
--- a/lib64gfx.c	Thu Nov 22 17:56:25 2012 +0200
+++ b/lib64gfx.c	Thu Nov 22 21:09:15 2012 +0200
@@ -276,7 +276,7 @@
 const DMC64ImageFormat dmC64ImageFormats[] =
 {
     {
-        D64_FMT_MC, ".drp", "DrazPaint 2.0 (packed)", 0x5800, -1,
+        D64_FMT_MC, "drp", "DrazPaint 2.0 (packed)", 0x5800, -1,
         fmtProbeDrazPaint20Packed, fmtDecodeDrazPaintPacked,
         NULL, NULL, NULL,
         4,
@@ -289,7 +289,7 @@
     },
 
     {
-        D64_FMT_MC | D64_FMT_ILACE, ".dlp", "DrazLace 1.0 (packed)", 0x5800, -1,
+        D64_FMT_MC | D64_FMT_ILACE, "dlp", "DrazLace 1.0 (packed)", 0x5800, -1,
         fmtProbeDrazLace10Packed, fmtDecodeDrazPaintPacked,
         NULL, NULL, NULL,
         6,
@@ -304,7 +304,7 @@
     },
     
     {
-        D64_FMT_MC, ".drp", "DrazPaint (unpacked)", 0x5800, 10051,
+        D64_FMT_MC, "drp", "DrazPaint (unpacked)", 0x5800, 10051,
         NULL, NULL,
         NULL, NULL, NULL,
         4,
@@ -317,7 +317,7 @@
     },
 
     {
-        D64_FMT_MC | D64_FMT_ILACE, ".drl", "DrazLace 1.0 (unpacked)", 0x5800, 18242,
+        D64_FMT_MC | D64_FMT_ILACE, "drl", "DrazLace 1.0 (unpacked)", 0x5800, 18242,
         NULL, NULL,
         NULL, NULL, NULL,
         6,
@@ -332,7 +332,7 @@
     },
     
     {
-        D64_FMT_MC | D64_FMT_ILACE, ".mci", "Truepaint (unpacked)", 0x9c00, 19434,
+        D64_FMT_MC | D64_FMT_ILACE, "mci", "Truepaint (unpacked)", 0x9c00, 19434,
         NULL, NULL,
         NULL, NULL, NULL,
         6,
@@ -348,7 +348,7 @@
     },
     
     {
-        D64_FMT_MC, ".kla", "Koala Paint (unpacked)", 0x6000, 10003,
+        D64_FMT_MC, "kla", "Koala Paint (unpacked)", 0x6000, 10003,
         NULL, NULL,
         NULL, NULL, NULL,
         4,
@@ -361,7 +361,7 @@
     },
 
     {
-        D64_FMT_MC, ".ocp", "Advanced Art Studio (unpacked)", 0x2000, 10018,
+        D64_FMT_MC, "ocp", "Advanced Art Studio (unpacked)", 0x2000, 10018,
         NULL, NULL,
         NULL, NULL, NULL,
         4,
@@ -374,7 +374,7 @@
     },
 
     {
-        D64_FMT_MC, ".ami", "Amica Paint (packed)", 0x4000, -1,
+        D64_FMT_MC, "ami", "Amica Paint (packed)", 0x4000, -1,
         fmtProbeAmicaPaintPacked, fmtDecodeAmicaPaintPacked,
         NULL, NULL, NULL,
         4,
@@ -387,7 +387,7 @@
     },
 
     {
-        D64_FMT_MC, ".rpm", "Run Paint (unpacked)", 0x6000, 10006,
+        D64_FMT_MC, "rpm", "Run Paint (unpacked)", 0x6000, 10006,
         NULL, NULL,
         NULL, NULL, NULL,
         4,
@@ -400,7 +400,7 @@
     },
 
     {
-        D64_FMT_HIRES, ".art", "Art Studio (unpacked)", 0x2000, 9009,
+        D64_FMT_HIRES, "art", "Art Studio (unpacked)", 0x2000, 9009,
         NULL, NULL,
         NULL, NULL, NULL,
         2,
@@ -411,7 +411,7 @@
     },
 
     {
-        D64_FMT_HIRES, ".iph", "Interpaint (unpacked)", 0x4000, 9002,
+        D64_FMT_HIRES, "iph", "Interpaint (unpacked)", 0x4000, 9002,
         NULL, NULL,
         NULL, NULL, NULL,
         2,
@@ -422,7 +422,7 @@
     },
 
     {
-        D64_FMT_HIRES, ".dd", "Doodle (unpacked)", 0x1c00, 9218,
+        D64_FMT_HIRES, "dd", "Doodle (unpacked)", 0x1c00, 9218,
         NULL, NULL,
         NULL, NULL, NULL,
         2,
@@ -433,7 +433,7 @@
     },
     
     {
-        D64_FMT_MC | D64_FMT_FLI, ".bml", "Blackmail FLI (unpacked)", 0x3b00, 17474,
+        D64_FMT_MC | D64_FMT_FLI, "bml", "Blackmail FLI (unpacked)", 0x3b00, 17474,
         NULL, NULL,
         NULL, NULL, NULL,
         11,
@@ -456,7 +456,7 @@
     },
 
     {
-        D64_FMT_MC | D64_FMT_FLI, ".fli", "FLI Designer (unpacked)", 0x3c00, 17409,
+        D64_FMT_MC | D64_FMT_FLI, "fli", "FLI Designer (unpacked)", 0x3c00, 17409,
         NULL, NULL,
         NULL, NULL, NULL,
         11,
--- a/lib64gfx.h	Thu Nov 22 17:56:25 2012 +0200
+++ b/lib64gfx.h	Thu Nov 22 21:09:15 2012 +0200
@@ -154,7 +154,7 @@
 typedef struct _DMC64ImageFormat
 {
     int  type;
-    char *extension;
+    char *fext;
     char *name;
     size_t addr; // Loading address (0 if no loading address)
     size_t size; // Size, including loading address. Only used in encoding, if even there (0 if no static size)
--- a/view64.c	Thu Nov 22 17:56:25 2012 +0200
+++ b/view64.c	Thu Nov 22 21:09:15 2012 +0200
@@ -50,7 +50,7 @@
         const DMC64ImageFormat *fmt = &dmC64ImageFormats[i];
         char buf[64];
         printf("%3d | %-5s | %-15s | %s\n",
-            i, fmt->extension,
+            i, fmt->fext,
             dmC64GetImageTypeString(buf, sizeof(buf), fmt->type),
             fmt->name);
     }
@@ -188,7 +188,8 @@
     if (optForcedFormat >= 0)
     {
         forced = &dmC64ImageFormats[optForcedFormat];
-        dmMsg(0,"Forced %s format image, type %d, %s\n", forced->name, forced->type, forced->extension);
+        dmMsg(0,"Forced %s format image, type %d, %s\n",
+            forced->name, forced->type, forced->fext);
     }
     else
         forced = NULL;
@@ -197,7 +198,7 @@
     if (forced == NULL && fmt != NULL)
     {
         dmMsg(0,"Probed %s format image, type %d, %s\n",
-            fmt->name, fmt->type, fmt->extension);
+            fmt->name, fmt->type, fmt->fext);
     }
 
     if (ret < 0)