changeset 1728:80adcda72210

Allow image pointer argument to be NULL for dmC64ImageDump().
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 07 Jun 2018 15:52:58 +0300
parents 8eb5ff34864a
children f4015f6cb173
files tools/lib64gfx.c
diffstat 1 files changed, 39 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/tools/lib64gfx.c	Thu Jun 07 15:21:54 2018 +0300
+++ b/tools/lib64gfx.c	Thu Jun 07 15:52:58 2018 +0300
@@ -28,9 +28,9 @@
 
 void dmC64ImageDump(FILE *fh, const DMC64Image *img, const DMC64ImageFormat *fmt)
 {
-    char typeStr[64];
+    char typeStr[64], typeStr2[64];
 
-    dmC64GetImageTypeString(typeStr, sizeof(typeStr), img->type, TRUE);
+    dmC64GetImageTypeString(typeStr, sizeof(typeStr), fmt->type, TRUE);
 
     if (fmt != NULL)
     {
@@ -39,31 +39,48 @@
             fmt->name, fmt->fext);
     }
 
-    fprintf(fh,
-        "Type                : %s\n"
-        "Banks               : %d\n",
-        typeStr,
-        img->nbanks);
+    if (img != NULL)
+    {
+        dmC64GetImageTypeString(typeStr2, sizeof(typeStr2), img->type, TRUE);
 
-    if (img->type & D64_FMT_ILACE)
-    {
-        char *tmps;
-        switch (img->laceType)
+        fprintf(fh,
+            "Type                : %s [%s]\n"
+            "Banks               : %d\n",
+            typeStr, typeStr2,
+            img->nbanks);
+
+        if (img->type & D64_FMT_ILACE)
         {
-            case D64_ILACE_COLOR: tmps = "color"; break;
-            case D64_ILACE_RES: tmps = "resolution"; break;
-            default: tmps = "ERROR"; break;
+            char *tmps;
+            switch (img->laceType)
+            {
+                case D64_ILACE_COLOR: tmps = "color"; break;
+                case D64_ILACE_RES: tmps = "resolution"; break;
+                default: tmps = "ERROR"; break;
+            }
+            fprintf(fh,
+                "Interlace type      : %s\n",
+                tmps);
         }
+
         fprintf(fh,
-            "Interlace type      : %s\n",
-            tmps);
+            "Width x Height      : %d x %d [%d x %d]\n"
+            "CHwidth x CHheight  : %d x %d [%d x %d]\n",
+            img->width, img->height,
+            fmt->width, fmt->height,
+            img->chWidth, img->chHeight,
+            fmt->chWidth, fmt->chHeight);
     }
-
-    fprintf(fh,
-        "Width x Height      : %d x %d\n"
-        "CHwidth x CHheight  : %d x %d\n",
-        img->width, img->height,
-        img->chWidth, img->chHeight);
+    else
+    {
+        fprintf(fh,
+            "Type                : %s\n"
+            "Width x Height      : %d x %d\n"
+            "CHwidth x CHheight  : %d x %d\n",
+            typeStr,
+            fmt->width, fmt->height,
+            fmt->chWidth, fmt->chHeight);
+    }
 }