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 "MagickCore/studio.h"
44 #include "MagickCore/attribute.h"
45 #include "MagickCore/blob.h"
46 #include "MagickCore/blob-private.h"
47 #include "MagickCore/cache.h"
48 #include "MagickCore/cache-view.h"
49 #include "MagickCore/client.h"
50 #include "MagickCore/color.h"
51 #include "MagickCore/color-private.h"
52 #include "MagickCore/colormap.h"
53 #include "MagickCore/colormap-private.h"
54 #include "MagickCore/colorspace.h"
55 #include "MagickCore/composite.h"
56 #include "MagickCore/composite-private.h"
57 #include "MagickCore/constitute.h"
58 #include "MagickCore/draw.h"
59 #include "MagickCore/draw-private.h"
60 #include "MagickCore/effect.h"
61 #include "MagickCore/enhance.h"
62 #include "MagickCore/exception.h"
63 #include "MagickCore/exception-private.h"
64 #include "MagickCore/geometry.h"
65 #include "MagickCore/histogram.h"
66 #include "MagickCore/identify.h"
67 #include "MagickCore/image.h"
68 #include "MagickCore/image-private.h"
69 #include "MagickCore/list.h"
70 #include "MagickCore/log.h"
71 #include "MagickCore/memory_.h"
72 #include "MagickCore/magick.h"
73 #include "MagickCore/monitor.h"
74 #include "MagickCore/monitor-private.h"
75 #include "MagickCore/paint.h"
76 #include "MagickCore/pixel.h"
77 #include "MagickCore/pixel-accessor.h"
78 #include "MagickCore/property.h"
79 #include "MagickCore/quantize.h"
80 #include "MagickCore/quantum-private.h"
81 #include "MagickCore/random_.h"
82 #include "MagickCore/resource_.h"
83 #include "MagickCore/semaphore.h"
84 #include "MagickCore/segment.h"
85 #include "MagickCore/splay-tree.h"
86 #include "MagickCore/string_.h"
87 #include "MagickCore/thread-private.h"
88 #include "MagickCore/threshold.h"
89 #include "MagickCore/transform.h"
90 #include "MagickCore/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 Quantum
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 GetPixelInfo(image,&target[0]);
151 image_view=AcquireCacheView(image);
152 p=GetCacheViewVirtualPixels(image_view,0,0,1,1,exception);
153 if (p == (const Quantum *) NULL)
155 image_view=DestroyCacheView(image_view);
158 SetPixelInfo(image,p,&target[0]);
159 GetPixelInfo(image,&target[1]);
160 p=GetCacheViewVirtualPixels(image_view,(ssize_t) image->columns-1,0,1,1,
162 SetPixelInfo(image,p,&target[1]);
163 GetPixelInfo(image,&target[2]);
164 p=GetCacheViewVirtualPixels(image_view,0,(ssize_t) image->rows-1,1,1,
166 SetPixelInfo(image,p,&target[2]);
168 GetPixelInfo(image,&zero);
169 #if defined(MAGICKCORE_OPENMP_SUPPORT)
170 #pragma omp parallel for schedule(dynamic,4) shared(status)
172 for (y=0; y < (ssize_t) image->rows; y++)
180 register const Quantum
186 if (status == MagickFalse)
188 #if defined(MAGICKCORE_OPENMP_SUPPORT)
189 # pragma omp critical (MagickCore_GetImageBoundingBox)
192 p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
193 if (p == (const Quantum *) NULL)
199 for (x=0; x < (ssize_t) image->columns; x++)
201 SetPixelInfo(image,p,&pixel);
202 if ((x < bounding_box.x) &&
203 (IsFuzzyEquivalencePixelInfo(&pixel,&target[0]) == MagickFalse))
205 if ((x > (ssize_t) bounding_box.width) &&
206 (IsFuzzyEquivalencePixelInfo(&pixel,&target[1]) == MagickFalse))
207 bounding_box.width=(size_t) x;
208 if ((y < bounding_box.y) &&
209 (IsFuzzyEquivalencePixelInfo(&pixel,&target[0]) == MagickFalse))
211 if ((y > (ssize_t) bounding_box.height) &&
212 (IsFuzzyEquivalencePixelInfo(&pixel,&target[2]) == MagickFalse))
213 bounding_box.height=(size_t) y;
214 p+=GetPixelChannels(image);
216 #if defined(MAGICKCORE_OPENMP_SUPPORT)
217 # pragma omp critical (MagickCore_GetImageBoundingBox)
220 if (bounding_box.x < bounds.x)
221 bounds.x=bounding_box.x;
222 if (bounding_box.y < bounds.y)
223 bounds.y=bounding_box.y;
224 if (bounding_box.width > bounds.width)
225 bounds.width=bounding_box.width;
226 if (bounding_box.height > bounds.height)
227 bounds.height=bounding_box.height;
230 image_view=DestroyCacheView(image_view);
231 if ((bounds.width == 0) || (bounds.height == 0))
232 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
233 "GeometryDoesNotContainImage","`%s'",image->filename);
236 bounds.width-=(bounds.x-1);
237 bounds.height-=(bounds.y-1);
243 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
247 % G e t I m a g e D e p t h %
251 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
253 % GetImageDepth() returns the depth of a particular image channel.
255 % The format of the GetImageDepth method is:
257 % size_t GetImageDepth(const Image *image,ExceptionInfo *exception)
259 % A description of each parameter follows:
261 % o image: the image.
263 % o exception: return any errors or warnings in this structure.
266 MagickExport size_t GetImageDepth(const Image *image,
267 ExceptionInfo *exception)
289 assert(image != (Image *) NULL);
290 assert(image->signature == MagickSignature);
291 if (image->debug != MagickFalse)
292 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
293 number_threads=GetOpenMPMaximumThreads();
294 current_depth=(size_t *) AcquireQuantumMemory(number_threads,
295 sizeof(*current_depth));
296 if (current_depth == (size_t *) NULL)
297 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
299 for (id=0; id < (ssize_t) number_threads; id++)
301 if ((image->storage_class == PseudoClass) && (image->matte == MagickFalse))
303 register const PixelPacket
310 #if defined(MAGICKCORE_OPENMP_SUPPORT)
311 #pragma omp parallel for schedule(dynamic,4) shared(status)
313 for (i=0; i < (ssize_t) image->colors; i++)
316 id = GetOpenMPThreadId();
318 if (status == MagickFalse)
320 while (current_depth[id] < MAGICKCORE_QUANTUM_DEPTH)
329 range=GetQuantumRange(current_depth[id]);
330 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
331 status|=p->red != ScaleAnyToQuantum(ScaleQuantumToAny(p->red,
333 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
334 status|=p->green != ScaleAnyToQuantum(ScaleQuantumToAny(p->green,
336 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
337 status|=p->blue != ScaleAnyToQuantum(ScaleQuantumToAny(p->blue,
345 depth=current_depth[0];
346 for (id=1; id < (ssize_t) number_threads; id++)
347 if (depth < current_depth[id])
348 depth=current_depth[id];
349 current_depth=(size_t *) RelinquishMagickMemory(current_depth);
352 image_view=AcquireCacheView(image);
353 #if defined(MAGICKCORE_OPENMP_SUPPORT)
354 #pragma omp parallel for schedule(dynamic,4) shared(status)
356 for (y=0; y < (ssize_t) image->rows; y++)
359 id = GetOpenMPThreadId();
361 register const Quantum
367 if (status == MagickFalse)
369 p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
370 if (p == (const Quantum *) NULL)
372 for (x=0; x < (ssize_t) image->columns; x++)
374 while (current_depth[id] < MAGICKCORE_QUANTUM_DEPTH)
383 range=GetQuantumRange(current_depth[id]);
384 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
385 status|=GetPixelRed(image,p) != ScaleAnyToQuantum(ScaleQuantumToAny(
386 GetPixelRed(image,p),range),range);
387 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
388 status|=GetPixelGreen(image,p) != ScaleAnyToQuantum(ScaleQuantumToAny(
389 GetPixelGreen(image,p),range),range);
390 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
391 status|=GetPixelBlue(image,p) != ScaleAnyToQuantum(ScaleQuantumToAny(
392 GetPixelBlue(image,p),range),range);
393 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
394 (image->matte != MagickFalse))
395 status|=GetPixelAlpha(image,p) != ScaleAnyToQuantum(ScaleQuantumToAny(
396 GetPixelAlpha(image,p),range),range);
397 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
398 (image->colorspace == CMYKColorspace))
399 status|=GetPixelBlack(image,p) != ScaleAnyToQuantum(ScaleQuantumToAny(
400 GetPixelBlack(image,p),range),range);
405 p+=GetPixelChannels(image);
407 if (current_depth[id] == MAGICKCORE_QUANTUM_DEPTH)
410 image_view=DestroyCacheView(image_view);
411 depth=current_depth[0];
412 for (id=1; id < (ssize_t) number_threads; id++)
413 if (depth < current_depth[id])
414 depth=current_depth[id];
415 current_depth=(size_t *) RelinquishMagickMemory(current_depth);
420 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
424 % G e t I m a g e Q u a n t u m D e p t h %
428 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
430 % GetImageQuantumDepth() returns the depth of the image rounded to a legal
431 % quantum depth: 8, 16, or 32.
433 % The format of the GetImageQuantumDepth method is:
435 % size_t GetImageQuantumDepth(const Image *image,
436 % const MagickBooleanType constrain)
438 % A description of each parameter follows:
440 % o image: the image.
442 % o constrain: A value other than MagickFalse, constrains the depth to
443 % a maximum of MAGICKCORE_QUANTUM_DEPTH.
447 static inline double MagickMin(const double x,const double y)
454 MagickExport size_t GetImageQuantumDepth(const Image *image,
455 const MagickBooleanType constrain)
472 if (constrain != MagickFalse)
473 depth=(size_t) MagickMin((double) depth,(double)
474 MAGICKCORE_QUANTUM_DEPTH);
479 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
483 % G e t I m a g e T y p e %
487 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
489 % GetImageType() returns the potential type of image:
491 % Bilevel Grayscale GrayscaleMatte
492 % Palette PaletteMatte TrueColor
493 % TrueColorMatte ColorSeparation ColorSeparationMatte
495 % To ensure the image type matches its potential, use SetImageType():
497 % (void) SetImageType(image,GetImageType(image));
499 % The format of the GetImageType method is:
501 % ImageType GetImageType(const Image *image,ExceptionInfo *exception)
503 % A description of each parameter follows:
505 % o image: the image.
507 % o exception: return any errors or warnings in this structure.
510 MagickExport ImageType GetImageType(const Image *image,ExceptionInfo *exception)
512 assert(image != (Image *) NULL);
513 assert(image->signature == MagickSignature);
514 if (image->debug != MagickFalse)
515 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
516 if (image->colorspace == CMYKColorspace)
518 if (image->matte == MagickFalse)
519 return(ColorSeparationType);
520 return(ColorSeparationMatteType);
522 if (IsImageMonochrome(image,exception) != MagickFalse)
524 if (IsImageGray(image,exception) != MagickFalse)
526 if (image->matte != MagickFalse)
527 return(GrayscaleMatteType);
528 return(GrayscaleType);
530 if (IsPaletteImage(image,exception) != MagickFalse)
532 if (image->matte != MagickFalse)
533 return(PaletteMatteType);
536 if (image->matte != MagickFalse)
537 return(TrueColorMatteType);
538 return(TrueColorType);
542 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
546 % I s I m a g e G r a y %
550 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
552 % IsImageGray() returns MagickTrue if all the pixels in the image have the
553 % same red, green, and blue intensities.
555 % The format of the IsImageGray method is:
557 % MagickBooleanType IsImageGray(const Image *image,
558 % ExceptionInfo *exception)
560 % A description of each parameter follows:
562 % o image: the image.
564 % o exception: return any errors or warnings in this structure.
567 MagickExport MagickBooleanType IsImageGray(const Image *image,
568 ExceptionInfo *exception)
576 register const Quantum
585 assert(image != (Image *) NULL);
586 assert(image->signature == MagickSignature);
587 if (image->debug != MagickFalse)
588 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
589 if ((image->type == BilevelType) || (image->type == GrayscaleType) ||
590 (image->type == GrayscaleMatteType))
592 if (image->colorspace == CMYKColorspace)
595 image_view=AcquireCacheView(image);
596 for (y=0; y < (ssize_t) image->rows; y++)
598 p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
599 if (p == (const Quantum *) NULL)
601 for (x=0; x < (ssize_t) image->columns; x++)
603 if (IsPixelGray(image,p) == MagickFalse)
608 if ((type == BilevelType) &&
609 (IsPixelMonochrome(image,p) == MagickFalse))
611 p+=GetPixelChannels(image);
613 if (type == UndefinedType)
616 image_view=DestroyCacheView(image_view);
617 if (type == UndefinedType)
619 ((Image *) image)->type=type;
620 if ((type == GrayscaleType) && (image->matte != MagickFalse))
621 ((Image *) image)->type=GrayscaleMatteType;
626 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
630 % I s I m a g e M o n o c h r o m e %
634 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
636 % IsImageMonochrome() returns MagickTrue if all the pixels in the image have
637 % the same red, green, and blue intensities and the intensity is either
640 % The format of the IsImageMonochrome method is:
642 % MagickBooleanType IsImageMonochrome(const Image *image,
643 % ExceptionInfo *exception)
645 % A description of each parameter follows:
647 % o image: the image.
649 % o exception: return any errors or warnings in this structure.
652 MagickExport MagickBooleanType IsImageMonochrome(const Image *image,
653 ExceptionInfo *exception)
664 register const Quantum
670 assert(image != (Image *) NULL);
671 assert(image->signature == MagickSignature);
672 if (image->debug != MagickFalse)
673 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
674 if (image->type == BilevelType)
676 if (image->colorspace == CMYKColorspace)
679 image_view=AcquireCacheView(image);
680 for (y=0; y < (ssize_t) image->rows; y++)
682 p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
683 if (p == (const Quantum *) NULL)
685 for (x=0; x < (ssize_t) image->columns; x++)
687 if (IsPixelMonochrome(image,p) == MagickFalse)
692 p+=GetPixelChannels(image);
694 if (type == UndefinedType)
697 image_view=DestroyCacheView(image_view);
698 if (type == UndefinedType)
700 ((Image *) image)->type=type;
705 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
709 % I s I m a g e O p a q u e %
713 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
715 % IsImageOpaque() returns MagickTrue if none of the pixels in the image have
716 % an opacity value other than opaque (0).
718 % The format of the IsImageOpaque method is:
720 % MagickBooleanType IsImageOpaque(const Image *image,
721 % ExceptionInfo *exception)
723 % A description of each parameter follows:
725 % o image: the image.
727 % o exception: return any errors or warnings in this structure.
730 MagickExport MagickBooleanType IsImageOpaque(const Image *image,
731 ExceptionInfo *exception)
736 register const Quantum
746 Determine if image is opaque.
748 assert(image != (Image *) NULL);
749 assert(image->signature == MagickSignature);
750 if (image->debug != MagickFalse)
751 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
752 if (image->matte == MagickFalse)
754 image_view=AcquireCacheView(image);
755 for (y=0; y < (ssize_t) image->rows; y++)
757 p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
758 if (p == (const Quantum *) NULL)
760 for (x=0; x < (ssize_t) image->columns; x++)
762 if (GetPixelAlpha(image,p) != OpaqueAlpha)
764 p+=GetPixelChannels(image);
766 if (x < (ssize_t) image->columns)
769 image_view=DestroyCacheView(image_view);
770 return(y < (ssize_t) image->rows ? MagickFalse : MagickTrue);
774 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
778 % S e t I m a g e D e p t h %
782 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
784 % SetImageDepth() sets the depth of the image.
786 % The format of the SetImageDepth method is:
788 % MagickBooleanType SetImageDepth(Image *image,const size_t depth)
789 % MagickBooleanType SetImageDepth(Image *image,
790 % const ChannelType channel,const size_t depth)
792 % A description of each parameter follows:
794 % o image: the image.
796 % o channel: the channel.
798 % o depth: the image depth.
801 MagickExport MagickBooleanType SetImageDepth(Image *image,
819 assert(image != (Image *) NULL);
820 if (image->debug != MagickFalse)
821 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
822 assert(image->signature == MagickSignature);
823 if (GetImageDepth(image,&image->exception) <= (size_t)
824 MagickMin((double) depth,(double) MAGICKCORE_QUANTUM_DEPTH))
830 Scale pixels to desired depth.
833 range=GetQuantumRange(depth);
834 exception=(&image->exception);
835 image_view=AcquireCacheView(image);
836 #if defined(MAGICKCORE_OPENMP_SUPPORT)
837 #pragma omp parallel for schedule(dynamic,4) shared(status)
839 for (y=0; y < (ssize_t) image->rows; y++)
847 if (status == MagickFalse)
849 q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,
851 if (q == (Quantum *) NULL)
856 for (x=0; x < (ssize_t) image->columns; x++)
858 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
859 SetPixelRed(image,ScaleAnyToQuantum(ScaleQuantumToAny(
860 GetPixelRed(image,q),range),range),q);
861 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
862 SetPixelGreen(image,ScaleAnyToQuantum(ScaleQuantumToAny(
863 GetPixelGreen(image,q),range),range),q);
864 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
865 SetPixelBlue(image,ScaleAnyToQuantum(ScaleQuantumToAny(
866 GetPixelBlue(image,q),range),range),q);
867 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
868 (image->colorspace == CMYKColorspace))
869 SetPixelBlack(image,ScaleAnyToQuantum(ScaleQuantumToAny(
870 GetPixelBlack(image,q),range),range),q);
871 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
872 (image->matte != MagickFalse))
873 SetPixelAlpha(image,ScaleAnyToQuantum(ScaleQuantumToAny(
874 GetPixelAlpha(image,q),range),range),q);
875 q+=GetPixelChannels(image);
877 if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
883 image_view=DestroyCacheView(image_view);
884 if (image->storage_class == PseudoClass)
893 #if defined(MAGICKCORE_OPENMP_SUPPORT)
894 #pragma omp parallel for schedule(dynamic,4) shared(status)
896 for (i=0; i < (ssize_t) image->colors; i++)
898 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
899 p->red=ScaleAnyToQuantum(ScaleQuantumToAny(p->red,range),range);
900 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
901 p->green=ScaleAnyToQuantum(ScaleQuantumToAny(p->green,range),range);
902 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
903 p->blue=ScaleAnyToQuantum(ScaleQuantumToAny(p->blue,range),range);
904 if ((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0)
905 p->alpha=ScaleAnyToQuantum(ScaleQuantumToAny(p->alpha,range),range);