2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13 % Read/Write Raw RGB Image Format %
20 % Copyright 1999-2008 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 "magick/studio.h"
43 #include "magick/blob.h"
44 #include "magick/blob-private.h"
45 #include "magick/cache.h"
46 #include "magick/colorspace.h"
47 #include "magick/constitute.h"
48 #include "magick/exception.h"
49 #include "magick/exception-private.h"
50 #include "magick/image.h"
51 #include "magick/image-private.h"
52 #include "magick/list.h"
53 #include "magick/magick.h"
54 #include "magick/memory_.h"
55 #include "magick/monitor.h"
56 #include "magick/monitor-private.h"
57 #include "magick/pixel-private.h"
58 #include "magick/quantum-private.h"
59 #include "magick/static.h"
60 #include "magick/statistic.h"
61 #include "magick/string_.h"
62 #include "magick/module.h"
63 #include "magick/utility.h"
68 static MagickBooleanType
69 WriteRGBImage(const ImageInfo *,Image *);
72 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
76 % R e a d R G B I m a g e %
80 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
82 % ReadRGBImage() reads an image of raw RGB or RGBA samples and returns it. It
83 % allocates the memory necessary for the new Image structure and returns a
84 % pointer to the new image.
86 % The format of the ReadRGBImage method is:
88 % Image *ReadRGBImage(const ImageInfo *image_info,ExceptionInfo *exception)
90 % A description of each parameter follows:
92 % o image_info: the image info.
94 % o exception: return any errors or warnings in this structure.
97 static Image *ReadRGBImage(const ImageInfo *image_info,ExceptionInfo *exception)
146 assert(image_info != (const ImageInfo *) NULL);
147 assert(image_info->signature == MagickSignature);
148 if (image_info->debug != MagickFalse)
149 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
150 image_info->filename);
151 assert(exception != (ExceptionInfo *) NULL);
152 assert(exception->signature == MagickSignature);
153 image=AcquireImage(image_info);
154 if ((image->columns == 0) || (image->rows == 0))
155 ThrowReaderException(OptionError,"MustSpecifyImageSize");
156 if (image_info->interlace != PartitionInterlace)
158 status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
159 if (status == MagickFalse)
161 image=DestroyImageList(image);
162 return((Image *) NULL);
164 for (i=0; i < image->offset; i++)
165 if (ReadBlobByte(image) == EOF)
167 ThrowFileException(exception,CorruptImageError,
168 "UnexpectedEndOfFile",image->filename);
173 Create virtual canvas to support cropping (i.e. image.rgb[100x100+10+20]).
175 canvas_image=CloneImage(image,image->extract_info.width,1,MagickFalse,
177 (void) SetImageVirtualPixelMethod(canvas_image,BlackVirtualPixelMethod);
178 quantum_info=AcquireQuantumInfo(image_info,canvas_image);
179 if (quantum_info == (QuantumInfo *) NULL)
180 ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
181 pixels=GetQuantumPixels(quantum_info);
182 quantum_type=RGBQuantum;
183 if (LocaleCompare(image_info->magick,"RGBA") == 0)
185 quantum_type=RGBAQuantum;
186 image->matte=MagickTrue;
189 if (LocaleCompare(image_info->magick,"RGBO") == 0)
191 quantum_type=RGBOQuantum;
192 image->matte=MagickTrue;
195 if (image_info->number_scenes != 0)
196 while (image->scene < image_info->scene)
202 length=GetQuantumExtent(canvas_image,quantum_info,quantum_type);
203 for (y=0; y < (long) image->rows; y++)
205 count=ReadBlob(image,length,pixels);
206 if (count != (ssize_t) length)
210 for (i=0; i < channels; i++)
212 switch(image_info->magick[i])
214 case 'R': quantum_types[i]=RedQuantum; break;
215 case 'G': quantum_types[i]=GreenQuantum; break;
216 case 'B': quantum_types[i]=BlueQuantum; break;
217 case 'A': quantum_types[i]=AlphaQuantum; break;
218 case 'O': quantum_types[i]=OpacityQuantum; break;
227 Read pixels to virtual canvas image then push to image.
229 if ((image_info->ping != MagickFalse) && (image_info->number_scenes != 0))
230 if (image->scene >= (image_info->scene+image_info->number_scenes-1))
232 switch (image_info->interlace)
238 No interlacing: RGBRGBRGBRGBRGBRGB...
242 length=GetQuantumExtent(canvas_image,quantum_info,quantum_type);
243 count=ReadBlob(image,length,pixels);
244 if (count != (ssize_t) length)
247 for (y=0; y < (long) image->extract_info.height; y++)
249 register const PixelPacket
258 q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1,
260 if (q == (PixelPacket *) NULL)
262 length=ImportQuantumPixels(canvas_image,(CacheView *) NULL,
263 quantum_info,quantum_type,pixels,exception);
264 if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
266 if (((y-image->extract_info.y) >= 0) &&
267 ((y-image->extract_info.y) < (long) image->rows))
269 p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
270 canvas_image->columns,1,exception);
271 q=QueueAuthenticPixels(image,0,y-image->extract_info.y,
272 image->columns,1,exception);
273 if ((p == (const PixelPacket *) NULL) ||
274 (q == (PixelPacket *) NULL))
276 for (x=0; x < (long) image->columns; x++)
281 for (i=0; i < 3; i++)
282 switch(quantum_types[i])
284 case RedQuantum: q->red=qx[i]; break;
285 case GreenQuantum: q->green=qx[i]; break;
286 case BlueQuantum: q->blue=qx[i]; break;
289 q->opacity=OpaqueOpacity;
290 if (image->matte != MagickFalse)
291 q->opacity=p->opacity;
295 if (SyncAuthenticPixels(image,exception) == MagickFalse)
298 if (image->previous == (Image *) NULL)
300 status=SetImageProgress(image,LoadImageTag,y,image->rows);
301 if (status == MagickFalse)
304 count=ReadBlob(image,length,pixels);
305 if (count != (ssize_t) length)
313 Line interlacing: RRR...GGG...BBB...RRR...GGG...BBB...
317 length=GetQuantumExtent(canvas_image,quantum_info,quantum_types[0]);
318 count=ReadBlob(image,length,pixels);
319 if (count != (ssize_t) length)
322 for (y=0; y < (long) image->extract_info.height; y++)
324 register const PixelPacket
333 for (i=0; i < channels; i++)
335 q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1,
337 if (q == (PixelPacket *) NULL)
339 length=ImportQuantumPixels(canvas_image,(CacheView *) NULL,
340 quantum_info,quantum_types[i],pixels,exception);
341 if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
343 if (((y-image->extract_info.y) >= 0) &&
344 ((y-image->extract_info.y) < (long) image->rows))
346 p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,
347 0,canvas_image->columns,1,exception);
348 q=GetAuthenticPixels(image,0,y-image->extract_info.y,
349 image->columns,1,exception);
350 if ((p == (const PixelPacket *) NULL) ||
351 (q == (PixelPacket *) NULL))
353 if (i == (channels - 1))
354 for (x=0; x < (long) image->columns; x++)
359 q->opacity=p->opacity;
363 if (SyncAuthenticPixels(image,exception) == MagickFalse)
366 count=ReadBlob(image,length,pixels);
367 if (count != (ssize_t) length)
370 if (image->previous == (Image *) NULL)
372 status=SetImageProgress(image,LoadImageTag,y,image->rows);
373 if (status == MagickFalse)
382 Plane interlacing: RRRRRR...GGGGGG...BBBBBB...
386 length=GetQuantumExtent(canvas_image,quantum_info,quantum_types[0]);
387 count=ReadBlob(image,length,pixels);
388 if (count != (ssize_t) length)
391 for (i=0; i < channels; i++)
393 for (y=0; y < (long) image->extract_info.height; y++)
395 register const PixelPacket
404 q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1,
406 if (q == (PixelPacket *) NULL)
408 length=ImportQuantumPixels(canvas_image,(CacheView *) NULL,
409 quantum_info,quantum_types[i],pixels,exception);
410 if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
412 if (((y-image->extract_info.y) >= 0) &&
413 ((y-image->extract_info.y) < (long) image->rows))
415 p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
416 canvas_image->columns,1,exception);
417 q=GetAuthenticPixels(image,0,y-image->extract_info.y,
418 image->columns,1,exception);
419 if ((p == (const PixelPacket *) NULL) ||
420 (q == (PixelPacket *) NULL))
422 for (x=0; x < (long) image->columns; x++)
424 switch(quantum_types[i])
426 case RedQuantum: q->red=p->red; break;
427 case GreenQuantum: q->green=p->green; break;
428 case BlueQuantum: q->blue=p->blue; break;
430 case AlphaQuantum: q->opacity=p->opacity; break;
436 if (SyncAuthenticPixels(image,exception) == MagickFalse)
439 count=ReadBlob(image,length,pixels);
440 if (count != (ssize_t) length)
443 if (image->previous == (Image *) NULL)
445 status=SetImageProgress(image,LoadImageTag,(i+1),5);
446 if (status == MagickFalse)
450 if (image->previous == (Image *) NULL)
452 status=SetImageProgress(image,LoadImageTag,5,5);
453 if (status == MagickFalse)
458 case PartitionInterlace:
461 Partition interlacing: RRRRRR..., GGGGGG..., BBBBBB...
463 for (i=0; i < channels; i++)
465 sfx[0]=image_info->magick[i];
466 AppendImageFormat(sfx,image->filename);
467 status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
468 if (status == MagickFalse)
470 canvas_image=DestroyImageList(canvas_image);
471 image=DestroyImageList(image);
472 return((Image *) NULL);
475 for (j=0; j < image->offset; j++)
476 if (ReadBlobByte(image) == EOF)
478 ThrowFileException(exception,CorruptImageError,
479 "UnexpectedEndOfFile",image->filename);
482 length=GetQuantumExtent(canvas_image,quantum_info,quantum_types[i]);
483 for (j=0; j < (long) scene; j++)
484 for (y=0; y < (long) image->extract_info.height; y++)
485 if (ReadBlob(image,length,pixels) != (ssize_t) length)
487 ThrowFileException(exception,CorruptImageError,
488 "UnexpectedEndOfFile",image->filename);
491 count=ReadBlob(image,length,pixels);
492 if (count != (ssize_t) length)
494 for (y=0; y < (long) image->extract_info.height; y++)
496 register const PixelPacket
505 q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1,
507 if (q == (PixelPacket *) NULL)
509 length=ImportQuantumPixels(canvas_image,(CacheView *) NULL,
510 quantum_info,quantum_types[i],pixels,exception);
511 if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
513 if (((y-image->extract_info.y) >= 0) &&
514 ((y-image->extract_info.y) < (long) image->rows))
516 p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
517 canvas_image->columns,1,exception);
518 q=GetAuthenticPixels(image,0,y-image->extract_info.y,
519 image->columns,1,exception);
520 if ((p == (const PixelPacket *) NULL) ||
521 (q == (PixelPacket *) NULL))
523 for (x=0; x < (long) image->columns; x++)
525 switch(quantum_types[i])
527 case RedQuantum: q->red=p->red; break;
528 case GreenQuantum: q->green=p->green; break;
529 case BlueQuantum: q->blue=p->blue; break;
531 case AlphaQuantum: q->opacity=p->opacity; break;
537 if (SyncAuthenticPixels(image,exception) == MagickFalse)
540 count=ReadBlob(image,length,pixels);
541 if (count != (ssize_t) length)
544 if (image->previous == (Image *) NULL)
546 status=SetImageProgress(image,LoadImageTag,(i+1),5);
547 if (status == MagickFalse)
550 if (i != (channels-1))
551 (void) CloseBlob(image);
553 if (image->previous == (Image *) NULL)
555 status=SetImageProgress(image,LoadImageTag,5,5);
556 if (status == MagickFalse)
562 SetQuantumImageType(image,quantum_type);
564 Proceed to next image.
566 if (image_info->number_scenes != 0)
567 if (image->scene >= (image_info->scene+image_info->number_scenes-1))
569 if (count == (ssize_t) length)
572 Allocate next image structure.
574 AcquireNextImage(image_info,image);
575 if (GetNextImageInList(image) == (Image *) NULL)
577 image=DestroyImageList(image);
578 return((Image *) NULL);
580 image=SyncNextImageInList(image);
581 status=SetImageProgress(image,LoadImagesTag,TellBlob(image),
583 if (status == MagickFalse)
587 } while (count == (ssize_t) length);
588 InheritException(exception,&image->exception);
589 quantum_info=DestroyQuantumInfo(quantum_info);
590 canvas_image=DestroyImage(canvas_image);
591 (void) CloseBlob(image);
592 return(GetFirstImageInList(image));
596 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
600 % R e g i s t e r R G B I m a g e %
604 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
606 % RegisterRGBImage() adds attributes for the RGB or RGBA image format to
607 % the list of supported formats. The attributes include the image format
608 % tag, a method to read and/or write the format, whether the format
609 % supports the saving of more than one frame to the same file or blob,
610 % whether the format supports native in-memory I/O, and a brief
611 % description of the format.
613 % The format of the RegisterRGBImage method is:
615 % unsigned long RegisterRGBImage(void)
618 ModuleExport unsigned long RegisterRGBImage(void)
623 entry=SetMagickInfo("RGB");
624 entry->decoder=(DecodeImageHandler *) ReadRGBImage;
625 entry->encoder=(EncodeImageHandler *) WriteRGBImage;
626 entry->raw=MagickTrue;
627 entry->endian_support=MagickTrue;
628 entry->format_type=ExplicitFormatType;
629 entry->description=ConstantString("Raw red, green, and blue samples");
630 entry->module=ConstantString("RGB");
631 (void) RegisterMagickInfo(entry);
632 entry=SetMagickInfo("RBG");
633 entry->decoder=(DecodeImageHandler *) ReadRGBImage;
634 entry->encoder=(EncodeImageHandler *) WriteRGBImage;
635 entry->raw=MagickTrue;
636 entry->endian_support=MagickTrue;
637 entry->format_type=ExplicitFormatType;
638 entry->description=ConstantString("Raw red, blue, and green samples");
639 entry->module=ConstantString("RGB");
640 (void) RegisterMagickInfo(entry);
641 entry=SetMagickInfo("GRB");
642 entry->decoder=(DecodeImageHandler *) ReadRGBImage;
643 entry->encoder=(EncodeImageHandler *) WriteRGBImage;
644 entry->raw=MagickTrue;
645 entry->endian_support=MagickTrue;
646 entry->format_type=ExplicitFormatType;
647 entry->description=ConstantString("Raw green, red, and blue samples");
648 entry->module=ConstantString("RGB");
649 (void) RegisterMagickInfo(entry);
650 entry=SetMagickInfo("GBR");
651 entry->decoder=(DecodeImageHandler *) ReadRGBImage;
652 entry->encoder=(EncodeImageHandler *) WriteRGBImage;
653 entry->raw=MagickTrue;
654 entry->endian_support=MagickTrue;
655 entry->format_type=ExplicitFormatType;
656 entry->description=ConstantString("Raw green, blue, and red samples");
657 entry->module=ConstantString("RGB");
658 (void) RegisterMagickInfo(entry);
659 entry=SetMagickInfo("BRG");
660 entry->decoder=(DecodeImageHandler *) ReadRGBImage;
661 entry->encoder=(EncodeImageHandler *) WriteRGBImage;
662 entry->raw=MagickTrue;
663 entry->endian_support=MagickTrue;
664 entry->format_type=ExplicitFormatType;
665 entry->description=ConstantString("Raw blue, red, and green samples");
666 entry->module=ConstantString("RGB");
667 (void) RegisterMagickInfo(entry);
668 entry=SetMagickInfo("BGR");
669 entry->decoder=(DecodeImageHandler *) ReadRGBImage;
670 entry->encoder=(EncodeImageHandler *) WriteRGBImage;
671 entry->raw=MagickTrue;
672 entry->endian_support=MagickTrue;
673 entry->format_type=ExplicitFormatType;
674 entry->description=ConstantString("Raw blue, green, and red samples");
675 entry->module=ConstantString("RGB");
676 (void) RegisterMagickInfo(entry);
677 entry=SetMagickInfo("RGBA");
678 entry->decoder=(DecodeImageHandler *) ReadRGBImage;
679 entry->encoder=(EncodeImageHandler *) WriteRGBImage;
680 entry->raw=MagickTrue;
681 entry->endian_support=MagickTrue;
682 entry->format_type=ExplicitFormatType;
683 entry->description=ConstantString("Raw red, green, blue, and alpha samples");
684 entry->module=ConstantString("RGB");
685 (void) RegisterMagickInfo(entry);
686 entry=SetMagickInfo("RGBO");
687 entry->decoder=(DecodeImageHandler *) ReadRGBImage;
688 entry->encoder=(EncodeImageHandler *) WriteRGBImage;
689 entry->raw=MagickTrue;
690 entry->endian_support=MagickTrue;
691 entry->format_type=ExplicitFormatType;
692 entry->description=ConstantString("Raw red, green, blue, and opacity "
694 entry->module=ConstantString("RGB");
695 (void) RegisterMagickInfo(entry);
696 return(MagickImageCoderSignature);
700 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
704 % U n r e g i s t e r R G B I m a g e %
708 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
710 % UnregisterRGBImage() removes format registrations made by the
711 % RGB module from the list of supported formats.
713 % The format of the UnregisterRGBImage method is:
715 % UnregisterRGBImage(void)
718 ModuleExport void UnregisterRGBImage(void)
720 (void) UnregisterMagickInfo("RGBO");
721 (void) UnregisterMagickInfo("RGBA");
722 (void) UnregisterMagickInfo("BGR");
723 (void) UnregisterMagickInfo("BRG");
724 (void) UnregisterMagickInfo("GBR");
725 (void) UnregisterMagickInfo("GRB");
726 (void) UnregisterMagickInfo("RBG");
727 (void) UnregisterMagickInfo("RGB");
731 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
735 % W r i t e R G B I m a g e %
739 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
741 % WriteRGBImage() writes an image to a file in the RGB or RGBA rasterfile
744 % The format of the WriteRGBImage method is:
746 % MagickBooleanType WriteRGBImage(const ImageInfo *image_info,Image *image)
748 % A description of each parameter follows.
750 % o image_info: the image info.
752 % o image: The image.
755 static MagickBooleanType WriteRGBImage(const ImageInfo *image_info,Image *image)
789 Allocate memory for pixels.
791 assert(image_info != (const ImageInfo *) NULL);
792 assert(image_info->signature == MagickSignature);
793 assert(image != (Image *) NULL);
794 assert(image->signature == MagickSignature);
795 if (image->debug != MagickFalse)
796 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
797 if (image_info->interlace != PartitionInterlace)
800 Open output image file.
802 status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);
803 if (status == MagickFalse)
806 quantum_type=RGBQuantum;
808 if (LocaleCompare(image_info->magick,"RGBA") == 0)
810 quantum_type=RGBAQuantum;
811 image->matte=MagickTrue;
814 if (LocaleCompare(image_info->magick,"RGBO") == 0)
816 quantum_type=RGBOQuantum;
817 image->matte=MagickTrue;
820 for (i=0; i < (long) channels; i++)
822 switch (image_info->magick[i])
824 case 'R': quantum_types[i]=RedQuantum; break;
825 case 'G': quantum_types[i]=GreenQuantum; break;
826 case 'B': quantum_types[i]=BlueQuantum; break;
827 case 'A': quantum_types[i]=AlphaQuantum; break;
828 case 'O': quantum_types[i]=OpacityQuantum; break;
835 Convert MIFF to RGB raster pixels.
837 if (image->colorspace != RGBColorspace)
838 (void) TransformImageColorspace(image,RGBColorspace);
839 if ((LocaleCompare(image_info->magick,"RGBA") == 0) &&
840 (image->matte == MagickFalse))
841 (void) SetImageAlphaChannel(image,ResetAlphaChannel);
842 quantum_info=AcquireQuantumInfo(image_info,image);
843 if (quantum_info == (QuantumInfo *) NULL)
844 ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
845 pixels=GetQuantumPixels(quantum_info);
846 switch (image_info->interlace)
861 No interlacing: RGBRGBRGBRGBRGBRGB...
863 image_view=AcquireCacheView(image);
864 for (y=0; y < (long) image->rows; y++)
872 q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,
874 if (q == (PixelPacket *) NULL)
876 for (x=0; x < (long) image->columns; x++)
882 for (i=0; i < 3; i++)
883 switch (quantum_types[i])
885 case RedQuantum: *qx[i]=px.red; break;
886 case GreenQuantum: *qx[i]=px.green; break;
887 case BlueQuantum: *qx[i]=px.blue; break;
892 length=ExportQuantumPixels(image,image_view,quantum_info,quantum_type,
893 pixels,&image->exception);
894 count=WriteBlob(image,length,pixels);
895 if (count != (ssize_t) length)
897 if (image->previous == (Image *) NULL)
899 status=SetImageProgress(image,SaveImageTag,y,image->rows);
900 if (status == MagickFalse)
904 image_view=DestroyCacheView(image_view);
910 Line interlacing: RRR...GGG...BBB...RRR...GGG...BBB...
912 for (y=0; y < (long) image->rows; y++)
914 register const PixelPacket
917 p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
918 if (p == (const PixelPacket *) NULL)
920 for (i=0; i < (long) channels; i++)
922 length=ExportQuantumPixels(image,(const CacheView *) NULL,
923 quantum_info,quantum_types[i],pixels,&image->exception);
924 count=WriteBlob(image,length,pixels);
925 if (count != (ssize_t) length)
928 if (image->previous == (Image *) NULL)
930 status=SetImageProgress(image,SaveImageTag,y,image->rows);
931 if (status == MagickFalse)
940 Plane interlacing: RRRRRR...GGGGGG...BBBBBB...
942 for (i=0; i < (long) channels; i++)
944 for (y=0; y < (long) image->rows; y++)
946 register const PixelPacket
949 p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
950 if (p == (const PixelPacket *) NULL)
952 length=ExportQuantumPixels(image,(const CacheView *) NULL,
953 quantum_info,quantum_types[i],pixels,&image->exception);
954 count=WriteBlob(image,length,pixels);
955 if (count != (ssize_t) length)
958 if (image->previous == (Image *) NULL)
960 status=SetImageProgress(image,SaveImageTag,(i+1),5);
961 if (status == MagickFalse)
965 if (image->previous == (Image *) NULL)
967 status=SetImageProgress(image,SaveImageTag,5,5);
968 if (status == MagickFalse)
973 case PartitionInterlace:
979 Partition interlacing: RRRRRR..., GGGGGG..., BBBBBB...
981 for (i=0; i < (long) channels; i++)
983 sfx[0]=image_info->magick[i];
984 AppendImageFormat(sfx,image->filename);
985 status=OpenBlob(image_info,image,scene == 0 ? WriteBinaryBlobMode :
986 AppendBinaryBlobMode,&image->exception);
987 if (status == MagickFalse)
989 for (y=0; y < (long) image->rows; y++)
991 register const PixelPacket
994 p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
995 if (p == (const PixelPacket *) NULL)
997 length=ExportQuantumPixels(image,(const CacheView *) NULL,
998 quantum_info,quantum_types[i],pixels,&image->exception);
999 count=WriteBlob(image,length,pixels);
1000 if (count != (ssize_t) length)
1003 if (image->previous == (Image *) NULL)
1005 status=SetImageProgress(image,SaveImageTag,(i+1),5);
1006 if (status == MagickFalse)
1009 (void) CloseBlob(image);
1011 (void) CopyMagickString(image->filename,image_info->filename,
1013 if (image->previous == (Image *) NULL)
1015 status=SetImageProgress(image,SaveImageTag,5,5);
1016 if (status == MagickFalse)
1022 quantum_info=DestroyQuantumInfo(quantum_info);
1023 if (GetNextImageInList(image) == (Image *) NULL)
1025 image=SyncNextImageInList(image);
1026 status=SetImageProgress(image,SaveImagesTag,scene++,
1027 GetImageListLength(image));
1028 if (status == MagickFalse)
1030 } while (image_info->adjoin != MagickFalse);
1031 (void) CloseBlob(image);