2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6 % AAA TTTTT TTTTT RRRR IIIII BBBB U U TTTTT EEEEE %
7 % A A T T R R I B B U U T E %
8 % AAAAA T T RRRR I BBBB U U T EEE %
9 % A A T T R R I B B U U T E %
10 % A A T T R R IIIII BBBB UUU T EEEEE %
13 % MagickCore Get / Set Image Attributes %
20 % Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization %
21 % dedicated to making software imaging solutions freely available. %
23 % You may not use this file except in compliance with the License. You may %
24 % obtain a copy of the License at %
26 % http://www.imagemagick.org/script/license.php %
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. %
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43 #include "magick/studio.h"
44 #include "magick/attribute.h"
45 #include "magick/blob.h"
46 #include "magick/blob-private.h"
47 #include "magick/cache.h"
48 #include "magick/cache-view.h"
49 #include "magick/client.h"
50 #include "magick/color.h"
51 #include "magick/color-private.h"
52 #include "magick/colormap.h"
53 #include "magick/colormap-private.h"
54 #include "magick/colorspace.h"
55 #include "magick/composite.h"
56 #include "magick/composite-private.h"
57 #include "magick/constitute.h"
58 #include "magick/deprecate.h"
59 #include "magick/draw.h"
60 #include "magick/draw-private.h"
61 #include "magick/effect.h"
62 #include "magick/enhance.h"
63 #include "magick/exception.h"
64 #include "magick/exception-private.h"
65 #include "magick/geometry.h"
66 #include "magick/histogram.h"
67 #include "magick/identify.h"
68 #include "magick/image.h"
69 #include "magick/image-private.h"
70 #include "magick/list.h"
71 #include "magick/log.h"
72 #include "magick/memory_.h"
73 #include "magick/magick.h"
74 #include "magick/monitor.h"
75 #include "magick/monitor-private.h"
76 #include "magick/paint.h"
77 #include "magick/pixel.h"
78 #include "magick/pixel-private.h"
79 #include "magick/property.h"
80 #include "magick/quantize.h"
81 #include "magick/random_.h"
82 #include "magick/resource_.h"
83 #include "magick/semaphore.h"
84 #include "magick/segment.h"
85 #include "magick/splay-tree.h"
86 #include "magick/string_.h"
87 #include "magick/thread-private.h"
88 #include "magick/threshold.h"
89 #include "magick/transform.h"
90 #include "magick/utility.h"
93 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
97 + G e t I m a g e B o u n d i n g B o x %
101 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
103 % GetImageBoundingBox() returns the bounding box of an image canvas.
105 % The format of the GetImageBoundingBox method is:
107 % RectangleInfo GetImageBoundingBox(const Image *image,
108 % ExceptionInfo *exception)
110 % A description of each parameter follows:
112 % o bounds: Method GetImageBoundingBox returns the bounding box of an
115 % o image: the image.
117 % o exception: return any errors or warnings in this structure.
120 MagickExport RectangleInfo GetImageBoundingBox(const Image *image,
121 ExceptionInfo *exception)
136 register const PixelPacket
142 assert(image != (Image *) NULL);
143 assert(image->signature == MagickSignature);
144 if (image->debug != MagickFalse)
145 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
148 bounds.x=(ssize_t) image->columns;
149 bounds.y=(ssize_t) image->rows;
150 GetMagickPixelPacket(image,&target[0]);
151 image_view=AcquireCacheView(image);
152 p=GetCacheViewVirtualPixels(image_view,0,0,1,1,exception);
153 if (p == (const PixelPacket *) NULL)
155 image_view=DestroyCacheView(image_view);
158 SetMagickPixelPacket(image,p,GetCacheViewAuthenticIndexQueue(image_view),
160 GetMagickPixelPacket(image,&target[1]);
161 p=GetCacheViewVirtualPixels(image_view,(ssize_t) image->columns-1,0,1,1,
163 SetMagickPixelPacket(image,p,GetCacheViewAuthenticIndexQueue(image_view),
165 GetMagickPixelPacket(image,&target[2]);
166 p=GetCacheViewVirtualPixels(image_view,0,(ssize_t) image->rows-1,1,1,
168 SetMagickPixelPacket(image,p,GetCacheViewAuthenticIndexQueue(image_view),
171 GetMagickPixelPacket(image,&zero);
172 #if defined(MAGICKCORE_OPENMP_SUPPORT)
173 #pragma omp parallel for schedule(dynamic,4) shared(status)
175 for (y=0; y < (ssize_t) image->rows; y++)
183 register const IndexPacket
186 register const PixelPacket
192 if (status == MagickFalse)
194 #if defined(MAGICKCORE_OPENMP_SUPPORT)
195 # pragma omp critical (MagickCore_GetImageBoundingBox)
198 p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
199 if (p == (const PixelPacket *) NULL)
204 indexes=GetCacheViewVirtualIndexQueue(image_view);
206 for (x=0; x < (ssize_t) image->columns; x++)
208 SetMagickPixelPacket(image,p,indexes+x,&pixel);
209 if ((x < bounding_box.x) &&
210 (IsMagickColorSimilar(&pixel,&target[0]) == MagickFalse))
212 if ((x > (ssize_t) bounding_box.width) &&
213 (IsMagickColorSimilar(&pixel,&target[1]) == MagickFalse))
214 bounding_box.width=(size_t) x;
215 if ((y < bounding_box.y) &&
216 (IsMagickColorSimilar(&pixel,&target[0]) == MagickFalse))
218 if ((y > (ssize_t) bounding_box.height) &&
219 (IsMagickColorSimilar(&pixel,&target[2]) == MagickFalse))
220 bounding_box.height=(size_t) y;
223 #if defined(MAGICKCORE_OPENMP_SUPPORT)
224 # pragma omp critical (MagickCore_GetImageBoundingBox)
227 if (bounding_box.x < bounds.x)
228 bounds.x=bounding_box.x;
229 if (bounding_box.y < bounds.y)
230 bounds.y=bounding_box.y;
231 if (bounding_box.width > bounds.width)
232 bounds.width=bounding_box.width;
233 if (bounding_box.height > bounds.height)
234 bounds.height=bounding_box.height;
237 image_view=DestroyCacheView(image_view);
238 if ((bounds.width == 0) || (bounds.height == 0))
239 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
240 "GeometryDoesNotContainImage","`%s'",image->filename);
243 bounds.width-=(bounds.x-1);
244 bounds.height-=(bounds.y-1);
250 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
254 % G e t I m a g e C h a n n e l D e p t h %
258 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
260 % GetImageChannelDepth() returns the depth of a particular image channel.
262 % The format of the GetImageChannelDepth method is:
264 % size_t GetImageDepth(const Image *image,ExceptionInfo *exception)
265 % size_t GetImageChannelDepth(const Image *image,
266 % const ChannelType channel,ExceptionInfo *exception)
268 % A description of each parameter follows:
270 % o image: the image.
272 % o channel: the channel.
274 % o exception: return any errors or warnings in this structure.
277 MagickExport size_t GetImageDepth(const Image *image,ExceptionInfo *exception)
279 return(GetImageChannelDepth(image,AllChannels,exception));
282 MagickExport size_t GetImageChannelDepth(const Image *image,
283 const ChannelType channel,ExceptionInfo *exception)
305 assert(image != (Image *) NULL);
306 assert(image->signature == MagickSignature);
307 if (image->debug != MagickFalse)
308 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
309 number_threads=GetOpenMPMaximumThreads();
310 current_depth=(size_t *) AcquireQuantumMemory(number_threads,
311 sizeof(*current_depth));
312 if (current_depth == (size_t *) NULL)
313 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
315 for (id=0; id < (ssize_t) number_threads; id++)
317 if ((image->storage_class == PseudoClass) && (image->matte == MagickFalse))
319 register const PixelPacket
326 #if defined(MAGICKCORE_OPENMP_SUPPORT)
327 #pragma omp parallel for schedule(dynamic,4) shared(status)
329 for (i=0; i < (ssize_t) image->colors; i++)
332 id = GetOpenMPThreadId();
334 if (status == MagickFalse)
336 while (current_depth[id] < MAGICKCORE_QUANTUM_DEPTH)
345 range=GetQuantumRange(current_depth[id]);
346 if ((channel & RedChannel) != 0)
347 status|=p->red != ScaleAnyToQuantum(ScaleQuantumToAny(p->red,
349 if ((channel & GreenChannel) != 0)
350 status|=p->green != ScaleAnyToQuantum(ScaleQuantumToAny(p->green,
352 if ((channel & BlueChannel) != 0)
353 status|=p->blue != ScaleAnyToQuantum(ScaleQuantumToAny(p->blue,
361 depth=current_depth[0];
362 for (id=1; id < (ssize_t) number_threads; id++)
363 if (depth < current_depth[id])
364 depth=current_depth[id];
365 current_depth=(size_t *) RelinquishMagickMemory(current_depth);
368 image_view=AcquireCacheView(image);
369 #if defined(MAGICKCORE_OPENMP_SUPPORT)
370 #pragma omp parallel for schedule(dynamic,4) shared(status)
372 for (y=0; y < (ssize_t) image->rows; y++)
375 id = GetOpenMPThreadId();
377 register const IndexPacket
380 register const PixelPacket
386 if (status == MagickFalse)
388 p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
389 if (p == (const PixelPacket *) NULL)
391 indexes=GetCacheViewVirtualIndexQueue(image_view);
392 for (x=0; x < (ssize_t) image->columns; x++)
394 while (current_depth[id] < MAGICKCORE_QUANTUM_DEPTH)
403 range=GetQuantumRange(current_depth[id]);
404 if ((channel & RedChannel) != 0)
405 status|=p->red != ScaleAnyToQuantum(ScaleQuantumToAny(p->red,range),
407 if ((channel & GreenChannel) != 0)
408 status|=p->green != ScaleAnyToQuantum(ScaleQuantumToAny(p->green,
410 if ((channel & BlueChannel) != 0)
411 status|=p->blue != ScaleAnyToQuantum(ScaleQuantumToAny(p->blue,range),
413 if (((channel & OpacityChannel) != 0) && (image->matte != MagickFalse))
414 status|=p->opacity != ScaleAnyToQuantum(ScaleQuantumToAny(p->opacity,
416 if (((channel & IndexChannel) != 0) &&
417 (image->colorspace == CMYKColorspace))
418 status|=indexes[x] != ScaleAnyToQuantum(ScaleQuantumToAny(indexes[x],
426 if (current_depth[id] == MAGICKCORE_QUANTUM_DEPTH)
429 image_view=DestroyCacheView(image_view);
430 depth=current_depth[0];
431 for (id=1; id < (ssize_t) number_threads; id++)
432 if (depth < current_depth[id])
433 depth=current_depth[id];
434 current_depth=(size_t *) RelinquishMagickMemory(current_depth);
439 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
443 % G e t I m a g e Q u a n t u m D e p t h %
447 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
449 % GetImageQuantumDepth() returns the depth of the image rounded to a legal
450 % quantum depth: 8, 16, or 32.
452 % The format of the GetImageQuantumDepth method is:
454 % size_t GetImageQuantumDepth(const Image *image,
455 % const MagickBooleanType constrain)
457 % A description of each parameter follows:
459 % o image: the image.
461 % o constrain: A value other than MagickFalse, constrains the depth to
462 % a maximum of MAGICKCORE_QUANTUM_DEPTH.
466 static inline double MagickMin(const double x,const double y)
473 MagickExport size_t GetImageQuantumDepth(const Image *image,
474 const MagickBooleanType constrain)
491 if (constrain != MagickFalse)
492 depth=(size_t) MagickMin((double) depth,(double)
493 MAGICKCORE_QUANTUM_DEPTH);
498 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
502 % G e t I m a g e T y p e %
506 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
508 % GetImageType() returns the potential type of image:
510 % Bilevel Grayscale GrayscaleMatte
511 % Palette PaletteMatte TrueColor
512 % TrueColorMatte ColorSeparation ColorSeparationMatte
514 % To ensure the image type matches its potential, use SetImageType():
516 % (void) SetImageType(image,GetImageType(image));
518 % The format of the GetImageType method is:
520 % ImageType GetImageType(const Image *image,ExceptionInfo *exception)
522 % A description of each parameter follows:
524 % o image: the image.
526 % o exception: return any errors or warnings in this structure.
529 MagickExport ImageType GetImageType(const Image *image,ExceptionInfo *exception)
531 assert(image != (Image *) NULL);
532 assert(image->signature == MagickSignature);
533 if (image->debug != MagickFalse)
534 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
535 if (image->colorspace == CMYKColorspace)
537 if (image->matte == MagickFalse)
538 return(ColorSeparationType);
539 return(ColorSeparationMatteType);
541 if (IsMonochromeImage(image,exception) != MagickFalse)
543 if (IsGrayImage(image,exception) != MagickFalse)
545 if (image->matte != MagickFalse)
546 return(GrayscaleMatteType);
547 return(GrayscaleType);
549 if (IsPaletteImage(image,exception) != MagickFalse)
551 if (image->matte != MagickFalse)
552 return(PaletteMatteType);
555 if (image->matte != MagickFalse)
556 return(TrueColorMatteType);
557 return(TrueColorType);
561 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
565 % I s G r a y I m a g e %
569 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
571 % IsGrayImage() returns MagickTrue if all the pixels in the image have the
572 % same red, green, and blue intensities.
574 % The format of the IsGrayImage method is:
576 % MagickBooleanType IsGrayImage(const Image *image,
577 % ExceptionInfo *exception)
579 % A description of each parameter follows:
581 % o image: the image.
583 % o exception: return any errors or warnings in this structure.
586 MagickExport MagickBooleanType IsGrayImage(const Image *image,
587 ExceptionInfo *exception)
595 register const PixelPacket
604 assert(image != (Image *) NULL);
605 assert(image->signature == MagickSignature);
606 if (image->debug != MagickFalse)
607 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
608 if ((image->type == BilevelType) || (image->type == GrayscaleType) ||
609 (image->type == GrayscaleMatteType))
611 if (image->colorspace == CMYKColorspace)
614 image_view=AcquireCacheView(image);
615 for (y=0; y < (ssize_t) image->rows; y++)
617 p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
618 if (p == (const PixelPacket *) NULL)
620 for (x=0; x < (ssize_t) image->columns; x++)
622 if (IsGrayPixel(p) == MagickFalse)
627 if ((type == BilevelType) && (IsMonochromePixel(p) == MagickFalse))
631 if (type == UndefinedType)
634 image_view=DestroyCacheView(image_view);
635 if (type == UndefinedType)
637 ((Image *) image)->type=type;
638 if ((type == GrayscaleType) && (image->matte != MagickFalse))
639 ((Image *) image)->type=GrayscaleMatteType;
644 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
648 % I s M o n o c h r o m e I m a g e %
652 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
654 % IsMonochromeImage() returns MagickTrue if all the pixels in the image have
655 % the same red, green, and blue intensities and the intensity is either
658 % The format of the IsMonochromeImage method is:
660 % MagickBooleanType IsMonochromeImage(const Image *image,
661 % ExceptionInfo *exception)
663 % A description of each parameter follows:
665 % o image: the image.
667 % o exception: return any errors or warnings in this structure.
670 MagickExport MagickBooleanType IsMonochromeImage(const Image *image,
671 ExceptionInfo *exception)
682 register const PixelPacket
688 assert(image != (Image *) NULL);
689 assert(image->signature == MagickSignature);
690 if (image->debug != MagickFalse)
691 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
692 if (image->type == BilevelType)
694 if (image->colorspace == CMYKColorspace)
697 image_view=AcquireCacheView(image);
698 for (y=0; y < (ssize_t) image->rows; y++)
700 p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
701 if (p == (const PixelPacket *) NULL)
703 for (x=0; x < (ssize_t) image->columns; x++)
705 if (IsMonochromePixel(p) == MagickFalse)
712 if (type == UndefinedType)
715 image_view=DestroyCacheView(image_view);
716 if (type == UndefinedType)
718 ((Image *) image)->type=type;
723 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
727 % I s O p a q u e I m a g e %
731 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
733 % IsOpaqueImage() returns MagickTrue if none of the pixels in the image have
734 % an opacity value other than opaque (0).
736 % The format of the IsOpaqueImage method is:
738 % MagickBooleanType IsOpaqueImage(const Image *image,
739 % ExceptionInfo *exception)
741 % A description of each parameter follows:
743 % o image: the image.
745 % o exception: return any errors or warnings in this structure.
748 MagickExport MagickBooleanType IsOpaqueImage(const Image *image,
749 ExceptionInfo *exception)
754 register const PixelPacket
764 Determine if image is opaque.
766 assert(image != (Image *) NULL);
767 assert(image->signature == MagickSignature);
768 if (image->debug != MagickFalse)
769 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
770 if (image->matte == MagickFalse)
772 image_view=AcquireCacheView(image);
773 for (y=0; y < (ssize_t) image->rows; y++)
775 p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
776 if (p == (const PixelPacket *) NULL)
778 for (x=0; x < (ssize_t) image->columns; x++)
780 if (p->opacity != OpaqueOpacity)
784 if (x < (ssize_t) image->columns)
787 image_view=DestroyCacheView(image_view);
788 return(y < (ssize_t) image->rows ? MagickFalse : MagickTrue);
792 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
796 % S e t I m a g e C h a n n e l D e p t h %
800 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
802 % SetImageChannelDepth() sets the depth of the image.
804 % The format of the SetImageChannelDepth method is:
806 % MagickBooleanType SetImageDepth(Image *image,const size_t depth)
807 % MagickBooleanType SetImageChannelDepth(Image *image,
808 % const ChannelType channel,const size_t depth)
810 % A description of each parameter follows:
812 % o image: the image.
814 % o channel: the channel.
816 % o depth: the image depth.
819 MagickExport MagickBooleanType SetImageDepth(Image *image,
822 return(SetImageChannelDepth(image,AllChannels,depth));
825 MagickExport MagickBooleanType SetImageChannelDepth(Image *image,
826 const ChannelType channel,const size_t depth)
843 assert(image != (Image *) NULL);
844 if (image->debug != MagickFalse)
845 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
846 assert(image->signature == MagickSignature);
847 if (GetImageDepth(image,&image->exception) <= (size_t)
848 MagickMin((double) depth,(double) MAGICKCORE_QUANTUM_DEPTH))
854 Scale pixels to desired depth.
857 range=GetQuantumRange(depth);
858 exception=(&image->exception);
859 image_view=AcquireCacheView(image);
860 #if defined(MAGICKCORE_OPENMP_SUPPORT)
861 #pragma omp parallel for schedule(dynamic,4) shared(status)
863 for (y=0; y < (ssize_t) image->rows; y++)
874 if (status == MagickFalse)
876 q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,
878 if (q == (PixelPacket *) NULL)
883 indexes=GetCacheViewAuthenticIndexQueue(image_view);
884 for (x=0; x < (ssize_t) image->columns; x++)
886 if ((channel & RedChannel) != 0)
887 q->red=ScaleAnyToQuantum(ScaleQuantumToAny(q->red,range),range);
888 if ((channel & GreenChannel) != 0)
889 q->green=ScaleAnyToQuantum(ScaleQuantumToAny(q->green,range),range);
890 if ((channel & BlueChannel) != 0)
891 q->blue=ScaleAnyToQuantum(ScaleQuantumToAny(q->blue,range),range);
892 if (((channel & OpacityChannel) != 0) && (image->matte != MagickFalse))
893 q->opacity=ScaleAnyToQuantum(ScaleQuantumToAny(q->opacity,range),range);
894 if (((channel & IndexChannel) != 0) &&
895 (image->colorspace == CMYKColorspace))
896 indexes[x]=ScaleAnyToQuantum(ScaleQuantumToAny(indexes[x],range),range);
899 if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
905 image_view=DestroyCacheView(image_view);
906 if (image->storage_class == PseudoClass)
915 #if defined(MAGICKCORE_OPENMP_SUPPORT)
916 #pragma omp parallel for schedule(dynamic,4) shared(status)
918 for (i=0; i < (ssize_t) image->colors; i++)
920 if ((channel & RedChannel) != 0)
921 p->red=ScaleAnyToQuantum(ScaleQuantumToAny(p->red,range),range);
922 if ((channel & GreenChannel) != 0)
923 p->green=ScaleAnyToQuantum(ScaleQuantumToAny(p->green,range),range);
924 if ((channel & BlueChannel) != 0)
925 p->blue=ScaleAnyToQuantum(ScaleQuantumToAny(p->blue,range),range);
926 if ((channel & OpacityChannel) != 0)
927 p->opacity=ScaleAnyToQuantum(ScaleQuantumToAny(p->opacity,range),