Coverage Report

Created: 2026-03-31 06:56

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/imagemagick/coders/rgb.c
Line
Count
Source
1
/*
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
%                                   Cristy                                    %
17
%                                 July 1992                                   %
18
%                                                                             %
19
%                                                                             %
20
%  Copyright @ 1999 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
%    https://imagemagick.org/license/                                         %
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
*/
42
#include "MagickCore/studio.h"
43
#include "MagickCore/blob.h"
44
#include "MagickCore/blob-private.h"
45
#include "MagickCore/cache.h"
46
#include "MagickCore/channel.h"
47
#include "MagickCore/colorspace.h"
48
#include "MagickCore/colorspace-private.h"
49
#include "MagickCore/constitute.h"
50
#include "MagickCore/exception.h"
51
#include "MagickCore/exception-private.h"
52
#include "MagickCore/image.h"
53
#include "MagickCore/image-private.h"
54
#include "MagickCore/list.h"
55
#include "MagickCore/magick.h"
56
#include "MagickCore/memory_.h"
57
#include "MagickCore/monitor.h"
58
#include "MagickCore/monitor-private.h"
59
#include "MagickCore/pixel-accessor.h"
60
#include "MagickCore/quantum-private.h"
61
#include "MagickCore/static.h"
62
#include "MagickCore/statistic.h"
63
#include "MagickCore/string_.h"
64
#include "MagickCore/module.h"
65
#include "MagickCore/utility.h"
66

67
/*
68
  Forward declarations.
69
*/
70
static MagickBooleanType
71
  WriteRGBImage(const ImageInfo *,Image *,ExceptionInfo *);
72

73
/*
74
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
75
%                                                                             %
76
%                                                                             %
77
%                                                                             %
78
%   R e a d R G B I m a g e                                                   %
79
%                                                                             %
80
%                                                                             %
81
%                                                                             %
82
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
83
%
84
%  ReadRGBImage() reads an image of raw RGB, RGBA, or RGBO samples and returns
85
%  it.  It allocates the memory necessary for the new Image structure and
86
%  returns a pointer to the new image.
87
%
88
%  The format of the ReadRGBImage method is:
89
%
90
%      Image *ReadRGBImage(const ImageInfo *image_info,
91
%        ExceptionInfo *exception)
92
%
93
%  A description of each parameter follows:
94
%
95
%    o image_info: the image info.
96
%
97
%    o exception: return any errors or warnings in this structure.
98
%
99
*/
100
static Image *ReadRGBImage(const ImageInfo *image_info,ExceptionInfo *exception)
101
117
{
102
117
  const void
103
117
    *stream;
104
105
117
  Image
106
117
    *canvas_image,
107
117
    *image;
108
109
117
  MagickBooleanType
110
117
    status = MagickTrue;
111
112
117
  MagickOffsetType
113
117
    scene;
114
115
117
  QuantumInfo
116
117
    *quantum_info;
117
118
117
  QuantumType
119
117
    quantum_type;
120
121
117
  ssize_t
122
117
    i;
123
124
117
  size_t
125
117
    length;
126
127
117
  ssize_t
128
117
    count,
129
117
    columns,
130
117
    y;
131
132
117
  unsigned char
133
117
    *pixels;
134
135
  /*
136
    Open image file.
137
  */
138
117
  assert(image_info != (const ImageInfo *) NULL);
139
117
  assert(image_info->signature == MagickCoreSignature);
140
117
  assert(exception != (ExceptionInfo *) NULL);
141
117
  assert(exception->signature == MagickCoreSignature);
142
117
  if (IsEventLogging() != MagickFalse)
143
0
    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
144
0
      image_info->filename);
145
117
  image=AcquireImage(image_info,exception);
146
117
  if ((image->columns == 0) || (image->rows == 0))
147
111
    ThrowReaderException(OptionError,"MustSpecifyImageSize");
148
6
  status=SetImageExtent(image,image->columns,image->rows,exception);
149
6
  if (status == MagickFalse)
150
2
    return(DestroyImageList(image));
151
4
  if (image_info->interlace != PartitionInterlace)
152
4
    {
153
4
      status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
154
4
      if (status == MagickFalse)
155
0
        {
156
0
          image=DestroyImageList(image);
157
0
          return((Image *) NULL);
158
0
        }
159
4
      if (DiscardBlobBytes(image,(MagickSizeType) image->offset) == MagickFalse)
160
0
        ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
161
4
          image->filename);
162
4
    }
163
  /*
164
    Create virtual canvas to support cropping (i.e. image.rgb[100x100+10+20]).
165
  */
166
4
  canvas_image=CloneImage(image,image->extract_info.width,1,MagickFalse,
167
4
    exception);
168
4
  if (canvas_image == (Image *) NULL)
169
4
    ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
170
4
  (void) SetImageVirtualPixelMethod(canvas_image,BlackVirtualPixelMethod,
171
4
    exception);
172
4
  quantum_type=RGBQuantum;
173
4
  if (LocaleCompare(image_info->magick,"RGBA") == 0)
174
1
    {
175
1
      quantum_type=RGBAQuantum;
176
1
      canvas_image->alpha_trait=BlendPixelTrait;
177
1
    }
178
4
  if (LocaleCompare(image_info->magick,"RGBO") == 0)
179
2
    {
180
2
      quantum_type=RGBOQuantum;
181
2
      canvas_image->alpha_trait=BlendPixelTrait;
182
2
    }
183
4
  quantum_info=AcquireQuantumInfo(image_info,canvas_image);
184
4
  if (quantum_info == (QuantumInfo *) NULL)
185
0
    {
186
0
      canvas_image=DestroyImage(canvas_image);
187
0
      ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
188
0
    }
189
4
  pixels=GetQuantumPixels(quantum_info);
190
4
  if (image_info->number_scenes != 0)
191
0
    while (image->scene < image_info->scene)
192
0
    {
193
      /*
194
        Skip to next image.
195
      */
196
0
      image->scene++;
197
0
      length=GetQuantumExtent(canvas_image,quantum_info,quantum_type);
198
0
      for (y=0; y < (ssize_t) image->rows; y++)
199
0
      {
200
0
        stream=ReadBlobStream(image,length,pixels,&count);
201
0
        if (count != (ssize_t) length)
202
0
          break;
203
0
      }
204
0
    }
205
4
  count=0;
206
4
  length=0;
207
4
  scene=0;
208
4
  status=MagickTrue;
209
4
  stream=NULL;
210
4
  columns=(ssize_t) MagickMin(image->columns,canvas_image->columns);
211
4
  do
212
19
  {
213
    /*
214
      Read pixels to virtual canvas image then push to image.
215
    */
216
19
    image->alpha_trait=canvas_image->alpha_trait;
217
19
    if ((image_info->ping != MagickFalse) && (image_info->number_scenes != 0))
218
0
      if (image->scene >= (image_info->scene+image_info->number_scenes-1))
219
0
        break;
220
19
    status=SetImageExtent(image,image->columns,image->rows,exception);
221
19
    if (status == MagickFalse)
222
1
      break;
223
18
    switch (image_info->interlace)
224
18
    {
225
18
      case NoInterlace:
226
18
      default:
227
18
      {
228
        /*
229
          No interlacing:  RGBRGBRGBRGBRGBRGB...
230
        */
231
18
        if (scene == 0)
232
4
          {
233
4
            length=GetQuantumExtent(canvas_image,quantum_info,quantum_type);
234
4
            stream=ReadBlobStream(image,length,pixels,&count);
235
4
          }
236
18
        for (y=0; y < (ssize_t) image->extract_info.height; y++)
237
0
        {
238
0
          const Quantum
239
0
            *magick_restrict p;
240
241
0
          Quantum
242
0
            *magick_restrict q;
243
244
0
          ssize_t
245
0
            x;
246
247
0
          if (count != (ssize_t) length)
248
0
            {
249
0
              status=MagickFalse;
250
0
              ThrowFileException(exception,CorruptImageError,
251
0
                "UnexpectedEndOfFile",image->filename);
252
0
              break;
253
0
            }
254
0
          q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1,
255
0
            exception);
256
0
          if (q == (Quantum *) NULL)
257
0
            break;
258
0
          length=ImportQuantumPixels(canvas_image,(CacheView *) NULL,
259
0
            quantum_info,quantum_type,(unsigned char *) stream,exception);
260
0
          if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
261
0
            break;
262
0
          if (((y-image->extract_info.y) >= 0) &&
263
0
              ((y-image->extract_info.y) < (ssize_t) image->rows))
264
0
            {
265
0
              p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
266
0
                canvas_image->columns,1,exception);
267
0
              q=QueueAuthenticPixels(image,0,y-image->extract_info.y,
268
0
                image->columns,1,exception);
269
0
              if ((p == (const Quantum *) NULL) || (q == (Quantum *) NULL))
270
0
                break;
271
0
              for (x=0; x < columns; x++)
272
0
              {
273
0
                SetPixelRed(image,GetPixelRed(canvas_image,p),q);
274
0
                SetPixelGreen(image,GetPixelGreen(canvas_image,p),q);
275
0
                SetPixelBlue(image,GetPixelBlue(canvas_image,p),q);
276
0
                SetPixelAlpha(image,OpaqueAlpha,q);
277
0
                if (image->alpha_trait != UndefinedPixelTrait)
278
0
                  SetPixelAlpha(image,GetPixelAlpha(canvas_image,p),q);
279
0
                p+=(ptrdiff_t) GetPixelChannels(canvas_image);
280
0
                q+=(ptrdiff_t) GetPixelChannels(image);
281
0
              }
282
0
              if (SyncAuthenticPixels(image,exception) == MagickFalse)
283
0
                break;
284
0
            }
285
0
          if (image->previous == (Image *) NULL)
286
0
            {
287
0
              status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,
288
0
                image->rows);
289
0
              if (status == MagickFalse)
290
0
                break;
291
0
            }
292
0
          stream=ReadBlobStream(image,length,pixels,&count);
293
0
        }
294
18
        break;
295
18
      }
296
0
      case LineInterlace:
297
0
      {
298
0
        static QuantumType
299
0
          quantum_types[4] =
300
0
          {
301
0
            RedQuantum,
302
0
            GreenQuantum,
303
0
            BlueQuantum,
304
0
            AlphaQuantum
305
0
          };
306
307
        /*
308
          Line interlacing:  RRR...GGG...BBB...RRR...GGG...BBB...
309
        */
310
0
        if (LocaleCompare(image_info->magick,"RGBO") == 0)
311
0
          quantum_types[3]=OpacityQuantum;
312
0
        if (scene == 0)
313
0
          {
314
0
            length=GetQuantumExtent(canvas_image,quantum_info,RedQuantum);
315
0
            stream=ReadBlobStream(image,length,pixels,&count);
316
0
          }
317
0
        for (y=0; y < (ssize_t) image->extract_info.height; y++)
318
0
        {
319
0
          for (i=0; i < (ssize_t) (image->alpha_trait != UndefinedPixelTrait ? 4 : 3); i++)
320
0
          {
321
0
            const Quantum
322
0
              *magick_restrict p;
323
324
0
            Quantum
325
0
              *magick_restrict q;
326
327
0
            ssize_t
328
0
              x;
329
330
0
            if (count != (ssize_t) length)
331
0
              {
332
0
                status=MagickFalse;
333
0
                ThrowFileException(exception,CorruptImageError,
334
0
                  "UnexpectedEndOfFile",image->filename);
335
0
                break;
336
0
              }
337
0
            quantum_type=quantum_types[i];
338
0
            q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1,
339
0
              exception);
340
0
            if (q == (Quantum *) NULL)
341
0
              break;
342
0
            length=ImportQuantumPixels(canvas_image,(CacheView *) NULL,
343
0
              quantum_info,quantum_type,(unsigned char *) stream,exception);
344
0
            if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
345
0
              break;
346
0
            if (((y-image->extract_info.y) >= 0) &&
347
0
                ((y-image->extract_info.y) < (ssize_t) image->rows))
348
0
              {
349
0
                p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,
350
0
                  0,canvas_image->columns,1,exception);
351
0
                q=GetAuthenticPixels(image,0,y-image->extract_info.y,
352
0
                  image->columns,1,exception);
353
0
                if ((p == (const Quantum *) NULL) || (q == (Quantum *) NULL))
354
0
                  break;
355
0
                for (x=0; x < columns; x++)
356
0
                {
357
0
                  switch (quantum_type)
358
0
                  {
359
0
                    case RedQuantum:
360
0
                    {
361
0
                      SetPixelRed(image,GetPixelRed(canvas_image,p),q);
362
0
                      break;
363
0
                    }
364
0
                    case GreenQuantum:
365
0
                    {
366
0
                      SetPixelGreen(image,GetPixelGreen(canvas_image,p),q);
367
0
                      break;
368
0
                    }
369
0
                    case BlueQuantum:
370
0
                    {
371
0
                      SetPixelBlue(image,GetPixelBlue(canvas_image,p),q);
372
0
                      break;
373
0
                    }
374
0
                    case OpacityQuantum:
375
0
                    {
376
0
                      SetPixelOpacity(image,GetPixelOpacity(canvas_image,p),q);
377
0
                      break;
378
0
                    }
379
0
                    case AlphaQuantum:
380
0
                    {
381
0
                      SetPixelAlpha(image,GetPixelAlpha(canvas_image,p),q);
382
0
                      break;
383
0
                    }
384
0
                    default:
385
0
                      break;
386
0
                  }
387
0
                  p+=(ptrdiff_t) GetPixelChannels(canvas_image);
388
0
                  q+=(ptrdiff_t) GetPixelChannels(image);
389
0
                }
390
0
                if (SyncAuthenticPixels(image,exception) == MagickFalse)
391
0
                  break;
392
0
              }
393
0
            stream=ReadBlobStream(image,length,pixels,&count);
394
0
          }
395
0
          if (image->previous == (Image *) NULL)
396
0
            {
397
0
              status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,
398
0
                image->rows);
399
0
              if (status == MagickFalse)
400
0
                break;
401
0
            }
402
0
        }
403
0
        break;
404
0
      }
405
0
      case PlaneInterlace:
406
0
      {
407
        /*
408
          Plane interlacing:  RRRRRR...GGGGGG...BBBBBB...
409
        */
410
0
        if (scene == 0)
411
0
          {
412
0
            length=GetQuantumExtent(canvas_image,quantum_info,RedQuantum);
413
0
            stream=ReadBlobStream(image,length,pixels,&count);
414
0
          }
415
0
        for (y=0; y < (ssize_t) image->extract_info.height; y++)
416
0
        {
417
0
          const Quantum
418
0
            *magick_restrict p;
419
420
0
          Quantum
421
0
            *magick_restrict q;
422
423
0
          ssize_t
424
0
            x;
425
426
0
          if (count != (ssize_t) length)
427
0
            {
428
0
              status=MagickFalse;
429
0
              ThrowFileException(exception,CorruptImageError,
430
0
                "UnexpectedEndOfFile",image->filename);
431
0
              break;
432
0
            }
433
0
          q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1,
434
0
            exception);
435
0
          if (q == (Quantum *) NULL)
436
0
            break;
437
0
          length=ImportQuantumPixels(canvas_image,(CacheView *) NULL,
438
0
            quantum_info,RedQuantum,(unsigned char *) stream,exception);
439
0
          if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
440
0
            break;
441
0
          if (((y-image->extract_info.y) >= 0) &&
442
0
              ((y-image->extract_info.y) < (ssize_t) image->rows))
443
0
            {
444
0
              p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
445
0
                canvas_image->columns,1,exception);
446
0
              q=GetAuthenticPixels(image,0,y-image->extract_info.y,
447
0
                image->columns,1,exception);
448
0
              if ((p == (const Quantum *) NULL) || (q == (Quantum *) NULL))
449
0
                break;
450
0
              for (x=0; x < columns; x++)
451
0
              {
452
0
                SetPixelRed(image,GetPixelRed(canvas_image,p),q);
453
0
                p+=(ptrdiff_t) GetPixelChannels(canvas_image);
454
0
                q+=(ptrdiff_t) GetPixelChannels(image);
455
0
              }
456
0
              if (SyncAuthenticPixels(image,exception) == MagickFalse)
457
0
                break;
458
0
            }
459
0
          stream=ReadBlobStream(image,length,pixels,&count);
460
0
        }
461
0
        if (image->previous == (Image *) NULL)
462
0
          {
463
0
            status=SetImageProgress(image,LoadImageTag,1,6);
464
0
            if (status == MagickFalse)
465
0
              break;
466
0
          }
467
0
        for (y=0; y < (ssize_t) image->extract_info.height; y++)
468
0
        {
469
0
          const Quantum
470
0
            *magick_restrict p;
471
472
0
          Quantum
473
0
            *magick_restrict q;
474
475
0
          ssize_t
476
0
            x;
477
478
0
          if (count != (ssize_t) length)
479
0
            {
480
0
              status=MagickFalse;
481
0
              ThrowFileException(exception,CorruptImageError,
482
0
                "UnexpectedEndOfFile",image->filename);
483
0
              break;
484
0
            }
485
0
          q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1,
486
0
            exception);
487
0
          if (q == (Quantum *) NULL)
488
0
            break;
489
0
          length=ImportQuantumPixels(canvas_image,(CacheView *) NULL,
490
0
            quantum_info,GreenQuantum,(unsigned char *) stream,exception);
491
0
          if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
492
0
            break;
493
0
          if (((y-image->extract_info.y) >= 0) &&
494
0
              ((y-image->extract_info.y) < (ssize_t) image->rows))
495
0
            {
496
0
              p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
497
0
                canvas_image->columns,1,exception);
498
0
              q=GetAuthenticPixels(image,0,y-image->extract_info.y,
499
0
                image->columns,1,exception);
500
0
              if ((p == (const Quantum *) NULL) || (q == (Quantum *) NULL))
501
0
                break;
502
0
              for (x=0; x < columns; x++)
503
0
              {
504
0
                SetPixelGreen(image,GetPixelGreen(canvas_image,p),q);
505
0
                p+=(ptrdiff_t) GetPixelChannels(canvas_image);
506
0
                q+=(ptrdiff_t) GetPixelChannels(image);
507
0
              }
508
0
              if (SyncAuthenticPixels(image,exception) == MagickFalse)
509
0
                break;
510
0
            }
511
0
          stream=ReadBlobStream(image,length,pixels,&count);
512
0
        }
513
0
        if (image->previous == (Image *) NULL)
514
0
          {
515
0
            status=SetImageProgress(image,LoadImageTag,2,6);
516
0
            if (status == MagickFalse)
517
0
              break;
518
0
          }
519
0
        for (y=0; y < (ssize_t) image->extract_info.height; y++)
520
0
        {
521
0
          const Quantum
522
0
            *magick_restrict p;
523
524
0
          Quantum
525
0
            *magick_restrict q;
526
527
0
          ssize_t
528
0
            x;
529
530
0
          if (count != (ssize_t) length)
531
0
            {
532
0
              status=MagickFalse;
533
0
              ThrowFileException(exception,CorruptImageError,
534
0
                "UnexpectedEndOfFile",image->filename);
535
0
              break;
536
0
            }
537
0
          q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1,
538
0
            exception);
539
0
          if (q == (Quantum *) NULL)
540
0
            break;
541
0
          length=ImportQuantumPixels(canvas_image,(CacheView *) NULL,
542
0
            quantum_info,BlueQuantum,(unsigned char *) stream,exception);
543
0
          if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
544
0
            break;
545
0
          if (((y-image->extract_info.y) >= 0) &&
546
0
              ((y-image->extract_info.y) < (ssize_t) image->rows))
547
0
            {
548
0
              p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
549
0
                canvas_image->columns,1,exception);
550
0
              q=GetAuthenticPixels(image,0,y-image->extract_info.y,
551
0
                image->columns,1,exception);
552
0
              if ((p == (const Quantum *) NULL) || (q == (Quantum *) NULL))
553
0
                break;
554
0
              for (x=0; x < columns; x++)
555
0
              {
556
0
                SetPixelBlue(image,GetPixelBlue(canvas_image,p),q);
557
0
                p+=(ptrdiff_t) GetPixelChannels(canvas_image);
558
0
                q+=(ptrdiff_t) GetPixelChannels(image);
559
0
              }
560
0
              if (SyncAuthenticPixels(image,exception) == MagickFalse)
561
0
                break;
562
0
            }
563
0
          stream=ReadBlobStream(image,length,pixels,&count);
564
0
        }
565
0
        if (image->previous == (Image *) NULL)
566
0
          {
567
0
            status=SetImageProgress(image,LoadImageTag,4,6);
568
0
            if (status == MagickFalse)
569
0
              break;
570
0
          }
571
0
        if (image->alpha_trait != UndefinedPixelTrait)
572
0
          {
573
0
            for (y=0; y < (ssize_t) image->extract_info.height; y++)
574
0
            {
575
0
              const Quantum
576
0
                *magick_restrict p;
577
578
0
              Quantum
579
0
                *magick_restrict q;
580
581
0
              ssize_t
582
0
                x;
583
584
0
              if (count != (ssize_t) length)
585
0
                {
586
0
                  status=MagickFalse;
587
0
                  ThrowFileException(exception,CorruptImageError,
588
0
                    "UnexpectedEndOfFile",image->filename);
589
0
                  break;
590
0
                }
591
0
              q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1,
592
0
                exception);
593
0
              if (q == (Quantum *) NULL)
594
0
                break;
595
0
              length=ImportQuantumPixels(canvas_image,(CacheView *) NULL,
596
0
                quantum_info,AlphaQuantum,(unsigned char *) stream,exception);
597
0
              if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
598
0
                break;
599
0
              if (((y-image->extract_info.y) >= 0) &&
600
0
                  ((y-image->extract_info.y) < (ssize_t) image->rows))
601
0
                {
602
0
                  p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,
603
0
                    0,canvas_image->columns,1,exception);
604
0
                  q=GetAuthenticPixels(image,0,y-image->extract_info.y,
605
0
                    image->columns,1,exception);
606
0
                  if ((p == (const Quantum *) NULL) || (q == (Quantum *) NULL))
607
0
                    break;
608
0
                  for (x=0; x < columns; x++)
609
0
                  {
610
0
                    SetPixelAlpha(image,GetPixelAlpha(canvas_image,p),q);
611
0
                    p+=(ptrdiff_t) GetPixelChannels(canvas_image);
612
0
                    q+=(ptrdiff_t) GetPixelChannels(image);
613
0
                  }
614
0
                  if (SyncAuthenticPixels(image,exception) == MagickFalse)
615
0
                    break;
616
0
                }
617
0
              stream=ReadBlobStream(image,length,pixels,&count);
618
0
            }
619
0
            if (image->previous == (Image *) NULL)
620
0
              {
621
0
                status=SetImageProgress(image,LoadImageTag,5,6);
622
0
                if (status == MagickFalse)
623
0
                  break;
624
0
              }
625
0
          }
626
0
        if (image->previous == (Image *) NULL)
627
0
          {
628
0
            status=SetImageProgress(image,LoadImageTag,6,6);
629
0
            if (status == MagickFalse)
630
0
              break;
631
0
          }
632
0
        break;
633
0
      }
634
0
      case PartitionInterlace:
635
0
      {
636
        /*
637
          Partition interlacing:  RRRRRR..., GGGGGG..., BBBBBB...
638
        */
639
0
        AppendImageFormat("R",image->filename);
640
0
        status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
641
0
        if (status == MagickFalse)
642
0
          break;
643
0
        if (DiscardBlobBytes(image,(MagickSizeType) image->offset) == MagickFalse)
644
0
          {
645
0
            status=MagickFalse;
646
0
            ThrowFileException(exception,CorruptImageError,
647
0
              "UnexpectedEndOfFile",image->filename);
648
0
            break;
649
0
          }
650
0
        length=GetQuantumExtent(canvas_image,quantum_info,RedQuantum);
651
0
        for (i=0; i < (ssize_t) scene; i++)
652
0
        {
653
0
          for (y=0; y < (ssize_t) image->extract_info.height; y++)
654
0
          {
655
0
            stream=ReadBlobStream(image,length,pixels,&count);
656
0
            if (count != (ssize_t) length)
657
0
              break;
658
0
          }
659
0
          if (count != (ssize_t) length)
660
0
            break;
661
0
        }
662
0
        stream=ReadBlobStream(image,length,pixels,&count);
663
0
        for (y=0; y < (ssize_t) image->extract_info.height; y++)
664
0
        {
665
0
          const Quantum
666
0
            *magick_restrict p;
667
668
0
          Quantum
669
0
            *magick_restrict q;
670
671
0
          ssize_t
672
0
            x;
673
674
0
          if (count != (ssize_t) length)
675
0
            {
676
0
              status=MagickFalse;
677
0
              ThrowFileException(exception,CorruptImageError,
678
0
                "UnexpectedEndOfFile",image->filename);
679
0
              break;
680
0
            }
681
0
          q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1,
682
0
            exception);
683
0
          if (q == (Quantum *) NULL)
684
0
            break;
685
0
          length=ImportQuantumPixels(canvas_image,(CacheView *) NULL,
686
0
            quantum_info,RedQuantum,(unsigned char *) stream,exception);
687
0
          if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
688
0
            break;
689
0
          if (((y-image->extract_info.y) >= 0) &&
690
0
              ((y-image->extract_info.y) < (ssize_t) image->rows))
691
0
            {
692
0
              p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
693
0
                canvas_image->columns,1,exception);
694
0
              q=GetAuthenticPixels(image,0,y-image->extract_info.y,
695
0
                image->columns,1,exception);
696
0
              if ((p == (const Quantum *) NULL) || (q == (Quantum *) NULL))
697
0
                break;
698
0
              for (x=0; x < columns; x++)
699
0
              {
700
0
                SetPixelRed(image,GetPixelRed(canvas_image,p),q);
701
0
                p+=(ptrdiff_t) GetPixelChannels(canvas_image);
702
0
                q+=(ptrdiff_t) GetPixelChannels(image);
703
0
              }
704
0
              if (SyncAuthenticPixels(image,exception) == MagickFalse)
705
0
                break;
706
0
            }
707
0
          stream=ReadBlobStream(image,length,pixels,&count);
708
0
        }
709
0
        if (image->previous == (Image *) NULL)
710
0
          {
711
0
            status=SetImageProgress(image,LoadImageTag,1,5);
712
0
            if (status == MagickFalse)
713
0
              break;
714
0
          }
715
0
        if (CloseBlob(image) == MagickFalse)
716
0
          break;
717
0
        AppendImageFormat("G",image->filename);
718
0
        status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
719
0
        if (status == MagickFalse)
720
0
          break;
721
0
        length=GetQuantumExtent(canvas_image,quantum_info,GreenQuantum);
722
0
        for (i=0; i < (ssize_t) scene; i++)
723
0
        {
724
0
          for (y=0; y < (ssize_t) image->extract_info.height; y++)
725
0
          {
726
0
            stream=ReadBlobStream(image,length,pixels,&count);
727
0
            if (count != (ssize_t) length)
728
0
              break;
729
0
          }
730
0
          if (count != (ssize_t) length)
731
0
            break;
732
0
        }
733
0
        stream=ReadBlobStream(image,length,pixels,&count);
734
0
        for (y=0; y < (ssize_t) image->extract_info.height; y++)
735
0
        {
736
0
          const Quantum
737
0
            *magick_restrict p;
738
739
0
          Quantum
740
0
            *magick_restrict q;
741
742
0
          ssize_t
743
0
            x;
744
745
0
          if (count != (ssize_t) length)
746
0
            {
747
0
              status=MagickFalse;
748
0
              ThrowFileException(exception,CorruptImageError,
749
0
                "UnexpectedEndOfFile",image->filename);
750
0
              break;
751
0
            }
752
0
          q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1,
753
0
            exception);
754
0
          if (q == (Quantum *) NULL)
755
0
            break;
756
0
          length=ImportQuantumPixels(canvas_image,(CacheView *) NULL,
757
0
            quantum_info,GreenQuantum,(unsigned char *) stream,exception);
758
0
          if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
759
0
            break;
760
0
          if (((y-image->extract_info.y) >= 0) &&
761
0
              ((y-image->extract_info.y) < (ssize_t) image->rows))
762
0
            {
763
0
              p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
764
0
                canvas_image->columns,1,exception);
765
0
              q=GetAuthenticPixels(image,0,y-image->extract_info.y,
766
0
                image->columns,1,exception);
767
0
              if ((p == (const Quantum *) NULL) || (q == (Quantum *) NULL))
768
0
                break;
769
0
              for (x=0; x < columns; x++)
770
0
              {
771
0
                SetPixelGreen(image,GetPixelGreen(canvas_image,p),q);
772
0
                p+=(ptrdiff_t) GetPixelChannels(canvas_image);
773
0
                q+=(ptrdiff_t) GetPixelChannels(image);
774
0
              }
775
0
              if (SyncAuthenticPixels(image,exception) == MagickFalse)
776
0
                break;
777
0
           }
778
0
          stream=ReadBlobStream(image,length,pixels,&count);
779
0
        }
780
0
        if (image->previous == (Image *) NULL)
781
0
          {
782
0
            status=SetImageProgress(image,LoadImageTag,2,5);
783
0
            if (status == MagickFalse)
784
0
              break;
785
0
          }
786
0
        if (CloseBlob(image) == MagickFalse)
787
0
          break;
788
0
        AppendImageFormat("B",image->filename);
789
0
        status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
790
0
        if (status == MagickFalse)
791
0
          break;
792
0
        length=GetQuantumExtent(canvas_image,quantum_info,BlueQuantum);
793
0
        for (i=0; i < (ssize_t) scene; i++)
794
0
        {
795
0
          for (y=0; y < (ssize_t) image->extract_info.height; y++)
796
0
          {
797
0
            stream=ReadBlobStream(image,length,pixels,&count);
798
0
            if (count != (ssize_t) length)
799
0
              break;
800
0
          }
801
0
          if (count != (ssize_t) length)
802
0
            break;
803
0
        }
804
0
        stream=ReadBlobStream(image,length,pixels,&count);
805
0
        for (y=0; y < (ssize_t) image->extract_info.height; y++)
806
0
        {
807
0
          const Quantum
808
0
            *magick_restrict p;
809
810
0
          Quantum
811
0
            *magick_restrict q;
812
813
0
          ssize_t
814
0
            x;
815
816
0
          if (count != (ssize_t) length)
817
0
            {
818
0
              status=MagickFalse;
819
0
              ThrowFileException(exception,CorruptImageError,
820
0
                "UnexpectedEndOfFile",image->filename);
821
0
              break;
822
0
            }
823
0
          q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1,
824
0
            exception);
825
0
          if (q == (Quantum *) NULL)
826
0
            break;
827
0
          length=ImportQuantumPixels(canvas_image,(CacheView *) NULL,
828
0
            quantum_info,BlueQuantum,(unsigned char *) stream,exception);
829
0
          if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
830
0
            break;
831
0
          if (((y-image->extract_info.y) >= 0) &&
832
0
              ((y-image->extract_info.y) < (ssize_t) image->rows))
833
0
            {
834
0
              p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
835
0
                canvas_image->columns,1,exception);
836
0
              q=GetAuthenticPixels(image,0,y-image->extract_info.y,
837
0
                image->columns,1,exception);
838
0
              if ((p == (const Quantum *) NULL) || (q == (Quantum *) NULL))
839
0
                break;
840
0
              for (x=0; x < columns; x++)
841
0
              {
842
0
                SetPixelBlue(image,GetPixelBlue(canvas_image,p),q);
843
0
                p+=(ptrdiff_t) GetPixelChannels(canvas_image);
844
0
                q+=(ptrdiff_t) GetPixelChannels(image);
845
0
              }
846
0
              if (SyncAuthenticPixels(image,exception) == MagickFalse)
847
0
                break;
848
0
           }
849
0
          stream=ReadBlobStream(image,length,pixels,&count);
850
0
        }
851
0
        if (image->previous == (Image *) NULL)
852
0
          {
853
0
            status=SetImageProgress(image,LoadImageTag,3,5);
854
0
            if (status == MagickFalse)
855
0
              break;
856
0
          }
857
0
        if (image->alpha_trait != UndefinedPixelTrait)
858
0
          {
859
0
            if (CloseBlob(image) == MagickFalse)
860
0
              break;
861
0
            AppendImageFormat("A",image->filename);
862
0
            status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
863
0
            if (status == MagickFalse)
864
0
              break;
865
0
            length=GetQuantumExtent(canvas_image,quantum_info,AlphaQuantum);
866
0
            for (i=0; i < (ssize_t) scene; i++)
867
0
            {
868
0
              for (y=0; y < (ssize_t) image->extract_info.height; y++)
869
0
              {
870
0
                stream=ReadBlobStream(image,length,pixels,&count);
871
0
                if (count != (ssize_t) length)
872
0
                  break;
873
0
              }
874
0
              if (count != (ssize_t) length)
875
0
                break;
876
0
            }
877
0
            stream=ReadBlobStream(image,length,pixels,&count);
878
0
            for (y=0; y < (ssize_t) image->extract_info.height; y++)
879
0
            {
880
0
              const Quantum
881
0
                *magick_restrict p;
882
883
0
              Quantum
884
0
                *magick_restrict q;
885
886
0
              ssize_t
887
0
                x;
888
889
0
              if (count != (ssize_t) length)
890
0
                {
891
0
                  status=MagickFalse;
892
0
                  ThrowFileException(exception,CorruptImageError,
893
0
                    "UnexpectedEndOfFile",image->filename);
894
0
                  break;
895
0
                }
896
0
              q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1,
897
0
                exception);
898
0
              if (q == (Quantum *) NULL)
899
0
                break;
900
0
              length=ImportQuantumPixels(canvas_image,(CacheView *) NULL,
901
0
                quantum_info,BlueQuantum,(unsigned char *) stream,exception);
902
0
              if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
903
0
                break;
904
0
              if (((y-image->extract_info.y) >= 0) &&
905
0
                  ((y-image->extract_info.y) < (ssize_t) image->rows))
906
0
                {
907
0
                  p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,
908
0
                    0,canvas_image->columns,1,exception);
909
0
                  q=GetAuthenticPixels(image,0,y-image->extract_info.y,
910
0
                    image->columns,1,exception);
911
0
                  if ((p == (const Quantum *) NULL) || (q == (Quantum *) NULL))
912
0
                    break;
913
0
                  for (x=0; x < columns; x++)
914
0
                  {
915
0
                    SetPixelAlpha(image,GetPixelAlpha(canvas_image,p),q);
916
0
                    p+=(ptrdiff_t) GetPixelChannels(canvas_image);
917
0
                    q+=(ptrdiff_t) GetPixelChannels(image);
918
0
                  }
919
0
                  if (SyncAuthenticPixels(image,exception) == MagickFalse)
920
0
                    break;
921
0
               }
922
0
              stream=ReadBlobStream(image,length,pixels,&count);
923
0
            }
924
0
            if (image->previous == (Image *) NULL)
925
0
              {
926
0
                status=SetImageProgress(image,LoadImageTag,4,5);
927
0
                if (status == MagickFalse)
928
0
                  break;
929
0
              }
930
0
          }
931
0
        if (image->previous == (Image *) NULL)
932
0
          {
933
0
            status=SetImageProgress(image,LoadImageTag,5,5);
934
0
            if (status == MagickFalse)
935
0
              break;
936
0
          }
937
0
        break;
938
0
      }
939
18
    }
940
18
    if (status == MagickFalse)
941
0
      break;
942
18
    SetQuantumImageType(image,quantum_type);
943
    /*
944
      Proceed to next image.
945
    */
946
18
    if (image_info->number_scenes != 0)
947
0
      if (image->scene >= (image_info->scene+image_info->number_scenes-1))
948
0
        break;
949
18
    if (count == (ssize_t) length)
950
15
      {
951
        /*
952
          Allocate next image structure.
953
        */
954
15
        AcquireNextImage(image_info,image,exception);
955
15
        if (GetNextImageInList(image) == (Image *) NULL)
956
0
          {
957
0
            status=MagickFalse;
958
0
            break;
959
0
          }
960
15
        image=SyncNextImageInList(image);
961
15
        status=SetImageProgress(image,LoadImagesTag,TellBlob(image),
962
15
          GetBlobSize(image));
963
15
        if (status == MagickFalse)
964
0
          break;
965
15
      }
966
18
    scene++;
967
18
  } while (count == (ssize_t) length);
968
4
  quantum_info=DestroyQuantumInfo(quantum_info);
969
4
  canvas_image=DestroyImage(canvas_image);
970
4
  if (CloseBlob(image) == MagickFalse)
971
0
    status=MagickFalse;
972
4
  if (status == MagickFalse)
973
1
    return(DestroyImageList(image));
974
3
  return(GetFirstImageInList(image));
975
4
}
976

977
/*
978
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
979
%                                                                             %
980
%                                                                             %
981
%                                                                             %
982
%   R e a d R G B 5 6 5 I m a g e                                             %
983
%                                                                             %
984
%                                                                             %
985
%                                                                             %
986
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
987
%
988
%  ReadRGB565Image() reads an image of raw RGB 5-6-5 samples and returns it.  It
989
%  allocates the memory necessary for the new Image structure and returns a
990
%  pointer to the new image.
991
%
992
%  The format of the ReadRGB565Image method is:
993
%
994
%      Image *ReadRGB565Image(const ImageInfo *image_info,
995
%        ExceptionInfo *exception)
996
%
997
%  A description of each parameter follows:
998
%
999
%    o image_info: the image info.
1000
%
1001
%    o exception: return any errors or warnings in this structure.
1002
%
1003
*/
1004
static Image *ReadRGB565Image(const ImageInfo *image_info,
1005
  ExceptionInfo *exception)
1006
27
{
1007
27
  const void
1008
27
    *stream;
1009
1010
27
  Image
1011
27
    *canvas_image,
1012
27
    *image;
1013
1014
27
  MagickBooleanType
1015
27
    status;
1016
1017
27
  MagickOffsetType
1018
27
    scene;
1019
1020
27
  QuantumInfo
1021
27
    *quantum_info;
1022
1023
27
  QuantumType
1024
27
    quantum_type;
1025
1026
27
  size_t
1027
27
    length;
1028
1029
27
  ssize_t
1030
27
    columns,
1031
27
    count,
1032
27
    y;
1033
1034
27
  unsigned char
1035
27
    *pixels;
1036
1037
  /*
1038
    Open image file.
1039
  */
1040
27
  assert(image_info != (const ImageInfo *) NULL);
1041
27
  assert(image_info->signature == MagickCoreSignature);
1042
27
  assert(exception != (ExceptionInfo *) NULL);
1043
27
  assert(exception->signature == MagickCoreSignature);
1044
27
  if (IsEventLogging() != MagickFalse)
1045
0
    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
1046
0
      image_info->filename);
1047
27
  image=AcquireImage(image_info,exception);
1048
27
  if ((image->columns == 0) || (image->rows == 0))
1049
27
    ThrowReaderException(OptionError,"MustSpecifyImageSize");
1050
0
  status=SetImageExtent(image,image->columns,image->rows,exception);
1051
0
  if (status == MagickFalse)
1052
0
    return(DestroyImageList(image));
1053
0
  image->depth=16;
1054
0
  if (image_info->interlace != PartitionInterlace)
1055
0
    {
1056
0
      status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
1057
0
      if (status == MagickFalse)
1058
0
        {
1059
0
          image=DestroyImageList(image);
1060
0
          return((Image *) NULL);
1061
0
        }
1062
0
      if (DiscardBlobBytes(image,(MagickSizeType) image->offset) == MagickFalse)
1063
0
        ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
1064
0
          image->filename);
1065
0
    }
1066
  /*
1067
    Create virtual canvas to support cropping (i.e. image.rgb[100x100+10+20]).
1068
  */
1069
0
  canvas_image=CloneImage(image,image->extract_info.width,1,MagickFalse,
1070
0
    exception);
1071
0
  if(canvas_image == (Image *) NULL)
1072
0
    ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
1073
0
  (void) SetImageVirtualPixelMethod(canvas_image,BlackVirtualPixelMethod,
1074
0
    exception);
1075
0
  quantum_info=AcquireQuantumInfo(image_info,canvas_image);
1076
0
  if (quantum_info == (QuantumInfo *) NULL)
1077
0
    {
1078
0
      canvas_image=DestroyImage(canvas_image);
1079
0
      ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
1080
0
    }
1081
0
  quantum_type=GrayQuantum;
1082
0
  pixels=GetQuantumPixels(quantum_info);
1083
0
  if (image_info->number_scenes != 0)
1084
0
    while (image->scene < image_info->scene)
1085
0
    {
1086
      /*
1087
        Skip to next image.
1088
      */
1089
0
      image->scene++;
1090
0
      length=GetQuantumExtent(canvas_image,quantum_info,quantum_type);
1091
0
      for (y=0; y < (ssize_t) image->rows; y++)
1092
0
      {
1093
0
        stream=ReadBlobStream(image,length,pixels,&count);
1094
0
        if (count != (ssize_t) length)
1095
0
          break;
1096
0
      }
1097
0
    }
1098
0
  count=0;
1099
0
  length=0;
1100
0
  scene=0;
1101
0
  status=MagickTrue;
1102
0
  stream=NULL;
1103
0
  columns=(ssize_t) MagickMin(image->columns,canvas_image->columns);
1104
0
  do
1105
0
  {
1106
    /*
1107
      Read pixels to virtual canvas image then push to image.
1108
    */
1109
0
    if ((image_info->ping != MagickFalse) && (image_info->number_scenes != 0))
1110
0
      if (image->scene >= (image_info->scene+image_info->number_scenes-1))
1111
0
        break;
1112
0
    status=SetImageExtent(image,image->columns,image->rows,exception);
1113
0
    if (status == MagickFalse)
1114
0
      break;
1115
    /*
1116
      No interlacing:  GGG...
1117
    */
1118
0
    if (scene == 0)
1119
0
      {
1120
0
        length=GetQuantumExtent(canvas_image,quantum_info,quantum_type);
1121
0
        stream=ReadBlobStream(image,length,pixels,&count);
1122
0
      }
1123
0
    for (y=0; y < (ssize_t) image->extract_info.height; y++)
1124
0
    {
1125
0
      const Quantum
1126
0
        *magick_restrict p;
1127
1128
0
      Quantum
1129
0
        *magick_restrict q;
1130
1131
0
      ssize_t
1132
0
        x;
1133
1134
0
      if (count != (ssize_t) length)
1135
0
        {
1136
0
          status=MagickFalse;
1137
0
          ThrowFileException(exception,CorruptImageError,
1138
0
            "UnexpectedEndOfFile",image->filename);
1139
0
          break;
1140
0
        }
1141
0
      q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1,exception);
1142
0
      if (q == (Quantum *) NULL)
1143
0
        break;
1144
0
      length=ImportQuantumPixels(canvas_image,(CacheView *) NULL,
1145
0
        quantum_info,quantum_type,(unsigned char *) stream,exception);
1146
0
      if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
1147
0
        break;
1148
0
      if (((y-image->extract_info.y) >= 0) &&
1149
0
          ((y-image->extract_info.y) < (ssize_t) image->rows))
1150
0
        {
1151
0
          p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
1152
0
            canvas_image->columns,1,exception);
1153
0
          q=QueueAuthenticPixels(image,0,y-image->extract_info.y,
1154
0
            image->columns,1,exception);
1155
0
          if ((p == (const Quantum *) NULL) || (q == (Quantum *) NULL))
1156
0
            break;
1157
0
          for (x=0; x < columns; x++)
1158
0
          {
1159
0
            unsigned short
1160
0
              pixel;
1161
1162
0
            pixel=(unsigned short) ScaleQuantumToShort(GetPixelGray(
1163
0
              canvas_image,p));
1164
0
            SetPixelRed(image,(Quantum) (((pixel >> 11) & 0x1f) << 11),q);
1165
0
            SetPixelGreen(image,(Quantum) (((pixel >> 5) & 0x3f) << 10),q);
1166
0
            SetPixelBlue(image,(Quantum) ((pixel & 0x1f) << 11),q);
1167
0
            p+=(ptrdiff_t) GetPixelChannels(canvas_image);
1168
0
            q+=(ptrdiff_t) GetPixelChannels(image);
1169
0
          }
1170
0
          if (SyncAuthenticPixels(image,exception) == MagickFalse)
1171
0
            break;
1172
0
        }
1173
0
      if (image->previous == (Image *) NULL)
1174
0
        {
1175
0
          status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,
1176
0
            image->rows);
1177
0
          if (status == MagickFalse)
1178
0
            break;
1179
0
        }
1180
0
      stream=ReadBlobStream(image,length,pixels,&count);
1181
0
    }
1182
0
    if (status == MagickFalse)
1183
0
      break;
1184
0
    SetQuantumImageType(image,quantum_type);
1185
    /*
1186
      Proceed to next image.
1187
    */
1188
0
    if (image_info->number_scenes != 0)
1189
0
      if (image->scene >= (image_info->scene+image_info->number_scenes-1))
1190
0
        break;
1191
0
    if (count == (ssize_t) length)
1192
0
      {
1193
        /*
1194
          Allocate next image structure.
1195
        */
1196
0
        AcquireNextImage(image_info,image,exception);
1197
0
        if (GetNextImageInList(image) == (Image *) NULL)
1198
0
          {
1199
0
            status=MagickFalse;
1200
0
            break;
1201
0
          }
1202
0
        image=SyncNextImageInList(image);
1203
0
        status=SetImageProgress(image,LoadImagesTag,TellBlob(image),
1204
0
          GetBlobSize(image));
1205
0
        if (status == MagickFalse)
1206
0
          break;
1207
0
      }
1208
0
    scene++;
1209
0
  } while (count == (ssize_t) length);
1210
0
  quantum_info=DestroyQuantumInfo(quantum_info);
1211
0
  canvas_image=DestroyImage(canvas_image);
1212
0
  if (CloseBlob(image) == MagickFalse)
1213
0
    status=MagickFalse;
1214
0
  if (status == MagickFalse)
1215
0
    return(DestroyImageList(image));
1216
0
  return(GetFirstImageInList(image));
1217
0
}
1218

1219
/*
1220
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1221
%                                                                             %
1222
%                                                                             %
1223
%                                                                             %
1224
%   R e g i s t e r R G B I m a g e                                           %
1225
%                                                                             %
1226
%                                                                             %
1227
%                                                                             %
1228
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1229
%
1230
%  RegisterRGBImage() adds attributes for the RGB image format to
1231
%  the list of supported formats.  The attributes include the image format
1232
%  tag, a method to read and/or write the format, whether the format
1233
%  supports the saving of more than one frame to the same file or blob,
1234
%  whether the format supports native in-memory I/O, and a brief
1235
%  description of the format.
1236
%
1237
%  The format of the RegisterRGBImage method is:
1238
%
1239
%      size_t RegisterRGBImage(void)
1240
%
1241
*/
1242
ModuleExport size_t RegisterRGBImage(void)
1243
12
{
1244
12
  MagickInfo
1245
12
    *entry;
1246
1247
12
  entry=AcquireMagickInfo("RGB","RGB",
1248
12
    "Raw red, green, and blue samples");
1249
12
  entry->decoder=(DecodeImageHandler *) ReadRGBImage;
1250
12
  entry->encoder=(EncodeImageHandler *) WriteRGBImage;
1251
12
  entry->flags|=CoderRawSupportFlag;
1252
12
  entry->flags|=CoderEndianSupportFlag;
1253
12
  (void) RegisterMagickInfo(entry);
1254
12
  entry=AcquireMagickInfo("RGB","RGBA",
1255
12
    "Raw red, green, blue, and alpha samples");
1256
12
  entry->decoder=(DecodeImageHandler *) ReadRGBImage;
1257
12
  entry->encoder=(EncodeImageHandler *) WriteRGBImage;
1258
12
  entry->flags|=CoderRawSupportFlag;
1259
12
  entry->flags|=CoderEndianSupportFlag;
1260
12
  (void) RegisterMagickInfo(entry);
1261
12
  entry=AcquireMagickInfo("RGB","RGBO",
1262
12
    "Raw red, green, blue, and opacity samples");
1263
12
  entry->decoder=(DecodeImageHandler *) ReadRGBImage;
1264
12
  entry->encoder=(EncodeImageHandler *) WriteRGBImage;
1265
12
  entry->flags|=CoderRawSupportFlag;
1266
12
  entry->flags|=CoderEndianSupportFlag;
1267
12
  (void) RegisterMagickInfo(entry);
1268
12
  entry=AcquireMagickInfo("RGB","RGB565",
1269
12
    "Raw red, green, blue samples in 565 format");
1270
12
  entry->decoder=(DecodeImageHandler *) ReadRGB565Image;
1271
12
  entry->flags|=CoderRawSupportFlag;
1272
12
  entry->flags|=CoderEndianSupportFlag;
1273
12
  (void) RegisterMagickInfo(entry);
1274
12
  return(MagickImageCoderSignature);
1275
12
}
1276

1277
/*
1278
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1279
%                                                                             %
1280
%                                                                             %
1281
%                                                                             %
1282
%   U n r e g i s t e r R G B I m a g e                                       %
1283
%                                                                             %
1284
%                                                                             %
1285
%                                                                             %
1286
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1287
%
1288
%  UnregisterRGBImage() removes format registrations made by the RGB module
1289
%  from the list of supported formats.
1290
%
1291
%  The format of the UnregisterRGBImage method is:
1292
%
1293
%      UnregisterRGBImage(void)
1294
%
1295
*/
1296
ModuleExport void UnregisterRGBImage(void)
1297
0
{
1298
0
  (void) UnregisterMagickInfo("RGBO");
1299
0
  (void) UnregisterMagickInfo("RGBA");
1300
0
  (void) UnregisterMagickInfo("RGB");
1301
0
}
1302

1303
/*
1304
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1305
%                                                                             %
1306
%                                                                             %
1307
%                                                                             %
1308
%   W r i t e R G B I m a g e                                                 %
1309
%                                                                             %
1310
%                                                                             %
1311
%                                                                             %
1312
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1313
%
1314
%  WriteRGBImage() writes an image to a file in the RGB, RGBA, or RGBO
1315
%  rasterfile format.
1316
%
1317
%  The format of the WriteRGBImage method is:
1318
%
1319
%      MagickBooleanType WriteRGBImage(const ImageInfo *image_info,
1320
%        Image *image,ExceptionInfo *exception)
1321
%
1322
%  A description of each parameter follows.
1323
%
1324
%    o image_info: the image info.
1325
%
1326
%    o image:  The image.
1327
%
1328
%    o exception: return any errors or warnings in this structure.
1329
%
1330
*/
1331
static MagickBooleanType WriteRGBImage(const ImageInfo *image_info,
1332
  Image *image,ExceptionInfo *exception)
1333
0
{
1334
0
  MagickBooleanType
1335
0
    status = MagickTrue;
1336
1337
0
  MagickOffsetType
1338
0
    scene;
1339
1340
0
  QuantumInfo
1341
0
    *quantum_info;
1342
1343
0
  QuantumType
1344
0
    quantum_type;
1345
1346
0
  size_t
1347
0
    length,
1348
0
    number_scenes;
1349
1350
0
  ssize_t
1351
0
    count,
1352
0
    y;
1353
1354
0
  unsigned char
1355
0
    *pixels;
1356
1357
  /*
1358
    Allocate memory for pixels.
1359
  */
1360
0
  assert(image_info != (const ImageInfo *) NULL);
1361
0
  assert(image_info->signature == MagickCoreSignature);
1362
0
  assert(image != (Image *) NULL);
1363
0
  assert(image->signature == MagickCoreSignature);
1364
0
  if (IsEventLogging() != MagickFalse)
1365
0
    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
1366
0
  if (image_info->interlace != PartitionInterlace)
1367
0
    {
1368
      /*
1369
        Open output image file.
1370
      */
1371
0
      status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception);
1372
0
      if (status == MagickFalse)
1373
0
        return(status);
1374
0
    }
1375
0
  quantum_type=RGBQuantum;
1376
0
  if (LocaleCompare(image_info->magick,"RGBA") == 0)
1377
0
    quantum_type=RGBAQuantum;
1378
0
  if (LocaleCompare(image_info->magick,"RGBO") == 0)
1379
0
    quantum_type=RGBOQuantum;
1380
0
  scene=0;
1381
0
  number_scenes=GetImageListLength(image);
1382
0
  do
1383
0
  {
1384
    /*
1385
      Convert MIFF to RGB raster pixels.
1386
    */
1387
0
    if (IssRGBCompatibleColorspace(image->colorspace) == MagickFalse)
1388
0
      (void) TransformImageColorspace(image,sRGBColorspace,exception);
1389
0
    if ((LocaleCompare(image_info->magick,"RGBA") == 0) &&
1390
0
        ((image->alpha_trait & BlendPixelTrait) == 0))
1391
0
      (void) SetImageAlphaChannel(image,OpaqueAlphaChannel,exception);
1392
0
    quantum_info=AcquireQuantumInfo(image_info,image);
1393
0
    if (quantum_info == (QuantumInfo *) NULL)
1394
0
      ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
1395
0
    pixels=(unsigned char *) GetQuantumPixels(quantum_info);
1396
0
    switch (image_info->interlace)
1397
0
    {
1398
0
      case NoInterlace:
1399
0
      default:
1400
0
      {
1401
        /*
1402
          No interlacing:  RGBRGBRGBRGBRGBRGB...
1403
        */
1404
0
        for (y=0; y < (ssize_t) image->rows; y++)
1405
0
        {
1406
0
          const Quantum
1407
0
            *magick_restrict p;
1408
1409
0
          p=GetVirtualPixels(image,0,y,image->columns,1,exception);
1410
0
          if (p == (const Quantum *) NULL)
1411
0
            break;
1412
0
          length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
1413
0
            quantum_type,pixels,exception);
1414
0
          count=WriteBlob(image,length,pixels);
1415
0
          if (count != (ssize_t) length)
1416
0
            break;
1417
0
          if (image->previous == (Image *) NULL)
1418
0
            {
1419
0
              status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
1420
0
                image->rows);
1421
0
              if (status == MagickFalse)
1422
0
                break;
1423
0
            }
1424
0
        }
1425
0
        break;
1426
0
      }
1427
0
      case LineInterlace:
1428
0
      {
1429
        /*
1430
          Line interlacing:  RRR...GGG...BBB...RRR...GGG...BBB...
1431
        */
1432
0
        for (y=0; y < (ssize_t) image->rows; y++)
1433
0
        {
1434
0
          const Quantum
1435
0
            *magick_restrict p;
1436
1437
0
          p=GetVirtualPixels(image,0,y,image->columns,1,exception);
1438
0
          if (p == (const Quantum *) NULL)
1439
0
            break;
1440
0
          length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
1441
0
            RedQuantum,pixels,exception);
1442
0
          count=WriteBlob(image,length,pixels);
1443
0
          if (count != (ssize_t) length)
1444
0
            break;
1445
0
          length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
1446
0
            GreenQuantum,pixels,exception);
1447
0
          count=WriteBlob(image,length,pixels);
1448
0
          if (count != (ssize_t) length)
1449
0
            break;
1450
0
          length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
1451
0
            BlueQuantum,pixels,exception);
1452
0
          count=WriteBlob(image,length,pixels);
1453
0
          if (count != (ssize_t) length)
1454
0
            break;
1455
0
          if (quantum_type == RGBAQuantum)
1456
0
            {
1457
0
              length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
1458
0
                AlphaQuantum,pixels,exception);
1459
0
              count=WriteBlob(image,length,pixels);
1460
0
              if (count != (ssize_t) length)
1461
0
                break;
1462
0
            }
1463
0
          if (quantum_type == RGBOQuantum)
1464
0
            {
1465
0
              length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
1466
0
                OpacityQuantum,pixels,exception);
1467
0
              count=WriteBlob(image,length,pixels);
1468
0
              if (count != (ssize_t) length)
1469
0
                break;
1470
0
            }
1471
0
          if (image->previous == (Image *) NULL)
1472
0
            {
1473
0
              status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
1474
0
                image->rows);
1475
0
              if (status == MagickFalse)
1476
0
                break;
1477
0
            }
1478
0
        }
1479
0
        break;
1480
0
      }
1481
0
      case PlaneInterlace:
1482
0
      {
1483
        /*
1484
          Plane interlacing:  RRRRRR...GGGGGG...BBBBBB...
1485
        */
1486
0
        for (y=0; y < (ssize_t) image->rows; y++)
1487
0
        {
1488
0
          const Quantum
1489
0
            *magick_restrict p;
1490
1491
0
          p=GetVirtualPixels(image,0,y,image->columns,1,exception);
1492
0
          if (p == (const Quantum *) NULL)
1493
0
            break;
1494
0
          length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
1495
0
            RedQuantum,pixels,exception);
1496
0
          count=WriteBlob(image,length,pixels);
1497
0
          if (count != (ssize_t) length)
1498
0
            break;
1499
0
        }
1500
0
        if (image->previous == (Image *) NULL)
1501
0
          {
1502
0
            status=SetImageProgress(image,SaveImageTag,1,6);
1503
0
            if (status == MagickFalse)
1504
0
              break;
1505
0
          }
1506
0
        for (y=0; y < (ssize_t) image->rows; y++)
1507
0
        {
1508
0
          const Quantum
1509
0
            *magick_restrict p;
1510
1511
0
          p=GetVirtualPixels(image,0,y,image->columns,1,exception);
1512
0
          if (p == (const Quantum *) NULL)
1513
0
            break;
1514
0
          length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
1515
0
            GreenQuantum,pixels,exception);
1516
0
          count=WriteBlob(image,length,pixels);
1517
0
          if (count != (ssize_t) length)
1518
0
            break;
1519
0
        }
1520
0
        if (image->previous == (Image *) NULL)
1521
0
          {
1522
0
            status=SetImageProgress(image,SaveImageTag,2,6);
1523
0
            if (status == MagickFalse)
1524
0
              break;
1525
0
          }
1526
0
        for (y=0; y < (ssize_t) image->rows; y++)
1527
0
        {
1528
0
          const Quantum
1529
0
            *magick_restrict p;
1530
1531
0
          p=GetVirtualPixels(image,0,y,image->columns,1,exception);
1532
0
          if (p == (const Quantum *) NULL)
1533
0
            break;
1534
0
          length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
1535
0
            BlueQuantum,pixels,exception);
1536
0
          count=WriteBlob(image,length,pixels);
1537
0
          if (count != (ssize_t) length)
1538
0
            break;
1539
0
        }
1540
0
        if (image->previous == (Image *) NULL)
1541
0
          {
1542
0
            status=SetImageProgress(image,SaveImageTag,3,6);
1543
0
            if (status == MagickFalse)
1544
0
              break;
1545
0
          }
1546
0
        if (quantum_type == RGBAQuantum)
1547
0
          {
1548
0
            for (y=0; y < (ssize_t) image->rows; y++)
1549
0
            {
1550
0
              const Quantum
1551
0
                *magick_restrict p;
1552
1553
0
              p=GetVirtualPixels(image,0,y,image->columns,1,exception);
1554
0
              if (p == (const Quantum *) NULL)
1555
0
                break;
1556
0
              length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
1557
0
                AlphaQuantum,pixels,exception);
1558
0
              count=WriteBlob(image,length,pixels);
1559
0
              if (count != (ssize_t) length)
1560
0
              break;
1561
0
            }
1562
0
            if (image->previous == (Image *) NULL)
1563
0
              {
1564
0
                status=SetImageProgress(image,SaveImageTag,5,6);
1565
0
                if (status == MagickFalse)
1566
0
                  break;
1567
0
              }
1568
0
          }
1569
0
        if (image_info->interlace == PartitionInterlace)
1570
0
          (void) CopyMagickString(image->filename,image_info->filename,
1571
0
            MagickPathExtent);
1572
0
        if (image->previous == (Image *) NULL)
1573
0
          {
1574
0
            status=SetImageProgress(image,SaveImageTag,6,6);
1575
0
            if (status == MagickFalse)
1576
0
              break;
1577
0
          }
1578
0
        break;
1579
0
      }
1580
0
      case PartitionInterlace:
1581
0
      {
1582
        /*
1583
          Partition interlacing:  RRRRRR..., GGGGGG..., BBBBBB...
1584
        */
1585
0
        AppendImageFormat("R",image->filename);
1586
0
        status=OpenBlob(image_info,image,scene == 0 ? WriteBinaryBlobMode :
1587
0
          AppendBinaryBlobMode,exception);
1588
0
        if (status == MagickFalse)
1589
0
          {
1590
0
            quantum_info=DestroyQuantumInfo(quantum_info);
1591
0
            return(status);
1592
0
          }
1593
0
        for (y=0; y < (ssize_t) image->rows; y++)
1594
0
        {
1595
0
          const Quantum
1596
0
            *magick_restrict p;
1597
1598
0
          p=GetVirtualPixels(image,0,y,image->columns,1,exception);
1599
0
          if (p == (const Quantum *) NULL)
1600
0
            break;
1601
0
          length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
1602
0
            RedQuantum,pixels,exception);
1603
0
          count=WriteBlob(image,length,pixels);
1604
0
          if (count != (ssize_t) length)
1605
0
            break;
1606
0
        }
1607
0
        if (image->previous == (Image *) NULL)
1608
0
          {
1609
0
            status=SetImageProgress(image,SaveImageTag,1,6);
1610
0
            if (status == MagickFalse)
1611
0
              break;
1612
0
          }
1613
0
        if (CloseBlob(image) == MagickFalse)
1614
0
          break;
1615
0
        AppendImageFormat("G",image->filename);
1616
0
        status=OpenBlob(image_info,image,scene == 0 ? WriteBinaryBlobMode :
1617
0
          AppendBinaryBlobMode,exception);
1618
0
        if (status == MagickFalse)
1619
0
          {
1620
0
            quantum_info=DestroyQuantumInfo(quantum_info);
1621
0
            return(status);
1622
0
          }
1623
0
        for (y=0; y < (ssize_t) image->rows; y++)
1624
0
        {
1625
0
          const Quantum
1626
0
            *magick_restrict p;
1627
1628
0
          p=GetVirtualPixels(image,0,y,image->columns,1,exception);
1629
0
          if (p == (const Quantum *) NULL)
1630
0
            break;
1631
0
          length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
1632
0
            GreenQuantum,pixels,exception);
1633
0
          count=WriteBlob(image,length,pixels);
1634
0
          if (count != (ssize_t) length)
1635
0
            break;
1636
0
        }
1637
0
        if (image->previous == (Image *) NULL)
1638
0
          {
1639
0
            status=SetImageProgress(image,SaveImageTag,2,6);
1640
0
            if (status == MagickFalse)
1641
0
              break;
1642
0
          }
1643
0
        if (CloseBlob(image) == MagickFalse)
1644
0
          break;
1645
0
        AppendImageFormat("B",image->filename);
1646
0
        status=OpenBlob(image_info,image,scene == 0 ? WriteBinaryBlobMode :
1647
0
          AppendBinaryBlobMode,exception);
1648
0
        if (status == MagickFalse)
1649
0
          {
1650
0
            quantum_info=DestroyQuantumInfo(quantum_info);
1651
0
            return(status);
1652
0
          }
1653
0
        for (y=0; y < (ssize_t) image->rows; y++)
1654
0
        {
1655
0
          const Quantum
1656
0
            *magick_restrict p;
1657
1658
0
          p=GetVirtualPixels(image,0,y,image->columns,1,exception);
1659
0
          if (p == (const Quantum *) NULL)
1660
0
            break;
1661
0
          length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
1662
0
            BlueQuantum,pixels,exception);
1663
0
          count=WriteBlob(image,length,pixels);
1664
0
          if (count != (ssize_t) length)
1665
0
            break;
1666
0
        }
1667
0
        if (image->previous == (Image *) NULL)
1668
0
          {
1669
0
            status=SetImageProgress(image,SaveImageTag,3,6);
1670
0
            if (status == MagickFalse)
1671
0
              break;
1672
0
          }
1673
0
        if (quantum_type == RGBAQuantum)
1674
0
          {
1675
0
            if (CloseBlob(image) == MagickFalse)
1676
0
              break;
1677
0
            AppendImageFormat("A",image->filename);
1678
0
            status=OpenBlob(image_info,image,scene == 0 ? WriteBinaryBlobMode :
1679
0
              AppendBinaryBlobMode,exception);
1680
0
            if (status == MagickFalse)
1681
0
              {
1682
0
                quantum_info=DestroyQuantumInfo(quantum_info);
1683
0
                return(status);
1684
0
              }
1685
0
            for (y=0; y < (ssize_t) image->rows; y++)
1686
0
            {
1687
0
              const Quantum
1688
0
                *magick_restrict p;
1689
1690
0
              p=GetVirtualPixels(image,0,y,image->columns,1,exception);
1691
0
              if (p == (const Quantum *) NULL)
1692
0
                break;
1693
0
              length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
1694
0
                AlphaQuantum,pixels,exception);
1695
0
              count=WriteBlob(image,length,pixels);
1696
0
              if (count != (ssize_t) length)
1697
0
                break;
1698
0
            }
1699
0
            if (image->previous == (Image *) NULL)
1700
0
              {
1701
0
                status=SetImageProgress(image,SaveImageTag,5,6);
1702
0
                if (status == MagickFalse)
1703
0
                  break;
1704
0
              }
1705
0
          }
1706
0
        (void) CloseBlob(image);
1707
0
        (void) CopyMagickString(image->filename,image_info->filename,
1708
0
          MagickPathExtent);
1709
0
        if (image->previous == (Image *) NULL)
1710
0
          {
1711
0
            status=SetImageProgress(image,SaveImageTag,6,6);
1712
0
            if (status == MagickFalse)
1713
0
              break;
1714
0
          }
1715
0
        break;
1716
0
      }
1717
0
    }
1718
0
    quantum_info=DestroyQuantumInfo(quantum_info);
1719
0
    if (GetNextImageInList(image) == (Image *) NULL)
1720
0
      break;
1721
0
    image=SyncNextImageInList(image);
1722
0
    status=SetImageProgress(image,SaveImagesTag,scene++,number_scenes);
1723
0
    if (status == MagickFalse)
1724
0
      break;
1725
0
  } while (image_info->adjoin != MagickFalse);
1726
0
  if (CloseBlob(image) == MagickFalse)
1727
0
    status=MagickFalse;
1728
0
  return(status);
1729
0
}