2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13 % Read/Write Raw CCIR 601 4:1:1 or 4:2:2 Image Format %
20 % Copyright 1999-2018 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 % https://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/blob.h"
44 #include "MagickCore/blob-private.h"
45 #include "MagickCore/cache.h"
46 #include "MagickCore/colorspace.h"
47 #include "MagickCore/constitute.h"
48 #include "MagickCore/exception.h"
49 #include "MagickCore/exception-private.h"
50 #include "MagickCore/geometry.h"
51 #include "MagickCore/image.h"
52 #include "MagickCore/image-private.h"
53 #include "MagickCore/list.h"
54 #include "MagickCore/magick.h"
55 #include "MagickCore/memory_.h"
56 #include "MagickCore/monitor.h"
57 #include "MagickCore/monitor-private.h"
58 #include "MagickCore/pixel-accessor.h"
59 #include "MagickCore/resize.h"
60 #include "MagickCore/quantum-private.h"
61 #include "MagickCore/static.h"
62 #include "MagickCore/string_.h"
63 #include "MagickCore/module.h"
64 #include "MagickCore/utility.h"
69 static MagickBooleanType
70 WriteYUVImage(const ImageInfo *,Image *,ExceptionInfo *);
73 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
77 % R e a d Y U V I m a g e %
81 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
83 % ReadYUVImage() reads an image with digital YUV (CCIR 601 4:1:1, plane
84 % or partition interlaced, or 4:2:2 plane, partition interlaced or
85 % noninterlaced) bytes and returns it. It allocates the memory necessary
86 % for the new Image structure and returns a pointer to the new image.
88 % The format of the ReadYUVImage method is:
90 % Image *ReadYUVImage(const ImageInfo *image_info,ExceptionInfo *exception)
92 % A description of each parameter follows:
94 % o image_info: the image info.
96 % o exception: return any errors or warnings in this structure.
99 static Image *ReadYUVImage(const ImageInfo *image_info,ExceptionInfo *exception)
112 register const Quantum
121 register unsigned char
138 Allocate image structure.
140 assert(image_info != (const ImageInfo *) NULL);
141 assert(image_info->signature == MagickCoreSignature);
142 if (image_info->debug != MagickFalse)
143 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
144 image_info->filename);
145 assert(exception != (ExceptionInfo *) NULL);
146 assert(exception->signature == MagickCoreSignature);
147 image=AcquireImage(image_info,exception);
148 if ((image->columns == 0) || (image->rows == 0))
149 ThrowReaderException(OptionError,"MustSpecifyImageSize");
150 status=SetImageExtent(image,image->columns,image->rows,exception);
151 if (status == MagickFalse)
152 return(DestroyImageList(image));
153 quantum=(ssize_t) (image->depth <= 8 ? 1 : 2);
154 interlace=image_info->interlace;
157 if (image_info->sampling_factor != (char *) NULL)
165 flags=ParseGeometry(image_info->sampling_factor,&geometry_info);
166 horizontal_factor=(ssize_t) geometry_info.rho;
167 vertical_factor=(ssize_t) geometry_info.sigma;
168 if ((flags & SigmaValue) == 0)
169 vertical_factor=horizontal_factor;
170 if ((horizontal_factor != 1) && (horizontal_factor != 2) &&
171 (vertical_factor != 1) && (vertical_factor != 2))
172 ThrowReaderException(CorruptImageError,"UnexpectedSamplingFactor");
174 if ((interlace == UndefinedInterlace) ||
175 ((interlace == NoInterlace) && (vertical_factor == 2)))
177 interlace=NoInterlace; /* CCIR 4:2:2 */
178 if (vertical_factor == 2)
179 interlace=PlaneInterlace; /* CCIR 4:1:1 */
181 if (interlace != PartitionInterlace)
186 status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
187 if (status == MagickFalse)
189 image=DestroyImageList(image);
190 return((Image *) NULL);
192 if (DiscardBlobBytes(image,(MagickSizeType) image->offset) == MagickFalse)
193 ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
197 Allocate memory for a scanline.
199 if (interlace == NoInterlace)
200 scanline=(unsigned char *) AcquireQuantumMemory((size_t) (2UL*
201 image->columns+2UL),(size_t) quantum*sizeof(*scanline));
203 scanline=(unsigned char *) AcquireQuantumMemory(image->columns,
204 (size_t) quantum*sizeof(*scanline));
205 if (scanline == (unsigned char *) NULL)
206 ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
210 chroma_image=CloneImage(image,(image->columns+horizontal_factor-1)/
211 horizontal_factor,(image->rows+vertical_factor-1)/vertical_factor,
212 MagickTrue,exception);
213 if (chroma_image == (Image *) NULL)
215 scanline=(unsigned char *) RelinquishMagickMemory(scanline);
216 ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
219 Convert raster image to pixel packets.
221 if ((image_info->ping != MagickFalse) && (image_info->number_scenes != 0))
222 if (image->scene >= (image_info->scene+image_info->number_scenes-1))
224 status=SetImageExtent(image,image->columns,image->rows,exception);
225 if (status == MagickFalse)
227 if (interlace == PartitionInterlace)
229 AppendImageFormat("Y",image->filename);
230 status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
231 if (status == MagickFalse)
233 scanline=(unsigned char *) RelinquishMagickMemory(scanline);
234 image=DestroyImageList(image);
235 return((Image *) NULL);
238 for (y=0; y < (ssize_t) image->rows; y++)
243 if (interlace == NoInterlace)
245 if ((y > 0) || (GetPreviousImageInList(image) == (Image *) NULL))
247 length=2*quantum*image->columns;
248 count=ReadBlob(image,length,scanline);
249 if (count != (ssize_t) length)
252 ThrowFileException(exception,CorruptImageError,
253 "UnexpectedEndOfFile",image->filename);
258 q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
259 if (q == (Quantum *) NULL)
261 chroma_pixels=QueueAuthenticPixels(chroma_image,0,y,
262 chroma_image->columns,1,exception);
263 if (chroma_pixels == (Quantum *) NULL)
265 for (x=0; x < (ssize_t) image->columns; x+=2)
267 SetPixelRed(chroma_image,0,chroma_pixels);
269 SetPixelGreen(chroma_image,ScaleCharToQuantum(*p++),
273 SetPixelGreen(chroma_image,ScaleShortToQuantum(((*p) << 8) |
274 *(p+1)),chroma_pixels);
278 SetPixelRed(image,ScaleCharToQuantum(*p++),q);
281 SetPixelRed(image,ScaleShortToQuantum(((*p) << 8) | *(p+1)),q);
284 SetPixelGreen(image,0,q);
285 SetPixelBlue(image,0,q);
286 q+=GetPixelChannels(image);
287 SetPixelGreen(image,0,q);
288 SetPixelBlue(image,0,q);
290 SetPixelBlue(chroma_image,ScaleCharToQuantum(*p++),chroma_pixels);
293 SetPixelBlue(chroma_image,ScaleShortToQuantum(((*p) << 8) |
294 *(p+1)),chroma_pixels);
298 SetPixelRed(image,ScaleCharToQuantum(*p++),q);
301 SetPixelRed(image,ScaleShortToQuantum(((*p) << 8) | *(p+1)),q);
304 chroma_pixels+=GetPixelChannels(chroma_image);
305 q+=GetPixelChannels(image);
310 if ((y > 0) || (GetPreviousImageInList(image) == (Image *) NULL))
312 length=quantum*image->columns;
313 count=ReadBlob(image,length,scanline);
314 if (count != (ssize_t) length)
317 ThrowFileException(exception,CorruptImageError,
318 "UnexpectedEndOfFile",image->filename);
323 q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
324 if (q == (Quantum *) NULL)
326 for (x=0; x < (ssize_t) image->columns; x++)
329 SetPixelRed(image,ScaleCharToQuantum(*p++),q);
332 SetPixelRed(image,ScaleShortToQuantum(((*p) << 8) | *(p+1)),q);
335 SetPixelGreen(image,0,q);
336 SetPixelBlue(image,0,q);
337 q+=GetPixelChannels(image);
340 if (SyncAuthenticPixels(image,exception) == MagickFalse)
342 if (interlace == NoInterlace)
343 if (SyncAuthenticPixels(chroma_image,exception) == MagickFalse)
345 if (image->previous == (Image *) NULL)
347 status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,
349 if (status == MagickFalse)
353 if (interlace == PartitionInterlace)
355 (void) CloseBlob(image);
356 AppendImageFormat("U",image->filename);
357 status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
358 if (status == MagickFalse)
360 scanline=(unsigned char *) RelinquishMagickMemory(scanline);
361 image=DestroyImageList(image);
362 return((Image *) NULL);
365 if (interlace != NoInterlace)
367 for (y=0; y < (ssize_t) chroma_image->rows; y++)
369 length=quantum*chroma_image->columns;
370 count=ReadBlob(image,length,scanline);
371 if (count != (ssize_t) length)
374 ThrowFileException(exception,CorruptImageError,
375 "UnexpectedEndOfFile",image->filename);
379 q=QueueAuthenticPixels(chroma_image,0,y,chroma_image->columns,1,
381 if (q == (Quantum *) NULL)
383 for (x=0; x < (ssize_t) chroma_image->columns; x++)
385 SetPixelRed(chroma_image,0,q);
387 SetPixelGreen(chroma_image,ScaleCharToQuantum(*p++),q);
390 SetPixelGreen(chroma_image,ScaleShortToQuantum(((*p) << 8) |
394 SetPixelBlue(chroma_image,0,q);
395 q+=GetPixelChannels(chroma_image);
397 if (SyncAuthenticPixels(chroma_image,exception) == MagickFalse)
400 if (interlace == PartitionInterlace)
402 (void) CloseBlob(image);
403 AppendImageFormat("V",image->filename);
404 status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
405 if (status == MagickFalse)
407 scanline=(unsigned char *) RelinquishMagickMemory(scanline);
408 image=DestroyImageList(image);
409 return((Image *) NULL);
412 for (y=0; y < (ssize_t) chroma_image->rows; y++)
414 length=quantum*chroma_image->columns;
415 count=ReadBlob(image,length,scanline);
416 if (count != (ssize_t) length)
419 ThrowFileException(exception,CorruptImageError,
420 "UnexpectedEndOfFile",image->filename);
424 q=GetAuthenticPixels(chroma_image,0,y,chroma_image->columns,1,
426 if (q == (Quantum *) NULL)
428 for (x=0; x < (ssize_t) chroma_image->columns; x++)
431 SetPixelBlue(chroma_image,ScaleCharToQuantum(*p++),q);
434 SetPixelBlue(chroma_image,ScaleShortToQuantum(((*p) << 8) |
438 q+=GetPixelChannels(chroma_image);
440 if (SyncAuthenticPixels(chroma_image,exception) == MagickFalse)
447 resize_image=ResizeImage(chroma_image,image->columns,image->rows,
448 TriangleFilter,exception);
449 chroma_image=DestroyImage(chroma_image);
450 if (resize_image == (Image *) NULL)
452 scanline=(unsigned char *) RelinquishMagickMemory(scanline);
453 ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
455 for (y=0; y < (ssize_t) image->rows; y++)
457 q=GetAuthenticPixels(image,0,y,image->columns,1,exception);
458 chroma_pixels=GetVirtualPixels(resize_image,0,y,resize_image->columns,1,
460 if ((q == (Quantum *) NULL) ||
461 (chroma_pixels == (const Quantum *) NULL))
463 for (x=0; x < (ssize_t) image->columns; x++)
465 SetPixelGreen(image,GetPixelGreen(resize_image,chroma_pixels),q);
466 SetPixelBlue(image,GetPixelBlue(resize_image,chroma_pixels),q);
467 chroma_pixels+=GetPixelChannels(resize_image);
468 q+=GetPixelChannels(image);
470 if (SyncAuthenticPixels(image,exception) == MagickFalse)
473 resize_image=DestroyImage(resize_image);
474 if (SetImageColorspace(image,YCbCrColorspace,exception) == MagickFalse)
476 if (interlace == PartitionInterlace)
477 (void) CopyMagickString(image->filename,image_info->filename,
479 if (EOFBlob(image) != MagickFalse)
481 ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
486 Proceed to next image.
488 if (image_info->number_scenes != 0)
489 if (image->scene >= (image_info->scene+image_info->number_scenes-1))
491 if (interlace == NoInterlace)
492 count=ReadBlob(image,(size_t) (2*quantum*image->columns),scanline);
494 count=ReadBlob(image,(size_t) quantum*image->columns,scanline);
498 Allocate next image structure.
500 AcquireNextImage(image_info,image,exception);
501 if (GetNextImageInList(image) == (Image *) NULL)
506 image=SyncNextImageInList(image);
507 status=SetImageProgress(image,LoadImagesTag,TellBlob(image),
509 if (status == MagickFalse)
512 } while (count != 0);
513 scanline=(unsigned char *) RelinquishMagickMemory(scanline);
514 (void) CloseBlob(image);
515 if (status == MagickFalse)
516 return(DestroyImageList(image));
517 return(GetFirstImageInList(image));
521 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
525 % R e g i s t e r Y U V I m a g e %
529 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
531 % RegisterYUVImage() adds attributes for the YUV image format to
532 % the list of supported formats. The attributes include the image format
533 % tag, a method to read and/or write the format, whether the format
534 % supports the saving of more than one frame to the same file or blob,
535 % whether the format supports native in-memory I/O, and a brief
536 % description of the format.
538 % The format of the RegisterYUVImage method is:
540 % size_t RegisterYUVImage(void)
543 ModuleExport size_t RegisterYUVImage(void)
548 entry=AcquireMagickInfo("YUV","YUV","CCIR 601 4:1:1 or 4:2:2");
549 entry->decoder=(DecodeImageHandler *) ReadYUVImage;
550 entry->encoder=(EncodeImageHandler *) WriteYUVImage;
551 entry->flags^=CoderAdjoinFlag;
552 entry->flags|=CoderRawSupportFlag;
553 (void) RegisterMagickInfo(entry);
554 return(MagickImageCoderSignature);
558 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
562 % U n r e g i s t e r Y U V I m a g e %
566 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
568 % UnregisterYUVImage() removes format registrations made by the
569 % YUV module from the list of supported formats.
571 % The format of the UnregisterYUVImage method is:
573 % UnregisterYUVImage(void)
576 ModuleExport void UnregisterYUVImage(void)
578 (void) UnregisterMagickInfo("YUV");
582 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
586 % W r i t e Y U V I m a g e %
590 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
592 % WriteYUVImage() writes an image to a file in the digital YUV
593 % (CCIR 601 4:1:1, plane or partition interlaced, or 4:2:2 plane, partition
594 % interlaced or noninterlaced) bytes and returns it.
596 % The format of the WriteYUVImage method is:
598 % MagickBooleanType WriteYUVImage(const ImageInfo *image_info,
599 % Image *image,ExceptionInfo *exception)
601 % A description of each parameter follows.
603 % o image_info: the image info.
605 % o image: The image.
607 % o exception: return any errors or warnings in this structure.
610 static MagickBooleanType WriteYUVImage(const ImageInfo *image_info,Image *image,
611 ExceptionInfo *exception)
626 register const Quantum
644 assert(image_info != (const ImageInfo *) NULL);
645 assert(image_info->signature == MagickCoreSignature);
646 assert(image != (Image *) NULL);
647 assert(image->signature == MagickCoreSignature);
648 if (image->debug != MagickFalse)
649 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
650 quantum=(size_t) (image->depth <= 8 ? 1 : 2);
651 interlace=image->interlace;
654 if (image_info->sampling_factor != (char *) NULL)
662 flags=ParseGeometry(image_info->sampling_factor,&geometry_info);
663 horizontal_factor=(ssize_t) geometry_info.rho;
664 vertical_factor=(ssize_t) geometry_info.sigma;
665 if ((flags & SigmaValue) == 0)
666 vertical_factor=horizontal_factor;
667 if ((horizontal_factor != 1) && (horizontal_factor != 2) &&
668 (vertical_factor != 1) && (vertical_factor != 2))
669 ThrowWriterException(CorruptImageError,"UnexpectedSamplingFactor");
671 if ((interlace == UndefinedInterlace) ||
672 ((interlace == NoInterlace) && (vertical_factor == 2)))
674 interlace=NoInterlace; /* CCIR 4:2:2 */
675 if (vertical_factor == 2)
676 interlace=PlaneInterlace; /* CCIR 4:1:1 */
678 if (interlace != PartitionInterlace)
681 Open output image file.
683 status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception);
684 if (status == MagickFalse)
689 AppendImageFormat("Y",image->filename);
690 status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception);
691 if (status == MagickFalse)
695 imageListLength=GetImageListLength(image);
699 Sample image to an even width and height, if necessary.
701 image->depth=(size_t) (quantum == 1 ? 8 : 16);
702 width=image->columns+(image->columns & (horizontal_factor-1));
703 height=image->rows+(image->rows & (vertical_factor-1));
704 yuv_image=ResizeImage(image,width,height,TriangleFilter,exception);
705 if (yuv_image == (Image *) NULL)
707 (void) CloseBlob(image);
710 (void) TransformImageColorspace(yuv_image,YCbCrColorspace,exception);
714 chroma_image=ResizeImage(image,width/horizontal_factor,
715 height/vertical_factor,TriangleFilter,exception);
716 if (chroma_image == (Image *) NULL)
718 (void) CloseBlob(image);
721 (void) TransformImageColorspace(chroma_image,YCbCrColorspace,exception);
722 if (interlace == NoInterlace)
725 Write noninterlaced YUV.
727 for (y=0; y < (ssize_t) yuv_image->rows; y++)
729 p=GetVirtualPixels(yuv_image,0,y,yuv_image->columns,1,exception);
730 if (p == (const Quantum *) NULL)
732 s=GetVirtualPixels(chroma_image,0,y,chroma_image->columns,1,
734 if (s == (const Quantum *) NULL)
736 for (x=0; x < (ssize_t) yuv_image->columns; x+=2)
740 (void) WriteBlobByte(image,ScaleQuantumToChar(
741 GetPixelGreen(yuv_image,s)));
742 (void) WriteBlobByte(image,ScaleQuantumToChar(
743 GetPixelRed(yuv_image,p)));
744 p+=GetPixelChannels(yuv_image);
745 (void) WriteBlobByte(image,ScaleQuantumToChar(
746 GetPixelBlue(yuv_image,s)));
747 (void) WriteBlobByte(image,ScaleQuantumToChar(
748 GetPixelRed(yuv_image,p)));
752 (void) WriteBlobByte(image,ScaleQuantumToChar(
753 GetPixelGreen(yuv_image,s)));
754 (void) WriteBlobShort(image,ScaleQuantumToShort(
755 GetPixelRed(yuv_image,p)));
756 p+=GetPixelChannels(yuv_image);
757 (void) WriteBlobByte(image,ScaleQuantumToChar(
758 GetPixelBlue(yuv_image,s)));
759 (void) WriteBlobShort(image,ScaleQuantumToShort(
760 GetPixelRed(yuv_image,p)));
762 p+=GetPixelChannels(yuv_image);
765 if (image->previous == (Image *) NULL)
767 status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
769 if (status == MagickFalse)
773 yuv_image=DestroyImage(yuv_image);
778 Initialize Y channel.
780 for (y=0; y < (ssize_t) yuv_image->rows; y++)
782 p=GetVirtualPixels(yuv_image,0,y,yuv_image->columns,1,exception);
783 if (p == (const Quantum *) NULL)
785 for (x=0; x < (ssize_t) yuv_image->columns; x++)
788 (void) WriteBlobByte(image,ScaleQuantumToChar(
789 GetPixelRed(yuv_image,p)));
791 (void) WriteBlobShort(image,ScaleQuantumToShort(
792 GetPixelRed(yuv_image,p)));
793 p+=GetPixelChannels(yuv_image);
795 if (image->previous == (Image *) NULL)
797 status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
799 if (status == MagickFalse)
803 yuv_image=DestroyImage(yuv_image);
804 if (image->previous == (Image *) NULL)
806 status=SetImageProgress(image,SaveImageTag,1,3);
807 if (status == MagickFalse)
811 Initialize U channel.
813 if (interlace == PartitionInterlace)
815 (void) CloseBlob(image);
816 AppendImageFormat("U",image->filename);
817 status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception);
818 if (status == MagickFalse)
821 for (y=0; y < (ssize_t) chroma_image->rows; y++)
823 p=GetVirtualPixels(chroma_image,0,y,chroma_image->columns,1,
825 if (p == (const Quantum *) NULL)
827 for (x=0; x < (ssize_t) chroma_image->columns; x++)
830 (void) WriteBlobByte(image,ScaleQuantumToChar(
831 GetPixelGreen(chroma_image,p)));
833 (void) WriteBlobShort(image,ScaleQuantumToShort(
834 GetPixelGreen(chroma_image,p)));
835 p+=GetPixelChannels(chroma_image);
838 if (image->previous == (Image *) NULL)
840 status=SetImageProgress(image,SaveImageTag,2,3);
841 if (status == MagickFalse)
845 Initialize V channel.
847 if (interlace == PartitionInterlace)
849 (void) CloseBlob(image);
850 AppendImageFormat("V",image->filename);
851 status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception);
852 if (status == MagickFalse)
855 for (y=0; y < (ssize_t) chroma_image->rows; y++)
857 p=GetVirtualPixels(chroma_image,0,y,chroma_image->columns,1,
859 if (p == (const Quantum *) NULL)
861 for (x=0; x < (ssize_t) chroma_image->columns; x++)
864 (void) WriteBlobByte(image,ScaleQuantumToChar(
865 GetPixelBlue(chroma_image,p)));
867 (void) WriteBlobShort(image,ScaleQuantumToShort(
868 GetPixelBlue(chroma_image,p)));
869 p+=GetPixelChannels(chroma_image);
872 if (image->previous == (Image *) NULL)
874 status=SetImageProgress(image,SaveImageTag,2,3);
875 if (status == MagickFalse)
879 chroma_image=DestroyImage(chroma_image);
880 if (interlace == PartitionInterlace)
881 (void) CopyMagickString(image->filename,image_info->filename,
883 if (GetNextImageInList(image) == (Image *) NULL)
885 image=SyncNextImageInList(image);
886 status=SetImageProgress(image,SaveImagesTag,scene++,imageListLength);
887 if (status == MagickFalse)
889 } while (image_info->adjoin != MagickFalse);
890 (void) CloseBlob(image);