]> granicus.if.org Git - imagemagick/blob - coders/txt.c
(no commit message)
[imagemagick] / coders / txt.c
1 /*
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %                                                                             %
4 %                                                                             %
5 %                                                                             %
6 %                            TTTTT  X   X  TTTTT                              %
7 %                              T     X X     T                                %
8 %                              T      X      T                                %
9 %                              T     X X     T                                %
10 %                              T    X   X    T                                %
11 %                                                                             %
12 %                                                                             %
13 %                      Render Text Onto A Canvas Image.                       %
14 %                                                                             %
15 %                              Software Design                                %
16 %                                John Cristy                                  %
17 %                                 July 1992                                   %
18 %                                                                             %
19 %                                                                             %
20 %  Copyright 1999-2010 ImageMagick Studio LLC, a non-profit organization      %
21 %  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 \f
39 /*
40   Include declarations.
41 */
42 #include "magick/studio.h"
43 #include "magick/annotate.h"
44 #include "magick/attribute.h"
45 #include "magick/blob.h"
46 #include "magick/blob-private.h"
47 #include "magick/cache.h"
48 #include "magick/color.h"
49 #include "magick/color-private.h"
50 #include "magick/colorspace.h"
51 #include "magick/constitute.h"
52 #include "magick/draw.h"
53 #include "magick/exception.h"
54 #include "magick/exception-private.h"
55 #include "magick/geometry.h"
56 #include "magick/image.h"
57 #include "magick/image-private.h"
58 #include "magick/list.h"
59 #include "magick/magick.h"
60 #include "magick/memory_.h"
61 #include "magick/monitor.h"
62 #include "magick/monitor-private.h"
63 #include "magick/option.h"
64 #include "magick/pixel-private.h"
65 #include "magick/quantum-private.h"
66 #include "magick/static.h"
67 #include "magick/statistic.h"
68 #include "magick/string_.h"
69 #include "magick/module.h"
70 \f
71 /*
72   Forward declarations.
73 */
74 static MagickBooleanType
75   WriteTXTImage(const ImageInfo *,Image *);
76 \f
77 /*
78 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
79 %                                                                             %
80 %                                                                             %
81 %                                                                             %
82 %   I s T X T                                                                 %
83 %                                                                             %
84 %                                                                             %
85 %                                                                             %
86 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
87 %
88 %  IsTXT() returns MagickTrue if the image format type, identified by the magick
89 %  string, is TXT.
90 %
91 %  The format of the IsTXT method is:
92 %
93 %      MagickBooleanType IsTXT(const unsigned char *magick,const size_t length)
94 %
95 %  A description of each parameter follows:
96 %
97 %    o magick: compare image format pattern against these bytes.
98 %
99 %    o length: Specifies the length of the magick string.
100 %
101 */
102 static MagickBooleanType IsTXT(const unsigned char *magick,const size_t length)
103 {
104 #define MagickID  "# ImageMagick pixel enumeration:"
105
106   char
107     colorspace[MaxTextExtent];
108
109   ssize_t
110     count;
111
112   unsigned long
113     columns,
114     depth,
115     rows;
116
117   if (length < 40)
118     return(MagickFalse);
119   if (LocaleNCompare((const char *) magick,MagickID,strlen(MagickID)) != 0)
120     return(MagickFalse);
121   count=(ssize_t) sscanf((const char *) magick+32,"%lu,%lu,%lu,%s",&columns,
122     &rows,&depth,colorspace);
123   if (count != 4)
124     return(MagickFalse);
125   return(MagickTrue);
126 }
127 \f
128 /*
129 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
130 %                                                                             %
131 %                                                                             %
132 %                                                                             %
133 %   R e a d T E X T I m a g e                                                 %
134 %                                                                             %
135 %                                                                             %
136 %                                                                             %
137 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
138 %
139 %  ReadTEXTImage() reads a text file and returns it as an image.  It
140 %  allocates the memory necessary for the new Image structure and returns a
141 %  pointer to the new image.
142 %
143 %  The format of the ReadTEXTImage method is:
144 %
145 %      Image *ReadTEXTImage(const ImageInfo *image_info,Image *image,
146 %        char *text,ExceptionInfo *exception)
147 %
148 %  A description of each parameter follows:
149 %
150 %    o image_info: the image info.
151 %
152 %    o image: the image.
153 %
154 %    o text: the text storage buffer.
155 %
156 %    o exception: return any errors or warnings in this structure.
157 %
158 */
159 static Image *ReadTEXTImage(const ImageInfo *image_info,Image *image,
160   char *text,ExceptionInfo *exception)
161 {
162   char
163     filename[MaxTextExtent],
164     geometry[MaxTextExtent],
165     *p;
166
167   DrawInfo
168     *draw_info;
169
170   Image
171     *texture;
172
173   ssize_t
174     offset;
175
176   MagickBooleanType
177     status;
178
179   PointInfo
180     delta;
181
182   RectangleInfo
183     page;
184
185   TypeMetric
186     metrics;
187
188   /*
189     Open image file.
190   */
191   assert(image_info != (const ImageInfo *) NULL);
192   assert(image_info->signature == MagickSignature);
193   if (image_info->debug != MagickFalse)
194     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
195       image_info->filename);
196   assert(exception != (ExceptionInfo *) NULL);
197   assert(exception->signature == MagickSignature);
198   /*
199     Set the page geometry.
200   */
201   delta.x=DefaultResolution;
202   delta.y=DefaultResolution;
203   if ((image->x_resolution == 0.0) || (image->y_resolution == 0.0))
204     {
205       GeometryInfo
206         geometry_info;
207
208       MagickStatusType
209         flags;
210
211       flags=ParseGeometry(PSDensityGeometry,&geometry_info);
212       image->x_resolution=geometry_info.rho;
213       image->y_resolution=geometry_info.sigma;
214       if ((flags & SigmaValue) == 0)
215         image->y_resolution=image->x_resolution;
216     }
217   page.width=612;
218   page.height=792;
219   page.x=43;
220   page.y=43;
221   if (image_info->page != (char *) NULL)
222     (void) ParseAbsoluteGeometry(image_info->page,&page);
223   /*
224     Initialize Image structure.
225   */
226   image->columns=(size_t) floor((((double) page.width*
227     image->x_resolution)/delta.x)+0.5);
228   image->rows=(size_t) floor((((double) page.height*
229     image->y_resolution)/delta.y)+0.5);
230   image->page.x=0;
231   image->page.y=0;
232   texture=(Image *) NULL;
233   if (image_info->texture != (char *) NULL)
234     {
235       ImageInfo
236         *read_info;
237
238       read_info=CloneImageInfo(image_info);
239       SetImageInfoBlob(read_info,(void *) NULL,0);
240       (void) CopyMagickString(read_info->filename,image_info->texture,
241         MaxTextExtent);
242       texture=ReadImage(read_info,exception);
243       read_info=DestroyImageInfo(read_info);
244     }
245   /*
246     Annotate the text image.
247   */
248   (void) SetImageBackgroundColor(image);
249   draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL);
250   (void) CloneString(&draw_info->text,image_info->filename);
251   (void) FormatMagickString(geometry,MaxTextExtent,"0x0%+ld%+ld",(long) page.x,
252     (long) page.y);
253   (void) CloneString(&draw_info->geometry,geometry);
254   status=GetTypeMetrics(image,draw_info,&metrics);
255   if (status == MagickFalse)
256     ThrowReaderException(TypeError,"UnableToGetTypeMetrics");
257   page.y=(ssize_t) ceil((double) page.y+metrics.ascent-0.5);
258   (void) FormatMagickString(geometry,MaxTextExtent,"0x0%+ld%+ld",(long) page.x,
259     (long) page.y);
260   (void) CloneString(&draw_info->geometry,geometry);
261   (void) CopyMagickString(filename,image_info->filename,MaxTextExtent);
262   if (*draw_info->text != '\0')
263     *draw_info->text='\0';
264   p=text;
265   for (offset=2*page.y; p != (char *) NULL; )
266   {
267     /*
268       Annotate image with text.
269     */
270     (void) ConcatenateString(&draw_info->text,text);
271     (void) ConcatenateString(&draw_info->text,"\n");
272     offset+=(ssize_t) (metrics.ascent-metrics.descent);
273     if (image->previous == (Image *) NULL)
274       {
275         status=SetImageProgress(image,LoadImageTag,offset,image->rows);
276         if (status == MagickFalse)
277           break;
278       }
279     p=ReadBlobString(image,text);
280     if ((offset < (ssize_t) image->rows) && (p != (char *) NULL))
281       continue;
282     if (texture != (Image *) NULL)
283       {
284         MagickProgressMonitor
285           progress_monitor;
286
287         progress_monitor=SetImageProgressMonitor(image,
288           (MagickProgressMonitor) NULL,image->client_data);
289         (void) TextureImage(image,texture);
290         (void) SetImageProgressMonitor(image,progress_monitor,
291           image->client_data);
292       }
293     (void) AnnotateImage(image,draw_info);
294     if (p == (char *) NULL)
295       break;
296     /*
297       Page is full-- allocate next image structure.
298     */
299     *draw_info->text='\0';
300     offset=2*page.y;
301     AcquireNextImage(image_info,image);
302     if (GetNextImageInList(image) == (Image *) NULL)
303       {
304         image=DestroyImageList(image);
305         return((Image *) NULL);
306       }
307     image->next->columns=image->columns;
308     image->next->rows=image->rows;
309     image=SyncNextImageInList(image);
310     (void) CopyMagickString(image->filename,filename,MaxTextExtent);
311     (void) SetImageBackgroundColor(image);
312     status=SetImageProgress(image,LoadImagesTag,TellBlob(image),
313       GetBlobSize(image));
314     if (status == MagickFalse)
315       break;
316   }
317   if (texture != (Image *) NULL)
318     {
319       MagickProgressMonitor
320         progress_monitor;
321
322       progress_monitor=SetImageProgressMonitor(image,
323         (MagickProgressMonitor) NULL,image->client_data);
324       (void) TextureImage(image,texture);
325       (void) SetImageProgressMonitor(image,progress_monitor,image->client_data);
326     }
327   (void) AnnotateImage(image,draw_info);
328   if (texture != (Image *) NULL)
329     texture=DestroyImage(texture);
330   draw_info=DestroyDrawInfo(draw_info);
331   (void) CloseBlob(image);
332   return(GetFirstImageInList(image));
333 }
334 \f
335 /*
336 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
337 %                                                                             %
338 %                                                                             %
339 %                                                                             %
340 %   R e a d T X T I m a g e                                                   %
341 %                                                                             %
342 %                                                                             %
343 %                                                                             %
344 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
345 %
346 %  ReadTXTImage() reads a text file and returns it as an image.  It allocates
347 %  the memory necessary for the new Image structure and returns a pointer to
348 %  the new image.
349 %
350 %  The format of the ReadTXTImage method is:
351 %
352 %      Image *ReadTXTImage(const ImageInfo *image_info,ExceptionInfo *exception)
353 %
354 %  A description of each parameter follows:
355 %
356 %    o image_info: the image info.
357 %
358 %    o exception: return any errors or warnings in this structure.
359 %
360 */
361 static Image *ReadTXTImage(const ImageInfo *image_info,ExceptionInfo *exception)
362 {
363   char
364     colorspace[MaxTextExtent],
365     text[MaxTextExtent];
366
367   Image
368     *image;
369
370   IndexPacket
371     *indexes;
372
373   long
374     type,
375     x_offset,
376     y,
377     y_offset;
378
379   LongPixelPacket
380     pixel;
381
382   MagickBooleanType
383     status;
384
385   QuantumAny
386     range;
387
388   register ssize_t
389     i,
390     x;
391
392   register PixelPacket
393     *q;
394
395   ssize_t
396     count;
397
398   unsigned long
399     depth,
400     height,
401     max_value,
402     width;
403
404   /*
405     Open image file.
406   */
407   assert(image_info != (const ImageInfo *) NULL);
408   assert(image_info->signature == MagickSignature);
409   if (image_info->debug != MagickFalse)
410     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
411       image_info->filename);
412   assert(exception != (ExceptionInfo *) NULL);
413   assert(exception->signature == MagickSignature);
414   image=AcquireImage(image_info);
415   status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
416   if (status == MagickFalse)
417     {
418       image=DestroyImageList(image);
419       return((Image *) NULL);
420     }
421   (void) ResetMagickMemory(text,0,sizeof(text));
422   (void) ReadBlobString(image,text);
423   if (LocaleNCompare((char *) text,MagickID,strlen(MagickID)) != 0)
424     return(ReadTEXTImage(image_info,image,text,exception));
425   do
426   {
427     *colorspace='\0';
428     count=(ssize_t) sscanf(text+32,"%lu,%lu,%lu,%s",&width,&height,&max_value,
429       colorspace);
430     if (count != 4)
431       ThrowReaderException(CorruptImageError,"ImproperImageHeader");
432     image->columns=width;
433     image->rows=height;
434     for (depth=1; (GetQuantumRange(depth)+1) < max_value; depth++) ;
435     image->depth=depth;
436     LocaleLower(colorspace);
437     i=(ssize_t) strlen(colorspace)-1;
438     image->matte=MagickFalse;
439     if ((i > 0) && (colorspace[i] == 'a'))
440       {
441         colorspace[i]='\0';
442         image->matte=MagickTrue;
443       }
444     type=ParseMagickOption(MagickColorspaceOptions,MagickFalse,colorspace);
445     if (type < 0)
446       ThrowReaderException(CorruptImageError,"ImproperImageHeader");
447     image->colorspace=(ColorspaceType) type;
448     (void) ResetMagickMemory(&pixel,0,sizeof(pixel));
449     (void) SetImageBackgroundColor(image);
450     range=GetQuantumRange(image->depth);
451     for (y=0; y < (ssize_t) image->rows; y++)
452     {
453       for (x=0; x < (ssize_t) image->columns; x++)
454       {
455         if (ReadBlobString(image,text) == (char *) NULL)
456           break;
457         if (image->colorspace == CMYKColorspace)
458           {
459             if (image->matte != MagickFalse)
460               count=(ssize_t) sscanf(text,"%ld,%ld: (%u,%u,%u,%u,%u",&x_offset,
461                 &y_offset,&pixel.red,&pixel.green,&pixel.blue,&pixel.index,
462                 &pixel.opacity);
463             else
464               count=(ssize_t) sscanf(text,"%ld,%ld: (%u,%u,%u,%u",&x_offset,
465                 &y_offset,&pixel.red,&pixel.green,&pixel.blue,&pixel.index);
466           }
467         else
468           if (image->matte != MagickFalse)
469             count=(ssize_t) sscanf(text,"%ld,%ld: (%u,%u,%u,%u",&x_offset,
470               &y_offset,&pixel.red,&pixel.green,&pixel.blue,&pixel.opacity);
471           else
472             count=(ssize_t) sscanf(text,"%ld,%ld: (%u,%u,%u",&x_offset,
473               &y_offset,&pixel.red,&pixel.green,&pixel.blue);
474         if (count < 5)
475           continue;
476         q=GetAuthenticPixels(image,x_offset,y_offset,1,1,exception);
477         if (q == (PixelPacket *) NULL)
478           continue;
479         q->red=ScaleAnyToQuantum(pixel.red,range);
480         q->green=ScaleAnyToQuantum(pixel.green,range);
481         q->blue=ScaleAnyToQuantum(pixel.blue,range);
482         if (image->colorspace == CMYKColorspace)
483           {
484             indexes=GetAuthenticIndexQueue(image);
485             *indexes=ScaleAnyToQuantum(pixel.index,range);
486           }
487         if (image->matte != MagickFalse)
488           q->opacity=(Quantum) (QuantumRange-ScaleAnyToQuantum(pixel.opacity,
489             range));
490         if (SyncAuthenticPixels(image,exception) == MagickFalse)
491           break;
492       }
493     }
494     (void) ReadBlobString(image,text);
495     if (LocaleNCompare((char *) text,MagickID,strlen(MagickID)) == 0)
496       {
497         /*
498           Allocate next image structure.
499         */
500         AcquireNextImage(image_info,image);
501         if (GetNextImageInList(image) == (Image *) NULL)
502           {
503             image=DestroyImageList(image);
504             return((Image *) NULL);
505           }
506         image=SyncNextImageInList(image);
507         status=SetImageProgress(image,LoadImagesTag,TellBlob(image),
508           GetBlobSize(image));
509         if (status == MagickFalse)
510           break;
511       }
512   } while (LocaleNCompare((char *) text,MagickID,strlen(MagickID)) == 0);
513   (void) CloseBlob(image);
514   return(GetFirstImageInList(image));
515 }
516 \f
517 /*
518 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
519 %                                                                             %
520 %                                                                             %
521 %                                                                             %
522 %   R e g i s t e r T X T I m a g e                                           %
523 %                                                                             %
524 %                                                                             %
525 %                                                                             %
526 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
527 %
528 %  RegisterTXTImage() adds attributes for the TXT image format to the
529 %  list of supported formats.  The attributes include the image format
530 %  tag, a method to read and/or write the format, whether the format
531 %  supports the saving of more than one frame to the same file or blob,
532 %  whether the format supports native in-memory I/O, and a brief
533 %  description of the format.
534 %
535 %  The format of the RegisterTXTImage method is:
536 %
537 %      size_t RegisterTXTImage(void)
538 %
539 */
540 ModuleExport size_t RegisterTXTImage(void)
541 {
542   MagickInfo
543     *entry;
544
545   entry=SetMagickInfo("TEXT");
546   entry->decoder=(DecodeImageHandler *) ReadTXTImage;
547   entry->encoder=(EncodeImageHandler *) WriteTXTImage;
548   entry->raw=MagickTrue;
549   entry->endian_support=MagickTrue;
550   entry->description=ConstantString("Text");
551   entry->module=ConstantString("TXT");
552   (void) RegisterMagickInfo(entry);
553   entry=SetMagickInfo("TXT");
554   entry->decoder=(DecodeImageHandler *) ReadTXTImage;
555   entry->encoder=(EncodeImageHandler *) WriteTXTImage;
556   entry->description=ConstantString("Text");
557   entry->magick=(IsImageFormatHandler *) IsTXT;
558   entry->module=ConstantString("TXT");
559   (void) RegisterMagickInfo(entry);
560   return(MagickImageCoderSignature);
561 }
562 \f
563 /*
564 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
565 %                                                                             %
566 %                                                                             %
567 %                                                                             %
568 %   U n r e g i s t e r T X T I m a g e                                       %
569 %                                                                             %
570 %                                                                             %
571 %                                                                             %
572 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
573 %
574 %  UnregisterTXTImage() removes format registrations made by the
575 %  TXT module from the list of supported format.
576 %
577 %  The format of the UnregisterTXTImage method is:
578 %
579 %      UnregisterTXTImage(void)
580 %
581 */
582 ModuleExport void UnregisterTXTImage(void)
583 {
584   (void) UnregisterMagickInfo("TEXT");
585   (void) UnregisterMagickInfo("TXT");
586 }
587 \f
588 /*
589 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
590 %                                                                             %
591 %                                                                             %
592 %                                                                             %
593 %   W r i t e T X T I m a g e                                                 %
594 %                                                                             %
595 %                                                                             %
596 %                                                                             %
597 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
598 %
599 %  WriteTXTImage writes the pixel values as text numbers.
600 %
601 %  The format of the WriteTXTImage method is:
602 %
603 %      MagickBooleanType WriteTXTImage(const ImageInfo *image_info,Image *image)
604 %
605 %  A description of each parameter follows.
606 %
607 %    o image_info: the image info.
608 %
609 %    o image:  The image.
610 %
611 */
612 static MagickBooleanType WriteTXTImage(const ImageInfo *image_info,Image *image)
613 {
614   char
615     buffer[MaxTextExtent],
616     colorspace[MaxTextExtent],
617     tuple[MaxTextExtent];
618
619   ssize_t
620     y;
621
622   MagickBooleanType
623     status;
624
625   MagickOffsetType
626     scene;
627
628   MagickPixelPacket
629     pixel;
630
631   register const IndexPacket
632     *indexes;
633
634   register const PixelPacket
635     *p;
636
637   register ssize_t
638     x;
639
640   /*
641     Open output image file.
642   */
643   assert(image_info != (const ImageInfo *) NULL);
644   assert(image_info->signature == MagickSignature);
645   assert(image != (Image *) NULL);
646   assert(image->signature == MagickSignature);
647   if (image->debug != MagickFalse)
648     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
649   status=OpenBlob(image_info,image,WriteBlobMode,&image->exception);
650   if (status == MagickFalse)
651     return(status);
652   scene=0;
653   do
654   {
655     (void) CopyMagickString(colorspace,MagickOptionToMnemonic(
656       MagickColorspaceOptions,(ssize_t) image->colorspace),MaxTextExtent);
657     LocaleLower(colorspace);
658     image->depth=GetImageQuantumDepth(image,MagickTrue);
659     if (image->matte != MagickFalse)
660       (void) ConcatenateMagickString(colorspace,"a",MaxTextExtent);
661     (void) FormatMagickString(buffer,MaxTextExtent,
662       "# ImageMagick pixel enumeration: %.20g,%.20g,%.20g,%s\n",(double)
663       image->columns,(double) image->rows,(double)
664       GetQuantumRange(image->depth),colorspace);
665     (void) WriteBlobString(image,buffer);
666     GetMagickPixelPacket(image,&pixel);
667     for (y=0; y < (ssize_t) image->rows; y++)
668     {
669       p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
670       if (p == (const PixelPacket *) NULL)
671         break;
672       indexes=GetVirtualIndexQueue(image);
673       for (x=0; x < (ssize_t) image->columns; x++)
674       {
675         (void) FormatMagickString(buffer,MaxTextExtent,"%.20g,%.20g: ",(double)
676           x,(double) y);
677         (void) WriteBlobString(image,buffer);
678         SetMagickPixelPacket(image,p,indexes+x,&pixel);
679         (void) CopyMagickString(tuple,"(",MaxTextExtent);
680         ConcatenateColorComponent(&pixel,RedChannel,X11Compliance,tuple);
681         (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
682         ConcatenateColorComponent(&pixel,GreenChannel,X11Compliance,tuple);
683         (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
684         ConcatenateColorComponent(&pixel,BlueChannel,X11Compliance,tuple);
685         if (pixel.colorspace == CMYKColorspace)
686           {
687             (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
688             ConcatenateColorComponent(&pixel,IndexChannel,X11Compliance,tuple);
689           }
690         if (pixel.matte != MagickFalse)
691           {
692             (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
693             ConcatenateColorComponent(&pixel,AlphaChannel,X11Compliance,tuple);
694           }
695         (void) ConcatenateMagickString(tuple,")",MaxTextExtent);
696         (void) WriteBlobString(image,tuple);
697         (void) WriteBlobString(image,"  ");
698         GetColorTuple(&pixel,MagickTrue,tuple);
699         (void) FormatMagickString(buffer,MaxTextExtent,"%s",tuple);
700         (void) WriteBlobString(image,buffer);
701         (void) WriteBlobString(image,"  ");
702         (void) QueryMagickColorname(image,&pixel,SVGCompliance,tuple,
703           &image->exception);
704         (void) WriteBlobString(image,tuple);
705         (void) WriteBlobString(image,"\n");
706         p++;
707       }
708       status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
709         image->rows);
710       if (status == MagickFalse)
711         break;
712     }
713     if (GetNextImageInList(image) == (Image *) NULL)
714       break;
715     image=SyncNextImageInList(image);
716     status=SetImageProgress(image,SaveImagesTag,scene++,
717       GetImageListLength(image));
718     if (status == MagickFalse)
719       break;
720   } while (image_info->adjoin != MagickFalse);
721   (void) CloseBlob(image);
722   return(MagickTrue);
723 }