[gs-commits] rev 10959 - trunk/gs/toolbin

robin at ghostscript.com robin at ghostscript.com
Wed Mar 24 00:10:28 UTC 2010


Author: robin
Date: 2010-03-24 00:10:27 +0000 (Wed, 24 Mar 2010)
New Revision: 10959

Modified:
   trunk/gs/toolbin/bmpcmp.c
Log:
Correct DOS line endings in bmpcmp.c.

Fix bug whereby areas with no changes in were still be saved out.



Modified: trunk/gs/toolbin/bmpcmp.c
===================================================================
--- trunk/gs/toolbin/bmpcmp.c	2010-03-23 20:46:14 UTC (rev 10958)
+++ trunk/gs/toolbin/bmpcmp.c	2010-03-24 00:10:27 UTC (rev 10959)
@@ -11,9 +11,9 @@
 #ifdef HAVE_LIBPNG
 #include <png.h>
 #endif
-
-#define DEBUG_BBOX(A) /* do {(A);} while(0==1) */
 
+#define DEBUG_BBOX(A) /* do {(A);} while(0==1) */
+
 /* Values in map field:
  *
  *  0 means Completely unchanged pixel
@@ -2009,13 +2009,14 @@
             local.ymax  = global->ymax;
         }
     }
+    *global = local;
 }
 
 int main(int argc, char *argv[])
 {
     int            w,  h,  s,  bpp,  cmyk;
     int            w2, h2, s2, bpp2, cmyk2;
-    int            nx, ny, n;
+    int            nx, ny, n;
     int            xstep, ystep;
     int            imagecount;
     unsigned char *bmp;
@@ -2066,46 +2067,46 @@
         params.height = h;
         params.span   = s;
         params.bpp    = bpp;
-        (*diffFn)(bmp, bmp2, map, &bbox, &params);
+        (*diffFn)(bmp, bmp2, map, &bbox, &params);
         if ((bbox.xmin <= bbox.xmax) && (bbox.ymin <= bbox.ymax))
         {
             /* Make the bbox sensibly exclusive */
             bbox.xmax++;
             bbox.ymax++;
 
-            DEBUG_BBOX(fprintf(stderr, "Raw bbox=%d %d %d %d\n",
-                               bbox.xmin, bbox.ymin, bbox.xmax, bbox.ymax));
+            DEBUG_BBOX(fprintf(stderr, "Raw bbox=%d %d %d %d\n",
+                               bbox.xmin, bbox.ymin, bbox.xmax, bbox.ymax));
             /* Make bbox2.xmin/ymin be the centre of the changed area */
             bbox2.xmin = (bbox.xmin + bbox.xmax + 1)/2;
             bbox2.ymin = (bbox.ymin + bbox.ymax + 1)/2;
 
-            /* Calculate subdivisions of image to fit as best as possible
+            /* Calculate subdivisions of image to fit as best as possible
              * into our max/min sizes. */
             nx = 1;
-            ny = 1;
+            ny = 1;
             xstep = bbox.xmax - bbox.xmin;
             if (xstep > params.output_size.xmax)
             {
                 nx = 1+(xstep/params.output_size.xmax);
                 xstep = params.output_size.xmax;
-            }
-            if (xstep < params.output_size.xmin)
-                xstep = params.output_size.xmin;
-            if (xstep*nx > w)
-                xstep = (w+nx-1)/nx;
-            bbox2.xmax = xstep*nx;
-            ystep = bbox.ymax - bbox.ymin;
+            }
+            if (xstep < params.output_size.xmin)
+                xstep = params.output_size.xmin;
+            if (xstep*nx > w)
+                xstep = (w+nx-1)/nx;
+            bbox2.xmax = xstep*nx;
+            ystep = bbox.ymax - bbox.ymin;
             bbox2.ymax = ystep;
             if (ystep > params.output_size.ymax)
             {
                 ny = 1+(ystep/params.output_size.ymax);
                 ystep = params.output_size.ymax;
             }
-            if (ystep < params.output_size.ymin)
-                ystep = params.output_size.ymin;
-            if (ystep*ny > h)
-                ystep = (h+ny-1)/ny;
-            bbox2.ymax = ystep*ny;
+            if (ystep < params.output_size.ymin)
+                ystep = params.output_size.ymin;
+            if (ystep*ny > h)
+                ystep = (h+ny-1)/ny;
+            bbox2.ymax = ystep*ny;
 
             /* Now make the real bbox */
             bbox2.xmin -= bbox2.xmax>>1;
@@ -2131,15 +2132,15 @@
                 bbox2.ymax = h;
             }
 
-            DEBUG_BBOX(fprintf(stderr, "Expanded bbox=%d %d %d %d\n",
-                               bbox2.xmin, bbox2.ymin, bbox2.xmax, bbox2.ymax));
-
+            DEBUG_BBOX(fprintf(stderr, "Expanded bbox=%d %d %d %d\n",
+                               bbox2.xmin, bbox2.ymin, bbox2.xmax, bbox2.ymax));
+
             /* bbox */
             boxlist = Malloc(sizeof(*boxlist) * nx * ny);
 
             /* Now save the changed bmps */
             n = params.basenum;
-            boxlist--;
+            boxlist--;
             for (w2=0; w2 < nx; w2++)
             {
                 for (h2=0; h2 < ny; h2++)
@@ -2153,16 +2154,16 @@
                     boxlist->ymax = boxlist->ymin + ystep;
                     if (boxlist->ymax > bbox2.ymax)
                         boxlist->ymax = bbox2.ymax;
-                    DEBUG_BBOX(fprintf(stderr, "Retesting bbox=%d %d %d %d\n",
-                                       boxlist->xmin, boxlist->ymin,
-                                       boxlist->xmax, boxlist->ymax));
-
+                    DEBUG_BBOX(fprintf(stderr, "Retesting bbox=%d %d %d %d\n",
+                                       boxlist->xmin, boxlist->ymin,
+                                       boxlist->xmax, boxlist->ymax));
+
                     rediff(map, boxlist, &params);
                     if (!BBox_valid(boxlist))
                         continue;
-                    DEBUG_BBOX(fprintf(stderr, "Reduced bbox=%d %d %d %d\n",
-                                       boxlist->xmin, boxlist->ymin,
-                                       boxlist->xmax, boxlist->ymax));
+                    DEBUG_BBOX(fprintf(stderr, "Reduced bbox=%d %d %d %d\n",
+                                       boxlist->xmin, boxlist->ymin,
+                                       boxlist->xmax, boxlist->ymax));
                     if (cmyk)
                     {
                         uncmyk_bmp(bmp,  boxlist, s);
@@ -2190,16 +2191,16 @@
                     sprintf(str4, "%s.%05d.meta", params.outroot, n);
                     save_meta(boxlist, str4, w, h, imagecount);
                     n += 3;
-                    /* If there is a maximum set */
-                    if (params.maxdiffs > 0)
-                    {
-                        /* Check to see we haven't exceeded it */
-                        params.maxdiffs--;
-                        if (params.maxdiffs == 0)
-                        {
-                            goto done;
-                        }
-                    }
+                    /* If there is a maximum set */
+                    if (params.maxdiffs > 0)
+                    {
+                        /* Check to see we haven't exceeded it */
+                        params.maxdiffs--;
+                        if (params.maxdiffs == 0)
+                        {
+                            goto done;
+                        }
+                    }
                 }
             }
             params.basenum = n;
@@ -2211,9 +2212,9 @@
         free(bmp);
         free(bmp2);
         free(map);
-    }
+    }
 
-done:
+done:
     /* If one loaded, and the other didn't - that's an error */
     if ((bmp2 != NULL) && (bmp == NULL))
     {



More information about the gs-commits mailing list