]> granicus.if.org Git - imagemagick/blob - coders/ycbcr.c
(no commit message)
[imagemagick] / coders / ycbcr.c
1 /*
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %                                                                             %
4 %                                                                             %
5 %                                                                             %
6 %                     Y   Y   YYYC  BBBB    YYYC  RRRR                        %
7 %                      Y Y   C      B   B  C      R   R                       %
8 %                       Y    C      BBBB   C      RRRR                        %
9 %                       Y    C      B   B  C      R  R                        %
10 %                       Y     YYYC  BBBB    YYYC  R   R                       %
11 %                                                                             %
12 %                                                                             %
13 %                     Read/Write Raw YCbCr Image Format                       %
14 %                                                                             %
15 %                              Software Design                                %
16 %                                John Cristy                                  %
17 %                                 July 1992                                   %
18 %                                                                             %
19 %                                                                             %
20 %  Copyright 1999-2011 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 \f
39 /*
40   Include declarations.
41 */
42 #include "magick/studio.h"
43 #include "magick/blob.h"
44 #include "magick/blob-private.h"
45 #include "magick/cache.h"
46 #include "magick/colorspace.h"
47 #include "magick/constitute.h"
48 #include "magick/exception.h"
49 #include "magick/exception-private.h"
50 #include "magick/image.h"
51 #include "magick/image-private.h"
52 #include "magick/list.h"
53 #include "magick/magick.h"
54 #include "magick/memory_.h"
55 #include "magick/monitor.h"
56 #include "magick/monitor-private.h"
57 #include "magick/pixel-private.h"
58 #include "magick/quantum-private.h"
59 #include "magick/static.h"
60 #include "magick/statistic.h"
61 #include "magick/string_.h"
62 #include "magick/module.h"
63 #include "magick/utility.h"
64 \f
65 /*
66   Forward declarations.
67 */
68 static MagickBooleanType
69   WriteYCBCRImage(const ImageInfo *,Image *);
70 \f
71 /*
72 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
73 %                                                                             %
74 %                                                                             %
75 %                                                                             %
76 %   R e a d Y C b C r I m a g e                                               %
77 %                                                                             %
78 %                                                                             %
79 %                                                                             %
80 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
81 %
82 %  ReadYCBCRImage() reads an image of raw YCbCr or YCbCrA samples and returns
83 %  it. It allocates the memory necessary for the new Image structure and
84 %  returns a pointer to the new image.
85 %
86 %  The format of the ReadYCBCRImage method is:
87 %
88 %      Image *ReadYCBCRImage(const ImageInfo *image_info,
89 %        ExceptionInfo *exception)
90 %
91 %  A description of each parameter follows:
92 %
93 %    o image_info: the image info.
94 %
95 %    o exception: return any errors or warnings in this structure.
96 %
97 */
98 static Image *ReadYCBCRImage(const ImageInfo *image_info,
99   ExceptionInfo *exception)
100 {
101   Image
102     *canvas_image,
103     *image;
104
105   ssize_t
106     y;
107
108   MagickBooleanType
109     status;
110
111   MagickOffsetType
112     scene;
113
114   QuantumInfo
115     *quantum_info;
116
117   QuantumType
118     quantum_type;
119
120   register const PixelPacket
121     *p;
122
123   register ssize_t
124     i,
125     x;
126
127   register PixelPacket
128     *q;
129
130   ssize_t
131     count;
132
133   size_t
134     length;
135
136   unsigned char
137     *pixels;
138
139   /*
140     Open image file.
141   */
142   assert(image_info != (const ImageInfo *) NULL);
143   assert(image_info->signature == MagickSignature);
144   if (image_info->debug != MagickFalse)
145     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
146       image_info->filename);
147   assert(exception != (ExceptionInfo *) NULL);
148   assert(exception->signature == MagickSignature);
149   image=AcquireImage(image_info);
150   if ((image->columns == 0) || (image->rows == 0))
151     ThrowReaderException(OptionError,"MustSpecifyImageSize");
152   image->colorspace=YCbCrColorspace;
153   if (image_info->interlace != PartitionInterlace)
154     {
155       status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
156       if (status == MagickFalse)
157         {
158           image=DestroyImageList(image);
159           return((Image *) NULL);
160         }
161       if (DiscardBlobBytes(image,image->offset) == MagickFalse)
162         ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
163           image->filename);
164     }
165   /*
166     Create virtual canvas to support cropping (i.e. image.rgb[100x100+10+20]).
167   */
168   canvas_image=CloneImage(image,image->extract_info.width,1,MagickFalse,
169     exception);
170   (void) SetImageVirtualPixelMethod(canvas_image,BlackVirtualPixelMethod);
171   quantum_info=AcquireQuantumInfo(image_info,canvas_image);
172   if (quantum_info == (QuantumInfo *) NULL)
173     ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
174   pixels=GetQuantumPixels(quantum_info);
175   quantum_type=RGBQuantum;
176   if (LocaleCompare(image_info->magick,"YCbCrA") == 0)
177     {
178       quantum_type=RGBAQuantum;
179       image->matte=MagickTrue;
180     }
181   if (image_info->number_scenes != 0)
182     while (image->scene < image_info->scene)
183     {
184       /*
185         Skip to next image.
186       */
187       image->scene++;
188       length=GetQuantumExtent(canvas_image,quantum_info,quantum_type);
189       for (y=0; y < (ssize_t) image->rows; y++)
190       {
191         count=ReadBlob(image,length,pixels);
192         if (count != (ssize_t) length)
193           break;
194       }
195     }
196   count=0;
197   length=0;
198   scene=0;
199   do
200   {
201     /*
202       Read pixels to virtual canvas image then push to image.
203     */
204     if ((image_info->ping != MagickFalse) && (image_info->number_scenes != 0))
205       if (image->scene >= (image_info->scene+image_info->number_scenes-1))
206         break;
207     image->colorspace=YCbCrColorspace;
208     switch (image_info->interlace)
209     {
210       case NoInterlace:
211       default:
212       {
213         /*
214           No interlacing:  YCbCrYCbCrYCbCrYCbCrYCbCrYCbCr...
215         */
216         if (scene == 0)
217           {
218             length=GetQuantumExtent(canvas_image,quantum_info,quantum_type);
219             count=ReadBlob(image,length,pixels);
220           }
221         for (y=0; y < (ssize_t) image->extract_info.height; y++)
222         {
223           if (count != (ssize_t) length)
224             {
225               ThrowFileException(exception,CorruptImageError,
226                 "UnexpectedEndOfFile",image->filename);
227               break;
228             }
229           q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1,
230             exception);
231           if (q == (PixelPacket *) NULL)
232             break;
233           length=ImportQuantumPixels(canvas_image,(CacheView *) NULL,
234             quantum_info,quantum_type,pixels,exception);
235           if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
236             break;
237           if (((y-image->extract_info.y) >= 0) && 
238               ((y-image->extract_info.y) < (ssize_t) image->rows))
239             {
240               p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
241                 canvas_image->columns,1,exception);
242               q=QueueAuthenticPixels(image,0,y-image->extract_info.y,
243                 image->columns,1,exception);
244               if ((p == (const PixelPacket *) NULL) ||
245                   (q == (PixelPacket *) NULL))
246                 break;
247               for (x=0; x < (ssize_t) image->columns; x++)
248               {
249                 SetRedPixelComponent(q,GetRedPixelComponent(p));
250                 SetGreenPixelComponent(q,GetGreenPixelComponent(p));
251                 SetBluePixelComponent(q,GetBluePixelComponent(p));
252                 if (image->matte != MagickFalse)
253                   SetOpacityPixelComponent(q,GetOpacityPixelComponent(p));
254                 p++;
255                 q++;
256               }
257               if (SyncAuthenticPixels(image,exception) == MagickFalse)
258                 break;
259             }
260           if (image->previous == (Image *) NULL)
261             {
262               status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,
263                 image->rows);
264               if (status == MagickFalse)
265                 break;
266             }
267           count=ReadBlob(image,length,pixels);
268         }
269         break;
270       }
271       case LineInterlace:
272       {
273         static QuantumType
274           quantum_types[4] =
275           {
276             RedQuantum,
277             GreenQuantum,
278             BlueQuantum,
279             OpacityQuantum
280           };
281
282         /*
283           Line interlacing:  YYY...CbCbCb...CrCrCr...YYY...CbCbCb...CrCrCr...
284         */
285         if (scene == 0)
286           {
287             length=GetQuantumExtent(canvas_image,quantum_info,RedQuantum);
288             count=ReadBlob(image,length,pixels);
289           }
290         for (y=0; y < (ssize_t) image->extract_info.height; y++)
291         {
292           for (i=0; i < (image->matte != MagickFalse ? 4 : 3); i++)
293           {
294             if (count != (ssize_t) length)
295               {
296                 ThrowFileException(exception,CorruptImageError,
297                   "UnexpectedEndOfFile",image->filename);
298                 break;
299               }
300             quantum_type=quantum_types[i];
301             q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1,
302               exception);
303             if (q == (PixelPacket *) NULL)
304               break;
305             length=ImportQuantumPixels(canvas_image,(CacheView *) NULL,
306               quantum_info,quantum_type,pixels,exception);
307             if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
308               break;
309             if (((y-image->extract_info.y) >= 0) && 
310                 ((y-image->extract_info.y) < (ssize_t) image->rows))
311               {
312                 p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,
313                   0,canvas_image->columns,1,exception);
314                 q=GetAuthenticPixels(image,0,y-image->extract_info.y,
315                   image->columns,1,exception);
316                 if ((p == (const PixelPacket *) NULL) ||
317                     (q == (PixelPacket *) NULL))
318                   break;
319                 for (x=0; x < (ssize_t) image->columns; x++)
320                 {
321                   switch (quantum_type)
322                   {
323                     case RedQuantum:
324                     {
325                       SetRedPixelComponent(q,GetRedPixelComponent(p));
326                       break;
327                     }
328                     case GreenQuantum:
329                     {
330                       SetGreenPixelComponent(q,GetGreenPixelComponent(p));
331                       break;
332                     }
333                     case BlueQuantum:
334                     {
335                       SetBluePixelComponent(q,GetBluePixelComponent(p));
336                       break;
337                     }
338                     case OpacityQuantum:
339                     {
340                       SetOpacityPixelComponent(q,GetOpacityPixelComponent(p));
341                       break;
342                     }
343                     default:
344                       break;
345                   }
346                   p++;
347                   q++;
348                 }
349                 if (SyncAuthenticPixels(image,exception) == MagickFalse)
350                   break;
351               }
352             count=ReadBlob(image,length,pixels);
353           }
354           if (image->previous == (Image *) NULL)
355             {
356               status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,
357                 image->rows);
358               if (status == MagickFalse)
359                 break;
360             }
361         }
362         break;
363       }
364       case PlaneInterlace:
365       {
366         /*
367           Plane interlacing:  YYYYYY...CbCbCbCbCbCb...CrCrCrCrCrCr...
368         */
369         if (scene == 0)
370           {
371             length=GetQuantumExtent(canvas_image,quantum_info,RedQuantum);
372             count=ReadBlob(image,length,pixels);
373           }
374         for (y=0; y < (ssize_t) image->extract_info.height; y++)
375         {
376           if (count != (ssize_t) length)
377             {
378               ThrowFileException(exception,CorruptImageError,
379                 "UnexpectedEndOfFile",image->filename);
380               break;
381             }
382           q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1,
383             exception);
384           if (q == (PixelPacket *) NULL)
385             break;
386           length=ImportQuantumPixels(canvas_image,(CacheView *) NULL,
387             quantum_info,RedQuantum,pixels,exception);
388           if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
389             break;
390           if (((y-image->extract_info.y) >= 0) && 
391               ((y-image->extract_info.y) < (ssize_t) image->rows))
392             {
393               p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
394                 canvas_image->columns,1,exception);
395               q=GetAuthenticPixels(image,0,y-image->extract_info.y,
396                 image->columns,1,exception);
397               if ((p == (const PixelPacket *) NULL) ||
398                   (q == (PixelPacket *) NULL))
399                 break;
400               for (x=0; x < (ssize_t) image->columns; x++)
401               {
402                 SetRedPixelComponent(q,GetRedPixelComponent(p));
403                 p++;
404                 q++;
405               }
406               if (SyncAuthenticPixels(image,exception) == MagickFalse)
407                 break;
408             }
409           count=ReadBlob(image,length,pixels);
410         }
411         if (image->previous == (Image *) NULL)
412           {
413             status=SetImageProgress(image,LoadImageTag,1,5);
414             if (status == MagickFalse)
415               break;
416           }
417         for (y=0; y < (ssize_t) image->extract_info.height; y++)
418         {
419           if (count != (ssize_t) length)
420             {
421               ThrowFileException(exception,CorruptImageError,
422                 "UnexpectedEndOfFile",image->filename);
423               break;
424             }
425           q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1,
426             exception);
427           if (q == (PixelPacket *) NULL)
428             break;
429           length=ImportQuantumPixels(canvas_image,(CacheView *) NULL,
430             quantum_info,GreenQuantum,pixels,exception);
431           if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
432             break;
433           if (((y-image->extract_info.y) >= 0) && 
434               ((y-image->extract_info.y) < (ssize_t) image->rows))
435             {
436               p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
437                 canvas_image->columns,1,exception);
438               q=GetAuthenticPixels(image,0,y-image->extract_info.y,
439                 image->columns,1,exception);
440               if ((p == (const PixelPacket *) NULL) ||
441                   (q == (PixelPacket *) NULL))
442                 break;
443               for (x=0; x < (ssize_t) image->columns; x++)
444               {
445                 SetGreenPixelComponent(q,GetGreenPixelComponent(p));
446                 p++;
447                 q++;
448               }
449               if (SyncAuthenticPixels(image,exception) == MagickFalse)
450                 break;
451            }
452           count=ReadBlob(image,length,pixels);
453         }
454         if (image->previous == (Image *) NULL)
455           {
456             status=SetImageProgress(image,LoadImageTag,2,5);
457             if (status == MagickFalse)
458               break;
459           }
460         for (y=0; y < (ssize_t) image->extract_info.height; y++)
461         {
462           if (count != (ssize_t) length)
463             {
464               ThrowFileException(exception,CorruptImageError,
465                 "UnexpectedEndOfFile",image->filename);
466               break;
467             }
468           q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1,
469             exception);
470           if (q == (PixelPacket *) NULL)
471             break;
472           length=ImportQuantumPixels(canvas_image,(CacheView *) NULL,
473             quantum_info,BlueQuantum,pixels,exception);
474           if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
475             break;
476           if (((y-image->extract_info.y) >= 0) && 
477               ((y-image->extract_info.y) < (ssize_t) image->rows))
478             {
479               p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
480                 canvas_image->columns,1,exception);
481               q=GetAuthenticPixels(image,0,y-image->extract_info.y,
482                 image->columns,1,exception);
483               if ((p == (const PixelPacket *) NULL) ||
484                   (q == (PixelPacket *) NULL))
485                 break;
486               for (x=0; x < (ssize_t) image->columns; x++)
487               {
488                 SetBluePixelComponent(q,GetBluePixelComponent(p));
489                 p++;
490                 q++;
491               }
492               if (SyncAuthenticPixels(image,exception) == MagickFalse)
493                 break;
494             }
495           count=ReadBlob(image,length,pixels);
496         }
497         if (image->previous == (Image *) NULL)
498           {
499             status=SetImageProgress(image,LoadImageTag,3,5);
500             if (status == MagickFalse)
501               break;
502           }
503         if (image->matte != MagickFalse)
504           {
505             for (y=0; y < (ssize_t) image->extract_info.height; y++)
506             {
507               if (count != (ssize_t) length)
508                 {
509                   ThrowFileException(exception,CorruptImageError,
510                     "UnexpectedEndOfFile",image->filename);
511                   break;
512                 }
513               q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1,
514                 exception);
515               if (q == (PixelPacket *) NULL)
516                 break;
517               length=ImportQuantumPixels(canvas_image,(CacheView *) NULL,
518                 quantum_info,AlphaQuantum,pixels,exception);
519               if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
520                 break;
521               if (((y-image->extract_info.y) >= 0) && 
522                   ((y-image->extract_info.y) < (ssize_t) image->rows))
523                 {
524                   p=GetVirtualPixels(canvas_image,
525                     canvas_image->extract_info.x,0,canvas_image->columns,1,
526                     exception);
527                   q=GetAuthenticPixels(image,0,y-image->extract_info.y,
528                     image->columns,1,exception);
529                   if ((p == (const PixelPacket *) NULL) ||
530                       (q == (PixelPacket *) NULL))
531                     break;
532                   for (x=0; x < (ssize_t) image->columns; x++)
533                   {
534                     SetOpacityPixelComponent(q,GetOpacityPixelComponent(p));
535                     p++;
536                     q++;
537                   }
538                   if (SyncAuthenticPixels(image,exception) == MagickFalse)
539                     break;
540                 }
541               count=ReadBlob(image,length,pixels);
542             }
543             if (image->previous == (Image *) NULL)
544               {
545                 status=SetImageProgress(image,LoadImageTag,4,5);
546                 if (status == MagickFalse)
547                   break;
548               }
549           }
550         if (image->previous == (Image *) NULL)
551           {
552             status=SetImageProgress(image,LoadImageTag,5,5);
553             if (status == MagickFalse)
554               break;
555           }
556         break;
557       }
558       case PartitionInterlace:
559       {
560         /*
561           Partition interlacing:  YYYYYY..., CbCbCbCbCbCb..., CrCrCrCrCrCr...
562         */
563         AppendImageFormat("Y",image->filename);
564         status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
565         if (status == MagickFalse)
566           {
567             canvas_image=DestroyImageList(canvas_image);
568             image=DestroyImageList(image);
569             return((Image *) NULL);
570           }
571         if (DiscardBlobBytes(image,image->offset) == MagickFalse)
572           ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
573             image->filename);
574         length=GetQuantumExtent(canvas_image,quantum_info,RedQuantum);
575         for (i=0; i < (ssize_t) scene; i++)
576           for (y=0; y < (ssize_t) image->extract_info.height; y++)
577             if (ReadBlob(image,length,pixels) != (ssize_t) length)
578               {
579                 ThrowFileException(exception,CorruptImageError,
580                   "UnexpectedEndOfFile",image->filename);
581                 break;
582               }
583         count=ReadBlob(image,length,pixels);
584         for (y=0; y < (ssize_t) image->extract_info.height; y++)
585         {
586           if (count != (ssize_t) length)
587             {
588               ThrowFileException(exception,CorruptImageError,
589                 "UnexpectedEndOfFile",image->filename);
590               break;
591             }
592           q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1,
593             exception);
594           if (q == (PixelPacket *) NULL)
595             break;
596           length=ImportQuantumPixels(canvas_image,(CacheView *) NULL,
597             quantum_info,RedQuantum,pixels,exception);
598           if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
599             break;
600           if (((y-image->extract_info.y) >= 0) && 
601               ((y-image->extract_info.y) < (ssize_t) image->rows))
602             {
603               p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
604                 canvas_image->columns,1,exception);
605               q=GetAuthenticPixels(image,0,y-image->extract_info.y,
606                 image->columns,1,exception);
607               if ((p == (const PixelPacket *) NULL) ||
608                   (q == (PixelPacket *) NULL))
609                 break;
610               for (x=0; x < (ssize_t) image->columns; x++)
611               {
612                 SetRedPixelComponent(q,GetRedPixelComponent(p));
613                 p++;
614                 q++;
615               }
616               if (SyncAuthenticPixels(image,exception) == MagickFalse)
617                 break;
618             }
619           count=ReadBlob(image,length,pixels);
620         }
621         if (image->previous == (Image *) NULL)
622           {
623             status=SetImageProgress(image,LoadImageTag,1,5);
624             if (status == MagickFalse)
625               break;
626           }
627         (void) CloseBlob(image);
628         AppendImageFormat("Cb",image->filename);
629         status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
630         if (status == MagickFalse)
631           {
632             canvas_image=DestroyImageList(canvas_image);
633             image=DestroyImageList(image);
634             return((Image *) NULL);
635           }
636         length=GetQuantumExtent(canvas_image,quantum_info,GreenQuantum);
637         for (i=0; i < (ssize_t) scene; i++)
638           for (y=0; y < (ssize_t) image->extract_info.height; y++)
639             if (ReadBlob(image,length,pixels) != (ssize_t) length)
640               {
641                 ThrowFileException(exception,CorruptImageError,
642                   "UnexpectedEndOfFile",image->filename);
643                 break;
644               }
645         count=ReadBlob(image,length,pixels);
646         for (y=0; y < (ssize_t) image->extract_info.height; y++)
647         {
648           if (count != (ssize_t) length)
649             {
650               ThrowFileException(exception,CorruptImageError,
651                 "UnexpectedEndOfFile",image->filename);
652               break;
653             }
654           q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1,
655             exception);
656           if (q == (PixelPacket *) NULL)
657             break;
658           length=ImportQuantumPixels(canvas_image,(CacheView *) NULL,
659             quantum_info,GreenQuantum,pixels,exception);
660           if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
661             break;
662           if (((y-image->extract_info.y) >= 0) && 
663               ((y-image->extract_info.y) < (ssize_t) image->rows))
664             {
665               p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
666                 canvas_image->columns,1,exception);
667               q=GetAuthenticPixels(image,0,y-image->extract_info.y,
668                 image->columns,1,exception);
669               if ((p == (const PixelPacket *) NULL) ||
670                   (q == (PixelPacket *) NULL))
671                 break;
672               for (x=0; x < (ssize_t) image->columns; x++)
673               {
674                 SetGreenPixelComponent(q,GetGreenPixelComponent(p));
675                 p++;
676                 q++;
677               }
678               if (SyncAuthenticPixels(image,exception) == MagickFalse)
679                 break;
680            }
681           count=ReadBlob(image,length,pixels);
682         }
683         if (image->previous == (Image *) NULL)
684           {
685             status=SetImageProgress(image,LoadImageTag,2,5);
686             if (status == MagickFalse)
687               break;
688           }
689         (void) CloseBlob(image);
690         AppendImageFormat("Cr",image->filename);
691         status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
692         if (status == MagickFalse)
693           {
694             canvas_image=DestroyImageList(canvas_image);
695             image=DestroyImageList(image);
696             return((Image *) NULL);
697           }
698         length=GetQuantumExtent(canvas_image,quantum_info,BlueQuantum);
699         for (i=0; i < (ssize_t) scene; i++)
700           for (y=0; y < (ssize_t) image->extract_info.height; y++)
701             if (ReadBlob(image,length,pixels) != (ssize_t) length)
702               {
703                 ThrowFileException(exception,CorruptImageError,
704                   "UnexpectedEndOfFile",image->filename);
705                 break;
706               }
707         count=ReadBlob(image,length,pixels);
708         for (y=0; y < (ssize_t) image->extract_info.height; y++)
709         {
710           if (count != (ssize_t) length)
711             {
712               ThrowFileException(exception,CorruptImageError,
713                 "UnexpectedEndOfFile",image->filename);
714               break;
715             }
716           q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1,
717             exception);
718           if (q == (PixelPacket *) NULL)
719             break;
720           length=ImportQuantumPixels(canvas_image,(CacheView *) NULL,
721             quantum_info,BlueQuantum,pixels,exception);
722           if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
723             break;
724           if (((y-image->extract_info.y) >= 0) && 
725               ((y-image->extract_info.y) < (ssize_t) image->rows))
726             {
727               p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
728                 canvas_image->columns,1,exception);
729               q=GetAuthenticPixels(image,0,y-image->extract_info.y,
730                 image->columns,1,exception);
731               if ((p == (const PixelPacket *) NULL) ||
732                   (q == (PixelPacket *) NULL))
733                 break;
734               for (x=0; x < (ssize_t) image->columns; x++)
735               {
736                 SetBluePixelComponent(q,GetBluePixelComponent(p));
737                 p++;
738                 q++;
739               }
740               if (SyncAuthenticPixels(image,exception) == MagickFalse)
741                 break;
742            }
743           count=ReadBlob(image,length,pixels);
744         }
745         if (image->previous == (Image *) NULL)
746           {
747             status=SetImageProgress(image,LoadImageTag,3,5);
748             if (status == MagickFalse)
749               break;
750           }
751         if (image->matte != MagickFalse)
752           {
753             (void) CloseBlob(image);
754             AppendImageFormat("A",image->filename);
755             status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
756             if (status == MagickFalse)
757               {
758                 canvas_image=DestroyImageList(canvas_image);
759                 image=DestroyImageList(image);
760                 return((Image *) NULL);
761               }
762             length=GetQuantumExtent(canvas_image,quantum_info,AlphaQuantum);
763             for (i=0; i < (ssize_t) scene; i++)
764               for (y=0; y < (ssize_t) image->extract_info.height; y++)
765                 if (ReadBlob(image,length,pixels) != (ssize_t) length)
766                   {
767                     ThrowFileException(exception,CorruptImageError,
768                       "UnexpectedEndOfFile",image->filename);
769                     break;
770                   }
771             count=ReadBlob(image,length,pixels);
772             for (y=0; y < (ssize_t) image->extract_info.height; y++)
773             {
774               if (count != (ssize_t) length)
775                 {
776                   ThrowFileException(exception,CorruptImageError,
777                     "UnexpectedEndOfFile",image->filename);
778                   break;
779                 }
780               q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1,
781                 exception);
782               if (q == (PixelPacket *) NULL)
783                 break;
784               length=ImportQuantumPixels(canvas_image,(CacheView *) NULL,
785                 quantum_info,BlueQuantum,pixels,exception);
786               if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
787                 break;
788               if (((y-image->extract_info.y) >= 0) && 
789                   ((y-image->extract_info.y) < (ssize_t) image->rows))
790                 {
791                   p=GetVirtualPixels(canvas_image,
792                     canvas_image->extract_info.x,0,canvas_image->columns,1,
793                     exception);
794                   q=GetAuthenticPixels(image,0,y-image->extract_info.y,
795                     image->columns,1,exception);
796                   if ((p == (const PixelPacket *) NULL) ||
797                       (q == (PixelPacket *) NULL))
798                     break;
799                   for (x=0; x < (ssize_t) image->columns; x++)
800                   {
801                     SetOpacityPixelComponent(q,GetOpacityPixelComponent(p));
802                     p++;
803                     q++;
804                   }
805                   if (SyncAuthenticPixels(image,exception) == MagickFalse)
806                     break;
807                }
808               count=ReadBlob(image,length,pixels);
809             }
810             if (image->previous == (Image *) NULL)
811               {
812                 status=SetImageProgress(image,LoadImageTag,4,5);
813                 if (status == MagickFalse)
814                   break;
815               }
816           }
817         if (image->previous == (Image *) NULL)
818           {
819             status=SetImageProgress(image,LoadImageTag,5,5);
820             if (status == MagickFalse)
821               break;
822           }
823         break;
824       }
825     }
826     SetQuantumImageType(image,quantum_type);
827     /*
828       Proceed to next image.
829     */
830     if (image_info->number_scenes != 0)
831       if (image->scene >= (image_info->scene+image_info->number_scenes-1))
832         break;
833     if (count == (ssize_t) length)
834       {
835         /*
836           Allocate next image structure.
837         */
838         AcquireNextImage(image_info,image);
839         if (GetNextImageInList(image) == (Image *) NULL)
840           {
841             image=DestroyImageList(image);
842             return((Image *) NULL);
843           }
844         image=SyncNextImageInList(image);
845         status=SetImageProgress(image,LoadImagesTag,TellBlob(image),
846           GetBlobSize(image));
847         if (status == MagickFalse)
848           break;
849       }
850     scene++;
851   } while (count == (ssize_t) length);
852   quantum_info=DestroyQuantumInfo(quantum_info);
853   InheritException(&image->exception,&canvas_image->exception);
854   canvas_image=DestroyImage(canvas_image);
855   (void) CloseBlob(image);
856   return(GetFirstImageInList(image));
857 }
858 \f
859 /*
860 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
861 %                                                                             %
862 %                                                                             %
863 %                                                                             %
864 %   R e g i s t e r Y C b C r I m a g e                                       %
865 %                                                                             %
866 %                                                                             %
867 %                                                                             %
868 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
869 %
870 %  RegisterYCBCRImage() adds attributes for the YCbCr or YCbCrA image format to
871 %  the list of supported formats.  The attributes include the image format
872 %  tag, a method to read and/or write the format, whether the format
873 %  supports the saving of more than one frame to the same file or blob,
874 %  whether the format supports native in-memory I/O, and a brief
875 %  description of the format.
876 %
877 %  The format of the RegisterYCBCRImage method is:
878 %
879 %      size_t RegisterYCBCRImage(void)
880 %
881 */
882 ModuleExport size_t RegisterYCBCRImage(void)
883 {
884   MagickInfo
885     *entry;
886
887   entry=SetMagickInfo("YCbCr");
888   entry->decoder=(DecodeImageHandler *) ReadYCBCRImage;
889   entry->encoder=(EncodeImageHandler *) WriteYCBCRImage;
890   entry->raw=MagickTrue;
891   entry->endian_support=MagickTrue;
892   entry->description=ConstantString("Raw Y, Cb, and Cr samples");
893   entry->module=ConstantString("YCbCr");
894   (void) RegisterMagickInfo(entry);
895   entry=SetMagickInfo("YCbCrA");
896   entry->decoder=(DecodeImageHandler *) ReadYCBCRImage;
897   entry->encoder=(EncodeImageHandler *) WriteYCBCRImage;
898   entry->raw=MagickTrue;
899   entry->endian_support=MagickTrue;
900   entry->description=ConstantString("Raw Y, Cb, Cr, and alpha samples");
901   entry->module=ConstantString("YCbCr");
902   (void) RegisterMagickInfo(entry);
903   return(MagickImageCoderSignature);
904 }
905 \f
906 /*
907 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
908 %                                                                             %
909 %                                                                             %
910 %                                                                             %
911 %   U n r e g i s t e r Y C b C r I m a g e                                   %
912 %                                                                             %
913 %                                                                             %
914 %                                                                             %
915 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
916 %
917 %  UnregisterYCBCRImage() removes format registrations made by the
918 %  YCbCr module from the list of supported formats.
919 %
920 %  The format of the UnregisterYCBCRImage method is:
921 %
922 %      UnregisterYCBCRImage(void)
923 %
924 */
925 ModuleExport void UnregisterYCBCRImage(void)
926 {
927   (void) UnregisterMagickInfo("YCbCr");
928   (void) UnregisterMagickInfo("YCbCrA");
929 }
930 \f
931 /*
932 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
933 %                                                                             %
934 %                                                                             %
935 %                                                                             %
936 %   W r i t e Y C b C r I m a g e                                             %
937 %                                                                             %
938 %                                                                             %
939 %                                                                             %
940 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
941 %
942 %  WriteYCBCRImage() writes an image to a file in the YCbCr or YCbCrA
943 %  rasterfile format.
944 %
945 %  The format of the WriteYCBCRImage method is:
946 %
947 %      MagickBooleanType WriteYCBCRImage(const ImageInfo *image_info,
948 %        Image *image)
949 %
950 %  A description of each parameter follows.
951 %
952 %    o image_info: the image info.
953 %
954 %    o image:  The image.
955 %
956 */
957 static MagickBooleanType WriteYCBCRImage(const ImageInfo *image_info,
958   Image *image)
959 {
960   ssize_t
961     y;
962
963   MagickBooleanType
964     status;
965
966   MagickOffsetType
967     scene;
968
969   QuantumInfo
970     *quantum_info;
971
972   QuantumType
973     quantum_type;
974
975   register const PixelPacket
976     *p;
977
978   ssize_t
979     count;
980
981   size_t
982     length;
983
984   unsigned char
985     *pixels;
986
987   /*
988     Allocate memory for pixels.
989   */
990   assert(image_info != (const ImageInfo *) NULL);
991   assert(image_info->signature == MagickSignature);
992   assert(image != (Image *) NULL);
993   assert(image->signature == MagickSignature);
994   if (image->debug != MagickFalse)
995     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
996   if (image_info->interlace != PartitionInterlace)
997     {
998       /*
999         Open output image file.
1000       */
1001       status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);
1002       if (status == MagickFalse)
1003         return(status);
1004     }
1005   quantum_type=RGBQuantum;
1006   if (LocaleCompare(image_info->magick,"YCbCrA") == 0)
1007     {
1008       quantum_type=RGBAQuantum;
1009       image->matte=MagickTrue;
1010     }
1011   scene=0;
1012   do
1013   {
1014     /*
1015       Convert MIFF to YCbCr raster pixels.
1016     */
1017     if (image->colorspace != YCbCrColorspace)
1018       (void) TransformImageColorspace(image,YCbCrColorspace);
1019     if ((LocaleCompare(image_info->magick,"YCbCrA") == 0) &&
1020         (image->matte == MagickFalse))
1021       (void) SetImageAlphaChannel(image,ResetAlphaChannel);
1022     quantum_info=AcquireQuantumInfo(image_info,image);
1023     if (quantum_info == (QuantumInfo *) NULL)
1024       ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
1025     pixels=GetQuantumPixels(quantum_info);
1026     switch (image_info->interlace)
1027     {
1028       case NoInterlace:
1029       default:
1030       {
1031         /*
1032           No interlacing:  YCbCrYCbCrYCbCrYCbCrYCbCrYCbCr...
1033         */
1034         for (y=0; y < (ssize_t) image->rows; y++)
1035         {
1036           p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
1037           if (p == (const PixelPacket *) NULL)
1038             break;
1039           length=ExportQuantumPixels(image,(const CacheView *) NULL,quantum_info,
1040             quantum_type,pixels,&image->exception);
1041           count=WriteBlob(image,length,pixels);
1042           if (count != (ssize_t) length)
1043             break;
1044           if (image->previous == (Image *) NULL)
1045             {
1046               status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
1047                 image->rows);
1048               if (status == MagickFalse)
1049                 break;
1050             }
1051         }
1052         break;
1053       }
1054       case LineInterlace:
1055       {
1056         /*
1057           Line interlacing:  YYY...CbCbCb...CrCrCr...YYY...CbCbCb...CrCrCr...
1058         */
1059         for (y=0; y < (ssize_t) image->rows; y++)
1060         {
1061           p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
1062           if (p == (const PixelPacket *) NULL)
1063             break;
1064           length=ExportQuantumPixels(image,(const CacheView *) NULL,quantum_info,
1065             RedQuantum,pixels,&image->exception);
1066           count=WriteBlob(image,length,pixels);
1067           if (count != (ssize_t) length)
1068             break;
1069           length=ExportQuantumPixels(image,(const CacheView *) NULL,quantum_info,
1070             GreenQuantum,pixels,&image->exception);
1071           count=WriteBlob(image,length,pixels);
1072           if (count != (ssize_t) length)
1073             break;
1074           length=ExportQuantumPixels(image,(const CacheView *) NULL,quantum_info,
1075             BlueQuantum,pixels,&image->exception);
1076           count=WriteBlob(image,length,pixels);
1077           if (count != (ssize_t) length)
1078             break;
1079           if (quantum_type == RGBAQuantum)
1080             {
1081               length=ExportQuantumPixels(image,(const CacheView *) NULL,
1082                 quantum_info,AlphaQuantum,pixels,&image->exception);
1083               count=WriteBlob(image,length,pixels);
1084               if (count != (ssize_t) length)
1085                 break;
1086             }
1087           if (image->previous == (Image *) NULL)
1088             {
1089               status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
1090                 image->rows);
1091               if (status == MagickFalse)
1092                 break;
1093             }
1094         }
1095         break;
1096       }
1097       case PlaneInterlace:
1098       {
1099         /*
1100           Plane interlacing:  YYYYYY...CbCbCbCbCbCb...CrCrCrCrCrCr...
1101         */
1102         for (y=0; y < (ssize_t) image->rows; y++)
1103         {
1104           p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
1105           if (p == (const PixelPacket *) NULL)
1106             break;
1107           length=ExportQuantumPixels(image,(const CacheView *) NULL,quantum_info,
1108             RedQuantum,pixels,&image->exception);
1109           count=WriteBlob(image,length,pixels);
1110           if (count != (ssize_t) length)
1111             break;
1112         }
1113         if (image->previous == (Image *) NULL)
1114           {
1115             status=SetImageProgress(image,SaveImageTag,1,5);
1116             if (status == MagickFalse)
1117               break;
1118           }
1119         for (y=0; y < (ssize_t) image->rows; y++)
1120         {
1121           p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
1122           if (p == (const PixelPacket *) NULL)
1123             break;
1124           length=ExportQuantumPixels(image,(const CacheView *) NULL,quantum_info,
1125             GreenQuantum,pixels,&image->exception);
1126           count=WriteBlob(image,length,pixels);
1127           if (count != (ssize_t) length)
1128             break;
1129         }
1130         if (image->previous == (Image *) NULL)
1131           {
1132             status=SetImageProgress(image,SaveImageTag,2,5);
1133             if (status == MagickFalse)
1134               break;
1135           }
1136         for (y=0; y < (ssize_t) image->rows; y++)
1137         {
1138           p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
1139           if (p == (const PixelPacket *) NULL)
1140             break;
1141           length=ExportQuantumPixels(image,(const CacheView *) NULL,quantum_info,
1142             BlueQuantum,pixels,&image->exception);
1143           count=WriteBlob(image,length,pixels);
1144           if (count != (ssize_t) length)
1145             break;
1146         }
1147         if (image->previous == (Image *) NULL)
1148           {
1149             status=SetImageProgress(image,SaveImageTag,3,5);
1150             if (status == MagickFalse)
1151               break;
1152           }
1153         if (quantum_type == RGBAQuantum)
1154           {
1155             for (y=0; y < (ssize_t) image->rows; y++)
1156             {
1157               p=GetVirtualPixels(image,0,y,image->columns,1,
1158                 &image->exception);
1159               if (p == (const PixelPacket *) NULL)
1160                 break;
1161               length=ExportQuantumPixels(image,(const CacheView *) NULL,
1162                 quantum_info,AlphaQuantum,pixels,&image->exception);
1163               count=WriteBlob(image,length,pixels);
1164               if (count != (ssize_t) length)
1165               break;
1166             }
1167           }
1168         if (image_info->interlace == PartitionInterlace)
1169           (void) CopyMagickString(image->filename,image_info->filename,
1170             MaxTextExtent);
1171         if (image->previous == (Image *) NULL)
1172           {
1173             status=SetImageProgress(image,SaveImageTag,5,5);
1174             if (status == MagickFalse)
1175               break;
1176           }
1177         break;
1178       }
1179       case PartitionInterlace:
1180       {
1181         /*
1182           Partition interlacing:  YYYYYY..., CbCbCbCbCbCb..., CrCrCrCrCrCr...
1183         */
1184         AppendImageFormat("Y",image->filename);
1185         status=OpenBlob(image_info,image,scene == 0 ? WriteBinaryBlobMode :
1186           AppendBinaryBlobMode,&image->exception);
1187         if (status == MagickFalse)
1188           return(status);
1189         for (y=0; y < (ssize_t) image->rows; y++)
1190         {
1191           p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
1192           if (p == (const PixelPacket *) NULL)
1193             break;
1194           length=ExportQuantumPixels(image,(const CacheView *) NULL,quantum_info,
1195             RedQuantum,pixels,&image->exception);
1196           count=WriteBlob(image,length,pixels);
1197           if (count != (ssize_t) length)
1198             break;
1199         }
1200         if (image->previous == (Image *) NULL)
1201           {
1202             status=SetImageProgress(image,SaveImageTag,1,5);
1203             if (status == MagickFalse)
1204               break;
1205           }
1206         (void) CloseBlob(image);
1207         AppendImageFormat("Cb",image->filename);
1208         status=OpenBlob(image_info,image,scene == 0 ? WriteBinaryBlobMode :
1209           AppendBinaryBlobMode,&image->exception);
1210         if (status == MagickFalse)
1211           return(status);
1212         for (y=0; y < (ssize_t) image->rows; y++)
1213         {
1214           p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
1215           if (p == (const PixelPacket *) NULL)
1216             break;
1217           length=ExportQuantumPixels(image,(const CacheView *) NULL,quantum_info,
1218             GreenQuantum,pixels,&image->exception);
1219           count=WriteBlob(image,length,pixels);
1220           if (count != (ssize_t) length)
1221             break;
1222         }
1223         if (image->previous == (Image *) NULL)
1224           {
1225             status=SetImageProgress(image,SaveImageTag,2,5);
1226             if (status == MagickFalse)
1227               break;
1228           }
1229         (void) CloseBlob(image);
1230         AppendImageFormat("Cr",image->filename);
1231         status=OpenBlob(image_info,image,scene == 0 ? WriteBinaryBlobMode :
1232           AppendBinaryBlobMode,&image->exception);
1233         if (status == MagickFalse)
1234           return(status);
1235         for (y=0; y < (ssize_t) image->rows; y++)
1236         {
1237           p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
1238           if (p == (const PixelPacket *) NULL)
1239             break;
1240           length=ExportQuantumPixels(image,(const CacheView *) NULL,quantum_info,
1241             BlueQuantum,pixels,&image->exception);
1242           count=WriteBlob(image,length,pixels);
1243           if (count != (ssize_t) length)
1244             break;
1245         }
1246         if (image->previous == (Image *) NULL)
1247           {
1248             status=SetImageProgress(image,SaveImageTag,3,5);
1249             if (status == MagickFalse)
1250               break;
1251           }
1252         if (quantum_type == RGBAQuantum)
1253           {
1254             (void) CloseBlob(image);
1255             AppendImageFormat("A",image->filename);
1256             status=OpenBlob(image_info,image,scene == 0 ? WriteBinaryBlobMode :
1257               AppendBinaryBlobMode,&image->exception);
1258             if (status == MagickFalse)
1259               return(status);
1260             for (y=0; y < (ssize_t) image->rows; y++)
1261             {
1262               p=GetVirtualPixels(image,0,y,image->columns,1,
1263                 &image->exception);
1264               if (p == (const PixelPacket *) NULL)
1265                 break;
1266               length=ExportQuantumPixels(image,(const CacheView *) NULL,
1267                 quantum_info,AlphaQuantum,pixels,&image->exception);
1268               count=WriteBlob(image,length,pixels);
1269               if (count != (ssize_t) length)
1270                 break;
1271             }
1272             if (image->previous == (Image *) NULL)
1273               {
1274                 status=SetImageProgress(image,SaveImageTag,4,5);
1275                 if (status == MagickFalse)
1276                   break;
1277               }
1278           }
1279         (void) CloseBlob(image);
1280         (void) CopyMagickString(image->filename,image_info->filename,
1281           MaxTextExtent);
1282         if (image->previous == (Image *) NULL)
1283           {
1284             status=SetImageProgress(image,SaveImageTag,5,5);
1285             if (status == MagickFalse)
1286               break;
1287           }
1288         break;
1289       }
1290     }
1291     quantum_info=DestroyQuantumInfo(quantum_info);
1292     if (GetNextImageInList(image) == (Image *) NULL)
1293       break;
1294     image=SyncNextImageInList(image);
1295     status=SetImageProgress(image,SaveImagesTag,scene++,
1296       GetImageListLength(image));
1297     if (status == MagickFalse)
1298       break;
1299   } while (image_info->adjoin != MagickFalse);
1300   (void) CloseBlob(image);
1301   return(MagickTrue);
1302 }