blob: 47121dfa893a5d3dabea5db5b24b2835136e219a [file] [log] [blame]
cristy3ed852e2009-09-05 21:47:34 +00001/*
2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3% %
4% %
5% %
6% RRRR AAA W W %
7% R R A A W W %
8% RRRR AAAAA W W W %
9% R R A A WW WW %
10% R R A A W W %
11% %
12% %
13% Read/Write RAW Image Format %
14% %
15% Software Design %
16% John Cristy %
17% July 1992 %
18% %
19% %
cristy7e41fe82010-12-04 23:12:08 +000020% Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization %
cristy3ed852e2009-09-05 21:47:34 +000021% dedicated to making software imaging solutions freely available. %
22% %
23% You may not use this file except in compliance with the License. You may %
24% obtain a copy of the License at %
25% %
26% http://www.imagemagick.org/script/license.php %
27% %
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. %
33% %
34%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35%
36%
37*/
38
39/*
40 Include declarations.
41*/
cristy4c08aed2011-07-01 19:47:50 +000042#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/image.h"
51#include "MagickCore/image-private.h"
52#include "MagickCore/list.h"
53#include "MagickCore/magick.h"
54#include "MagickCore/memory_.h"
55#include "MagickCore/monitor.h"
56#include "MagickCore/monitor-private.h"
57#include "MagickCore/pixel-accessor.h"
58#include "MagickCore/quantum-private.h"
59#include "MagickCore/quantum-private.h"
60#include "MagickCore/static.h"
61#include "MagickCore/statistic.h"
62#include "MagickCore/string_.h"
63#include "MagickCore/module.h"
cristy3ed852e2009-09-05 21:47:34 +000064
65/*
66 Forward declarations.
67*/
68static MagickBooleanType
cristy3a37efd2011-08-28 20:31:03 +000069 WriteRAWImage(const ImageInfo *,Image *,ExceptionInfo *);
cristy3ed852e2009-09-05 21:47:34 +000070
71/*
72%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
73% %
74% %
75% %
76% R e a d R A W I m a g e %
77% %
78% %
79% %
80%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
81%
82% ReadRAWImage() reads an image of raw samples and returns it. It allocates
83% the memory necessary for the new Image structure and returns a pointer to
84% the new image.
85%
86% The format of the ReadRAWImage method is:
87%
88% Image *ReadRAWImage(const ImageInfo *image_info,ExceptionInfo *exception)
89%
90% A description of each parameter follows:
91%
92% o image_info: the image info.
93%
94% o exception: return any errors or warnings in this structure.
95%
96*/
97static Image *ReadRAWImage(const ImageInfo *image_info,
98 ExceptionInfo *exception)
99{
100 Image
101 *canvas_image,
102 *image;
103
cristy3ed852e2009-09-05 21:47:34 +0000104 MagickBooleanType
105 status;
106
cristy9af8a2a2009-10-02 13:29:27 +0000107 MagickOffsetType
108 scene;
109
cristy3ed852e2009-09-05 21:47:34 +0000110 QuantumInfo
111 *quantum_info;
112
113 QuantumType
114 quantum_type;
115
cristyb20901d2010-09-16 23:13:55 +0000116 size_t
117 length;
cristy3ed852e2009-09-05 21:47:34 +0000118
119 ssize_t
cristyc6da28e2011-04-28 01:41:35 +0000120 count,
121 y;
cristy3ed852e2009-09-05 21:47:34 +0000122
cristy3ed852e2009-09-05 21:47:34 +0000123 unsigned char
124 *pixels;
125
126 /*
127 Open image file.
128 */
129 assert(image_info != (const ImageInfo *) NULL);
130 assert(image_info->signature == MagickSignature);
131 if (image_info->debug != MagickFalse)
132 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
133 image_info->filename);
134 assert(exception != (ExceptionInfo *) NULL);
135 assert(exception->signature == MagickSignature);
136 image=AcquireImage(image_info);
137 if ((image->columns == 0) || (image->rows == 0))
138 ThrowReaderException(OptionError,"MustSpecifyImageSize");
139 status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
140 if (status == MagickFalse)
141 {
142 image=DestroyImageList(image);
143 return((Image *) NULL);
144 }
cristyd4297022010-09-16 22:59:09 +0000145 if (DiscardBlobBytes(image,image->offset) == MagickFalse)
146 ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
147 image->filename);
cristy3ed852e2009-09-05 21:47:34 +0000148 /*
149 Create virtual canvas to support cropping (i.e. image.gray[100x100+10+20]).
150 */
151 canvas_image=CloneImage(image,image->extract_info.width,1,MagickFalse,
152 exception);
153 (void) SetImageVirtualPixelMethod(canvas_image,BlackVirtualPixelMethod);
154 quantum_type=GrayQuantum;
155 quantum_info=AcquireQuantumInfo(image_info,canvas_image);
156 if (quantum_info == (QuantumInfo *) NULL)
157 ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
158 pixels=GetQuantumPixels(quantum_info);
159 if (image_info->number_scenes != 0)
160 while (image->scene < image_info->scene)
161 {
162 /*
163 Skip to next image.
164 */
165 image->scene++;
166 length=GetQuantumExtent(canvas_image,quantum_info,quantum_type);
cristybb503372010-05-27 20:51:26 +0000167 for (y=0; y < (ssize_t) image->rows; y++)
cristy3ed852e2009-09-05 21:47:34 +0000168 {
169 count=ReadBlob(image,length,pixels);
170 if (count != (ssize_t) length)
171 break;
172 }
173 }
cristy9af8a2a2009-10-02 13:29:27 +0000174 scene=0;
175 count=0;
176 length=0;
cristy3ed852e2009-09-05 21:47:34 +0000177 do
178 {
179 /*
180 Read pixels to virtual canvas image then push to image.
181 */
182 if ((image_info->ping != MagickFalse) && (image_info->number_scenes != 0))
183 if (image->scene >= (image_info->scene+image_info->number_scenes-1))
184 break;
cristy9af8a2a2009-10-02 13:29:27 +0000185 if (scene == 0)
186 {
187 length=GetQuantumExtent(canvas_image,quantum_info,quantum_type);
188 count=ReadBlob(image,length,pixels);
189 }
cristybb503372010-05-27 20:51:26 +0000190 for (y=0; y < (ssize_t) image->extract_info.height; y++)
cristy3ed852e2009-09-05 21:47:34 +0000191 {
cristy4c08aed2011-07-01 19:47:50 +0000192 register const Quantum
cristyc47d1f82009-11-26 01:44:43 +0000193 *restrict p;
cristy9af8a2a2009-10-02 13:29:27 +0000194
cristy4c08aed2011-07-01 19:47:50 +0000195 register Quantum
cristyc47d1f82009-11-26 01:44:43 +0000196 *restrict q;
cristy9af8a2a2009-10-02 13:29:27 +0000197
cristyc6da28e2011-04-28 01:41:35 +0000198 register ssize_t
199 x;
200
cristy9af8a2a2009-10-02 13:29:27 +0000201 if (count != (ssize_t) length)
202 {
203 ThrowFileException(exception,CorruptImageError,
204 "UnexpectedEndOfFile",image->filename);
205 break;
206 }
cristy3ed852e2009-09-05 21:47:34 +0000207 q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1,exception);
cristy4c08aed2011-07-01 19:47:50 +0000208 if (q == (const Quantum *) NULL)
cristy3ed852e2009-09-05 21:47:34 +0000209 break;
210 length=ImportQuantumPixels(canvas_image,(CacheView *) NULL,quantum_info,
211 quantum_type,pixels,exception);
212 if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
213 break;
cristy3ed852e2009-09-05 21:47:34 +0000214 if (((y-image->extract_info.y) >= 0) &&
cristybb503372010-05-27 20:51:26 +0000215 ((y-image->extract_info.y) < (ssize_t) image->rows))
cristy3ed852e2009-09-05 21:47:34 +0000216 {
217 p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
cristy9af8a2a2009-10-02 13:29:27 +0000218 image->columns,1,exception);
219 q=QueueAuthenticPixels(image,0,y-image->extract_info.y,image->columns,
220 1,exception);
cristy4c08aed2011-07-01 19:47:50 +0000221 if ((p == (const Quantum *) NULL) || (q == (Quantum *) NULL))
cristy3ed852e2009-09-05 21:47:34 +0000222 break;
cristybb503372010-05-27 20:51:26 +0000223 for (x=0; x < (ssize_t) image->columns; x++)
cristy3ed852e2009-09-05 21:47:34 +0000224 {
cristy4c08aed2011-07-01 19:47:50 +0000225 SetPixelRed(image,GetPixelRed(canvas_image,p),q);
226 SetPixelGreen(image,GetPixelGreen(canvas_image,p),q);
227 SetPixelBlue(image,GetPixelBlue(canvas_image,p),q);
cristyed231572011-07-14 02:18:59 +0000228 p+=GetPixelChannels(canvas_image);
229 q+=GetPixelChannels(image);
cristy3ed852e2009-09-05 21:47:34 +0000230 }
231 if (SyncAuthenticPixels(image,exception) == MagickFalse)
232 break;
233 }
234 if (image->previous == (Image *) NULL)
235 {
cristycee97112010-05-28 00:44:52 +0000236 status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,
cristyc6da28e2011-04-28 01:41:35 +0000237 image->rows);
cristy3ed852e2009-09-05 21:47:34 +0000238 if (status == MagickFalse)
239 break;
240 }
cristy9af8a2a2009-10-02 13:29:27 +0000241 count=ReadBlob(image,length,pixels);
cristy3ed852e2009-09-05 21:47:34 +0000242 }
243 SetQuantumImageType(image,quantum_type);
244 /*
245 Proceed to next image.
246 */
247 if (image_info->number_scenes != 0)
248 if (image->scene >= (image_info->scene+image_info->number_scenes-1))
249 break;
250 if (count == (ssize_t) length)
251 {
252 /*
253 Allocate next image structure.
254 */
255 AcquireNextImage(image_info,image);
256 if (GetNextImageInList(image) == (Image *) NULL)
257 {
258 image=DestroyImageList(image);
259 return((Image *) NULL);
260 }
261 image=SyncNextImageInList(image);
262 status=SetImageProgress(image,LoadImagesTag,TellBlob(image),
263 GetBlobSize(image));
264 if (status == MagickFalse)
265 break;
266 }
cristy9af8a2a2009-10-02 13:29:27 +0000267 scene++;
cristy3ed852e2009-09-05 21:47:34 +0000268 } while (count == (ssize_t) length);
269 quantum_info=DestroyQuantumInfo(quantum_info);
cristy01a3f332009-10-27 14:17:37 +0000270 InheritException(&image->exception,&canvas_image->exception);
cristy3ed852e2009-09-05 21:47:34 +0000271 canvas_image=DestroyImage(canvas_image);
272 (void) CloseBlob(image);
273 return(GetFirstImageInList(image));
274}
275
276/*
277%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
278% %
279% %
280% %
281% R e g i s t e r R A W I m a g e %
282% %
283% %
284% %
285%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
286%
287% RegisterRAWImage() adds attributes for the RAW image format to the list of
288% supported formats. The attributes include the image format tag, a method to
289% read and/or write the format, whether the format supports the saving of
290% more than one frame to the same file or blob, whether the format supports
291% native in-memory I/O, and a brief description of the format.
292%
293% The format of the RegisterRAWImage method is:
294%
cristybb503372010-05-27 20:51:26 +0000295% size_t RegisterRAWImage(void)
cristy3ed852e2009-09-05 21:47:34 +0000296%
297*/
cristybb503372010-05-27 20:51:26 +0000298ModuleExport size_t RegisterRAWImage(void)
cristy3ed852e2009-09-05 21:47:34 +0000299{
300 MagickInfo
301 *entry;
302
303 entry=SetMagickInfo("R");
304 entry->decoder=(DecodeImageHandler *) ReadRAWImage;
305 entry->encoder=(EncodeImageHandler *) WriteRAWImage;
306 entry->raw=MagickTrue;
307 entry->endian_support=MagickTrue;
cristy3ed852e2009-09-05 21:47:34 +0000308 entry->description=ConstantString("Raw red samples");
309 entry->module=ConstantString("RAW");
310 (void) RegisterMagickInfo(entry);
311 entry=SetMagickInfo("C");
312 entry->decoder=(DecodeImageHandler *) ReadRAWImage;
313 entry->encoder=(EncodeImageHandler *) WriteRAWImage;
314 entry->raw=MagickTrue;
315 entry->endian_support=MagickTrue;
cristy3ed852e2009-09-05 21:47:34 +0000316 entry->description=ConstantString("Raw cyan samples");
317 entry->module=ConstantString("RAW");
318 (void) RegisterMagickInfo(entry);
319 entry=SetMagickInfo("G");
320 entry->decoder=(DecodeImageHandler *) ReadRAWImage;
321 entry->encoder=(EncodeImageHandler *) WriteRAWImage;
322 entry->raw=MagickTrue;
323 entry->endian_support=MagickTrue;
cristy3ed852e2009-09-05 21:47:34 +0000324 entry->description=ConstantString("Raw green samples");
325 entry->module=ConstantString("RAW");
326 (void) RegisterMagickInfo(entry);
327 entry=SetMagickInfo("M");
328 entry->decoder=(DecodeImageHandler *) ReadRAWImage;
329 entry->encoder=(EncodeImageHandler *) WriteRAWImage;
330 entry->raw=MagickTrue;
331 entry->endian_support=MagickTrue;
cristy3ed852e2009-09-05 21:47:34 +0000332 entry->description=ConstantString("Raw magenta samples");
333 entry->module=ConstantString("RAW");
334 (void) RegisterMagickInfo(entry);
335 entry=SetMagickInfo("B");
336 entry->decoder=(DecodeImageHandler *) ReadRAWImage;
337 entry->encoder=(EncodeImageHandler *) WriteRAWImage;
338 entry->raw=MagickTrue;
339 entry->endian_support=MagickTrue;
340 entry->description=ConstantString("Raw blue samples");
cristy3ed852e2009-09-05 21:47:34 +0000341 entry->module=ConstantString("RAW");
342 (void) RegisterMagickInfo(entry);
343 entry=SetMagickInfo("Y");
344 entry->decoder=(DecodeImageHandler *) ReadRAWImage;
345 entry->encoder=(EncodeImageHandler *) WriteRAWImage;
346 entry->raw=MagickTrue;
347 entry->endian_support=MagickTrue;
cristy3ed852e2009-09-05 21:47:34 +0000348 entry->description=ConstantString("Raw yellow samples");
349 entry->module=ConstantString("RAW");
350 (void) RegisterMagickInfo(entry);
351 entry=SetMagickInfo("A");
352 entry->decoder=(DecodeImageHandler *) ReadRAWImage;
353 entry->encoder=(EncodeImageHandler *) WriteRAWImage;
354 entry->raw=MagickTrue;
355 entry->endian_support=MagickTrue;
356 entry->description=ConstantString("Raw alpha samples");
357 entry->module=ConstantString("RAW");
358 (void) RegisterMagickInfo(entry);
359 entry=SetMagickInfo("O");
360 entry->decoder=(DecodeImageHandler *) ReadRAWImage;
361 entry->encoder=(EncodeImageHandler *) WriteRAWImage;
362 entry->raw=MagickTrue;
363 entry->endian_support=MagickTrue;
cristy3ed852e2009-09-05 21:47:34 +0000364 entry->description=ConstantString("Raw opacity samples");
365 entry->module=ConstantString("RAW");
366 (void) RegisterMagickInfo(entry);
367 entry=SetMagickInfo("K");
368 entry->decoder=(DecodeImageHandler *) ReadRAWImage;
369 entry->encoder=(EncodeImageHandler *) WriteRAWImage;
370 entry->raw=MagickTrue;
371 entry->endian_support=MagickTrue;
cristy3ed852e2009-09-05 21:47:34 +0000372 entry->description=ConstantString("Raw black samples");
373 entry->module=ConstantString("RAW");
374 (void) RegisterMagickInfo(entry);
375 return(MagickImageCoderSignature);
376}
377
378/*
379%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
380% %
381% %
382% %
383% U n r e g i s t e r R A W I m a g e %
384% %
385% %
386% %
387%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
388%
389% UnregisterRAWImage() removes format registrations made by the RAW module
390% from the list of supported formats.
391%
392% The format of the UnregisterRAWImage method is:
393%
394% UnregisterRAWImage(void)
395%
396*/
397ModuleExport void UnregisterRAWImage(void)
398{
399 (void) UnregisterMagickInfo("R");
400 (void) UnregisterMagickInfo("C");
401 (void) UnregisterMagickInfo("G");
402 (void) UnregisterMagickInfo("M");
403 (void) UnregisterMagickInfo("B");
404 (void) UnregisterMagickInfo("Y");
405 (void) UnregisterMagickInfo("A");
406 (void) UnregisterMagickInfo("O");
407 (void) UnregisterMagickInfo("K");
408}
409
410/*
411%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
412% %
413% %
414% %
415% W r i t e R A W I m a g e %
416% %
417% %
418% %
419%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
420%
421% WriteRAWImage() writes an image to a file as raw intensity values.
422%
423% The format of the WriteRAWImage method is:
424%
cristy3a37efd2011-08-28 20:31:03 +0000425% MagickBooleanType WriteRAWImage(const ImageInfo *image_info,
426% Image *image,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000427%
428% A description of each parameter follows.
429%
430% o image_info: the image info.
431%
432% o image: The image.
433%
cristy3a37efd2011-08-28 20:31:03 +0000434% o exception: return any errors or warnings in this structure.
435%
cristy3ed852e2009-09-05 21:47:34 +0000436*/
cristy3a37efd2011-08-28 20:31:03 +0000437static MagickBooleanType WriteRAWImage(const ImageInfo *image_info,Image *image,
438 ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000439{
cristy3ed852e2009-09-05 21:47:34 +0000440 MagickOffsetType
441 scene;
442
443 QuantumInfo
444 *quantum_info;
445
446 QuantumType
447 quantum_type;
448
449 MagickBooleanType
450 status;
451
cristy4c08aed2011-07-01 19:47:50 +0000452 register const Quantum
cristy3ed852e2009-09-05 21:47:34 +0000453 *p;
454
cristy3ed852e2009-09-05 21:47:34 +0000455 size_t
456 length;
457
cristyc6da28e2011-04-28 01:41:35 +0000458 ssize_t
459 count,
460 y;
461
cristy3ed852e2009-09-05 21:47:34 +0000462 unsigned char
463 *pixels;
464
465 /*
466 Open output image file.
467 */
468 assert(image_info != (const ImageInfo *) NULL);
469 assert(image_info->signature == MagickSignature);
470 assert(image != (Image *) NULL);
471 assert(image->signature == MagickSignature);
472 if (image->debug != MagickFalse)
473 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
cristy3a37efd2011-08-28 20:31:03 +0000474 assert(exception != (ExceptionInfo *) NULL);
475 assert(exception->signature == MagickSignature);
476 status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception);
cristy3ed852e2009-09-05 21:47:34 +0000477 if (status == MagickFalse)
478 return(status);
479 switch (*image->magick)
480 {
481 case 'A':
482 case 'a':
483 {
484 quantum_type=AlphaQuantum;
485 break;
486 }
487 case 'B':
488 case 'b':
489 {
490 quantum_type=BlueQuantum;
491 break;
492 }
493 case 'C':
494 case 'c':
495 {
496 quantum_type=CyanQuantum;
497 if (image->colorspace == CMYKColorspace)
498 break;
499 ThrowWriterException(ImageError,"ColorSeparatedImageRequired");
500 }
501 case 'g':
502 case 'G':
503 {
504 quantum_type=GreenQuantum;
505 break;
506 }
507 case 'I':
508 case 'i':
509 {
510 quantum_type=IndexQuantum;
511 break;
512 }
513 case 'K':
514 case 'k':
515 {
516 quantum_type=BlackQuantum;
517 if (image->colorspace == CMYKColorspace)
518 break;
519 ThrowWriterException(ImageError,"ColorSeparatedImageRequired");
520 }
521 case 'M':
522 case 'm':
523 {
524 quantum_type=MagentaQuantum;
525 if (image->colorspace == CMYKColorspace)
526 break;
527 ThrowWriterException(ImageError,"ColorSeparatedImageRequired");
528 }
529 case 'o':
530 case 'O':
531 {
532 quantum_type=OpacityQuantum;
533 break;
534 }
535 case 'R':
536 case 'r':
537 {
538 quantum_type=RedQuantum;
539 break;
540 }
541 case 'Y':
542 case 'y':
543 {
544 quantum_type=YellowQuantum;
545 if (image->colorspace == CMYKColorspace)
546 break;
547 ThrowWriterException(ImageError,"ColorSeparatedImageRequired");
548 }
549 default:
550 {
551 quantum_type=GrayQuantum;
552 break;
553 }
554 }
555 scene=0;
556 do
557 {
558 /*
559 Convert image to RAW raster pixels.
560 */
561 quantum_info=AcquireQuantumInfo(image_info,image);
562 if (quantum_info == (QuantumInfo *) NULL)
563 ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
564 pixels=GetQuantumPixels(quantum_info);
cristybb503372010-05-27 20:51:26 +0000565 for (y=0; y < (ssize_t) image->rows; y++)
cristy3ed852e2009-09-05 21:47:34 +0000566 {
cristy3a37efd2011-08-28 20:31:03 +0000567 p=GetVirtualPixels(image,0,y,image->columns,1,exception);
cristy4c08aed2011-07-01 19:47:50 +0000568 if (p == (const Quantum *) NULL)
cristy3ed852e2009-09-05 21:47:34 +0000569 break;
cristy4c08aed2011-07-01 19:47:50 +0000570 length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
cristy3a37efd2011-08-28 20:31:03 +0000571 quantum_type,pixels,exception);
cristy3ed852e2009-09-05 21:47:34 +0000572 count=WriteBlob(image,length,pixels);
573 if (count != (ssize_t) length)
574 break;
575 if (image->previous == (Image *) NULL)
576 {
cristycee97112010-05-28 00:44:52 +0000577 status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
cristy566c5a82010-06-06 15:37:51 +0000578 image->rows);
cristy3ed852e2009-09-05 21:47:34 +0000579 if (status == MagickFalse)
580 break;
581 }
582 }
583 quantum_info=DestroyQuantumInfo(quantum_info);
584 if (GetNextImageInList(image) == (Image *) NULL)
585 break;
586 image=SyncNextImageInList(image);
587 status=SetImageProgress(image,SaveImagesTag,scene++,
588 GetImageListLength(image));
589 if (status == MagickFalse)
590 break;
591 } while (image_info->adjoin != MagickFalse);
592 (void) CloseBlob(image);
593 return(MagickTrue);
594}