2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13 % Read/Write HP PCL Printer Format %
20 % Copyright 1999-2014 ImageMagick Studio LLC, a non-profit organization %
21 % dedicated to making software imaging solutions freely available. %
23 % You may not use this file except in compliance with the License. You may %
24 % obtain a copy of the License at %
26 % http://www.imagemagick.org/script/license.php %
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. %
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
42 #include "MagickCore/studio.h"
43 #include "MagickCore/artifact.h"
44 #include "MagickCore/attribute.h"
45 #include "MagickCore/blob.h"
46 #include "MagickCore/blob-private.h"
47 #include "MagickCore/cache.h"
48 #include "MagickCore/color.h"
49 #include "MagickCore/color-private.h"
50 #include "MagickCore/colorspace.h"
51 #include "MagickCore/colorspace-private.h"
52 #include "MagickCore/constitute.h"
53 #include "MagickCore/delegate.h"
54 #include "MagickCore/draw.h"
55 #include "MagickCore/exception.h"
56 #include "MagickCore/exception-private.h"
57 #include "MagickCore/geometry.h"
58 #include "MagickCore/image.h"
59 #include "MagickCore/image-private.h"
60 #include "MagickCore/list.h"
61 #include "MagickCore/magick.h"
62 #include "MagickCore/memory_.h"
63 #include "MagickCore/monitor.h"
64 #include "MagickCore/monitor-private.h"
65 #include "MagickCore/option.h"
66 #include "MagickCore/pixel-accessor.h"
67 #include "MagickCore/profile.h"
68 #include "MagickCore/property.h"
69 #include "MagickCore/resource_.h"
70 #include "MagickCore/quantum-private.h"
71 #include "MagickCore/static.h"
72 #include "MagickCore/string_.h"
73 #include "MagickCore/module.h"
74 #include "MagickCore/token.h"
75 #include "MagickCore/transform.h"
76 #include "MagickCore/utility.h"
81 static MagickBooleanType
82 WritePCLImage(const ImageInfo *,Image *,ExceptionInfo *);
85 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
93 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
95 % IsPCL() returns MagickTrue if the image format type, identified by the
96 % magick string, is PCL.
98 % The format of the IsPCL method is:
100 % MagickBooleanType IsPCL(const unsigned char *magick,const size_t length)
102 % A description of each parameter follows:
104 % o magick: compare image format pattern against these bytes.
106 % o length: Specifies the length of the magick string.
109 static MagickBooleanType IsPCL(const unsigned char *magick,const size_t length)
113 if (memcmp(magick,"\033E\033&",4) == 0)
115 if (memcmp(magick,"\033E\033",3) == 0)
121 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
125 % R e a d P C L I m a g e %
129 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
131 % ReadPCLImage() reads a Printer Control Language image file and returns it.
132 % It allocates the memory necessary for the new Image structure and returns a
133 % pointer to the new image.
135 % The format of the ReadPCLImage method is:
137 % Image *ReadPCLImage(const ImageInfo *image_info,ExceptionInfo *exception)
139 % A description of each parameter follows:
141 % o image_info: the image info.
143 % o exception: return any errors or warnings in this structure.
146 static Image *ReadPCLImage(const ImageInfo *image_info,ExceptionInfo *exception)
148 #define CropBox "CropBox"
149 #define DeviceCMYK "DeviceCMYK"
150 #define MediaBox "MediaBox"
151 #define RenderPCLText " Rendering PCL... "
154 command[MaxTextExtent],
155 density[MaxTextExtent],
156 filename[MaxTextExtent],
157 geometry[MaxTextExtent],
158 options[MaxTextExtent],
159 input_filename[MaxTextExtent];
201 assert(image_info != (const ImageInfo *) NULL);
202 assert(image_info->signature == MagickSignature);
203 if (image_info->debug != MagickFalse)
204 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
205 image_info->filename);
206 assert(exception != (ExceptionInfo *) NULL);
207 assert(exception->signature == MagickSignature);
211 image=AcquireImage(image_info,exception);
212 status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
213 if (status == MagickFalse)
215 image=DestroyImageList(image);
216 return((Image *) NULL);
218 status=AcquireUniqueSymbolicLink(image_info->filename,input_filename);
219 if (status == MagickFalse)
221 ThrowFileException(exception,FileOpenError,"UnableToCreateTemporaryFile",
222 image_info->filename);
223 image=DestroyImageList(image);
224 return((Image *) NULL);
227 Set the page density.
229 delta.x=DefaultResolution;
230 delta.y=DefaultResolution;
231 if ((image->resolution.x == 0.0) || (image->resolution.y == 0.0))
239 flags=ParseGeometry(PSDensityGeometry,&geometry_info);
240 image->resolution.x=geometry_info.rho;
241 image->resolution.y=geometry_info.sigma;
242 if ((flags & SigmaValue) == 0)
243 image->resolution.y=image->resolution.x;
246 Determine page geometry from the PCL media box.
248 cmyk=image->colorspace == CMYKColorspace ? MagickTrue : MagickFalse;
250 (void) ResetMagickMemory(&bounding_box,0,sizeof(bounding_box));
251 (void) ResetMagickMemory(&bounds,0,sizeof(bounds));
252 (void) ResetMagickMemory(&page,0,sizeof(page));
253 (void) ResetMagickMemory(command,0,sizeof(command));
255 for (c=ReadBlobByte(image); c != EOF; c=ReadBlobByte(image))
257 if (image_info->page != (char *) NULL)
263 if ((c != (int) '/') && (c != '\n') &&
264 ((size_t) (p-command) < (MaxTextExtent-1)))
269 Is this a CMYK document?
271 if (LocaleNCompare(DeviceCMYK,command,strlen(DeviceCMYK)) == 0)
273 if (LocaleNCompare(CropBox,command,strlen(CropBox)) == 0)
276 Note region defined by crop box.
278 count=(ssize_t) sscanf(command,"CropBox [%lf %lf %lf %lf",
279 &bounds.x1,&bounds.y1,&bounds.x2,&bounds.y2);
281 count=(ssize_t) sscanf(command,"CropBox[%lf %lf %lf %lf",
282 &bounds.x1,&bounds.y1,&bounds.x2,&bounds.y2);
284 if (LocaleNCompare(MediaBox,command,strlen(MediaBox)) == 0)
287 Note region defined by media box.
289 count=(ssize_t) sscanf(command,"MediaBox [%lf %lf %lf %lf",
290 &bounds.x1,&bounds.y1,&bounds.x2,&bounds.y2);
292 count=(ssize_t) sscanf(command,"MediaBox[%lf %lf %lf %lf",
293 &bounds.x1,&bounds.y1,&bounds.x2,&bounds.y2);
298 Set PCL render geometry.
300 width=(size_t) floor(bounds.x2-bounds.x1+0.5);
301 height=(size_t) floor(bounds.y2-bounds.y1+0.5);
302 if (width > page.width)
304 if (height > page.height)
307 (void) CloseBlob(image);
309 Render PCL with the GhostPCL delegate.
311 if ((page.width == 0) || (page.height == 0))
312 (void) ParseAbsoluteGeometry(PSPageGeometry,&page);
313 if (image_info->page != (char *) NULL)
314 (void) ParseAbsoluteGeometry(image_info->page,&page);
315 (void) FormatLocaleString(geometry,MaxTextExtent,"%.20gx%.20g",(double)
316 page.width,(double) page.height);
317 if (image_info->monochrome != MagickFalse)
318 delegate_info=GetDelegateInfo("pcl:mono",(char *) NULL,exception);
320 if (cmyk != MagickFalse)
321 delegate_info=GetDelegateInfo("pcl:cmyk",(char *) NULL,exception);
323 delegate_info=GetDelegateInfo("pcl:color",(char *) NULL,exception);
324 if (delegate_info == (const DelegateInfo *) NULL)
325 return((Image *) NULL);
327 if ((page.width == 0) || (page.height == 0))
328 (void) ParseAbsoluteGeometry(PSPageGeometry,&page);
329 if (image_info->page != (char *) NULL)
330 (void) ParseAbsoluteGeometry(image_info->page,&page);
331 (void) FormatLocaleString(density,MaxTextExtent,"%gx%g",
332 image->resolution.x,image->resolution.y);
333 page.width=(size_t) floor(page.width*image->resolution.x/delta.x+0.5);
334 page.height=(size_t) floor(page.height*image->resolution.y/delta.y+
336 (void) FormatLocaleString(options,MaxTextExtent,"-g%.20gx%.20g ",(double)
337 page.width,(double) page.height);
338 image=DestroyImage(image);
339 read_info=CloneImageInfo(image_info);
340 *read_info->magick='\0';
341 if (read_info->number_scenes != 0)
343 if (read_info->number_scenes != 1)
344 (void) FormatLocaleString(options,MaxTextExtent,"-dLastPage=%.20g",
345 (double) (read_info->scene+read_info->number_scenes));
347 (void) FormatLocaleString(options,MaxTextExtent,
348 "-dFirstPage=%.20g -dLastPage=%.20g",(double) read_info->scene+1,
349 (double) (read_info->scene+read_info->number_scenes));
350 read_info->number_scenes=0;
351 if (read_info->scenes != (char *) NULL)
352 *read_info->scenes='\0';
354 option=GetImageOption(image_info,"authenticate");
355 if (option != (const char *) NULL)
356 (void) FormatLocaleString(options+strlen(options),MaxTextExtent,
357 " -sPCLPassword=%s",option);
358 (void) CopyMagickString(filename,read_info->filename,MaxTextExtent);
359 (void) AcquireUniqueFilename(read_info->filename);
360 (void) FormatLocaleString(command,MaxTextExtent,
361 GetDelegateCommands(delegate_info),
362 read_info->antialias != MagickFalse ? 4 : 1,
363 read_info->antialias != MagickFalse ? 4 : 1,density,options,
364 read_info->filename,input_filename);
365 status=SystemCommand(MagickFalse,read_info->verbose,command,exception) != 0 ?
366 MagickTrue : MagickFalse;
367 image=ReadImage(read_info,exception);
368 (void) RelinquishUniqueFileResource(read_info->filename);
369 (void) RelinquishUniqueFileResource(input_filename);
370 read_info=DestroyImageInfo(read_info);
371 if (image == (Image *) NULL)
372 ThrowReaderException(DelegateError,"PCLDelegateFailed");
373 if (LocaleCompare(image->magick,"BMP") == 0)
378 cmyk_image=ConsolidateCMYKImages(image,exception);
379 if (cmyk_image != (Image *) NULL)
381 image=DestroyImageList(image);
387 (void) CopyMagickString(image->filename,filename,MaxTextExtent);
389 next_image=SyncNextImageInList(image);
390 if (next_image != (Image *) NULL)
392 } while (next_image != (Image *) NULL);
393 return(GetFirstImageInList(image));
397 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
401 % R e g i s t e r P C L I m a g e %
405 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
407 % RegisterPCLImage() adds attributes for the PCL image format to
408 % the list of supported formats. The attributes include the image format
409 % tag, a method to read and/or write the format, whether the format
410 % supports the saving of more than one frame to the i file or blob,
411 % whether the format supports native in-memory I/O, and a brief
412 % description of the format.
414 % The format of the RegisterPCLImage method is:
416 % size_t RegisterPCLImage(void)
419 ModuleExport size_t RegisterPCLImage(void)
424 entry=SetMagickInfo("PCL");
425 entry->decoder=(DecodeImageHandler *) ReadPCLImage;
426 entry->encoder=(EncodeImageHandler *) WritePCLImage;
427 entry->magick=(IsImageFormatHandler *) IsPCL;
428 entry->blob_support=MagickFalse;
429 entry->seekable_stream=MagickTrue;
430 entry->thread_support=EncoderThreadSupport;
431 entry->description=ConstantString("Printer Control Language");
432 entry->module=ConstantString("PCL");
433 (void) RegisterMagickInfo(entry);
434 return(MagickImageCoderSignature);
438 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
442 % U n r e g i s t e r P C L I m a g e %
446 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
448 % UnregisterPCLImage() removes format registrations made by the PCL module
449 % from the list of supported formats.
451 % The format of the UnregisterPCLImage method is:
453 % UnregisterPCLImage(void)
456 ModuleExport void UnregisterPCLImage(void)
458 (void) UnregisterMagickInfo("PCL");
462 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
466 % W r i t e P C L I m a g e %
470 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
472 % WritePCLImage() writes an image in the Page Control Language encoded
475 % The format of the WritePCLImage method is:
477 % MagickBooleanType WritePCLImage(const ImageInfo *image_info,
478 % Image *image,ExceptionInfo *exception)
480 % A description of each parameter follows.
482 % o image_info: the image info.
484 % o image: The image.
486 % o exception: return any errors or warnings in this structure.
490 static size_t PCLDeltaCompressImage(const size_t length,
491 const unsigned char *previous_pixels,const unsigned char *pixels,
492 unsigned char *compress_pixels)
503 register unsigned char
507 for (x=0; x < (ssize_t) length; )
510 for (i=0; x < (ssize_t) length; x++)
512 if (*pixels++ != *previous_pixels++)
519 while (x < (ssize_t) length)
522 if (*pixels == *previous_pixels)
530 replacement=j >= 31 ? 31 : j;
532 delta=i >= 8 ? 8 : i;
533 *q++=(unsigned char) (((delta-1) << 5) | replacement);
534 if (replacement == 31)
536 for (replacement=255; j != 0; )
540 *q++=(unsigned char) replacement;
543 if (replacement == 255)
546 for (pixels-=i; i != 0; )
548 for (i-=delta; delta != 0; delta--)
555 *q++=(unsigned char) ((delta-1) << 5);
558 return((size_t) (q-compress_pixels));
561 static size_t PCLPackbitsCompressImage(const size_t length,
562 const unsigned char *pixels,unsigned char *compress_pixels)
570 register unsigned char
580 Compress pixels with Packbits encoding.
583 for (x=(ssize_t) length; x != 0; )
605 if ((*pixels == *(pixels+1)) && (*(pixels+1) == *(pixels+2)))
607 *q++=(unsigned char) ((256-3)+1);
619 if ((*pixels == *(pixels+1)) && (*(pixels+1) == *(pixels+2)))
625 while (((ssize_t) count < x) && (*pixels == *(pixels+count)))
632 *q++=(unsigned char) ((256-count)+1);
641 while ((*(pixels+count) != *(pixels+count+1)) ||
642 (*(pixels+count+1) != *(pixels+count+2)))
644 packbits[count+1]=pixels[count];
646 if (((ssize_t) count >= (x-3)) || (count >= 127))
650 *packbits=(unsigned char) (count-1);
651 for (j=0; j <= (ssize_t) count; j++)
658 *q++=128; /* EOD marker */
659 return((size_t) (q-compress_pixels));
662 static MagickBooleanType WritePCLImage(const ImageInfo *image_info,Image *image,
663 ExceptionInfo *exception)
666 buffer[MaxTextExtent];
680 register const Quantum *p;
682 register ssize_t i, x;
684 register unsigned char *q;
702 Open output image file.
704 assert(image_info != (const ImageInfo *) NULL);
705 assert(image_info->signature == MagickSignature);
706 assert(image != (Image *) NULL);
707 assert(image->signature == MagickSignature);
708 if (image->debug != MagickFalse)
709 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
710 assert(exception != (ExceptionInfo *) NULL);
711 assert(exception->signature == MagickSignature);
712 status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception);
713 if (status == MagickFalse)
716 if (image_info->density != (char *) NULL)
721 (void) ParseGeometry(image_info->density,&geometry);
722 density=(size_t) geometry.rho;
728 if (IssRGBCompatibleColorspace(image->colorspace) == MagickFalse)
729 (void) TransformImageColorspace(image,sRGBColorspace,exception);
731 Initialize the printer.
733 (void) WriteBlobString(image,"\033E"); /* printer reset */
734 (void) WriteBlobString(image,"\033*r3F"); /* set presentation mode */
735 (void) FormatLocaleString(buffer,MaxTextExtent,"\033*r%.20gs%.20gT",
736 (double) image->columns,(double) image->rows);
737 (void) WriteBlobString(image,buffer);
738 (void) FormatLocaleString(buffer,MaxTextExtent,"\033*t%.20gR",(double)
740 (void) WriteBlobString(image,buffer);
741 (void) WriteBlobString(image,"\033&l0E"); /* top margin 0 */
742 if (IsImageMonochrome(image,exception) != MagickFalse)
745 Monochrome image: use default printer monochrome setup.
750 if (image->storage_class == DirectClass)
756 (void) WriteBlobString(image,"\033*v6W"); /* set color mode */
757 (void) WriteBlobByte(image,0); /* RGB */
758 (void) WriteBlobByte(image,3); /* direct by pixel */
759 (void) WriteBlobByte(image,0); /* bits per index (ignored) */
760 (void) WriteBlobByte(image,8); /* bits per red component */
761 (void) WriteBlobByte(image,8); /* bits per green component */
762 (void) WriteBlobByte(image,8); /* bits per blue component */
770 (void) WriteBlobString(image,"\033*v6W"); /* set color mode... */
771 (void) WriteBlobByte(image,0); /* RGB */
772 (void) WriteBlobByte(image,1); /* indexed by pixel */
773 (void) WriteBlobByte(image,bits_per_pixel); /* bits per index */
774 (void) WriteBlobByte(image,8); /* bits per red component */
775 (void) WriteBlobByte(image,8); /* bits per green component */
776 (void) WriteBlobByte(image,8); /* bits per blue component */
777 for (i=0; i < (ssize_t) image->colors; i++)
779 (void) FormatLocaleString(buffer,MaxTextExtent,
780 "\033*v%da%db%dc%.20gI",
781 ScaleQuantumToChar(image->colormap[i].red),
782 ScaleQuantumToChar(image->colormap[i].green),
783 ScaleQuantumToChar(image->colormap[i].blue),(double) i);
784 (void) WriteBlobString(image,buffer);
786 for (one=1; i < (ssize_t) (one << bits_per_pixel); i++)
788 (void) FormatLocaleString(buffer,MaxTextExtent,"\033*v%.20gI",
790 (void) WriteBlobString(image,buffer);
793 option=GetImageOption(image_info,"pcl:fit-to-page");
794 if (IfMagickTrue(IsStringTrue(option)))
795 (void) WriteBlobString(image,"\033*r3A");
797 (void) WriteBlobString(image,"\033*r1A"); /* start raster graphics */
798 (void) WriteBlobString(image,"\033*b0Y"); /* set y offset */
799 length=(image->columns*bits_per_pixel+7)/8;
800 pixels=(unsigned char *) AcquireQuantumMemory(length+1,sizeof(*pixels));
801 if (pixels == (unsigned char *) NULL)
802 ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
803 (void) ResetMagickMemory(pixels,0,(length+1)*sizeof(*pixels));
804 compress_pixels=(unsigned char *) NULL;
805 previous_pixels=(unsigned char *) NULL;
807 compression=UndefinedCompression;
808 if (image_info->compression != UndefinedCompression)
809 compression=image_info->compression;
814 (void) FormatLocaleString(buffer,MaxTextExtent,"\033*b0M");
815 (void) WriteBlobString(image,buffer);
820 compress_pixels=(unsigned char *) AcquireQuantumMemory(length+256,
821 sizeof(*compress_pixels));
822 if (compress_pixels == (unsigned char *) NULL)
824 pixels=(unsigned char *) RelinquishMagickMemory(pixels);
825 ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
827 (void) ResetMagickMemory(compress_pixels,0,(length+256)*
828 sizeof(*compress_pixels));
829 (void) FormatLocaleString(buffer,MaxTextExtent,"\033*b2M");
830 (void) WriteBlobString(image,buffer);
835 compress_pixels=(unsigned char *) AcquireQuantumMemory(3*length+256,
836 sizeof(*compress_pixels));
837 if (compress_pixels == (unsigned char *) NULL)
839 pixels=(unsigned char *) RelinquishMagickMemory(pixels);
840 ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
842 (void) ResetMagickMemory(compress_pixels,0,(3*length+256)*
843 sizeof(*compress_pixels));
844 previous_pixels=(unsigned char *) AcquireQuantumMemory(length+1,
845 sizeof(*previous_pixels));
846 if (previous_pixels == (unsigned char *) NULL)
848 compress_pixels=(unsigned char *) RelinquishMagickMemory(
850 pixels=(unsigned char *) RelinquishMagickMemory(pixels);
851 ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
853 (void) ResetMagickMemory(previous_pixels,0,(length+1)*
854 sizeof(*previous_pixels));
855 (void) FormatLocaleString(buffer,MaxTextExtent,"\033*b3M");
856 (void) WriteBlobString(image,buffer);
860 for (y=0; y < (ssize_t) image->rows; y++)
862 p=GetVirtualPixels(image,0,y,image->columns,1,exception);
863 if (p == (const Quantum *) NULL)
866 switch (bits_per_pixel)
870 register unsigned char
879 for (x=0; x < (ssize_t) image->columns; x++)
882 if (GetPixelLuma(image,p) < (QuantumRange/2.0))
891 p+=GetPixelChannels(image);
894 *q++=byte << (8-bit);
902 for (x=0; x < (ssize_t) image->columns; x++)
904 *q++=(unsigned char) GetPixelIndex(image,p);
905 p+=GetPixelChannels(image);
915 for (x=0; x < (ssize_t) image->columns; x++)
917 *q++=ScaleQuantumToChar(GetPixelRed(image,p));
918 *q++=ScaleQuantumToChar(GetPixelGreen(image,p));
919 *q++=ScaleQuantumToChar(GetPixelBlue(image,p));
920 p+=GetPixelChannels(image);
929 (void) FormatLocaleString(buffer,MaxTextExtent,"\033*b%.20gW",
931 (void) WriteBlobString(image,buffer);
932 (void) WriteBlob(image,length,pixels);
937 packets=PCLPackbitsCompressImage(length,pixels,compress_pixels);
938 (void) FormatLocaleString(buffer,MaxTextExtent,"\033*b%.20gW",
940 (void) WriteBlobString(image,buffer);
941 (void) WriteBlob(image,packets,compress_pixels);
947 for (i=0; i < (ssize_t) length; i++)
948 previous_pixels[i]=(~pixels[i]);
949 packets=PCLDeltaCompressImage(length,previous_pixels,pixels,
951 (void) FormatLocaleString(buffer,MaxTextExtent,"\033*b%.20gW",
953 (void) WriteBlobString(image,buffer);
954 (void) WriteBlob(image,packets,compress_pixels);
955 (void) CopyMagickMemory(previous_pixels,pixels,length*
961 (void) WriteBlobString(image,"\033*rB"); /* end graphics */
968 compress_pixels=(unsigned char *) RelinquishMagickMemory(
974 previous_pixels=(unsigned char *) RelinquishMagickMemory(
976 compress_pixels=(unsigned char *) RelinquishMagickMemory(
981 pixels=(unsigned char *) RelinquishMagickMemory(pixels);
982 if (GetNextImageInList(image) == (Image *) NULL)
984 image=SyncNextImageInList(image);
985 status=SetImageProgress(image,SaveImagesTag,scene++,
986 GetImageListLength(image));
987 if (status == MagickFalse)
989 } while (image_info->adjoin != MagickFalse);
990 (void) WriteBlobString(image,"\033E");
991 (void) CloseBlob(image);