% July 1992 %
% %
% %
-% Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization %
% dedicated to making software imaging solutions freely available. %
% %
% You may not use this file except in compliance with the License. You may %
#include "MagickCore/client.h"
#include "MagickCore/color.h"
#include "MagickCore/color-private.h"
+#include "MagickCore/colorspace-private.h"
#include "MagickCore/composite.h"
#include "MagickCore/composite-private.h"
#include "MagickCore/constitute.h"
}
if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)
return(MagickFalse);
+ if (IsGrayColorspace(image->colorspace) != MagickFalse)
+ (void) TransformImageColorspace(image,sRGBColorspace,exception);
status=MagickTrue;
for (i=0; textlist[i] != (char *) NULL; i++)
{
const MagickBooleanType split,TypeMetric *metrics,char **caption,
ExceptionInfo *exception)
{
+ char
+ *text;
+
MagickBooleanType
status;
ssize_t
n;
+ text=AcquireString(draw_info->text);
q=draw_info->text;
s=(char *) NULL;
for (p=(*caption); GetUTFCode(p) != 0; p+=GetUTFOctets(p))
if (status == MagickFalse)
break;
width=(size_t) floor(metrics->width+0.5);
- if (width <= image->columns)
+ if ((width <= image->columns) || (strcmp(text,draw_info->text) == 0))
continue;
+ (void) strcpy(text,draw_info->text);
if ((s != (char *) NULL) && (GetUTFOctets(s) == 1))
{
*s='\n';
q=draw_info->text;
s=(char *) NULL;
}
+ text=DestroyString(text);
n=0;
for (p=(*caption); GetUTFCode(p) != 0; p+=GetUTFOctets(p))
if (GetUTFCode(p) == '\n')
type_info=GetTypeInfo(draw_info->font,exception);
if (type_info == (const TypeInfo *) NULL)
(void) ThrowMagickException(exception,GetMagickModule(),TypeWarning,
- "UnableToReadFont","`%s'",draw_info->font);
+ "UnableToReadFont","'%s'",draw_info->font);
}
if ((type_info == (const TypeInfo *) NULL) &&
(draw_info->family != (const char *) NULL))
draw_info->stretch,draw_info->weight,exception);
if (type_info == (const TypeInfo *) NULL)
(void) ThrowMagickException(exception,GetMagickModule(),TypeWarning,
- "UnableToReadFont","`%s'",draw_info->family);
+ "UnableToReadFont","'%s'",draw_info->family);
}
if (type_info == (const TypeInfo *) NULL)
type_info=GetTypeInfoByFamily("Arial",draw_info->style,
{
(void) FT_Done_FreeType(library);
(void) ThrowMagickException(exception,GetMagickModule(),TypeError,
- "UnableToReadFont","`%s'",draw_info->font);
+ "UnableToReadFont","'%s'",draw_info->font);
return(RenderPostscript(image,draw_info,offset,metrics,exception));
}
if ((draw_info->metrics != (char *) NULL) &&
metrics->bounds.y2=metrics->ascent+metrics->descent;
metrics->underline_position=face->underline_position/64.0;
metrics->underline_thickness=face->underline_thickness/64.0;
- if (*draw_info->text == '\0')
+ if ((draw_info->text == (char *) NULL) || (*draw_info->text == '\0'))
{
(void) FT_Done_Face(face);
(void) FT_Done_FreeType(library);
draw_info->encoding != (char *) NULL ? draw_info->encoding : "none",
draw_info->pointsize);
flags=FT_LOAD_NO_BITMAP;
- value=GetImageProperty(image,"type:hinting");
+ if (draw_info->text_antialias == MagickFalse)
+ flags|=FT_LOAD_TARGET_MONO;
+ else
+ {
+#if defined(FT_LOAD_TARGET_LIGHT)
+ flags|=FT_LOAD_TARGET_LIGHT;
+#elif defined(FT_LOAD_TARGET_LCD)
+ flags|=FT_LOAD_TARGET_LCD;
+#endif
+ }
+ value=GetImageProperty(image,"type:hinting",exception);
if ((value != (const char *) NULL) && (LocaleCompare(value,"off") == 0))
flags|=FT_LOAD_NO_HINTING;
glyph.id=0;
glyph.id=FT_Get_Char_Index(face,'?');
if ((glyph.id != 0) && (last_glyph.id != 0))
{
- if (draw_info->kerning != 0.0)
+ if (fabs(draw_info->kerning) >= MagickEpsilon)
origin.x+=(FT_Pos) (64.0*direction*draw_info->kerning);
else
if (FT_HAS_KERNING(face))
if (status != 0)
continue;
if ((p == draw_info->text) || (bounds.xMin < metrics->bounds.x1))
- metrics->bounds.x1=bounds.xMin;
+ metrics->bounds.x1=(double) bounds.xMin;
if ((p == draw_info->text) || (bounds.yMin < metrics->bounds.y1))
- metrics->bounds.y1=bounds.yMin;
+ metrics->bounds.y1=(double) bounds.yMin;
if ((p == draw_info->text) || (bounds.xMax > metrics->bounds.x2))
- metrics->bounds.x2=bounds.xMax;
+ metrics->bounds.x2=(double) bounds.xMax;
if ((p == draw_info->text) || (bounds.yMax > metrics->bounds.y2))
- metrics->bounds.y2=bounds.yMax;
+ metrics->bounds.y2=(double) bounds.yMax;
if (draw_info->render != MagickFalse)
if ((draw_info->stroke.alpha != TransparentAlpha) ||
(draw_info->stroke_pattern != (Image *) NULL))
Rasterize the glyph.
*/
status=MagickTrue;
- image_view=AcquireCacheView(image);
+ image_view=AcquireAuthenticCacheView(image,exception);
p=bitmap->bitmap.buffer;
for (y=0; y < (ssize_t) bitmap->bitmap.rows; y++)
{
MagickRealType
fill_opacity;
- PixelPacket
+ PixelInfo
fill_color;
register Quantum
bitmap->bitmap.width,1,exception);
active=q != (Quantum *) NULL ? MagickTrue : MagickFalse;
}
- n=y*bitmap->bitmap.pitch;
- for (x=0; x < (ssize_t) bitmap->bitmap.width; x++, n++)
+ n=y*bitmap->bitmap.pitch-1;
+ for (x=0; x < (ssize_t) bitmap->bitmap.width; x++)
{
+ n++;
x_offset++;
if ((x_offset < 0) || (x_offset >= (ssize_t) image->columns))
{
q+=GetPixelChannels(image);
continue;
}
- (void) GetFillColor(draw_info,x_offset,y_offset,&fill_color);
+ GetPixelInfo(image,&fill_color);
+ (void) GetFillColor(draw_info,x_offset,y_offset,&fill_color,
+ exception);
fill_opacity=fill_opacity*fill_color.alpha;
CompositePixelOver(image,&fill_color,fill_opacity,q,
GetPixelAlpha(image,q),q);
}
if ((bitmap->left+bitmap->bitmap.width) > metrics->width)
metrics->width=bitmap->left+bitmap->bitmap.width;
- if ((draw_info->interword_spacing != 0.0) &&
+ if ((fabs(draw_info->interword_spacing) >= MagickEpsilon) &&
(IsUTFSpace(GetUTFCode(p)) != MagickFalse) &&
(IsUTFSpace(code) == MagickFalse))
origin.x+=(FT_Pos) (64.0*direction*draw_info->interword_spacing);
else
origin.x+=(FT_Pos) (direction*face->glyph->advance.x);
- metrics->origin.x=origin.x;
- metrics->origin.y=origin.y;
+ metrics->origin.x=(double) origin.x;
+ metrics->origin.y=(double) origin.y;
if (last_glyph.id != 0)
FT_Done_Glyph(last_glyph.image);
last_glyph=glyph;
status=FT_Get_Glyph(face->glyph,&glyph.image);
if (status == 0)
{
- status=FT_Outline_Get_BBox(&((FT_OutlineGlyph) glyph.image)->
- outline,&bounds);
+ status=FT_Outline_Get_BBox(&((FT_OutlineGlyph) glyph.image)->outline,
+ &bounds);
if (status == 0)
{
FT_Vector_Transform(&glyph.origin,&affine);
TypeMetric *metrics,ExceptionInfo *exception)
{
(void) ThrowMagickException(exception,GetMagickModule(),
- MissingDelegateWarning,"DelegateLibrarySupportNotBuiltIn","`%s' (Freetype)",
+ MissingDelegateWarning,"DelegateLibrarySupportNotBuiltIn","'%s' (Freetype)",
draw_info->font != (char *) NULL ? draw_info->font : "none");
- return(RenderPostscript(image,draw_info,offset,metrics));
+ return(RenderPostscript(image,draw_info,offset,metrics,exception));
}
#endif
\f
/*
Sample to compute bounding box.
*/
- identity=(draw_info->affine.sx == draw_info->affine.sy) &&
- (draw_info->affine.rx == 0.0) && (draw_info->affine.ry == 0.0) ?
- MagickTrue : MagickFalse;
+ identity=(fabs(draw_info->affine.sx-draw_info->affine.sy) < MagickEpsilon) &&
+ (fabs(draw_info->affine.rx) < MagickEpsilon) &&
+ (fabs(draw_info->affine.ry) < MagickEpsilon) ? MagickTrue : MagickFalse;
extent.x=0.0;
extent.y=0.0;
for (i=0; i <= (ssize_t) (strlen(draw_info->text)+2); i++)
resolution.y=resolution.x;
}
if (identity == MagickFalse)
- (void) TransformImage(&annotate_image,"0x0",(char *) NULL);
+ (void) TransformImage(&annotate_image,"0x0",(char *) NULL,exception);
else
{
RectangleInfo
(void) FormatLocaleString(geometry,MaxTextExtent,
"%.20gx%.20g%+.20g%+.20g",(double) crop_info.width,(double)
crop_info.height,(double) crop_info.x,(double) crop_info.y);
- (void) TransformImage(&annotate_image,geometry,(char *) NULL);
+ (void) TransformImage(&annotate_image,geometry,(char *) NULL,exception);
}
metrics->pixels_per_em.x=(resolution.y/DefaultResolution)*
ExpandAffine(&draw_info->affine)*draw_info->pointsize;
}
if (draw_info->fill.alpha != TransparentAlpha)
{
+ CacheView
+ *annotate_view;
+
MagickBooleanType
sync;
- PixelPacket
+ PixelInfo
fill_color;
- CacheView
- *annotate_view;
-
/*
Render fill color.
*/
(void) SetImageAlphaChannel(annotate_image,OpaqueAlphaChannel,
exception);
fill_color=draw_info->fill;
- annotate_view=AcquireCacheView(annotate_image);
+ annotate_view=AcquireAuthenticCacheView(annotate_image,exception);
for (y=0; y < (ssize_t) annotate_image->rows; y++)
{
register ssize_t
break;
for (x=0; x < (ssize_t) annotate_image->columns; x++)
{
- (void) GetFillColor(draw_info,x,y,&fill_color);
+ (void) GetFillColor(draw_info,x,y,&fill_color,exception);
SetPixelAlpha(annotate_image,ClampToQuantum((((MagickRealType)
GetPixelIntensity(annotate_image,q)*fill_color.alpha)/
QuantumRange)),q);
break;
}
annotate_view=DestroyCacheView(annotate_view);
- (void) CompositeImage(image,OverCompositeOp,annotate_image,
+ (void) CompositeImage(image,annotate_image,OverCompositeOp,MagickTrue,
(ssize_t) ceil(offset->x-0.5),(ssize_t) ceil(offset->y-(metrics->ascent+
- metrics->descent)-0.5));
+ metrics->descent)-0.5),exception);
}
annotate_image=DestroyImage(annotate_image);
return(MagickTrue);
image_info=AcquireImageInfo();
client_name=GetClientName();
resource_database=XGetResourceDatabase(display,client_name);
- XGetResourceInfo(image_info,resource_database,client_name,&resource_info);
+ XGetResourceInfo(image_info,resource_database,client_name,
+ &resource_info);
resource_info.close_server=MagickFalse;
resource_info.colormap=PrivateColormap;
resource_info.font=AcquireString(draw_info->font);
*/
width=annotate_info.width;
height=annotate_info.height;
- if ((draw_info->affine.rx != 0.0) || (draw_info->affine.ry != 0.0))
+ if ((fabs(draw_info->affine.rx) >= MagickEpsilon) ||
+ (fabs(draw_info->affine.ry) >= MagickEpsilon))
{
- if (((draw_info->affine.sx-draw_info->affine.sy) == 0.0) &&
- ((draw_info->affine.rx+draw_info->affine.ry) == 0.0))
- annotate_info.degrees=(180.0/MagickPI)*
+ if ((fabs(draw_info->affine.sx-draw_info->affine.sy) < MagickEpsilon) &&
+ (fabs(draw_info->affine.rx+draw_info->affine.ry) < MagickEpsilon))
+ annotate_info.degrees=(double) (180.0/MagickPI)*
atan2(draw_info->affine.rx,draw_info->affine.sx);
}
(void) FormatLocaleString(annotate_info.geometry,MaxTextExtent,
pixel.pen_color.red=ScaleQuantumToShort(draw_info->fill.red);
pixel.pen_color.green=ScaleQuantumToShort(draw_info->fill.green);
pixel.pen_color.blue=ScaleQuantumToShort(draw_info->fill.blue);
- status=XAnnotateImage(display,&pixel,&annotate_info,image);
+ status=XAnnotateImage(display,&pixel,&annotate_info,image,exception);
if (status == 0)
{
ThrowXWindowException(ResourceLimitError,"MemoryAllocationFailed",
(void) offset;
(void) metrics;
(void) ThrowMagickException(exception,GetMagickModule(),
- MissingDelegateError,"DelegateLibrarySupportNotBuiltIn","`%s' (X11)",
+ MissingDelegateError,"DelegateLibrarySupportNotBuiltIn","'%s' (X11)",
image->filename);
return(MagickFalse);
}