diff tools/gfxconv.c @ 2157:9a9493809b3a

Rename DM_COLFMT_* constants to DM_PIXFMT_* and the 'format' field of DMImage and DMImageWriteSpec to 'pixfmt' to be more precise about their meaning.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 04 Jun 2019 16:27:09 +0300
parents e6ec7fad9ce2
children e363dc852383
line wrap: on
line diff
--- a/tools/gfxconv.c	Tue Jun 04 16:18:41 2019 +0300
+++ b/tools/gfxconv.c	Tue Jun 04 16:27:09 2019 +0300
@@ -144,7 +144,7 @@
     .nplanes = 0,
     .bpp = 8,
     .planar = FALSE,
-    .format = 0,
+    .pixfmt = 0,
     .compression = FCMP_BEST,
 };
 
@@ -1068,7 +1068,7 @@
         goto error;
     }
 
-    if ((dst = *pdst = dmImageAlloc(src->width, src->height, src->format, src->bpp)) == NULL)
+    if ((dst = *pdst = dmImageAlloc(src->width, src->height, src->pixfmt, src->bpp)) == NULL)
     {
         res = dmError(DMERR_MALLOC,
             "Could not allocate memory for remapped image.\n");
@@ -1435,7 +1435,7 @@
     // Perform color remapping
     DMImage *image = pimage;
     BOOL allocated = FALSE;
-    if (optRemapColors && pimage->format == DM_COLFMT_PALETTE)
+    if (optRemapColors && pimage->pixfmt == DM_PIXFMT_PALETTE)
     {
         if ((res = dmRemapImageColors(&image, pimage)) != DMERR_OK)
             return res;
@@ -1446,11 +1446,11 @@
     // Determine number of planes, if paletted
     if (spec->nplanes == 0)
     {
-        if (image->format == DM_COLFMT_PALETTE &&
+        if (image->pixfmt == DM_PIXFMT_PALETTE &&
             image->pal != NULL)
             spec->nplanes = dmGetNPlanesFromNColors(image->pal->ncolors);
         else
-        if (image->format == DM_COLFMT_GRAYSCALE)
+        if (image->pixfmt == DM_PIXFMT_GRAYSCALE)
             spec->nplanes = image->bpp;
     }
 
@@ -1464,16 +1464,16 @@
     {
         case DM_IMGFMT_PNG:
             if (optUsePalette)
-                spec->format = (image->format == DM_COLFMT_GRAYSCALE) ? DM_COLFMT_GRAYSCALE : DM_COLFMT_PALETTE;
+                spec->pixfmt = (image->pixfmt == DM_PIXFMT_GRAYSCALE) ? DM_PIXFMT_GRAYSCALE : DM_PIXFMT_PALETTE;
             else
-                spec->format = DM_COLFMT_RGBA;
+                spec->pixfmt = DM_PIXFMT_RGBA;
             break;
 
         case DM_IMGFMT_PPM:
-            if (optUsePalette && image->format == DM_COLFMT_GRAYSCALE)
-                spec->format = DM_COLFMT_GRAYSCALE;
+            if (optUsePalette && image->pixfmt == DM_PIXFMT_GRAYSCALE)
+                spec->pixfmt = DM_PIXFMT_GRAYSCALE;
             else
-                spec->format = DM_COLFMT_RGB;
+                spec->pixfmt = DM_PIXFMT_RGB;
             break;
 
         case DM_IMGFMT_RAW:
@@ -1511,7 +1511,7 @@
             break;
 
         default:
-            spec->format = optUsePalette ? DM_COLFMT_PALETTE : DM_COLFMT_RGB;
+            spec->pixfmt = optUsePalette ? DM_PIXFMT_PALETTE : DM_PIXFMT_RGB;
             break;
     }
 
@@ -1523,12 +1523,12 @@
         if (info)
         {
             char *str;
-            switch (image->format)
+            switch (image->pixfmt)
             {
-                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;
+                case DM_PIXFMT_PALETTE   : str = "indexed/paletted"; break;
+                case DM_PIXFMT_RGB       : str = "24bit RGB"; break;
+                case DM_PIXFMT_RGBA      : str = "32bit RGBA"; break;
+                case DM_PIXFMT_GRAYSCALE : str = "grayscale"; break;
                 default                  : str = "???"; break;
             }
             dmMsg(2, "Using %s output.\n", str);
@@ -1806,7 +1806,7 @@
                 goto error;
             }
 
-            outImage = dmImageAlloc(outWidthPX, outHeight, DM_COLFMT_PALETTE, -1);
+            outImage = dmImageAlloc(outWidthPX, outHeight, DM_PIXFMT_PALETTE, -1);
             dmMsg(1, "Outputting sequence of %d images @ %d x %d -> %d x %d.\n",
                 optItemCount,
                 outImage->width, outImage->height,
@@ -1827,7 +1827,7 @@
             if (optItemCount % optPlanedWidth)
                 outIHeight++;
 
-            outImage = dmImageAlloc(outWidthPX * outIWidth, outIHeight * outHeight, DM_COLFMT_PALETTE, -1);
+            outImage = dmImageAlloc(outWidthPX * outIWidth, outIHeight * outHeight, DM_PIXFMT_PALETTE, -1);
         }
 
         if ((err = dmSetDefaultC64Palette(outImage)) != DMERR_OK)