blob: 62d56b2ebfb3601b9429be362ae3f8cbcead0479 [file] [log] [blame]
cristybb06a1a2012-03-15 00:16:53 +00001/*
2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3% %
4% %
5% %
6% PPPP AAA N N GGGG OOO %
7% P P A A NN N G O O %
cristyfde4ac32012-03-15 11:25:35 +00008% PPPP AAAAA N N N G GGG O O %
9% P M A A N NN G G O O %
10% P A A N N GGGG OOO %
cristybb06a1a2012-03-15 00:16:53 +000011% %
12% %
cristyfde4ac32012-03-15 11:25:35 +000013% Read Pango Markup Language Format %
cristybb06a1a2012-03-15 00:16:53 +000014% %
15% Software Design %
16% John Cristy %
cristyfde4ac32012-03-15 11:25:35 +000017% March 2012 %
cristybb06a1a2012-03-15 00:16:53 +000018% %
19% %
cristy45ef08f2012-12-07 13:13:34 +000020% Copyright 1999-2013 ImageMagick Studio LLC, a non-profit organization %
cristybb06a1a2012-03-15 00:16:53 +000021% dedicated to making software imaging solutions freely available. %
22% %
23% You may not use this file except in compliance with the License. You may %
24% obtain a copy of the License at %
25% %
26% http://www.imagemagick.org/script/license.php %
27% %
28% Unless required by applicable law or agreed to in writing, software %
29% distributed under the License is distributed on an "AS IS" BASIS, %
30% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
31% See the License for the specific language governing permissions and %
32% limitations under the License. %
33% %
34%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35%
36%
37*/
38
39/*
40 Include declarations.
41*/
42#include "MagickCore/studio.h"
43#include "MagickCore/annotate.h"
cristy63fe24b2013-04-05 18:04:34 +000044#include "MagickCore/artifact.h"
cristybb06a1a2012-03-15 00:16:53 +000045#include "MagickCore/blob.h"
46#include "MagickCore/blob-private.h"
47#include "MagickCore/composite-private.h"
48#include "MagickCore/draw.h"
49#include "MagickCore/draw-private.h"
50#include "MagickCore/exception.h"
51#include "MagickCore/exception-private.h"
52#include "MagickCore/image.h"
53#include "MagickCore/image-private.h"
54#include "MagickCore/list.h"
55#include "MagickCore/magick.h"
cristyfde4ac32012-03-15 11:25:35 +000056#include "MagickCore/memory_.h"
cristy19642b02012-03-26 19:33:21 +000057#include "MagickCore/module.h"
58#include "MagickCore/monitor.h"
59#include "MagickCore/monitor-private.h"
cristybb06a1a2012-03-15 00:16:53 +000060#include "MagickCore/option.h"
cristyfde4ac32012-03-15 11:25:35 +000061#include "MagickCore/pixel-accessor.h"
cristybb06a1a2012-03-15 00:16:53 +000062#include "MagickCore/property.h"
63#include "MagickCore/quantum-private.h"
64#include "MagickCore/static.h"
65#include "MagickCore/string_.h"
66#include "MagickCore/string-private.h"
cristye40005d2012-03-23 12:18:45 +000067#include "MagickCore/token.h"
cristybb06a1a2012-03-15 00:16:53 +000068#include "MagickCore/utility.h"
cristy19642b02012-03-26 19:33:21 +000069#if defined(MAGICKCORE_PANGOCAIRO_DELEGATE)
cristybb06a1a2012-03-15 00:16:53 +000070#include <pango/pango.h>
cristy19642b02012-03-26 19:33:21 +000071#include <pango/pangocairo.h>
cristybb06a1a2012-03-15 00:16:53 +000072#include <pango/pango-features.h>
73#endif
74
cristy19642b02012-03-26 19:33:21 +000075#if defined(MAGICKCORE_PANGOCAIRO_DELEGATE)
cristybb06a1a2012-03-15 00:16:53 +000076/*
77%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
78% %
79% %
80% %
81% R e a d P A N G O I m a g e %
82% %
83% %
84% %
85%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
86%
cristyfde4ac32012-03-15 11:25:35 +000087% ReadPANGOImage() reads an image in the Pango Markup Language Format.
cristybb06a1a2012-03-15 00:16:53 +000088%
89% The format of the ReadPANGOImage method is:
90%
91% Image *ReadPANGOImage(const ImageInfo *image_info,
92% ExceptionInfo *exception)
93%
94% A description of each parameter follows:
95%
96% o image_info: the image info.
97%
98% o exception: return any errors or warnings in this structure.
99%
100*/
cristyfde4ac32012-03-15 11:25:35 +0000101static Image *ReadPANGOImage(const ImageInfo *image_info,
102 ExceptionInfo *exception)
cristybb06a1a2012-03-15 00:16:53 +0000103{
cristy19642b02012-03-26 19:33:21 +0000104 cairo_font_options_t
105 *font_options;
106
107 cairo_surface_t
108 *surface;
109
cristyfde4ac32012-03-15 11:25:35 +0000110 char
111 *caption,
112 *property;
113
cristy19642b02012-03-26 19:33:21 +0000114 cairo_t
cristyab1975c2012-03-27 01:34:11 +0000115 *cairo_image;
cristy19642b02012-03-26 19:33:21 +0000116
cristybb06a1a2012-03-15 00:16:53 +0000117 const char
118 *option;
119
cristyfde4ac32012-03-15 11:25:35 +0000120 DrawInfo
121 *draw_info;
122
cristyfde4ac32012-03-15 11:25:35 +0000123 Image
124 *image;
125
cristy19642b02012-03-26 19:33:21 +0000126 MagickBooleanType
127 status;
128
cristybb06a1a2012-03-15 00:16:53 +0000129 PangoAlignment
130 align;
131
132 PangoContext
133 *context;
134
cristybb06a1a2012-03-15 00:16:53 +0000135 PangoFontMap
136 *fontmap;
137
138 PangoGravity
139 gravity;
140
141 PangoLayout
142 *layout;
143
144 PangoRectangle
145 extent;
146
147 PixelInfo
148 fill_color;
149
150 RectangleInfo
151 page;
152
cristybb06a1a2012-03-15 00:16:53 +0000153 register unsigned char
154 *p;
155
cristyab1975c2012-03-27 01:34:11 +0000156 size_t
157 stride;
158
cristybb06a1a2012-03-15 00:16:53 +0000159 ssize_t
160 y;
161
cristy19642b02012-03-26 19:33:21 +0000162 unsigned char
163 *pixels;
164
cristybb06a1a2012-03-15 00:16:53 +0000165 /*
cristyfde4ac32012-03-15 11:25:35 +0000166 Initialize Image structure.
167 */
168 assert(image_info != (const ImageInfo *) NULL);
169 assert(image_info->signature == MagickSignature);
170 if (image_info->debug != MagickFalse)
171 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
172 image_info->filename);
173 assert(exception != (ExceptionInfo *) NULL);
174 assert(exception->signature == MagickSignature);
175 image=AcquireImage(image_info,exception);
176 (void) ResetImagePage(image,"0x0+0+0");
177 /*
cristyc0732c42012-03-20 19:28:35 +0000178 Format caption.
179 */
cristy092ec8d2013-04-26 13:46:22 +0000180 option=GetImageOption(image_info,"filename");
cristyc0732c42012-03-20 19:28:35 +0000181 if (option == (const char *) NULL)
cristye67f43f2013-04-29 10:27:50 +0000182 property=InterpretImageProperties((ImageInfo *) image_info,image,
183 image_info->filename,exception);
cristyc0732c42012-03-20 19:28:35 +0000184 else
185 if (LocaleNCompare(option,"pango:",6) == 0)
cristye67f43f2013-04-29 10:27:50 +0000186 property=InterpretImageProperties((ImageInfo *) image_info,image,option+6,
187 exception);
cristyc0732c42012-03-20 19:28:35 +0000188 else
cristye67f43f2013-04-29 10:27:50 +0000189 property=InterpretImageProperties((ImageInfo *) image_info,image,option,
190 exception);
cristyc0732c42012-03-20 19:28:35 +0000191 (void) SetImageProperty(image,"caption",property,exception);
192 property=DestroyString(property);
193 caption=ConstantString(GetImageProperty(image,"caption",exception));
194 /*
cristybb06a1a2012-03-15 00:16:53 +0000195 Get context.
196 */
cristy19642b02012-03-26 19:33:21 +0000197 fontmap=pango_cairo_font_map_new();
198 pango_cairo_font_map_set_resolution(PANGO_CAIRO_FONT_MAP(fontmap),
cristy2d677312013-01-02 19:19:21 +0000199 image->resolution.x == 0.0 ? 90.0 : image->resolution.x);
cristy19642b02012-03-26 19:33:21 +0000200 font_options=cairo_font_options_create();
cristy092ec8d2013-04-26 13:46:22 +0000201 option=GetImageOption(image_info,"pango:hinting");
cristy19642b02012-03-26 19:33:21 +0000202 if (option != (const char *) NULL)
203 {
204 if (LocaleCompare(option,"none") != 0)
205 cairo_font_options_set_hint_style(font_options,CAIRO_HINT_STYLE_NONE);
206 if (LocaleCompare(option,"full") != 0)
207 cairo_font_options_set_hint_style(font_options,CAIRO_HINT_STYLE_FULL);
208 }
cristybb06a1a2012-03-15 00:16:53 +0000209 context=pango_font_map_create_context(fontmap);
cristy19642b02012-03-26 19:33:21 +0000210 pango_cairo_context_set_font_options(context,font_options);
cristyab1975c2012-03-27 01:34:11 +0000211 cairo_font_options_destroy(font_options);
cristy092ec8d2013-04-26 13:46:22 +0000212 option=GetImageOption(image_info,"pango:language");
cristybb06a1a2012-03-15 00:16:53 +0000213 if (option != (const char *) NULL)
214 pango_context_set_language(context,pango_language_from_string(option));
cristyfde4ac32012-03-15 11:25:35 +0000215 draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL);
cristybb06a1a2012-03-15 00:16:53 +0000216 pango_context_set_base_dir(context,draw_info->direction ==
217 RightToLeftDirection ? PANGO_DIRECTION_RTL : PANGO_DIRECTION_LTR);
218 switch (draw_info->gravity)
219 {
cristy58845e32012-03-27 15:44:05 +0000220 case NorthGravity:
221 {
222 gravity=PANGO_GRAVITY_NORTH;
223 break;
224 }
225 case NorthWestGravity:
226 case WestGravity:
227 case SouthWestGravity:
228 {
229 gravity=PANGO_GRAVITY_WEST;
230 break;
231 }
232 case NorthEastGravity:
233 case EastGravity:
234 case SouthEastGravity:
235 {
236 gravity=PANGO_GRAVITY_EAST;
237 break;
238 }
239 case SouthGravity:
240 {
241 gravity=PANGO_GRAVITY_SOUTH;
242 break;
243 }
244 default:
245 {
246 gravity=PANGO_GRAVITY_AUTO;
247 break;
248 }
cristybb06a1a2012-03-15 00:16:53 +0000249 }
250 pango_context_set_base_gravity(context,gravity);
cristy092ec8d2013-04-26 13:46:22 +0000251 option=GetImageOption(image_info,"pango:gravity-hint");
cristybb06a1a2012-03-15 00:16:53 +0000252 if (option != (const char *) NULL)
253 {
254 if (LocaleCompare(option,"line") == 0)
255 pango_context_set_gravity_hint(context,PANGO_GRAVITY_HINT_LINE);
256 if (LocaleCompare(option,"natural") == 0)
257 pango_context_set_gravity_hint(context,PANGO_GRAVITY_HINT_NATURAL);
258 if (LocaleCompare(option,"strong") == 0)
259 pango_context_set_gravity_hint(context,PANGO_GRAVITY_HINT_STRONG);
260 }
261 /*
262 Configure layout.
263 */
264 layout=pango_layout_new(context);
cristy092ec8d2013-04-26 13:46:22 +0000265 option=GetImageOption(image_info,"pango:auto-dir");
cristybb06a1a2012-03-15 00:16:53 +0000266 if (option != (const char *) NULL)
267 pango_layout_set_auto_dir(layout,1);
cristy092ec8d2013-04-26 13:46:22 +0000268 option=GetImageOption(image_info,"pango:ellipsize");
cristybb06a1a2012-03-15 00:16:53 +0000269 if (option != (const char *) NULL)
270 {
271 if (LocaleCompare(option,"end") == 0)
272 pango_layout_set_ellipsize(layout,PANGO_ELLIPSIZE_END);
273 if (LocaleCompare(option,"middle") == 0)
274 pango_layout_set_ellipsize(layout,PANGO_ELLIPSIZE_MIDDLE);
275 if (LocaleCompare(option,"none") == 0)
276 pango_layout_set_ellipsize(layout,PANGO_ELLIPSIZE_NONE);
277 if (LocaleCompare(option,"start") == 0)
278 pango_layout_set_ellipsize(layout,PANGO_ELLIPSIZE_START);
279 }
cristy092ec8d2013-04-26 13:46:22 +0000280 option=GetImageOption(image_info,"pango:justify");
anthony7bcfe7f2012-03-30 14:01:22 +0000281 if (IfMagickTrue(IsStringTrue(option)))
cristybb06a1a2012-03-15 00:16:53 +0000282 pango_layout_set_justify(layout,1);
cristy092ec8d2013-04-26 13:46:22 +0000283 option=GetImageOption(image_info,"pango:single-paragraph");
anthony7bcfe7f2012-03-30 14:01:22 +0000284 if (IfMagickTrue(IsStringTrue(option)))
cristybb06a1a2012-03-15 00:16:53 +0000285 pango_layout_set_single_paragraph_mode(layout,1);
cristy092ec8d2013-04-26 13:46:22 +0000286 option=GetImageOption(image_info,"pango:wrap");
cristybb06a1a2012-03-15 00:16:53 +0000287 if (option != (const char *) NULL)
288 {
289 if (LocaleCompare(option,"char") == 0)
290 pango_layout_set_wrap(layout,PANGO_WRAP_CHAR);
291 if (LocaleCompare(option,"word") == 0)
292 pango_layout_set_wrap(layout,PANGO_WRAP_WORD);
293 if (LocaleCompare(option,"word-char") == 0)
294 pango_layout_set_wrap(layout,PANGO_WRAP_WORD_CHAR);
295 }
cristy092ec8d2013-04-26 13:46:22 +0000296 option=GetImageOption(image_info,"pango:indent");
cristybb06a1a2012-03-15 00:16:53 +0000297 if (option != (const char *) NULL)
cristy22fd9d32012-03-19 11:50:33 +0000298 pango_layout_set_indent(layout,(int) ((StringToLong(option)*
cristy2d677312013-01-02 19:19:21 +0000299 (image->resolution.x == 0.0 ? 90.0 : image->resolution.x)*PANGO_SCALE+36)/
300 90.0+0.5));
cristybb06a1a2012-03-15 00:16:53 +0000301 switch (draw_info->align)
302 {
303 case CenterAlign: align=PANGO_ALIGN_CENTER; break;
304 case RightAlign: align=PANGO_ALIGN_RIGHT; break;
305 case LeftAlign: align=PANGO_ALIGN_LEFT; break;
306 default:
307 {
308 if (draw_info->gravity == CenterGravity)
cristyfde4ac32012-03-15 11:25:35 +0000309 {
cristybb06a1a2012-03-15 00:16:53 +0000310 align=PANGO_ALIGN_CENTER;
311 break;
312 }
313 align=PANGO_ALIGN_LEFT;
314 break;
315 }
316 }
317 if ((align != PANGO_ALIGN_CENTER) &&
318 (draw_info->direction == RightToLeftDirection))
319 align=(PangoAlignment) (PANGO_ALIGN_LEFT+PANGO_ALIGN_RIGHT-align);
320 pango_layout_set_alignment(layout,align);
cristy19642b02012-03-26 19:33:21 +0000321 if (draw_info->font != (char *) NULL)
322 {
323 PangoFontDescription
324 *description;
325
326 /*
327 Set font.
328 */
329 description=pango_font_description_from_string(draw_info->font);
330 pango_font_description_set_size(description,(int) (PANGO_SCALE*
331 draw_info->pointsize+0.5));
332 pango_layout_set_font_description(layout,description);
333 pango_font_description_free(description);
334 }
cristy092ec8d2013-04-26 13:46:22 +0000335 option=GetImageOption(image_info,"pango:markup");
cristyf3dbd112012-04-11 21:05:40 +0000336 if ((option != (const char *) NULL) && (IsStringTrue(option) == MagickFalse))
cristyfde4ac32012-03-15 11:25:35 +0000337 pango_layout_set_text(layout,caption,-1);
cristy4d84e4a2012-03-19 11:27:53 +0000338 else
339 {
340 GError
341 *error;
342
343 error=(GError *) NULL;
344 if (pango_parse_markup(caption,-1,0,NULL,NULL,NULL,&error) == 0)
345 (void) ThrowMagickException(exception,GetMagickModule(),CoderError,
346 error->message,"`%s'",image_info->filename);
347 pango_layout_set_markup(layout,caption,-1);
348 }
cristybb06a1a2012-03-15 00:16:53 +0000349 pango_layout_context_changed(layout);
350 page.x=0;
351 page.y=0;
352 if (image_info->page != (char *) NULL)
353 (void) ParseAbsoluteGeometry(image_info->page,&page);
354 if (image->columns == 0)
355 {
cristy8592b052013-02-07 01:24:54 +0000356 pango_layout_get_extents(layout,NULL,&extent);
cristy9171f112013-01-02 19:59:13 +0000357 image->columns=(extent.x+extent.width+PANGO_SCALE/2)/PANGO_SCALE+2*page.x;
cristybb06a1a2012-03-15 00:16:53 +0000358 }
359 else
360 {
361 image->columns-=2*page.x;
cristy22fd9d32012-03-19 11:50:33 +0000362 pango_layout_set_width(layout,(int) ((PANGO_SCALE*image->columns*
cristy910b7962013-01-06 14:30:18 +0000363 (image->resolution.x == 0.0 ? 90.0 : image->resolution.x)+45.0)/90.0+
cristy67cd01f2013-01-02 13:49:56 +0000364 0.5));
cristybb06a1a2012-03-15 00:16:53 +0000365 }
366 if (image->rows == 0)
367 {
cristy8592b052013-02-07 01:24:54 +0000368 pango_layout_get_extents(layout,NULL,&extent);
cristy9171f112013-01-02 19:59:13 +0000369 image->rows=(extent.y+extent.height+PANGO_SCALE/2)/PANGO_SCALE+2*page.y;
cristybb06a1a2012-03-15 00:16:53 +0000370 }
371 else
372 {
373 image->rows-=2*page.y;
cristy22fd9d32012-03-19 11:50:33 +0000374 pango_layout_set_height(layout,(int) ((PANGO_SCALE*image->rows*
cristy910b7962013-01-06 14:30:18 +0000375 (image->resolution.y == 0.0 ? 90.0 : image->resolution.y)+45.0)/90.0+
cristy67cd01f2013-01-02 13:49:56 +0000376 0.5));
cristybb06a1a2012-03-15 00:16:53 +0000377 }
378 /*
cristyba275302012-03-27 14:42:23 +0000379 Render markup.
cristybb06a1a2012-03-15 00:16:53 +0000380 */
cristyab1975c2012-03-27 01:34:11 +0000381 stride=(size_t) cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32,
382 image->columns);
cristye5dc0282012-04-09 19:07:44 +0000383 pixels=(unsigned char *) AcquireQuantumMemory(image->rows,stride*
cristyab1975c2012-03-27 01:34:11 +0000384 sizeof(*pixels));
cristy19642b02012-03-26 19:33:21 +0000385 if (pixels == (unsigned char *) NULL)
cristyab1975c2012-03-27 01:34:11 +0000386 {
387 draw_info=DestroyDrawInfo(draw_info);
388 caption=DestroyString(caption);
389 ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
390 }
cristy19642b02012-03-26 19:33:21 +0000391 surface=cairo_image_surface_create_for_data(pixels,CAIRO_FORMAT_ARGB32,
cristyab1975c2012-03-27 01:34:11 +0000392 image->columns,image->rows,stride);
393 cairo_image=cairo_create(surface);
cristyba275302012-03-27 14:42:23 +0000394 cairo_set_operator(cairo_image,CAIRO_OPERATOR_CLEAR);
cristyab1975c2012-03-27 01:34:11 +0000395 cairo_paint(cairo_image);
396 cairo_set_operator(cairo_image,CAIRO_OPERATOR_OVER);
cristy973b85f2012-03-27 14:56:21 +0000397 cairo_translate(cairo_image,page.x,page.y);
cristyab1975c2012-03-27 01:34:11 +0000398 pango_cairo_show_layout(cairo_image,layout);
cristyab1975c2012-03-27 01:34:11 +0000399 cairo_destroy(cairo_image);
cristy19642b02012-03-26 19:33:21 +0000400 cairo_surface_destroy(surface);
cristyba275302012-03-27 14:42:23 +0000401 g_object_unref(layout);
cristy19642b02012-03-26 19:33:21 +0000402 g_object_unref(fontmap);
cristybb06a1a2012-03-15 00:16:53 +0000403 /*
cristyab1975c2012-03-27 01:34:11 +0000404 Convert surface to image.
cristybb06a1a2012-03-15 00:16:53 +0000405 */
cristy19642b02012-03-26 19:33:21 +0000406 (void) SetImageBackgroundColor(image,exception);
407 p=pixels;
cristybb06a1a2012-03-15 00:16:53 +0000408 GetPixelInfo(image,&fill_color);
cristy19642b02012-03-26 19:33:21 +0000409 for (y=0; y < (ssize_t) image->rows; y++)
cristybb06a1a2012-03-15 00:16:53 +0000410 {
cristyba275302012-03-27 14:42:23 +0000411 register Quantum
412 *q;
413
cristyab1975c2012-03-27 01:34:11 +0000414 register ssize_t
415 x;
cristybb06a1a2012-03-15 00:16:53 +0000416
417 q=GetAuthenticPixels(image,0,y,image->columns,1,exception);
418 if (q == (Quantum *) NULL)
419 break;
cristy19642b02012-03-26 19:33:21 +0000420 for (x=0; x < (ssize_t) image->columns; x++)
cristybb06a1a2012-03-15 00:16:53 +0000421 {
cristyab1975c2012-03-27 01:34:11 +0000422 double
423 gamma;
424
cristya19f1d72012-08-07 18:24:38 +0000425 fill_color.blue=(double) ScaleCharToQuantum(*p++);
426 fill_color.green=(double) ScaleCharToQuantum(*p++);
427 fill_color.red=(double) ScaleCharToQuantum(*p++);
428 fill_color.alpha=(double) ScaleCharToQuantum(*p++);
cristyab1975c2012-03-27 01:34:11 +0000429 /*
430 Disassociate alpha.
431 */
432 gamma=1.0-QuantumScale*fill_color.alpha;
cristy3e3ec3a2012-11-03 23:11:06 +0000433 gamma=PerceptibleReciprocal(gamma);
cristyab1975c2012-03-27 01:34:11 +0000434 fill_color.blue*=gamma;
435 fill_color.green*=gamma;
436 fill_color.red*=gamma;
cristya19f1d72012-08-07 18:24:38 +0000437 CompositePixelOver(image,&fill_color,fill_color.alpha,q,(double)
cristy19642b02012-03-26 19:33:21 +0000438 GetPixelAlpha(image,q),q);
cristybb06a1a2012-03-15 00:16:53 +0000439 q+=GetPixelChannels(image);
440 }
cristy19642b02012-03-26 19:33:21 +0000441 if (SyncAuthenticPixels(image,exception) == MagickFalse)
442 break;
443 if (image->previous == (Image *) NULL)
444 {
445 status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,
446 image->rows);
447 if (status == MagickFalse)
448 break;
449 }
cristybb06a1a2012-03-15 00:16:53 +0000450 }
451 /*
452 Relinquish resources.
453 */
cristy19642b02012-03-26 19:33:21 +0000454 pixels=(unsigned char *) RelinquishMagickMemory(pixels);
cristyfde4ac32012-03-15 11:25:35 +0000455 draw_info=DestroyDrawInfo(draw_info);
cristybb06a1a2012-03-15 00:16:53 +0000456 caption=DestroyString(caption);
cristybb06a1a2012-03-15 00:16:53 +0000457 return(GetFirstImageInList(image));
458}
cristyfde4ac32012-03-15 11:25:35 +0000459#endif
cristybb06a1a2012-03-15 00:16:53 +0000460
461/*
462%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
463% %
464% %
465% %
466% R e g i s t e r P A N G O I m a g e %
467% %
468% %
469% %
470%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
471%
cristyfde4ac32012-03-15 11:25:35 +0000472% RegisterPANGOImage() adds attributes for the Pango Markup Language format to
cristybb06a1a2012-03-15 00:16:53 +0000473% the list of supported formats. The attributes include the image format
474% tag, a method to read and/or write the format, whether the format
475% supports the saving of more than one frame to the same file or blob,
476% whether the format supports native in-memory I/O, and a brief
477% description of the format.
478%
479% The format of the RegisterPANGOImage method is:
480%
481% size_t RegisterPANGOImage(void)
482%
483*/
484ModuleExport size_t RegisterPANGOImage(void)
485{
486 char
487 version[MaxTextExtent];
488
489 MagickInfo
490 *entry;
491
492 *version='\0';
493#if defined(PANGO_VERSION_STRING)
cristy19642b02012-03-26 19:33:21 +0000494 (void) FormatLocaleString(version,MaxTextExtent,"Pangocairo %s",
cristybb06a1a2012-03-15 00:16:53 +0000495 PANGO_VERSION_STRING);
496#endif
497 entry=SetMagickInfo("PANGO");
cristy19642b02012-03-26 19:33:21 +0000498#if defined(MAGICKCORE_PANGOCAIRO_DELEGATE)
cristybb06a1a2012-03-15 00:16:53 +0000499 entry->decoder=(DecodeImageHandler *) ReadPANGOImage;
cristyfde4ac32012-03-15 11:25:35 +0000500#endif
501 entry->description=ConstantString("Pango Markup Language");
cristybb06a1a2012-03-15 00:16:53 +0000502 if (*version != '\0')
503 entry->version=ConstantString(version);
504 entry->adjoin=MagickFalse;
505 entry->module=ConstantString("PANGO");
506 (void) RegisterMagickInfo(entry);
507 return(MagickImageCoderSignature);
508}
509
510/*
511%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
512% %
513% %
514% %
515% U n r e g i s t e r P A N G O I m a g e %
516% %
517% %
518% %
519%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
520%
cristyfde4ac32012-03-15 11:25:35 +0000521% UnregisterPANGOImage() removes format registrations made by the Pango module
522% from the list of supported formats.
cristybb06a1a2012-03-15 00:16:53 +0000523%
524% The format of the UnregisterPANGOImage method is:
525%
526% UnregisterPANGOImage(void)
527%
528*/
529ModuleExport void UnregisterPANGOImage(void)
530{
531 (void) UnregisterMagickInfo("PANGO");
532}