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-2010 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)
139 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,exception);
167 SetMagickPixelPacket(image,p,GetCacheViewAuthenticIndexQueue(image_view),
170 GetMagickPixelPacket(image,&zero);
171 #if defined(MAGICKCORE_OPENMP_SUPPORT)
172 #pragma omp parallel for schedule(dynamic,4) shared(status)
174 for (y=0; y < (ssize_t) image->rows; y++)
182 register const IndexPacket
185 register const PixelPacket
191 if (status == MagickFalse)
193 #if defined(MAGICKCORE_OPENMP_SUPPORT)
194 # pragma omp critical (MagickCore_GetImageBoundingBox)
197 p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
198 if (p == (const PixelPacket *) NULL)
203 indexes=GetCacheViewVirtualIndexQueue(image_view);
205 for (x=0; x < (ssize_t) image->columns; x++)
207 SetMagickPixelPacket(image,p,indexes+x,&pixel);
208 if ((x < bounding_box.x) &&
209 (IsMagickColorSimilar(&pixel,&target[0]) == MagickFalse))
211 if ((x > (ssize_t) bounding_box.width) &&
212 (IsMagickColorSimilar(&pixel,&target[1]) == MagickFalse))
213 bounding_box.width=(size_t) x;
214 if ((y < bounding_box.y) &&
215 (IsMagickColorSimilar(&pixel,&target[0]) == MagickFalse))
217 if ((y > (ssize_t) bounding_box.height) &&
218 (IsMagickColorSimilar(&pixel,&target[2]) == MagickFalse))
219 bounding_box.height=(size_t) y;
222 #if defined(MAGICKCORE_OPENMP_SUPPORT)
223 # pragma omp critical (MagickCore_GetImageBoundingBox)
226 if (bounding_box.x < bounds.x)
227 bounds.x=bounding_box.x;
228 if (bounding_box.y < bounds.y)
229 bounds.y=bounding_box.y;
230 if (bounding_box.width > bounds.width)
231 bounds.width=bounding_box.width;
232 if (bounding_box.height > bounds.height)
233 bounds.height=bounding_box.height;
236 image_view=DestroyCacheView(image_view);
237 if ((bounds.width == 0) || (bounds.height == 0))
238 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
239 "GeometryDoesNotContainImage","`%s'",image->filename);
242 bounds.width-=(bounds.x-1);
243 bounds.height-=(bounds.y-1);
249 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
253 % G e t I m a g e C h a n n e l D e p t h %
257 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
259 % GetImageChannelDepth() returns the depth of a particular image channel.
261 % The format of the GetImageChannelDepth method is:
263 % size_t GetImageDepth(const Image *image,ExceptionInfo *exception)
264 % size_t GetImageChannelDepth(const Image *image,
265 % const ChannelType channel,ExceptionInfo *exception)
267 % A description of each parameter follows:
269 % o image: the image.
271 % o channel: the channel.
273 % o exception: return any errors or warnings in this structure.
277 static inline QuantumAny GetPixelDepth(const Quantum pixel,
278 const QuantumAny scale)
280 #if !defined(MAGICKCORE_HDRI_SUPPORT)
281 return((QuantumAny) (scale*(pixel/scale)));
283 return((QuantumAny) (scale*(pixel/scale)+0.5));
287 MagickExport size_t GetImageDepth(const Image *image,ExceptionInfo *exception)
289 return(GetImageChannelDepth(image,AllChannels,exception));
292 MagickExport size_t GetImageChannelDepth(const Image *image,
293 const ChannelType channel,ExceptionInfo *exception)
315 assert(image != (Image *) NULL);
316 assert(image->signature == MagickSignature);
317 if (image->debug != MagickFalse)
318 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
319 number_threads=GetOpenMPMaximumThreads();
320 current_depth=(size_t *) AcquireQuantumMemory(number_threads,
321 sizeof(*current_depth));
322 if (current_depth == (size_t *) NULL)
323 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
325 for (id=0; id < (ssize_t) number_threads; id++)
327 if ((image->storage_class == PseudoClass) && (image->matte == MagickFalse))
329 register const PixelPacket
336 #if defined(MAGICKCORE_OPENMP_SUPPORT)
337 #pragma omp parallel for schedule(dynamic,4) shared(status)
339 for (i=0; i < (ssize_t) image->colors; i++)
341 if (status == MagickFalse)
343 id=GetOpenMPThreadId();
344 while (current_depth[id] < MAGICKCORE_QUANTUM_DEPTH)
354 if (current_depth[id] < QuantumDepth)
355 scale=QuantumRange/((QuantumAny) QuantumRange >> (QuantumDepth-
357 if ((channel & RedChannel) != 0)
358 status|=(QuantumAny) p->red != GetPixelDepth(p->red,scale);
359 if ((channel & GreenChannel) != 0)
360 status|=(QuantumAny) p->green != GetPixelDepth(p->green,scale);
361 if ((channel & BlueChannel) != 0)
362 status|=(QuantumAny) p->blue != GetPixelDepth(p->blue,scale);
369 depth=current_depth[0];
370 for (id=1; id < (ssize_t) number_threads; id++)
371 if (depth < current_depth[id])
372 depth=current_depth[id];
373 current_depth=(size_t *) RelinquishMagickMemory(current_depth);
376 image_view=AcquireCacheView(image);
377 #if defined(MAGICKCORE_OPENMP_SUPPORT)
378 #pragma omp parallel for schedule(dynamic,4) shared(status)
380 for (y=0; y < (ssize_t) image->rows; y++)
382 register const IndexPacket
385 register const PixelPacket
392 if (status == MagickFalse)
394 id=GetOpenMPThreadId();
395 p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
396 if (p == (const PixelPacket *) NULL)
398 indexes=GetCacheViewVirtualIndexQueue(image_view);
399 for (x=0; x < (ssize_t) image->columns; x++)
401 while (current_depth[id] < MAGICKCORE_QUANTUM_DEPTH)
411 if (current_depth[id] < QuantumDepth)
412 scale=QuantumRange/((QuantumAny) QuantumRange >> (QuantumDepth-
414 if ((channel & RedChannel) != 0)
415 status|=(QuantumAny) p->red != GetPixelDepth(p->red,scale);
416 if ((channel & GreenChannel) != 0)
417 status|=(QuantumAny) p->green != GetPixelDepth(p->green,scale);
418 if ((channel & BlueChannel) != 0)
419 status|=(QuantumAny) p->blue != GetPixelDepth(p->blue,scale);
420 if (((channel & OpacityChannel) != 0) && (image->matte != MagickFalse))
421 status|=(QuantumAny) p->opacity != GetPixelDepth(p->opacity,scale);
422 if (((channel & IndexChannel) != 0) &&
423 (image->colorspace == CMYKColorspace))
424 status|=(QuantumAny) indexes[x] != GetPixelDepth(indexes[x],scale);
431 if (current_depth[id] == MAGICKCORE_QUANTUM_DEPTH)
434 image_view=DestroyCacheView(image_view);
435 depth=current_depth[0];
436 for (id=1; id < (ssize_t) number_threads; id++)
437 if (depth < current_depth[id])
438 depth=current_depth[id];
439 current_depth=(size_t *) RelinquishMagickMemory(current_depth);
444 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
448 % G e t I m a g e Q u a n t u m D e p t h %
452 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
454 % GetImageQuantumDepth() returns the depth of the image rounded to a legal
455 % quantum depth: 8, 16, or 32.
457 % The format of the GetImageQuantumDepth method is:
459 % size_t GetImageQuantumDepth(const Image *image,
460 % const MagickBooleanType constrain)
462 % A description of each parameter follows:
464 % o image: the image.
466 % o constrain: A value other than MagickFalse, constrains the depth to
467 % a maximum of MAGICKCORE_QUANTUM_DEPTH.
471 static inline double MagickMin(const double x,const double y)
478 MagickExport size_t GetImageQuantumDepth(const Image *image,
479 const MagickBooleanType constrain)
496 if (constrain != MagickFalse)
497 depth=(size_t) MagickMin((double) depth,(double)
498 MAGICKCORE_QUANTUM_DEPTH);
503 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
507 % G e t I m a g e T y p e %
511 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
513 % GetImageType() returns the potential type of image:
515 % Bilevel Grayscale GrayscaleMatte
516 % Palette PaletteMatte TrueColor
517 % TrueColorMatte ColorSeparation ColorSeparationMatte
519 % To ensure the image type matches its potential, use SetImageType():
521 % (void) SetImageType(image,GetImageType(image));
523 % The format of the GetImageType method is:
525 % ImageType GetImageType(const Image *image,ExceptionInfo *exception)
527 % A description of each parameter follows:
529 % o image: the image.
531 % o exception: return any errors or warnings in this structure.
534 MagickExport ImageType GetImageType(const Image *image,ExceptionInfo *exception)
536 assert(image != (Image *) NULL);
537 assert(image->signature == MagickSignature);
538 if (image->debug != MagickFalse)
539 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
540 if (image->colorspace == CMYKColorspace)
542 if (image->matte == MagickFalse)
543 return(ColorSeparationType);
544 return(ColorSeparationMatteType);
546 if (IsMonochromeImage(image,exception) != MagickFalse)
548 if (IsGrayImage(image,exception) != MagickFalse)
550 if (image->matte != MagickFalse)
551 return(GrayscaleMatteType);
552 return(GrayscaleType);
554 if (IsPaletteImage(image,exception) != MagickFalse)
556 if (image->matte != MagickFalse)
557 return(PaletteMatteType);
560 if (image->matte != MagickFalse)
561 return(TrueColorMatteType);
562 return(TrueColorType);
566 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
570 % I s G r a y I m a g e %
574 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
576 % IsGrayImage() returns MagickTrue if all the pixels in the image have the
577 % same red, green, and blue intensities.
579 % The format of the IsGrayImage method is:
581 % MagickBooleanType IsGrayImage(const Image *image,
582 % ExceptionInfo *exception)
584 % A description of each parameter follows:
586 % o image: the image.
588 % o exception: return any errors or warnings in this structure.
591 MagickExport MagickBooleanType IsGrayImage(const Image *image,
592 ExceptionInfo *exception)
603 register const PixelPacket
609 assert(image != (Image *) NULL);
610 assert(image->signature == MagickSignature);
611 if (image->debug != MagickFalse)
612 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
613 if ((image->type == BilevelType) || (image->type == GrayscaleType) ||
614 (image->type == GrayscaleMatteType))
616 if (image->colorspace == CMYKColorspace)
619 image_view=AcquireCacheView(image);
620 for (y=0; y < (ssize_t) image->rows; y++)
622 p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
623 if (p == (const PixelPacket *) NULL)
625 for (x=0; x < (ssize_t) image->columns; x++)
627 if (IsGrayPixel(p) == MagickFalse)
632 if ((type == BilevelType) && (IsMonochromePixel(p) == MagickFalse))
636 if (type == UndefinedType)
639 image_view=DestroyCacheView(image_view);
640 if (type == UndefinedType)
642 ((Image *) image)->type=type;
643 if ((type == GrayscaleType) && (image->matte != MagickFalse))
644 ((Image *) image)->type=GrayscaleMatteType;
649 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
653 % I s M o n o c h r o m e I m a g e %
657 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
659 % IsMonochromeImage() returns MagickTrue if all the pixels in the image have
660 % the same red, green, and blue intensities and the intensity is either
663 % The format of the IsMonochromeImage method is:
665 % MagickBooleanType IsMonochromeImage(const Image *image,
666 % ExceptionInfo *exception)
668 % A description of each parameter follows:
670 % o image: the image.
672 % o exception: return any errors or warnings in this structure.
675 MagickExport MagickBooleanType IsMonochromeImage(const Image *image,
676 ExceptionInfo *exception)
690 register const PixelPacket
693 assert(image != (Image *) NULL);
694 assert(image->signature == MagickSignature);
695 if (image->debug != MagickFalse)
696 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
697 if (image->type == BilevelType)
699 if (image->colorspace == CMYKColorspace)
702 image_view=AcquireCacheView(image);
703 for (y=0; y < (ssize_t) image->rows; y++)
705 p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
706 if (p == (const PixelPacket *) NULL)
708 for (x=0; x < (ssize_t) image->columns; x++)
710 if (IsMonochromePixel(p) == MagickFalse)
717 if (type == UndefinedType)
720 image_view=DestroyCacheView(image_view);
721 if (type == UndefinedType)
723 ((Image *) image)->type=type;
728 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
732 % I s O p a q u e I m a g e %
736 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
738 % IsOpaqueImage() returns MagickTrue if none of the pixels in the image have
739 % an opacity value other than opaque (0).
741 % The format of the IsOpaqueImage method is:
743 % MagickBooleanType IsOpaqueImage(const Image *image,
744 % ExceptionInfo *exception)
746 % A description of each parameter follows:
748 % o image: the image.
750 % o exception: return any errors or warnings in this structure.
753 MagickExport MagickBooleanType IsOpaqueImage(const Image *image,
754 ExceptionInfo *exception)
762 register const PixelPacket
769 Determine if image is opaque.
771 assert(image != (Image *) NULL);
772 assert(image->signature == MagickSignature);
773 if (image->debug != MagickFalse)
774 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
775 if (image->matte == MagickFalse)
777 image_view=AcquireCacheView(image);
778 for (y=0; y < (ssize_t) image->rows; y++)
780 p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
781 if (p == (const PixelPacket *) NULL)
783 for (x=0; x < (ssize_t) image->columns; x++)
785 if (p->opacity != OpaqueOpacity)
789 if (x < (ssize_t) image->columns)
792 image_view=DestroyCacheView(image_view);
793 return(y < (ssize_t) image->rows ? MagickFalse : MagickTrue);
797 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
801 % S e t I m a g e C h a n n e l D e p t h %
805 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
807 % SetImageChannelDepth() sets the depth of the image.
809 % The format of the SetImageChannelDepth method is:
811 % MagickBooleanType SetImageDepth(Image *image,const size_t depth)
812 % MagickBooleanType SetImageChannelDepth(Image *image,
813 % const ChannelType channel,const size_t depth)
815 % A description of each parameter follows:
817 % o image: the image.
819 % o channel: the channel.
821 % o depth: the image depth.
825 static inline Quantum SetPixelDepth(const Quantum pixel,
826 const QuantumAny scale)
828 return((Quantum) (scale*(pixel/scale)));
831 MagickExport MagickBooleanType SetImageDepth(Image *image,
834 return(SetImageChannelDepth(image,AllChannels,depth));
837 MagickExport MagickBooleanType SetImageChannelDepth(Image *image,
838 const ChannelType channel,const size_t depth)
855 assert(image != (Image *) NULL);
856 if (image->debug != MagickFalse)
857 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
858 assert(image->signature == MagickSignature);
859 if (GetImageDepth(image,&image->exception) <= (size_t)
860 MagickMin((double) depth,(double) MAGICKCORE_QUANTUM_DEPTH))
866 Scale pixels to desired depth.
870 if (depth < QuantumDepth)
871 scale=QuantumRange/((QuantumAny) QuantumRange >> (QuantumDepth-depth));
872 exception=(&image->exception);
873 image_view=AcquireCacheView(image);
874 #if defined(MAGICKCORE_OPENMP_SUPPORT)
875 #pragma omp parallel for schedule(dynamic,4) shared(status)
877 for (y=0; y < (ssize_t) image->rows; y++)
888 if (status == MagickFalse)
890 q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,
892 if (q == (PixelPacket *) NULL)
897 indexes=GetCacheViewAuthenticIndexQueue(image_view);
898 for (x=0; x < (ssize_t) image->columns; x++)
900 if ((channel & RedChannel) != 0)
901 q->red=SetPixelDepth(q->red,scale);
902 if ((channel & GreenChannel) != 0)
903 q->green=SetPixelDepth(q->green,scale);
904 if ((channel & BlueChannel) != 0)
905 q->green=SetPixelDepth(q->blue,scale);
906 if (((channel & OpacityChannel) != 0) && (image->matte != MagickFalse))
907 q->opacity=SetPixelDepth(q->opacity,scale);
908 if (((channel & IndexChannel) != 0) &&
909 (image->colorspace == CMYKColorspace))
910 indexes[x]=SetPixelDepth(indexes[x],scale);
913 if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
919 image_view=DestroyCacheView(image_view);
920 if (image->storage_class == PseudoClass)
932 range=GetQuantumRange(depth);
933 #if defined(MAGICKCORE_OPENMP_SUPPORT)
934 #pragma omp parallel for schedule(dynamic,4) shared(status)
936 for (i=0; i < (ssize_t) image->colors; i++)
938 if ((channel & RedChannel) != 0)
939 p->red=SetPixelDepth(p->red,scale);
940 if ((channel & GreenChannel) != 0)
941 p->green=SetPixelDepth(p->green,scale);
942 if ((channel & BlueChannel) != 0)
943 p->blue=SetPixelDepth(p->blue,scale);
944 if ((channel & OpacityChannel) != 0)
945 p->opacity=SetPixelDepth(p->opacity,scale);