diff src/libgfx.c @ 1102:e06abfde6c39

Cosmetics pass: Remove excess whitespace.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 03 Mar 2015 23:22:36 +0200
parents 985225a93aeb
children d0898867ec4c
line wrap: on
line diff
--- a/src/libgfx.c	Tue Mar 03 22:32:34 2015 +0200
+++ b/src/libgfx.c	Tue Mar 03 23:22:36 2015 +0200
@@ -31,7 +31,7 @@
     DMImage *img = dmMalloc0(sizeof(DMImage));
     if (img == NULL)
         return NULL;
-    
+
     img->width = width;
     img->height = height;
     img->pitch = width * sizeof(Uint8);
@@ -42,7 +42,7 @@
         dmFree(img);
         return NULL;
     }
-    
+
     return img;
 }
 
@@ -86,7 +86,7 @@
 {
     if (img == NULL)
         return FALSE;
-    
+
     img->ncolors = ncolors;
     img->ctransp = ctransp;
     return dmPaletteAlloc(&(img->pal), ncolors, ctransp);
@@ -112,7 +112,7 @@
 static BOOL dmReadPaletteData(FILE *fp, DMColor *pal, int ncolors)
 {
     int i;
-    
+
     for (i = 0; i < ncolors; i++)
     {
         Uint8 colR, colG, colB;
@@ -167,7 +167,7 @@
                     qg = img->pal[c].g;
                     qb = img->pal[c].b;
                     qa = img->pal[c].a;
-                
+
                     for (xscale = 0; xscale < spec->scaleX; xscale++)
                     {
                         *ptr1++ = qr;
@@ -181,7 +181,7 @@
                     qr = img->pal[c].r;
                     qg = img->pal[c].g;
                     qb = img->pal[c].b;
-                
+
                     for (xscale = 0; xscale < spec->scaleX; xscale++)
                     {
                         *ptr1++ = qr;
@@ -194,7 +194,7 @@
                     qr = img->pal[c].r;
                     qg = img->pal[c].g;
                     qb = img->pal[c].b;
-                
+
                     for (xscale = 0; xscale < spec->scaleX; xscale++)
                     {
                         *ptr1++ = qr;
@@ -213,7 +213,7 @@
     }
 
 done:
-    dmFree(row);    
+    dmFree(row);
     return res;
 }
 
@@ -251,7 +251,7 @@
 {
     int xc, yc, plane, res;
     DMBitStreamContext bs;
-    
+
     if ((res = dmInitBitStreamFILE(&bs, fp)) != DMERR_OK)
         return res;
 
@@ -287,7 +287,7 @@
             }
         }
     }
-    
+
     return dmFlushBitStream(&bs);
 }
 
@@ -386,7 +386,7 @@
             "PNG: png_create_write_struct() failed.\n");
         goto error;
     }
-    
+
     info_ptr = png_create_info_struct(png_ptr);
     if (info_ptr == NULL)
     {
@@ -395,7 +395,7 @@
             png_ptr);
         goto error;
     }
-    
+
     if (setjmp(png_jmpbuf(png_ptr)))
     {
         res = dmError(DMERR_INIT_FAIL,
@@ -417,7 +417,7 @@
                 spec->format);
             goto error;
     }
- 
+
     png_set_IHDR(png_ptr, info_ptr,
         img->width * spec->scaleX,
         img->height * spec->scaleY,
@@ -444,7 +444,7 @@
                 "PNG: Could not allocate palette structure.");
             goto error;
         }
-        
+
         memset(palette, 0, PNG_MAX_PALETTE_LENGTH * sizeof(png_color));
 
         for (i = 0; i < img->ncolors; i++)
@@ -530,7 +530,7 @@
             png_ptr);
         goto error;
     }
-    
+
     if (setjmp(png_jmpbuf(png_ptr)))
     {
         res = dmError(DMERR_INIT_FAIL,
@@ -568,7 +568,7 @@
                 goto error;
             }
             break;
-        
+
         case PNG_COLOR_TYPE_PALETTE:
             png_set_packing(png_ptr);
             break;
@@ -617,10 +617,10 @@
                 img->pal[i].r = img->pal[i].g = img->pal[i].b = i;
             }
             break;
-        
+
         case PNG_COLOR_TYPE_PALETTE:
             png_get_PLTE(png_ptr, info_ptr, &palette, &ncolors);
-            dmMsg(3, "PNG: Palette of %d colors found.\n", ncolors);            
+            dmMsg(3, "PNG: Palette of %d colors found.\n", ncolors);
             if (ncolors > 0 && palette != NULL)
             {
                 if (!dmImageAllocPalette(img, ncolors, -1))
@@ -652,7 +652,7 @@
                     img->ctransp = i;
             }
         }
-    }    
+    }
 
 error:
 //    png_free(png_ptr, palette);
@@ -747,7 +747,7 @@
     DMPCXData *pcx = (DMPCXData *) cbdata;
     int plane;
     size_t soffs = 0;
-    
+
 //    fprintf(stderr, "%d, %d * %d = %d\n", len, pcx->header->bpl, pcx->header->nplanes, pcx->header->nplanes * pcx->header->bpl);
 
     pcx->bufOffs = 0;
@@ -864,7 +864,7 @@
             "PCX: Could not write basic header data.\n");
         goto error;
     }
-    
+
     if (!dm_fwrite_le16(pcx.fp, hdr.xmin) ||
         !dm_fwrite_le16(pcx.fp, hdr.ymin) ||
         !dm_fwrite_le16(pcx.fp, hdr.xmax) ||
@@ -883,7 +883,7 @@
             "PCX: Could not write colormap.\n");
         goto error;
     }
-    
+
     if (!dm_fwrite_byte(pcx.fp, hdr.reserved) ||
         !dm_fwrite_byte(pcx.fp, hdr.nplanes) ||
         !dm_fwrite_le16(pcx.fp, hdr.bpl) ||
@@ -912,7 +912,7 @@
             dm_fwrite_byte(pcx.fp, img->pal[i].b);
         }
 
-        // Pad the palette, if necessary        
+        // Pad the palette, if necessary
         for (; i < 256; i++)
         {
             dm_fwrite_byte(pcx.fp, 0);
@@ -920,7 +920,7 @@
             dm_fwrite_byte(pcx.fp, 0);
         }
     }
-    
+
 error:
     dmFree(pcx.buf);
     return res;
@@ -938,9 +938,9 @@
             "PCX: Could not open file '%s' for writing.\n",
             filename);
     }
-    
+
     res = dmWritePCXImageFILE(fp, img, spec);
-    
+
     fclose(fp);
     return res;
 }
@@ -956,7 +956,7 @@
 
         if (!dm_fread_byte(fp, &data))
             return FALSE;
-        
+
         if ((data & 0xC0) == 0xC0)
         {
             count = data & 0x3F;
@@ -996,7 +996,7 @@
             "PCX: Could not read basic header data.\n");
         goto error;
     }
-    
+
     if (hdr.manufacturer != 10 ||
         hdr.version != 5 ||
         hdr.encoding != 1 ||
@@ -1006,7 +1006,7 @@
             "PCX: Not a PCX file, or unsupported variant.\n");
         goto error;
     }
-    
+
     if (!dm_fread_le16(fp, &hdr.xmin) ||
         !dm_fread_le16(fp, &hdr.ymin) ||
         !dm_fread_le16(fp, &hdr.xmax) ||
@@ -1025,7 +1025,7 @@
             "PCX: Could not read colormap.\n");
         goto error;
     }
-    
+
     if (!dm_fread_byte(fp, &hdr.reserved) ||
         !dm_fread_byte(fp, &hdr.nplanes) ||
         !dm_fread_le16(fp, &hdr.bpl) ||
@@ -1036,7 +1036,7 @@
             "PCX: Could not read header remainder.\n");
         goto error;
     }
-    
+
     if (hdr.nplanes != 3 && hdr.nplanes != 1)
     {
         res = dmError(DMERR_FREAD,
@@ -1073,14 +1073,14 @@
                 "PCX: Error decoding RLE data.\n");
             goto error;
         }
-        
+
         // Decode bitplanes
         switch (hdr.nplanes)
         {
             case 1:
                 memcpy(dp, pcx.buf, img->width);
                 break;
-            
+
             case 3:
                 {
                     Uint8 *dptr = dp,
@@ -1097,7 +1097,7 @@
                 }
                 break;
         }
-        
+
         dp += img->pitch;
     }
 
@@ -1125,7 +1125,7 @@
                 "PCX: Could not allocate palette data!\n");
             goto error;
         }
-        
+
         if (read)
         {
             if (!dmReadPaletteData(fp, img->pal, ncolors))
@@ -1166,7 +1166,7 @@
             "PCX: Could not open file '%s' for reading.\n",
             filename);
     }
-    
+
     res = dmReadPCXImageFILE(fp, pimg);
 
     fclose(fp);
@@ -1302,7 +1302,7 @@
 
         if (!dm_fread_byte(fp, (Uint8 *) &dcount))
             return FALSE;
-        
+
         if (dcount == -128)
         {
             if (!dm_fread_byte(fp, &data))
@@ -1361,7 +1361,7 @@
     Uint8 *buf;
     size_t bufLen;
     int yc, res = DMERR_OK;
-    
+
     *read = 0;
 
     // Allocate image
@@ -1374,7 +1374,7 @@
         return DMERR_MALLOC;
 
     dmMsg(3, "ILBM: plane row size %d bytes.\n", bufLen);
-    
+
     // Decode the chunk
     for (yc = 0; yc < img->height; yc++)
     {
@@ -1418,7 +1418,7 @@
             for (xc = 0; xc < img->width; xc++)
             {
                 const Uint8 data = (buf[xc / 8] >> (7 - (xc & 7))) & 1;
-                
+
                 // Black out any pixels with mask bit 0
                 if (!data)
                     dp[xc] = 0;
@@ -1484,7 +1484,7 @@
         return dmError(DMERR_NOT_SUPPORTED,
             "ILBM: Not a IFF file.\n");
     }
-    
+
     // Check IFF ILBM signature
     if (!dm_fread_be32(fp, &idILBM) ||
         (idILBM != IFF_ID_ILBM && idILBM != IFF_ID_PBM))
@@ -1502,7 +1502,7 @@
             return dmError(DMERR_FREAD,
                 "ILBM: Error reading IFF ILBM data.\n");
         }
-        
+
         switch (chunk.id)
         {
             case IFF_ID_BMHD:
@@ -1532,7 +1532,7 @@
                 dmMsg(3, "ILBM: BMHD %d x %d @ %d, %d : nplanes=%d, comp=%d, mask=%d\n",
                     iff.bmhd.w, iff.bmhd.h, iff.bmhd.x, iff.bmhd.y,
                     iff.bmhd.nplanes, iff.bmhd.compression, iff.bmhd.masking);
-                
+
                 // Sanity check
                 if (iff.bmhd.nplanes < 1 || iff.bmhd.nplanes > 8 ||
                     (iff.bmhd.compression != IFF_COMP_NONE &&
@@ -1569,7 +1569,7 @@
 
                 if (iff.bmhd.nplanes > 0 && iff.ncolors != 1 << iff.bmhd.nplanes)
                     dmMsg(3, "ILBM: Expected %d entries in CMAP.\n", 1 << iff.bmhd.nplanes);
-                
+
                 // Read palette
                 if (iff.ncolors > 0)
                 {
@@ -1589,7 +1589,7 @@
                 if (iff.chBMHD.count && iff.chBODY.count)
                     parsed = TRUE;
                 break;
-            
+
             case IFF_ID_BODY:
                 // Check for multiple occurences of CMAP
                 if ((res = dmCheckIFFChunk(&iff.chBODY, &chunk, FALSE, 1)) != DMERR_OK)
@@ -1603,7 +1603,7 @@
                 }
 
                 dmMsg(3, "ILBM: BODY chunk size %d bytes\n", chunk.size);
-                
+
                 // Decode the body
                 if (iff.planar)
                 {
@@ -1630,7 +1630,7 @@
                     return dmError(DMERR_FREAD,
                         "ILBM: Error reading CAMG chunk.\n");
                 }
-                
+
                 dmMsg(3, "ILBM: CAMG value 0x%08x\n", iff.camg);
 
                 if ((iff.camg & IFF_CAMG_HAM))
@@ -1648,7 +1648,7 @@
                 {
                     dmMsg(4, "Unknown chunk ID '%s', size %d\n",
                         dmGetIFFChunkID(&chunk), chunk.size);
-                    
+
                     if (fseeko(fp, chunk.size, SEEK_CUR) != 0)
                     {
                         return dmError(DMERR_FSEEK,
@@ -1657,7 +1657,7 @@
                 }
                 break;
         }
-        
+
         if (chunk.size & 1)
             fgetc(fp);
     }
@@ -1684,7 +1684,7 @@
             }
             else
                 iff.pal = ptmp;
-            
+
             for (i = 0; i < iff.ncolors; i++)
             {
                 int i2 = iff.ncolors + i;
@@ -1693,7 +1693,7 @@
                 iff.pal[i2].b = iff.pal[i].b / 2;
             }
         }
-    
+
         (*pimg)->ncolors = iff.ncolors;
         (*pimg)->pal = iff.pal;
     }
@@ -1713,7 +1713,7 @@
             "ILBM: Could not open file '%s' for reading.\n",
             filename);
     }
-    
+
     res = dmReadILBMImageFILE(fp, pimg);
 
     fclose(fp);