changeset 1303:be30466fbc47

Cleanups.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 19 Aug 2017 11:54:20 +0300
parents 38614c07c2e2
children e968b259605b
files src/libgfx.c tools/gfxconv.c
diffstat 2 files changed, 23 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/libgfx.c	Sat Aug 19 11:46:49 2017 +0300
+++ b/src/libgfx.c	Sat Aug 19 11:54:20 2017 +0300
@@ -839,11 +839,11 @@
 {
     DMPCXData pcx;
     DMPCXHeader hdr;
+    DMImageConvSpec spec;
     int res;
-    DMImageConvSpec spec;
 
+    // Always force planar for PCX
     memcpy(&spec, pspec, sizeof(DMImageConvSpec));
-    spec.format = spec.paletted ? DM_IFMT_PALETTE : DM_IFMT_RGB;
     spec.planar = TRUE;
 
     // Create output file
--- 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: