% Read Pango Markup Language Format %
% %
% Software Design %
-% John Cristy %
+% Cristy %
% March 2012 %
% %
% %
-% Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2014 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/studio.h"
#include "MagickCore/annotate.h"
+#include "MagickCore/artifact.h"
#include "MagickCore/blob.h"
#include "MagickCore/blob-private.h"
#include "MagickCore/composite-private.h"
MagickBooleanType
status;
+ MemoryInfo
+ *pixel_info;
+
PangoAlignment
align;
*/
option=GetImageOption(image_info,"filename");
if (option == (const char *) NULL)
- property=InterpretImageProperties(image_info,image,image_info->filename,
- exception);
+ property=InterpretImageProperties((ImageInfo *) image_info,image,
+ image_info->filename,exception);
else
if (LocaleNCompare(option,"pango:",6) == 0)
- property=InterpretImageProperties(image_info,image,option+6,exception);
+ property=InterpretImageProperties((ImageInfo *) image_info,image,option+6,
+ exception);
else
- property=InterpretImageProperties(image_info,image,option,exception);
+ property=InterpretImageProperties((ImageInfo *) image_info,image,option,
+ exception);
(void) SetImageProperty(image,"caption",property,exception);
property=DestroyString(property);
caption=ConstantString(GetImageProperty(image,"caption",exception));
*/
fontmap=pango_cairo_font_map_new();
pango_cairo_font_map_set_resolution(PANGO_CAIRO_FONT_MAP(fontmap),
- image->resolution.x);
+ image->resolution.x == 0.0 ? 90.0 : image->resolution.x);
font_options=cairo_font_options_create();
option=GetImageOption(image_info,"pango:hinting");
if (option != (const char *) NULL)
option=GetImageOption(image_info,"pango:indent");
if (option != (const char *) NULL)
pango_layout_set_indent(layout,(int) ((StringToLong(option)*
- image->resolution.x*PANGO_SCALE+36)/72.0+0.5));
+ (image->resolution.x == 0.0 ? 90.0 : image->resolution.x)*PANGO_SCALE+36)/
+ 90.0+0.5));
switch (draw_info->align)
{
case CenterAlign: align=PANGO_ALIGN_CENTER; break;
pango_font_description_free(description);
}
option=GetImageOption(image_info,"pango:markup");
- if (IfMagickTrue(IsStringNotFalse(option))) /* enabled by default */
+ if ((option != (const char *) NULL) && (IsStringTrue(option) == MagickFalse))
pango_layout_set_text(layout,caption,-1);
else
{
(void) ParseAbsoluteGeometry(image_info->page,&page);
if (image->columns == 0)
{
- pango_layout_get_pixel_extents(layout,NULL,&extent);
- image->columns=extent.x+extent.width+2*page.x;
+ pango_layout_get_extents(layout,NULL,&extent);
+ image->columns=(extent.x+extent.width+PANGO_SCALE/2)/PANGO_SCALE+2*page.x;
}
else
{
image->columns-=2*page.x;
pango_layout_set_width(layout,(int) ((PANGO_SCALE*image->columns*
- image->resolution.x+36.0)/72.0+0.5));
+ (image->resolution.x == 0.0 ? 90.0 : image->resolution.x)+45.0)/90.0+
+ 0.5));
}
if (image->rows == 0)
{
- pango_layout_get_pixel_extents(layout,NULL,&extent);
- image->rows=extent.y+extent.height+2*page.y;
+ pango_layout_get_extents(layout,NULL,&extent);
+ image->rows=(extent.y+extent.height+PANGO_SCALE/2)/PANGO_SCALE+2*page.y;
}
else
{
image->rows-=2*page.y;
pango_layout_set_height(layout,(int) ((PANGO_SCALE*image->rows*
- image->resolution.y+36.0)/72.0+0.5));
+ (image->resolution.y == 0.0 ? 90.0 : image->resolution.y)+45.0)/90.0+
+ 0.5));
}
/*
Render markup.
*/
stride=(size_t) cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32,
- image->columns);
- pixels=(unsigned char *) AcquireQuantumMemory(image->columns,stride*
- sizeof(*pixels));
- if (pixels == (unsigned char *) NULL)
+ (int) image->columns);
+ pixel_info=AcquireVirtualMemory(image->rows,stride*sizeof(*pixels));
+ if (pixel_info == (MemoryInfo *) NULL)
{
draw_info=DestroyDrawInfo(draw_info);
caption=DestroyString(caption);
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
}
+ pixels=(unsigned char *) GetVirtualMemoryBlob(pixel_info);
surface=cairo_image_surface_create_for_data(pixels,CAIRO_FORMAT_ARGB32,
- image->columns,image->rows,stride);
+ (int) image->columns,(int) image->rows,(int) stride);
cairo_image=cairo_create(surface);
cairo_set_operator(cairo_image,CAIRO_OPERATOR_CLEAR);
cairo_paint(cairo_image);
double
gamma;
- fill_color.blue=(MagickRealType) ScaleCharToQuantum(*p++);
- fill_color.green=(MagickRealType) ScaleCharToQuantum(*p++);
- fill_color.red=(MagickRealType) ScaleCharToQuantum(*p++);
- fill_color.alpha=(MagickRealType) ScaleCharToQuantum(*p++);
+ fill_color.blue=(double) ScaleCharToQuantum(*p++);
+ fill_color.green=(double) ScaleCharToQuantum(*p++);
+ fill_color.red=(double) ScaleCharToQuantum(*p++);
+ fill_color.alpha=(double) ScaleCharToQuantum(*p++);
/*
Disassociate alpha.
*/
gamma=1.0-QuantumScale*fill_color.alpha;
- gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma);
+ gamma=PerceptibleReciprocal(gamma);
fill_color.blue*=gamma;
fill_color.green*=gamma;
fill_color.red*=gamma;
- CompositePixelOver(image,&fill_color,fill_color.alpha,q,(MagickRealType)
+ CompositePixelOver(image,&fill_color,fill_color.alpha,q,(double)
GetPixelAlpha(image,q),q);
q+=GetPixelChannels(image);
}
/*
Relinquish resources.
*/
- pixels=(unsigned char *) RelinquishMagickMemory(pixels);
+ pixel_info=RelinquishVirtualMemory(pixel_info);
draw_info=DestroyDrawInfo(draw_info);
caption=DestroyString(caption);
return(GetFirstImageInList(image));