changeset 2153:7652b3fe8f30

Fix IFF and PCX checks for non-indexed images.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 04 Jun 2019 15:44:49 +0300
parents 44d7e8e2483c
children 1c111bfc17d4
files tools/libgfx.c
diffstat 1 files changed, 7 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/tools/libgfx.c	Tue Jun 04 15:21:35 2019 +0300
+++ b/tools/libgfx.c	Tue Jun 04 15:44:49 2019 +0300
@@ -1411,8 +1411,8 @@
     spec.planar = TRUE;
 
     // XXX: 24bit PCX does not work yet ..
-    if (spec.format != DM_COLFMT_PALETTE &&
-        spec.format != DM_COLFMT_GRAYSCALE)
+    if ((img->format != DM_COLFMT_PALETTE && img->format != DM_COLFMT_GRAYSCALE) ||
+        (spec.format != DM_COLFMT_PALETTE && spec.format != DM_COLFMT_GRAYSCALE))
     {
         return dmError(DMERR_NOT_SUPPORTED,
             "24bit PCX not supported yet.\n");
@@ -2622,7 +2622,8 @@
     int res = DMERR_OK;
 
     // XXX: Non-paletted IFF not supported!
-    if (spec->format != DM_COLFMT_PALETTE)
+    if ((img->format != DM_COLFMT_PALETTE && img->format != DM_COLFMT_GRAYSCALE) ||
+        (spec->format != DM_COLFMT_PALETTE && spec->format != DM_COLFMT_GRAYSCALE))
     {
         return dmError(DMERR_NOT_SUPPORTED,
             "Non-paletted IFF is not supported.\n");
@@ -2702,7 +2703,9 @@
     //
     // CMAP
     //
-    if (img->pal->ncolors > 0 && spec->format == DM_COLFMT_PALETTE)
+    if (spec->format == DM_COLFMT_PALETTE &&
+        img->pal != NULL &&
+        img->pal->ncolors > 0)
     {
         if ((res = dmWriteIFFChunkHdr(fp, &iff.chCMAP, IFF_ID_CMAP)) != DMERR_OK)
             goto out;