changeset 2220:a8b4e9c9f337

Set PCX header palette information correctly for grayscale data images.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 14 Jun 2019 08:33:18 +0300
parents 8cd2a821e8a0
children b858ade0fb0b
files tools/libgfx.c
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/tools/libgfx.c	Fri Jun 14 08:17:00 2019 +0300
+++ b/tools/libgfx.c	Fri Jun 14 08:33:18 2019 +0300
@@ -1575,10 +1575,15 @@
     hdr.xmin         = hdr.ymin = 0;
     hdr.xmax         = (img->width * spec.scaleX) - 1;
     hdr.ymax         = (img->height * spec.scaleY) - 1;
-    hdr.palInfo      = 1;
     hdr.hScreenSize  = hdr.hres;
     hdr.vScreenSize  = hdr.vres;
 
+    switch (spec.pixfmt)
+    {
+        case DM_PIXFMT_GRAYSCALE: hdr.palInfo = 2; break;
+        default: hdr.palInfo = 1; break;
+    }
+
     // TODO XXX .. maybe actually compute these asdf
     hdr.bitsPerPlane = 8;
     hdr.nplanes      = dmImageGetBytesPerPixel(spec.pixfmt);