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)
353 scale=QuantumRange/((QuantumAny) QuantumRange >>
354 (MAGICKCORE_QUANTUM_DEPTH-current_depth[id]));
355 if ((channel & RedChannel) != 0)
356 status|=(QuantumAny) p->red != GetPixelDepth(p->red,scale);
357 if ((channel & GreenChannel) != 0)
358 status|=(QuantumAny) p->green != GetPixelDepth(p->green,scale);
359 if ((channel & BlueChannel) != 0)
360 status|=(QuantumAny) p->blue != GetPixelDepth(p->blue,scale);
367 depth=current_depth[0];
368 for (id=1; id < (ssize_t) number_threads; id++)
369 if (depth < current_depth[id])
370 depth=current_depth[id];
371 current_depth=(size_t *) RelinquishMagickMemory(current_depth);
374 image_view=AcquireCacheView(image);
375 #if defined(MAGICKCORE_OPENMP_SUPPORT)
376 #pragma omp parallel for schedule(dynamic,4) shared(status)
378 for (y=0; y < (ssize_t) image->rows; y++)
380 register const IndexPacket
383 register const PixelPacket
390 if (status == MagickFalse)
392 id=GetOpenMPThreadId();
393 p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
394 if (p == (const PixelPacket *) NULL)
396 indexes=GetCacheViewVirtualIndexQueue(image_view);
397 for (x=0; x < (ssize_t) image->columns; x++)
399 while (current_depth[id] < MAGICKCORE_QUANTUM_DEPTH)
408 scale=QuantumRange/((QuantumAny) QuantumRange >>
409 (MAGICKCORE_QUANTUM_DEPTH-current_depth[id]));
410 if ((channel & RedChannel) != 0)
411 status|=(QuantumAny) p->red != GetPixelDepth(p->red,scale);
412 if ((channel & GreenChannel) != 0)
413 status|=(QuantumAny) p->green != GetPixelDepth(p->green,scale);
414 if ((channel & BlueChannel) != 0)
415 status|=(QuantumAny) p->blue != GetPixelDepth(p->blue,scale);
416 if (((channel & OpacityChannel) != 0) && (image->matte != MagickFalse))
417 status|=(QuantumAny) p->opacity != GetPixelDepth(p->opacity,scale);
418 if (((channel & IndexChannel) != 0) &&
419 (image->colorspace == CMYKColorspace))
420 status|=(QuantumAny) indexes[x] != GetPixelDepth(indexes[x],scale);
427 if (current_depth[id] == MAGICKCORE_QUANTUM_DEPTH)
430 image_view=DestroyCacheView(image_view);
431 depth=current_depth[0];
432 for (id=1; id < (ssize_t) number_threads; id++)
433 if (depth < current_depth[id])
434 depth=current_depth[id];
435 current_depth=(size_t *) RelinquishMagickMemory(current_depth);
440 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
444 % G e t I m a g e Q u a n t u m D e p t h %
448 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
450 % GetImageQuantumDepth() returns the depth of the image rounded to a legal
451 % quantum depth: 8, 16, or 32.
453 % The format of the GetImageQuantumDepth method is:
455 % size_t GetImageQuantumDepth(const Image *image,
456 % const MagickBooleanType constrain)
458 % A description of each parameter follows:
460 % o image: the image.
462 % o constrain: A value other than MagickFalse, constrains the depth to
463 % a maximum of MAGICKCORE_QUANTUM_DEPTH.
467 static inline double MagickMin(const double x,const double y)
474 MagickExport size_t GetImageQuantumDepth(const Image *image,
475 const MagickBooleanType constrain)
492 if (constrain != MagickFalse)
493 depth=(size_t) MagickMin((double) depth,(double)
494 MAGICKCORE_QUANTUM_DEPTH);
499 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
503 % G e t I m a g e T y p e %
507 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
509 % GetImageType() returns the potential type of image:
511 % Bilevel Grayscale GrayscaleMatte
512 % Palette PaletteMatte TrueColor
513 % TrueColorMatte ColorSeparation ColorSeparationMatte
515 % To ensure the image type matches its potential, use SetImageType():
517 % (void) SetImageType(image,GetImageType(image));
519 % The format of the GetImageType method is:
521 % ImageType GetImageType(const Image *image,ExceptionInfo *exception)
523 % A description of each parameter follows:
525 % o image: the image.
527 % o exception: return any errors or warnings in this structure.
530 MagickExport ImageType GetImageType(const Image *image,ExceptionInfo *exception)
532 assert(image != (Image *) NULL);
533 assert(image->signature == MagickSignature);
534 if (image->debug != MagickFalse)
535 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
536 if (image->colorspace == CMYKColorspace)
538 if (image->matte == MagickFalse)
539 return(ColorSeparationType);
540 return(ColorSeparationMatteType);
542 if (IsMonochromeImage(image,exception) != MagickFalse)
544 if (IsGrayImage(image,exception) != MagickFalse)
546 if (image->matte != MagickFalse)
547 return(GrayscaleMatteType);
548 return(GrayscaleType);
550 if (IsPaletteImage(image,exception) != MagickFalse)
552 if (image->matte != MagickFalse)
553 return(PaletteMatteType);
556 if (image->matte != MagickFalse)
557 return(TrueColorMatteType);
558 return(TrueColorType);
562 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
566 % I s G r a y I m a g e %
570 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
572 % IsGrayImage() returns MagickTrue if all the pixels in the image have the
573 % same red, green, and blue intensities.
575 % The format of the IsGrayImage method is:
577 % MagickBooleanType IsGrayImage(const Image *image,
578 % ExceptionInfo *exception)
580 % A description of each parameter follows:
582 % o image: the image.
584 % o exception: return any errors or warnings in this structure.
587 MagickExport MagickBooleanType IsGrayImage(const Image *image,
588 ExceptionInfo *exception)
599 register const PixelPacket
605 assert(image != (Image *) NULL);
606 assert(image->signature == MagickSignature);
607 if (image->debug != MagickFalse)
608 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
609 if ((image->type == BilevelType) || (image->type == GrayscaleType) ||
610 (image->type == GrayscaleMatteType))
612 if (image->colorspace == CMYKColorspace)
615 image_view=AcquireCacheView(image);
616 for (y=0; y < (ssize_t) image->rows; y++)
618 p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
619 if (p == (const PixelPacket *) NULL)
621 for (x=0; x < (ssize_t) image->columns; x++)
623 if (IsGrayPixel(p) == MagickFalse)
628 if ((type == BilevelType) && (IsMonochromePixel(p) == MagickFalse))
632 if (type == UndefinedType)
635 image_view=DestroyCacheView(image_view);
636 if (type == UndefinedType)
638 ((Image *) image)->type=type;
639 if ((type == GrayscaleType) && (image->matte != MagickFalse))
640 ((Image *) image)->type=GrayscaleMatteType;
645 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
649 % I s M o n o c h r o m e I m a g e %
653 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
655 % IsMonochromeImage() returns MagickTrue if all the pixels in the image have
656 % the same red, green, and blue intensities and the intensity is either
659 % The format of the IsMonochromeImage method is:
661 % MagickBooleanType IsMonochromeImage(const Image *image,
662 % ExceptionInfo *exception)
664 % A description of each parameter follows:
666 % o image: the image.
668 % o exception: return any errors or warnings in this structure.
671 MagickExport MagickBooleanType IsMonochromeImage(const Image *image,
672 ExceptionInfo *exception)
686 register const PixelPacket
689 assert(image != (Image *) NULL);
690 assert(image->signature == MagickSignature);
691 if (image->debug != MagickFalse)
692 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
693 if (image->type == BilevelType)
695 if (image->colorspace == CMYKColorspace)
698 image_view=AcquireCacheView(image);
699 for (y=0; y < (ssize_t) image->rows; y++)
701 p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
702 if (p == (const PixelPacket *) NULL)
704 for (x=0; x < (ssize_t) image->columns; x++)
706 if (IsMonochromePixel(p) == MagickFalse)
713 if (type == UndefinedType)
716 image_view=DestroyCacheView(image_view);
717 if (type == UndefinedType)
719 ((Image *) image)->type=type;
724 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
728 % I s O p a q u e I m a g e %
732 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
734 % IsOpaqueImage() returns MagickTrue if none of the pixels in the image have
735 % an opacity value other than opaque (0).
737 % The format of the IsOpaqueImage method is:
739 % MagickBooleanType IsOpaqueImage(const Image *image,
740 % ExceptionInfo *exception)
742 % A description of each parameter follows:
744 % o image: the image.
746 % o exception: return any errors or warnings in this structure.
749 MagickExport MagickBooleanType IsOpaqueImage(const Image *image,
750 ExceptionInfo *exception)
758 register const PixelPacket
765 Determine if image is opaque.
767 assert(image != (Image *) NULL);
768 assert(image->signature == MagickSignature);
769 if (image->debug != MagickFalse)
770 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
771 if (image->matte == MagickFalse)
773 image_view=AcquireCacheView(image);
774 for (y=0; y < (ssize_t) image->rows; y++)
776 p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
777 if (p == (const PixelPacket *) NULL)
779 for (x=0; x < (ssize_t) image->columns; x++)
781 if (p->opacity != OpaqueOpacity)
785 if (x < (ssize_t) image->columns)
788 image_view=DestroyCacheView(image_view);
789 return(y < (ssize_t) image->rows ? MagickFalse : MagickTrue);
793 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
797 % S e t I m a g e C h a n n e l D e p t h %
801 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
803 % SetImageChannelDepth() sets the depth of the image.
805 % The format of the SetImageChannelDepth method is:
807 % MagickBooleanType SetImageDepth(Image *image,const size_t depth)
808 % MagickBooleanType SetImageChannelDepth(Image *image,
809 % const ChannelType channel,const size_t depth)
811 % A description of each parameter follows:
813 % o image: the image.
815 % o channel: the channel.
817 % o depth: the image depth.
821 static inline Quantum SetPixelDepth(const Quantum pixel,
822 const QuantumAny scale)
824 return((Quantum) (scale*(pixel/scale)));
827 MagickExport MagickBooleanType SetImageDepth(Image *image,
830 return(SetImageChannelDepth(image,AllChannels,depth));
833 MagickExport MagickBooleanType SetImageChannelDepth(Image *image,
834 const ChannelType channel,const size_t depth)
851 assert(image != (Image *) NULL);
852 if (image->debug != MagickFalse)
853 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
854 assert(image->signature == MagickSignature);
855 if (GetImageDepth(image,&image->exception) <= (size_t)
856 MagickMin((double) depth,(double) MAGICKCORE_QUANTUM_DEPTH))
862 Scale pixels to desired depth.
865 scale=QuantumRange/((QuantumAny) QuantumRange >> (MAGICKCORE_QUANTUM_DEPTH-
867 exception=(&image->exception);
868 image_view=AcquireCacheView(image);
869 #if defined(MAGICKCORE_OPENMP_SUPPORT)
870 #pragma omp parallel for schedule(dynamic,4) shared(status)
872 for (y=0; y < (ssize_t) image->rows; y++)
883 if (status == MagickFalse)
885 q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,
887 if (q == (PixelPacket *) NULL)
892 indexes=GetCacheViewAuthenticIndexQueue(image_view);
893 for (x=0; x < (ssize_t) image->columns; x++)
895 if ((channel & RedChannel) != 0)
896 q->red=SetPixelDepth(q->red,scale);
897 if ((channel & GreenChannel) != 0)
898 q->green=SetPixelDepth(q->green,scale);
899 if ((channel & BlueChannel) != 0)
900 q->blue=SetPixelDepth(q->blue,scale);
901 if (((channel & OpacityChannel) != 0) && (image->matte != MagickFalse))
902 q->opacity=SetPixelDepth(q->opacity,scale);
903 if (((channel & IndexChannel) != 0) &&
904 (image->colorspace == CMYKColorspace))
905 indexes[x]=SetPixelDepth(indexes[x],scale);
908 if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
914 image_view=DestroyCacheView(image_view);
915 if (image->storage_class == PseudoClass)
927 range=GetQuantumRange(depth);
928 #if defined(MAGICKCORE_OPENMP_SUPPORT)
929 #pragma omp parallel for schedule(dynamic,4) shared(status)
931 for (i=0; i < (ssize_t) image->colors; i++)
933 if ((channel & RedChannel) != 0)
934 p->red=SetPixelDepth(p->red,scale);
935 if ((channel & GreenChannel) != 0)
936 p->green=SetPixelDepth(p->green,scale);
937 if ((channel & BlueChannel) != 0)
938 p->blue=SetPixelDepth(p->blue,scale);
939 if ((channel & OpacityChannel) != 0)
940 p->opacity=SetPixelDepth(p->opacity,scale);