blob: aef2619ae95dca6a22dd0f380a252c6a4555888d [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);
cristy9950d572011-10-01 18:22:35 +0000141 image=AcquireImage(image_info,exception);
cristy3ed852e2009-09-05 21:47:34 +0000142 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 {
cristyf27ee032011-09-29 17:51:41 +0000486 SetPixelGreen(image,GetPixelGreen(canvas_image,p),q);
cristyed231572011-07-14 02:18:59 +0000487 p+=GetPixelChannels(canvas_image);
488 q+=GetPixelChannels(image);
cristy90dbac72010-08-22 15:08:40 +0000489 }
490 if (SyncAuthenticPixels(image,exception) == MagickFalse)
491 break;
492 }
493 count=ReadBlob(image,length,pixels);
494 }
495 if (image->previous == (Image *) NULL)
496 {
497 status=SetImageProgress(image,LoadImageTag,2,6);
498 if (status == MagickFalse)
499 break;
500 }
501 for (y=0; y < (ssize_t) image->extract_info.height; y++)
502 {
cristy4c08aed2011-07-01 19:47:50 +0000503 register const Quantum
cristy90dbac72010-08-22 15:08:40 +0000504 *restrict p;
505
cristy4c08aed2011-07-01 19:47:50 +0000506 register Quantum
cristy90dbac72010-08-22 15:08:40 +0000507 *restrict q;
508
509 register ssize_t
510 x;
511
512 if (count != (ssize_t) length)
513 {
514 ThrowFileException(exception,CorruptImageError,
515 "UnexpectedEndOfFile",image->filename);
516 break;
517 }
518 q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1,
519 exception);
cristyacd2ed22011-08-30 01:44:23 +0000520 if (q == (Quantum *) NULL)
cristy90dbac72010-08-22 15:08:40 +0000521 break;
522 length=ImportQuantumPixels(canvas_image,(CacheView *) NULL,
523 quantum_info,BlueQuantum,pixels,exception);
524 if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
525 break;
526 if (((y-image->extract_info.y) >= 0) &&
527 ((y-image->extract_info.y) < (ssize_t) image->rows))
528 {
529 p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
530 canvas_image->columns,1,exception);
531 q=GetAuthenticPixels(image,0,y-image->extract_info.y,
532 image->columns,1,exception);
cristy4c08aed2011-07-01 19:47:50 +0000533 if ((p == (const Quantum *) NULL) ||
cristyacd2ed22011-08-30 01:44:23 +0000534 (q == (Quantum *) NULL))
cristy90dbac72010-08-22 15:08:40 +0000535 break;
536 for (x=0; x < (ssize_t) image->columns; x++)
537 {
cristyf27ee032011-09-29 17:51:41 +0000538 SetPixelBlue(image,GetPixelBlue(canvas_image,p),q);
cristyed231572011-07-14 02:18:59 +0000539 p+=GetPixelChannels(canvas_image);
540 q+=GetPixelChannels(image);
cristy90dbac72010-08-22 15:08:40 +0000541 }
542 if (SyncAuthenticPixels(image,exception) == MagickFalse)
543 break;
544 }
545 count=ReadBlob(image,length,pixels);
546 }
547 if (image->previous == (Image *) NULL)
548 {
549 status=SetImageProgress(image,LoadImageTag,3,6);
550 if (status == MagickFalse)
551 break;
552 }
553 if (image->previous == (Image *) NULL)
554 {
555 status=SetImageProgress(image,LoadImageTag,4,6);
556 if (status == MagickFalse)
557 break;
558 }
559 if (image->matte != MagickFalse)
560 {
561 for (y=0; y < (ssize_t) image->extract_info.height; y++)
562 {
cristy4c08aed2011-07-01 19:47:50 +0000563 register const Quantum
cristy90dbac72010-08-22 15:08:40 +0000564 *restrict p;
565
cristy4c08aed2011-07-01 19:47:50 +0000566 register Quantum
cristy90dbac72010-08-22 15:08:40 +0000567 *restrict q;
568
569 register ssize_t
570 x;
571
572 if (count != (ssize_t) length)
573 {
574 ThrowFileException(exception,CorruptImageError,
575 "UnexpectedEndOfFile",image->filename);
576 break;
577 }
578 q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1,
579 exception);
cristyacd2ed22011-08-30 01:44:23 +0000580 if (q == (Quantum *) NULL)
cristy90dbac72010-08-22 15:08:40 +0000581 break;
582 length=ImportQuantumPixels(canvas_image,(CacheView *) NULL,
583 quantum_info,AlphaQuantum,pixels,exception);
584 if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
585 break;
586 if (((y-image->extract_info.y) >= 0) &&
587 ((y-image->extract_info.y) < (ssize_t) image->rows))
588 {
589 p=GetVirtualPixels(canvas_image,
590 canvas_image->extract_info.x,0,canvas_image->columns,1,
591 exception);
592 q=GetAuthenticPixels(image,0,y-image->extract_info.y,
593 image->columns,1,exception);
cristy4c08aed2011-07-01 19:47:50 +0000594 if ((p == (const Quantum *) NULL) ||
cristyacd2ed22011-08-30 01:44:23 +0000595 (q == (Quantum *) NULL))
cristy90dbac72010-08-22 15:08:40 +0000596 break;
597 for (x=0; x < (ssize_t) image->columns; x++)
598 {
cristyf27ee032011-09-29 17:51:41 +0000599 SetPixelAlpha(image,GetPixelAlpha(canvas_image,p),q);
cristyed231572011-07-14 02:18:59 +0000600 p+=GetPixelChannels(canvas_image);
601 q+=GetPixelChannels(image);
cristy90dbac72010-08-22 15:08:40 +0000602 }
603 if (SyncAuthenticPixels(image,exception) == MagickFalse)
604 break;
605 }
606 count=ReadBlob(image,length,pixels);
607 }
608 if (image->previous == (Image *) NULL)
609 {
610 status=SetImageProgress(image,LoadImageTag,5,6);
611 if (status == MagickFalse)
612 break;
613 }
614 }
615 if (image->previous == (Image *) NULL)
616 {
617 status=SetImageProgress(image,LoadImageTag,6,6);
cristy3ed852e2009-09-05 21:47:34 +0000618 if (status == MagickFalse)
619 break;
620 }
621 break;
622 }
623 case PartitionInterlace:
624 {
625 /*
626 Partition interlacing: RRRRRR..., GGGGGG..., BBBBBB...
627 */
cristy90dbac72010-08-22 15:08:40 +0000628 AppendImageFormat("R",image->filename);
629 status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
630 if (status == MagickFalse)
cristy3ed852e2009-09-05 21:47:34 +0000631 {
cristy90dbac72010-08-22 15:08:40 +0000632 canvas_image=DestroyImageList(canvas_image);
633 image=DestroyImageList(image);
634 return((Image *) NULL);
635 }
cristyd4297022010-09-16 22:59:09 +0000636 if (DiscardBlobBytes(image,image->offset) == MagickFalse)
637 ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
638 image->filename);
cristy90dbac72010-08-22 15:08:40 +0000639 length=GetQuantumExtent(canvas_image,quantum_info,RedQuantum);
640 for (i=0; i < (ssize_t) scene; i++)
641 for (y=0; y < (ssize_t) image->extract_info.height; y++)
642 if (ReadBlob(image,length,pixels) != (ssize_t) length)
cristy21da32d2009-09-12 14:56:09 +0000643 {
644 ThrowFileException(exception,CorruptImageError,
645 "UnexpectedEndOfFile",image->filename);
646 break;
647 }
cristy90dbac72010-08-22 15:08:40 +0000648 count=ReadBlob(image,length,pixels);
649 for (y=0; y < (ssize_t) image->extract_info.height; y++)
650 {
cristy4c08aed2011-07-01 19:47:50 +0000651 register const Quantum
cristy90dbac72010-08-22 15:08:40 +0000652 *restrict p;
653
cristy4c08aed2011-07-01 19:47:50 +0000654 register Quantum
cristy90dbac72010-08-22 15:08:40 +0000655 *restrict q;
656
657 register ssize_t
658 x;
659
660 if (count != (ssize_t) length)
cristy3ed852e2009-09-05 21:47:34 +0000661 {
cristy90dbac72010-08-22 15:08:40 +0000662 ThrowFileException(exception,CorruptImageError,
663 "UnexpectedEndOfFile",image->filename);
664 break;
665 }
666 q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1,
667 exception);
cristyacd2ed22011-08-30 01:44:23 +0000668 if (q == (Quantum *) NULL)
cristy90dbac72010-08-22 15:08:40 +0000669 break;
670 length=ImportQuantumPixels(canvas_image,(CacheView *) NULL,
671 quantum_info,RedQuantum,pixels,exception);
672 if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
673 break;
674 if (((y-image->extract_info.y) >= 0) &&
675 ((y-image->extract_info.y) < (ssize_t) image->rows))
676 {
677 p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
678 canvas_image->columns,1,exception);
679 q=GetAuthenticPixels(image,0,y-image->extract_info.y,
680 image->columns,1,exception);
cristy4c08aed2011-07-01 19:47:50 +0000681 if ((p == (const Quantum *) NULL) ||
cristyacd2ed22011-08-30 01:44:23 +0000682 (q == (Quantum *) NULL))
cristy90dbac72010-08-22 15:08:40 +0000683 break;
684 for (x=0; x < (ssize_t) image->columns; x++)
685 {
cristy4c08aed2011-07-01 19:47:50 +0000686 SetPixelRed(image,GetPixelRed(canvas_image,p),q);
cristyed231572011-07-14 02:18:59 +0000687 p+=GetPixelChannels(canvas_image);
688 q+=GetPixelChannels(image);
cristy90dbac72010-08-22 15:08:40 +0000689 }
690 if (SyncAuthenticPixels(image,exception) == MagickFalse)
cristy3ed852e2009-09-05 21:47:34 +0000691 break;
692 }
cristy90dbac72010-08-22 15:08:40 +0000693 count=ReadBlob(image,length,pixels);
cristy3ed852e2009-09-05 21:47:34 +0000694 }
695 if (image->previous == (Image *) NULL)
696 {
cristy90dbac72010-08-22 15:08:40 +0000697 status=SetImageProgress(image,LoadImageTag,1,5);
698 if (status == MagickFalse)
699 break;
700 }
701 (void) CloseBlob(image);
702 AppendImageFormat("G",image->filename);
703 status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
704 if (status == MagickFalse)
705 {
706 canvas_image=DestroyImageList(canvas_image);
707 image=DestroyImageList(image);
708 return((Image *) NULL);
709 }
710 length=GetQuantumExtent(canvas_image,quantum_info,GreenQuantum);
711 for (i=0; i < (ssize_t) scene; i++)
712 for (y=0; y < (ssize_t) image->extract_info.height; y++)
713 if (ReadBlob(image,length,pixels) != (ssize_t) length)
714 {
715 ThrowFileException(exception,CorruptImageError,
716 "UnexpectedEndOfFile",image->filename);
717 break;
718 }
719 count=ReadBlob(image,length,pixels);
720 for (y=0; y < (ssize_t) image->extract_info.height; y++)
721 {
cristy4c08aed2011-07-01 19:47:50 +0000722 register const Quantum
cristy90dbac72010-08-22 15:08:40 +0000723 *restrict p;
724
cristy4c08aed2011-07-01 19:47:50 +0000725 register Quantum
cristy90dbac72010-08-22 15:08:40 +0000726 *restrict q;
727
728 register ssize_t
729 x;
730
731 if (count != (ssize_t) length)
732 {
733 ThrowFileException(exception,CorruptImageError,
734 "UnexpectedEndOfFile",image->filename);
735 break;
736 }
737 q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1,
738 exception);
cristyacd2ed22011-08-30 01:44:23 +0000739 if (q == (Quantum *) NULL)
cristy90dbac72010-08-22 15:08:40 +0000740 break;
741 length=ImportQuantumPixels(canvas_image,(CacheView *) NULL,
742 quantum_info,GreenQuantum,pixels,exception);
743 if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
744 break;
745 if (((y-image->extract_info.y) >= 0) &&
746 ((y-image->extract_info.y) < (ssize_t) image->rows))
747 {
748 p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
749 canvas_image->columns,1,exception);
750 q=GetAuthenticPixels(image,0,y-image->extract_info.y,
751 image->columns,1,exception);
cristy4c08aed2011-07-01 19:47:50 +0000752 if ((p == (const Quantum *) NULL) ||
cristyacd2ed22011-08-30 01:44:23 +0000753 (q == (Quantum *) NULL))
cristy90dbac72010-08-22 15:08:40 +0000754 break;
755 for (x=0; x < (ssize_t) image->columns; x++)
756 {
cristyf27ee032011-09-29 17:51:41 +0000757 SetPixelGreen(image,GetPixelGreen(canvas_image,p),q);
cristyed231572011-07-14 02:18:59 +0000758 p+=GetPixelChannels(canvas_image);
759 q+=GetPixelChannels(image);
cristy90dbac72010-08-22 15:08:40 +0000760 }
761 if (SyncAuthenticPixels(image,exception) == MagickFalse)
762 break;
763 }
764 count=ReadBlob(image,length,pixels);
765 }
766 if (image->previous == (Image *) NULL)
767 {
768 status=SetImageProgress(image,LoadImageTag,2,5);
769 if (status == MagickFalse)
770 break;
771 }
772 (void) CloseBlob(image);
773 AppendImageFormat("B",image->filename);
774 status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
775 if (status == MagickFalse)
776 {
777 canvas_image=DestroyImageList(canvas_image);
778 image=DestroyImageList(image);
779 return((Image *) NULL);
780 }
781 length=GetQuantumExtent(canvas_image,quantum_info,BlueQuantum);
782 for (i=0; i < (ssize_t) scene; i++)
783 for (y=0; y < (ssize_t) image->extract_info.height; y++)
784 if (ReadBlob(image,length,pixels) != (ssize_t) length)
785 {
786 ThrowFileException(exception,CorruptImageError,
787 "UnexpectedEndOfFile",image->filename);
788 break;
789 }
790 count=ReadBlob(image,length,pixels);
791 for (y=0; y < (ssize_t) image->extract_info.height; y++)
792 {
cristy4c08aed2011-07-01 19:47:50 +0000793 register const Quantum
cristy90dbac72010-08-22 15:08:40 +0000794 *restrict p;
795
cristy4c08aed2011-07-01 19:47:50 +0000796 register Quantum
cristy90dbac72010-08-22 15:08:40 +0000797 *restrict q;
798
799 register ssize_t
800 x;
801
802 if (count != (ssize_t) length)
803 {
804 ThrowFileException(exception,CorruptImageError,
805 "UnexpectedEndOfFile",image->filename);
806 break;
807 }
808 q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1,
809 exception);
cristyacd2ed22011-08-30 01:44:23 +0000810 if (q == (Quantum *) NULL)
cristy90dbac72010-08-22 15:08:40 +0000811 break;
812 length=ImportQuantumPixels(canvas_image,(CacheView *) NULL,
813 quantum_info,BlueQuantum,pixels,exception);
814 if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
815 break;
816 if (((y-image->extract_info.y) >= 0) &&
817 ((y-image->extract_info.y) < (ssize_t) image->rows))
818 {
819 p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
820 canvas_image->columns,1,exception);
821 q=GetAuthenticPixels(image,0,y-image->extract_info.y,
822 image->columns,1,exception);
cristy4c08aed2011-07-01 19:47:50 +0000823 if ((p == (const Quantum *) NULL) ||
cristyacd2ed22011-08-30 01:44:23 +0000824 (q == (Quantum *) NULL))
cristy90dbac72010-08-22 15:08:40 +0000825 break;
826 for (x=0; x < (ssize_t) image->columns; x++)
827 {
cristyf27ee032011-09-29 17:51:41 +0000828 SetPixelBlue(image,GetPixelBlue(canvas_image,p),q);
cristyed231572011-07-14 02:18:59 +0000829 p+=GetPixelChannels(canvas_image);
830 q+=GetPixelChannels(image);
cristy90dbac72010-08-22 15:08:40 +0000831 }
832 if (SyncAuthenticPixels(image,exception) == MagickFalse)
833 break;
834 }
835 count=ReadBlob(image,length,pixels);
836 }
837 if (image->previous == (Image *) NULL)
838 {
839 status=SetImageProgress(image,LoadImageTag,3,5);
840 if (status == MagickFalse)
841 break;
842 }
843 if (image->matte != MagickFalse)
844 {
845 (void) CloseBlob(image);
846 AppendImageFormat("A",image->filename);
847 status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
848 if (status == MagickFalse)
849 {
850 canvas_image=DestroyImageList(canvas_image);
851 image=DestroyImageList(image);
852 return((Image *) NULL);
853 }
854 length=GetQuantumExtent(canvas_image,quantum_info,AlphaQuantum);
855 for (i=0; i < (ssize_t) scene; i++)
856 for (y=0; y < (ssize_t) image->extract_info.height; y++)
857 if (ReadBlob(image,length,pixels) != (ssize_t) length)
858 {
859 ThrowFileException(exception,CorruptImageError,
860 "UnexpectedEndOfFile",image->filename);
861 break;
862 }
863 count=ReadBlob(image,length,pixels);
864 for (y=0; y < (ssize_t) image->extract_info.height; y++)
865 {
cristy4c08aed2011-07-01 19:47:50 +0000866 register const Quantum
cristy90dbac72010-08-22 15:08:40 +0000867 *restrict p;
868
cristy4c08aed2011-07-01 19:47:50 +0000869 register Quantum
cristy90dbac72010-08-22 15:08:40 +0000870 *restrict q;
871
872 register ssize_t
873 x;
874
875 if (count != (ssize_t) length)
876 {
877 ThrowFileException(exception,CorruptImageError,
878 "UnexpectedEndOfFile",image->filename);
879 break;
880 }
881 q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1,
882 exception);
cristyacd2ed22011-08-30 01:44:23 +0000883 if (q == (Quantum *) NULL)
cristy90dbac72010-08-22 15:08:40 +0000884 break;
885 length=ImportQuantumPixels(canvas_image,(CacheView *) NULL,
886 quantum_info,BlueQuantum,pixels,exception);
887 if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
888 break;
889 if (((y-image->extract_info.y) >= 0) &&
890 ((y-image->extract_info.y) < (ssize_t) image->rows))
891 {
892 p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,
893 0,canvas_image->columns,1,exception);
894 q=GetAuthenticPixels(image,0,y-image->extract_info.y,
895 image->columns,1,exception);
cristy4c08aed2011-07-01 19:47:50 +0000896 if ((p == (const Quantum *) NULL) ||
cristyacd2ed22011-08-30 01:44:23 +0000897 (q == (Quantum *) NULL))
cristy90dbac72010-08-22 15:08:40 +0000898 break;
899 for (x=0; x < (ssize_t) image->columns; x++)
900 {
cristyf27ee032011-09-29 17:51:41 +0000901 SetPixelAlpha(image,GetPixelAlpha(canvas_image,p),q);
cristyed231572011-07-14 02:18:59 +0000902 p+=GetPixelChannels(canvas_image);
903 q+=GetPixelChannels(image);
cristy90dbac72010-08-22 15:08:40 +0000904 }
905 if (SyncAuthenticPixels(image,exception) == MagickFalse)
906 break;
907 }
908 count=ReadBlob(image,length,pixels);
909 }
910 if (image->previous == (Image *) NULL)
911 {
912 status=SetImageProgress(image,LoadImageTag,4,5);
913 if (status == MagickFalse)
914 break;
915 }
916 }
917 (void) CloseBlob(image);
918 if (image->previous == (Image *) NULL)
919 {
cristy3ed852e2009-09-05 21:47:34 +0000920 status=SetImageProgress(image,LoadImageTag,5,5);
921 if (status == MagickFalse)
922 break;
923 }
924 break;
925 }
926 }
927 SetQuantumImageType(image,quantum_type);
cristy3ed852e2009-09-05 21:47:34 +0000928 /*
929 Proceed to next image.
930 */
931 if (image_info->number_scenes != 0)
932 if (image->scene >= (image_info->scene+image_info->number_scenes-1))
933 break;
934 if (count == (ssize_t) length)
935 {
936 /*
937 Allocate next image structure.
938 */
cristy9950d572011-10-01 18:22:35 +0000939 AcquireNextImage(image_info,image,exception);
cristy3ed852e2009-09-05 21:47:34 +0000940 if (GetNextImageInList(image) == (Image *) NULL)
941 {
942 image=DestroyImageList(image);
943 return((Image *) NULL);
944 }
945 image=SyncNextImageInList(image);
946 status=SetImageProgress(image,LoadImagesTag,TellBlob(image),
947 GetBlobSize(image));
948 if (status == MagickFalse)
949 break;
950 }
951 scene++;
952 } while (count == (ssize_t) length);
cristy3ed852e2009-09-05 21:47:34 +0000953 quantum_info=DestroyQuantumInfo(quantum_info);
cristy3ed852e2009-09-05 21:47:34 +0000954 canvas_image=DestroyImage(canvas_image);
955 (void) CloseBlob(image);
956 return(GetFirstImageInList(image));
957}
958
959/*
960%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
961% %
962% %
963% %
964% R e g i s t e r R G B I m a g e %
965% %
966% %
967% %
968%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
969%
cristy90dbac72010-08-22 15:08:40 +0000970% RegisterRGBImage() adds attributes for the RGB image format to
cristy3ed852e2009-09-05 21:47:34 +0000971% the list of supported formats. The attributes include the image format
972% tag, a method to read and/or write the format, whether the format
973% supports the saving of more than one frame to the same file or blob,
974% whether the format supports native in-memory I/O, and a brief
975% description of the format.
976%
977% The format of the RegisterRGBImage method is:
978%
cristybb503372010-05-27 20:51:26 +0000979% size_t RegisterRGBImage(void)
cristy3ed852e2009-09-05 21:47:34 +0000980%
981*/
cristybb503372010-05-27 20:51:26 +0000982ModuleExport size_t RegisterRGBImage(void)
cristy3ed852e2009-09-05 21:47:34 +0000983{
984 MagickInfo
985 *entry;
986
987 entry=SetMagickInfo("RGB");
988 entry->decoder=(DecodeImageHandler *) ReadRGBImage;
989 entry->encoder=(EncodeImageHandler *) WriteRGBImage;
990 entry->raw=MagickTrue;
991 entry->endian_support=MagickTrue;
cristy3ed852e2009-09-05 21:47:34 +0000992 entry->description=ConstantString("Raw red, green, and blue samples");
993 entry->module=ConstantString("RGB");
994 (void) RegisterMagickInfo(entry);
cristy3ed852e2009-09-05 21:47:34 +0000995 entry=SetMagickInfo("RGBA");
996 entry->decoder=(DecodeImageHandler *) ReadRGBImage;
997 entry->encoder=(EncodeImageHandler *) WriteRGBImage;
998 entry->raw=MagickTrue;
999 entry->endian_support=MagickTrue;
cristy3ed852e2009-09-05 21:47:34 +00001000 entry->description=ConstantString("Raw red, green, blue, and alpha samples");
1001 entry->module=ConstantString("RGB");
1002 (void) RegisterMagickInfo(entry);
1003 entry=SetMagickInfo("RGBO");
1004 entry->decoder=(DecodeImageHandler *) ReadRGBImage;
1005 entry->encoder=(EncodeImageHandler *) WriteRGBImage;
1006 entry->raw=MagickTrue;
1007 entry->endian_support=MagickTrue;
cristy90dbac72010-08-22 15:08:40 +00001008 entry->description=ConstantString("Raw red, green, blue, and opacity samples");
cristy3ed852e2009-09-05 21:47:34 +00001009 entry->module=ConstantString("RGB");
1010 (void) RegisterMagickInfo(entry);
1011 return(MagickImageCoderSignature);
1012}
1013
1014/*
1015%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1016% %
1017% %
1018% %
1019% U n r e g i s t e r R G B I m a g e %
1020% %
1021% %
1022% %
1023%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1024%
cristy90dbac72010-08-22 15:08:40 +00001025% UnregisterRGBImage() removes format registrations made by the RGB module
1026% from the list of supported formats.
cristy3ed852e2009-09-05 21:47:34 +00001027%
1028% The format of the UnregisterRGBImage method is:
1029%
1030% UnregisterRGBImage(void)
1031%
1032*/
1033ModuleExport void UnregisterRGBImage(void)
1034{
1035 (void) UnregisterMagickInfo("RGBO");
1036 (void) UnregisterMagickInfo("RGBA");
cristy3ed852e2009-09-05 21:47:34 +00001037 (void) UnregisterMagickInfo("RGB");
1038}
1039
1040/*
1041%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1042% %
1043% %
1044% %
1045% W r i t e R G B I m a g e %
1046% %
1047% %
1048% %
1049%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1050%
cristy90dbac72010-08-22 15:08:40 +00001051% WriteRGBImage() writes an image to a file in the RGB, RGBA, or RGBO
1052% rasterfile format.
cristy3ed852e2009-09-05 21:47:34 +00001053%
1054% The format of the WriteRGBImage method is:
1055%
cristy90dbac72010-08-22 15:08:40 +00001056% MagickBooleanType WriteRGBImage(const ImageInfo *image_info,
cristy3a37efd2011-08-28 20:31:03 +00001057% Image *image,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +00001058%
1059% A description of each parameter follows.
1060%
1061% o image_info: the image info.
1062%
1063% o image: The image.
1064%
cristy3a37efd2011-08-28 20:31:03 +00001065% o exception: return any errors or warnings in this structure.
1066%
cristy3ed852e2009-09-05 21:47:34 +00001067*/
cristy90dbac72010-08-22 15:08:40 +00001068static MagickBooleanType WriteRGBImage(const ImageInfo *image_info,
cristy3a37efd2011-08-28 20:31:03 +00001069 Image *image,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +00001070{
cristy3ed852e2009-09-05 21:47:34 +00001071 MagickBooleanType
1072 status;
1073
1074 MagickOffsetType
1075 scene;
1076
1077 QuantumInfo
1078 *quantum_info;
1079
1080 QuantumType
cristy90dbac72010-08-22 15:08:40 +00001081 quantum_type;
cristy3ed852e2009-09-05 21:47:34 +00001082
cristyc6da28e2011-04-28 01:41:35 +00001083 size_t
1084 length;
1085
cristy3ed852e2009-09-05 21:47:34 +00001086 ssize_t
cristy90dbac72010-08-22 15:08:40 +00001087 count,
1088 y;
cristy3ed852e2009-09-05 21:47:34 +00001089
cristy3ed852e2009-09-05 21:47:34 +00001090 unsigned char
1091 *pixels;
1092
cristy3ed852e2009-09-05 21:47:34 +00001093 /*
1094 Allocate memory for pixels.
1095 */
1096 assert(image_info != (const ImageInfo *) NULL);
1097 assert(image_info->signature == MagickSignature);
1098 assert(image != (Image *) NULL);
1099 assert(image->signature == MagickSignature);
1100 if (image->debug != MagickFalse)
1101 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
1102 if (image_info->interlace != PartitionInterlace)
1103 {
1104 /*
1105 Open output image file.
1106 */
cristyedf03fa2011-08-30 12:44:39 +00001107 status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception);
cristy3ed852e2009-09-05 21:47:34 +00001108 if (status == MagickFalse)
1109 return(status);
1110 }
1111 quantum_type=RGBQuantum;
cristy90dbac72010-08-22 15:08:40 +00001112 if (LocaleCompare(image_info->magick,"RGBA") == 0)
cristy3ed852e2009-09-05 21:47:34 +00001113 {
cristy90dbac72010-08-22 15:08:40 +00001114 quantum_type=RGBAQuantum;
cristy100b8d92012-01-08 00:32:49 +00001115 if (image->matte == MagickFalse)
1116 SetImageAlphaChannel(image,OpaqueAlphaChannel,exception);
cristy3ed852e2009-09-05 21:47:34 +00001117 }
cristy90dbac72010-08-22 15:08:40 +00001118 if (LocaleCompare(image_info->magick,"RGBO") == 0)
1119 {
1120 quantum_type=RGBOQuantum;
cristy100b8d92012-01-08 00:32:49 +00001121 if (image->matte == MagickFalse)
1122 SetImageAlphaChannel(image,QuantumRange-OpaqueAlphaChannel,exception);
cristy90dbac72010-08-22 15:08:40 +00001123 }
cristy3ed852e2009-09-05 21:47:34 +00001124 scene=0;
1125 do
1126 {
1127 /*
1128 Convert MIFF to RGB raster pixels.
1129 */
cristy510d06a2011-07-06 23:43:54 +00001130 if (IsRGBColorspace(image->colorspace) == MagickFalse)
cristye941a752011-10-15 01:52:48 +00001131 (void) TransformImageColorspace(image,RGBColorspace,exception);
cristy3ed852e2009-09-05 21:47:34 +00001132 if ((LocaleCompare(image_info->magick,"RGBA") == 0) &&
1133 (image->matte == MagickFalse))
cristy3a37efd2011-08-28 20:31:03 +00001134 (void) SetImageAlphaChannel(image,OpaqueAlphaChannel,exception);
cristy3ed852e2009-09-05 21:47:34 +00001135 quantum_info=AcquireQuantumInfo(image_info,image);
1136 if (quantum_info == (QuantumInfo *) NULL)
1137 ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
1138 pixels=GetQuantumPixels(quantum_info);
1139 switch (image_info->interlace)
1140 {
1141 case NoInterlace:
1142 default:
1143 {
cristy3ed852e2009-09-05 21:47:34 +00001144 /*
1145 No interlacing: RGBRGBRGBRGBRGBRGB...
1146 */
cristybb503372010-05-27 20:51:26 +00001147 for (y=0; y < (ssize_t) image->rows; y++)
cristy3ed852e2009-09-05 21:47:34 +00001148 {
cristy4c08aed2011-07-01 19:47:50 +00001149 register const Quantum
cristy90dbac72010-08-22 15:08:40 +00001150 *restrict p;
cristy3ed852e2009-09-05 21:47:34 +00001151
cristy3a37efd2011-08-28 20:31:03 +00001152 p=GetVirtualPixels(image,0,y,image->columns,1,exception);
cristy4c08aed2011-07-01 19:47:50 +00001153 if (p == (const Quantum *) NULL)
cristy3ed852e2009-09-05 21:47:34 +00001154 break;
cristy4c08aed2011-07-01 19:47:50 +00001155 length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
cristy3a37efd2011-08-28 20:31:03 +00001156 quantum_type,pixels,exception);
cristy3ed852e2009-09-05 21:47:34 +00001157 count=WriteBlob(image,length,pixels);
1158 if (count != (ssize_t) length)
1159 break;
1160 if (image->previous == (Image *) NULL)
1161 {
cristycee97112010-05-28 00:44:52 +00001162 status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
1163 image->rows);
cristy3ed852e2009-09-05 21:47:34 +00001164 if (status == MagickFalse)
1165 break;
1166 }
1167 }
cristy3ed852e2009-09-05 21:47:34 +00001168 break;
1169 }
1170 case LineInterlace:
1171 {
1172 /*
1173 Line interlacing: RRR...GGG...BBB...RRR...GGG...BBB...
1174 */
cristybb503372010-05-27 20:51:26 +00001175 for (y=0; y < (ssize_t) image->rows; y++)
cristy3ed852e2009-09-05 21:47:34 +00001176 {
cristy4c08aed2011-07-01 19:47:50 +00001177 register const Quantum
cristyc47d1f82009-11-26 01:44:43 +00001178 *restrict p;
cristy3ed852e2009-09-05 21:47:34 +00001179
cristy3a37efd2011-08-28 20:31:03 +00001180 p=GetVirtualPixels(image,0,y,image->columns,1,exception);
cristy4c08aed2011-07-01 19:47:50 +00001181 if (p == (const Quantum *) NULL)
cristy3ed852e2009-09-05 21:47:34 +00001182 break;
cristy4c08aed2011-07-01 19:47:50 +00001183 length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
cristy3a37efd2011-08-28 20:31:03 +00001184 RedQuantum,pixels,exception);
cristy90dbac72010-08-22 15:08:40 +00001185 count=WriteBlob(image,length,pixels);
1186 if (count != (ssize_t) length)
1187 break;
cristy4c08aed2011-07-01 19:47:50 +00001188 length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
cristy3a37efd2011-08-28 20:31:03 +00001189 GreenQuantum,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 BlueQuantum,pixels,exception);
cristy90dbac72010-08-22 15:08:40 +00001195 count=WriteBlob(image,length,pixels);
1196 if (count != (ssize_t) length)
1197 break;
1198 if (quantum_type == RGBAQuantum)
1199 {
cristy4c08aed2011-07-01 19:47:50 +00001200 length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
cristy3a37efd2011-08-28 20:31:03 +00001201 AlphaQuantum,pixels,exception);
cristy90dbac72010-08-22 15:08:40 +00001202 count=WriteBlob(image,length,pixels);
1203 if (count != (ssize_t) length)
1204 break;
1205 }
1206 if (quantum_type == RGBOQuantum)
1207 {
cristy4c08aed2011-07-01 19:47:50 +00001208 length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
cristy3a37efd2011-08-28 20:31:03 +00001209 OpacityQuantum,pixels,exception);
cristy90dbac72010-08-22 15:08:40 +00001210 count=WriteBlob(image,length,pixels);
1211 if (count != (ssize_t) length)
1212 break;
1213 }
cristy3ed852e2009-09-05 21:47:34 +00001214 if (image->previous == (Image *) NULL)
1215 {
cristycee97112010-05-28 00:44:52 +00001216 status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
1217 image->rows);
cristy3ed852e2009-09-05 21:47:34 +00001218 if (status == MagickFalse)
1219 break;
1220 }
1221 }
1222 break;
1223 }
1224 case PlaneInterlace:
1225 {
1226 /*
1227 Plane interlacing: RRRRRR...GGGGGG...BBBBBB...
1228 */
cristy90dbac72010-08-22 15:08:40 +00001229 for (y=0; y < (ssize_t) image->rows; y++)
cristy3ed852e2009-09-05 21:47:34 +00001230 {
cristy4c08aed2011-07-01 19:47:50 +00001231 register const Quantum
cristy90dbac72010-08-22 15:08:40 +00001232 *restrict p;
cristy3ed852e2009-09-05 21:47:34 +00001233
cristy3a37efd2011-08-28 20:31:03 +00001234 p=GetVirtualPixels(image,0,y,image->columns,1,exception);
cristy4c08aed2011-07-01 19:47:50 +00001235 if (p == (const Quantum *) NULL)
cristy90dbac72010-08-22 15:08:40 +00001236 break;
cristy4c08aed2011-07-01 19:47:50 +00001237 length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
cristy3a37efd2011-08-28 20:31:03 +00001238 RedQuantum,pixels,exception);
cristy90dbac72010-08-22 15:08:40 +00001239 count=WriteBlob(image,length,pixels);
1240 if (count != (ssize_t) length)
1241 break;
cristy3ed852e2009-09-05 21:47:34 +00001242 }
1243 if (image->previous == (Image *) NULL)
1244 {
cristy90dbac72010-08-22 15:08:40 +00001245 status=SetImageProgress(image,SaveImageTag,1,6);
1246 if (status == MagickFalse)
1247 break;
1248 }
1249 for (y=0; y < (ssize_t) image->rows; y++)
1250 {
cristy4c08aed2011-07-01 19:47:50 +00001251 register const Quantum
cristy90dbac72010-08-22 15:08:40 +00001252 *restrict p;
1253
cristy3a37efd2011-08-28 20:31:03 +00001254 p=GetVirtualPixels(image,0,y,image->columns,1,exception);
cristy4c08aed2011-07-01 19:47:50 +00001255 if (p == (const Quantum *) NULL)
cristy90dbac72010-08-22 15:08:40 +00001256 break;
cristy4c08aed2011-07-01 19:47:50 +00001257 length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
cristy3a37efd2011-08-28 20:31:03 +00001258 GreenQuantum,pixels,exception);
cristy90dbac72010-08-22 15:08:40 +00001259 count=WriteBlob(image,length,pixels);
1260 if (count != (ssize_t) length)
1261 break;
1262 }
1263 if (image->previous == (Image *) NULL)
1264 {
1265 status=SetImageProgress(image,SaveImageTag,2,6);
1266 if (status == MagickFalse)
1267 break;
1268 }
1269 for (y=0; y < (ssize_t) image->rows; y++)
1270 {
cristy4c08aed2011-07-01 19:47:50 +00001271 register const Quantum
cristy90dbac72010-08-22 15:08:40 +00001272 *restrict p;
1273
cristy3a37efd2011-08-28 20:31:03 +00001274 p=GetVirtualPixels(image,0,y,image->columns,1,exception);
cristy4c08aed2011-07-01 19:47:50 +00001275 if (p == (const Quantum *) NULL)
cristy90dbac72010-08-22 15:08:40 +00001276 break;
cristy4c08aed2011-07-01 19:47:50 +00001277 length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
cristy3a37efd2011-08-28 20:31:03 +00001278 BlueQuantum,pixels,exception);
cristy90dbac72010-08-22 15:08:40 +00001279 count=WriteBlob(image,length,pixels);
1280 if (count != (ssize_t) length)
1281 break;
1282 }
1283 if (image->previous == (Image *) NULL)
1284 {
1285 status=SetImageProgress(image,SaveImageTag,3,6);
1286 if (status == MagickFalse)
1287 break;
1288 }
1289 if (quantum_type == RGBAQuantum)
1290 {
1291 for (y=0; y < (ssize_t) image->rows; y++)
1292 {
cristy4c08aed2011-07-01 19:47:50 +00001293 register const Quantum
cristy90dbac72010-08-22 15:08:40 +00001294 *restrict p;
1295
cristy3a37efd2011-08-28 20:31:03 +00001296 p=GetVirtualPixels(image,0,y,image->columns,1,exception);
cristy4c08aed2011-07-01 19:47:50 +00001297 if (p == (const Quantum *) NULL)
cristy90dbac72010-08-22 15:08:40 +00001298 break;
cristy4c08aed2011-07-01 19:47:50 +00001299 length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
cristy3a37efd2011-08-28 20:31:03 +00001300 AlphaQuantum,pixels,exception);
cristy90dbac72010-08-22 15:08:40 +00001301 count=WriteBlob(image,length,pixels);
1302 if (count != (ssize_t) length)
1303 break;
1304 }
1305 if (image->previous == (Image *) NULL)
1306 {
1307 status=SetImageProgress(image,SaveImageTag,5,6);
1308 if (status == MagickFalse)
1309 break;
1310 }
1311 }
1312 if (image_info->interlace == PartitionInterlace)
1313 (void) CopyMagickString(image->filename,image_info->filename,
1314 MaxTextExtent);
1315 if (image->previous == (Image *) NULL)
1316 {
1317 status=SetImageProgress(image,SaveImageTag,6,6);
cristy3ed852e2009-09-05 21:47:34 +00001318 if (status == MagickFalse)
1319 break;
1320 }
1321 break;
1322 }
1323 case PartitionInterlace:
1324 {
cristy3ed852e2009-09-05 21:47:34 +00001325 /*
1326 Partition interlacing: RRRRRR..., GGGGGG..., BBBBBB...
1327 */
cristy90dbac72010-08-22 15:08:40 +00001328 AppendImageFormat("R",image->filename);
1329 status=OpenBlob(image_info,image,scene == 0 ? WriteBinaryBlobMode :
cristy3a37efd2011-08-28 20:31:03 +00001330 AppendBinaryBlobMode,exception);
cristy90dbac72010-08-22 15:08:40 +00001331 if (status == MagickFalse)
1332 return(status);
1333 for (y=0; y < (ssize_t) image->rows; y++)
cristy3ed852e2009-09-05 21:47:34 +00001334 {
cristy4c08aed2011-07-01 19:47:50 +00001335 register const Quantum
cristy90dbac72010-08-22 15:08:40 +00001336 *restrict p;
cristy3ed852e2009-09-05 21:47:34 +00001337
cristy3a37efd2011-08-28 20:31:03 +00001338 p=GetVirtualPixels(image,0,y,image->columns,1,exception);
cristy4c08aed2011-07-01 19:47:50 +00001339 if (p == (const Quantum *) NULL)
cristy90dbac72010-08-22 15:08:40 +00001340 break;
cristy4c08aed2011-07-01 19:47:50 +00001341 length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
cristy3a37efd2011-08-28 20:31:03 +00001342 RedQuantum,pixels,exception);
cristy90dbac72010-08-22 15:08:40 +00001343 count=WriteBlob(image,length,pixels);
1344 if (count != (ssize_t) length)
1345 break;
1346 }
1347 if (image->previous == (Image *) NULL)
1348 {
1349 status=SetImageProgress(image,SaveImageTag,1,6);
1350 if (status == MagickFalse)
cristy3ed852e2009-09-05 21:47:34 +00001351 break;
1352 }
cristy90dbac72010-08-22 15:08:40 +00001353 (void) CloseBlob(image);
1354 AppendImageFormat("G",image->filename);
1355 status=OpenBlob(image_info,image,scene == 0 ? WriteBinaryBlobMode :
cristy3a37efd2011-08-28 20:31:03 +00001356 AppendBinaryBlobMode,exception);
cristy90dbac72010-08-22 15:08:40 +00001357 if (status == MagickFalse)
1358 return(status);
1359 for (y=0; y < (ssize_t) image->rows; y++)
1360 {
cristy4c08aed2011-07-01 19:47:50 +00001361 register const Quantum
cristy90dbac72010-08-22 15:08:40 +00001362 *restrict p;
1363
cristy3a37efd2011-08-28 20:31:03 +00001364 p=GetVirtualPixels(image,0,y,image->columns,1,exception);
cristy4c08aed2011-07-01 19:47:50 +00001365 if (p == (const Quantum *) NULL)
cristy90dbac72010-08-22 15:08:40 +00001366 break;
cristy4c08aed2011-07-01 19:47:50 +00001367 length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
cristy3a37efd2011-08-28 20:31:03 +00001368 GreenQuantum,pixels,exception);
cristy90dbac72010-08-22 15:08:40 +00001369 count=WriteBlob(image,length,pixels);
1370 if (count != (ssize_t) length)
1371 break;
1372 }
1373 if (image->previous == (Image *) NULL)
1374 {
1375 status=SetImageProgress(image,SaveImageTag,2,6);
1376 if (status == MagickFalse)
1377 break;
1378 }
1379 (void) CloseBlob(image);
1380 AppendImageFormat("B",image->filename);
1381 status=OpenBlob(image_info,image,scene == 0 ? WriteBinaryBlobMode :
cristy3a37efd2011-08-28 20:31:03 +00001382 AppendBinaryBlobMode,exception);
cristy90dbac72010-08-22 15:08:40 +00001383 if (status == MagickFalse)
1384 return(status);
1385 for (y=0; y < (ssize_t) image->rows; y++)
1386 {
cristy4c08aed2011-07-01 19:47:50 +00001387 register const Quantum
cristy90dbac72010-08-22 15:08:40 +00001388 *restrict p;
1389
cristy3a37efd2011-08-28 20:31:03 +00001390 p=GetVirtualPixels(image,0,y,image->columns,1,exception);
cristy4c08aed2011-07-01 19:47:50 +00001391 if (p == (const Quantum *) NULL)
cristy90dbac72010-08-22 15:08:40 +00001392 break;
cristy4c08aed2011-07-01 19:47:50 +00001393 length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
cristy3a37efd2011-08-28 20:31:03 +00001394 BlueQuantum,pixels,exception);
cristy90dbac72010-08-22 15:08:40 +00001395 count=WriteBlob(image,length,pixels);
1396 if (count != (ssize_t) length)
1397 break;
1398 }
1399 if (image->previous == (Image *) NULL)
1400 {
1401 status=SetImageProgress(image,SaveImageTag,3,6);
1402 if (status == MagickFalse)
1403 break;
1404 }
1405 (void) CloseBlob(image);
1406 if (quantum_type == RGBAQuantum)
1407 {
1408 (void) CloseBlob(image);
1409 AppendImageFormat("A",image->filename);
1410 status=OpenBlob(image_info,image,scene == 0 ? WriteBinaryBlobMode :
cristy3a37efd2011-08-28 20:31:03 +00001411 AppendBinaryBlobMode,exception);
cristy90dbac72010-08-22 15:08:40 +00001412 if (status == MagickFalse)
1413 return(status);
1414 for (y=0; y < (ssize_t) image->rows; y++)
cristy3ed852e2009-09-05 21:47:34 +00001415 {
cristy4c08aed2011-07-01 19:47:50 +00001416 register const Quantum
cristy90dbac72010-08-22 15:08:40 +00001417 *restrict p;
1418
cristy3a37efd2011-08-28 20:31:03 +00001419 p=GetVirtualPixels(image,0,y,image->columns,1,exception);
cristy4c08aed2011-07-01 19:47:50 +00001420 if (p == (const Quantum *) NULL)
cristy90dbac72010-08-22 15:08:40 +00001421 break;
cristy4c08aed2011-07-01 19:47:50 +00001422 length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
cristy3a37efd2011-08-28 20:31:03 +00001423 AlphaQuantum,pixels,exception);
cristy90dbac72010-08-22 15:08:40 +00001424 count=WriteBlob(image,length,pixels);
1425 if (count != (ssize_t) length)
cristy3ed852e2009-09-05 21:47:34 +00001426 break;
1427 }
cristy90dbac72010-08-22 15:08:40 +00001428 if (image->previous == (Image *) NULL)
1429 {
1430 status=SetImageProgress(image,SaveImageTag,5,6);
1431 if (status == MagickFalse)
1432 break;
1433 }
1434 }
1435 (void) CloseBlob(image);
cristy3ed852e2009-09-05 21:47:34 +00001436 (void) CopyMagickString(image->filename,image_info->filename,
1437 MaxTextExtent);
1438 if (image->previous == (Image *) NULL)
1439 {
cristy90dbac72010-08-22 15:08:40 +00001440 status=SetImageProgress(image,SaveImageTag,6,6);
cristy3ed852e2009-09-05 21:47:34 +00001441 if (status == MagickFalse)
1442 break;
1443 }
1444 break;
1445 }
1446 }
1447 quantum_info=DestroyQuantumInfo(quantum_info);
1448 if (GetNextImageInList(image) == (Image *) NULL)
1449 break;
1450 image=SyncNextImageInList(image);
1451 status=SetImageProgress(image,SaveImagesTag,scene++,
1452 GetImageListLength(image));
1453 if (status == MagickFalse)
1454 break;
1455 } while (image_info->adjoin != MagickFalse);
1456 (void) CloseBlob(image);
1457 return(MagickTrue);
1458}