2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13 % Read/Write Palm Database ImageViewer Image Format %
20 % Copyright 1999-2010 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 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
37 20071202 TS * rewrote RLE decoder - old version could cause buffer overflows
38 * failure of RLE decoding now thows error RLEDecoderError
39 * fixed bug in RLE decoding - now all rows are decoded, not just
41 * fixed bug in reader - record offsets now handled correctly
42 * fixed bug in reader - only bits 0..2 indicate compression type
43 * in writer: now using image color count instead of depth
49 #include "magick/studio.h"
50 #include "magick/attribute.h"
51 #include "magick/blob.h"
52 #include "magick/blob-private.h"
53 #include "magick/cache.h"
54 #include "magick/colormap-private.h"
55 #include "magick/color-private.h"
56 #include "magick/colorspace.h"
57 #include "magick/constitute.h"
58 #include "magick/exception.h"
59 #include "magick/exception-private.h"
60 #include "magick/image.h"
61 #include "magick/image-private.h"
62 #include "magick/list.h"
63 #include "magick/magick.h"
64 #include "magick/memory_.h"
65 #include "magick/monitor.h"
66 #include "magick/monitor-private.h"
67 #include "magick/property.h"
68 #include "magick/quantum-private.h"
69 #include "magick/quantum-private.h"
70 #include "magick/static.h"
71 #include "magick/string_.h"
72 #include "magick/module.h"
77 typedef struct _PDBInfo
95 type[4], /* database type identifier "vIMG" */
96 id[4]; /* database creator identifier "View" */
106 typedef struct _PDBImage
131 Forward declarations.
133 static MagickBooleanType
134 WritePDBImage(const ImageInfo *,Image *);
137 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
141 % D e c o d e I m a g e %
145 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
147 % DecodeImage unpacks the packed image pixels into runlength-encoded
150 % The format of the DecodeImage method is:
152 % MagickBooleanType DecodeImage(Image *image,unsigned char *pixels,
153 % const size_t length)
155 % A description of each parameter follows:
157 % o image: the address of a structure of type Image.
159 % o pixels: The address of a byte (8 bits) array of pixel data created by
160 % the decoding process.
162 % o length: Number of bytes to read into buffer 'pixels'.
165 static MagickBooleanType DecodeImage(Image *image, unsigned char *pixels,
168 #define RLE_MODE_NONE -1
169 #define RLE_MODE_COPY 0
170 #define RLE_MODE_RUN 1
172 int data = 0, count = 0;
174 int mode = RLE_MODE_NONE;
176 for (p = pixels; p < pixels + length; p++) {
178 data = ReadBlobByte( image );
179 if (-1 == data) return MagickFalse;
182 count = data - 128 + 1;
183 data = ReadBlobByte( image );
184 if (-1 == data) return MagickFalse;
186 mode = RLE_MODE_COPY;
191 if (RLE_MODE_COPY == mode) {
192 data = ReadBlobByte( image );
193 if (-1 == data) return MagickFalse;
195 *p = (unsigned char)data;
202 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
210 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
212 % IsPDB() returns MagickTrue if the image format type, identified by the
213 % magick string, is PDB.
215 % The format of the ReadPDBImage method is:
217 % MagickBooleanType IsPDB(const unsigned char *magick,const size_t length)
219 % A description of each parameter follows:
221 % o magick: compare image format pattern against these bytes.
223 % o length: Specifies the length of the magick string.
226 static MagickBooleanType IsPDB(const unsigned char *magick,const size_t length)
230 if (memcmp(magick+60,"vIMGView",8) == 0)
236 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
240 % R e a d P D B I m a g e %
244 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
246 % ReadPDBImage() reads an Pilot image file and returns it. It
247 % allocates the memory necessary for the new Image structure and returns a
248 % pointer to the new image.
250 % The format of the ReadPDBImage method is:
252 % Image *ReadPDBImage(const ImageInfo *image_info,ExceptionInfo *exception)
254 % A description of each parameter follows:
256 % o image_info: the image info.
258 % o exception: return any errors or warnings in this structure.
261 static Image *ReadPDBImage(const ImageInfo *image_info,ExceptionInfo *exception)
296 register unsigned char
306 num_pad_bytes, /* TS */
313 assert(image_info != (const ImageInfo *) NULL);
314 assert(image_info->signature == MagickSignature);
315 if (image_info->debug != MagickFalse)
316 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
317 image_info->filename);
318 assert(exception != (ExceptionInfo *) NULL);
319 assert(exception->signature == MagickSignature);
320 image=AcquireImage(image_info);
321 status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
322 if (status == MagickFalse)
324 image=DestroyImageList(image);
325 return((Image *) NULL);
328 Determine if this a PDB image file.
330 count=ReadBlob(image,32,(unsigned char *) pdb_info.name);
331 pdb_info.attributes=(short) ReadBlobMSBShort(image);
332 pdb_info.version=(short) ReadBlobMSBShort(image);
333 pdb_info.create_time=ReadBlobMSBLong(image);
334 pdb_info.modify_time=ReadBlobMSBLong(image);
335 pdb_info.archive_time=ReadBlobMSBLong(image);
336 pdb_info.modify_number=ReadBlobMSBLong(image);
337 pdb_info.application_info=ReadBlobMSBLong(image);
338 pdb_info.sort_info=ReadBlobMSBLong(image);
339 count=ReadBlob(image,4,(unsigned char *) pdb_info.type);
340 count=ReadBlob(image,4,(unsigned char *) pdb_info.id);
341 if ((count == 0) || (memcmp(pdb_info.type,"vIMG",4) != 0) ||
342 (memcmp(pdb_info.id,"View",4) != 0))
343 ThrowReaderException(CorruptImageError,"ImproperImageHeader");
344 pdb_info.seed=ReadBlobMSBLong(image);
345 pdb_info.next_record=ReadBlobMSBLong(image);
346 pdb_info.number_records=(short) ReadBlobMSBShort(image);
347 if (pdb_info.next_record != 0)
348 ThrowReaderException(CoderError,"MultipleRecordListNotSupported");
352 img_offset=(long) ReadBlobMSBLong(image); /* TS */
353 attributes=(unsigned char) ReadBlobByte(image);
354 count=ReadBlob(image,3,(unsigned char *) tag);
355 if (count != 3 || memcmp(tag,"\x6f\x80\x00",3) != 0)
356 ThrowReaderException(CorruptImageError,"CorruptImage");
358 if (pdb_info.number_records > 1)
360 comment_offset=(long) ReadBlobMSBLong(image);
361 attributes=(unsigned char) ReadBlobByte(image);
362 count=ReadBlob(image,3,(unsigned char *) tag);
363 if (count != 3 || memcmp(tag,"\x6f\x80\x01",3) != 0)
364 ThrowReaderException(CorruptImageError,"CorruptImage");
367 num_pad_bytes = (unsigned long) (img_offset - TellBlob( image ));
368 while (num_pad_bytes--) ReadBlobByte( image );
372 count=ReadBlob(image,32,(unsigned char *) pdb_image.name);
373 pdb_image.version=ReadBlobByte(image);
374 pdb_image.type=ReadBlobByte(image);
375 pdb_image.reserved_1=ReadBlobMSBLong(image);
376 pdb_image.note=ReadBlobMSBLong(image);
377 pdb_image.x_last=(short) ReadBlobMSBShort(image);
378 pdb_image.y_last=(short) ReadBlobMSBShort(image);
379 pdb_image.reserved_2=ReadBlobMSBLong(image);
380 pdb_image.x_anchor=(short) ReadBlobMSBShort(image);
381 pdb_image.y_anchor=(short) ReadBlobMSBShort(image);
382 pdb_image.width=(short) ReadBlobMSBShort(image);
383 pdb_image.height=(short) ReadBlobMSBShort(image);
385 Initialize image structure.
387 image->columns=(unsigned long) pdb_image.width;
388 image->rows=(unsigned long) pdb_image.height;
390 image->storage_class=PseudoClass;
391 bits_per_pixel=pdb_image.type == 0 ? 2UL : pdb_image.type == 2 ? 4UL : 1UL;
392 if (AcquireImageColormap(image,1 << bits_per_pixel) == MagickFalse)
393 ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
394 if (image_info->ping != MagickFalse)
396 (void) CloseBlob(image);
397 return(GetFirstImageInList(image));
399 packets=bits_per_pixel*image->columns/8;
400 pixels=(unsigned char *) AcquireQuantumMemory(packets+256UL,image->rows*
402 if (pixels == (unsigned char *) NULL)
403 ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
405 switch (pdb_image.version & 7) /* TS */
409 image->compression=NoCompression;
410 count=(ssize_t) ReadBlob(image, packets * image -> rows, pixels);
415 image->compression=RLECompression;
416 if (!DecodeImage(image, pixels, packets * image -> rows))
417 ThrowReaderException( CorruptImageError, "RLEDecoderError" ); /* TS */
421 ThrowReaderException(CorruptImageError,
422 "UnrecognizedImageCompressionType" );
425 switch (bits_per_pixel)
433 Read 1-bit PDB image.
435 for (y=0; y < (long) image->rows; y++)
437 q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
438 if (q == (PixelPacket *) NULL)
440 indexes=GetAuthenticIndexQueue(image);
441 for (x=0; x < ((long) image->columns-7); x+=8)
443 for (bit=0; bit < 8; bit++)
445 index=(IndexPacket) (*p & (0x80 >> bit) ? 0x00 : 0x01);
446 indexes[x+bit]=index;
447 *q++=image->colormap[(long) index];
451 if (SyncAuthenticPixels(image,exception) == MagickFalse)
453 status=SetImageProgress(image,LoadImageTag,y,image->rows);
454 if (status == MagickFalse)
462 Read 2-bit PDB image.
464 for (y=0; y < (long) image->rows; y++)
466 q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
467 if (q == (PixelPacket *) NULL)
469 indexes=GetAuthenticIndexQueue(image);
470 for (x=0; x < (long) image->columns; x+=4)
472 index=ConstrainColormapIndex(image,3UL-((*p >> 6) & 0x03));
474 *q++=image->colormap[(long) index];
475 index=ConstrainColormapIndex(image,3UL-((*p >> 4) & 0x03));
477 *q++=image->colormap[(long) index];
478 index=ConstrainColormapIndex(image,3UL-((*p >> 2) & 0x03));
480 *q++=image->colormap[(long) index];
481 index=ConstrainColormapIndex(image,3UL-((*p) & 0x03));
483 *q++=image->colormap[(long) index];
486 if (SyncAuthenticPixels(image,exception) == MagickFalse)
488 status=SetImageProgress(image,LoadImageTag,y,image->rows);
489 if (status == MagickFalse)
497 Read 4-bit PDB image.
499 for (y=0; y < (long) image->rows; y++)
501 q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
502 if (q == (PixelPacket *) NULL)
504 indexes=GetAuthenticIndexQueue(image);
505 for (x=0; x < (long) image->columns; x+=2)
507 index=ConstrainColormapIndex(image,15UL-((*p >> 4) & 0x0f));
509 *q++=image->colormap[(long) index];
510 index=ConstrainColormapIndex(image,15UL-((*p) & 0x0f));
512 *q++=image->colormap[(long) index];
515 if (SyncAuthenticPixels(image,exception) == MagickFalse)
517 status=SetImageProgress(image,LoadImageTag,y,image->rows);
518 if (status == MagickFalse)
524 ThrowReaderException(CorruptImageError,"ImproperImageHeader");
527 pixels=(unsigned char *) RelinquishMagickMemory(pixels);
528 if (EOFBlob(image) != MagickFalse)
529 ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
531 if (pdb_info.number_records > 1) /* TS */
545 num_pad_bytes = (unsigned long) (comment_offset - TellBlob( image ));
546 while (num_pad_bytes--) ReadBlobByte( image );
551 c=ReadBlobByte(image);
552 length=MaxTextExtent;
553 comment=AcquireString((char *) NULL);
554 for (p=comment; c != EOF; p++)
556 if ((size_t) (p-comment+MaxTextExtent) >= length)
560 length+=MaxTextExtent;
561 comment=(char *) ResizeQuantumMemory(comment,length+MaxTextExtent,
563 if (comment == (char *) NULL)
565 p=comment+strlen(comment);
568 c=ReadBlobByte(image);
571 if (comment == (char *) NULL)
572 ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
573 (void) SetImageProperty(image,"comment",comment);
574 comment=DestroyString(comment);
576 (void) CloseBlob(image);
577 return(GetFirstImageInList(image));
581 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
585 % R e g i s t e r P D B I m a g e %
589 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
591 % RegisterPDBImage() adds properties for the PDB image format to
592 % the list of supported formats. The properties include the image format
593 % tag, a method to read and/or write the format, whether the format
594 % supports the saving of more than one frame to the same file or blob,
595 % whether the format supports native in-memory I/O, and a brief
596 % description of the format.
598 % The format of the RegisterPDBImage method is:
600 % unsigned long RegisterPDBImage(void)
603 ModuleExport unsigned long RegisterPDBImage(void)
608 entry=SetMagickInfo("PDB");
609 entry->decoder=(DecodeImageHandler *) ReadPDBImage;
610 entry->encoder=(EncodeImageHandler *) WritePDBImage;
611 entry->magick=(IsImageFormatHandler *) IsPDB;
612 entry->description=ConstantString("Palm Database ImageViewer Format");
613 entry->module=ConstantString("PDB");
614 (void) RegisterMagickInfo(entry);
615 return(MagickImageCoderSignature);
619 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
623 % U n r e g i s t e r P D B I m a g e %
627 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
629 % UnregisterPDBImage() removes format registrations made by the
630 % PDB module from the list of supported formats.
632 % The format of the UnregisterPDBImage method is:
634 % UnregisterPDBImage(void)
637 ModuleExport void UnregisterPDBImage(void)
639 (void) UnregisterMagickInfo("PDB");
643 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
647 % W r i t e P D B I m a g e %
651 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
653 % WritePDBImage() writes an image
655 % The format of the WritePDBImage method is:
657 % MagickBooleanType WritePDBImage(const ImageInfo *image_info,Image *image)
659 % A description of each parameter follows.
661 % o image_info: the image info.
663 % o image: The image.
668 static unsigned char *EncodeRLE(unsigned char *destination,
669 unsigned char *source,unsigned long literal,unsigned long repeat)
672 *destination++=(unsigned char) (literal-1);
673 (void) CopyMagickMemory(destination,source,literal);
674 destination+=literal;
677 *destination++=(unsigned char) (0x80 | (repeat-1));
678 *destination++=source[literal];
683 static MagickBooleanType WritePDBImage(const ImageInfo *image_info,Image *image)
706 register const PixelPacket
712 register unsigned char
730 Open output image file.
732 assert(image_info != (const ImageInfo *) NULL);
733 assert(image_info->signature == MagickSignature);
734 assert(image != (Image *) NULL);
735 assert(image->signature == MagickSignature);
736 if (image->debug != MagickFalse)
737 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
738 status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);
739 if (status == MagickFalse)
741 if (image->colorspace != RGBColorspace)
742 (void) TransformImageColorspace(image,RGBColorspace);
744 if (image -> colors <= 2 || GetImageType( image, &image -> exception ) == BilevelType) { /* TS */
746 } else if (image -> colors <= 4) {
748 } else if (image -> colors <= 8) {
754 (void) ResetMagickMemory(pdb_info.name,0,32);
755 (void) CopyMagickString(pdb_info.name,image_info->filename,32);
756 pdb_info.attributes=0;
758 pdb_info.create_time=time(NULL);
759 pdb_info.modify_time=pdb_info.create_time;
760 pdb_info.archive_time=0;
761 pdb_info.modify_number=0;
762 pdb_info.application_info=0;
763 pdb_info.sort_info=0;
764 (void) CopyMagickMemory(pdb_info.type,"vIMG",4);
765 (void) CopyMagickMemory(pdb_info.id,"View",4);
767 pdb_info.next_record=0;
768 comment=GetImageProperty(image,"comment");
769 pdb_info.number_records=(comment == (const char *) NULL ? 1 : 2);
770 (void) WriteBlob(image,32,(unsigned char *) pdb_info.name);
771 (void) WriteBlobMSBShort(image,(unsigned short) pdb_info.attributes);
772 (void) WriteBlobMSBShort(image,(unsigned short) pdb_info.version);
773 (void) WriteBlobMSBLong(image,pdb_info.create_time);
774 (void) WriteBlobMSBLong(image,pdb_info.modify_time);
775 (void) WriteBlobMSBLong(image,pdb_info.archive_time);
776 (void) WriteBlobMSBLong(image,pdb_info.modify_number);
777 (void) WriteBlobMSBLong(image,pdb_info.application_info);
778 (void) WriteBlobMSBLong(image,pdb_info.sort_info);
779 (void) WriteBlob(image,4,(unsigned char *) pdb_info.type);
780 (void) WriteBlob(image,4,(unsigned char *) pdb_info.id);
781 (void) WriteBlobMSBLong(image,(unsigned long) pdb_info.seed);
782 (void) WriteBlobMSBLong(image,(unsigned long) pdb_info.next_record);
783 (void) WriteBlobMSBShort(image,(unsigned short) pdb_info.number_records);
784 (void) CopyMagickString(pdb_image.name,pdb_info.name,32);
785 pdb_image.version=1; /* RLE Compressed */
786 switch (bits_per_pixel)
788 case 1: pdb_image.type=(char) 0xff; break; /* monochrome */
789 case 2: pdb_image.type=(char) 0x00; break; /* 2 bit gray */
790 default: pdb_image.type=(char) 0x02; /* 4 bit gray */
792 pdb_image.reserved_1=0;
796 pdb_image.reserved_2=0;
797 pdb_image.x_anchor=(short) 0xffff;
798 pdb_image.y_anchor=(short) 0xffff;
799 pdb_image.width=(short) image->columns;
800 if (image->columns % 16)
801 pdb_image.width=(short) (16*(image->columns/16+1));
802 pdb_image.height=(short) image->rows;
803 packets=(bits_per_pixel*image->columns/8)*image->rows;
804 runlength=(unsigned char *) AcquireQuantumMemory(2UL*packets,
806 if (runlength == (unsigned char *) NULL)
807 ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
808 buffer=(unsigned char *) AcquireQuantumMemory(256UL,sizeof(*buffer));
809 if (buffer == (unsigned char *) NULL)
810 ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
811 packet_size=(size_t) (image->depth > 8 ? 2: 1);
812 scanline=(unsigned char *) AcquireQuantumMemory(image->columns,packet_size*
814 if (scanline == (unsigned char *) NULL)
815 ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
816 if (image->colorspace != RGBColorspace)
817 (void) TransformImageColorspace(image,RGBColorspace);
819 Convert to GRAY raster scanline.
821 quantum_info=AcquireQuantumInfo(image_info,image);
822 if (quantum_info == (QuantumInfo *) NULL)
823 ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
824 bits=8/(long) bits_per_pixel-1; /* start at most significant bits */
829 for (y=0; y < (long) image->rows; y++)
831 p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
832 if (p == (const PixelPacket *) NULL)
834 (void) ExportQuantumPixels(image,(const CacheView *) NULL,quantum_info,
835 GrayQuantum,scanline,&image->exception);
836 for (x=0; x < pdb_image.width; x++)
838 if (x < (long) image->columns)
839 buffer[literal+repeat]|=(0xff-scanline[x*packet_size]) >>
840 (8-bits_per_pixel) << bits*bits_per_pixel;
844 if (((literal+repeat) > 0) &&
845 (buffer[literal+repeat] == buffer[literal+repeat-1]))
855 q=EncodeRLE(q,buffer,literal,repeat);
866 q=EncodeRLE(q,buffer,literal,repeat);
867 buffer[0]=buffer[literal+repeat];
874 q=EncodeRLE(q,buffer,(literal < 0x80 ? literal : 0x80),0);
875 (void) CopyMagickMemory(buffer,buffer+literal+repeat,0x80);
879 bits=8/(long) bits_per_pixel-1;
880 buffer[literal+repeat]=0x00;
883 status=SetImageProgress(image,SaveImageTag,y,image->rows);
884 if (status == MagickFalse)
887 q=EncodeRLE(q,buffer,literal,repeat);
888 scanline=(unsigned char *) RelinquishMagickMemory(scanline);
889 buffer=(unsigned char *) RelinquishMagickMemory(buffer);
890 quantum_info=DestroyQuantumInfo(quantum_info);
892 Write the Image record header.
894 (void) WriteBlobMSBLong(image,(unsigned long)
895 (TellBlob(image)+8*pdb_info.number_records));
896 (void) WriteBlobByte(image,0x40);
897 (void) WriteBlobByte(image,0x6f);
898 (void) WriteBlobByte(image,0x80);
899 (void) WriteBlobByte(image,0);
900 if (pdb_info.number_records > 1)
903 Write the comment record header.
905 (void) WriteBlobMSBLong(image,(unsigned long) (TellBlob(image)+8+58+q-
907 (void) WriteBlobByte(image,0x40);
908 (void) WriteBlobByte(image,0x6f);
909 (void) WriteBlobByte(image,0x80);
910 (void) WriteBlobByte(image,1);
913 Write the Image data.
915 (void) WriteBlob(image,32,(unsigned char *) pdb_image.name);
916 (void) WriteBlobByte(image,(unsigned char) pdb_image.version);
917 (void) WriteBlobByte(image,(unsigned char) pdb_image.type);
918 (void) WriteBlobMSBLong(image,pdb_image.reserved_1);
919 (void) WriteBlobMSBLong(image,pdb_image.note);
920 (void) WriteBlobMSBShort(image,(unsigned short) pdb_image.x_last);
921 (void) WriteBlobMSBShort(image,(unsigned short) pdb_image.y_last);
922 (void) WriteBlobMSBLong(image,pdb_image.reserved_2);
923 (void) WriteBlobMSBShort(image,(unsigned short) pdb_image.x_anchor);
924 (void) WriteBlobMSBShort(image,(unsigned short) pdb_image.y_anchor);
925 (void) WriteBlobMSBShort(image,(unsigned short) pdb_image.width);
926 (void) WriteBlobMSBShort(image,(unsigned short) pdb_image.height);
927 (void) WriteBlob(image,(size_t) (q-runlength),runlength);
928 runlength=(unsigned char *) RelinquishMagickMemory(runlength);
929 if (pdb_info.number_records > 1)
930 (void) WriteBlobString(image,comment);
931 (void) CloseBlob(image);