From 9eb18477509197d7fe96aa7d9674d10d2f4362f8 Mon Sep 17 00:00:00 2001 From: cristy Date: Mon, 11 Nov 2013 14:55:48 +0000 Subject: [PATCH] --- MagickCore/fx.c | 18 ++++++++-------- MagickCore/property.c | 48 +++++++++++++++++++++++++++++++++---------- 2 files changed, 46 insertions(+), 20 deletions(-) diff --git a/MagickCore/fx.c b/MagickCore/fx.c index e30a8bf07..778bbdea5 100644 --- a/MagickCore/fx.c +++ b/MagickCore/fx.c @@ -208,23 +208,23 @@ MagickPrivate FxInfo *AcquireFxInfo(const Image *image,const char *expression, Convert compound to simple operators. */ fx_op[1]='\0'; - *fx_op=(char) LeftShiftOperator; + *fx_op=(char) ((int) LeftShiftOperator); (void) SubstituteString(&fx_info->expression,"<<",fx_op); - *fx_op=(char) RightShiftOperator; + *fx_op=(char) ((int) RightShiftOperator); (void) SubstituteString(&fx_info->expression,">>",fx_op); - *fx_op=(char) LessThanEqualOperator; + *fx_op=(char) ((int) LessThanEqualOperator); (void) SubstituteString(&fx_info->expression,"<=",fx_op); - *fx_op=(char) GreaterThanEqualOperator; + *fx_op=(char) ((int) GreaterThanEqualOperator); (void) SubstituteString(&fx_info->expression,">=",fx_op); - *fx_op=(char) EqualOperator; + *fx_op=(char) ((int) EqualOperator); (void) SubstituteString(&fx_info->expression,"==",fx_op); - *fx_op=(char) NotEqualOperator; + *fx_op=(char) ((int) NotEqualOperator); (void) SubstituteString(&fx_info->expression,"!=",fx_op); - *fx_op=(char) LogicalAndOperator; + *fx_op=(char) ((int) LogicalAndOperator); (void) SubstituteString(&fx_info->expression,"&&",fx_op); - *fx_op=(char) LogicalOrOperator; + *fx_op=(char) ((int) LogicalOrOperator); (void) SubstituteString(&fx_info->expression,"||",fx_op); - *fx_op=(char) ExponentialNotation; + *fx_op=(char) ((int) ExponentialNotation); (void) SubstituteString(&fx_info->expression,"**",fx_op); return(fx_info); } diff --git a/MagickCore/property.c b/MagickCore/property.c index 7ea082a38..8e770ef29 100644 --- a/MagickCore/property.c +++ b/MagickCore/property.c @@ -1949,14 +1949,28 @@ 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,MaxTextExtent,"L %g,%g\n", - point[1].x,point[1].y); - else (void) FormatLocaleString(message,MaxTextExtent, - "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); + " %g %g l\n",point[1].x,point[1].y); + else + if ((last[1].x == last[2].x) && (last[1].y == last[2].y)) + (void) FormatLocaleString(message,MaxTextExtent, + " %g %g %g %g v\n",point[0].x,point[0].y, + point[1].x,point[1].y); + else + if ((point[0].x == point[1].x) && (point[0].y == point[1].y)) + (void) FormatLocaleString(message,MaxTextExtent, + " %g %g %g %g y\n",last[2].x,last[2].y, + point[1].x,point[1].y); + else + (void) FormatLocaleString(message,MaxTextExtent, + " %g %g %g %g %g %g c\n",last[2].x, + last[2].y,point[0].x,point[0].y,point[1].x,point[1].y); for (i=0; i < 3; i++) last[i]=point[i]; } @@ -1968,17 +1982,29 @@ 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,MaxTextExtent, - "L %g,%g Z\n",first[1].x,first[1].y); + " %g %g l z\n",first[1].x,first[1].y); else - { + if ((last[1].x == last[2].x) && (last[1].y == last[2].y)) (void) FormatLocaleString(message,MaxTextExtent, - "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); - } + " %g %g %g %g v z\n",first[0].x,first[0].y, + first[1].x,first[1].y); + else + if ((first[0].x == first[1].x) && (first[0].y == first[1].y)) + (void) FormatLocaleString(message,MaxTextExtent, + " %g %g %g %g y z\n",last[2].x,last[2].y, + first[1].x,first[1].y); + else + (void) FormatLocaleString(message,MaxTextExtent, + " %g %g %g %g %g %g c z\n",last[2].x, + last[2].y,first[0].x,first[0].y,first[1].x,first[1].y); + (void) ConcatenateString(&path,message); in_subpath=MagickFalse; } break; -- 2.40.0