case double to long
diff --git a/MagickCore/annotate.c b/MagickCore/annotate.c
index 37bd037..71c2558 100644
--- a/MagickCore/annotate.c
+++ b/MagickCore/annotate.c
@@ -1722,8 +1722,8 @@
 
           if (status == MagickFalse)
             continue;
-          x_offset=MagickDoubleToLong(ceil(point.x-0.5));
-          y_offset=MagickDoubleToLong(ceil(point.y+y-0.5));
+          x_offset=CastDoubleToLong(ceil(point.x-0.5));
+          y_offset=CastDoubleToLong(ceil(point.y+y-0.5));
           if ((y_offset < 0) || (y_offset >= (ssize_t) image->rows))
             continue;
           q=(Quantum *) NULL;
@@ -1738,7 +1738,7 @@
           n=y*bitmap->bitmap.pitch;
           for (x=0; x < (ssize_t) bitmap->bitmap.width; x++, n++)
           {
-            x_offset=MagickDoubleToLong(ceil(point.x+x-0.5));
+            x_offset=CastDoubleToLong(ceil(point.x+x-0.5));
             if ((x_offset < 0) || (x_offset >= (ssize_t) image->columns))
               {
                 if (q != (Quantum *) NULL)
@@ -2090,7 +2090,7 @@
       crop_info=GetImageBoundingBox(annotate_image,exception);
       crop_info.height=(size_t) ((resolution.y/DefaultResolution)*
         ExpandAffine(&draw_info->affine)*draw_info->pointsize+0.5);
-      crop_info.y=MagickDoubleToLong(ceil((resolution.y/DefaultResolution)*
+      crop_info.y=CastDoubleToLong(ceil((resolution.y/DefaultResolution)*
         extent.y/8.0-0.5));
       (void) FormatLocaleString(geometry,MagickPathExtent,
         "%.20gx%.20g%+.20g%+.20g",(double) crop_info.width,(double)
diff --git a/MagickCore/constitute.c b/MagickCore/constitute.c
index 13a089f..255681b 100644
--- a/MagickCore/constitute.c
+++ b/MagickCore/constitute.c
@@ -834,13 +834,13 @@
           if ((flags & LessValue) != 0)
             {
               if (next->delay < (size_t) floor(geometry_info.rho+0.5))
-                next->ticks_per_second=MagickDoubleToLong(floor(
+                next->ticks_per_second=CastDoubleToLong(floor(
                   geometry_info.sigma+0.5));
             }
           else
             next->delay=(size_t) floor(geometry_info.rho+0.5);
         if ((flags & SigmaValue) != 0)
-          next->ticks_per_second=MagickDoubleToLong(floor(
+          next->ticks_per_second=CastDoubleToLong(floor(
             geometry_info.sigma+0.5));
       }
     option=GetImageOption(image_info,"dispose");
diff --git a/MagickCore/draw.c b/MagickCore/draw.c
index 79eb35e..346a27f 100644
--- a/MagickCore/draw.c
+++ b/MagickCore/draw.c
@@ -1233,8 +1233,8 @@
   edge.y2=MagickMin(max.y,(double) image->rows-1.0);
   inverse_affine=InverseAffineMatrix(affine);
   GetPixelInfo(image,&zero);
-  start=MagickDoubleToLong(ceil(edge.y1-0.5));
-  stop=MagickDoubleToLong(floor(edge.y2+0.5));
+  start=CastDoubleToLong(ceil(edge.y1-0.5));
+  stop=CastDoubleToLong(floor(edge.y2+0.5));
   source_view=AcquireVirtualCacheView(source,exception);
   image_view=AcquireAuthenticCacheView(image,exception);
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
@@ -1267,16 +1267,16 @@
     inverse_edge=AffineEdge(source,&inverse_affine,(double) y,&edge);
     if (inverse_edge.x2 < inverse_edge.x1)
       continue;
-    q=GetCacheViewAuthenticPixels(image_view,MagickDoubleToLong(
-      ceil(inverse_edge.x1-0.5)),y,(size_t) MagickDoubleToLong(floor(
+    q=GetCacheViewAuthenticPixels(image_view,CastDoubleToLong(
+      ceil(inverse_edge.x1-0.5)),y,(size_t) CastDoubleToLong(floor(
       inverse_edge.x2+0.5)-ceil(inverse_edge.x1-0.5)+1),1,exception);
     if (q == (Quantum *) NULL)
       continue;
     pixel=zero;
     composite=zero;
     x_offset=0;
-    for (x=MagickDoubleToLong(ceil(inverse_edge.x1-0.5));
-         x <= MagickDoubleToLong(floor(inverse_edge.x2+0.5)); x++)
+    for (x=CastDoubleToLong(ceil(inverse_edge.x1-0.5));
+         x <= CastDoubleToLong(floor(inverse_edge.x2+0.5)); x++)
     {
       point.x=(double) x*inverse_affine.sx+y*inverse_affine.ry+
         inverse_affine.tx;
@@ -2090,8 +2090,8 @@
         case UndefinedSpread:
         case PadSpread:
         {
-          if ((x != MagickDoubleToLong(ceil(gradient_vector->x1-0.5))) ||
-              (y != MagickDoubleToLong(ceil(gradient_vector->y1-0.5))))
+          if ((x != CastDoubleToLong(ceil(gradient_vector->x1-0.5))) ||
+              (y != CastDoubleToLong(ceil(gradient_vector->y1-0.5))))
             {
               offset=GetStopColorOffset(gradient,x,y);
               if (gradient->type != RadialGradient)
@@ -2118,8 +2118,8 @@
         }
         case ReflectSpread:
         {
-          if ((x != MagickDoubleToLong(ceil(gradient_vector->x1-0.5))) ||
-              (y != MagickDoubleToLong(ceil(gradient_vector->y1-0.5))))
+          if ((x != CastDoubleToLong(ceil(gradient_vector->x1-0.5))) ||
+              (y != CastDoubleToLong(ceil(gradient_vector->y1-0.5))))
             {
               offset=GetStopColorOffset(gradient,x,y);
               if (gradient->type != RadialGradient)
@@ -2160,8 +2160,8 @@
 
           antialias=MagickFalse;
           repeat=0.0;
-          if ((x != MagickDoubleToLong(ceil(gradient_vector->x1-0.5))) ||
-              (y != MagickDoubleToLong(ceil(gradient_vector->y1-0.5))))
+          if ((x != CastDoubleToLong(ceil(gradient_vector->x1-0.5))) ||
+              (y != CastDoubleToLong(ceil(gradient_vector->y1-0.5))))
             {
               offset=GetStopColorOffset(gradient,x,y);
               if (gradient->type == LinearGradient)
@@ -3456,21 +3456,21 @@
                 (void) GetNextToken(q,&q,extent,token);
                 (void) CopyMagickString(name,token,MagickPathExtent);
                 (void) GetNextToken(q,&q,extent,token);
-                bounds.x=MagickDoubleToLong(ceil(GetDrawValue(token,
+                bounds.x=CastDoubleToLong(ceil(GetDrawValue(token,
                   &next_token)-0.5));
                 if (token == next_token)
                   ThrowPointExpectedException(token,exception);
                 (void) GetNextToken(q,&q,extent,token);
                 if (*token == ',')
                   (void) GetNextToken(q,&q,extent,token);
-                bounds.y=MagickDoubleToLong(ceil(GetDrawValue(token,
+                bounds.y=CastDoubleToLong(ceil(GetDrawValue(token,
                   &next_token)-0.5));
                 if (token == next_token)
                   ThrowPointExpectedException(token,exception);
                 (void) GetNextToken(q,&q,extent,token);
                 if (*token == ',')
                   (void) GetNextToken(q,&q,extent,token);
-                bounds.width=(size_t) MagickDoubleToLong(floor(GetDrawValue(
+                bounds.width=(size_t) CastDoubleToLong(floor(GetDrawValue(
                   token,&next_token)+0.5));
                 if (token == next_token)
                   ThrowPointExpectedException(token,exception);
@@ -3881,28 +3881,28 @@
         if (LocaleCompare("viewbox",keyword) == 0)
           {
             (void) GetNextToken(q,&q,extent,token);
-            graphic_context[n]->viewbox.x=MagickDoubleToLong(ceil(
+            graphic_context[n]->viewbox.x=CastDoubleToLong(ceil(
               GetDrawValue(token,&next_token)-0.5));
             if (token == next_token)
               ThrowPointExpectedException(token,exception);
             (void) GetNextToken(q,&q,extent,token);
             if (*token == ',')
               (void) GetNextToken(q,&q,extent,token);
-            graphic_context[n]->viewbox.y=MagickDoubleToLong(ceil(
+            graphic_context[n]->viewbox.y=CastDoubleToLong(ceil(
               GetDrawValue(token,&next_token)-0.5));
             if (token == next_token)
               ThrowPointExpectedException(token,exception);
             (void) GetNextToken(q,&q,extent,token);
             if (*token == ',')
               (void) GetNextToken(q,&q,extent,token);
-            graphic_context[n]->viewbox.width=(size_t) MagickDoubleToLong(
+            graphic_context[n]->viewbox.width=(size_t) CastDoubleToLong(
               floor(GetDrawValue(token,&next_token)+0.5));
             if (token == next_token)
               ThrowPointExpectedException(token,exception);
             (void) GetNextToken(q,&q,extent,token);
             if (*token == ',')
               (void) GetNextToken(q,&q,extent,token);
-            graphic_context[n]->viewbox.height=(size_t) MagickDoubleToLong(
+            graphic_context[n]->viewbox.height=(size_t) CastDoubleToLong(
               floor(GetDrawValue(token,&next_token)+0.5));
             if (token == next_token)
               ThrowPointExpectedException(token,exception);
@@ -4984,8 +4984,8 @@
       /*
         Draw point.
       */
-      start_y=MagickDoubleToLong(ceil(bounds.y1-0.5));
-      stop_y=MagickDoubleToLong(floor(bounds.y2+0.5));
+      start_y=CastDoubleToLong(ceil(bounds.y1-0.5));
+      stop_y=CastDoubleToLong(floor(bounds.y2+0.5));
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
       #pragma omp parallel for schedule(static) shared(status) \
         magick_number_threads(image,image,stop_y-start_y+1,1)
@@ -5010,8 +5010,8 @@
 
         if (status == MagickFalse)
           continue;
-        start_x=MagickDoubleToLong(ceil(bounds.x1-0.5));
-        stop_x=MagickDoubleToLong(floor(bounds.x2+0.5));
+        start_x=CastDoubleToLong(ceil(bounds.x1-0.5));
+        stop_x=CastDoubleToLong(floor(bounds.x2+0.5));
         x=start_x;
         q=GetCacheViewAuthenticPixels(image_view,x,y,(size_t) (stop_x-x+1),1,
           exception);
@@ -5023,8 +5023,8 @@
         GetPixelInfo(image,&pixel);
         for ( ; x <= stop_x; x++)
         {
-          if ((x == MagickDoubleToLong(ceil(primitive_info->point.x-0.5))) &&
-              (y == MagickDoubleToLong(ceil(primitive_info->point.y-0.5))))
+          if ((x == CastDoubleToLong(ceil(primitive_info->point.x-0.5))) &&
+              (y == CastDoubleToLong(ceil(primitive_info->point.y-0.5))))
             {
               GetFillColor(draw_info,x-start_x,y-start_y,&pixel,exception);
               SetPixelViaPixelInfo(image,&pixel,q);
@@ -5045,8 +5045,8 @@
   /*
     Draw polygon or line.
   */
-  start_y=MagickDoubleToLong(ceil(bounds.y1-0.5));
-  stop_y=MagickDoubleToLong(floor(bounds.y2+0.5));
+  start_y=CastDoubleToLong(ceil(bounds.y1-0.5));
+  stop_y=CastDoubleToLong(floor(bounds.y2+0.5));
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(static) shared(status) \
     magick_number_threads(image,image,stop_y-start_y+1,1)
@@ -5068,8 +5068,8 @@
 
     if (status == MagickFalse)
       continue;
-    start_x=MagickDoubleToLong(ceil(bounds.x1-0.5));
-    stop_x=MagickDoubleToLong(floor(bounds.x2+0.5));
+    start_x=CastDoubleToLong(ceil(bounds.x1-0.5));
+    stop_x=CastDoubleToLong(floor(bounds.x2+0.5));
     q=GetCacheViewAuthenticPixels(image_view,start_x,y,(size_t) (stop_x-start_x+
       1),1,exception);
     if (q == (Quantum *) NULL)
@@ -5170,8 +5170,8 @@
     coordinates,
     y;
 
-  x=MagickDoubleToLong(ceil(primitive_info->point.x-0.5));
-  y=MagickDoubleToLong(ceil(primitive_info->point.y-0.5));
+  x=CastDoubleToLong(ceil(primitive_info->point.x-0.5));
+  y=CastDoubleToLong(ceil(primitive_info->point.y-0.5));
   switch (primitive_info->primitive)
   {
     case AlphaPrimitive:
@@ -5284,8 +5284,8 @@
       status&=SetImageMask(image,CompositePixelMask,draw_info->composite_mask,
         exception);
     }
-  x=MagickDoubleToLong(ceil(primitive_info->point.x-0.5));
-  y=MagickDoubleToLong(ceil(primitive_info->point.y-0.5));
+  x=CastDoubleToLong(ceil(primitive_info->point.x-0.5));
+  y=CastDoubleToLong(ceil(primitive_info->point.y-0.5));
   image_view=AcquireAuthenticCacheView(image,exception);
   switch (primitive_info->primitive)
   {
@@ -5563,8 +5563,8 @@
       composite_images=DestroyImageList(composite_images);
       (void) SetImageProgressMonitor(composite_image,(MagickProgressMonitor)
         NULL,(void *) NULL);
-      x1=MagickDoubleToLong(ceil(primitive_info[1].point.x-0.5));
-      y1=MagickDoubleToLong(ceil(primitive_info[1].point.y-0.5));
+      x1=CastDoubleToLong(ceil(primitive_info[1].point.x-0.5));
+      y1=CastDoubleToLong(ceil(primitive_info[1].point.y-0.5));
       if (((x1 != 0L) && (x1 != (ssize_t) composite_image->columns)) ||
           ((y1 != 0L) && (y1 != (ssize_t) composite_image->rows)))
         {
@@ -6173,7 +6173,7 @@
   else
     if ((theta > 0.0) && (sweep == MagickFalse))
       theta-=2.0*MagickPI;
-  arc_segments=(size_t) MagickDoubleToLong(ceil(fabs((double) (theta/(0.5*
+  arc_segments=(size_t) CastDoubleToLong(ceil(fabs((double) (theta/(0.5*
     MagickPI+MagickEpsilon)))));
   status=MagickTrue;
   p=primitive_info;
@@ -7529,7 +7529,7 @@
           theta.q=atan2(box_q[2].y-center.y,box_q[2].x-center.x);
           if (theta.q < theta.p)
             theta.q+=2.0*MagickPI;
-          arc_segments=(size_t) MagickDoubleToLong(ceil((double) ((theta.
+          arc_segments=(size_t) CastDoubleToLong(ceil((double) ((theta.
             q-theta.p)/(2.0*sqrt((double) (1.0/mid))))));
           CheckPathExtent(MaxStrokePad,arc_segments+MaxStrokePad);
           stroke_q[q].x=box_q[1].x;
@@ -7602,7 +7602,7 @@
           theta.q=atan2(box_p[2].y-center.y,box_p[2].x-center.x);
           if (theta.p < theta.q)
             theta.p+=2.0*MagickPI;
-          arc_segments=(size_t) MagickDoubleToLong(ceil((double) ((theta.p-
+          arc_segments=(size_t) CastDoubleToLong(ceil((double) ((theta.p-
             theta.q)/(2.0*sqrt((double) (1.0/mid))))));
           CheckPathExtent(arc_segments+MaxStrokePad,MaxStrokePad);
           stroke_p[p++]=box_p[1];
diff --git a/MagickCore/effect.c b/MagickCore/effect.c
index 6b6621c..c95fd01 100644
--- a/MagickCore/effect.c
+++ b/MagickCore/effect.c
@@ -288,7 +288,7 @@
         center,
         j;
 
-      j=MagickDoubleToLong(ceil((double) width*(1.0-QuantumScale*
+      j=CastDoubleToLong(ceil((double) width*(1.0-QuantumScale*
         GetPixelIntensity(edge_image,r))-0.5));
       if (j < 0)
         j=0;
@@ -609,7 +609,7 @@
         center,
         j;
 
-      j=MagickDoubleToLong(ceil((double) width*(1.0-QuantumScale*
+      j=CastDoubleToLong(ceil((double) width*(1.0-QuantumScale*
         GetPixelIntensity(edge_image,r))-0.5));
       if (j < 0)
         j=0;
@@ -2402,9 +2402,9 @@
   point.y=(double) width*cos(DegreesToRadians(angle));
   for (i=0; i < (ssize_t) width; i++)
   {
-    offset[i].x=MagickDoubleToLong(ceil((double) (i*point.y)/
+    offset[i].x=CastDoubleToLong(ceil((double) (i*point.y)/
       hypot(point.x,point.y)-0.5));
-    offset[i].y=MagickDoubleToLong(ceil((double) (i*point.x)/
+    offset[i].y=CastDoubleToLong(ceil((double) (i*point.x)/
       hypot(point.x,point.y)-0.5));
   }
   /*
diff --git a/MagickCore/gem.c b/MagickCore/gem.c
index a986276..f37990c 100644
--- a/MagickCore/gem.c
+++ b/MagickCore/gem.c
@@ -692,7 +692,7 @@
       *blue=QuantumRange*v;
       return;
     }
-  i=MagickDoubleToLong(floor(6.0*hue));
+  i=CastDoubleToLong(floor(6.0*hue));
   f=6.0*hue-i;
   if ((i & 0x01) != 0)
     f=1.0-f;
diff --git a/MagickCore/image-private.h b/MagickCore/image-private.h
index 935eed5..43e4971 100644
--- a/MagickCore/image-private.h
+++ b/MagickCore/image-private.h
@@ -55,7 +55,7 @@
   return((double) (MagickPI*degrees/180.0));
 }
 
-static inline ssize_t MagickDoubleToLong(const double value)
+static inline ssize_t CastDoubleToLong(const double value)
 {
   if (IsNaN(value) != 0)
     return(0);
diff --git a/MagickCore/image.c b/MagickCore/image.c
index e0919c0..3f6925f 100644
--- a/MagickCore/image.c
+++ b/MagickCore/image.c
@@ -282,21 +282,21 @@
       if ((flags & GreaterValue) != 0)
         {
           if ((double) image->delay > floor(geometry_info.rho+0.5))
-            image->delay=(size_t) MagickDoubleToLong(floor(
+            image->delay=(size_t) CastDoubleToLong(floor(
               geometry_info.rho+0.5));
         }
       else
         if ((flags & LessValue) != 0)
           {
             if ((double) image->delay < floor(geometry_info.rho+0.5))
-              image->ticks_per_second=MagickDoubleToLong(floor(
+              image->ticks_per_second=CastDoubleToLong(floor(
                 geometry_info.sigma+0.5));
           }
         else
-          image->delay=(size_t) MagickDoubleToLong(floor(
+          image->delay=(size_t) CastDoubleToLong(floor(
             geometry_info.rho+0.5));
       if ((flags & SigmaValue) != 0)
-        image->ticks_per_second=MagickDoubleToLong(floor(
+        image->ticks_per_second=CastDoubleToLong(floor(
           geometry_info.sigma+0.5));
     }
   option=GetImageOption(image_info,"dispose");
@@ -881,18 +881,18 @@
   scale=1.0;
   if (image->columns != 0)
     scale=(double) columns/(double) image->columns;
-  clone_image->page.width=(size_t) MagickDoubleToLong(floor(scale*
+  clone_image->page.width=(size_t) CastDoubleToLong(floor(scale*
     image->page.width+0.5));
-  clone_image->page.x=MagickDoubleToLong(ceil(scale*image->page.x-0.5));
-  clone_image->tile_offset.x=MagickDoubleToLong(ceil(scale*
+  clone_image->page.x=CastDoubleToLong(ceil(scale*image->page.x-0.5));
+  clone_image->tile_offset.x=CastDoubleToLong(ceil(scale*
     image->tile_offset.x-0.5));
   scale=1.0;
   if (image->rows != 0)
     scale=(double) rows/(double) image->rows;
-  clone_image->page.height=(size_t) MagickDoubleToLong(floor(scale*
+  clone_image->page.height=(size_t) CastDoubleToLong(floor(scale*
     image->page.height+0.5));
-  clone_image->page.y=MagickDoubleToLong(ceil(scale*image->page.y-0.5));
-  clone_image->tile_offset.y=MagickDoubleToLong(ceil(scale*
+  clone_image->page.y=CastDoubleToLong(ceil(scale*image->page.y-0.5));
+  clone_image->tile_offset.y=CastDoubleToLong(ceil(scale*
     image->tile_offset.y-0.5));
   clone_image->cache=ClonePixelCache(image->cache);
   if (SetImageExtent(clone_image,columns,rows,exception) == MagickFalse)
diff --git a/MagickCore/pixel.c b/MagickCore/pixel.c
index 5e345ee..85bf51e 100644
--- a/MagickCore/pixel.c
+++ b/MagickCore/pixel.c
@@ -4524,8 +4524,8 @@
   status=MagickTrue;
   *pixel=0.0;
   traits=GetPixelChannelTraits(image,channel);
-  x_offset=MagickDoubleToLong(floor(ConstrainPixelOffset(x)));
-  y_offset=MagickDoubleToLong(floor(ConstrainPixelOffset(y)));
+  x_offset=CastDoubleToLong(floor(ConstrainPixelOffset(x)));
+  y_offset=CastDoubleToLong(floor(ConstrainPixelOffset(y)));
   interpolate=method;
   if (interpolate == UndefinedInterpolatePixel)
     interpolate=image->interpolate;
@@ -4542,8 +4542,8 @@
       if (interpolate == Average9InterpolatePixel)
         {
           count=3;
-          x_offset=MagickDoubleToLong(floor(ConstrainPixelOffset(x)+0.5)-1.0);
-          y_offset=MagickDoubleToLong(floor(ConstrainPixelOffset(y)+0.5)-1.0);
+          x_offset=CastDoubleToLong(floor(ConstrainPixelOffset(x)+0.5)-1.0);
+          y_offset=CastDoubleToLong(floor(ConstrainPixelOffset(y)+0.5)-1.0);
         }
       else
         if (interpolate == Average16InterpolatePixel)
@@ -4726,8 +4726,8 @@
     }
     case NearestInterpolatePixel:
     {
-      x_offset=MagickDoubleToLong(floor(ConstrainPixelOffset(x)+0.5));
-      y_offset=MagickDoubleToLong(floor(ConstrainPixelOffset(y)+0.5));
+      x_offset=CastDoubleToLong(floor(ConstrainPixelOffset(x)+0.5));
+      y_offset=CastDoubleToLong(floor(ConstrainPixelOffset(y)+0.5));
       p=GetCacheViewVirtualPixels(image_view,x_offset,y_offset,1,1,exception);
       if (p == (const Quantum *) NULL)
         {
@@ -4944,8 +4944,8 @@
   assert(source->signature == MagickCoreSignature);
   assert(source_view != (CacheView *) NULL);
   status=MagickTrue;
-  x_offset=MagickDoubleToLong(floor(ConstrainPixelOffset(x)));
-  y_offset=MagickDoubleToLong(floor(ConstrainPixelOffset(y)));
+  x_offset=CastDoubleToLong(floor(ConstrainPixelOffset(x)));
+  y_offset=CastDoubleToLong(floor(ConstrainPixelOffset(y)));
   interpolate=method;
   if (interpolate == UndefinedInterpolatePixel)
     interpolate=source->interpolate;
@@ -4962,8 +4962,8 @@
       if (interpolate == Average9InterpolatePixel)
         {
           count=3;
-          x_offset=MagickDoubleToLong(floor(ConstrainPixelOffset(x)+0.5)-1.0);
-          y_offset=MagickDoubleToLong(floor(ConstrainPixelOffset(y)+0.5)-1.0);
+          x_offset=CastDoubleToLong(floor(ConstrainPixelOffset(x)+0.5)-1.0);
+          y_offset=CastDoubleToLong(floor(ConstrainPixelOffset(y)+0.5)-1.0);
         }
       else
         if (interpolate == Average16InterpolatePixel)
@@ -5227,8 +5227,8 @@
     }
     case NearestInterpolatePixel:
     {
-      x_offset=MagickDoubleToLong(floor(ConstrainPixelOffset(x)+0.5));
-      y_offset=MagickDoubleToLong(floor(ConstrainPixelOffset(y)+0.5));
+      x_offset=CastDoubleToLong(floor(ConstrainPixelOffset(x)+0.5));
+      y_offset=CastDoubleToLong(floor(ConstrainPixelOffset(y)+0.5));
       p=GetCacheViewVirtualPixels(source_view,x_offset,y_offset,1,1,exception);
       if (p == (const Quantum *) NULL)
         {
@@ -5511,8 +5511,8 @@
   assert(image->signature == MagickCoreSignature);
   assert(image_view != (CacheView *) NULL);
   status=MagickTrue;
-  x_offset=MagickDoubleToLong(floor(ConstrainPixelOffset(x)));
-  y_offset=MagickDoubleToLong(floor(ConstrainPixelOffset(y)));
+  x_offset=CastDoubleToLong(floor(ConstrainPixelOffset(x)));
+  y_offset=CastDoubleToLong(floor(ConstrainPixelOffset(y)));
   interpolate=method;
   if (interpolate == UndefinedInterpolatePixel)
     interpolate=image->interpolate;
@@ -5531,8 +5531,8 @@
       if (interpolate == Average9InterpolatePixel)
         {
           count=3;
-          x_offset=MagickDoubleToLong(floor(ConstrainPixelOffset(x)+0.5)-1.0);
-          y_offset=MagickDoubleToLong(floor(ConstrainPixelOffset(y)+0.5)-1.0);
+          x_offset=CastDoubleToLong(floor(ConstrainPixelOffset(x)+0.5)-1.0);
+          y_offset=CastDoubleToLong(floor(ConstrainPixelOffset(y)+0.5)-1.0);
         }
       else if (interpolate == Average16InterpolatePixel)
         {
@@ -5856,8 +5856,8 @@
     }
     case NearestInterpolatePixel:
     {
-      x_offset=MagickDoubleToLong(floor(ConstrainPixelOffset(x)+0.5));
-      y_offset=MagickDoubleToLong(floor(ConstrainPixelOffset(y)+0.5));
+      x_offset=CastDoubleToLong(floor(ConstrainPixelOffset(x)+0.5));
+      y_offset=CastDoubleToLong(floor(ConstrainPixelOffset(y)+0.5));
       p=GetCacheViewVirtualPixels(image_view,x_offset,y_offset,1,1,exception);
       if (p == (const Quantum *) NULL)
         {
diff --git a/MagickCore/property.c b/MagickCore/property.c
index c08106f..4116e9b 100644
--- a/MagickCore/property.c
+++ b/MagickCore/property.c
@@ -4355,13 +4355,13 @@
             if ((flags & LessValue) != 0)
               {
                 if ((double) image->delay < floor(geometry_info.rho+0.5))
-                  image->delay=MagickDoubleToLong(
+                  image->delay=CastDoubleToLong(
                     floor(geometry_info.sigma+0.5));
               }
             else
               image->delay=(size_t) floor(geometry_info.rho+0.5);
           if ((flags & SigmaValue) != 0)
-            image->ticks_per_second=MagickDoubleToLong(floor(
+            image->ticks_per_second=CastDoubleToLong(floor(
               geometry_info.sigma+0.5));
           return(MagickTrue);
         }
diff --git a/MagickCore/shear.c b/MagickCore/shear.c
index 6552070..b5520b0 100644
--- a/MagickCore/shear.c
+++ b/MagickCore/shear.c
@@ -163,10 +163,10 @@
     if (max.y < extent[i].y)
       max.y=extent[i].y;
   }
-  geometry.x=MagickDoubleToLong(ceil(min.x-0.5));
-  geometry.y=MagickDoubleToLong(ceil(min.y-0.5));
-  geometry.width=(size_t) MagickDoubleToLong(floor(max.x-min.x+0.5));
-  geometry.height=(size_t) MagickDoubleToLong(floor(max.y-min.y+0.5));
+  geometry.x=CastDoubleToLong(ceil(min.x-0.5));
+  geometry.y=CastDoubleToLong(ceil(min.y-0.5));
+  geometry.width=(size_t) CastDoubleToLong(floor(max.x-min.x+0.5));
+  geometry.height=(size_t) CastDoubleToLong(floor(max.y-min.y+0.5));
   page=(*image)->page;
   (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page);
   crop_image=CropImage(*image,&geometry,exception);
@@ -1217,7 +1217,7 @@
         displacement*=(-1.0);
         direction=LEFT;
       }
-    step=MagickDoubleToLong(floor((double) displacement));
+    step=CastDoubleToLong(floor((double) displacement));
     area=(double) (displacement-step);
     step++;
     pixel=background;
@@ -1434,7 +1434,7 @@
         displacement*=(-1.0);
         direction=UP;
       }
-    step=MagickDoubleToLong(floor((double) displacement));
+    step=CastDoubleToLong(floor((double) displacement));
     area=(double) (displacement-step);
     step++;
     pixel=background;
@@ -1617,11 +1617,11 @@
   /*
     Compute image size.
   */
-  bounds.width=image->columns+MagickDoubleToLong(floor(fabs(shear.x)*
+  bounds.width=image->columns+CastDoubleToLong(floor(fabs(shear.x)*
     image->rows+0.5));
-  bounds.x=MagickDoubleToLong(ceil((double) image->columns+((fabs(shear.x)*
+  bounds.x=CastDoubleToLong(ceil((double) image->columns+((fabs(shear.x)*
     image->rows)-image->columns)/2.0-0.5));
-  bounds.y=MagickDoubleToLong(ceil((double) image->rows+((fabs(shear.y)*
+  bounds.y=CastDoubleToLong(ceil((double) image->rows+((fabs(shear.y)*
     bounds.width)-image->rows)/2.0-0.5));
   /*
     Surround image with border.
@@ -1770,9 +1770,9 @@
   bounds.height=(size_t) floor(fabs((double) bounds.width*shear.y)+height+0.5);
   shear_width=(size_t) floor(fabs((double) bounds.height*shear.x)+
     bounds.width+0.5);
-  bounds.x=MagickDoubleToLong(floor((double) ((shear_width > bounds.width) ?
+  bounds.x=CastDoubleToLong(floor((double) ((shear_width > bounds.width) ?
     width : bounds.width-shear_width+2)/2.0+0.5));
-  bounds.y=MagickDoubleToLong(floor(((double) bounds.height-height+2)/2.0+0.5));
+  bounds.y=CastDoubleToLong(floor(((double) bounds.height-height+2)/2.0+0.5));
   /*
     Surround image with a border.
   */
diff --git a/MagickCore/visual-effects.c b/MagickCore/visual-effects.c
index 517f24e..560beab 100644
--- a/MagickCore/visual-effects.c
+++ b/MagickCore/visual-effects.c
@@ -1437,8 +1437,8 @@
       */
       depth--;
       attenuate++;
-      x_mid=MagickDoubleToLong(ceil((segment->x1+segment->x2)/2-0.5));
-      y_mid=MagickDoubleToLong(ceil((segment->y1+segment->y2)/2-0.5));
+      x_mid=CastDoubleToLong(ceil((segment->x1+segment->x2)/2-0.5));
+      y_mid=CastDoubleToLong(ceil((segment->y1+segment->y2)/2-0.5));
       local_info=(*segment);
       local_info.x2=(double) x_mid;
       local_info.y2=(double) y_mid;
@@ -1461,8 +1461,8 @@
         &local_info,attenuate,depth,exception);
       return(status == 0 ? MagickFalse : MagickTrue);
     }
-  x_mid=MagickDoubleToLong(ceil((segment->x1+segment->x2)/2-0.5));
-  y_mid=MagickDoubleToLong(ceil((segment->y1+segment->y2)/2-0.5));
+  x_mid=CastDoubleToLong(ceil((segment->x1+segment->x2)/2-0.5));
+  y_mid=CastDoubleToLong(ceil((segment->y1+segment->y2)/2-0.5));
   if ((fabs(segment->x1-x_mid) < MagickEpsilon) &&
       (fabs(segment->x2-x_mid) < MagickEpsilon) &&
       (fabs(segment->y1-y_mid) < MagickEpsilon) &&
@@ -1479,10 +1479,10 @@
       /*
         Left pixel.
       */
-      x=MagickDoubleToLong(ceil(segment->x1-0.5));
-      u=GetCacheViewVirtualPixels(u_view,x,MagickDoubleToLong(ceil(
+      x=CastDoubleToLong(ceil(segment->x1-0.5));
+      u=GetCacheViewVirtualPixels(u_view,x,CastDoubleToLong(ceil(
         segment->y1-0.5)),1,1,exception);
-      v=GetCacheViewVirtualPixels(v_view,x,MagickDoubleToLong(ceil(
+      v=GetCacheViewVirtualPixels(v_view,x,CastDoubleToLong(ceil(
         segment->y2-0.5)),1,1,exception);
       q=QueueCacheViewAuthenticPixels(image_view,x,y_mid,1,1,exception);
       if ((u == (const Quantum *) NULL) || (v == (const Quantum *) NULL) ||
@@ -1502,10 +1502,10 @@
           /*
             Right pixel.
           */
-          x=MagickDoubleToLong(ceil(segment->x2-0.5));
-          u=GetCacheViewVirtualPixels(u_view,x,MagickDoubleToLong(ceil(
+          x=CastDoubleToLong(ceil(segment->x2-0.5));
+          u=GetCacheViewVirtualPixels(u_view,x,CastDoubleToLong(ceil(
             segment->y1-0.5)),1,1,exception);
-          v=GetCacheViewVirtualPixels(v_view,x,MagickDoubleToLong(ceil(
+          v=GetCacheViewVirtualPixels(v_view,x,CastDoubleToLong(ceil(
             segment->y2-0.5)),1,1,exception);
           q=QueueCacheViewAuthenticPixels(image_view,x,y_mid,1,1,exception);
           if ((u == (const Quantum *) NULL) || (v == (const Quantum *) NULL) ||
@@ -1531,10 +1531,10 @@
           /*
             Bottom pixel.
           */
-          y=MagickDoubleToLong(ceil(segment->y2-0.5));
-          u=GetCacheViewVirtualPixels(u_view,MagickDoubleToLong(ceil(
+          y=CastDoubleToLong(ceil(segment->y2-0.5));
+          u=GetCacheViewVirtualPixels(u_view,CastDoubleToLong(ceil(
             segment->x1-0.5)),y,1,1,exception);
-          v=GetCacheViewVirtualPixels(v_view,MagickDoubleToLong(ceil(
+          v=GetCacheViewVirtualPixels(v_view,CastDoubleToLong(ceil(
             segment->x2-0.5)),y,1,1,exception);
           q=QueueCacheViewAuthenticPixels(image_view,x_mid,y,1,1,exception);
           if ((u == (const Quantum *) NULL) || (v == (const Quantum *) NULL) ||
@@ -1555,10 +1555,10 @@
           /*
             Top pixel.
           */
-          y=MagickDoubleToLong(ceil(segment->y1-0.5));
-          u=GetCacheViewVirtualPixels(u_view,MagickDoubleToLong(ceil(
+          y=CastDoubleToLong(ceil(segment->y1-0.5));
+          u=GetCacheViewVirtualPixels(u_view,CastDoubleToLong(ceil(
             segment->x1-0.5)),y,1,1,exception);
-          v=GetCacheViewVirtualPixels(v_view,MagickDoubleToLong(ceil(
+          v=GetCacheViewVirtualPixels(v_view,CastDoubleToLong(ceil(
             segment->x2-0.5)),y,1,1,exception);
           q=QueueCacheViewAuthenticPixels(image_view,x_mid,y,1,1,exception);
           if ((u == (const Quantum *) NULL) || (v == (const Quantum *) NULL) ||
@@ -1581,11 +1581,11 @@
       /*
         Middle pixel.
       */
-      x=MagickDoubleToLong(ceil(segment->x1-0.5));
-      y=MagickDoubleToLong(ceil(segment->y1-0.5));
+      x=CastDoubleToLong(ceil(segment->x1-0.5));
+      y=CastDoubleToLong(ceil(segment->y1-0.5));
       u=GetCacheViewVirtualPixels(u_view,x,y,1,1,exception);
-      x=MagickDoubleToLong(ceil(segment->x2-0.5));
-      y=MagickDoubleToLong(ceil(segment->y2-0.5));
+      x=CastDoubleToLong(ceil(segment->x2-0.5));
+      y=CastDoubleToLong(ceil(segment->y2-0.5));
       v=GetCacheViewVirtualPixels(v_view,x,y,1,1,exception);
       q=QueueCacheViewAuthenticPixels(image_view,x_mid,y_mid,1,1,exception);
       if ((u == (const Quantum *) NULL) || (v == (const Quantum *) NULL) ||
diff --git a/MagickWand/drawing-wand.c b/MagickWand/drawing-wand.c
index 2ac2f25..3638cad 100644
--- a/MagickWand/drawing-wand.c
+++ b/MagickWand/drawing-wand.c
@@ -4285,10 +4285,10 @@
     x,y,width,height);
   wand->indent_depth++;
   wand->pattern_id=AcquireString(pattern_id);
-  wand->pattern_bounds.x=MagickDoubleToLong(ceil(x-0.5));
-  wand->pattern_bounds.y=MagickDoubleToLong(ceil(y-0.5));
-  wand->pattern_bounds.width=(size_t) MagickDoubleToLong(floor(width+0.5));
-  wand->pattern_bounds.height=(size_t) MagickDoubleToLong(floor(height+0.5));
+  wand->pattern_bounds.x=CastDoubleToLong(ceil(x-0.5));
+  wand->pattern_bounds.y=CastDoubleToLong(ceil(y-0.5));
+  wand->pattern_bounds.width=(size_t) CastDoubleToLong(floor(width+0.5));
+  wand->pattern_bounds.height=(size_t) CastDoubleToLong(floor(height+0.5));
   wand->pattern_offset=wand->mvg_length;
   return(MagickTrue);
 }
diff --git a/coders/histogram.c b/coders/histogram.c
index 7a158f3..bbbfc9c 100644
--- a/coders/histogram.c
+++ b/coders/histogram.c
@@ -295,7 +295,7 @@
       break;
     if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
       {
-        y=MagickDoubleToLong(ceil(histogram_image->rows-scale*
+        y=CastDoubleToLong(ceil(histogram_image->rows-scale*
           histogram[x].red-0.5));
         r=q+y*GetPixelChannels(histogram_image);
         for ( ; y < (ssize_t) histogram_image->rows; y++)
@@ -306,7 +306,7 @@
       }
     if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
       {
-        y=MagickDoubleToLong(ceil(histogram_image->rows-scale*
+        y=CastDoubleToLong(ceil(histogram_image->rows-scale*
           histogram[x].green-0.5));
         r=q+y*GetPixelChannels(histogram_image);
         for ( ; y < (ssize_t) histogram_image->rows; y++)
@@ -317,7 +317,7 @@
       }
     if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
       {
-        y=MagickDoubleToLong(ceil(histogram_image->rows-scale*
+        y=CastDoubleToLong(ceil(histogram_image->rows-scale*
           histogram[x].blue-0.5));
         r=q+y*GetPixelChannels(histogram_image);
         for ( ; y < (ssize_t) histogram_image->rows; y++)
diff --git a/coders/tiff.c b/coders/tiff.c
index 68653c5..fdaf555 100644
--- a/coders/tiff.c
+++ b/coders/tiff.c
@@ -1589,9 +1589,9 @@
     if ((TIFFGetFieldDefaulted(tiff,TIFFTAG_XPOSITION,&x_position,sans) == 1) &&
         (TIFFGetFieldDefaulted(tiff,TIFFTAG_YPOSITION,&y_position,sans) == 1))
       {
-        image->page.x=MagickDoubleToLong(ceil(x_position*
+        image->page.x=CastDoubleToLong(ceil(x_position*
           image->resolution.x-0.5));
-        image->page.y=MagickDoubleToLong(ceil(y_position*
+        image->page.y=CastDoubleToLong(ceil(y_position*
           image->resolution.y-0.5));
       }
     if (TIFFGetFieldDefaulted(tiff,TIFFTAG_ORIENTATION,&orientation,sans) == 1)
diff --git a/coders/txt.c b/coders/txt.c
index e111347..e832815 100644
--- a/coders/txt.c
+++ b/coders/txt.c
@@ -273,7 +273,7 @@
       draw_info=DestroyDrawInfo(draw_info);
       ThrowReaderException(TypeError,"UnableToGetTypeMetrics");
     }
-  page.y=MagickDoubleToLong(ceil((double) page.y+metrics.ascent-0.5));
+  page.y=CastDoubleToLong(ceil((double) page.y+metrics.ascent-0.5));
   (void) FormatLocaleString(geometry,MagickPathExtent,"%gx%g%+g%+g",(double)
     image->columns,(double) image->rows,(double) page.x,(double) page.y);
   (void) CloneString(&draw_info->geometry,geometry);
@@ -574,8 +574,8 @@
           MagickMax(black+0.5,0.0),range);
         pixel.alpha=(MagickRealType) ScaleAnyToQuantum((QuantumAny)
           MagickMax(alpha+0.5,0.0),range);
-        q=GetAuthenticPixels(image,MagickDoubleToLong(x_offset),
-          MagickDoubleToLong(y_offset),1,1,exception);
+        q=GetAuthenticPixels(image,CastDoubleToLong(x_offset),
+          CastDoubleToLong(y_offset),1,1,exception);
         if (q == (Quantum *) NULL)
           {
             status=MagickFalse;