]> granicus.if.org Git - imagemagick/commitdiff
(no commit message)
authorcristy <urban-warrior@git.imagemagick.org>
Wed, 17 Mar 2010 20:21:27 +0000 (20:21 +0000)
committercristy <urban-warrior@git.imagemagick.org>
Wed, 17 Mar 2010 20:21:27 +0000 (20:21 +0000)
34 files changed:
ChangeLog
coders/cals.c
coders/caption.c
coders/dcm.c
coders/emf.c
coders/fpx.c
coders/histogram.c
coders/jpeg.c
coders/label.c
coders/msl.c
coders/mvg.c
coders/pcl.c
coders/pdf.c
coders/ps.c
coders/ps2.c
coders/ps3.c
coders/svg.c
coders/tiff.c
coders/txt.c
coders/xps.c
magick/annotate.c
magick/display.c
magick/distort.c
magick/draw.c
magick/effect.c
magick/fx.c
magick/geometry.c
magick/image.c
magick/property.c
magick/resize.c
magick/shear.c
magick/statistic.c
wand/drawing-wand.c
wand/mogrify.c

index d14e69458a99377268bd417524106e91104564e1..9255f744d88e031d88033705ba3455beb21198e8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,6 @@
 2010-03-17  6.6.0-7 Cristy  <quetzlzacatenango@image...>
   * Detect CMYKProcessColor AI tag.
+  * Delete image from command line cache for -write option.
 
 2010-03-13  6.6.0-6 Cristy  <quetzlzacatenango@image...>
   * Add support for the Adobe Large Document format.
index 72bde2a2ba207829478c75932160c82c36963985..ead41655db2016c88ec135a954b6658eb980bf5d 100644 (file)
@@ -542,7 +542,7 @@ static MagickBooleanType WriteCALSImage(const ImageInfo *image_info,
         geometry_info;
 
       (void) ParseGeometry(image_info->density,&geometry_info);
-      density=(unsigned long) (geometry_info.rho+0.5);
+      density=(unsigned long) floor(geometry_info.rho+0.5);
     }
   (void) FormatMagickString(header,MaxTextExtent,"rdensty: %04lu",density);
   count=WriteCALSRecord(image,header);
index 035572bfe14ca06cc5d31b539b0cbeeea62e5e89..b7242cbea7e8a98d80f4ed19ddf0b7ab2e3083cf 100644 (file)
@@ -162,8 +162,9 @@ static Image *ReadCAPTIONImage(const ImageInfo *image_info,
         if (draw_info->gravity == UndefinedGravity)
           (void) CloneString(&draw_info->geometry,geometry);
         status=GetMultilineTypeMetrics(image,draw_info,&metrics);
-        width=(unsigned long) (metrics.width+draw_info->stroke_width+0.5);
-        height=(unsigned long) (metrics.height+draw_info->stroke_width+0.5);
+        width=(unsigned long) floor(metrics.width+draw_info->stroke_width+0.5);
+        height=(unsigned long) floor(metrics.height+draw_info->stroke_width+
+          0.5);
         if ((width > (image->columns+1)) || (height > (image->rows+1)))
           break;
         draw_info->pointsize*=2.0;
@@ -180,8 +181,9 @@ static Image *ReadCAPTIONImage(const ImageInfo *image_info,
         if (draw_info->gravity == UndefinedGravity)
           (void) CloneString(&draw_info->geometry,geometry);
         status=GetMultilineTypeMetrics(image,draw_info,&metrics);
-        width=(unsigned long) (metrics.width+draw_info->stroke_width+0.5);
-        height=(unsigned long) (metrics.height+draw_info->stroke_width+0.5);
+        width=(unsigned long) floor(metrics.width+draw_info->stroke_width+0.5);
+        height=(unsigned long) floor(metrics.height+draw_info->stroke_width+
+          0.5);
         if ((width > (image->columns+1)) || (height > (image->rows+1)))
           break;
         draw_info->pointsize++;
index 450cdbe7aee8e19cff2c5537eb4117538bb57066..b393c5d4507e71f9e21959e77fa7ca019b9e2654 100644 (file)
@@ -3738,8 +3738,10 @@ static Image *ReadDCMImage(const ImageInfo *image_info,ExceptionInfo *exception)
                       window_max,
                       window_min;
 
-                    window_min=(long) (window_center-(window_width-1)/2.0-0.5);
-                    window_max=(long) (window_center+(window_width-1)/2.0-0.5);
+                    window_min=(long) ceil(window_center-(window_width-1)/2.0-
+                      0.5);
+                    window_max=(long) floor(window_center+(window_width-1)/2.0+
+                      0.5);
                     if ((long) pixel_value <= window_min)
                       index=0;
                     else
index 86072fa4022e3de9d053c551eda95be20f40f6ee..2489258864eda3700e4053b31a7e54c40bf8d9cb 100644 (file)
@@ -526,10 +526,11 @@ static Image *ReadEMFImage(const ImageInfo *image_info,
           flags=ParseMetaGeometry(geometry,&sans,&sans,&image->columns,
             &image->rows);
           if (image->x_resolution != 0.0)
-            image->columns=(unsigned long) ((image->columns*
+            image->columns=(unsigned long) floor((image->columns*
               image->x_resolution)+0.5);
           if (image->y_resolution != 0.0)
-            image->rows=(unsigned long) ((image->rows*image->y_resolution)+0.5);
+            image->rows=(unsigned long) floor((image->rows*image->y_resolution)+
+              0.5);
         }
       else
         {
@@ -537,11 +538,11 @@ static Image *ReadEMFImage(const ImageInfo *image_info,
           flags=ParseMetaGeometry(geometry,&sans,&sans,&image->columns,
             &image->rows);
           if (image->x_resolution != 0.0)
-            image->columns=(unsigned long) (((image->columns*
+            image->columns=(unsigned long) floor(((image->columns*
               image->x_resolution)/DefaultResolution)+0.5);
           if (image->y_resolution != 0.0)
-            image->rows=(unsigned long) (((image->rows*image->y_resolution)/
-              DefaultResolution)+0.5);
+            image->rows=(unsigned long) floor(((image->rows*
+              image->y_resolution)/DefaultResolution)+0.5);
         }
       geometry=DestroyString(geometry);
     }
index ace1a4f85fcd6a836c895e16e4382d2fbbf53a86..f43e5582a13729f6489cb0ba3fca328a87440bb4 100644 (file)
@@ -282,7 +282,7 @@ static Image *ReadFPXImage(const ImageInfo *image_info,ExceptionInfo *exception)
       fpx_status=FPX_GetImageResultAspectRatio(flashpix,&aspect_ratio);
       if (fpx_status != FPX_OK)
         ThrowReaderException(DelegateError,"UnableToReadAspectRatio");
-      if (width != (unsigned long) ((aspect_ratio*height)+0.5))
+      if (width != (unsigned long) floor((aspect_ratio*height)+0.5))
         Swap(width,height);
     }
   fpx_status=FPX_GetSummaryInformation(flashpix,&summary_info);
index ff5f3fc1fab95ce4577b259dd85f4e64ae8da6df..8d4b84193390df2360faf849eeac507839e82ea1 100644 (file)
@@ -305,7 +305,7 @@ static MagickBooleanType WriteHISTOGRAMImage(const ImageInfo *image_info,
       break;
     if ((channel & RedChannel) != 0)
       {
-        y=(long) (histogram_image->rows-scale*histogram[x].red+0.5);
+        y=(long) ceil(histogram_image->rows-scale*histogram[x].red-0.5);
         r=q+y;
         for ( ; y < (long) histogram_image->rows; y++)
         {
@@ -315,7 +315,7 @@ static MagickBooleanType WriteHISTOGRAMImage(const ImageInfo *image_info,
       }
     if ((channel & GreenChannel) != 0)
       {
-        y=(long) (histogram_image->rows-scale*histogram[x].green+0.5);
+        y=(long) ceil(histogram_image->rows-scale*histogram[x].green-0.5);
         r=q+y;
         for ( ; y < (long) histogram_image->rows; y++)
         {
@@ -325,7 +325,7 @@ static MagickBooleanType WriteHISTOGRAMImage(const ImageInfo *image_info,
       }
     if ((channel & BlueChannel) != 0)
       {
-        y=(long) (histogram_image->rows-scale*histogram[x].blue+0.5);
+        y=(long) ceil(histogram_image->rows-scale*histogram[x].blue-0.5);
         r=q+y;
         for ( ; y < (long) histogram_image->rows; y++)
         {
index f311b70556f5115c710adb53c1b2c8ab0c38b787..460c33c3f6baef920a97626c71ed4c9fb5eee13d 100644 (file)
@@ -1778,8 +1778,8 @@ static MagickBooleanType WriteJPEGImage(const ImageInfo *image_info,
   jpeg_info.density_unit=(UINT8) 1;
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-      "Image resolution: %ld,%ld",(long) (image->x_resolution+0.5),
-      (long) (image->y_resolution+0.5));
+      "Image resolution: %ld,%ld",(long) ceil(image->x_resolution-0.5),
+      (long) ceil(image->y_resolution-0.5));
   if ((image->x_resolution != 0.0) && (image->y_resolution != 0.0))
     {
       /*
index 43a2d6ded25a1769d3d0b7e45064c3eaa3a2280c..84351c420e729ffcd41f72a1bcba9554c670c38e 100644 (file)
@@ -138,8 +138,9 @@ static Image *ReadLABELImage(const ImageInfo *image_info,
       status=GetMultilineTypeMetrics(image,draw_info,&metrics);
       for ( ; status != MagickFalse; draw_info->pointsize*=2.0)
       {
-        width=(unsigned long) (metrics.width+draw_info->stroke_width+0.5);
-        height=(unsigned long) (metrics.height+draw_info->stroke_width+0.5);
+        width=(unsigned long) floor(metrics.width+draw_info->stroke_width+0.5);
+        height=(unsigned long) floor(metrics.height+draw_info->stroke_width+
+          0.5);
         if (((image->columns != 0) && (width > (image->columns+1))) ||
             ((image->rows != 0) && (height > (image->rows+1))))
           break;
@@ -147,8 +148,9 @@ static Image *ReadLABELImage(const ImageInfo *image_info,
       }
       for ( ; status != MagickFalse; draw_info->pointsize--)
       {
-        width=(unsigned long) (metrics.width+draw_info->stroke_width+0.5);
-        height=(unsigned long) (metrics.height+draw_info->stroke_width+0.5);
+        width=(unsigned long) floor(metrics.width+draw_info->stroke_width+0.5);
+        height=(unsigned long) floor(metrics.height+draw_info->stroke_width+
+          0.5);
         if ((image->columns != 0) && (width <= (image->columns+1)) &&
            ((image->rows == 0) || (height <= (image->rows+1))))
           break;
@@ -180,10 +182,11 @@ static Image *ReadLABELImage(const ImageInfo *image_info,
       draw_info->geometry=AcquireString(geometry);
     }
   if (image->rows == 0)
-    image->rows=(unsigned long) (metrics.height+draw_info->stroke_width+0.5);
-  if (image->rows == 0)
-    image->rows=(unsigned long) (draw_info->pointsize+draw_info->stroke_width+
+    image->rows=(unsigned long) floor(metrics.height+draw_info->stroke_width+
       0.5);
+  if (image->rows == 0)
+    image->rows=(unsigned long) floor(draw_info->pointsize+
+      draw_info->stroke_width+0.5);
   if (SetImageBackgroundColor(image) == MagickFalse)
     {
       InheritException(exception,&image->exception);
index aa85eac13c882dfe64aa89fd54071a1aec0448c9..aa015092a916611e151d929f0e8e5a206ef60a73 100644 (file)
@@ -6248,8 +6248,8 @@ static void MSLStartElement(void *context,const xmlChar *tag,
               }
             }
           shadow_image=ShadowImage(msl_info->image[n],geometry_info.rho,
-            geometry_info.sigma,(long) (geometry_info.xi+0.5),(long)
-            (geometry_info.psi+0.5),&msl_info->image[n]->exception);
+            geometry_info.sigma,(long) floor(geometry_info.xi+0.5),(long)
+            floor(geometry_info.psi+0.5),&msl_info->image[n]->exception);
           if (shadow_image == (Image *) NULL)
             break;
           msl_info->image[n]=DestroyImage(msl_info->image[n]);
index a1b4e68d7a8bad7c859dd9fe73a0ac64056cd37f..5c716587099b971962f430654337a861fa77bce5 100644 (file)
@@ -175,8 +175,8 @@ static Image *ReadMVGImage(const ImageInfo *image_info,ExceptionInfo *exception)
           continue;
         (void) sscanf(p,"viewbox %lf %lf %lf %lf",&bounds.x1,&bounds.y1,
           &bounds.x2,&bounds.y2);
-        image->columns=(unsigned long) ((bounds.x2-bounds.x1)+0.5);
-        image->rows=(unsigned long) ((bounds.y2-bounds.y1)+0.5);
+        image->columns=(unsigned long) floor((bounds.x2-bounds.x1)+0.5);
+        image->rows=(unsigned long) floor((bounds.y2-bounds.y1)+0.5);
         break;
       }
     }
index 31852b5fe6a1509194bae437a20f008619d879c1..ec1ac388ef80b17df0b2358609f70da3249b3c37 100644 (file)
@@ -290,8 +290,8 @@ static Image *ReadPCLImage(const ImageInfo *image_info,ExceptionInfo *exception)
     /*
       Set PCL render geometry.
     */
-    width=(unsigned long) (bounds.x2-bounds.x1+0.5);
-    height=(unsigned long) (bounds.y2-bounds.y1+0.5);
+    width=(unsigned long) floor(bounds.x2-bounds.x1+0.5);
+    height=(unsigned long) floor(bounds.y2-bounds.y1+0.5);
     if (width > page.width)
       page.width=width;
     if (height > page.height)
@@ -323,8 +323,9 @@ static Image *ReadPCLImage(const ImageInfo *image_info,ExceptionInfo *exception)
     (void) ParseAbsoluteGeometry(image_info->page,&page);
   (void) FormatMagickString(density,MaxTextExtent,"%gx%g",
     image->x_resolution,image->y_resolution);
-  page.width=(unsigned long) (page.width*image->x_resolution/delta.x+0.5);
-  page.height=(unsigned long) (page.height*image->y_resolution/delta.y+0.5);
+  page.width=(unsigned long) floor(page.width*image->x_resolution/delta.x+0.5);
+  page.height=(unsigned long) floor(page.height*image->y_resolution/delta.y+
+    0.5);
   (void) FormatMagickString(options,MaxTextExtent,"-g%lux%lu ",
     page.width,page.height);
   image=DestroyImage(image);
index e3bbbefbd1a7982b293de0f1a1cd679a1a62a879..e7ad0d0aa2c76f448dfe1b968eb9f9397e4d04a3 100644 (file)
@@ -531,8 +531,8 @@ static Image *ReadPDFImage(const ImageInfo *image_info,ExceptionInfo *exception)
           "%gx%g%+.15g%+.15g",bounds.x2-bounds.x1,bounds.y2-bounds.y1,
            bounds.x1,bounds.y1);
         (void) SetImageProperty(image,"pdf:HiResBoundingBox",geometry);
-        page.width=(unsigned long) (bounds.x2-bounds.x1+0.5);
-        page.height=(unsigned long) (bounds.y2-bounds.y1+0.5);
+        page.width=(unsigned long) floor(bounds.x2-bounds.x1+0.5);
+        page.height=(unsigned long) floor(bounds.y2-bounds.y1+0.5);
         hires_bounds=bounds;
       }
   }
@@ -587,8 +587,10 @@ static Image *ReadPDFImage(const ImageInfo *image_info,ExceptionInfo *exception)
   if (image_info->page != (char *) NULL)
     {
       (void) ParseAbsoluteGeometry(image_info->page,&page);
-      page.width=(unsigned long) (page.width*image->x_resolution/delta.x+0.5);
-      page.height=(unsigned long) (page.height*image->y_resolution/delta.y+0.5);
+      page.width=(unsigned long) floor(page.width*image->x_resolution/delta.x+
+        0.5);
+      page.height=(unsigned long) floor(page.height*image->y_resolution/delta.y+
+        0.5);
       (void) FormatMagickString(options,MaxTextExtent,"-g%lux%lu ",page.width,
         page.height);
     }
@@ -1263,9 +1265,9 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image)
     (void) ParseMetaGeometry(page_geometry,&geometry.x,&geometry.y,
       &geometry.width,&geometry.height);
     scale.x=(double) (geometry.width*delta.x)/resolution.x;
-    geometry.width=(unsigned long) (scale.x+0.5);
+    geometry.width=(unsigned long) floor(scale.x+0.5);
     scale.y=(double) (geometry.height*delta.y)/resolution.y;
-    geometry.height=(unsigned long) (scale.y+0.5);
+    geometry.height=(unsigned long) floor(scale.y+0.5);
     (void) ParseAbsoluteGeometry(page_geometry,&media_info);
     (void) ParseGravityGeometry(image,page_geometry,&page_info,
       &image->exception);
index 5ee5cbe6d328e3b6de6d20559b26086844a4cb39..d204f5b389ef48be0b140a267ffad4ca141909ce 100644 (file)
@@ -669,8 +669,8 @@ static Image *ReadPSImage(const ImageInfo *image_info,ExceptionInfo *exception)
           "%gx%g%+.15g%+.15g",bounds.x2-bounds.x1,bounds.y2-bounds.y1,
           bounds.x1,bounds.y1);
         (void) SetImageProperty(image,"ps:HiResBoundingBox",geometry);
-        page.width=(unsigned long) (bounds.x2-bounds.x1+0.5);
-        page.height=(unsigned long) (bounds.y2-bounds.y1+0.5);
+        page.width=(unsigned long) floor(bounds.x2-bounds.x1+0.5);
+        page.height=(unsigned long) floor(bounds.y2-bounds.y1+0.5);
         hires_bounds=bounds;
       }
   }
@@ -722,8 +722,9 @@ static Image *ReadPSImage(const ImageInfo *image_info,ExceptionInfo *exception)
     (void) ParseAbsoluteGeometry(image_info->page,&page);
   (void) FormatMagickString(density,MaxTextExtent,"%gx%g",
     image->x_resolution,image->y_resolution);
-  page.width=(unsigned long) (page.width*image->x_resolution/delta.x+0.5);
-  page.height=(unsigned long) (page.height*image->y_resolution/delta.y+0.5);
+  page.width=(unsigned long) floor(page.width*image->x_resolution/delta.x+0.5);
+  page.height=(unsigned long) floor(page.height*image->y_resolution/delta.y+
+    0.5);
   (void) FormatMagickString(options,MaxTextExtent,"-g%lux%lu ",
     page.width,page.height);
   read_info=CloneImageInfo(image_info);
@@ -1433,9 +1434,9 @@ static MagickBooleanType WritePSImage(const ImageInfo *image_info,Image *image)
     (void) ParseMetaGeometry(page_geometry,&geometry.x,&geometry.y,
       &geometry.width,&geometry.height);
     scale.x=(double) (geometry.width*delta.x)/resolution.x;
-    geometry.width=(unsigned long) (scale.x+0.5);
+    geometry.width=(unsigned long) floor(scale.x+0.5);
     scale.y=(double) (geometry.height*delta.y)/resolution.y;
-    geometry.height=(unsigned long) (scale.y+0.5);
+    geometry.height=(unsigned long) floor(scale.y+0.5);
     (void) ParseAbsoluteGeometry(page_geometry,&media_info);
     (void) ParseGravityGeometry(image,page_geometry,&page_info,
       &image->exception);
@@ -1482,9 +1483,9 @@ static MagickBooleanType WritePSImage(const ImageInfo *image_info,Image *image)
         else
           {
             (void) FormatMagickString(buffer,MaxTextExtent,
-              "%%%%BoundingBox: %ld %ld %ld %ld\n",(long) (bounds.x1+0.5),
-              (long) (bounds.y1+0.5),(long) (bounds.x2+0.5),
-              (long) (bounds.y2+0.5));
+              "%%%%BoundingBox: %ld %ld %ld %ld\n",(long) ceil(bounds.x1-0.5),
+              (long) ceil(bounds.y1-0.5),(long) floor(bounds.x2+0.5),
+              (long) floor(bounds.y2+0.5));
             (void) WriteBlobString(image,buffer);
             (void) FormatMagickString(buffer,MaxTextExtent,
               "%%%%HiResBoundingBox: %g %g %g %g\n",bounds.x1,
@@ -2088,8 +2089,9 @@ static MagickBooleanType WritePSImage(const ImageInfo *image_info,Image *image)
   if (page > 2)
     {
       (void) FormatMagickString(buffer,MaxTextExtent,
-        "%%%%BoundingBox: %ld %ld %ld %ld\n",(long) (bounds.x1+0.5),
-        (long) (bounds.y1+0.5),(long) (bounds.x2+0.5),(long) (bounds.y2+0.5));
+        "%%%%BoundingBox: %ld %ld %ld %ld\n",(long) ceil(bounds.x1-0.5),
+        (long) ceil(bounds.y1-0.5),(long) floor(bounds.x2+0.5),(long)
+        floor(bounds.y2+0.5));
       (void) WriteBlobString(image,buffer);
       (void) FormatMagickString(buffer,MaxTextExtent,
         "%%%%HiResBoundingBox: %g %g %g %g\n",bounds.x1,bounds.y1,
index b373d284cba0448652232474d775ff2d799a0eae..76c78bd6880b3713fae88a313ea504f94af88682 100644 (file)
@@ -531,9 +531,9 @@ static MagickBooleanType WritePS2Image(const ImageInfo *image_info,Image *image)
     (void) ParseMetaGeometry(page_geometry,&geometry.x,&geometry.y,
       &geometry.width,&geometry.height);
     scale.x=(double) (geometry.width*delta.x)/resolution.x;
-    geometry.width=(unsigned long) (scale.x+0.5);
+    geometry.width=(unsigned long) floor(scale.x+0.5);
     scale.y=(double) (geometry.height*delta.y)/resolution.y;
-    geometry.height=(unsigned long) (scale.y+0.5);
+    geometry.height=(unsigned long) floor(scale.y+0.5);
     (void) ParseAbsoluteGeometry(page_geometry,&media_info);
     (void) ParseGravityGeometry(image,page_geometry,&page_info,
       &image->exception);
@@ -580,9 +580,9 @@ static MagickBooleanType WritePS2Image(const ImageInfo *image_info,Image *image)
         else
           {
             (void) FormatMagickString(buffer,MaxTextExtent,
-              "%%%%BoundingBox: %ld %ld %ld %ld\n",(long) (bounds.x1+0.5),
-              (long) (bounds.y1+0.5),
-              (long) (bounds.x2+0.5),(long) (bounds.y2+0.5));
+              "%%%%BoundingBox: %ld %ld %ld %ld\n",(long) ceil(bounds.x1-0.5),
+              (long) ceil(bounds.y1-0.5),(long) floor(bounds.x2+0.5),(long)
+              floor(bounds.y2+0.5));
             (void) WriteBlobString(image,buffer);
             (void) FormatMagickString(buffer,MaxTextExtent,
               "%%%%HiResBoundingBox: %g %g %g %g\n",bounds.x1,
@@ -1093,8 +1093,9 @@ static MagickBooleanType WritePS2Image(const ImageInfo *image_info,Image *image)
   if (page > 1)
     {
       (void) FormatMagickString(buffer,MaxTextExtent,
-        "%%%%BoundingBox: %ld %ld %ld %ld\n",(long) (bounds.x1+0.5),
-        (long) (bounds.y1+0.5),(long) (bounds.x2+0.5),(long) (bounds.y2+0.5));
+        "%%%%BoundingBox: %ld %ld %ld %ld\n",(long) ceil(bounds.x1-0.5),
+        (long) ceil(bounds.y1-0.5),(long) floor(bounds.x2+0.5),(long)
+        floor(bounds.y2+0.5));
       (void) WriteBlobString(image,buffer);
       (void) FormatMagickString(buffer,MaxTextExtent,
         "%%%%HiResBoundingBox: %g %g %g %g\n",bounds.x1,bounds.y1,
index e5282339d24d02c61dac66cfa65d930b11391580..4a2d4784f56c73e6fcadb678317b3f3b6026badf 100644 (file)
@@ -952,9 +952,9 @@ static MagickBooleanType WritePS3Image(const ImageInfo *image_info,Image *image)
     (void) ParseMetaGeometry(page_geometry,&geometry.x,&geometry.y,
       &geometry.width,&geometry.height);
     scale.x=(double) (geometry.width*delta.x)/resolution.x;
-    geometry.width=(unsigned long) (scale.x+0.5);
+    geometry.width=(unsigned long) floor(scale.x+0.5);
     scale.y=(double) (geometry.height*delta.y)/resolution.y;
-    geometry.height=(unsigned long) (scale.y+0.5);
+    geometry.height=(unsigned long) floor(scale.y+0.5);
     (void) ParseAbsoluteGeometry(page_geometry,&media_info);
     (void) ParseGravityGeometry(image,page_geometry,&page_info,
       &image->exception);
index a65a5265b443f803297a8c10b2819d24fe41099e..b9a83384c838613241f77b1b87836a8ff8f0f6cd 100644 (file)
@@ -2114,8 +2114,8 @@ static void SVGStartElement(void *context,const xmlChar *name,
           if ((svg_info->view_box.width == 0.0) ||
               (svg_info->view_box.height == 0.0))
             svg_info->view_box=svg_info->bounds;
-          svg_info->width=(unsigned long) (svg_info->bounds.width+0.5);
-          svg_info->height=(unsigned long) (svg_info->bounds.height+0.5);
+          svg_info->width=(unsigned long) floor(svg_info->bounds.width+0.5);
+          svg_info->height=(unsigned long) floor(svg_info->bounds.height+0.5);
           MVGPrintf(svg_info->file,"viewbox 0 0 %lu %lu\n",svg_info->width,
             svg_info->height);
           sx=(double) svg_info->width/svg_info->view_box.width;
index 807c127f58a0a18b9a98e1f713053ab06fd0f482..71441494fbe727fc4b671bd8859482f461967ab9 100644 (file)
@@ -949,8 +949,8 @@ static Image *ReadTIFFImage(const ImageInfo *image_info,
     y_position=(float) image->page.y/y_resolution;
     (void) TIFFGetFieldDefaulted(tiff,TIFFTAG_XPOSITION,&x_position);
     (void) TIFFGetFieldDefaulted(tiff,TIFFTAG_YPOSITION,&y_position);
-    image->page.x=(long) (x_position*x_resolution+0.5);
-    image->page.y=(long) (y_position*y_resolution+0.5);
+    image->page.x=(long) ceil(x_position*x_resolution-0.5);
+    image->page.y=(long) ceil(y_position*y_resolution-0.5);
     image->orientation=(OrientationType) orientation;
     chromaticity=(float *) NULL;
     (void) TIFFGetField(tiff,TIFFTAG_WHITEPOINT,&chromaticity);
index 30d29a61231de72d5c9b6b6da61b1927db724d2b..7d78b97444dce084023fb48065b92f063b85dad5 100644 (file)
@@ -223,9 +223,10 @@ static Image *ReadTEXTImage(const ImageInfo *image_info,Image *image,
   /*
     Initialize Image structure.
   */
-  image->columns=(unsigned long) (((page.width*image->x_resolution)/
+  image->columns=(unsigned long) floor(((page.width*image->x_resolution)/
     delta.x)+0.5);
-  image->rows=(unsigned long) (((page.height*image->y_resolution)/delta.y)+0.5);
+  image->rows=(unsigned long) floor(((page.height*image->y_resolution)/
+    delta.y)+0.5);
   image->page.x=0;
   image->page.y=0;
   texture=(Image *) NULL;
@@ -252,7 +253,7 @@ static Image *ReadTEXTImage(const ImageInfo *image_info,Image *image,
   status=GetTypeMetrics(image,draw_info,&metrics);
   if (status == MagickFalse)
     ThrowReaderException(TypeError,"UnableToGetTypeMetrics");
-  page.y=(long) (page.y+metrics.ascent+0.5);
+  page.y=(long) ceil(page.y+metrics.ascent-0.5);
   (void) FormatMagickString(geometry,MaxTextExtent,"0x0%+ld%+ld",page.x,page.y);
   (void) CloneString(&draw_info->geometry,geometry);
   (void) CopyMagickString(filename,image_info->filename,MaxTextExtent);
index a6dd479814f796657d2c337babc5e60fe9ebd349..51a347cd96c0f3ca436052b0c54123c91bc93e94 100644 (file)
@@ -248,8 +248,8 @@ static Image *ReadXPSImage(const ImageInfo *image_info,ExceptionInfo *exception)
     /*
       Set XPS render geometry.
     */
-    width=(unsigned long) (bounds.x2-bounds.x1+0.5);
-    height=(unsigned long) (bounds.y2-bounds.y1+0.5);
+    width=(unsigned long) floor(bounds.x2-bounds.x1+0.5);
+    height=(unsigned long) floor(bounds.y2-bounds.y1+0.5);
     if (width > page.width)
       page.width=width;
     if (height > page.height)
@@ -279,8 +279,9 @@ static Image *ReadXPSImage(const ImageInfo *image_info,ExceptionInfo *exception)
     (void) ParseAbsoluteGeometry(PSPageGeometry,&page);
   if (image_info->page != (char *) NULL)
     (void) ParseAbsoluteGeometry(image_info->page,&page);
-  page.width=(unsigned long) (page.width*image->y_resolution/delta.x+0.5);
-  page.height=(unsigned long) (page.height*image->y_resolution/delta.y+0.5);
+  page.width=(unsigned long) floor(page.width*image->y_resolution/delta.x+0.5);
+  page.height=(unsigned long) floor(page.height*image->y_resolution/delta.y+
+    0.5);
   (void) FormatMagickString(options,MaxTextExtent,"-g%lux%lu ",
     page.width,page.height);
   image=DestroyImage(image);
index 188c0dad7217e87b90d952083da6b58e8c2829b9..e3faef0396439ece499b367e9212795b84037a95 100644 (file)
@@ -503,7 +503,7 @@ MagickExport long FormatMagickCaption(Image *image,DrawInfo *draw_info,
     status=GetTypeMetrics(image,draw_info,metrics);
     if (status == MagickFalse)
       break;
-    width=(unsigned long) (metrics->width+0.5);
+    width=(unsigned long) floor(metrics->width+0.5);
     if (GetUTFCode(p) != '\n')
       if (width <= image->columns)
         continue;
@@ -817,7 +817,7 @@ static MagickBooleanType RenderType(Image *image,const DrawInfo *draw_info,
           TypeWarning,"UnableToReadFont","`%s'",draw_info->family);
     }
   if (type_info == (const TypeInfo *) NULL)
-    type_info=GetTypeInfoByFamily("Utopia",draw_info->style,
+    type_info=GetTypeInfoByFamily("Century Schoolbook",draw_info->style,
       draw_info->stretch,draw_info->weight,&image->exception);
   if (type_info == (const TypeInfo *) NULL)
     type_info=GetTypeInfoByFamily("Arial",draw_info->style,
@@ -1291,8 +1291,8 @@ static MagickBooleanType RenderFreetype(Image *image,const DrawInfo *draw_info,
 
             if (status == MagickFalse)
               continue;
-            x_offset=(long) (point.x+0.5);
-            y_offset=(long) (point.y+y+0.5);
+            x_offset=(long) ceil(point.x-0.5);
+            y_offset=(long) ceil(point.y+y-0.5);
             if ((y_offset < 0) || (y_offset >= (long) image->rows))
               continue;
             q=(PixelPacket *) NULL;
@@ -1470,8 +1470,8 @@ static MagickBooleanType RenderFreetype(Image *image,const DrawInfo *draw_info,
 
             if (status == MagickFalse)
               continue;
-            x_offset=(long) (point.x+0.5);
-            y_offset=(long) (point.y+y+0.5);
+            x_offset=(long) ceil(point.x-0.5);
+            y_offset=(long) ceil(point.y+y-0.5);
             if ((y_offset < 0) || (y_offset >= (long) image->rows))
               continue;
             q=(PixelPacket *) NULL;
@@ -1780,7 +1780,7 @@ static MagickBooleanType RenderPostscript(Image *image,
   (void) fprintf(file,"showpage\n");
   (void) fclose(file);
   (void) FormatMagickString(geometry,MaxTextExtent,"%ldx%ld+0+0!",(long)
-    (extent.x+0.5),(long) (extent.y+0.5));
+    floor(extent.x+0.5),(long) floor(extent.y+0.5));
   annotate_info=AcquireImageInfo();
   (void) FormatMagickString(annotate_info->filename,MaxTextExtent,"ps:%s",
     filename);
@@ -1820,7 +1820,8 @@ static MagickBooleanType RenderPostscript(Image *image,
       crop_info=GetImageBoundingBox(annotate_image,&annotate_image->exception);
       crop_info.height=(unsigned long) ((resolution.y/DefaultResolution)*
         ExpandAffine(&draw_info->affine)*draw_info->pointsize+0.5);
-      crop_info.y=(long) ((resolution.y/DefaultResolution)*extent.y/8.0+0.5);
+      crop_info.y=(long) ceil((resolution.y/DefaultResolution)*extent.y/8.0-
+        0.5);
       (void) FormatMagickString(geometry,MaxTextExtent,"%lux%lu%+ld%+ld",
         crop_info.width,crop_info.height,crop_info.x,crop_info.y);
       (void) TransformImage(&annotate_image,geometry,(char *) NULL);
@@ -1898,8 +1899,8 @@ static MagickBooleanType RenderPostscript(Image *image,
       }
       annotate_view=DestroyCacheView(annotate_view);
       (void) CompositeImage(image,OverCompositeOp,annotate_image,
-        (long) (offset->x+0.5),(long) (offset->y-(metrics->ascent+
-        metrics->descent)+0.5));
+        (long) ceil(offset->x-0.5),(long) ceil(offset->y-(metrics->ascent+
+        metrics->descent)-0.5));
     }
   annotate_image=DestroyImage(annotate_image);
   return(MagickTrue);
@@ -2113,9 +2114,9 @@ static MagickBooleanType RenderX11(Image *image,const DrawInfo *draw_info,
           atan2(draw_info->affine.rx,draw_info->affine.sx);
     }
   (void) FormatMagickString(annotate_info.geometry,MaxTextExtent,
-    "%lux%lu+%ld+%ld",width,height,(long) (offset->x+0.5),
-    (long) (offset->y-metrics->ascent-metrics->descent+
-    draw_info->interline_spacing+0.5));
+    "%lux%lu+%ld+%ld",width,height,(long) ceil(offset->x-0.5),
+    (long) ceil(offset->y-metrics->ascent-metrics->descent+
+    draw_info->interline_spacing-0.5));
   pixel.pen_color.red=ScaleQuantumToShort(draw_info->fill.red);
   pixel.pen_color.green=ScaleQuantumToShort(draw_info->fill.green);
   pixel.pen_color.blue=ScaleQuantumToShort(draw_info->fill.blue);
index 15ca70ade9886aa9b2e9363bf09db90d333f7a80..61ac790dac50be2e71fc97ca529e7bb1c1e27748 100644 (file)
@@ -8517,7 +8517,7 @@ static Image *XMagickCommand(Display *display,XResourceInfo *resource_info,
       if ((flags & PsiValue) == 0)
         geometry_info.psi=0.1*(*image)->rows;
       vignette_image=VignetteImage(*image,geometry_info.rho,geometry_info.sigma,
-        (long) (geometry_info.xi+0.5),(long) (geometry_info.psi+0.5),
+        (long) floor(geometry_info.xi+0.5),(long) floor(geometry_info.psi+0.5),
         &(*image)->exception);
       if (vignette_image != (Image *) NULL)
         {
index 3b805de258358bc86f8f8e47f782bca6dbd3a7ae..f353cee3b205d330135725cc2cab73bfcc71ba0f 100644 (file)
@@ -127,7 +127,9 @@ static void InvertPerspectiveCoefficients(const double *coeff,
 
 static inline double MagickRound(double x)
 {
-  /* round the fraction to nearest integer */
+  /*
+    Round the fraction to nearest integer.
+  */
   if (x >= 0.0)
     return((double) ((long) (x+0.5)));
   return((double) ((long) (x-0.5)));
@@ -1607,10 +1609,10 @@ MagickExport Image *DistortImage(const Image *image,DistortImageMethod method,
        Do not do this for DePolar which needs to be exact for tiling
     */
     if ( bestfit && method != DePolarDistortion ) {
-      geometry.x = (long) floor(min.x-0.5);
-      geometry.y = (long) floor(min.y-0.5);
-      geometry.width=(unsigned long) ceil(max.x-geometry.x+0.5);
-      geometry.height=(unsigned long) ceil(max.y-geometry.y+0.5);
+      geometry.x = (long) ceil(min.x-0.5);
+      geometry.y = (long) ceil(min.y-0.5);
+      geometry.width=(unsigned long) floor(max.x-geometry.x+0.5);
+      geometry.height=(unsigned long) floor(max.y-geometry.y+0.5);
     }
     /* now that we have a new size lets fit distortion to it exactly */
     if ( method == DePolarDistortion ) {
index 4b15824589cfa0ec1bc8d248b4f46e1039ac2e68..29a3531154651e174f1a5459f0545b17fb81ab2f 100644 (file)
@@ -997,7 +997,7 @@ static SegmentInfo AffineEdge(const Image *image,const AffineMatrix *affine,
           inverse_edge.x2=x;
       }
     else
-      if ((z < 0.0) || ((unsigned long) (z+0.5) >= image->columns))
+      if ((z < 0.0) || ((unsigned long) floor(z+0.5) >= image->columns))
         {
           inverse_edge.x2=edge->x1;
           return(inverse_edge);
@@ -1030,7 +1030,7 @@ static SegmentInfo AffineEdge(const Image *image,const AffineMatrix *affine,
           inverse_edge.x2=x;
       }
     else
-      if ((z < 0.0) || ((unsigned long) (z+0.5) >= image->rows))
+      if ((z < 0.0) || ((unsigned long) floor(z+0.5) >= image->rows))
         {
           inverse_edge.x2=edge->x2;
           return(inverse_edge);
@@ -1173,7 +1173,7 @@ MagickExport MagickBooleanType DrawAffineImage(Image *image,
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-  for (y=(long) (edge.y1+0.5); y <= (long) (edge.y2+0.5); y++)
+  for (y=(long) ceil(edge.y1-0.5); y <= (long) floor(edge.y2+0.5); y++)
   {
     long
       x_offset;
@@ -1201,9 +1201,9 @@ MagickExport MagickBooleanType DrawAffineImage(Image *image,
     inverse_edge=AffineEdge(source,&inverse_affine,(double) y,&edge);
     if (inverse_edge.x2 < inverse_edge.x1)
       continue;
-    q=GetCacheViewAuthenticPixels(image_view,(long) (inverse_edge.x1+0.5),y,
-      (unsigned long) ((long) (inverse_edge.x2+0.5)-(long) (inverse_edge.x1+
-      0.5)+1),1,exception);
+    q=GetCacheViewAuthenticPixels(image_view,(long) ceil(inverse_edge.x1-0.5),y,
+      (unsigned long) ((long) floor(inverse_edge.x2+0.5)-(long) floor(
+      inverse_edge.x1+0.5)+1),1,exception);
     if (q == (PixelPacket *) NULL)
       continue;
     id=GetOpenMPThreadId();
@@ -1211,7 +1211,7 @@ MagickExport MagickBooleanType DrawAffineImage(Image *image,
     pixel=zero;
     composite=zero;
     x_offset=0;
-    for (x=(long) (inverse_edge.x1+0.5); x <= (long) (inverse_edge.x2+0.5); x++)
+    for (x=(long) ceil(inverse_edge.x1-0.5); x <= (long) floor(inverse_edge.x2+0.5); x++)
     {
       point.x=(double) x*inverse_affine.sx+y*inverse_affine.ry+
         inverse_affine.tx;
@@ -2391,19 +2391,19 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info)
                 GetMagickToken(q,&q,token);
                 (void) CopyMagickString(name,token,MaxTextExtent);
                 GetMagickToken(q,&q,token);
-                bounds.x=(long) (StringToDouble(token)+0.5);
+                bounds.x=(long) ceil(StringToDouble(token)-0.5);
                 GetMagickToken(q,&q,token);
                 if (*token == ',')
                   GetMagickToken(q,&q,token);
-                bounds.y=(long) (StringToDouble(token)+0.5);
+                bounds.y=(long) ceil(StringToDouble(token)-0.5);
                 GetMagickToken(q,&q,token);
                 if (*token == ',')
                   GetMagickToken(q,&q,token);
-                bounds.width=(unsigned long) (StringToDouble(token)+0.5);
+                bounds.width=(unsigned long) floor(StringToDouble(token)+0.5);
                 GetMagickToken(q,&q,token);
                 if (*token == ',')
                   GetMagickToken(q,&q,token);
-                bounds.height=(unsigned long) (StringToDouble(token)+0.5);
+                bounds.height=(unsigned long) floor(StringToDouble(token)+0.5);
                 for (p=q; *q != '\0'; )
                 {
                   GetMagickToken(q,&q,token);
@@ -2726,20 +2726,23 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info)
         if (LocaleCompare("viewbox",keyword) == 0)
           {
             GetMagickToken(q,&q,token);
-            graphic_context[n]->viewbox.x=(long) (StringToDouble(token)+0.5);
+            graphic_context[n]->viewbox.x=(long) ceil(StringToDouble(token)-
+              0.5);
             GetMagickToken(q,&q,token);
             if (*token == ',')
               GetMagickToken(q,&q,token);
-            graphic_context[n]->viewbox.y=(long) (StringToDouble(token)+0.5);
+            graphic_context[n]->viewbox.y=(long) ceil(StringToDouble(token)-
+              0.5);
             GetMagickToken(q,&q,token);
             if (*token == ',')
               GetMagickToken(q,&q,token);
-            graphic_context[n]->viewbox.width=(unsigned long) (StringToDouble(token)+0.5);
+            graphic_context[n]->viewbox.width=(unsigned long) floor(
+              StringToDouble(token)+0.5);
             GetMagickToken(q,&q,token);
             if (*token == ',')
               GetMagickToken(q,&q,token);
-            graphic_context[n]->viewbox.height=(unsigned long) (StringToDouble(token)+
-              0.5);
+            graphic_context[n]->viewbox.height=(unsigned long) floor(
+              StringToDouble(token)+0.5);
             break;
           }
         status=MagickFalse;
@@ -3323,8 +3326,8 @@ MagickExport MagickBooleanType DrawGradientImage(Image *image,
         case UndefinedSpread:
         case PadSpread:
         {
-          if ((x != (long) (gradient_vector->x1+0.5)) ||
-              (y != (long) (gradient_vector->y1+0.5)))
+          if ((x != (long) ceil(gradient_vector->x1-0.5)) ||
+              (y != (long) ceil(gradient_vector->y1-0.5)))
             {
               offset=GetStopColorOffset(gradient,x,y);
               if (gradient->type != RadialGradient)
@@ -3351,8 +3354,8 @@ MagickExport MagickBooleanType DrawGradientImage(Image *image,
         }
         case ReflectSpread:
         {
-          if ((x != (long) (gradient_vector->x1+0.5)) ||
-              (y != (long) (gradient_vector->y1+0.5)))
+          if ((x != (long) ceil(gradient_vector->x1-0.5)) ||
+              (y != (long) ceil(gradient_vector->y1-0.5)))
             {
               offset=GetStopColorOffset(gradient,x,y);
               if (gradient->type != RadialGradient)
@@ -3393,8 +3396,8 @@ MagickExport MagickBooleanType DrawGradientImage(Image *image,
 
           antialias=MagickFalse;
           repeat=0.0;
-          if ((x != (long) (gradient_vector->x1+0.5)) ||
-              (y != (long) (gradient_vector->y1+0.5)))
+          if ((x != (long) ceil(gradient_vector->x1-0.5)) ||
+              (y != (long) ceil(gradient_vector->y1-0.5)))
             {
               offset=GetStopColorOffset(gradient,x,y);
               if (gradient->type == LinearGradient)
@@ -3862,21 +3865,21 @@ static MagickBooleanType DrawPolygonPrimitive(Image *image,
       bounds.y2=p->bounds.y2;
   }
   bounds.x1-=(mid+1.0);
-  bounds.x1=bounds.x1 < 0.0 ? 0.0 : (unsigned long) (bounds.x1+0.5) >=
+  bounds.x1=bounds.x1 < 0.0 ? 0.0 : (unsigned long) ceil(bounds.x1-0.5) >=
     image->columns ? (double) image->columns-1.0 : bounds.x1;
   bounds.y1-=(mid+1.0);
-  bounds.y1=bounds.y1 < 0.0 ? 0.0 : (unsigned long) (bounds.y1+0.5) >=
+  bounds.y1=bounds.y1 < 0.0 ? 0.0 : (unsigned long) ceil(bounds.y1-0.5) >=
     image->rows ? (double) image->rows-1.0 : bounds.y1;
   bounds.x2+=(mid+1.0);
-  bounds.x2=bounds.x2 < 0.0 ? 0.0 : (unsigned long) (bounds.x2+0.5) >=
+  bounds.x2=bounds.x2 < 0.0 ? 0.0 : (unsigned long) floor(bounds.x2+0.5) >=
     image->columns ? (double) image->columns-1.0 : bounds.x2;
   bounds.y2+=(mid+1.0);
-  bounds.y2=bounds.y2 < 0.0 ? 0.0 : (unsigned long) (bounds.y2+0.5) >=
+  bounds.y2=bounds.y2 < 0.0 ? 0.0 : (unsigned long) floor(bounds.y2+0.5) >=
     image->rows ? (double) image->rows-1.0 : bounds.y2;
   status=MagickTrue;
   exception=(&image->exception);
-  start=(long) (bounds.x1+0.5);
-  stop=(long) (bounds.x2+0.5);
+  start=(long) ceil(bounds.x1-0.5);
+  stop=(long) floor(bounds.x2+0.5);
   image_view=AcquireCacheView(image);
   if (primitive_info->coordinates == 1)
     {
@@ -3886,7 +3889,7 @@ static MagickBooleanType DrawPolygonPrimitive(Image *image,
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-      for (y=(long) (bounds.y1+0.5); y <= (long) (bounds.y2+0.5); y++)
+      for (y=(long) ceil(bounds.y1-0.5); y <= (long) floor(bounds.y2+0.5); y++)
       {
         MagickBooleanType
           sync;
@@ -3909,8 +3912,8 @@ static MagickBooleanType DrawPolygonPrimitive(Image *image,
           }
         for ( ; x <= stop; x++)
         {
-          if ((x == (long) (primitive_info->point.x+0.5)) &&
-              (y == (long) (primitive_info->point.y+0.5)))
+          if ((x == (long) ceil(primitive_info->point.x-0.5)) &&
+              (y == (long) ceil(primitive_info->point.y-0.5)))
             (void) GetStrokeColor(draw_info,x,y,q);
           q++;
         }
@@ -3933,7 +3936,7 @@ static MagickBooleanType DrawPolygonPrimitive(Image *image,
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-  for (y=(long) (bounds.y1+0.5); y <= (long) (bounds.y2+0.5); y++)
+  for (y=(long) ceil(bounds.y1-0.5); y <= (long) floor(bounds.y2+0.5); y++)
   {
     MagickRealType
       fill_opacity,
@@ -4048,8 +4051,8 @@ static void LogPrimitiveInfo(const PrimitiveInfo *primitive_info)
     i,
     x;
 
-  x=(long) (primitive_info->point.x+0.5);
-  y=(long) (primitive_info->point.y+0.5);
+  x=(long) ceil(primitive_info->point.x-0.5);
+  y=(long) ceil(primitive_info->point.y-0.5);
   switch (primitive_info->primitive)
   {
     case PointPrimitive:
@@ -4151,8 +4154,8 @@ MagickExport MagickBooleanType DrawPrimitive(Image *image,
     }
   status=MagickTrue;
   exception=(&image->exception);
-  x=(long) (primitive_info->point.x+0.5);
-  y=(long) (primitive_info->point.y+0.5);
+  x=(long) ceil(primitive_info->point.x-0.5);
+  y=(long) ceil(primitive_info->point.y-0.5);
   image_view=AcquireCacheView(image);
   switch (primitive_info->primitive)
   {
@@ -4449,8 +4452,8 @@ MagickExport MagickBooleanType DrawPrimitive(Image *image,
         break;
       (void) SetImageProgressMonitor(composite_image,(MagickProgressMonitor)
         NULL,(void *) NULL);
-      x1=(long) (primitive_info[1].point.x+0.5);
-      y1=(long) (primitive_info[1].point.y+0.5);
+      x1=(long) ceil(primitive_info[1].point.x-0.5);
+      y1=(long) ceil(primitive_info[1].point.y-0.5);
       if (((x1 != 0L) && (x1 != (long) composite_image->columns)) ||
           ((y1 != 0L) && (y1 != (long) composite_image->rows)))
         {
index 69016704456626207310d5d43569ef68ca484eb4..e426759fe74a17e7af57ba3052be4dcb0d62ee48 100644 (file)
@@ -316,7 +316,7 @@ MagickExport Image *AdaptiveBlurImageChannel(const Image *image,
         v;
 
       gamma=0.0;
-      i=(long) (width*QuantumScale*PixelIntensity(r)+0.5);
+      i=(long) ceil(width*QuantumScale*PixelIntensity(r)-0.5);
       if (i < 0)
         i=0;
       else
@@ -631,7 +631,7 @@ MagickExport Image *AdaptiveSharpenImageChannel(const Image *image,
         v;
 
       gamma=0.0;
-      i=(long) (width*(QuantumRange-QuantumScale*PixelIntensity(r))+0.5);
+      i=(long) ceil(width*(QuantumRange-QuantumScale*PixelIntensity(r))-0.5);
       if (i < 0)
         i=0;
       else
@@ -3167,8 +3167,8 @@ MagickExport Image *MotionBlurImageChannel(const Image *image,
   point.y=(double) width*cos(DegreesToRadians(angle));
   for (i=0; i < (long) width; i++)
   {
-    offset[i].x=(long) ((i*point.y)/hypot(point.x,point.y)+0.5);
-    offset[i].y=(long) ((i*point.x)/hypot(point.x,point.y)+0.5);
+    offset[i].x=(long) ceil((i*point.y)/hypot(point.x,point.y)-0.5);
+    offset[i].y=(long) ceil((i*point.x)/hypot(point.x,point.y)-0.5);
   }
   /*
     Motion blur image.
index dbc4b2bd5f30a0eb1fac64d7af7cf1ed28b2c06b..40f27b7b5d0c012307ec8be99e6f1dcc4d59889f 100644 (file)
@@ -3273,8 +3273,8 @@ MagickExport MagickBooleanType PlasmaImageProxy(Image *image,
       */
       depth--;
       attenuate++;
-      x_mid=(long) (segment->x1+segment->x2+0.5)/2;
-      y_mid=(long) (segment->y1+segment->y2+0.5)/2;
+      x_mid=(long) ceil(segment->x1+segment->x2-0.5)/2;
+      y_mid=(long) ceil(segment->y1+segment->y2-0.5)/2;
       local_info=(*segment);
       local_info.x2=(double) x_mid;
       local_info.y2=(double) y_mid;
@@ -3294,8 +3294,8 @@ MagickExport MagickBooleanType PlasmaImageProxy(Image *image,
     }
   if (SetImageStorageClass(image,DirectClass) == MagickFalse)
     return(MagickFalse);
-  x_mid=(long) (segment->x1+segment->x2+0.5)/2;
-  y_mid=(long) (segment->y1+segment->y2+0.5)/2;
+  x_mid=(long) ceil(segment->x1+segment->x2-0.5)/2;
+  y_mid=(long) ceil(segment->y1+segment->y2-0.5)/2;
   if ((segment->x1 == (double) x_mid) && (segment->x2 == (double) x_mid) &&
       (segment->y1 == (double) y_mid) && (segment->y2 == (double) y_mid))
     return(MagickFalse);
@@ -3312,9 +3312,11 @@ MagickExport MagickBooleanType PlasmaImageProxy(Image *image,
       /*
         Left pixel.
       */
-      x=(long) (segment->x1+0.5);
-      (void) GetOneVirtualPixel(image,x,(long) (segment->y1+0.5),&u,exception);
-      (void) GetOneVirtualPixel(image,x,(long) (segment->y2+0.5),&v,exception);
+      x=(long) ceil(segment->x1-0.5);
+      (void) GetOneVirtualPixel(image,x,(long) ceil(segment->y1-0.5),&u,
+        exception);
+      (void) GetOneVirtualPixel(image,x,(long) ceil(segment->y2-0.5),&v,
+        exception);
       q=QueueAuthenticPixels(image,x,y_mid,1,1,exception);
       if (q == (PixelPacket *) NULL)
         return(MagickTrue);
@@ -3330,10 +3332,10 @@ MagickExport MagickBooleanType PlasmaImageProxy(Image *image,
           /*
             Right pixel.
           */
-          x=(long) (segment->x2+0.5);
-          (void) GetOneVirtualPixel(image,x,(long) (segment->y1+0.5),&u,
+          x=(long) ceil(segment->x2-0.5);
+          (void) GetOneVirtualPixel(image,x,(long) ceil(segment->y1-0.5),&u,
             exception);
-          (void) GetOneVirtualPixel(image,x,(long) (segment->y2+0.5),&v,
+          (void) GetOneVirtualPixel(image,x,(long) ceil(segment->y2-0.5),&v,
             exception);
           q=QueueAuthenticPixels(image,x,y_mid,1,1,exception);
           if (q == (PixelPacket *) NULL)
@@ -3357,10 +3359,10 @@ MagickExport MagickBooleanType PlasmaImageProxy(Image *image,
           /*
             Bottom pixel.
           */
-          y=(long) (segment->y2+0.5);
-          (void) GetOneVirtualPixel(image,(long) (segment->x1+0.5),y,&u,
+          y=(long) ceil(segment->y2-0.5);
+          (void) GetOneVirtualPixel(image,(long) ceil(segment->x1-0.5),y,&u,
             exception);
-          (void) GetOneVirtualPixel(image,(long) (segment->x2+0.5),y,&v,
+          (void) GetOneVirtualPixel(image,(long) ceil(segment->x2-0.5),y,&v,
             exception);
           q=QueueAuthenticPixels(image,x_mid,y,1,1,exception);
           if (q == (PixelPacket *) NULL)
@@ -3381,10 +3383,10 @@ MagickExport MagickBooleanType PlasmaImageProxy(Image *image,
           /*
             Top pixel.
           */
-          y=(long) (segment->y1+0.5);
-          (void) GetOneVirtualPixel(image,(long) (segment->x1+0.5),y,&u,
+          y=(long) ceil(segment->y1-0.5);
+          (void) GetOneVirtualPixel(image,(long) ceil(segment->x1-0.5),y,&u,
             exception);
-          (void) GetOneVirtualPixel(image,(long) (segment->x2+0.5),y,&v,
+          (void) GetOneVirtualPixel(image,(long) ceil(segment->x2-0.5),y,&v,
             exception);
           q=QueueAuthenticPixels(image,x_mid,y,1,1,exception);
           if (q == (PixelPacket *) NULL)
@@ -3406,11 +3408,11 @@ MagickExport MagickBooleanType PlasmaImageProxy(Image *image,
       /*
         Middle pixel.
       */
-      x=(long) (segment->x1+0.5);
-      y=(long) (segment->y1+0.5);
+      x=(long) ceil(segment->x1-0.5);
+      y=(long) ceil(segment->y1-0.5);
       (void) GetOneVirtualPixel(image,x,y,&u,exception);
-      x=(long) (segment->x2+0.5);
-      y=(long) (segment->y2+0.5);
+      x=(long) ceil(segment->x2-0.5);
+      y=(long) ceil(segment->y2-0.5);
       (void) GetOneVirtualPixel(image,x,y,&v,exception);
       q=QueueAuthenticPixels(image,x_mid,y_mid,1,1,exception);
       if (q == (PixelPacket *) NULL)
@@ -4109,8 +4111,8 @@ MagickExport Image *ShadowImage(const Image *image,const double opacity,
     return((Image *) NULL);
   (void) SetImageVirtualPixelMethod(clone_image,EdgeVirtualPixelMethod);
   clone_image->compose=OverCompositeOp;
-  border_info.width=(unsigned long) (2.0*sigma+0.5);
-  border_info.height=(unsigned long) (2.0*sigma+0.5);
+  border_info.width=(unsigned long) floor(2.0*sigma+0.5);
+  border_info.height=(unsigned long) floor(2.0*sigma+0.5);
   border_info.x=0;
   border_info.y=0;
   (void) QueryColorDatabase("none",&clone_image->border_color,exception);
index 0f9a16cfc64e22ed7b855c2febbec50bf79f6654..d51c1a3ab94df7c09995e60ff7f365b2c7c388ba 100644 (file)
@@ -1014,8 +1014,10 @@ MagickExport MagickStatusType ParseGravityGeometry(const Image *image,
       scale.y=geometry_info.sigma;
       if ((status & SigmaValue) == 0)
         scale.y=scale.x;
-      region_info->width=(unsigned long) ((scale.x*image->columns/100.0)+0.5);
-      region_info->height=(unsigned long) ((scale.y*image->rows/100.0)+0.5);
+      region_info->width=(unsigned long) floor((scale.x*image->columns/100.0)+
+        0.5);
+      region_info->height=(unsigned long) floor((scale.y*image->rows/100.0)+
+        0.5);
     }
   /*
     Adjust offset according to gravity setting.
@@ -1119,10 +1121,10 @@ MagickExport MagickStatusType ParseMetaGeometry(const char *geometry,long *x,
       scale.y=geometry_info.sigma;
       if ((flags & SigmaValue) == 0)
         scale.y=scale.x;
-      *width=(unsigned long) (scale.x*former_width/100.0+0.5);
+      *width=(unsigned long) floor(scale.x*former_width/100.0-0.5);
       if (*width == 0)
         *width=1;
-      *height=(unsigned long) (scale.y*former_height/100.0+0.5);
+      *height=(unsigned long) floor(scale.y*former_height/100.0-0.5);
       if (*height == 0)
         *height=1;
       former_width=(*width);
@@ -1177,8 +1179,10 @@ MagickExport MagickStatusType ParseMetaGeometry(const char *geometry,long *x,
                 scale_factor=(MagickRealType) *height/(MagickRealType)
                   former_width;
             }
-      *width=MagickMax((unsigned long) (scale_factor*former_width+0.5),1UL);
-      *height=MagickMax((unsigned long) (scale_factor*former_height+0.5),1UL);
+      *width=MagickMax((unsigned long) floor(scale_factor*former_width+0.5),
+        1UL);
+      *height=MagickMax((unsigned long) floor(scale_factor*former_height+0.5),
+        1UL);
     }
   if ((flags & GreaterValue) != 0)
     {
index 9c6610fba757876cc05940c24c29b4c14199de0d..9021411618e7134055cfb49cf6e81f250ffd958d 100644 (file)
@@ -890,13 +890,13 @@ MagickExport Image *CloneImage(const Image *image,const unsigned long columns,
       return(clone_image);
     }
   scale=(MagickRealType) columns/(MagickRealType) image->columns;
-  clone_image->page.width=(unsigned long) (scale*image->page.width+0.5);
-  clone_image->page.x=(long) (scale*image->page.x+0.5);
-  clone_image->tile_offset.x=(long) (scale*image->tile_offset.x+0.5);
+  clone_image->page.width=(unsigned long) floor(scale*image->page.width+0.5);
+  clone_image->page.x=(long) ceil(scale*image->page.x-0.5);
+  clone_image->tile_offset.x=(long) ceil(scale*image->tile_offset.x-0.5);
   scale=(MagickRealType) rows/(MagickRealType) image->rows;
-  clone_image->page.height=(unsigned long) (scale*image->page.height+0.5);
-  clone_image->page.y=(long) (image->page.y*scale+0.5);
-  clone_image->tile_offset.y=(long) (scale*image->tile_offset.y+0.5);
+  clone_image->page.height=(unsigned long) floor(scale*image->page.height+0.5);
+  clone_image->page.y=(long) ceil(image->page.y*scale-0.5);
+  clone_image->tile_offset.y=(long) ceil(scale*image->tile_offset.y-0.5);
   clone_image->columns=columns;
   clone_image->rows=rows;
   clone_image->cache=ClonePixelCache(image->cache);
@@ -4015,19 +4015,19 @@ MagickExport MagickBooleanType SyncImageSettings(const ImageInfo *image_info,
       flags=ParseGeometry(option,&geometry_info);
       if ((flags & GreaterValue) != 0)
         {
-          if (image->delay > (unsigned long) (geometry_info.rho+0.5))
-            image->delay=(unsigned long) (geometry_info.rho+0.5);
+          if (image->delay > (unsigned long) floor(geometry_info.rho+0.5))
+            image->delay=(unsigned long) floor(geometry_info.rho+0.5);
         }
       else
         if ((flags & LessValue) != 0)
           {
-            if (image->delay < (unsigned long) (geometry_info.rho+0.5))
-              image->ticks_per_second=(long) (geometry_info.sigma+0.5);
+            if (image->delay < (unsigned long) floor(geometry_info.rho+0.5))
+              image->ticks_per_second=(long) floor(geometry_info.sigma+0.5);
           }
         else
-          image->delay=(unsigned long) (geometry_info.rho+0.5);
+          image->delay=(unsigned long) floor(geometry_info.rho+0.5);
       if ((flags & SigmaValue) != 0)
-        image->ticks_per_second=(long) (geometry_info.sigma+0.5);
+        image->ticks_per_second=(long) floor(geometry_info.sigma+0.5);
     }
   option=GetImageOption(image_info,"density");
   if (option != (const char *) NULL)
index acbd1926ecb1d9557ef83615b87d444f6804627f..cc0e247aac476fe22b6769e93d841ca9c3870947 100644 (file)
@@ -3327,19 +3327,19 @@ MagickExport MagickBooleanType SetImageProperty(Image *image,
           flags=ParseGeometry(value,&geometry_info);
           if ((flags & GreaterValue) != 0)
             {
-              if (image->delay > (unsigned long) (geometry_info.rho+0.5))
-                image->delay=(unsigned long) (geometry_info.rho+0.5);
+              if (image->delay > (unsigned long) floor(geometry_info.rho+0.5))
+                image->delay=(unsigned long) floor(geometry_info.rho+0.5);
             }
           else
             if ((flags & LessValue) != 0)
               {
-                if (image->delay < (unsigned long) (geometry_info.rho+0.5))
-                  image->ticks_per_second=(long) (geometry_info.sigma+0.5);
+                if (image->delay < (unsigned long) floor(geometry_info.rho+0.5))
+                  image->ticks_per_second=(long) floor(geometry_info.sigma+0.5);
               }
             else
-              image->delay=(unsigned long) (geometry_info.rho+0.5);
+              image->delay=(unsigned long) floor(geometry_info.rho+0.5);
           if ((flags & SigmaValue) != 0)
-            image->ticks_per_second=(long) (geometry_info.sigma+0.5);
+            image->ticks_per_second=(long) floor(geometry_info.sigma+0.5);
           break;
         }
       if (LocaleCompare(property,"depth") == 0)
index 49290b8af871b5dd12550cbdfd5edcff160170fd..77128a899a3523efe5adbd39e7bc00946fcf197b 100644 (file)
@@ -1811,8 +1811,8 @@ static MagickBooleanType HorizontalFilter(const ResizeFilter *resize_filter,
     if (status == MagickFalse)
       continue;
     center=(MagickRealType) (x+0.5)/x_factor;
-    start=(long) (MagickMax(center-support-MagickEpsilon,0.0)+0.5);
-    stop=(long) (MagickMin(center+support,(double) image->columns)+0.5);
+    start=(long) ceil(MagickMax(center-support-MagickEpsilon,0.0)-0.5);
+    stop=(long) floor(MagickMin(center+support,(double) image->columns)+0.5);
     density=0.0;
     contribution=contributions[GetOpenMPThreadId()];
     for (n=0; n < (stop-start); n++)
@@ -2052,9 +2052,9 @@ static MagickBooleanType VerticalFilter(const ResizeFilter *resize_filter,
 
     if (status == MagickFalse)
       continue;
-    center=(MagickRealType) (y+0.5)/y_factor;
-    start=(long) (MagickMax(center-support-MagickEpsilon,0.0)+0.5);
-    stop=(long) (MagickMin(center+support,(double) image->rows)+0.5);
+    center=(MagickRealType) (y-0.5)/y_factor;
+    start=(long) ceil(MagickMax(center-support-MagickEpsilon,0.0)-0.5);
+    stop=(long) floor(MagickMin(center+support,(double) image->rows)+0.5);
     density=0.0;
     contribution=contributions[GetOpenMPThreadId()];
     for (n=0; n < (stop-start); n++)
@@ -2417,7 +2417,8 @@ MagickExport Image *SampleImage(const Image *image,const unsigned long columns,
 
     if (status == MagickFalse)
       continue;
-    y_offset=(long) (((MagickRealType) y+0.5)*image->rows/sample_image->rows);
+    y_offset=(long) ceil(((MagickRealType) y-0.5)*image->rows/
+      sample_image->rows);
     p=GetCacheViewVirtualPixels(image_view,0,y_offset,image->columns,1,
       exception);
     q=QueueCacheViewAuthenticPixels(sample_view,0,y,sample_image->columns,1,
index f764b2fa4f46c9fc2a12763500f3f365e6385ff4..a163a0db45b0b773aa27f35e11481256455a310e 100644 (file)
@@ -218,10 +218,10 @@ static MagickBooleanType CropToFitImage(Image **image,
     if (max.y < extent[i].y)
       max.y=extent[i].y;
   }
-  geometry.x=(long) (min.x+0.5);
-  geometry.y=(long) (min.y+0.5);
-  geometry.width=(unsigned long) ((long) (max.x+0.5)-(long) (min.x+0.5));
-  geometry.height=(unsigned long) ((long) (max.y+0.5)-(long) (min.y+0.5));
+  geometry.x=(long) ceil(min.x-0.5);
+  geometry.y=(long) ceil(min.y-0.5);
+  geometry.width=(unsigned long) floor(max.x-min.x+0.5);
+  geometry.height=(unsigned long) floor(max.y-min.y+0.5);
   page=(*image)->page;
   (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page);
   crop_image=CropImage(*image,&geometry,exception);
@@ -1932,9 +1932,9 @@ MagickExport Image *RotateImage(const Image *image,const double degrees,
       width=image->rows;
       height=image->columns;
     }
-  y_width=width+(long) (fabs(shear.x)*height+0.5);
-  x_offset=(long) (width+((fabs(shear.y)*height)-width)/2.0+0.5);
-  y_offset=(long) (height+((fabs(shear.y)*y_width)-height)/2.0+0.5);
+  y_width=width+(long) floor(fabs(shear.x)*height+0.5);
+  x_offset=(long) ceil(width+((fabs(shear.y)*height)-width)/2.0-0.5);
+  y_offset=(long) ceil(height+((fabs(shear.y)*y_width)-height)/2.0-0.5);
   /*
     Surround image with a border.
   */
@@ -2076,10 +2076,11 @@ MagickExport Image *ShearImage(const Image *image,const double x_shear,
   /*
     Compute image size.
   */
-  y_width=image->columns+(long) (fabs(shear.x)*image->rows+0.5);
-  x_offset=(long) (image->columns+((fabs(shear.x)*image->rows)-image->columns)/
-    2.0+0.5);
-  y_offset=(long) (image->rows+((fabs(shear.y)*y_width)-image->rows)/2.0+0.5);
+  y_width=image->columns+(long) floor(fabs(shear.x)*image->rows+0.5);
+  x_offset=(long) ceil(image->columns+((fabs(shear.x)*image->rows)-
+    image->columns)/2.0-0.5);
+  y_offset=(long) ceil(image->rows+((fabs(shear.y)*y_width)-image->rows)/2.0-
+    0.5);
   /*
     Surround image with border.
   */
index 72c493f52835c356ef9d9e69afa2f619a406eb53..86bd279a1bfd5334c6005918c18d2445b1b9493c 100644 (file)
@@ -957,8 +957,8 @@ MagickExport MagickBooleanType GetImageChannelExtrema(const Image *image,
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
   status=GetImageChannelRange(image,channel,&min,&max,exception);
-  *minima=(unsigned long) (min+0.5);
-  *maxima=(unsigned long) (max+0.5);
+  *minima=(unsigned long) ceil(min-0.5);
+  *maxima=(unsigned long) floor(max+0.5);
   return(status);
 }
 \f
index 2bbddb13784bd452879e463b24350b84b64392ea..020e8f75d2ea73fe717f754302d1ce75f5888348 100644 (file)
@@ -4175,8 +4175,8 @@ WandExport MagickBooleanType DrawPushPattern(DrawingWand *wand,
   wand->pattern_id=AcquireString(pattern_id);
   wand->pattern_bounds.x=(long) ceil(x-0.5);
   wand->pattern_bounds.y=(long) ceil(y-0.5);
-  wand->pattern_bounds.width=(unsigned long) (width+0.5);
-  wand->pattern_bounds.height=(unsigned long) (height+0.5);
+  wand->pattern_bounds.width=(unsigned long) floor(width+0.5);
+  wand->pattern_bounds.height=(unsigned long) floor(height+0.5);
   wand->pattern_offset=wand->mvg_length;
   return(MagickTrue);
 }
index 9bf316d3d381e004fea2479afa0c4e73cfa6b109..2275532f18e8548eab4a925845cc4f0ef0e3f5f0 100644 (file)
@@ -2993,8 +2993,8 @@ WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
             if ((flags & PsiValue) == 0)
               geometry_info.psi=4.0;
             shadow_image=ShadowImage(*image,geometry_info.rho,
-              geometry_info.sigma,(long) (geometry_info.xi+0.5),(long)
-              (geometry_info.psi+0.5),exception);
+              geometry_info.sigma,(long) floor(geometry_info.xi+0.5),(long)
+              floor(geometry_info.psi+0.5),exception);
             if (shadow_image == (Image *) NULL)
               break;
             *image=DestroyImage(*image);
@@ -3499,8 +3499,8 @@ WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
             if ((flags & PsiValue) == 0)
               geometry_info.psi=0.1*(*image)->rows;
             vignette_image=VignetteImage(*image,geometry_info.rho,
-              geometry_info.sigma,(long) (geometry_info.xi+0.5),(long)
-              (geometry_info.psi+0.5),exception);
+              geometry_info.sigma,(long) floor(geometry_info.xi+0.5),(long)
+              floor(geometry_info.psi+0.5),exception);
             if (vignette_image == (Image *) NULL)
               break;
             *image=DestroyImage(*image);
@@ -8374,6 +8374,9 @@ WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info,
       {
         if (LocaleCompare("write",option+1) == 0)
           {
+            char 
+              key[MaxTextExtent];
+
             Image
               *write_images;
 
@@ -8381,6 +8384,8 @@ WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info,
               *write_info;
 
             (void) SyncImagesSettings(image_info,*images);
+            (void) FormatMagickString(key,MaxTextExtent,"cache:%s",argv[i+1]);
+            (void) DeleteImageRegistry(key);
             write_images=(*images);
             if (*option == '+')
               write_images=CloneImageList(*images,exception);