changeset 1892:cbc911ffd21e

Rename ILBM functions to IFF, which is more approriate as we support both ILBM and PBM variants of the IFF images.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 25 Jun 2018 19:36:26 +0300
parents 91b80990043c
children 334501b6cce5
files tools/libgfx.c tools/libgfx.h
diffstat 2 files changed, 35 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/tools/libgfx.c	Mon Jun 25 17:56:35 2018 +0300
+++ b/tools/libgfx.c	Mon Jun 25 19:36:26 2018 +0300
@@ -1428,7 +1428,7 @@
 } DMIFF;
 
 
-static int fmtProbeILBM(const Uint8 *buf, const size_t len)
+static int fmtProbeIFF(const Uint8 *buf, const size_t len)
 {
     if (len > 32 &&
         buf[ 0] == 'F' && buf[ 1] == 'O' &&
@@ -1464,7 +1464,7 @@
         !dmf_read_be32(fp, &chunk->size))
     {
         return dmError(DMERR_FREAD,
-            "ILBM: Could not read IFF chunk header.\n");
+            "IFF: Could not read IFF chunk header.\n");
     }
     else
     {
@@ -1478,13 +1478,13 @@
 {
     if (chunk->size > used)
     {
-        dmMsg(4, "ILBM: Skipping %d bytes (%d of %d consumed)\n",
+        dmMsg(4, "IFF: Skipping %d bytes (%d of %d consumed)\n",
             chunk->size - used, used, chunk->size);
 
         if (dmfseek(fp, chunk->size - used, SEEK_CUR) != 0)
         {
             return dmError(DMERR_FSEEK,
-                "ILBM: Failed to skip chunk end.\n");
+                "IFF: Failed to skip chunk end.\n");
         }
         else
             return DMERR_OK;
@@ -1500,7 +1500,7 @@
     if (dest->count > 0 && !multi)
     {
         return dmError(DMERR_INVALID_DATA,
-            "ILBM: Multiple instances of chunk %s found.\n",
+            "IFF: Multiple instances of chunk %s found.\n",
             chunk->idStr);
     }
 
@@ -1509,7 +1509,7 @@
     if (chunk->size < minSize)
     {
         return dmError(DMERR_OUT_OF_DATA,
-            "ILBM: Chunk is too small.\n");
+            "IFF: Chunk is too small.\n");
     }
 
     return DMERR_OK;
@@ -1595,7 +1595,7 @@
     if ((buf = dmMalloc(bufLen)) == NULL)
         return DMERR_MALLOC;
 
-    dmMsg(2, "ILBM: plane row size %d bytes.\n", bufLen);
+    dmMsg(2, "IFF: plane row size %d bytes.\n", bufLen);
 
     // Decode the chunk
     for (int yc = 0; yc < img->height; yc++)
@@ -1610,7 +1610,7 @@
             if (!dmIFFReadOneRow(fp, iff, buf, bufLen))
             {
                 res = dmError(DMERR_FREAD,
-                    "ILBM: Error in reading image plane #%d @ %d.\n",
+                    "IFF: Error in reading image plane #%d @ %d.\n",
                     plane, yc);
                 goto error;
             }
@@ -1628,7 +1628,7 @@
             if (!dmIFFReadOneRow(fp, iff, buf, bufLen))
             {
                 res = dmError(DMERR_FREAD,
-                    "ILBM: Error in reading mask plane.\n");
+                    "IFF: Error in reading mask plane.\n");
                 goto error;
             }
 
@@ -1666,7 +1666,7 @@
         if (!dmIFFReadOneRow(fp, iff, dp, img->width))
         {
             res = dmError(DMERR_FREAD,
-                "ILBM: Error in reading image row #%d.\n", yc);
+                "IFF: Error in reading image row #%d.\n", yc);
             goto error;
         }
 
@@ -1678,7 +1678,7 @@
 }
 
 
-int dmReadILBMImage(DMResource *fp, DMImage **pimg)
+int dmReadIFFImage(DMResource *fp, DMImage **pimg)
 {
     DMIFFChunk chunk;
     DMIFF iff;
@@ -1695,16 +1695,16 @@
     if (chunk.id != IFF_ID_FORM || chunk.size < 32)
     {
         return dmError(DMERR_NOT_SUPPORTED,
-            "ILBM: Not a IFF file (%08X vs %08X / %d).\n",
+            "IFF: Not a IFF file (%08X vs %08X / %d).\n",
             chunk.id, IFF_ID_FORM, chunk.size);
     }
 
-    // Check IFF ILBM signature
+    // Check IFF ILBM/PBM signature
     if (!dmf_read_be32(fp, &idsig) ||
         (idsig != IFF_ID_ILBM && idsig != IFF_ID_PBM))
     {
         return dmError(DMERR_INVALID_DATA,
-            "ILBM: Not a ILBM file.\n");
+            "IFF: Not a IFF ILBM/PBM file.\n");
     }
 
     planar = (idsig == IFF_ID_ILBM);
@@ -1737,10 +1737,10 @@
                     !dmf_read_be16(fp, (Uint16 *) &iff.bmhd.pageh))
                 {
                     return dmError(DMERR_FREAD,
-                        "ILBM: Error reading BMHD chunk.\n");
+                        "IFF: Error reading BMHD chunk.\n");
                 }
 
-                dmMsg(1, "ILBM: BMHD %d x %d @ %d, %d : nplanes=%d, comp=%d, mask=%d, transp=%d\n",
+                dmMsg(1, "IFF: BMHD %d x %d @ %d, %d : nplanes=%d, comp=%d, mask=%d, transp=%d\n",
                     iff.bmhd.w, iff.bmhd.h, iff.bmhd.x, iff.bmhd.y,
                     iff.bmhd.nplanes, iff.bmhd.compression, iff.bmhd.masking,
                     iff.bmhd.transp);
@@ -1754,7 +1754,7 @@
                     iff.bmhd.masking != IFF_MASK_TRANSP))
                 {
                     return dmError(DMERR_NOT_SUPPORTED,
-                        "ILBM: Unsupported features, refusing to load.\n");
+                        "IFF: Unsupported features, refusing to load.\n");
                 }
 
                 if ((res = dmSkipIFFChunkRest(fp, &chunk, sizeof(iff.bmhd))) != DMERR_OK)
@@ -1772,15 +1772,15 @@
                 {
                     // Non-fatal
                     dmError(DMERR_INVALID_DATA,
-                    "ILBM: CMAP chunk size not divisible by 3, possibly broken file.\n");
+                    "IFF: CMAP chunk size not divisible by 3, possibly broken file.\n");
                 }
 
                 iff.ncolors = chunk.size / 3;
-                dmMsg(2, "ILBM: CMAP %d entries (%d bytes)\n",
+                dmMsg(2, "IFF: CMAP %d entries (%d bytes)\n",
                     iff.ncolors, chunk.size);
 
                 if (iff.bmhd.nplanes > 0 && iff.ncolors != 1 << iff.bmhd.nplanes)
-                    dmMsg(2, "ILBM: Expected %d entries in CMAP.\n", 1 << iff.bmhd.nplanes);
+                    dmMsg(2, "IFF: Expected %d entries in CMAP.\n", 1 << iff.bmhd.nplanes);
 
                 // Read palette
                 if (iff.ncolors > 0)
@@ -1789,12 +1789,12 @@
                         (iff.bmhd.masking == IFF_MASK_TRANSP) ? iff.bmhd.transp : -1))
                     {
                         return dmError(DMERR_MALLOC,
-                            "ILBM: Could not allocate palette data.\n");
+                            "IFF: Could not allocate palette data.\n");
                     }
                     if (!dmPaletteReadData(fp, iff.pal, iff.ncolors))
                     {
                         return dmError(DMERR_FREAD,
-                            "ILBM: Error reading CMAP.\n");
+                            "IFF: Error reading CMAP.\n");
                     }
                 }
 
@@ -1811,10 +1811,10 @@
                 if (!iff.chBMHD.count)
                 {
                     return dmError(DMERR_INVALID_DATA,
-                        "ILBM: BODY chunk before BMHD?\n");
+                        "IFF: BODY chunk before BMHD?\n");
                 }
 
-                dmMsg(2, "ILBM: BODY chunk size %d bytes\n", chunk.size);
+                dmMsg(2, "IFF: BODY chunk size %d bytes\n", chunk.size);
 
                 // Allocate image
                 if ((*pimg = dmImageAlloc(iff.bmhd.w, iff.bmhd.h,
@@ -1853,15 +1853,15 @@
                 if (!dmf_read_be32(fp, &iff.camg))
                 {
                     return dmError(DMERR_FREAD,
-                        "ILBM: Error reading CAMG chunk.\n");
+                        "IFF: Error reading CAMG chunk.\n");
                 }
 
-                dmMsg(2, "ILBM: CAMG value 0x%08x\n", iff.camg);
+                dmMsg(2, "IFF: CAMG value 0x%08x\n", iff.camg);
 
                 if ((iff.camg & IFF_CAMG_HAM))
                 {
                     return dmError(DMERR_NOT_SUPPORTED,
-                        "ILBM: HAM files are not supported.\n");
+                        "IFF: HAM files are not supported.\n");
                 }
 
                 if ((res = dmSkipIFFChunkRest(fp, &chunk, sizeof(Uint32))) != DMERR_OK)
@@ -1877,7 +1877,7 @@
                     if (dmfseek(fp, chunk.size, SEEK_CUR) != 0)
                     {
                         return dmError(DMERR_FSEEK,
-                            "ILBM: Error skipping in file.");
+                            "IFF: Error skipping in file.");
                     }
                 }
                 break;
@@ -1896,13 +1896,13 @@
             void *ptmp;
             if (!planar)
             {
-                dmErrorMsg("ILBM: Non-planar PBM file with Halfbrite enabled! This might not work.\n");
+                dmErrorMsg("IFF: Non-planar PBM file with Halfbrite enabled! This might not work.\n");
             }
 
             if (iff.ncolors > 128)
             {
                 return dmError(DMERR_NOT_SUPPORTED,
-                    "ILBM: Halfbrite enabled, but ncolors > 128.\n");
+                    "IFF: Halfbrite enabled, but ncolors > 128.\n");
             }
 
             if ((ptmp = dmRealloc(iff.pal, sizeof(DMColor) * iff.ncolors * 2)) == NULL)
@@ -1954,9 +1954,9 @@
         fmtProbePCX, dmReadPCXImage, dmWritePCXImage,
     },
     {
-        "ilbm", "IFF ILBM / PBM",
-        DM_IMGFMT_ILBM, DM_FMT_RDWR,
-        fmtProbeILBM, dmReadILBMImage,
+        "iff", "IFF ILBM / PBM",
+        DM_IMGFMT_IFF, DM_FMT_RDWR,
+        fmtProbeIFF, dmReadIFFImage,
         NULL,
     },
     {
--- a/tools/libgfx.h	Mon Jun 25 17:56:35 2018 +0300
+++ b/tools/libgfx.h	Mon Jun 25 19:36:26 2018 +0300
@@ -22,7 +22,7 @@
     DM_IMGFMT_PNG,
     DM_IMGFMT_PPM,
     DM_IMGFMT_PCX,
-    DM_IMGFMT_ILBM,
+    DM_IMGFMT_IFF,
     DM_IMGFMT_RAW,
     DM_IMGFMT_ARAW,
 };
@@ -139,7 +139,7 @@
 int dmWritePCXImage(DMResource *fp, const DMImage *img, const DMImageConvSpec *spec);
 int dmReadPCXImage(DMResource *fp, DMImage **pimg);
 
-int dmReadILBMImage(DMResource *fp, DMImage **pimg);
+int dmReadIFFImage(DMResource *fp, DMImage **pimg);
 
 
 typedef struct _DMBitStreamContext