diff tools/gfxconv.c @ 1303:be30466fbc47

Cleanups.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 19 Aug 2017 11:54:20 +0300
parents 1dce9e5f4a2f
children a8850642d0d2
line wrap: on
line diff
--- a/tools/gfxconv.c	Sat Aug 19 11:46:49 2017 +0300
+++ b/tools/gfxconv.c	Sat Aug 19 11:54:20 2017 +0300
@@ -1075,6 +1075,23 @@
 }
 
 
+void dmOutputImageBitFormat(const int format, const BOOL info)
+{
+    if (info)
+    {
+        char *str;
+        switch (format)
+        {
+            case DM_IFMT_PALETTE : str = "Indexed 8bpp"; break;
+            case DM_IFMT_RGB     : str = "24bit RGB"; break;
+            case DM_IFMT_RGBA    : str = "32bit RGBA"; break;
+            default              : str = "???"; break;
+        }
+        dmMsg(2, "%s output.\n", str);
+    }
+}
+
+
 int dmWriteImage(const char *filename, DMImage *image, DMImageConvSpec *spec, int iformat, BOOL info)
 {
     if (info)
@@ -1098,18 +1115,19 @@
     {
 #ifdef DM_USE_LIBPNG
         case IMGFMT_PNG:
-            if (info) dmMsg(2, "%s output.\n", spec->paletted ? "Indexed 8bpp" : "32bit RGBA");
             spec->format = spec->paletted ? DM_IFMT_PALETTE : DM_IFMT_RGBA;
+            dmOutputImageBitFormat(spec->format, info);
             return dmWritePNGImage(filename, image, spec);
 #endif
 
         case IMGFMT_PPM:
-            if (info) dmMsg(2, "24bit RGB output.\n");
             spec->format = DM_IFMT_RGB;
+            dmOutputImageBitFormat(spec->format, info);
             return dmWritePPMImage(filename, image, spec);
 
         case IMGFMT_PCX:
-            if (info) dmMsg(2, "%s output.\n", spec->paletted ? "Indexed 8bpp" : "24bit RGB");
+            spec->format = spec->paletted ? DM_IFMT_PALETTE : DM_IFMT_RGB;
+            dmOutputImageBitFormat(spec->format, info);
             return dmWritePCXImage(filename, image, spec);
 
         case IMGFMT_RAW: