]> granicus.if.org Git - imagemagick/blobdiff - MagickCore/draw.c
(no commit message)
[imagemagick] / MagickCore / draw.c
index e497bc3b9ab78aa89ac265e952b9d629907906bf..fc792353bfc9f43393138072c97cf682a54b5481 100644 (file)
@@ -1105,9 +1105,11 @@ MagickExport MagickBooleanType DrawAffineImage(Image *image,
   SegmentInfo
     edge;
 
+#if defined(MAGICKCORE_OPENMP_SUPPORT)
   size_t
     height,
     width;
+#endif
 
   ssize_t
     start,
@@ -1164,13 +1166,15 @@ MagickExport MagickBooleanType DrawAffineImage(Image *image,
   inverse_affine=InverseAffineMatrix(affine);
   GetPixelInfo(image,&zero);
   start=(ssize_t) ceil(edge.y1-0.5);
-  stop=(ssize_t) ceil(edge.y2-0.5);
-  height=(size_t) (floor(edge.y2-0.5)-ceil(edge.y1-0.5));
-  width=(size_t) (floor(edge.x2-0.5)-ceil(edge.x1-0.5));
+  stop=(ssize_t) floor(edge.y2+0.5);
+#if defined(MAGICKCORE_OPENMP_SUPPORT)
+  height=(size_t) (floor(edge.y2+0.5)-ceil(edge.y1-0.5));
+  width=(size_t) (floor(edge.x2+0.5)-ceil(edge.x1-0.5));
+#endif
   source_view=AcquireVirtualCacheView(source,exception);
   image_view=AcquireAuthenticCacheView(image,exception);
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp parallel for schedule(static) shared(status) \
+  #pragma omp parallel for schedule(static,4) shared(status) \
     dynamic_number_threads(image,width,height,1)
 #endif
   for (y=start; y <= stop; y++)
@@ -1198,14 +1202,14 @@ MagickExport MagickBooleanType DrawAffineImage(Image *image,
     if (inverse_edge.x2 < inverse_edge.x1)
       continue;
     q=GetCacheViewAuthenticPixels(image_view,(ssize_t) ceil(inverse_edge.x1-
-      0.5),y,(size_t) ((ssize_t) floor(inverse_edge.x2-0.5)-(ssize_t) ceil(
+      0.5),y,(size_t) ((ssize_t) floor(inverse_edge.x2+0.5)-(ssize_t) ceil(
       inverse_edge.x1-0.5)),1,exception);
     if (q == (Quantum *) NULL)
       continue;
     pixel=zero;
     composite=zero;
     x_offset=0;
-    for (x=(ssize_t) ceil(inverse_edge.x1-0.5); x <= (ssize_t) floor(inverse_edge.x2-0.5); x++)
+    for (x=(ssize_t) ceil(inverse_edge.x1-0.5); x <= (ssize_t) floor(inverse_edge.x2+0.5); x++)
     {
       point.x=(double) x*inverse_affine.sx+y*inverse_affine.ry+
         inverse_affine.tx;
@@ -1444,8 +1448,8 @@ MagickExport MagickBooleanType DrawClipPath(Image *image,
   status=NegateImage(clip_mask,MagickFalse,exception);
   (void) SetImageMask(image,clip_mask,exception);
   clip_mask=DestroyImage(clip_mask);
-  clone_info=DestroyDrawInfo(clone_info);
   status=DrawImage(image,clone_info,exception);
+  clone_info=DestroyDrawInfo(clone_info);
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(DrawEvent,GetMagickModule(),"end clip-path");
   return(status != 0 ? MagickTrue : MagickFalse);
@@ -3233,9 +3237,11 @@ MagickExport MagickBooleanType DrawGradientImage(Image *image,
   RectangleInfo
     bounding_box;
 
+#if defined(MAGICKCORE_OPENMP_SUPPORT)
   size_t
     height,
     width;
+#endif
 
   ssize_t
     y;
@@ -3256,11 +3262,13 @@ MagickExport MagickBooleanType DrawGradientImage(Image *image,
   bounding_box=gradient->bounding_box;
   status=MagickTrue;
   GetPixelInfo(image,&zero);
+#if defined(MAGICKCORE_OPENMP_SUPPORT)
   height=bounding_box.height-bounding_box.y;
   width=bounding_box.width-bounding_box.x;
+#endif
   image_view=AcquireAuthenticCacheView(image,exception);
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp parallel for schedule(static) shared(status) \
+  #pragma omp parallel for schedule(static,4) shared(status) \
     dynamic_number_threads(image,width,height,1)
 #endif
   for (y=bounding_box.y; y < (ssize_t) bounding_box.height; y++)
@@ -3805,9 +3813,11 @@ static MagickBooleanType DrawPolygonPrimitive(Image *image,
   SegmentInfo
     bounds;
 
+#if defined(MAGICKCORE_OPENMP_SUPPORT)
   size_t
     height,
     width;
+#endif
 
   ssize_t
     start,
@@ -3851,29 +3861,31 @@ static MagickBooleanType DrawPolygonPrimitive(Image *image,
   }
   bounds.x1-=(mid+1.0);
   bounds.x1=bounds.x1 < 0.0 ? 0.0 : (size_t) ceil(bounds.x1-0.5) >=
-    image->columns ? (double) image->columns-1.0 : bounds.x1;
+    image->columns ? (double) image->columns-1 : bounds.x1;
   bounds.y1-=(mid+1.0);
   bounds.y1=bounds.y1 < 0.0 ? 0.0 : (size_t) ceil(bounds.y1-0.5) >=
-    image->rows ? (double) image->rows-1.0 : bounds.y1;
+    image->rows ? (double) image->rows-1 : bounds.y1;
   bounds.x2+=(mid+1.0);
-  bounds.x2=bounds.x2 < 0.0 ? 0.0 : (size_t) floor(bounds.x2-0.5) >=
-    image->columns ? (double) image->columns-1.0 : bounds.x2;
+  bounds.x2=bounds.x2 < 0.0 ? 0.0 : (size_t) floor(bounds.x2+0.5) >=
+    image->columns ? (double) image->columns-1 : bounds.x2;
   bounds.y2+=(mid+1.0);
-  bounds.y2=bounds.y2 < 0.0 ? 0.0 : (size_t) floor(bounds.y2-0.5) >=
-    image->rows ? (double) image->rows-1.0 : bounds.y2;
+  bounds.y2=bounds.y2 < 0.0 ? 0.0 : (size_t) floor(bounds.y2+0.5) >=
+    image->rows ? (double) image->rows-1 : bounds.y2;
   status=MagickTrue;
   image_view=AcquireAuthenticCacheView(image,exception);
-  height=(size_t) (floor(bounds.y2-0.5)-ceil(bounds.y1-0.5));
-  width=(size_t) (floor(bounds.x2-0.5)-ceil(bounds.x1-0.5));
+#if defined(MAGICKCORE_OPENMP_SUPPORT)
+  height=(size_t) (floor(bounds.y2+0.5)-ceil(bounds.y1-0.5));
+  width=(size_t) (floor(bounds.x2+0.5)-ceil(bounds.x1-0.5));
+#endif
   if (primitive_info->coordinates == 1)
     {
       /*
         Draw point.
       */
       start=(ssize_t) ceil(bounds.y1-0.5);
-      stop=(ssize_t) floor(bounds.y2-0.5);
+      stop=(ssize_t) floor(bounds.y2+0.5);
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
-      #pragma omp parallel for schedule(static) shared(status) \
+      #pragma omp parallel for schedule(static,4) shared(status) \
         dynamic_number_threads(image,width,height,1)
 #endif
       for (y=start; y <= stop; y++)
@@ -3897,10 +3909,10 @@ static MagickBooleanType DrawPolygonPrimitive(Image *image,
         if (status == MagickFalse)
           continue;
         start=(ssize_t) ceil(bounds.x1-0.5);
-        stop=(ssize_t) floor(bounds.x2-0.5);
+        stop=(ssize_t) floor(bounds.x2+0.5);
         x=start;
-        q=GetCacheViewAuthenticPixels(image_view,x,y,(size_t) (stop-x+1),
-          1,exception);
+        q=GetCacheViewAuthenticPixels(image_view,x,y,(size_t) (stop-x+1),1,
+          exception);
         if (q == (Quantum *) NULL)
           {
             status=MagickFalse;
@@ -3934,9 +3946,9 @@ static MagickBooleanType DrawPolygonPrimitive(Image *image,
   if (image->alpha_trait != BlendPixelTrait)
     (void) SetImageAlphaChannel(image,OpaqueAlphaChannel,exception);
   start=(ssize_t) ceil(bounds.y1-0.5);
-  stop=(ssize_t) floor(bounds.y2-0.5);
+  stop=(ssize_t) floor(bounds.y2+0.5);
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp parallel for schedule(static) shared(status) \
+  #pragma omp parallel for schedule(static,4) shared(status) \
     dynamic_number_threads(image,width,height,1)
 #endif
   for (y=start; y <= stop; y++)
@@ -3965,7 +3977,7 @@ static MagickBooleanType DrawPolygonPrimitive(Image *image,
     if (status == MagickFalse)
       continue;
     start=(ssize_t) ceil(bounds.x1-0.5);
-    stop=(ssize_t) floor(bounds.x2-0.5);
+    stop=(ssize_t) floor(bounds.x2+0.5);
     q=GetCacheViewAuthenticPixels(image_view,start,y,(size_t) (stop-start+1),1,
       exception);
     if (q == (Quantum *) NULL)