2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13 % Read/Write HP PCL Printer Format %
20 % Copyright 1999-2012 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/attribute.h"
44 #include "MagickCore/blob.h"
45 #include "MagickCore/blob-private.h"
46 #include "MagickCore/cache.h"
47 #include "MagickCore/color.h"
48 #include "MagickCore/color-private.h"
49 #include "MagickCore/colorspace.h"
50 #include "MagickCore/colorspace-private.h"
51 #include "MagickCore/constitute.h"
52 #include "MagickCore/delegate.h"
53 #include "MagickCore/draw.h"
54 #include "MagickCore/exception.h"
55 #include "MagickCore/exception-private.h"
56 #include "MagickCore/geometry.h"
57 #include "MagickCore/image.h"
58 #include "MagickCore/image-private.h"
59 #include "MagickCore/list.h"
60 #include "MagickCore/magick.h"
61 #include "MagickCore/memory_.h"
62 #include "MagickCore/monitor.h"
63 #include "MagickCore/monitor-private.h"
64 #include "MagickCore/option.h"
65 #include "MagickCore/pixel-accessor.h"
66 #include "MagickCore/profile.h"
67 #include "MagickCore/property.h"
68 #include "MagickCore/resource_.h"
69 #include "MagickCore/quantum-private.h"
70 #include "MagickCore/static.h"
71 #include "MagickCore/string_.h"
72 #include "MagickCore/module.h"
73 #include "MagickCore/token.h"
74 #include "MagickCore/transform.h"
75 #include "MagickCore/utility.h"
80 static MagickBooleanType
81 WritePCLImage(const ImageInfo *,Image *,ExceptionInfo *);
84 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
92 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
94 % IsPCL() returns MagickTrue if the image format type, identified by the
95 % magick string, is PCL.
97 % The format of the IsPCL method is:
99 % MagickBooleanType IsPCL(const unsigned char *magick,const size_t length)
101 % A description of each parameter follows:
103 % o magick: compare image format pattern against these bytes.
105 % o length: Specifies the length of the magick string.
108 static MagickBooleanType IsPCL(const unsigned char *magick,const size_t length)
112 if (memcmp(magick,"\033E\033&",4) == 0)
114 if (memcmp(magick,"\033E\033",3) == 0)
120 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
124 % R e a d P C L I m a g e %
128 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
130 % ReadPCLImage() reads a Printer Control Language image file and returns it.
131 % It allocates the memory necessary for the new Image structure and returns a
132 % pointer to the new image.
134 % The format of the ReadPCLImage method is:
136 % Image *ReadPCLImage(const ImageInfo *image_info,ExceptionInfo *exception)
138 % A description of each parameter follows:
140 % o image_info: the image info.
142 % o exception: return any errors or warnings in this structure.
145 static Image *ReadPCLImage(const ImageInfo *image_info,ExceptionInfo *exception)
147 #define CropBox "CropBox"
148 #define DeviceCMYK "DeviceCMYK"
149 #define MediaBox "MediaBox"
150 #define RenderPCLText " Rendering PCL... "
153 command[MaxTextExtent],
154 density[MaxTextExtent],
155 filename[MaxTextExtent],
156 geometry[MaxTextExtent],
157 options[MaxTextExtent],
158 input_filename[MaxTextExtent];
200 assert(image_info != (const ImageInfo *) NULL);
201 assert(image_info->signature == MagickSignature);
202 if (image_info->debug != MagickFalse)
203 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
204 image_info->filename);
205 assert(exception != (ExceptionInfo *) NULL);
206 assert(exception->signature == MagickSignature);
210 image=AcquireImage(image_info,exception);
211 status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
212 if (status == MagickFalse)
214 image=DestroyImageList(image);
215 return((Image *) NULL);
217 status=AcquireUniqueSymbolicLink(image_info->filename,input_filename);
218 if (status == MagickFalse)
220 ThrowFileException(exception,FileOpenError,"UnableToCreateTemporaryFile",
221 image_info->filename);
222 image=DestroyImageList(image);
223 return((Image *) NULL);
226 Set the page density.
228 delta.x=DefaultResolution;
229 delta.y=DefaultResolution;
230 if ((image->resolution.x == 0.0) || (image->resolution.y == 0.0))
238 flags=ParseGeometry(PSDensityGeometry,&geometry_info);
239 image->resolution.x=geometry_info.rho;
240 image->resolution.y=geometry_info.sigma;
241 if ((flags & SigmaValue) == 0)
242 image->resolution.y=image->resolution.x;
245 Determine page geometry from the PCL media box.
247 cmyk=image->colorspace == CMYKColorspace ? MagickTrue : MagickFalse;
249 (void) ResetMagickMemory(&bounding_box,0,sizeof(bounding_box));
250 (void) ResetMagickMemory(&bounds,0,sizeof(bounds));
251 (void) ResetMagickMemory(&page,0,sizeof(page));
252 (void) ResetMagickMemory(command,0,sizeof(command));
254 for (c=ReadBlobByte(image); c != EOF; c=ReadBlobByte(image))
256 if (image_info->page != (char *) NULL)
262 if ((c != (int) '/') && (c != '\n') &&
263 ((size_t) (p-command) < (MaxTextExtent-1)))
268 Is this a CMYK document?
270 if (LocaleNCompare(DeviceCMYK,command,strlen(DeviceCMYK)) == 0)
272 if (LocaleNCompare(CropBox,command,strlen(CropBox)) == 0)
275 Note region defined by crop box.
277 count=(ssize_t) sscanf(command,"CropBox [%lf %lf %lf %lf",
278 &bounds.x1,&bounds.y1,&bounds.x2,&bounds.y2);
280 count=(ssize_t) sscanf(command,"CropBox[%lf %lf %lf %lf",
281 &bounds.x1,&bounds.y1,&bounds.x2,&bounds.y2);
283 if (LocaleNCompare(MediaBox,command,strlen(MediaBox)) == 0)
286 Note region defined by media box.
288 count=(ssize_t) sscanf(command,"MediaBox [%lf %lf %lf %lf",
289 &bounds.x1,&bounds.y1,&bounds.x2,&bounds.y2);
291 count=(ssize_t) sscanf(command,"MediaBox[%lf %lf %lf %lf",
292 &bounds.x1,&bounds.y1,&bounds.x2,&bounds.y2);
297 Set PCL render geometry.
299 width=(size_t) floor(bounds.x2-bounds.x1+0.5);
300 height=(size_t) floor(bounds.y2-bounds.y1+0.5);
301 if (width > page.width)
303 if (height > page.height)
306 (void) CloseBlob(image);
308 Render PCL with the GhostPCL delegate.
310 if ((page.width == 0) || (page.height == 0))
311 (void) ParseAbsoluteGeometry(PSPageGeometry,&page);
312 if (image_info->page != (char *) NULL)
313 (void) ParseAbsoluteGeometry(image_info->page,&page);
314 (void) FormatLocaleString(geometry,MaxTextExtent,"%.20gx%.20g",(double)
315 page.width,(double) page.height);
316 if (image_info->monochrome != MagickFalse)
317 delegate_info=GetDelegateInfo("pcl:mono",(char *) NULL,exception);
319 if (cmyk != MagickFalse)
320 delegate_info=GetDelegateInfo("pcl:cmyk",(char *) NULL,exception);
322 delegate_info=GetDelegateInfo("pcl:color",(char *) NULL,exception);
323 if (delegate_info == (const DelegateInfo *) NULL)
324 return((Image *) NULL);
326 if ((page.width == 0) || (page.height == 0))
327 (void) ParseAbsoluteGeometry(PSPageGeometry,&page);
328 if (image_info->page != (char *) NULL)
329 (void) ParseAbsoluteGeometry(image_info->page,&page);
330 (void) FormatLocaleString(density,MaxTextExtent,"%gx%g",
331 image->resolution.x,image->resolution.y);
332 page.width=(size_t) floor(page.width*image->resolution.x/delta.x+0.5);
333 page.height=(size_t) floor(page.height*image->resolution.y/delta.y+
335 (void) FormatLocaleString(options,MaxTextExtent,"-g%.20gx%.20g ",(double)
336 page.width,(double) page.height);
337 image=DestroyImage(image);
338 read_info=CloneImageInfo(image_info);
339 *read_info->magick='\0';
340 if (read_info->number_scenes != 0)
342 if (read_info->number_scenes != 1)
343 (void) FormatLocaleString(options,MaxTextExtent,"-dLastPage=%.20g",
344 (double) (read_info->scene+read_info->number_scenes));
346 (void) FormatLocaleString(options,MaxTextExtent,
347 "-dFirstPage=%.20g -dLastPage=%.20g",(double) read_info->scene+1,
348 (double) (read_info->scene+read_info->number_scenes));
349 read_info->number_scenes=0;
350 if (read_info->scenes != (char *) NULL)
351 *read_info->scenes='\0';
353 option=GetImageOption(read_info,"authenticate");
354 if (option != (const char *) NULL)
355 (void) FormatLocaleString(options+strlen(options),MaxTextExtent,
356 " -sPCLPassword=%s",option);
357 (void) CopyMagickString(filename,read_info->filename,MaxTextExtent);
358 (void) AcquireUniqueFilename(read_info->filename);
359 (void) FormatLocaleString(command,MaxTextExtent,
360 GetDelegateCommands(delegate_info),
361 read_info->antialias != MagickFalse ? 4 : 1,
362 read_info->antialias != MagickFalse ? 4 : 1,density,options,
363 read_info->filename,input_filename);
364 status=SystemCommand(MagickFalse,read_info->verbose,command,exception) != 0 ?
365 MagickTrue : MagickFalse;
366 image=ReadImage(read_info,exception);
367 (void) RelinquishUniqueFileResource(read_info->filename);
368 (void) RelinquishUniqueFileResource(input_filename);
369 read_info=DestroyImageInfo(read_info);
370 if (image == (Image *) NULL)
371 ThrowReaderException(DelegateError,"PCLDelegateFailed");
372 if (LocaleCompare(image->magick,"BMP") == 0)
377 cmyk_image=ConsolidateCMYKImages(image,exception);
378 if (cmyk_image != (Image *) NULL)
380 image=DestroyImageList(image);
386 (void) CopyMagickString(image->filename,filename,MaxTextExtent);
388 next_image=SyncNextImageInList(image);
389 if (next_image != (Image *) NULL)
391 } while (next_image != (Image *) NULL);
392 return(GetFirstImageInList(image));
396 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
400 % R e g i s t e r P C L I m a g e %
404 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
406 % RegisterPCLImage() adds attributes for the PCL image format to
407 % the list of supported formats. The attributes include the image format
408 % tag, a method to read and/or write the format, whether the format
409 % supports the saving of more than one frame to the i file or blob,
410 % whether the format supports native in-memory I/O, and a brief
411 % description of the format.
413 % The format of the RegisterPCLImage method is:
415 % size_t RegisterPCLImage(void)
418 ModuleExport size_t RegisterPCLImage(void)
423 entry=SetMagickInfo("PCL");
424 entry->decoder=(DecodeImageHandler *) ReadPCLImage;
425 entry->encoder=(EncodeImageHandler *) WritePCLImage;
426 entry->magick=(IsImageFormatHandler *) IsPCL;
427 entry->blob_support=MagickFalse;
428 entry->seekable_stream=MagickTrue;
429 entry->thread_support=EncoderThreadSupport;
430 entry->description=ConstantString("Printer Control Language");
431 entry->module=ConstantString("PCL");
432 (void) RegisterMagickInfo(entry);
433 return(MagickImageCoderSignature);
437 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
441 % U n r e g i s t e r P C L I m a g e %
445 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
447 % UnregisterPCLImage() removes format registrations made by the PCL module
448 % from the list of supported formats.
450 % The format of the UnregisterPCLImage method is:
452 % UnregisterPCLImage(void)
455 ModuleExport void UnregisterPCLImage(void)
457 (void) UnregisterMagickInfo("PCL");
461 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
465 % W r i t e P C L I m a g e %
469 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
471 % WritePCLImage() writes an image in the Page Control Language encoded
474 % The format of the WritePCLImage method is:
476 % MagickBooleanType WritePCLImage(const ImageInfo *image_info,
477 % Image *image,ExceptionInfo *exception)
479 % A description of each parameter follows.
481 % o image_info: the image info.
483 % o image: The image.
485 % o exception: return any errors or warnings in this structure.
489 static size_t PCLDeltaCompressImage(const size_t length,
490 const unsigned char *previous_pixels,const unsigned char *pixels,
491 unsigned char *compress_pixels)
502 register unsigned char
506 for (x=0; x < (ssize_t) length; )
509 for (i=0; x < (ssize_t) length; x++)
511 if (*pixels++ != *previous_pixels++)
518 while (x < (ssize_t) length)
521 if (*pixels == *previous_pixels)
529 replacement=j >= 31 ? 31 : j;
531 delta=i >= 8 ? 8 : i;
532 *q++=(unsigned char) (((delta-1) << 5) | replacement);
533 if (replacement == 31)
535 for (replacement=255; j != 0; )
539 *q++=(unsigned char) replacement;
542 if (replacement == 255)
545 for (pixels-=i; i != 0; )
547 for (i-=delta; delta != 0; delta--)
554 *q++=(unsigned char) ((delta-1) << 5);
557 return((size_t) (q-compress_pixels));
560 static size_t PCLPackbitsCompressImage(const size_t length,
561 const unsigned char *pixels,unsigned char *compress_pixels)
569 register unsigned char
579 Compress pixels with Packbits encoding.
582 for (x=(ssize_t) length; x != 0; )
604 if ((*pixels == *(pixels+1)) && (*(pixels+1) == *(pixels+2)))
606 *q++=(unsigned char) ((256-3)+1);
618 if ((*pixels == *(pixels+1)) && (*(pixels+1) == *(pixels+2)))
624 while (((ssize_t) count < x) && (*pixels == *(pixels+count)))
631 *q++=(unsigned char) ((256-count)+1);
640 while ((*(pixels+count) != *(pixels+count+1)) ||
641 (*(pixels+count+1) != *(pixels+count+2)))
643 packbits[count+1]=pixels[count];
645 if (((ssize_t) count >= (x-3)) || (count >= 127))
649 *packbits=(unsigned char) (count-1);
650 for (j=0; j <= (ssize_t) count; j++)
657 *q++=128; /* EOD marker */
658 return((size_t) (q-compress_pixels));
661 static MagickBooleanType WritePCLImage(const ImageInfo *image_info,Image *image,
662 ExceptionInfo *exception)
665 buffer[MaxTextExtent];
676 register const Quantum *p;
678 register ssize_t i, x;
680 register unsigned char *q;
698 Open output image file.
700 assert(image_info != (const ImageInfo *) NULL);
701 assert(image_info->signature == MagickSignature);
702 assert(image != (Image *) NULL);
703 assert(image->signature == MagickSignature);
704 if (image->debug != MagickFalse)
705 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
706 assert(exception != (ExceptionInfo *) NULL);
707 assert(exception->signature == MagickSignature);
708 status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception);
709 if (status == MagickFalse)
712 if (image_info->density != (char *) NULL)
717 (void) ParseGeometry(image_info->density,&geometry);
718 density=(size_t) geometry.rho;
724 if (IsRGBColorspace(image->colorspace) == MagickFalse)
725 (void) TransformImageColorspace(image,sRGBColorspace,exception);
727 Initialize the printer.
729 (void) WriteBlobString(image,"\033E"); /* printer reset */
730 (void) WriteBlobString(image,"\033*r3F"); /* set presentation mode */
731 (void) FormatLocaleString(buffer,MaxTextExtent,"\033*r%.20gs%.20gT",
732 (double) image->columns,(double) image->rows);
733 (void) WriteBlobString(image,buffer);
734 (void) FormatLocaleString(buffer,MaxTextExtent,"\033*t%.20gR",(double)
736 (void) WriteBlobString(image,buffer);
737 (void) WriteBlobString(image,"\033&l0E"); /* top margin 0 */
738 if (IsImageMonochrome(image,exception) != MagickFalse)
741 Monochrome image: use default printer monochrome setup.
746 if (image->storage_class == DirectClass)
752 (void) WriteBlobString(image,"\033*v6W"); /* set color mode */
753 (void) WriteBlobByte(image,0); /* RGB */
754 (void) WriteBlobByte(image,3); /* direct by pixel */
755 (void) WriteBlobByte(image,0); /* bits per index (ignored) */
756 (void) WriteBlobByte(image,8); /* bits per red component */
757 (void) WriteBlobByte(image,8); /* bits per green component */
758 (void) WriteBlobByte(image,8); /* bits per blue component */
766 (void) WriteBlobString(image,"\033*v6W"); /* set color mode... */
767 (void) WriteBlobByte(image,0); /* RGB */
768 (void) WriteBlobByte(image,1); /* indexed by pixel */
769 (void) WriteBlobByte(image,bits_per_pixel); /* bits per index */
770 (void) WriteBlobByte(image,8); /* bits per red component */
771 (void) WriteBlobByte(image,8); /* bits per green component */
772 (void) WriteBlobByte(image,8); /* bits per blue component */
773 for (i=0; i < (ssize_t) image->colors; i++)
775 (void) FormatLocaleString(buffer,MaxTextExtent,
776 "\033*v%da%db%dc%.20gI",
777 ScaleQuantumToChar(image->colormap[i].red),
778 ScaleQuantumToChar(image->colormap[i].green),
779 ScaleQuantumToChar(image->colormap[i].blue),(double) i);
780 (void) WriteBlobString(image,buffer);
782 for (one=1; i < (ssize_t) (one << bits_per_pixel); i++)
784 (void) FormatLocaleString(buffer,MaxTextExtent,"\033*v%.20gI",
786 (void) WriteBlobString(image,buffer);
789 option=GetImageOption(image_info,"pcl:fit-to-page");
790 if (IfTrue(IsStringTrue(option)))
791 (void) WriteBlobString(image,"\033*r3A");
793 (void) WriteBlobString(image,"\033*r1A"); /* start raster graphics */
794 (void) WriteBlobString(image,"\033*b0Y"); /* set y offset */
795 length=(image->columns*bits_per_pixel+7)/8;
796 pixels=(unsigned char *) AcquireQuantumMemory(length+1,sizeof(*pixels));
797 if (pixels == (unsigned char *) NULL)
798 ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
799 (void) ResetMagickMemory(pixels,0,(length+1)*sizeof(*pixels));
800 compress_pixels=(unsigned char *) NULL;
801 previous_pixels=(unsigned char *) NULL;
802 switch (image->compression)
806 (void) FormatLocaleString(buffer,MaxTextExtent,"\033*b0M");
807 (void) WriteBlobString(image,buffer);
812 compress_pixels=(unsigned char *) AcquireQuantumMemory(length+256,
813 sizeof(*compress_pixels));
814 if (compress_pixels == (unsigned char *) NULL)
816 pixels=(unsigned char *) RelinquishMagickMemory(pixels);
817 ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
819 (void) ResetMagickMemory(compress_pixels,0,(length+256)*
820 sizeof(*compress_pixels));
821 (void) FormatLocaleString(buffer,MaxTextExtent,"\033*b2M");
822 (void) WriteBlobString(image,buffer);
827 compress_pixels=(unsigned char *) AcquireQuantumMemory(3*length+256,
828 sizeof(*compress_pixels));
829 if (compress_pixels == (unsigned char *) NULL)
831 pixels=(unsigned char *) RelinquishMagickMemory(pixels);
832 ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
834 (void) ResetMagickMemory(compress_pixels,0,(3*length+256)*
835 sizeof(*compress_pixels));
836 previous_pixels=(unsigned char *) AcquireQuantumMemory(length+1,
837 sizeof(*previous_pixels));
838 if (previous_pixels == (unsigned char *) NULL)
840 compress_pixels=(unsigned char *) RelinquishMagickMemory(
842 pixels=(unsigned char *) RelinquishMagickMemory(pixels);
843 ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
845 (void) ResetMagickMemory(previous_pixels,0,(length+1)*
846 sizeof(*previous_pixels));
847 (void) FormatLocaleString(buffer,MaxTextExtent,"\033*b3M");
848 (void) WriteBlobString(image,buffer);
852 for (y=0; y < (ssize_t) image->rows; y++)
854 p=GetVirtualPixels(image,0,y,image->columns,1,exception);
855 if (p == (const Quantum *) NULL)
858 switch (bits_per_pixel)
862 register unsigned char
871 for (x=0; x < (ssize_t) image->columns; x++)
874 if (GetPixelIntensity(image,p) < ((MagickRealType) QuantumRange/2.0))
883 p+=GetPixelChannels(image);
886 *q++=byte << (8-bit);
894 for (x=0; x < (ssize_t) image->columns; x++)
896 *q++=(unsigned char) GetPixelIndex(image,p);
897 p+=GetPixelChannels(image);
907 for (x=0; x < (ssize_t) image->columns; x++)
909 *q++=ScaleQuantumToChar(GetPixelRed(image,p));
910 *q++=ScaleQuantumToChar(GetPixelGreen(image,p));
911 *q++=ScaleQuantumToChar(GetPixelBlue(image,p));
912 p+=GetPixelChannels(image);
917 switch (image->compression)
921 (void) FormatLocaleString(buffer,MaxTextExtent,"\033*b%.20gW",
923 (void) WriteBlobString(image,buffer);
924 (void) WriteBlob(image,length,pixels);
929 packets=PCLPackbitsCompressImage(length,pixels,compress_pixels);
930 (void) FormatLocaleString(buffer,MaxTextExtent,"\033*b%.20gW",
932 (void) WriteBlobString(image,buffer);
933 (void) WriteBlob(image,packets,compress_pixels);
939 for (i=0; i < (ssize_t) length; i++)
940 previous_pixels[i]=(~pixels[i]);
941 packets=PCLDeltaCompressImage(length,previous_pixels,pixels,
943 (void) FormatLocaleString(buffer,MaxTextExtent,"\033*b%.20gW",
945 (void) WriteBlobString(image,buffer);
946 (void) WriteBlob(image,packets,compress_pixels);
947 (void) CopyMagickMemory(previous_pixels,pixels,length*
953 (void) WriteBlobString(image,"\033*rB"); /* end graphics */
954 switch (image->compression)
960 compress_pixels=(unsigned char *) RelinquishMagickMemory(
966 previous_pixels=(unsigned char *) RelinquishMagickMemory(
968 compress_pixels=(unsigned char *) RelinquishMagickMemory(
973 pixels=(unsigned char *) RelinquishMagickMemory(pixels);
974 if (GetNextImageInList(image) == (Image *) NULL)
976 image=SyncNextImageInList(image);
977 status=SetImageProgress(image,SaveImagesTag,scene++,
978 GetImageListLength(image));
979 if (status == MagickFalse)
981 } while (image_info->adjoin != MagickFalse);
982 (void) WriteBlobString(image,"\033E");
983 (void) CloseBlob(image);