if (draw_info->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
assert(draw_info != (DrawInfo *) NULL);
- assert(draw_info->signature == MagickSignature);
+ assert(draw_info->signature == MagickCoreSignature);
if (draw_info->primitive != (char *) NULL)
draw_info->primitive=DestroyString(draw_info->primitive);
if (draw_info->text != (char *) NULL)
draw_info->gradient.stops);
if (draw_info->clip_mask != (char *) NULL)
draw_info->clip_mask=DestroyString(draw_info->clip_mask);
- draw_info->signature=(~MagickSignature);
+ draw_info->signature=(~MagickCoreSignature);
draw_info=(DrawInfo *) RelinquishMagickMemory(draw_info);
return(draw_info);
}
Determine bounding box.
*/
assert(image != (Image *) NULL);
- assert(image->signature == MagickSignature);
+ assert(image->signature == MagickCoreSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
assert(source != (const Image *) NULL);
- assert(source->signature == MagickSignature);
+ assert(source->signature == MagickCoreSignature);
assert(affine != (AffineMatrix *) NULL);
extent[0].x=0.0;
extent[0].y=0.0;
status;
assert(image != (Image *) NULL);
- assert(image->signature == MagickSignature);
+ assert(image->signature == MagickCoreSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
assert(draw_info != (const DrawInfo *) NULL);
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.
*/
assert(image != (Image *) NULL);
- assert(image->signature == MagickSignature);
+ assert(image->signature == MagickCoreSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
assert(draw_info != (DrawInfo *) NULL);
- assert(draw_info->signature == MagickSignature);
+ assert(draw_info->signature == MagickCoreSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
if ((draw_info->primitive == (char *) NULL) ||
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;
graphic_context[n]->decorate=(DecorationType) decorate;
break;
}
+ if (LocaleCompare("density",keyword) == 0)
+ {
+ GetMagickToken(q,&q,token);
+ (void) CloneString(&graphic_context[n]->density,token);
+ break;
+ }
if (LocaleCompare("direction",keyword) == 0)
{
ssize_t
}
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;
graphic_context[n]->affine.ty;
(void) FormatLocaleString(key,MagickPathExtent,"%s",name);
(void) SetImageArtifact(image,key,token);
+ (void) FormatLocaleString(key,MagickPathExtent,"%s-type",name);
+ (void) SetImageArtifact(image,key,type);
(void) FormatLocaleString(key,MagickPathExtent,"%s-geometry",name);
(void) FormatLocaleString(geometry,MagickPathExtent,
"%gx%g%+.15g%+.15g",
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);
- (void) GradientImage(image,LinearGradient,ReflectSpread,
- &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)
{
Draw linear or radial gradient on image.
*/
assert(image != (Image *) NULL);
- assert(image->signature == MagickSignature);
+ assert(image->signature == MagickCoreSignature);
if (image->debug != MagickFalse)
(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;
const char
*geometry,
- *path;
+ *path,
+ *type;
DrawInfo
*clone_info;
status;
assert(image != (Image *) NULL);
- assert(image->signature == MagickSignature);
+ assert(image->signature == MagickCoreSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
assert(draw_info != (const DrawInfo *) NULL);
clone_info=CloneDrawInfo((ImageInfo *) NULL,draw_info);
clone_info->fill_pattern=NewImageList();
clone_info->stroke_pattern=NewImageList();
+ (void) FormatLocaleString(property,MagickPathExtent,"%s-type",name);
+ type=GetImageArtifact(image,property);
+ if (type != (const char *) NULL)
+ clone_info->gradient.type=(GradientType) ParseCommandOption(
+ MagickGradientOptions,MagickFalse,type);
(void) CloneString(&clone_info->primitive,path);
status=DrawImage(*pattern,clone_info,exception);
clone_info=DestroyDrawInfo(clone_info);
bounds;
ssize_t
- start,
- stop,
+ start_y,
+ stop_y,
y;
/*
Compute bounding box.
*/
assert(image != (Image *) NULL);
- assert(image->signature == MagickSignature);
+ assert(image->signature == MagickCoreSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
assert(draw_info != (DrawInfo *) NULL);
- assert(draw_info->signature == MagickSignature);
+ assert(draw_info->signature == MagickCoreSignature);
assert(primitive_info != (PrimitiveInfo *) NULL);
if (primitive_info->coordinates == 0)
return(MagickTrue);
/*
Draw point.
*/
- start=(ssize_t) ceil(bounds.y1-0.5);
- stop=(ssize_t) floor(bounds.y2+0.5);
+ start_y=(ssize_t) ceil(bounds.y1-0.5);
+ stop_y=(ssize_t) floor(bounds.y2+0.5);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp parallel for schedule(static,4) shared(status) \
magick_threads(image,image,1,1)
#endif
- for (y=start; y <= stop; y++)
+ for (y=start_y; y <= stop_y; y++)
{
MagickBooleanType
sync;
*restrict q;
ssize_t
- start,
- stop;
+ start_x,
+ stop_x;
if (status == MagickFalse)
continue;
- start=(ssize_t) ceil(bounds.x1-0.5);
- stop=(ssize_t) floor(bounds.x2+0.5);
- x=start;
- q=GetCacheViewAuthenticPixels(image_view,x,y,(size_t) (stop-x+1),1,
+ start_x=(ssize_t) ceil(bounds.x1-0.5);
+ stop_x=(ssize_t) floor(bounds.x2+0.5);
+ x=start_x;
+ q=GetCacheViewAuthenticPixels(image_view,x,y,(size_t) (stop_x-x+1),1,
exception);
if (q == (Quantum *) NULL)
{
continue;
}
GetPixelInfo(image,&pixel);
- for ( ; x <= stop; x++)
+ for ( ; x <= stop_x; x++)
{
if ((x == (ssize_t) ceil(primitive_info->point.x-0.5)) &&
(y == (ssize_t) ceil(primitive_info->point.y-0.5)))
{
- (void) GetFillColor(draw_info,x,y,&pixel,exception);
+ (void) GetFillColor(draw_info,x-start_x,y-start_y,&pixel,exception);
SetPixelViaPixelInfo(image,&pixel,q);
}
q+=GetPixelChannels(image);
*/
if (image->alpha_trait == UndefinedPixelTrait)
(void) SetImageAlphaChannel(image,OpaqueAlphaChannel,exception);
- start=(ssize_t) ceil(bounds.y1-0.5);
- stop=(ssize_t) floor(bounds.y2+0.5);
+ start_y=(ssize_t) ceil(bounds.y1-0.5);
+ stop_y=(ssize_t) floor(bounds.y2+0.5);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp parallel for schedule(static,4) shared(status) \
magick_threads(image,image,1,1)
#endif
- for (y=start; y <= stop; y++)
+ for (y=start_y; y <= stop_y; y++)
{
const int
id = GetOpenMPThreadId();
x;
ssize_t
- start,
- stop;
+ start_x,
+ stop_x;
if (status == MagickFalse)
continue;
- start=(ssize_t) ceil(bounds.x1-0.5);
- stop=(ssize_t) floor(bounds.x2+0.5);
- q=GetCacheViewAuthenticPixels(image_view,start,y,(size_t) (stop-start+1),1,
+ start_x=(ssize_t) ceil(bounds.x1-0.5);
+ stop_x=(ssize_t) 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)
{
status=MagickFalse;
continue;
}
- for (x=start; x <= stop; x++)
+ for (x=start_x; x <= stop_x; x++)
{
/*
Fill and/or stroke.
fill_alpha=fill_alpha > 0.25 ? 1.0 : 0.0;
stroke_alpha=stroke_alpha > 0.25 ? 1.0 : 0.0;
}
- (void) GetFillColor(draw_info,x,y,&fill_color,exception);
+ (void) GetFillColor(draw_info,x-start_x,y-start_y,&fill_color,exception);
fill_alpha=fill_alpha*fill_color.alpha;
CompositePixelOver(image,&fill_color,fill_alpha,q,(double)
GetPixelAlpha(image,q),q);
- (void) GetStrokeColor(draw_info,x,y,&stroke_color,exception);
+ (void) GetStrokeColor(draw_info,x-start_x,y-start_y,&stroke_color,exception);
stroke_alpha=stroke_alpha*stroke_color.alpha;
CompositePixelOver(image,&stroke_color,stroke_alpha,q,(double)
GetPixelAlpha(image,q),q);
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=MagickSignature;
+ draw_info->signature=MagickCoreSignature;
clone_info=DestroyImageInfo(clone_info);
}
\f