]> granicus.if.org Git - imagemagick/commitdiff
Fixed extracting the clip path.
authorDirk Lemstra <dirk@lemstra.org>
Fri, 12 Jul 2019 14:28:43 +0000 (16:28 +0200)
committerDirk Lemstra <dirk@lemstra.org>
Fri, 12 Jul 2019 14:29:24 +0000 (16:29 +0200)
MagickCore/property.c

index 2649c5212e925f6514bda27b70e9352226bbd80b..ea63b143b18f431e0e9a7d44a4ca141d54cccfe6 100644 (file)
@@ -2063,6 +2063,22 @@ static char *TracePSClippath(const unsigned char *blob,size_t length)
   return(path);
 }
 
+static inline void TraceBezierCurve(char *message,PointInfo *last,
+  PointInfo *point)
+{
+  /*
+    Handle special cases when Bezier curves are used to describe
+    corners and straight lines.
+  */
+  if (((last+1)->x == (last+2)->x) && ((last+1)->y == (last+2)->y) &&
+      (point->x == (point+1)->x) && (point->y == (point+1)->y))
+    (void) FormatLocaleString(message,MagickPathExtent,
+      "L %g %g\n",point[1].x,point[1].y);
+  else
+    (void) FormatLocaleString(message,MagickPathExtent,"C %g %g %g %g %g %g\n",
+      (last+2)->x,(last+2)->y,point->x,point->y,(point+1)->x,(point+1)->y);
+}
+
 static char *TraceSVGClippath(const unsigned char *blob,size_t length,
   const size_t columns,const size_t rows)
 {
@@ -2173,18 +2189,7 @@ static char *TraceSVGClippath(const unsigned char *blob,size_t length,
           }
         else
           {
-            /*
-              Handle special cases when Bezier curves are used to describe
-              corners and straight lines.
-            */
-            if (((last[1].x == last[2].x) || (last[1].y == last[2].y)) &&
-                (point[0].x == point[1].x) && (point[0].y == point[1].y))
-              (void) FormatLocaleString(message,MagickPathExtent,
-                "L %g %g\n",point[1].x,point[1].y);
-            else
-              (void) FormatLocaleString(message,MagickPathExtent,
-                "C %g %g %g %g %g %g\n",last[2].x,last[2].y,point[0].x,
-                point[0].y,point[1].x,point[1].y);
+            TraceBezierCurve(message,last,point);
             for (i=0; i < 3; i++)
               last[i]=point[i];
           }
@@ -2196,19 +2201,7 @@ static char *TraceSVGClippath(const unsigned char *blob,size_t length,
         */
         if (knot_count == 0)
           {
-           /*
-              Same special handling as above except we compare to the
-              first point in the path and close the path.
-            */
-            if (((last[1].x == last[2].x) || (last[1].y == last[2].y)) &&
-                (first[0].x == first[1].x) && (first[0].y == first[1].y))
-              (void) FormatLocaleString(message,MagickPathExtent,
-                "L %g %g Z\n",first[1].x,first[1].y);
-            else
-              (void) FormatLocaleString(message,MagickPathExtent,
-                "C %g %g %g %g %g %g Z\n",last[2].x,last[2].y,first[0].x,
-                first[0].y,first[1].x,first[1].y);
-            (void) ConcatenateString(&path,message);
+            TraceBezierCurve(message,last,first);
             in_subpath=MagickFalse;
           }
         break;