blob: 9daf89490221cc242845c68464558e3948e87f74 [file] [log] [blame]
cristy3ed852e2009-09-05 21:47:34 +00001/*
2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3% %
4% %
5% %
6% RRRR GGGG BBBB %
7% R R G B B %
8% RRRR G GG BBBB %
9% R R G G B B %
10% R R GGG BBBB %
11% %
12% %
13% Read/Write Raw RGB Image Format %
14% %
15% Software Design %
16% John Cristy %
17% July 1992 %
18% %
19% %
20% Copyright 1999-2008 ImageMagick Studio LLC, a non-profit organization %
21% 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"
cristy510d06a2011-07-06 23:43:54 +000047#include "MagickCore/colorspace-private.h"
cristy4c08aed2011-07-01 19:47:50 +000048#include "MagickCore/constitute.h"
49#include "MagickCore/exception.h"
50#include "MagickCore/exception-private.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/quantum-private.h"
60#include "MagickCore/static.h"
61#include "MagickCore/statistic.h"
62#include "MagickCore/string_.h"
63#include "MagickCore/module.h"
64#include "MagickCore/utility.h"
cristy3ed852e2009-09-05 21:47:34 +000065
66/*
67 Forward declarations.
68*/
69static MagickBooleanType
cristy3a37efd2011-08-28 20:31:03 +000070 WriteRGBImage(const ImageInfo *,Image *,ExceptionInfo *);
cristy3ed852e2009-09-05 21:47:34 +000071
72/*
73%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
74% %
75% %
76% %
77% R e a d R G B I m a g e %
78% %
79% %
80% %
81%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
82%
cristy90dbac72010-08-22 15:08:40 +000083% ReadRGBImage() reads an image of raw RGB, RGBA, or RGBO samples and returns
84% it. It allocates the memory necessary for the new Image structure and
85% returns a pointer to the new image.
cristy3ed852e2009-09-05 21:47:34 +000086%
87% The format of the ReadRGBImage method is:
88%
cristy90dbac72010-08-22 15:08:40 +000089% Image *ReadRGBImage(const ImageInfo *image_info,
90% ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +000091%
92% A description of each parameter follows:
93%
94% o image_info: the image info.
95%
96% o exception: return any errors or warnings in this structure.
97%
98*/
cristy90dbac72010-08-22 15:08:40 +000099static Image *ReadRGBImage(const ImageInfo *image_info,
100 ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000101{
102 Image
103 *canvas_image,
104 *image;
105
cristy3ed852e2009-09-05 21:47:34 +0000106 MagickBooleanType
107 status;
108
109 MagickOffsetType
110 scene;
111
112 QuantumInfo
113 *quantum_info;
114
115 QuantumType
116 quantum_type;
117
cristybb503372010-05-27 20:51:26 +0000118 register ssize_t
cristy90dbac72010-08-22 15:08:40 +0000119 i;
cristy3ed852e2009-09-05 21:47:34 +0000120
cristyc6da28e2011-04-28 01:41:35 +0000121 size_t
122 length;
123
cristy3ed852e2009-09-05 21:47:34 +0000124 ssize_t
cristya38675f2010-08-21 18:35:13 +0000125 count,
126 y;
cristy3ed852e2009-09-05 21:47:34 +0000127
cristy3ed852e2009-09-05 21:47:34 +0000128 unsigned char
129 *pixels;
130
cristy3ed852e2009-09-05 21:47:34 +0000131 /*
132 Open image file.
133 */
134 assert(image_info != (const ImageInfo *) NULL);
135 assert(image_info->signature == MagickSignature);
136 if (image_info->debug != MagickFalse)
137 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
138 image_info->filename);
139 assert(exception != (ExceptionInfo *) NULL);
140 assert(exception->signature == MagickSignature);
141 image=AcquireImage(image_info);
142 if ((image->columns == 0) || (image->rows == 0))
143 ThrowReaderException(OptionError,"MustSpecifyImageSize");
cristy90dbac72010-08-22 15:08:40 +0000144 image->colorspace=RGBColorspace;
cristy3ed852e2009-09-05 21:47:34 +0000145 if (image_info->interlace != PartitionInterlace)
146 {
147 status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
148 if (status == MagickFalse)
149 {
150 image=DestroyImageList(image);
151 return((Image *) NULL);
152 }
cristyd4297022010-09-16 22:59:09 +0000153 if (DiscardBlobBytes(image,image->offset) == MagickFalse)
154 ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
155 image->filename);
cristy3ed852e2009-09-05 21:47:34 +0000156 }
157 /*
158 Create virtual canvas to support cropping (i.e. image.rgb[100x100+10+20]).
159 */
160 canvas_image=CloneImage(image,image->extract_info.width,1,MagickFalse,
161 exception);
162 (void) SetImageVirtualPixelMethod(canvas_image,BlackVirtualPixelMethod);
163 quantum_info=AcquireQuantumInfo(image_info,canvas_image);
164 if (quantum_info == (QuantumInfo *) NULL)
165 ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
166 pixels=GetQuantumPixels(quantum_info);
167 quantum_type=RGBQuantum;
cristy90dbac72010-08-22 15:08:40 +0000168 if (LocaleCompare(image_info->magick,"RGBA") == 0)
cristya38675f2010-08-21 18:35:13 +0000169 {
cristy90dbac72010-08-22 15:08:40 +0000170 quantum_type=RGBAQuantum;
171 image->matte=MagickTrue;
cristya38675f2010-08-21 18:35:13 +0000172 }
cristy90dbac72010-08-22 15:08:40 +0000173 if (LocaleCompare(image_info->magick,"RGBO") == 0)
174 {
175 quantum_type=RGBOQuantum;
176 image->matte=MagickTrue;
177 }
cristy3ed852e2009-09-05 21:47:34 +0000178 if (image_info->number_scenes != 0)
179 while (image->scene < image_info->scene)
180 {
181 /*
182 Skip to next image.
183 */
184 image->scene++;
185 length=GetQuantumExtent(canvas_image,quantum_info,quantum_type);
cristybb503372010-05-27 20:51:26 +0000186 for (y=0; y < (ssize_t) image->rows; y++)
cristy3ed852e2009-09-05 21:47:34 +0000187 {
188 count=ReadBlob(image,length,pixels);
189 if (count != (ssize_t) length)
190 break;
191 }
192 }
cristy3ed852e2009-09-05 21:47:34 +0000193 count=0;
194 length=0;
195 scene=0;
196 do
197 {
198 /*
199 Read pixels to virtual canvas image then push to image.
200 */
201 if ((image_info->ping != MagickFalse) && (image_info->number_scenes != 0))
202 if (image->scene >= (image_info->scene+image_info->number_scenes-1))
203 break;
cristy90dbac72010-08-22 15:08:40 +0000204 image->colorspace=RGBColorspace;
cristy3ed852e2009-09-05 21:47:34 +0000205 switch (image_info->interlace)
206 {
207 case NoInterlace:
208 default:
209 {
210 /*
211 No interlacing: RGBRGBRGBRGBRGBRGB...
212 */
213 if (scene == 0)
214 {
215 length=GetQuantumExtent(canvas_image,quantum_info,quantum_type);
216 count=ReadBlob(image,length,pixels);
cristy3ed852e2009-09-05 21:47:34 +0000217 }
cristybb503372010-05-27 20:51:26 +0000218 for (y=0; y < (ssize_t) image->extract_info.height; y++)
cristy3ed852e2009-09-05 21:47:34 +0000219 {
cristy4c08aed2011-07-01 19:47:50 +0000220 register const Quantum
cristyc47d1f82009-11-26 01:44:43 +0000221 *restrict p;
cristy3ed852e2009-09-05 21:47:34 +0000222
cristy4c08aed2011-07-01 19:47:50 +0000223 register Quantum
cristyc47d1f82009-11-26 01:44:43 +0000224 *restrict q;
cristy3ed852e2009-09-05 21:47:34 +0000225
cristy90dbac72010-08-22 15:08:40 +0000226 register ssize_t
227 x;
228
cristy21da32d2009-09-12 14:56:09 +0000229 if (count != (ssize_t) length)
230 {
231 ThrowFileException(exception,CorruptImageError,
232 "UnexpectedEndOfFile",image->filename);
233 break;
234 }
cristy3ed852e2009-09-05 21:47:34 +0000235 q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1,
236 exception);
cristyacd2ed22011-08-30 01:44:23 +0000237 if (q == (Quantum *) NULL)
cristy3ed852e2009-09-05 21:47:34 +0000238 break;
239 length=ImportQuantumPixels(canvas_image,(CacheView *) NULL,
240 quantum_info,quantum_type,pixels,exception);
241 if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
242 break;
cristy90dbac72010-08-22 15:08:40 +0000243 if (((y-image->extract_info.y) >= 0) &&
cristybb503372010-05-27 20:51:26 +0000244 ((y-image->extract_info.y) < (ssize_t) image->rows))
cristy3ed852e2009-09-05 21:47:34 +0000245 {
246 p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
247 canvas_image->columns,1,exception);
248 q=QueueAuthenticPixels(image,0,y-image->extract_info.y,
249 image->columns,1,exception);
cristy4c08aed2011-07-01 19:47:50 +0000250 if ((p == (const Quantum *) NULL) ||
cristyacd2ed22011-08-30 01:44:23 +0000251 (q == (Quantum *) NULL))
cristy3ed852e2009-09-05 21:47:34 +0000252 break;
cristybb503372010-05-27 20:51:26 +0000253 for (x=0; x < (ssize_t) image->columns; x++)
cristy3ed852e2009-09-05 21:47:34 +0000254 {
cristy4c08aed2011-07-01 19:47:50 +0000255 SetPixelRed(image,GetPixelRed(canvas_image,p),q);
256 SetPixelGreen(image,GetPixelGreen(canvas_image,p),q);
257 SetPixelBlue(image,GetPixelBlue(canvas_image,p),q);
258 SetPixelAlpha(image,OpaqueAlpha,q);
cristy90dbac72010-08-22 15:08:40 +0000259 if (image->matte != MagickFalse)
cristy4c08aed2011-07-01 19:47:50 +0000260 SetPixelAlpha(image,GetPixelAlpha(canvas_image,p),q);
cristyed231572011-07-14 02:18:59 +0000261 p+=GetPixelChannels(canvas_image);
262 q+=GetPixelChannels(image);
cristy3ed852e2009-09-05 21:47:34 +0000263 }
264 if (SyncAuthenticPixels(image,exception) == MagickFalse)
265 break;
266 }
267 if (image->previous == (Image *) NULL)
268 {
cristycee97112010-05-28 00:44:52 +0000269 status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,
270 image->rows);
cristy3ed852e2009-09-05 21:47:34 +0000271 if (status == MagickFalse)
272 break;
273 }
274 count=ReadBlob(image,length,pixels);
cristy3ed852e2009-09-05 21:47:34 +0000275 }
276 break;
277 }
278 case LineInterlace:
279 {
cristy90dbac72010-08-22 15:08:40 +0000280 static QuantumType
281 quantum_types[4] =
282 {
283 RedQuantum,
284 GreenQuantum,
285 BlueQuantum,
286 AlphaQuantum
287 };
288
cristy3ed852e2009-09-05 21:47:34 +0000289 /*
290 Line interlacing: RRR...GGG...BBB...RRR...GGG...BBB...
291 */
cristy90dbac72010-08-22 15:08:40 +0000292 if (LocaleCompare(image_info->magick,"RGBO") == 0)
293 quantum_types[3]=OpacityQuantum;
cristy3ed852e2009-09-05 21:47:34 +0000294 if (scene == 0)
295 {
cristy90dbac72010-08-22 15:08:40 +0000296 length=GetQuantumExtent(canvas_image,quantum_info,RedQuantum);
cristy3ed852e2009-09-05 21:47:34 +0000297 count=ReadBlob(image,length,pixels);
cristy3ed852e2009-09-05 21:47:34 +0000298 }
cristybb503372010-05-27 20:51:26 +0000299 for (y=0; y < (ssize_t) image->extract_info.height; y++)
cristy3ed852e2009-09-05 21:47:34 +0000300 {
cristy4c08aed2011-07-01 19:47:50 +0000301 register const Quantum
cristyc47d1f82009-11-26 01:44:43 +0000302 *restrict p;
cristy3ed852e2009-09-05 21:47:34 +0000303
cristy4c08aed2011-07-01 19:47:50 +0000304 register Quantum
cristyc47d1f82009-11-26 01:44:43 +0000305 *restrict q;
cristy3ed852e2009-09-05 21:47:34 +0000306
cristy90dbac72010-08-22 15:08:40 +0000307 register ssize_t
308 x;
309
cristy21da32d2009-09-12 14:56:09 +0000310 if (count != (ssize_t) length)
311 {
312 ThrowFileException(exception,CorruptImageError,
313 "UnexpectedEndOfFile",image->filename);
314 break;
315 }
cristy90dbac72010-08-22 15:08:40 +0000316 for (i=0; i < (ssize_t) (image->matte != MagickFalse ? 4 : 3); i++)
cristy3ed852e2009-09-05 21:47:34 +0000317 {
cristy90dbac72010-08-22 15:08:40 +0000318 quantum_type=quantum_types[i];
cristy3ed852e2009-09-05 21:47:34 +0000319 q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1,
320 exception);
cristyacd2ed22011-08-30 01:44:23 +0000321 if (q == (Quantum *) NULL)
cristy3ed852e2009-09-05 21:47:34 +0000322 break;
323 length=ImportQuantumPixels(canvas_image,(CacheView *) NULL,
cristy90dbac72010-08-22 15:08:40 +0000324 quantum_info,quantum_type,pixels,exception);
cristy3ed852e2009-09-05 21:47:34 +0000325 if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
326 break;
cristy90dbac72010-08-22 15:08:40 +0000327 if (((y-image->extract_info.y) >= 0) &&
cristybb503372010-05-27 20:51:26 +0000328 ((y-image->extract_info.y) < (ssize_t) image->rows))
cristy3ed852e2009-09-05 21:47:34 +0000329 {
330 p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,
331 0,canvas_image->columns,1,exception);
332 q=GetAuthenticPixels(image,0,y-image->extract_info.y,
333 image->columns,1,exception);
cristy4c08aed2011-07-01 19:47:50 +0000334 if ((p == (const Quantum *) NULL) ||
cristyacd2ed22011-08-30 01:44:23 +0000335 (q == (Quantum *) NULL))
cristy3ed852e2009-09-05 21:47:34 +0000336 break;
cristy90dbac72010-08-22 15:08:40 +0000337 for (x=0; x < (ssize_t) image->columns; x++)
338 {
339 switch (quantum_type)
cristy3ed852e2009-09-05 21:47:34 +0000340 {
cristy90dbac72010-08-22 15:08:40 +0000341 case RedQuantum:
342 {
cristy4c08aed2011-07-01 19:47:50 +0000343 SetPixelRed(image,GetPixelRed(canvas_image,p),q);
cristy90dbac72010-08-22 15:08:40 +0000344 break;
345 }
346 case GreenQuantum:
347 {
cristy4c08aed2011-07-01 19:47:50 +0000348 SetPixelGreen(image,GetPixelGreen(canvas_image,p),q);
cristy90dbac72010-08-22 15:08:40 +0000349 break;
350 }
351 case BlueQuantum:
352 {
cristy4c08aed2011-07-01 19:47:50 +0000353 SetPixelBlue(image,GetPixelBlue(canvas_image,p),q);
cristy90dbac72010-08-22 15:08:40 +0000354 break;
355 }
356 case OpacityQuantum:
357 {
cristy4c08aed2011-07-01 19:47:50 +0000358 SetPixelAlpha(image,GetPixelAlpha(canvas_image,p),q);
cristy90dbac72010-08-22 15:08:40 +0000359 break;
360 }
361 case AlphaQuantum:
362 {
cristy4c08aed2011-07-01 19:47:50 +0000363 SetPixelAlpha(image,GetPixelAlpha(canvas_image,p),q);
cristy90dbac72010-08-22 15:08:40 +0000364 break;
365 }
366 default:
367 break;
cristy3ed852e2009-09-05 21:47:34 +0000368 }
cristyed231572011-07-14 02:18:59 +0000369 p+=GetPixelChannels(canvas_image);
370 q+=GetPixelChannels(image);
cristy90dbac72010-08-22 15:08:40 +0000371 }
cristy3ed852e2009-09-05 21:47:34 +0000372 if (SyncAuthenticPixels(image,exception) == MagickFalse)
373 break;
374 }
375 count=ReadBlob(image,length,pixels);
cristy3ed852e2009-09-05 21:47:34 +0000376 }
377 if (image->previous == (Image *) NULL)
378 {
cristycee97112010-05-28 00:44:52 +0000379 status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,
380 image->rows);
cristy3ed852e2009-09-05 21:47:34 +0000381 if (status == MagickFalse)
382 break;
383 }
384 }
385 break;
386 }
387 case PlaneInterlace:
388 {
389 /*
390 Plane interlacing: RRRRRR...GGGGGG...BBBBBB...
391 */
392 if (scene == 0)
393 {
cristy90dbac72010-08-22 15:08:40 +0000394 length=GetQuantumExtent(canvas_image,quantum_info,RedQuantum);
cristy3ed852e2009-09-05 21:47:34 +0000395 count=ReadBlob(image,length,pixels);
cristy3ed852e2009-09-05 21:47:34 +0000396 }
cristy90dbac72010-08-22 15:08:40 +0000397 for (y=0; y < (ssize_t) image->extract_info.height; y++)
cristy3ed852e2009-09-05 21:47:34 +0000398 {
cristy4c08aed2011-07-01 19:47:50 +0000399 register const Quantum
cristy90dbac72010-08-22 15:08:40 +0000400 *restrict p;
cristy3ed852e2009-09-05 21:47:34 +0000401
cristy4c08aed2011-07-01 19:47:50 +0000402 register Quantum
cristy90dbac72010-08-22 15:08:40 +0000403 *restrict q;
cristy3ed852e2009-09-05 21:47:34 +0000404
cristy90dbac72010-08-22 15:08:40 +0000405 register ssize_t
406 x;
cristy3ed852e2009-09-05 21:47:34 +0000407
cristy90dbac72010-08-22 15:08:40 +0000408 if (count != (ssize_t) length)
cristy3ed852e2009-09-05 21:47:34 +0000409 {
cristy90dbac72010-08-22 15:08:40 +0000410 ThrowFileException(exception,CorruptImageError,
411 "UnexpectedEndOfFile",image->filename);
412 break;
413 }
414 q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1,
415 exception);
cristyacd2ed22011-08-30 01:44:23 +0000416 if (q == (Quantum *) NULL)
cristy90dbac72010-08-22 15:08:40 +0000417 break;
418 length=ImportQuantumPixels(canvas_image,(CacheView *) NULL,
419 quantum_info,RedQuantum,pixels,exception);
420 if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
421 break;
422 if (((y-image->extract_info.y) >= 0) &&
423 ((y-image->extract_info.y) < (ssize_t) image->rows))
424 {
425 p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
426 canvas_image->columns,1,exception);
427 q=GetAuthenticPixels(image,0,y-image->extract_info.y,
428 image->columns,1,exception);
cristy4c08aed2011-07-01 19:47:50 +0000429 if ((p == (const Quantum *) NULL) ||
cristyacd2ed22011-08-30 01:44:23 +0000430 (q == (Quantum *) NULL))
cristy90dbac72010-08-22 15:08:40 +0000431 break;
432 for (x=0; x < (ssize_t) image->columns; x++)
433 {
cristy4c08aed2011-07-01 19:47:50 +0000434 SetPixelRed(image,GetPixelRed(canvas_image,p),q);
cristyed231572011-07-14 02:18:59 +0000435 p+=GetPixelChannels(canvas_image);
436 q+=GetPixelChannels(image);
cristy90dbac72010-08-22 15:08:40 +0000437 }
438 if (SyncAuthenticPixels(image,exception) == MagickFalse)
cristy3ed852e2009-09-05 21:47:34 +0000439 break;
440 }
cristy90dbac72010-08-22 15:08:40 +0000441 count=ReadBlob(image,length,pixels);
cristy3ed852e2009-09-05 21:47:34 +0000442 }
443 if (image->previous == (Image *) NULL)
444 {
cristy90dbac72010-08-22 15:08:40 +0000445 status=SetImageProgress(image,LoadImageTag,1,6);
446 if (status == MagickFalse)
447 break;
448 }
449 for (y=0; y < (ssize_t) image->extract_info.height; y++)
450 {
cristy4c08aed2011-07-01 19:47:50 +0000451 register const Quantum
cristy90dbac72010-08-22 15:08:40 +0000452 *restrict p;
453
cristy4c08aed2011-07-01 19:47:50 +0000454 register Quantum
cristy90dbac72010-08-22 15:08:40 +0000455 *restrict q;
456
457 register ssize_t
458 x;
459
460 if (count != (ssize_t) length)
461 {
462 ThrowFileException(exception,CorruptImageError,
463 "UnexpectedEndOfFile",image->filename);
464 break;
465 }
466 q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1,
467 exception);
cristyacd2ed22011-08-30 01:44:23 +0000468 if (q == (Quantum *) NULL)
cristy90dbac72010-08-22 15:08:40 +0000469 break;
470 length=ImportQuantumPixels(canvas_image,(CacheView *) NULL,
471 quantum_info,GreenQuantum,pixels,exception);
472 if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
473 break;
474 if (((y-image->extract_info.y) >= 0) &&
475 ((y-image->extract_info.y) < (ssize_t) image->rows))
476 {
477 p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
478 canvas_image->columns,1,exception);
479 q=GetAuthenticPixels(image,0,y-image->extract_info.y,
480 image->columns,1,exception);
cristy4c08aed2011-07-01 19:47:50 +0000481 if ((p == (const Quantum *) NULL) ||
cristyacd2ed22011-08-30 01:44:23 +0000482 (q == (Quantum *) NULL))
cristy90dbac72010-08-22 15:08:40 +0000483 break;
484 for (x=0; x < (ssize_t) image->columns; x++)
485 {
cristy4c08aed2011-07-01 19:47:50 +0000486 SetPixelGreen(image,
487 GetPixelGreen(canvas_image,p),q);
cristyed231572011-07-14 02:18:59 +0000488 p+=GetPixelChannels(canvas_image);
489 q+=GetPixelChannels(image);
cristy90dbac72010-08-22 15:08:40 +0000490 }
491 if (SyncAuthenticPixels(image,exception) == MagickFalse)
492 break;
493 }
494 count=ReadBlob(image,length,pixels);
495 }
496 if (image->previous == (Image *) NULL)
497 {
498 status=SetImageProgress(image,LoadImageTag,2,6);
499 if (status == MagickFalse)
500 break;
501 }
502 for (y=0; y < (ssize_t) image->extract_info.height; y++)
503 {
cristy4c08aed2011-07-01 19:47:50 +0000504 register const Quantum
cristy90dbac72010-08-22 15:08:40 +0000505 *restrict p;
506
cristy4c08aed2011-07-01 19:47:50 +0000507 register Quantum
cristy90dbac72010-08-22 15:08:40 +0000508 *restrict q;
509
510 register ssize_t
511 x;
512
513 if (count != (ssize_t) length)
514 {
515 ThrowFileException(exception,CorruptImageError,
516 "UnexpectedEndOfFile",image->filename);
517 break;
518 }
519 q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1,
520 exception);
cristyacd2ed22011-08-30 01:44:23 +0000521 if (q == (Quantum *) NULL)
cristy90dbac72010-08-22 15:08:40 +0000522 break;
523 length=ImportQuantumPixels(canvas_image,(CacheView *) NULL,
524 quantum_info,BlueQuantum,pixels,exception);
525 if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
526 break;
527 if (((y-image->extract_info.y) >= 0) &&
528 ((y-image->extract_info.y) < (ssize_t) image->rows))
529 {
530 p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
531 canvas_image->columns,1,exception);
532 q=GetAuthenticPixels(image,0,y-image->extract_info.y,
533 image->columns,1,exception);
cristy4c08aed2011-07-01 19:47:50 +0000534 if ((p == (const Quantum *) NULL) ||
cristyacd2ed22011-08-30 01:44:23 +0000535 (q == (Quantum *) NULL))
cristy90dbac72010-08-22 15:08:40 +0000536 break;
537 for (x=0; x < (ssize_t) image->columns; x++)
538 {
cristy4c08aed2011-07-01 19:47:50 +0000539 SetPixelBlue(image,
540 GetPixelBlue(canvas_image,p),q);
cristyed231572011-07-14 02:18:59 +0000541 p+=GetPixelChannels(canvas_image);
542 q+=GetPixelChannels(image);
cristy90dbac72010-08-22 15:08:40 +0000543 }
544 if (SyncAuthenticPixels(image,exception) == MagickFalse)
545 break;
546 }
547 count=ReadBlob(image,length,pixels);
548 }
549 if (image->previous == (Image *) NULL)
550 {
551 status=SetImageProgress(image,LoadImageTag,3,6);
552 if (status == MagickFalse)
553 break;
554 }
555 if (image->previous == (Image *) NULL)
556 {
557 status=SetImageProgress(image,LoadImageTag,4,6);
558 if (status == MagickFalse)
559 break;
560 }
561 if (image->matte != MagickFalse)
562 {
563 for (y=0; y < (ssize_t) image->extract_info.height; y++)
564 {
cristy4c08aed2011-07-01 19:47:50 +0000565 register const Quantum
cristy90dbac72010-08-22 15:08:40 +0000566 *restrict p;
567
cristy4c08aed2011-07-01 19:47:50 +0000568 register Quantum
cristy90dbac72010-08-22 15:08:40 +0000569 *restrict q;
570
571 register ssize_t
572 x;
573
574 if (count != (ssize_t) length)
575 {
576 ThrowFileException(exception,CorruptImageError,
577 "UnexpectedEndOfFile",image->filename);
578 break;
579 }
580 q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1,
581 exception);
cristyacd2ed22011-08-30 01:44:23 +0000582 if (q == (Quantum *) NULL)
cristy90dbac72010-08-22 15:08:40 +0000583 break;
584 length=ImportQuantumPixels(canvas_image,(CacheView *) NULL,
585 quantum_info,AlphaQuantum,pixels,exception);
586 if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
587 break;
588 if (((y-image->extract_info.y) >= 0) &&
589 ((y-image->extract_info.y) < (ssize_t) image->rows))
590 {
591 p=GetVirtualPixels(canvas_image,
592 canvas_image->extract_info.x,0,canvas_image->columns,1,
593 exception);
594 q=GetAuthenticPixels(image,0,y-image->extract_info.y,
595 image->columns,1,exception);
cristy4c08aed2011-07-01 19:47:50 +0000596 if ((p == (const Quantum *) NULL) ||
cristyacd2ed22011-08-30 01:44:23 +0000597 (q == (Quantum *) NULL))
cristy90dbac72010-08-22 15:08:40 +0000598 break;
599 for (x=0; x < (ssize_t) image->columns; x++)
600 {
cristy4c08aed2011-07-01 19:47:50 +0000601 SetPixelAlpha(image,
602 GetPixelAlpha(canvas_image,p),q);
cristyed231572011-07-14 02:18:59 +0000603 p+=GetPixelChannels(canvas_image);
604 q+=GetPixelChannels(image);
cristy90dbac72010-08-22 15:08:40 +0000605 }
606 if (SyncAuthenticPixels(image,exception) == MagickFalse)
607 break;
608 }
609 count=ReadBlob(image,length,pixels);
610 }
611 if (image->previous == (Image *) NULL)
612 {
613 status=SetImageProgress(image,LoadImageTag,5,6);
614 if (status == MagickFalse)
615 break;
616 }
617 }
618 if (image->previous == (Image *) NULL)
619 {
620 status=SetImageProgress(image,LoadImageTag,6,6);
cristy3ed852e2009-09-05 21:47:34 +0000621 if (status == MagickFalse)
622 break;
623 }
624 break;
625 }
626 case PartitionInterlace:
627 {
628 /*
629 Partition interlacing: RRRRRR..., GGGGGG..., BBBBBB...
630 */
cristy90dbac72010-08-22 15:08:40 +0000631 AppendImageFormat("R",image->filename);
632 status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
633 if (status == MagickFalse)
cristy3ed852e2009-09-05 21:47:34 +0000634 {
cristy90dbac72010-08-22 15:08:40 +0000635 canvas_image=DestroyImageList(canvas_image);
636 image=DestroyImageList(image);
637 return((Image *) NULL);
638 }
cristyd4297022010-09-16 22:59:09 +0000639 if (DiscardBlobBytes(image,image->offset) == MagickFalse)
640 ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
641 image->filename);
cristy90dbac72010-08-22 15:08:40 +0000642 length=GetQuantumExtent(canvas_image,quantum_info,RedQuantum);
643 for (i=0; i < (ssize_t) scene; i++)
644 for (y=0; y < (ssize_t) image->extract_info.height; y++)
645 if (ReadBlob(image,length,pixels) != (ssize_t) length)
cristy21da32d2009-09-12 14:56:09 +0000646 {
647 ThrowFileException(exception,CorruptImageError,
648 "UnexpectedEndOfFile",image->filename);
649 break;
650 }
cristy90dbac72010-08-22 15:08:40 +0000651 count=ReadBlob(image,length,pixels);
652 for (y=0; y < (ssize_t) image->extract_info.height; y++)
653 {
cristy4c08aed2011-07-01 19:47:50 +0000654 register const Quantum
cristy90dbac72010-08-22 15:08:40 +0000655 *restrict p;
656
cristy4c08aed2011-07-01 19:47:50 +0000657 register Quantum
cristy90dbac72010-08-22 15:08:40 +0000658 *restrict q;
659
660 register ssize_t
661 x;
662
663 if (count != (ssize_t) length)
cristy3ed852e2009-09-05 21:47:34 +0000664 {
cristy90dbac72010-08-22 15:08:40 +0000665 ThrowFileException(exception,CorruptImageError,
666 "UnexpectedEndOfFile",image->filename);
667 break;
668 }
669 q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1,
670 exception);
cristyacd2ed22011-08-30 01:44:23 +0000671 if (q == (Quantum *) NULL)
cristy90dbac72010-08-22 15:08:40 +0000672 break;
673 length=ImportQuantumPixels(canvas_image,(CacheView *) NULL,
674 quantum_info,RedQuantum,pixels,exception);
675 if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
676 break;
677 if (((y-image->extract_info.y) >= 0) &&
678 ((y-image->extract_info.y) < (ssize_t) image->rows))
679 {
680 p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
681 canvas_image->columns,1,exception);
682 q=GetAuthenticPixels(image,0,y-image->extract_info.y,
683 image->columns,1,exception);
cristy4c08aed2011-07-01 19:47:50 +0000684 if ((p == (const Quantum *) NULL) ||
cristyacd2ed22011-08-30 01:44:23 +0000685 (q == (Quantum *) NULL))
cristy90dbac72010-08-22 15:08:40 +0000686 break;
687 for (x=0; x < (ssize_t) image->columns; x++)
688 {
cristy4c08aed2011-07-01 19:47:50 +0000689 SetPixelRed(image,GetPixelRed(canvas_image,p),q);
cristyed231572011-07-14 02:18:59 +0000690 p+=GetPixelChannels(canvas_image);
691 q+=GetPixelChannels(image);
cristy90dbac72010-08-22 15:08:40 +0000692 }
693 if (SyncAuthenticPixels(image,exception) == MagickFalse)
cristy3ed852e2009-09-05 21:47:34 +0000694 break;
695 }
cristy90dbac72010-08-22 15:08:40 +0000696 count=ReadBlob(image,length,pixels);
cristy3ed852e2009-09-05 21:47:34 +0000697 }
698 if (image->previous == (Image *) NULL)
699 {
cristy90dbac72010-08-22 15:08:40 +0000700 status=SetImageProgress(image,LoadImageTag,1,5);
701 if (status == MagickFalse)
702 break;
703 }
704 (void) CloseBlob(image);
705 AppendImageFormat("G",image->filename);
706 status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
707 if (status == MagickFalse)
708 {
709 canvas_image=DestroyImageList(canvas_image);
710 image=DestroyImageList(image);
711 return((Image *) NULL);
712 }
713 length=GetQuantumExtent(canvas_image,quantum_info,GreenQuantum);
714 for (i=0; i < (ssize_t) scene; i++)
715 for (y=0; y < (ssize_t) image->extract_info.height; y++)
716 if (ReadBlob(image,length,pixels) != (ssize_t) length)
717 {
718 ThrowFileException(exception,CorruptImageError,
719 "UnexpectedEndOfFile",image->filename);
720 break;
721 }
722 count=ReadBlob(image,length,pixels);
723 for (y=0; y < (ssize_t) image->extract_info.height; y++)
724 {
cristy4c08aed2011-07-01 19:47:50 +0000725 register const Quantum
cristy90dbac72010-08-22 15:08:40 +0000726 *restrict p;
727
cristy4c08aed2011-07-01 19:47:50 +0000728 register Quantum
cristy90dbac72010-08-22 15:08:40 +0000729 *restrict q;
730
731 register ssize_t
732 x;
733
734 if (count != (ssize_t) length)
735 {
736 ThrowFileException(exception,CorruptImageError,
737 "UnexpectedEndOfFile",image->filename);
738 break;
739 }
740 q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1,
741 exception);
cristyacd2ed22011-08-30 01:44:23 +0000742 if (q == (Quantum *) NULL)
cristy90dbac72010-08-22 15:08:40 +0000743 break;
744 length=ImportQuantumPixels(canvas_image,(CacheView *) NULL,
745 quantum_info,GreenQuantum,pixels,exception);
746 if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
747 break;
748 if (((y-image->extract_info.y) >= 0) &&
749 ((y-image->extract_info.y) < (ssize_t) image->rows))
750 {
751 p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
752 canvas_image->columns,1,exception);
753 q=GetAuthenticPixels(image,0,y-image->extract_info.y,
754 image->columns,1,exception);
cristy4c08aed2011-07-01 19:47:50 +0000755 if ((p == (const Quantum *) NULL) ||
cristyacd2ed22011-08-30 01:44:23 +0000756 (q == (Quantum *) NULL))
cristy90dbac72010-08-22 15:08:40 +0000757 break;
758 for (x=0; x < (ssize_t) image->columns; x++)
759 {
cristy4c08aed2011-07-01 19:47:50 +0000760 SetPixelGreen(image,
761 GetPixelGreen(canvas_image,p),q);
cristyed231572011-07-14 02:18:59 +0000762 p+=GetPixelChannels(canvas_image);
763 q+=GetPixelChannels(image);
cristy90dbac72010-08-22 15:08:40 +0000764 }
765 if (SyncAuthenticPixels(image,exception) == MagickFalse)
766 break;
767 }
768 count=ReadBlob(image,length,pixels);
769 }
770 if (image->previous == (Image *) NULL)
771 {
772 status=SetImageProgress(image,LoadImageTag,2,5);
773 if (status == MagickFalse)
774 break;
775 }
776 (void) CloseBlob(image);
777 AppendImageFormat("B",image->filename);
778 status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
779 if (status == MagickFalse)
780 {
781 canvas_image=DestroyImageList(canvas_image);
782 image=DestroyImageList(image);
783 return((Image *) NULL);
784 }
785 length=GetQuantumExtent(canvas_image,quantum_info,BlueQuantum);
786 for (i=0; i < (ssize_t) scene; i++)
787 for (y=0; y < (ssize_t) image->extract_info.height; y++)
788 if (ReadBlob(image,length,pixels) != (ssize_t) length)
789 {
790 ThrowFileException(exception,CorruptImageError,
791 "UnexpectedEndOfFile",image->filename);
792 break;
793 }
794 count=ReadBlob(image,length,pixels);
795 for (y=0; y < (ssize_t) image->extract_info.height; y++)
796 {
cristy4c08aed2011-07-01 19:47:50 +0000797 register const Quantum
cristy90dbac72010-08-22 15:08:40 +0000798 *restrict p;
799
cristy4c08aed2011-07-01 19:47:50 +0000800 register Quantum
cristy90dbac72010-08-22 15:08:40 +0000801 *restrict q;
802
803 register ssize_t
804 x;
805
806 if (count != (ssize_t) length)
807 {
808 ThrowFileException(exception,CorruptImageError,
809 "UnexpectedEndOfFile",image->filename);
810 break;
811 }
812 q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1,
813 exception);
cristyacd2ed22011-08-30 01:44:23 +0000814 if (q == (Quantum *) NULL)
cristy90dbac72010-08-22 15:08:40 +0000815 break;
816 length=ImportQuantumPixels(canvas_image,(CacheView *) NULL,
817 quantum_info,BlueQuantum,pixels,exception);
818 if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
819 break;
820 if (((y-image->extract_info.y) >= 0) &&
821 ((y-image->extract_info.y) < (ssize_t) image->rows))
822 {
823 p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
824 canvas_image->columns,1,exception);
825 q=GetAuthenticPixels(image,0,y-image->extract_info.y,
826 image->columns,1,exception);
cristy4c08aed2011-07-01 19:47:50 +0000827 if ((p == (const Quantum *) NULL) ||
cristyacd2ed22011-08-30 01:44:23 +0000828 (q == (Quantum *) NULL))
cristy90dbac72010-08-22 15:08:40 +0000829 break;
830 for (x=0; x < (ssize_t) image->columns; x++)
831 {
cristy4c08aed2011-07-01 19:47:50 +0000832 SetPixelBlue(image,
833 GetPixelBlue(canvas_image,p),q);
cristyed231572011-07-14 02:18:59 +0000834 p+=GetPixelChannels(canvas_image);
835 q+=GetPixelChannels(image);
cristy90dbac72010-08-22 15:08:40 +0000836 }
837 if (SyncAuthenticPixels(image,exception) == MagickFalse)
838 break;
839 }
840 count=ReadBlob(image,length,pixels);
841 }
842 if (image->previous == (Image *) NULL)
843 {
844 status=SetImageProgress(image,LoadImageTag,3,5);
845 if (status == MagickFalse)
846 break;
847 }
848 if (image->matte != MagickFalse)
849 {
850 (void) CloseBlob(image);
851 AppendImageFormat("A",image->filename);
852 status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
853 if (status == MagickFalse)
854 {
855 canvas_image=DestroyImageList(canvas_image);
856 image=DestroyImageList(image);
857 return((Image *) NULL);
858 }
859 length=GetQuantumExtent(canvas_image,quantum_info,AlphaQuantum);
860 for (i=0; i < (ssize_t) scene; i++)
861 for (y=0; y < (ssize_t) image->extract_info.height; y++)
862 if (ReadBlob(image,length,pixels) != (ssize_t) length)
863 {
864 ThrowFileException(exception,CorruptImageError,
865 "UnexpectedEndOfFile",image->filename);
866 break;
867 }
868 count=ReadBlob(image,length,pixels);
869 for (y=0; y < (ssize_t) image->extract_info.height; y++)
870 {
cristy4c08aed2011-07-01 19:47:50 +0000871 register const Quantum
cristy90dbac72010-08-22 15:08:40 +0000872 *restrict p;
873
cristy4c08aed2011-07-01 19:47:50 +0000874 register Quantum
cristy90dbac72010-08-22 15:08:40 +0000875 *restrict q;
876
877 register ssize_t
878 x;
879
880 if (count != (ssize_t) length)
881 {
882 ThrowFileException(exception,CorruptImageError,
883 "UnexpectedEndOfFile",image->filename);
884 break;
885 }
886 q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1,
887 exception);
cristyacd2ed22011-08-30 01:44:23 +0000888 if (q == (Quantum *) NULL)
cristy90dbac72010-08-22 15:08:40 +0000889 break;
890 length=ImportQuantumPixels(canvas_image,(CacheView *) NULL,
891 quantum_info,BlueQuantum,pixels,exception);
892 if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
893 break;
894 if (((y-image->extract_info.y) >= 0) &&
895 ((y-image->extract_info.y) < (ssize_t) image->rows))
896 {
897 p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,
898 0,canvas_image->columns,1,exception);
899 q=GetAuthenticPixels(image,0,y-image->extract_info.y,
900 image->columns,1,exception);
cristy4c08aed2011-07-01 19:47:50 +0000901 if ((p == (const Quantum *) NULL) ||
cristyacd2ed22011-08-30 01:44:23 +0000902 (q == (Quantum *) NULL))
cristy90dbac72010-08-22 15:08:40 +0000903 break;
904 for (x=0; x < (ssize_t) image->columns; x++)
905 {
cristy4c08aed2011-07-01 19:47:50 +0000906 SetPixelAlpha(image,
907 GetPixelAlpha(canvas_image,p),q);
cristyed231572011-07-14 02:18:59 +0000908 p+=GetPixelChannels(canvas_image);
909 q+=GetPixelChannels(image);
cristy90dbac72010-08-22 15:08:40 +0000910 }
911 if (SyncAuthenticPixels(image,exception) == MagickFalse)
912 break;
913 }
914 count=ReadBlob(image,length,pixels);
915 }
916 if (image->previous == (Image *) NULL)
917 {
918 status=SetImageProgress(image,LoadImageTag,4,5);
919 if (status == MagickFalse)
920 break;
921 }
922 }
923 (void) CloseBlob(image);
924 if (image->previous == (Image *) NULL)
925 {
cristy3ed852e2009-09-05 21:47:34 +0000926 status=SetImageProgress(image,LoadImageTag,5,5);
927 if (status == MagickFalse)
928 break;
929 }
930 break;
931 }
932 }
933 SetQuantumImageType(image,quantum_type);
cristy3ed852e2009-09-05 21:47:34 +0000934 /*
935 Proceed to next image.
936 */
937 if (image_info->number_scenes != 0)
938 if (image->scene >= (image_info->scene+image_info->number_scenes-1))
939 break;
940 if (count == (ssize_t) length)
941 {
942 /*
943 Allocate next image structure.
944 */
945 AcquireNextImage(image_info,image);
946 if (GetNextImageInList(image) == (Image *) NULL)
947 {
948 image=DestroyImageList(image);
949 return((Image *) NULL);
950 }
951 image=SyncNextImageInList(image);
952 status=SetImageProgress(image,LoadImagesTag,TellBlob(image),
953 GetBlobSize(image));
954 if (status == MagickFalse)
955 break;
956 }
957 scene++;
958 } while (count == (ssize_t) length);
cristy3ed852e2009-09-05 21:47:34 +0000959 quantum_info=DestroyQuantumInfo(quantum_info);
cristy01a3f332009-10-27 14:17:37 +0000960 InheritException(&image->exception,&canvas_image->exception);
cristy3ed852e2009-09-05 21:47:34 +0000961 canvas_image=DestroyImage(canvas_image);
962 (void) CloseBlob(image);
963 return(GetFirstImageInList(image));
964}
965
966/*
967%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
968% %
969% %
970% %
971% R e g i s t e r R G B I m a g e %
972% %
973% %
974% %
975%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
976%
cristy90dbac72010-08-22 15:08:40 +0000977% RegisterRGBImage() adds attributes for the RGB image format to
cristy3ed852e2009-09-05 21:47:34 +0000978% the list of supported formats. The attributes include the image format
979% tag, a method to read and/or write the format, whether the format
980% supports the saving of more than one frame to the same file or blob,
981% whether the format supports native in-memory I/O, and a brief
982% description of the format.
983%
984% The format of the RegisterRGBImage method is:
985%
cristybb503372010-05-27 20:51:26 +0000986% size_t RegisterRGBImage(void)
cristy3ed852e2009-09-05 21:47:34 +0000987%
988*/
cristybb503372010-05-27 20:51:26 +0000989ModuleExport size_t RegisterRGBImage(void)
cristy3ed852e2009-09-05 21:47:34 +0000990{
991 MagickInfo
992 *entry;
993
994 entry=SetMagickInfo("RGB");
995 entry->decoder=(DecodeImageHandler *) ReadRGBImage;
996 entry->encoder=(EncodeImageHandler *) WriteRGBImage;
997 entry->raw=MagickTrue;
998 entry->endian_support=MagickTrue;
cristy3ed852e2009-09-05 21:47:34 +0000999 entry->description=ConstantString("Raw red, green, and blue samples");
1000 entry->module=ConstantString("RGB");
1001 (void) RegisterMagickInfo(entry);
cristy3ed852e2009-09-05 21:47:34 +00001002 entry=SetMagickInfo("RGBA");
1003 entry->decoder=(DecodeImageHandler *) ReadRGBImage;
1004 entry->encoder=(EncodeImageHandler *) WriteRGBImage;
1005 entry->raw=MagickTrue;
1006 entry->endian_support=MagickTrue;
cristy3ed852e2009-09-05 21:47:34 +00001007 entry->description=ConstantString("Raw red, green, blue, and alpha samples");
1008 entry->module=ConstantString("RGB");
1009 (void) RegisterMagickInfo(entry);
1010 entry=SetMagickInfo("RGBO");
1011 entry->decoder=(DecodeImageHandler *) ReadRGBImage;
1012 entry->encoder=(EncodeImageHandler *) WriteRGBImage;
1013 entry->raw=MagickTrue;
1014 entry->endian_support=MagickTrue;
cristy90dbac72010-08-22 15:08:40 +00001015 entry->description=ConstantString("Raw red, green, blue, and opacity samples");
cristy3ed852e2009-09-05 21:47:34 +00001016 entry->module=ConstantString("RGB");
1017 (void) RegisterMagickInfo(entry);
1018 return(MagickImageCoderSignature);
1019}
1020
1021/*
1022%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1023% %
1024% %
1025% %
1026% U n r e g i s t e r R G B I m a g e %
1027% %
1028% %
1029% %
1030%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1031%
cristy90dbac72010-08-22 15:08:40 +00001032% UnregisterRGBImage() removes format registrations made by the RGB module
1033% from the list of supported formats.
cristy3ed852e2009-09-05 21:47:34 +00001034%
1035% The format of the UnregisterRGBImage method is:
1036%
1037% UnregisterRGBImage(void)
1038%
1039*/
1040ModuleExport void UnregisterRGBImage(void)
1041{
1042 (void) UnregisterMagickInfo("RGBO");
1043 (void) UnregisterMagickInfo("RGBA");
cristy3ed852e2009-09-05 21:47:34 +00001044 (void) UnregisterMagickInfo("RGB");
1045}
1046
1047/*
1048%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1049% %
1050% %
1051% %
1052% W r i t e R G B I m a g e %
1053% %
1054% %
1055% %
1056%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1057%
cristy90dbac72010-08-22 15:08:40 +00001058% WriteRGBImage() writes an image to a file in the RGB, RGBA, or RGBO
1059% rasterfile format.
cristy3ed852e2009-09-05 21:47:34 +00001060%
1061% The format of the WriteRGBImage method is:
1062%
cristy90dbac72010-08-22 15:08:40 +00001063% MagickBooleanType WriteRGBImage(const ImageInfo *image_info,
cristy3a37efd2011-08-28 20:31:03 +00001064% Image *image,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +00001065%
1066% A description of each parameter follows.
1067%
1068% o image_info: the image info.
1069%
1070% o image: The image.
1071%
cristy3a37efd2011-08-28 20:31:03 +00001072% o exception: return any errors or warnings in this structure.
1073%
cristy3ed852e2009-09-05 21:47:34 +00001074*/
cristy90dbac72010-08-22 15:08:40 +00001075static MagickBooleanType WriteRGBImage(const ImageInfo *image_info,
cristy3a37efd2011-08-28 20:31:03 +00001076 Image *image,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +00001077{
cristy3ed852e2009-09-05 21:47:34 +00001078 MagickBooleanType
1079 status;
1080
1081 MagickOffsetType
1082 scene;
1083
1084 QuantumInfo
1085 *quantum_info;
1086
1087 QuantumType
cristy90dbac72010-08-22 15:08:40 +00001088 quantum_type;
cristy3ed852e2009-09-05 21:47:34 +00001089
cristyc6da28e2011-04-28 01:41:35 +00001090 size_t
1091 length;
1092
cristy3ed852e2009-09-05 21:47:34 +00001093 ssize_t
cristy90dbac72010-08-22 15:08:40 +00001094 count,
1095 y;
cristy3ed852e2009-09-05 21:47:34 +00001096
cristy3ed852e2009-09-05 21:47:34 +00001097 unsigned char
1098 *pixels;
1099
cristy3ed852e2009-09-05 21:47:34 +00001100 /*
1101 Allocate memory for pixels.
1102 */
1103 assert(image_info != (const ImageInfo *) NULL);
1104 assert(image_info->signature == MagickSignature);
1105 assert(image != (Image *) NULL);
1106 assert(image->signature == MagickSignature);
1107 if (image->debug != MagickFalse)
1108 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
1109 if (image_info->interlace != PartitionInterlace)
1110 {
1111 /*
1112 Open output image file.
1113 */
cristyedf03fa2011-08-30 12:44:39 +00001114 status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception);
cristy3ed852e2009-09-05 21:47:34 +00001115 if (status == MagickFalse)
1116 return(status);
1117 }
1118 quantum_type=RGBQuantum;
cristy90dbac72010-08-22 15:08:40 +00001119 if (LocaleCompare(image_info->magick,"RGBA") == 0)
cristy3ed852e2009-09-05 21:47:34 +00001120 {
cristy90dbac72010-08-22 15:08:40 +00001121 quantum_type=RGBAQuantum;
1122 image->matte=MagickTrue;
cristy3ed852e2009-09-05 21:47:34 +00001123 }
cristy90dbac72010-08-22 15:08:40 +00001124 if (LocaleCompare(image_info->magick,"RGBO") == 0)
1125 {
1126 quantum_type=RGBOQuantum;
1127 image->matte=MagickTrue;
1128 }
cristy3ed852e2009-09-05 21:47:34 +00001129 scene=0;
1130 do
1131 {
1132 /*
1133 Convert MIFF to RGB raster pixels.
1134 */
cristy510d06a2011-07-06 23:43:54 +00001135 if (IsRGBColorspace(image->colorspace) == MagickFalse)
cristy3ed852e2009-09-05 21:47:34 +00001136 (void) TransformImageColorspace(image,RGBColorspace);
1137 if ((LocaleCompare(image_info->magick,"RGBA") == 0) &&
1138 (image->matte == MagickFalse))
cristy3a37efd2011-08-28 20:31:03 +00001139 (void) SetImageAlphaChannel(image,OpaqueAlphaChannel,exception);
cristy3ed852e2009-09-05 21:47:34 +00001140 quantum_info=AcquireQuantumInfo(image_info,image);
1141 if (quantum_info == (QuantumInfo *) NULL)
1142 ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
1143 pixels=GetQuantumPixels(quantum_info);
1144 switch (image_info->interlace)
1145 {
1146 case NoInterlace:
1147 default:
1148 {
cristy3ed852e2009-09-05 21:47:34 +00001149 /*
1150 No interlacing: RGBRGBRGBRGBRGBRGB...
1151 */
cristybb503372010-05-27 20:51:26 +00001152 for (y=0; y < (ssize_t) image->rows; y++)
cristy3ed852e2009-09-05 21:47:34 +00001153 {
cristy4c08aed2011-07-01 19:47:50 +00001154 register const Quantum
cristy90dbac72010-08-22 15:08:40 +00001155 *restrict p;
cristy3ed852e2009-09-05 21:47:34 +00001156
cristy3a37efd2011-08-28 20:31:03 +00001157 p=GetVirtualPixels(image,0,y,image->columns,1,exception);
cristy4c08aed2011-07-01 19:47:50 +00001158 if (p == (const Quantum *) NULL)
cristy3ed852e2009-09-05 21:47:34 +00001159 break;
cristy4c08aed2011-07-01 19:47:50 +00001160 length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
cristy3a37efd2011-08-28 20:31:03 +00001161 quantum_type,pixels,exception);
cristy3ed852e2009-09-05 21:47:34 +00001162 count=WriteBlob(image,length,pixels);
1163 if (count != (ssize_t) length)
1164 break;
1165 if (image->previous == (Image *) NULL)
1166 {
cristycee97112010-05-28 00:44:52 +00001167 status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
1168 image->rows);
cristy3ed852e2009-09-05 21:47:34 +00001169 if (status == MagickFalse)
1170 break;
1171 }
1172 }
cristy3ed852e2009-09-05 21:47:34 +00001173 break;
1174 }
1175 case LineInterlace:
1176 {
1177 /*
1178 Line interlacing: RRR...GGG...BBB...RRR...GGG...BBB...
1179 */
cristybb503372010-05-27 20:51:26 +00001180 for (y=0; y < (ssize_t) image->rows; y++)
cristy3ed852e2009-09-05 21:47:34 +00001181 {
cristy4c08aed2011-07-01 19:47:50 +00001182 register const Quantum
cristyc47d1f82009-11-26 01:44:43 +00001183 *restrict p;
cristy3ed852e2009-09-05 21:47:34 +00001184
cristy3a37efd2011-08-28 20:31:03 +00001185 p=GetVirtualPixels(image,0,y,image->columns,1,exception);
cristy4c08aed2011-07-01 19:47:50 +00001186 if (p == (const Quantum *) NULL)
cristy3ed852e2009-09-05 21:47:34 +00001187 break;
cristy4c08aed2011-07-01 19:47:50 +00001188 length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
cristy3a37efd2011-08-28 20:31:03 +00001189 RedQuantum,pixels,exception);
cristy90dbac72010-08-22 15:08:40 +00001190 count=WriteBlob(image,length,pixels);
1191 if (count != (ssize_t) length)
1192 break;
cristy4c08aed2011-07-01 19:47:50 +00001193 length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
cristy3a37efd2011-08-28 20:31:03 +00001194 GreenQuantum,pixels,exception);
cristy90dbac72010-08-22 15:08:40 +00001195 count=WriteBlob(image,length,pixels);
1196 if (count != (ssize_t) length)
1197 break;
cristy4c08aed2011-07-01 19:47:50 +00001198 length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
cristy3a37efd2011-08-28 20:31:03 +00001199 BlueQuantum,pixels,exception);
cristy90dbac72010-08-22 15:08:40 +00001200 count=WriteBlob(image,length,pixels);
1201 if (count != (ssize_t) length)
1202 break;
1203 if (quantum_type == RGBAQuantum)
1204 {
cristy4c08aed2011-07-01 19:47:50 +00001205 length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
cristy3a37efd2011-08-28 20:31:03 +00001206 AlphaQuantum,pixels,exception);
cristy90dbac72010-08-22 15:08:40 +00001207 count=WriteBlob(image,length,pixels);
1208 if (count != (ssize_t) length)
1209 break;
1210 }
1211 if (quantum_type == RGBOQuantum)
1212 {
cristy4c08aed2011-07-01 19:47:50 +00001213 length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
cristy3a37efd2011-08-28 20:31:03 +00001214 OpacityQuantum,pixels,exception);
cristy90dbac72010-08-22 15:08:40 +00001215 count=WriteBlob(image,length,pixels);
1216 if (count != (ssize_t) length)
1217 break;
1218 }
cristy3ed852e2009-09-05 21:47:34 +00001219 if (image->previous == (Image *) NULL)
1220 {
cristycee97112010-05-28 00:44:52 +00001221 status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
1222 image->rows);
cristy3ed852e2009-09-05 21:47:34 +00001223 if (status == MagickFalse)
1224 break;
1225 }
1226 }
1227 break;
1228 }
1229 case PlaneInterlace:
1230 {
1231 /*
1232 Plane interlacing: RRRRRR...GGGGGG...BBBBBB...
1233 */
cristy90dbac72010-08-22 15:08:40 +00001234 for (y=0; y < (ssize_t) image->rows; y++)
cristy3ed852e2009-09-05 21:47:34 +00001235 {
cristy4c08aed2011-07-01 19:47:50 +00001236 register const Quantum
cristy90dbac72010-08-22 15:08:40 +00001237 *restrict p;
cristy3ed852e2009-09-05 21:47:34 +00001238
cristy3a37efd2011-08-28 20:31:03 +00001239 p=GetVirtualPixels(image,0,y,image->columns,1,exception);
cristy4c08aed2011-07-01 19:47:50 +00001240 if (p == (const Quantum *) NULL)
cristy90dbac72010-08-22 15:08:40 +00001241 break;
cristy4c08aed2011-07-01 19:47:50 +00001242 length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
cristy3a37efd2011-08-28 20:31:03 +00001243 RedQuantum,pixels,exception);
cristy90dbac72010-08-22 15:08:40 +00001244 count=WriteBlob(image,length,pixels);
1245 if (count != (ssize_t) length)
1246 break;
cristy3ed852e2009-09-05 21:47:34 +00001247 }
1248 if (image->previous == (Image *) NULL)
1249 {
cristy90dbac72010-08-22 15:08:40 +00001250 status=SetImageProgress(image,SaveImageTag,1,6);
1251 if (status == MagickFalse)
1252 break;
1253 }
1254 for (y=0; y < (ssize_t) image->rows; y++)
1255 {
cristy4c08aed2011-07-01 19:47:50 +00001256 register const Quantum
cristy90dbac72010-08-22 15:08:40 +00001257 *restrict p;
1258
cristy3a37efd2011-08-28 20:31:03 +00001259 p=GetVirtualPixels(image,0,y,image->columns,1,exception);
cristy4c08aed2011-07-01 19:47:50 +00001260 if (p == (const Quantum *) NULL)
cristy90dbac72010-08-22 15:08:40 +00001261 break;
cristy4c08aed2011-07-01 19:47:50 +00001262 length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
cristy3a37efd2011-08-28 20:31:03 +00001263 GreenQuantum,pixels,exception);
cristy90dbac72010-08-22 15:08:40 +00001264 count=WriteBlob(image,length,pixels);
1265 if (count != (ssize_t) length)
1266 break;
1267 }
1268 if (image->previous == (Image *) NULL)
1269 {
1270 status=SetImageProgress(image,SaveImageTag,2,6);
1271 if (status == MagickFalse)
1272 break;
1273 }
1274 for (y=0; y < (ssize_t) image->rows; y++)
1275 {
cristy4c08aed2011-07-01 19:47:50 +00001276 register const Quantum
cristy90dbac72010-08-22 15:08:40 +00001277 *restrict p;
1278
cristy3a37efd2011-08-28 20:31:03 +00001279 p=GetVirtualPixels(image,0,y,image->columns,1,exception);
cristy4c08aed2011-07-01 19:47:50 +00001280 if (p == (const Quantum *) NULL)
cristy90dbac72010-08-22 15:08:40 +00001281 break;
cristy4c08aed2011-07-01 19:47:50 +00001282 length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
cristy3a37efd2011-08-28 20:31:03 +00001283 BlueQuantum,pixels,exception);
cristy90dbac72010-08-22 15:08:40 +00001284 count=WriteBlob(image,length,pixels);
1285 if (count != (ssize_t) length)
1286 break;
1287 }
1288 if (image->previous == (Image *) NULL)
1289 {
1290 status=SetImageProgress(image,SaveImageTag,3,6);
1291 if (status == MagickFalse)
1292 break;
1293 }
1294 if (quantum_type == RGBAQuantum)
1295 {
1296 for (y=0; y < (ssize_t) image->rows; y++)
1297 {
cristy4c08aed2011-07-01 19:47:50 +00001298 register const Quantum
cristy90dbac72010-08-22 15:08:40 +00001299 *restrict p;
1300
cristy3a37efd2011-08-28 20:31:03 +00001301 p=GetVirtualPixels(image,0,y,image->columns,1,exception);
cristy4c08aed2011-07-01 19:47:50 +00001302 if (p == (const Quantum *) NULL)
cristy90dbac72010-08-22 15:08:40 +00001303 break;
cristy4c08aed2011-07-01 19:47:50 +00001304 length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
cristy3a37efd2011-08-28 20:31:03 +00001305 AlphaQuantum,pixels,exception);
cristy90dbac72010-08-22 15:08:40 +00001306 count=WriteBlob(image,length,pixels);
1307 if (count != (ssize_t) length)
1308 break;
1309 }
1310 if (image->previous == (Image *) NULL)
1311 {
1312 status=SetImageProgress(image,SaveImageTag,5,6);
1313 if (status == MagickFalse)
1314 break;
1315 }
1316 }
1317 if (image_info->interlace == PartitionInterlace)
1318 (void) CopyMagickString(image->filename,image_info->filename,
1319 MaxTextExtent);
1320 if (image->previous == (Image *) NULL)
1321 {
1322 status=SetImageProgress(image,SaveImageTag,6,6);
cristy3ed852e2009-09-05 21:47:34 +00001323 if (status == MagickFalse)
1324 break;
1325 }
1326 break;
1327 }
1328 case PartitionInterlace:
1329 {
cristy3ed852e2009-09-05 21:47:34 +00001330 /*
1331 Partition interlacing: RRRRRR..., GGGGGG..., BBBBBB...
1332 */
cristy90dbac72010-08-22 15:08:40 +00001333 AppendImageFormat("R",image->filename);
1334 status=OpenBlob(image_info,image,scene == 0 ? WriteBinaryBlobMode :
cristy3a37efd2011-08-28 20:31:03 +00001335 AppendBinaryBlobMode,exception);
cristy90dbac72010-08-22 15:08:40 +00001336 if (status == MagickFalse)
1337 return(status);
1338 for (y=0; y < (ssize_t) image->rows; y++)
cristy3ed852e2009-09-05 21:47:34 +00001339 {
cristy4c08aed2011-07-01 19:47:50 +00001340 register const Quantum
cristy90dbac72010-08-22 15:08:40 +00001341 *restrict p;
cristy3ed852e2009-09-05 21:47:34 +00001342
cristy3a37efd2011-08-28 20:31:03 +00001343 p=GetVirtualPixels(image,0,y,image->columns,1,exception);
cristy4c08aed2011-07-01 19:47:50 +00001344 if (p == (const Quantum *) NULL)
cristy90dbac72010-08-22 15:08:40 +00001345 break;
cristy4c08aed2011-07-01 19:47:50 +00001346 length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
cristy3a37efd2011-08-28 20:31:03 +00001347 RedQuantum,pixels,exception);
cristy90dbac72010-08-22 15:08:40 +00001348 count=WriteBlob(image,length,pixels);
1349 if (count != (ssize_t) length)
1350 break;
1351 }
1352 if (image->previous == (Image *) NULL)
1353 {
1354 status=SetImageProgress(image,SaveImageTag,1,6);
1355 if (status == MagickFalse)
cristy3ed852e2009-09-05 21:47:34 +00001356 break;
1357 }
cristy90dbac72010-08-22 15:08:40 +00001358 (void) CloseBlob(image);
1359 AppendImageFormat("G",image->filename);
1360 status=OpenBlob(image_info,image,scene == 0 ? WriteBinaryBlobMode :
cristy3a37efd2011-08-28 20:31:03 +00001361 AppendBinaryBlobMode,exception);
cristy90dbac72010-08-22 15:08:40 +00001362 if (status == MagickFalse)
1363 return(status);
1364 for (y=0; y < (ssize_t) image->rows; y++)
1365 {
cristy4c08aed2011-07-01 19:47:50 +00001366 register const Quantum
cristy90dbac72010-08-22 15:08:40 +00001367 *restrict p;
1368
cristy3a37efd2011-08-28 20:31:03 +00001369 p=GetVirtualPixels(image,0,y,image->columns,1,exception);
cristy4c08aed2011-07-01 19:47:50 +00001370 if (p == (const Quantum *) NULL)
cristy90dbac72010-08-22 15:08:40 +00001371 break;
cristy4c08aed2011-07-01 19:47:50 +00001372 length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
cristy3a37efd2011-08-28 20:31:03 +00001373 GreenQuantum,pixels,exception);
cristy90dbac72010-08-22 15:08:40 +00001374 count=WriteBlob(image,length,pixels);
1375 if (count != (ssize_t) length)
1376 break;
1377 }
1378 if (image->previous == (Image *) NULL)
1379 {
1380 status=SetImageProgress(image,SaveImageTag,2,6);
1381 if (status == MagickFalse)
1382 break;
1383 }
1384 (void) CloseBlob(image);
1385 AppendImageFormat("B",image->filename);
1386 status=OpenBlob(image_info,image,scene == 0 ? WriteBinaryBlobMode :
cristy3a37efd2011-08-28 20:31:03 +00001387 AppendBinaryBlobMode,exception);
cristy90dbac72010-08-22 15:08:40 +00001388 if (status == MagickFalse)
1389 return(status);
1390 for (y=0; y < (ssize_t) image->rows; y++)
1391 {
cristy4c08aed2011-07-01 19:47:50 +00001392 register const Quantum
cristy90dbac72010-08-22 15:08:40 +00001393 *restrict p;
1394
cristy3a37efd2011-08-28 20:31:03 +00001395 p=GetVirtualPixels(image,0,y,image->columns,1,exception);
cristy4c08aed2011-07-01 19:47:50 +00001396 if (p == (const Quantum *) NULL)
cristy90dbac72010-08-22 15:08:40 +00001397 break;
cristy4c08aed2011-07-01 19:47:50 +00001398 length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
cristy3a37efd2011-08-28 20:31:03 +00001399 BlueQuantum,pixels,exception);
cristy90dbac72010-08-22 15:08:40 +00001400 count=WriteBlob(image,length,pixels);
1401 if (count != (ssize_t) length)
1402 break;
1403 }
1404 if (image->previous == (Image *) NULL)
1405 {
1406 status=SetImageProgress(image,SaveImageTag,3,6);
1407 if (status == MagickFalse)
1408 break;
1409 }
1410 (void) CloseBlob(image);
1411 if (quantum_type == RGBAQuantum)
1412 {
1413 (void) CloseBlob(image);
1414 AppendImageFormat("A",image->filename);
1415 status=OpenBlob(image_info,image,scene == 0 ? WriteBinaryBlobMode :
cristy3a37efd2011-08-28 20:31:03 +00001416 AppendBinaryBlobMode,exception);
cristy90dbac72010-08-22 15:08:40 +00001417 if (status == MagickFalse)
1418 return(status);
1419 for (y=0; y < (ssize_t) image->rows; y++)
cristy3ed852e2009-09-05 21:47:34 +00001420 {
cristy4c08aed2011-07-01 19:47:50 +00001421 register const Quantum
cristy90dbac72010-08-22 15:08:40 +00001422 *restrict p;
1423
cristy3a37efd2011-08-28 20:31:03 +00001424 p=GetVirtualPixels(image,0,y,image->columns,1,exception);
cristy4c08aed2011-07-01 19:47:50 +00001425 if (p == (const Quantum *) NULL)
cristy90dbac72010-08-22 15:08:40 +00001426 break;
cristy4c08aed2011-07-01 19:47:50 +00001427 length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
cristy3a37efd2011-08-28 20:31:03 +00001428 AlphaQuantum,pixels,exception);
cristy90dbac72010-08-22 15:08:40 +00001429 count=WriteBlob(image,length,pixels);
1430 if (count != (ssize_t) length)
cristy3ed852e2009-09-05 21:47:34 +00001431 break;
1432 }
cristy90dbac72010-08-22 15:08:40 +00001433 if (image->previous == (Image *) NULL)
1434 {
1435 status=SetImageProgress(image,SaveImageTag,5,6);
1436 if (status == MagickFalse)
1437 break;
1438 }
1439 }
1440 (void) CloseBlob(image);
cristy3ed852e2009-09-05 21:47:34 +00001441 (void) CopyMagickString(image->filename,image_info->filename,
1442 MaxTextExtent);
1443 if (image->previous == (Image *) NULL)
1444 {
cristy90dbac72010-08-22 15:08:40 +00001445 status=SetImageProgress(image,SaveImageTag,6,6);
cristy3ed852e2009-09-05 21:47:34 +00001446 if (status == MagickFalse)
1447 break;
1448 }
1449 break;
1450 }
1451 }
1452 quantum_info=DestroyQuantumInfo(quantum_info);
1453 if (GetNextImageInList(image) == (Image *) NULL)
1454 break;
1455 image=SyncNextImageInList(image);
1456 status=SetImageProgress(image,SaveImagesTag,scene++,
1457 GetImageListLength(image));
1458 if (status == MagickFalse)
1459 break;
1460 } while (image_info->adjoin != MagickFalse);
1461 (void) CloseBlob(image);
1462 return(MagickTrue);
1463}