changeset 2142:894781b7310a

Possibly fix RAW output when clipping nplanes/bpp.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 02 Jun 2019 20:12:05 +0300
parents 009ee261704c
children 693c3e73eb34
files tools/gfxconv.c
diffstat 1 files changed, 15 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/tools/gfxconv.c	Sat Jun 01 03:56:05 2019 +0300
+++ b/tools/gfxconv.c	Sun Jun 02 20:12:05 2019 +0300
@@ -1444,12 +1444,15 @@
     }
 
     // Determine number of planes, if paletted
-    if (spec->format == DM_COLFMT_PALETTE &&
-        spec->nplanes == 0 && image->pal != NULL)
-        spec->nplanes = dmGetNPlanesFromNColors(image->pal->ncolors);
-    else
-    if (image->format == DM_COLFMT_GRAYSCALE)
-        spec->nplanes = 8;
+    if (spec->nplanes == 0)
+    {
+        if (image->format == DM_COLFMT_PALETTE &&
+            image->pal != NULL)
+            spec->nplanes = dmGetNPlanesFromNColors(image->pal->ncolors);
+        else
+        if (image->format == DM_COLFMT_GRAYSCALE)
+            spec->nplanes = image->bpp;
+    }
 
     if (spec->nplanes <= 0)
         spec->nplanes = 4;
@@ -1514,12 +1517,13 @@
         if (info)
         {
             char *str;
-            switch (spec->format)
+            switch (image->format)
             {
-                case DM_COLFMT_PALETTE : str = "indexed/paletted"; break;
-                case DM_COLFMT_RGB     : str = "24bit RGB"; break;
-                case DM_COLFMT_RGBA    : str = "32bit RGBA"; break;
-                default                : str = "???"; break;
+                case DM_COLFMT_PALETTE   : str = "indexed/paletted"; break;
+                case DM_COLFMT_RGB       : str = "24bit RGB"; break;
+                case DM_COLFMT_RGBA      : str = "32bit RGBA"; break;
+                case DM_COLFMT_GRAYSCALE : str = "grayscale"; break;
+                default                  : str = "???"; break;
             }
             dmMsg(2, "Using %s output.\n", str);
         }