exception);
clone_info->clip_mask=(char *) NULL;
status=NegateImage(clip_mask,MagickFalse,exception);
- (void) SetImageMask(image,clip_mask,exception);
+ (void) SetImageMask(image,ReadPixelMask,clip_mask,exception);
clip_mask=DestroyImage(clip_mask);
status&=DrawImage(image,clone_info,exception);
clone_info=DestroyDrawInfo(clone_info);
PointInfo
point;
- PixelInfo
- start_color;
-
PrimitiveInfo
*primitive_info;
size_t
length,
- number_points;
+ number_points,
+ number_stops;
ssize_t
j,
k,
n;
+ StopInfo
+ *stops;
+
/*
Ensure the annotation info is valid.
*/
primitive_extent=(double) strlen(primitive);
(void) SetImageArtifact(image,"MVG",primitive);
n=0;
+ number_stops=0;
+ stops=(StopInfo *) NULL;
/*
Allocate primitive info memory.
*/
graphic_context[n]->viewbox.height=image->rows;
}
token=AcquireString(primitive);
- (void) QueryColorCompliance("#000000",AllCompliance,&start_color,
- exception);
if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)
return(MagickFalse);
status=MagickTrue;
}
if (LocaleCompare("font-weight",keyword) == 0)
{
+ ssize_t
+ weight;
+
GetMagickToken(q,&q,token);
- graphic_context[n]->weight=StringToUnsignedLong(token);
- if (LocaleCompare(token,"all") == 0)
- graphic_context[n]->weight=0;
- if (LocaleCompare(token,"bold") == 0)
- graphic_context[n]->weight=700;
- if (LocaleCompare(token,"bolder") == 0)
- if (graphic_context[n]->weight <= 800)
- graphic_context[n]->weight+=100;
- if (LocaleCompare(token,"lighter") == 0)
- if (graphic_context[n]->weight >= 100)
- graphic_context[n]->weight-=100;
- if (LocaleCompare(token,"normal") == 0)
- graphic_context[n]->weight=400;
+ weight=ParseCommandOption(MagickWeightOptions,MagickFalse,
+ token);
+ if (weight == -1)
+ weight=StringToUnsignedLong(token);
+ graphic_context[n]->weight=(size_t) weight;
break;
}
status=MagickFalse;
if (graphic_context[n]->clip_mask != (char *) NULL)
if (LocaleCompare(graphic_context[n]->clip_mask,
graphic_context[n-1]->clip_mask) != 0)
- (void) SetImageMask(image,(Image *) NULL,exception);
+ (void) SetImageMask(image,ReadPixelMask,(Image *) NULL,
+ exception);
graphic_context[n]=DestroyDrawInfo(graphic_context[n]);
n--;
break;
}
if (LocaleCompare("stop-color",keyword) == 0)
{
- GradientType
- type;
-
PixelInfo
stop_color;
+ number_stops++;
+ if (number_stops == 1)
+ stops=(StopInfo *) AcquireQuantumMemory(2,sizeof(*stops));
+ else if (number_stops > 2)
+ stops=(StopInfo *) ResizeQuantumMemory(stops,number_stops,
+ sizeof(*stops));
+ if (stops == (StopInfo *) NULL)
+ {
+ (void) ThrowMagickException(exception,GetMagickModule(),
+ ResourceLimitError,"MemoryAllocationFailed","`%s'",
+ image->filename);
+ break;
+ }
GetMagickToken(q,&q,token);
(void) QueryColorCompliance(token,AllCompliance,&stop_color,
exception);
- type=LinearGradient;
- if (draw_info->gradient.type == RadialGradient)
- type=RadialGradient;
- (void) GradientImage(image,type,PadSpread,&start_color,&stop_color,
- exception);
- start_color=stop_color;
+ stops[number_stops-1].color=stop_color;
GetMagickToken(q,&q,token);
+ stops[number_stops-1].offset=StringToDouble(token,(char **) NULL);
break;
}
if (LocaleCompare("stroke",keyword) == 0)
}
if (primitive_type == UndefinedPrimitive)
{
+ if (*q == '\0')
+ {
+ if (number_stops > 1)
+ {
+ GradientType
+ type;
+
+ type=LinearGradient;
+ if (draw_info->gradient.type == RadialGradient)
+ type=RadialGradient;
+ (void) GradientImage(image,type,PadSpread,stops,number_stops,
+ exception);
+ }
+ if (number_stops > 0)
+ stops=(StopInfo *) RelinquishMagickMemory(stops);
+ }
if (image->debug != MagickFalse)
(void) LogMagickEvent(DrawEvent,GetMagickModule()," %.*s",
(int) (q-p),p);
return(0.0);
}
+static int StopInfoCompare(const void *x,const void *y)
+{
+ StopInfo
+ *stop_1,
+ *stop_2;
+
+ stop_1=(StopInfo *) x;
+ stop_2=(StopInfo *) y;
+
+ if (stop_1->offset > stop_2->offset)
+ return(1);
+ if (fabs(stop_1->offset-stop_2->offset) <= MagickEpsilon)
+ return(0);
+ return(-1);
+}
+
MagickExport MagickBooleanType DrawGradientImage(Image *image,
const DrawInfo *draw_info,ExceptionInfo *exception)
{
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
assert(draw_info != (const DrawInfo *) NULL);
gradient=(&draw_info->gradient);
+ qsort(gradient->stops,gradient->number_stops,sizeof(StopInfo),
+ StopInfoCompare);
gradient_vector=(&gradient->gradient_vector);
point.x=gradient_vector->x2-gradient_vector->x1;
point.y=gradient_vector->y2-gradient_vector->y1;
draw_info->border_color=clone_info->border_color;
if (clone_info->server_name != (char *) NULL)
draw_info->server_name=AcquireString(clone_info->server_name);
+ option=GetImageOption(clone_info,"direction");
+ if (option != (const char *) NULL)
+ draw_info->direction=(DirectionType) ParseCommandOption(
+ MagickDirectionOptions,MagickFalse,option);
+ else
+ draw_info->direction=UndefinedDirection;
option=GetImageOption(clone_info,"encoding");
if (option != (const char *) NULL)
(void) CloneString(&draw_info->encoding,option);
- option=GetImageOption(clone_info,"kerning");
+ option=GetImageOption(clone_info,"family");
if (option != (const char *) NULL)
- draw_info->kerning=StringToDouble(option,(char **) NULL);
+ (void) CloneString(&draw_info->family,option);
+ option=GetImageOption(clone_info,"fill");
+ if (option != (const char *) NULL)
+ (void) QueryColorCompliance(option,AllCompliance,&draw_info->fill,
+ exception);
+ option=GetImageOption(clone_info,"gravity");
+ if (option != (const char *) NULL)
+ draw_info->gravity=(GravityType) ParseCommandOption(MagickGravityOptions,
+ MagickFalse,option);
option=GetImageOption(clone_info,"interline-spacing");
if (option != (const char *) NULL)
draw_info->interline_spacing=StringToDouble(option,(char **) NULL);
option=GetImageOption(clone_info,"interword-spacing");
if (option != (const char *) NULL)
draw_info->interword_spacing=StringToDouble(option,(char **) NULL);
- option=GetImageOption(clone_info,"direction");
- if (option != (const char *) NULL)
- draw_info->direction=(DirectionType) ParseCommandOption(
- MagickDirectionOptions,MagickFalse,option);
- else
- draw_info->direction=UndefinedDirection;
- option=GetImageOption(clone_info,"fill");
+ option=GetImageOption(clone_info,"kerning");
if (option != (const char *) NULL)
- (void) QueryColorCompliance(option,AllCompliance,&draw_info->fill,
- exception);
+ draw_info->kerning=StringToDouble(option,(char **) NULL);
option=GetImageOption(clone_info,"stroke");
if (option != (const char *) NULL)
(void) QueryColorCompliance(option,AllCompliance,&draw_info->stroke,
option=GetImageOption(clone_info,"strokewidth");
if (option != (const char *) NULL)
draw_info->stroke_width=StringToDouble(option,(char **) NULL);
+ option=GetImageOption(clone_info,"style");
+ if (option != (const char *) NULL)
+ draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions,
+ MagickFalse,option);
option=GetImageOption(clone_info,"undercolor");
if (option != (const char *) NULL)
(void) QueryColorCompliance(option,AllCompliance,&draw_info->undercolor,
exception);
- option=GetImageOption(clone_info,"gravity");
+ option=GetImageOption(clone_info,"weight");
if (option != (const char *) NULL)
- draw_info->gravity=(GravityType) ParseCommandOption(MagickGravityOptions,
- MagickFalse,option);
+ {
+ ssize_t
+ weight;
+
+ weight=ParseCommandOption(MagickWeightOptions,MagickFalse,option);
+ if (weight == -1)
+ weight=StringToUnsignedLong(option);
+ draw_info->weight=(size_t) weight;
+ }
exception=DestroyExceptionInfo(exception);
draw_info->signature=MagickCoreSignature;
clone_info=DestroyImageInfo(clone_info);