changeset 2219:8cd2a821e8a0

Cleanups.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 14 Jun 2019 08:17:00 +0300
parents f808d3483d4b
children a8b4e9c9f337
files tools/libgfx.c
diffstat 1 files changed, 8 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/tools/libgfx.c	Fri Jun 14 07:44:22 2019 +0300
+++ b/tools/libgfx.c	Fri Jun 14 08:17:00 2019 +0300
@@ -1583,6 +1583,7 @@
     hdr.bitsPerPlane = 8;
     hdr.nplanes      = dmImageGetBytesPerPixel(spec.pixfmt);
 
+    // Compute bytes per line
     res = img->width * spec.scaleX;
     hdr.bpl = res / 2;
     if (res % 2) hdr.bpl++;
@@ -1601,7 +1602,7 @@
         );
 
     // TODO XXX this is also bogus
-    pcx.bufLen       = hdr.bpl * 4;
+    pcx.bufLen = hdr.bpl * 4;
     if ((pcx.buf = dmMalloc(pcx.bufLen)) == NULL)
     {
         res = dmError(DMERR_MALLOC,
@@ -1614,33 +1615,15 @@
     if (!dmf_write_byte(pcx.fp, hdr.manufacturer) ||
         !dmf_write_byte(pcx.fp, hdr.version) ||
         !dmf_write_byte(pcx.fp, hdr.encoding) ||
-        !dmf_write_byte(pcx.fp, hdr.bitsPerPlane))
-    {
-        res = dmError(DMERR_FWRITE,
-            "PCX: Could not write basic header data.\n");
-        goto error;
-    }
-
-    if (!dmf_write_le16(pcx.fp, hdr.xmin) ||
+        !dmf_write_byte(pcx.fp, hdr.bitsPerPlane) ||
+        !dmf_write_le16(pcx.fp, hdr.xmin) ||
         !dmf_write_le16(pcx.fp, hdr.ymin) ||
         !dmf_write_le16(pcx.fp, hdr.xmax) ||
         !dmf_write_le16(pcx.fp, hdr.ymax) ||
         !dmf_write_le16(pcx.fp, hdr.hres) ||
-        !dmf_write_le16(pcx.fp, hdr.vres))
-    {
-        res = dmError(DMERR_FWRITE,
-            "PCX: Could not write image dimensions.\n");
-        goto error;
-    }
-
-    if (!dmf_write_str(pcx.fp, (Uint8 *) &hdr.colorMap, sizeof(hdr.colorMap)))
-    {
-        res = dmError(DMERR_FWRITE,
-            "PCX: Could not write colormap.\n");
-        goto error;
-    }
-
-    if (!dmf_write_byte(pcx.fp, hdr.reserved) ||
+        !dmf_write_le16(pcx.fp, hdr.vres) ||
+        !dmf_write_str(pcx.fp, (Uint8 *) &hdr.colorMap, sizeof(hdr.colorMap)) ||
+        !dmf_write_byte(pcx.fp, hdr.reserved) ||
         !dmf_write_byte(pcx.fp, hdr.nplanes) ||
         !dmf_write_le16(pcx.fp, hdr.bpl) ||
         !dmf_write_le16(pcx.fp, hdr.palInfo) ||
@@ -1649,7 +1632,7 @@
         !dmf_write_str(pcx.fp, (Uint8 *) &hdr.filler, sizeof(hdr.filler)))
     {
         res = dmError(DMERR_FWRITE,
-            "PCX: Could not write header remainder.\n");
+            "PCX: Could not write header data.\n");
         goto error;
     }