pixel-wand.c

Go to the documentation of this file.
00001 /*
00002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00003 %                                                                             %
00004 %                                                                             %
00005 %                                                                             %
00006 %                      PPPP   IIIII  X   X  EEEEE  L                          %
00007 %                      P   P    I     X X   E      L                          %
00008 %                      PPPP     I      X    EEE    L                          %
00009 %                      P        I     X X   E      L                          %
00010 %                      P      IIIII  X   X  EEEEE  LLLLL                      %
00011 %                                                                             %
00012 %                         W   W   AAA   N   N  DDDD                           %
00013 %                         W   W  A   A  NN  N  D   D                          %
00014 %                         W W W  AAAAA  N N N  D   D                          %
00015 %                         WW WW  A   A  N  NN  D   D                          %
00016 %                         W   W  A   A  N   N  DDDD                           %
00017 %                                                                             %
00018 %                                                                             %
00019 %                    MagickWand Image Pixel Wand Methods                      %
00020 %                                                                             %
00021 %                              Software Design                                %
00022 %                                John Cristy                                  %
00023 %                                March 2003                                   %
00024 %                                                                             %
00025 %                                                                             %
00026 %  Copyright 1999-2008 ImageMagick Studio LLC, a non-profit organization      %
00027 %  dedicated to making software imaging solutions freely available.           %
00028 %                                                                             %
00029 %  You may not use this file except in compliance with the License.  You may  %
00030 %  obtain a copy of the License at                                            %
00031 %                                                                             %
00032 %    http://www.imagemagick.org/script/license.php                            %
00033 %                                                                             %
00034 %  Unless required by applicable law or agreed to in writing, software        %
00035 %  distributed under the License is distributed on an "AS IS" BASIS,          %
00036 %  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   %
00037 %  See the License for the specific language governing permissions and        %
00038 %  limitations under the License.                                             %
00039 %                                                                             %
00040 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00041 %
00042 %
00043 %
00044 */
00045 
00046 /*
00047   Include declarations.
00048 */
00049 #include "wand/studio.h"
00050 #include "wand/MagickWand.h"
00051 #include "wand/magick-wand-private.h"
00052 #include "wand/pixel-wand-private.h"
00053 #include "wand/wand.h"
00054 
00055 /*
00056   Define declarations.
00057 */
00058 #define PixelWandId  "PixelWand"
00059 
00060 /*
00061   Typedef declarations.
00062 */
00063 struct _PixelWand
00064 {
00065   unsigned long
00066     id;
00067 
00068   char
00069     name[MaxTextExtent];
00070 
00071   ExceptionInfo
00072     *exception;
00073 
00074   MagickPixelPacket
00075     pixel;
00076 
00077   unsigned long
00078     count;
00079 
00080   MagickBooleanType
00081     debug;
00082 
00083   unsigned long
00084     signature;
00085 };
00086 
00087 /*
00088 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00089 %                                                                             %
00090 %                                                                             %
00091 %                                                                             %
00092 %   C l e a r P i x e l W a n d                                               %
00093 %                                                                             %
00094 %                                                                             %
00095 %                                                                             %
00096 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00097 %
00098 %  ClearPixelWand() clears resources associated with the wand.
00099 %
00100 %  The format of the ClearPixelWand method is:
00101 %
00102 %      void ClearPixelWand(PixelWand *wand)
00103 %
00104 %  A description of each parameter follows:
00105 %
00106 %    o wand: the pixel wand.
00107 %
00108 */
00109 WandExport void ClearPixelWand(PixelWand *wand)
00110 {
00111   assert(wand != (PixelWand *) NULL);
00112   assert(wand->signature == WandSignature);
00113   if (wand->debug != MagickFalse)
00114     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
00115   ClearMagickException(wand->exception);
00116   wand->pixel.colorspace=RGBColorspace;
00117   wand->debug=IsEventLogging();
00118 }
00119 
00120 /*
00121 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00122 %                                                                             %
00123 %                                                                             %
00124 %                                                                             %
00125 %   C l o n e P i x e l W a n d                                               %
00126 %                                                                             %
00127 %                                                                             %
00128 %                                                                             %
00129 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00130 %
00131 %  ClonePixelWand() makes an exact copy of the specified wand.
00132 %
00133 %  The format of the ClonePixelWand method is:
00134 %
00135 %      PixelWand *ClonePixelWand(const PixelWand *wand)
00136 %
00137 %  A description of each parameter follows:
00138 %
00139 %    o wand: the magick wand.
00140 %
00141 */
00142 WandExport PixelWand *ClonePixelWand(const PixelWand *wand)
00143 {
00144   PixelWand
00145     *clone_wand;
00146 
00147   assert(wand != (PixelWand *) NULL);
00148   assert(wand->signature == WandSignature);
00149   if (wand->debug != MagickFalse)
00150     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
00151   clone_wand=(PixelWand *) AcquireMagickMemory(sizeof(*clone_wand));
00152   if (clone_wand == (PixelWand *) NULL)
00153     ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed",
00154       wand->name);
00155   (void) ResetMagickMemory(clone_wand,0,sizeof(*clone_wand));
00156   clone_wand->id=AcquireWandId();
00157   (void) FormatMagickString(clone_wand->name,MaxTextExtent,"%s-%lu",PixelWandId,
00158     clone_wand->id);
00159   clone_wand->exception=AcquireExceptionInfo();
00160   InheritException(clone_wand->exception,wand->exception);
00161   clone_wand->pixel=wand->pixel;
00162   clone_wand->count=wand->count;
00163   clone_wand->debug=IsEventLogging();
00164   if (clone_wand->debug != MagickFalse)
00165     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",clone_wand->name);
00166   clone_wand->signature=WandSignature;
00167   return(clone_wand);
00168 }
00169 
00170 /*
00171 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00172 %                                                                             %
00173 %                                                                             %
00174 %                                                                             %
00175 %   C l o n e P i x e l W a n d s                                             %
00176 %                                                                             %
00177 %                                                                             %
00178 %                                                                             %
00179 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00180 %
00181 %  ClonePixelWands() makes an exact copy of the specified wands.
00182 %
00183 %  The format of the ClonePixelWands method is:
00184 %
00185 %      PixelWand **ClonePixelWands(const PixelWand **wands,
00186 %        const unsigned long number_wands)
00187 %
00188 %  A description of each parameter follows:
00189 %
00190 %    o wands: the magick wands.
00191 %
00192 %    o number_wands: the number of wands.
00193 %
00194 */
00195 WandExport PixelWand **ClonePixelWands(const PixelWand **wands,
00196   const unsigned long number_wands)
00197 {
00198   register long
00199     i;
00200 
00201   PixelWand
00202     **clone_wands;
00203 
00204   clone_wands=(PixelWand **) AcquireQuantumMemory((size_t) number_wands,
00205     sizeof(*clone_wands));
00206   if (clone_wands == (PixelWand **) NULL)
00207     ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed",
00208       strerror(errno));
00209   for (i=0; i < (long) number_wands; i++)
00210     clone_wands[i]=ClonePixelWand(wands[i]);
00211   return(clone_wands);
00212 }
00213 
00214 /*
00215 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00216 %                                                                             %
00217 %                                                                             %
00218 %                                                                             %
00219 %   D e s t r o y P i x e l W a n d                                           %
00220 %                                                                             %
00221 %                                                                             %
00222 %                                                                             %
00223 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00224 %
00225 %  DestroyPixelWand() deallocates resources associated with a PixelWand.
00226 %
00227 %  The format of the DestroyPixelWand method is:
00228 %
00229 %      PixelWand *DestroyPixelWand(PixelWand *wand)
00230 %
00231 %  A description of each parameter follows:
00232 %
00233 %    o wand: the pixel wand.
00234 %
00235 */
00236 WandExport PixelWand *DestroyPixelWand(PixelWand *wand)
00237 {
00238   assert(wand != (PixelWand *) NULL);
00239   assert(wand->signature == WandSignature);
00240   if (wand->debug != MagickFalse)
00241     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
00242   wand->exception=DestroyExceptionInfo(wand->exception);
00243   wand->signature=(~WandSignature);
00244   RelinquishWandId(wand->id);
00245   wand=(PixelWand *) RelinquishMagickMemory(wand);
00246   return(wand);
00247 }
00248 
00249 /*
00250 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00251 %                                                                             %
00252 %                                                                             %
00253 %                                                                             %
00254 %   D e s t r o y P i x e l W a n d s                                         %
00255 %                                                                             %
00256 %                                                                             %
00257 %                                                                             %
00258 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00259 %
00260 %  DestroyPixelWands() deallocates resources associated with an array of
00261 %  pixel wands.
00262 %
00263 %  The format of the DestroyPixelWands method is:
00264 %
00265 %      PixelWand **DestroyPixelWands(PixelWand **wand,
00266 %        const unsigned long number_wands)
00267 %
00268 %  A description of each parameter follows:
00269 %
00270 %    o wand: the pixel wand.
00271 %
00272 %    o number_wands: the number of wands.
00273 %
00274 */
00275 WandExport PixelWand **DestroyPixelWands(PixelWand **wand,
00276   const unsigned long number_wands)
00277 {
00278   register long
00279     i;
00280 
00281   assert(wand != (PixelWand **) NULL);
00282   assert(*wand != (PixelWand *) NULL);
00283   assert((*wand)->signature == WandSignature);
00284   if ((*wand)->debug != MagickFalse)
00285     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",(*wand)->name);
00286   for (i=(long) number_wands-1; i >= 0; i--)
00287     wand[i]=DestroyPixelWand(wand[i]);
00288   wand=(PixelWand **) RelinquishMagickMemory(wand);
00289   return(wand);
00290 }
00291 
00292 /*
00293 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00294 %                                                                             %
00295 %                                                                             %
00296 %                                                                             %
00297 %   I s P i x e l W a n d S i m i l a r                                       %
00298 %                                                                             %
00299 %                                                                             %
00300 %                                                                             %
00301 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00302 %
00303 %  IsPixelWandSimilar() returns MagickTrue if the distance between two
00304 %  colors is less than the specified distance.
00305 %
00306 %  The format of the IsPixelWandSimilar method is:
00307 %
00308 %      MagickBooleanType IsPixelWandSimilar(PixelWand *p,PixelWand *q,
00309 %        const double fuzz)
00310 %
00311 %  A description of each parameter follows:
00312 %
00313 %    o p: the pixel wand.
00314 %
00315 %    o q: the pixel wand.
00316 %
00317 %    o fuzz: any two colors that are less than or equal to this distance
00318 %      squared are consider similar.
00319 %
00320 */
00321 WandExport MagickBooleanType IsPixelWandSimilar(PixelWand *p,PixelWand *q,
00322   const double fuzz)
00323 {
00324   assert(p != (PixelWand *) NULL);
00325   assert(p->signature == WandSignature);
00326   if (p->debug != MagickFalse)
00327     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",p->name);
00328   assert(q != (PixelWand *) NULL);
00329   assert(q->signature == WandSignature);
00330   if (q->debug != MagickFalse)
00331     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",q->name);
00332   p->pixel.fuzz=fuzz;
00333   q->pixel.fuzz=fuzz;
00334   return(IsMagickColorSimilar(&p->pixel,&q->pixel));
00335 }
00336 
00337 /*
00338 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00339 %                                                                             %
00340 %                                                                             %
00341 %                                                                             %
00342 %   I s P i x e l W a n d                                                     %
00343 %                                                                             %
00344 %                                                                             %
00345 %                                                                             %
00346 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00347 %
00348 %  IsPixelWand() returns MagickTrue if the wand is verified as a pixel wand.
00349 %
00350 %  The format of the IsPixelWand method is:
00351 %
00352 %      MagickBooleanType IsPixelWand(const PixelWand *wand)
00353 %
00354 %  A description of each parameter follows:
00355 %
00356 %    o wand: the magick wand.
00357 %
00358 */
00359 WandExport MagickBooleanType IsPixelWand(const PixelWand *wand)
00360 {
00361   if (wand == (const PixelWand *) NULL)
00362     return(MagickFalse);
00363   if (wand->signature != WandSignature)
00364     return(MagickFalse);
00365   if (LocaleNCompare(wand->name,PixelWandId,strlen(PixelWandId)) != 0)
00366     return(MagickFalse);
00367   return(MagickTrue);
00368 }
00369 
00370 /*
00371 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00372 %                                                                             %
00373 %                                                                             %
00374 %                                                                             %
00375 %   N e w P i x e l W a n d                                                   %
00376 %                                                                             %
00377 %                                                                             %
00378 %                                                                             %
00379 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00380 %
00381 %  NewPixelWand() returns a new pixel wand.
00382 %
00383 %  The format of the NewPixelWand method is:
00384 %
00385 %      PixelWand *NewPixelWand(void)
00386 %
00387 */
00388 WandExport PixelWand *NewPixelWand(void)
00389 {
00390   const char
00391     *quantum;
00392 
00393   PixelWand
00394     *wand;
00395 
00396   unsigned long
00397     depth;
00398 
00399   depth=MAGICKCORE_QUANTUM_DEPTH;
00400   quantum=GetMagickQuantumDepth(&depth);
00401   if (depth != MAGICKCORE_QUANTUM_DEPTH)
00402     ThrowWandFatalException(WandError,"QuantumDepthMismatch",quantum);
00403   wand=(PixelWand *) AcquireMagickMemory(sizeof(*wand));
00404   if (wand == (PixelWand *) NULL)
00405     ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed",
00406       strerror(errno));
00407   (void) ResetMagickMemory(wand,0,sizeof(*wand));
00408   wand->id=AcquireWandId();
00409   (void) FormatMagickString(wand->name,MaxTextExtent,"%s-%lu",PixelWandId,
00410     wand->id);
00411   wand->exception=AcquireExceptionInfo();
00412   GetMagickPixelPacket((Image *) NULL,&wand->pixel);
00413   wand->debug=IsEventLogging();
00414   if (wand->debug != MagickFalse)
00415     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
00416   wand->signature=WandSignature;
00417   return(wand);
00418 }
00419 
00420 /*
00421 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00422 %                                                                             %
00423 %                                                                             %
00424 %                                                                             %
00425 %   N e w P i x e l W a n d s                                                 %
00426 %                                                                             %
00427 %                                                                             %
00428 %                                                                             %
00429 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00430 %
00431 %  NewPixelWands() returns an array of pixel wands.
00432 %
00433 %  The format of the NewPixelWands method is:
00434 %
00435 %      PixelWand **NewPixelWands(const unsigned long number_wands)
00436 %
00437 %  A description of each parameter follows:
00438 %
00439 %    o number_wands: the number of wands.
00440 %
00441 */
00442 WandExport PixelWand **NewPixelWands(const unsigned long number_wands)
00443 {
00444   register long
00445     i;
00446 
00447   PixelWand
00448     **wands;
00449 
00450   wands=(PixelWand **) AcquireQuantumMemory((size_t) number_wands,
00451     sizeof(*wands));
00452   if (wands == (PixelWand **) NULL)
00453     ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed",
00454       strerror(errno));
00455   for (i=0; i < (long) number_wands; i++)
00456     wands[i]=NewPixelWand();
00457   return(wands);
00458 }
00459 
00460 /*
00461 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00462 %                                                                             %
00463 %                                                                             %
00464 %                                                                             %
00465 %   P i x e l C l e a r E x c e p t i o n                                     %
00466 %                                                                             %
00467 %                                                                             %
00468 %                                                                             %
00469 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00470 %
00471 %  PixelClearException() clear any exceptions associated with the iterator.
00472 %
00473 %  The format of the PixelClearException method is:
00474 %
00475 %      MagickBooleanType PixelClearException(PixelWand *wand)
00476 %
00477 %  A description of each parameter follows:
00478 %
00479 %    o wand: the pixel wand.
00480 %
00481 */
00482 WandExport MagickBooleanType PixelClearException(PixelWand *wand)
00483 {
00484   assert(wand != (PixelWand *) NULL);
00485   assert(wand->signature == WandSignature);
00486   if (wand->debug != MagickFalse)
00487     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
00488   ClearMagickException(wand->exception);
00489   return(MagickTrue);
00490 }
00491 
00492 /*
00493 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00494 %                                                                             %
00495 %                                                                             %
00496 %                                                                             %
00497 %   P i x e l G e t A l p h a                                                 %
00498 %                                                                             %
00499 %                                                                             %
00500 %                                                                             %
00501 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00502 %
00503 %  PixelGetAlpha() returns the normalized alpha color of the pixel wand.
00504 %
00505 %  The format of the PixelGetAlpha method is:
00506 %
00507 %      double PixelGetAlpha(const PixelWand *wand)
00508 %
00509 %  A description of each parameter follows:
00510 %
00511 %    o wand: the pixel wand.
00512 %
00513 */
00514 WandExport double PixelGetAlpha(const PixelWand *wand)
00515 {
00516   assert(wand != (const PixelWand *) NULL);
00517   assert(wand->signature == WandSignature);
00518   if (wand->debug != MagickFalse)
00519     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
00520   return((double) QuantumScale*(QuantumRange-wand->pixel.opacity));
00521 }
00522 
00523 /*
00524 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00525 %                                                                             %
00526 %                                                                             %
00527 %                                                                             %
00528 %   P i x e l G e t A l p h a Q u a n t u m                                   %
00529 %                                                                             %
00530 %                                                                             %
00531 %                                                                             %
00532 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00533 %
00534 %  PixelGetAlphaQuantum() returns the alpha value of the pixel wand.
00535 %
00536 %  The format of the PixelGetAlphaQuantum method is:
00537 %
00538 %      Quantum PixelGetAlphaQuantum(const PixelWand *wand)
00539 %
00540 %  A description of each parameter follows:
00541 %
00542 %    o wand: the pixel wand.
00543 %
00544 */
00545 WandExport Quantum PixelGetAlphaQuantum(const PixelWand *wand)
00546 {
00547   assert(wand != (const PixelWand *) NULL);
00548   assert(wand->signature == WandSignature);
00549   if (wand->debug != MagickFalse)
00550     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
00551   return((Quantum) QuantumRange-RoundToQuantum(wand->pixel.opacity));
00552 }
00553 
00554 /*
00555 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00556 %                                                                             %
00557 %                                                                             %
00558 %                                                                             %
00559 %   P i x e l G e t B l a c k                                                 %
00560 %                                                                             %
00561 %                                                                             %
00562 %                                                                             %
00563 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00564 %
00565 %  PixelGetBlack() returns the normalized black color of the pixel wand.
00566 %
00567 %  The format of the PixelGetBlack method is:
00568 %
00569 %      double PixelGetBlack(const PixelWand *wand)
00570 %
00571 %  A description of each parameter follows:
00572 %
00573 %    o wand: the pixel wand.
00574 %
00575 */
00576 WandExport double PixelGetBlack(const PixelWand *wand)
00577 {
00578   assert(wand != (const PixelWand *) NULL);
00579   assert(wand->signature == WandSignature);
00580   if (wand->debug != MagickFalse)
00581     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
00582   return((double) QuantumScale*wand->pixel.index);
00583 }
00584 
00585 /*
00586 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00587 %                                                                             %
00588 %                                                                             %
00589 %                                                                             %
00590 %   P i x e l G e t B l a c k Q u a n t u m                                   %
00591 %                                                                             %
00592 %                                                                             %
00593 %                                                                             %
00594 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00595 %
00596 %  PixelGetBlackQuantum() returns the black color of the pixel wand.
00597 %
00598 %  The format of the PixelGetBlackQuantum method is:
00599 %
00600 %      Quantum PixelGetBlackQuantum(const PixelWand *wand)
00601 %
00602 %  A description of each parameter follows:
00603 %
00604 %    o wand: the pixel wand.
00605 %
00606 */
00607 WandExport Quantum PixelGetBlackQuantum(const PixelWand *wand)
00608 {
00609   assert(wand != (const PixelWand *) NULL);
00610   assert(wand->signature == WandSignature);
00611   if (wand->debug != MagickFalse)
00612     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
00613   return(RoundToQuantum(wand->pixel.index));
00614 }
00615 
00616 /*
00617 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00618 %                                                                             %
00619 %                                                                             %
00620 %                                                                             %
00621 %   P i x e l G e t B l u e                                                   %
00622 %                                                                             %
00623 %                                                                             %
00624 %                                                                             %
00625 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00626 %
00627 %  PixelGetBlue() returns the normalized blue color of the pixel wand.
00628 %
00629 %  The format of the PixelGetBlue method is:
00630 %
00631 %      double PixelGetBlue(const PixelWand *wand)
00632 %
00633 %  A description of each parameter follows:
00634 %
00635 %    o wand: the pixel wand.
00636 %
00637 */
00638 WandExport double PixelGetBlue(const PixelWand *wand)
00639 {
00640   assert(wand != (const PixelWand *) NULL);
00641   assert(wand->signature == WandSignature);
00642   if (wand->debug != MagickFalse)
00643     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
00644   return((double) QuantumScale*wand->pixel.blue);
00645 }
00646 
00647 /*
00648 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00649 %                                                                             %
00650 %                                                                             %
00651 %                                                                             %
00652 %   P i x e l G e t B l u e Q u a n t u m                                     %
00653 %                                                                             %
00654 %                                                                             %
00655 %                                                                             %
00656 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00657 %
00658 %  PixelGetBlueQuantum() returns the blue color of the pixel wand.
00659 %
00660 %  The format of the PixelGetBlueQuantum method is:
00661 %
00662 %      Quantum PixelGetBlueQuantum(const PixelWand *wand)
00663 %
00664 %  A description of each parameter follows:
00665 %
00666 %    o wand: the pixel wand.
00667 %
00668 */
00669 WandExport Quantum PixelGetBlueQuantum(const PixelWand *wand)
00670 {
00671   assert(wand != (const PixelWand *) NULL);
00672   assert(wand->signature == WandSignature);
00673   if (wand->debug != MagickFalse)
00674     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
00675   return(RoundToQuantum(wand->pixel.blue));
00676 }
00677 
00678 /*
00679 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00680 %                                                                             %
00681 %                                                                             %
00682 %                                                                             %
00683 %   P i x e l G e t C o l o r A s S t r i n g                                 %
00684 %                                                                             %
00685 %                                                                             %
00686 %                                                                             %
00687 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00688 %
00689 %  PixelGetColorAsString() returnsd the color of the pixel wand as a string.
00690 %
00691 %  The format of the PixelGetColorAsString method is:
00692 %
00693 %      char *PixelGetColorAsString(PixelWand *wand)
00694 %
00695 %  A description of each parameter follows:
00696 %
00697 %    o wand: the pixel wand.
00698 %
00699 */
00700 WandExport char *PixelGetColorAsString(const PixelWand *wand)
00701 {
00702   char
00703     *color;
00704 
00705   MagickPixelPacket
00706     pixel;
00707 
00708   assert(wand != (const PixelWand *) NULL);
00709   assert(wand->signature == WandSignature);
00710   if (wand->debug != MagickFalse)
00711     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
00712   pixel=wand->pixel;
00713   color=AcquireString((const char *) NULL);
00714   GetColorTuple(&pixel,MagickFalse,color);
00715   return(color);
00716 }
00717 
00718 /*
00719 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00720 %                                                                             %
00721 %                                                                             %
00722 %                                                                             %
00723 %   P i x e l G e t C o l o r A s N o r m a l i z e d S t r i n g             %
00724 %                                                                             %
00725 %                                                                             %
00726 %                                                                             %
00727 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00728 %
00729 %  PixelGetColorAsNormalizedString() returns the normalized color of the pixel
00730 %  wand as a string.
00731 %
00732 %  The format of the PixelGetColorAsNormalizedString method is:
00733 %
00734 %      char *PixelGetColorAsNormalizedString(PixelWand *wand)
00735 %
00736 %  A description of each parameter follows:
00737 %
00738 %    o wand: the pixel wand.
00739 %
00740 */
00741 WandExport char *PixelGetColorAsNormalizedString(const PixelWand *wand)
00742 {
00743   char
00744     color[MaxTextExtent];
00745 
00746   assert(wand != (const PixelWand *) NULL);
00747   assert(wand->signature == WandSignature);
00748   if (wand->debug != MagickFalse)
00749     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
00750   (void) FormatMagickString(color,MaxTextExtent,"%g,%g,%g",
00751     (double) (QuantumScale*wand->pixel.red),
00752     (double) (QuantumScale*wand->pixel.green),
00753     (double) (QuantumScale*wand->pixel.blue));
00754   if (wand->pixel.colorspace == CMYKColorspace)
00755     (void) FormatMagickString(color+strlen(color),MaxTextExtent,",%g",
00756       (double) (QuantumScale*wand->pixel.index));
00757   if (wand->pixel.matte != MagickFalse)
00758     (void) FormatMagickString(color+strlen(color),MaxTextExtent,",%g",
00759       (double) (QuantumScale*wand->pixel.opacity));
00760   return(ConstantString(color));
00761 }
00762 
00763 /*
00764 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00765 %                                                                             %
00766 %                                                                             %
00767 %                                                                             %
00768 %   P i x e l G e t C o l o r C o u n t                                       %
00769 %                                                                             %
00770 %                                                                             %
00771 %                                                                             %
00772 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00773 %
00774 %  PixelGetColorCount() returns the color count associated with this color.
00775 %
00776 %  The format of the PixelGetColorCount method is:
00777 %
00778 %      unsigned long PixelGetColorCount(const PixelWand *wand)
00779 %
00780 %  A description of each parameter follows:
00781 %
00782 %    o wand: the pixel wand.
00783 %
00784 */
00785 WandExport unsigned long PixelGetColorCount(const PixelWand *wand)
00786 {
00787   assert(wand != (const PixelWand *) NULL);
00788   assert(wand->signature == WandSignature);
00789   if (wand->debug != MagickFalse)
00790     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
00791   return(wand->count);
00792 }
00793 
00794 /*
00795 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00796 %                                                                             %
00797 %                                                                             %
00798 %                                                                             %
00799 %   P i x e l G e t C y a n                                                   %
00800 %                                                                             %
00801 %                                                                             %
00802 %                                                                             %
00803 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00804 %
00805 %  PixelGetCyan() returns the normalized cyan color of the pixel wand.
00806 %
00807 %  The format of the PixelGetCyan method is:
00808 %
00809 %      double PixelGetCyan(const PixelWand *wand)
00810 %
00811 %  A description of each parameter follows:
00812 %
00813 %    o wand: the pixel wand.
00814 %
00815 */
00816 WandExport double PixelGetCyan(const PixelWand *wand)
00817 {
00818   assert(wand != (const PixelWand *) NULL);
00819   assert(wand->signature == WandSignature);
00820   if (wand->debug != MagickFalse)
00821     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
00822   return((double) QuantumScale*wand->pixel.red);
00823 }
00824 
00825 /*
00826 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00827 %                                                                             %
00828 %                                                                             %
00829 %                                                                             %
00830 %   P i x e l G e t C y a n Q u a n t u m                                     %
00831 %                                                                             %
00832 %                                                                             %
00833 %                                                                             %
00834 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00835 %
00836 %  PixelGetCyanQuantum() returns the cyan color of the pixel wand.
00837 %
00838 %  The format of the PixelGetCyanQuantum method is:
00839 %
00840 %      Quantum PixelGetCyanQuantum(const PixelWand *wand)
00841 %
00842 %  A description of each parameter follows:
00843 %
00844 %    o wand: the pixel wand.
00845 %
00846 */
00847 WandExport Quantum PixelGetCyanQuantum(const PixelWand *wand)
00848 {
00849   assert(wand != (const PixelWand *) NULL);
00850   assert(wand->signature == WandSignature);
00851   if (wand->debug != MagickFalse)
00852     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
00853   return(RoundToQuantum(wand->pixel.red));
00854 }
00855 
00856 /*
00857 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00858 %                                                                             %
00859 %                                                                             %
00860 %                                                                             %
00861 %   P i x e l G e t E x c e p t i o n                                         %
00862 %                                                                             %
00863 %                                                                             %
00864 %                                                                             %
00865 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00866 %
00867 %  PixelGetException() returns the severity, reason, and description of any
00868 %  error that occurs when using other methods in this API.
00869 %
00870 %  The format of the PixelGetException method is:
00871 %
00872 %      char *PixelGetException(const PixelWand *wand,ExceptionType *severity)
00873 %
00874 %  A description of each parameter follows:
00875 %
00876 %    o wand: the pixel wand.
00877 %
00878 %    o severity: the severity of the error is returned here.
00879 %
00880 */
00881 WandExport char *PixelGetException(const PixelWand *wand,
00882   ExceptionType *severity)
00883 {
00884   char
00885     *description;
00886 
00887   assert(wand != (const PixelWand *) NULL);
00888   assert(wand->signature == WandSignature);
00889   if (wand->debug != MagickFalse)
00890     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
00891   assert(severity != (ExceptionType *) NULL);
00892   *severity=wand->exception->severity;
00893   description=(char *) AcquireQuantumMemory(2UL*MaxTextExtent,
00894     sizeof(*description));
00895   if (description == (char *) NULL)
00896     ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed",
00897       wand->name);
00898   *description='\0';
00899   if (wand->exception->reason != (char *) NULL)
00900     (void) CopyMagickString(description,GetLocaleExceptionMessage(
00901       wand->exception->severity,wand->exception->reason),MaxTextExtent);
00902   if (wand->exception->description != (char *) NULL)
00903     {
00904       (void) ConcatenateMagickString(description," (",MaxTextExtent);
00905       (void) ConcatenateMagickString(description,GetLocaleExceptionMessage(
00906         wand->exception->severity,wand->exception->description),MaxTextExtent);
00907       (void) ConcatenateMagickString(description,")",MaxTextExtent);
00908     }
00909   return(description);
00910 }
00911 
00912 /*
00913 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00914 %                                                                             %
00915 %                                                                             %
00916 %                                                                             %
00917 %   P i x e l G e t E x c e p t i o n T y p e                                 %
00918 %                                                                             %
00919 %                                                                             %
00920 %                                                                             %
00921 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00922 %
00923 %  PixelGetExceptionType() the exception type associated with the wand.  If
00924 %  no exception has occurred, UndefinedExceptionType is returned.
00925 %
00926 %  The format of the PixelGetExceptionType method is:
00927 %
00928 %      ExceptionType PixelGetExceptionType(const PixelWand *wand)
00929 %
00930 %  A description of each parameter follows:
00931 %
00932 %    o wand: the magick wand.
00933 %
00934 */
00935 WandExport ExceptionType PixelGetExceptionType(const PixelWand *wand)
00936 {
00937   assert(wand != (const PixelWand *) NULL);
00938   assert(wand->signature == WandSignature);
00939   if (wand->debug != MagickFalse)
00940     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
00941   return(wand->exception->severity);
00942 }
00943 
00944 /*
00945 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00946 %                                                                             %
00947 %                                                                             %
00948 %                                                                             %
00949 %   P i x e l G e t F u z z                                                   %
00950 %                                                                             %
00951 %                                                                             %
00952 %                                                                             %
00953 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00954 %
00955 %  PixelGetFuzz() returns the normalized fuzz value of the pixel wand.
00956 %
00957 %  The format of the PixelGetFuzz method is:
00958 %
00959 %      double PixelGetFuzz(const PixelWand *wand)
00960 %
00961 %  A description of each parameter follows:
00962 %
00963 %    o wand: the pixel wand.
00964 %
00965 */
00966 WandExport double PixelGetFuzz(const PixelWand *wand)
00967 {
00968   assert(wand != (const PixelWand *) NULL);
00969   assert(wand->signature == WandSignature);
00970   if (wand->debug != MagickFalse)
00971     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
00972   return((double) wand->pixel.fuzz);
00973 }
00974 
00975 /*
00976 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00977 %                                                                             %
00978 %                                                                             %
00979 %                                                                             %
00980 %   P i x e l G e t G r e e n                                                 %
00981 %                                                                             %
00982 %                                                                             %
00983 %                                                                             %
00984 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00985 %
00986 %  PixelGetGreen() returns the normalized green color of the pixel wand.
00987 %
00988 %  The format of the PixelGetGreen method is:
00989 %
00990 %      double PixelGetGreen(const PixelWand *wand)
00991 %
00992 %  A description of each parameter follows:
00993 %
00994 %    o wand: the pixel wand.
00995 %
00996 */
00997 WandExport double PixelGetGreen(const PixelWand *wand)
00998 {
00999   assert(wand != (const PixelWand *) NULL);
01000   assert(wand->signature == WandSignature);
01001   if (wand->debug != MagickFalse)
01002     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
01003   return((double) QuantumScale*wand->pixel.green);
01004 }
01005 
01006 /*
01007 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01008 %                                                                             %
01009 %                                                                             %
01010 %                                                                             %
01011 %   P i x e l G e t G r e e n Q u a n t u m                                   %
01012 %                                                                             %
01013 %                                                                             %
01014 %                                                                             %
01015 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01016 %
01017 %  PixelGetGreenQuantum() returns the green color of the pixel wand.
01018 %
01019 %  The format of the PixelGetGreenQuantum method is:
01020 %
01021 %      Quantum PixelGetGreenQuantum(const PixelWand *wand)
01022 %
01023 %  A description of each parameter follows:
01024 %
01025 %    o wand: the pixel wand.
01026 %
01027 */
01028 WandExport Quantum PixelGetGreenQuantum(const PixelWand *wand)
01029 {
01030   assert(wand != (const PixelWand *) NULL);
01031   assert(wand->signature == WandSignature);
01032   if (wand->debug != MagickFalse)
01033     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
01034   return(RoundToQuantum(wand->pixel.green));
01035 }
01036 
01037 /*
01038 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01039 %                                                                             %
01040 %                                                                             %
01041 %                                                                             %
01042 %   P i x e l G e t H S L                                                     %
01043 %                                                                             %
01044 %                                                                             %
01045 %                                                                             %
01046 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01047 %
01048 %  PixelGetHSL() returns the normalized HSL color of the pixel wand.
01049 %
01050 %  The format of the PixelGetHSL method is:
01051 %
01052 %      void PixelGetHSL(const PixelWand *wand,double *hue,double *saturation,
01053 %        double *lightness)
01054 %
01055 %  A description of each parameter follows:
01056 %
01057 %    o wand: the pixel wand.
01058 %
01059 %    o hue,saturation,lightness: Return the pixel hue, saturation, and
01060 %      brightness.
01061 %
01062 */
01063 WandExport void PixelGetHSL(const PixelWand *wand,double *hue,
01064   double *saturation,double *lightness)
01065 {
01066   assert(wand != (const PixelWand *) NULL);
01067   assert(wand->signature == WandSignature);
01068   if (wand->debug != MagickFalse)
01069     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
01070   ConvertRGBToHSL(RoundToQuantum(wand->pixel.red),RoundToQuantum(
01071     wand->pixel.green),RoundToQuantum(wand->pixel.blue),hue,saturation,
01072     lightness);
01073 }
01074 
01075 /*
01076 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01077 %                                                                             %
01078 %                                                                             %
01079 %                                                                             %
01080 %   P i x e l G e t I n d e x                                                 %
01081 %                                                                             %
01082 %                                                                             %
01083 %                                                                             %
01084 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01085 %
01086 %  PixelGetIndex() returns the colormap index from the pixel wand.
01087 %
01088 %  The format of the PixelGetIndex method is:
01089 %
01090 %      IndexPacket PixelGetIndex(const PixelWand *wand)
01091 %
01092 %  A description of each parameter follows:
01093 %
01094