root / ImageMagick / trunk / wand / pixel-wand.c
| Revision 12706, 92.8 kB (checked in by cristy, 2 days ago) |
|---|
| Line | |
|---|---|
| 1 | /* |
| 2 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3 | % % |
| 4 | % % |
| 5 | % % |
| 6 | % PPPP IIIII X X EEEEE L % |
| 7 | % P P I X X E L % |
| 8 | % PPPP I X EEE L % |
| 9 | % P I X X E L % |
| 10 | % P IIIII X X EEEEE LLLLL % |
| 11 | % % |
| 12 | % W W AAA N N DDDD % |
| 13 | % W W A A NN N D D % |
| 14 | % W W W AAAAA N N N D D % |
| 15 | % WW WW A A N NN D D % |
| 16 | % W W A A N N DDDD % |
| 17 | % % |
| 18 | % % |
| 19 | % MagickWand Image Pixel Wand Methods % |
| 20 | % % |
| 21 | % Software Design % |
| 22 | % John Cristy % |
| 23 | % March 2003 % |
| 24 | % % |
| 25 | % % |
| 26 | % Copyright 1999-2008 ImageMagick Studio LLC, a non-profit organization % |
| 27 | % dedicated to making software imaging solutions freely available. % |
| 28 | % % |
| 29 | % You may not use this file except in compliance with the License. You may % |
| 30 | % obtain a copy of the License at % |
| 31 | % % |
| 32 | % http://www.imagemagick.org/script/license.php % |
| 33 | % % |
| 34 | % Unless required by applicable law or agreed to in writing, software % |
| 35 | % distributed under the License is distributed on an "AS IS" BASIS, % |
| 36 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. % |
| 37 | % See the License for the specific language governing permissions and % |
| 38 | % limitations under the License. % |
| 39 | % % |
| 40 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 41 | % |
| 42 | % |
| 43 | % |
| 44 | */ |
| 45 | |
| 46 | /* |
| 47 | Include declarations. |
| 48 | */ |
| 49 | #include "wand/studio.h" |
| 50 | #include "wand/MagickWand.h" |
| 51 | #include "wand/magick-wand-private.h" |
| 52 | #include "wand/pixel-wand-private.h" |
| 53 | #include "wand/wand.h" |
| 54 | |
| 55 | /* |
| 56 | Define declarations. |
| 57 | */ |
| 58 | #define PixelWandId "PixelWand" |
| 59 | |
| 60 | /* |
| 61 | Typedef declarations. |
| 62 | */ |
| 63 | struct _PixelWand |
| 64 | { |
| 65 | unsigned long |
| 66 | id; |
| 67 | |
| 68 | char |
| 69 | name[MaxTextExtent]; |
| 70 | |
| 71 | ExceptionInfo |
| 72 | *exception; |
| 73 | |
| 74 | MagickPixelPacket |
| 75 | pixel; |
| 76 | |
| 77 | unsigned long |
| 78 | count; |
| 79 | |
| 80 | MagickBooleanType |
| 81 | debug; |
| 82 | |
| 83 | unsigned long |
| 84 | signature; |
| 85 | }; |
| 86 | |
| 87 | /* |
| 88 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 89 | % % |
| 90 | % % |
| 91 | % % |
| 92 | % C l e a r P i x e l W a n d % |
| 93 | % % |
| 94 | % % |
| 95 | % % |
| 96 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 97 | % |
| 98 | % ClearPixelWand() clears resources associated with the wand. |
| 99 | % |
| 100 | % The format of the ClearPixelWand method is: |
| 101 | % |
| 102 | % void ClearPixelWand(PixelWand *wand) |
| 103 | % |
| 104 | % A description of each parameter follows: |
| 105 | % |
| 106 | % o wand: the pixel wand. |
| 107 | % |
| 108 | */ |
| 109 | WandExport void ClearPixelWand(PixelWand *wand) |
| 110 | { |
| 111 | assert(wand != (PixelWand *) NULL); |
| 112 | assert(wand->signature == WandSignature); |
| 113 | if (wand->debug != MagickFalse) |
| 114 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name); |
| 115 | ClearMagickException(wand->exception); |
| 116 | wand->pixel.colorspace=RGBColorspace; |
| 117 | wand->debug=IsEventLogging(); |
| 118 | } |
| 119 | |
| 120 | /* |
| 121 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 122 | % % |
| 123 | % % |
| 124 | % % |
| 125 | % C l o n e P i x e l W a n d % |
| 126 | % % |
| 127 | % % |
| 128 | % % |
| 129 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 130 | % |
| 131 | % ClonePixelWand() makes an exact copy of the specified wand. |
| 132 | % |
| 133 | % The format of the ClonePixelWand method is: |
| 134 | % |
| 135 | % PixelWand *ClonePixelWand(const PixelWand *wand) |
| 136 | % |
| 137 | % A description of each parameter follows: |
| 138 | % |
| 139 | % o wand: the magick wand. |
| 140 | % |
| 141 | */ |
| 142 | WandExport PixelWand *ClonePixelWand(const PixelWand *wand) |
| 143 | { |
| 144 | PixelWand |
| 145 | *clone_wand; |
| 146 | |
| 147 | assert(wand != (PixelWand *) NULL); |
| 148 | assert(wand->signature == WandSignature); |
| 149 | if (wand->debug != MagickFalse) |
| 150 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name); |
| 151 | clone_wand=(PixelWand *) AcquireMagickMemory(sizeof(*clone_wand)); |
| 152 | if (clone_wand == (PixelWand *) NULL) |
| 153 | ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed", |
| 154 | wand->name); |
| 155 | (void) ResetMagickMemory(clone_wand,0,sizeof(*clone_wand)); |
| 156 | clone_wand->id=AcquireWandId(); |
| 157 | (void) FormatMagickString(clone_wand->name,MaxTextExtent,"%s-%lu",PixelWandId, |
| 158 | clone_wand->id); |
| 159 | clone_wand->exception=AcquireExceptionInfo(); |
| 160 | InheritException(clone_wand->exception,wand->exception); |
| 161 | clone_wand->pixel=wand->pixel; |
| 162 | clone_wand->count=wand->count; |
| 163 | clone_wand->debug=IsEventLogging(); |
| 164 | if (clone_wand->debug != MagickFalse) |
| 165 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",clone_wand->name); |
| 166 | clone_wand->signature=WandSignature; |
| 167 | return(clone_wand); |
| 168 | } |
| 169 | |
| 170 | /* |
| 171 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 172 | % % |
| 173 | % % |
| 174 | % % |
| 175 | % C l o n e P i x e l W a n d s % |
| 176 | % % |
| 177 | % % |
| 178 | % % |
| 179 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 180 | % |
| 181 | % ClonePixelWands() makes an exact copy of the specified wands. |
| 182 | % |
| 183 | % The format of the ClonePixelWands method is: |
| 184 | % |
| 185 | % PixelWand **ClonePixelWands(const PixelWand **wands, |
| 186 | % const unsigned long number_wands) |
| 187 | % |
| 188 | % A description of each parameter follows: |
| 189 | % |
| 190 | % o wands: the magick wands. |
| 191 | % |
| 192 | % o number_wands: the number of wands. |
| 193 | % |
| 194 | */ |
| 195 | WandExport PixelWand **ClonePixelWands(const PixelWand **wands, |
| 196 | const unsigned long number_wands) |
| 197 | { |
| 198 | register long |
| 199 | i; |
| 200 | |
| 201 | PixelWand |
| 202 | **clone_wands; |
| 203 | |
| 204 | clone_wands=(PixelWand **) AcquireQuantumMemory((size_t) number_wands, |
| 205 | sizeof(*clone_wands)); |
| 206 | if (clone_wands == (PixelWand **) NULL) |
| 207 | ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed", |
| 208 | strerror(errno)); |
| 209 | for (i=0; i < (long) number_wands; i++) |
| 210 | clone_wands[i]=ClonePixelWand(wands[i]); |
| 211 | return(clone_wands); |
| 212 | } |
| 213 | |
| 214 | /* |
| 215 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 216 | % % |
| 217 | % % |
| 218 | % % |
| 219 | % D e s t r o y P i x e l W a n d % |
| 220 | % % |
| 221 | % % |
| 222 | % % |
| 223 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 224 | % |
| 225 | % DestroyPixelWand() deallocates resources associated with a PixelWand. |
| 226 | % |
| 227 | % The format of the DestroyPixelWand method is: |
| 228 | % |
| 229 | % PixelWand *DestroyPixelWand(PixelWand *wand) |
| 230 | % |
| 231 | % A description of each parameter follows: |
| 232 | % |
| 233 | % o wand: the pixel wand. |
| 234 | % |
| 235 | */ |
| 236 | WandExport PixelWand *DestroyPixelWand(PixelWand *wand) |
| 237 | { |
| 238 | assert(wand != (PixelWand *) NULL); |
| 239 | assert(wand->signature == WandSignature); |
| 240 | if (wand->debug != MagickFalse) |
| 241 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name); |
| 242 | wand->exception=DestroyExceptionInfo(wand->exception); |
| 243 | wand->signature=(~WandSignature); |
| 244 | RelinquishWandId(wand->id); |
| 245 | wand=(PixelWand *) RelinquishMagickMemory(wand); |
| 246 | return(wand); |
| 247 | } |
| 248 | |
| 249 | /* |
| 250 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 251 | % % |
| 252 | % % |
| 253 | % % |
| 254 | % D e s t r o y P i x e l W a n d s % |
| 255 | % % |
| 256 | % % |
| 257 | % % |
| 258 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 259 | % |
| 260 | % DestroyPixelWands() deallocates resources associated with an array of |
| 261 | % pixel wands. |
| 262 | % |
| 263 | % The format of the DestroyPixelWands method is: |
| 264 | % |
| 265 | % PixelWand **DestroyPixelWands(PixelWand **wand, |
| 266 | % const unsigned long number_wands) |
| 267 | % |
| 268 | % A description of each parameter follows: |
| 269 | % |
| 270 | % o wand: the pixel wand. |
| 271 | % |
| 272 | % o number_wands: the number of wands. |
| 273 | % |
| 274 | */ |
| 275 | WandExport PixelWand **DestroyPixelWands(PixelWand **wand, |
| 276 | const unsigned long number_wands) |
| 277 | { |
| 278 | register long |
| 279 | i; |
| 280 | |
| 281 | assert(wand != (PixelWand **) NULL); |
| 282 | assert(*wand != (PixelWand *) NULL); |
| 283 | assert((*wand)->signature == WandSignature); |
| 284 | if ((*wand)->debug != MagickFalse) |
| 285 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",(*wand)->name); |
| 286 | for (i=(long) number_wands-1; i >= 0; i--) |
| 287 | wand[i]=DestroyPixelWand(wand[i]); |
| 288 | wand=(PixelWand **) RelinquishMagickMemory(wand); |
| 289 | return(wand); |
| 290 | } |
| 291 | |
| 292 | /* |
| 293 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 294 | % % |
| 295 | % % |
| 296 | % % |
| 297 | % I s P i x e l W a n d S i m i l a r % |
| 298 | % % |
| 299 | % % |
| 300 | % % |
| 301 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 302 | % |
| 303 | % IsPixelWandSimilar() returns MagickTrue if the distance between two |
| 304 | % colors is less than the specified distance. |
| 305 | % |
| 306 | % The format of the IsPixelWandSimilar method is: |
| 307 | % |
| 308 | % MagickBooleanType IsPixelWandSimilar(PixelWand *p,PixelWand *q, |
| 309 | % const double fuzz) |
| 310 | % |
| 311 | % A description of each parameter follows: |
| 312 | % |
| 313 | % o p: the pixel wand. |
| 314 | % |
| 315 | % o q: the pixel wand. |
| 316 | % |
| 317 | % o fuzz: any two colors that are less than or equal to this distance |
| 318 | % squared are consider similar. |
| 319 | % |
| 320 | */ |
| 321 | WandExport MagickBooleanType IsPixelWandSimilar(PixelWand *p,PixelWand *q, |
| 322 | const double fuzz) |
| 323 | { |
| 324 | assert(p != (PixelWand *) NULL); |
| 325 | assert(p->signature == WandSignature); |
| 326 | if (p->debug != MagickFalse) |
| 327 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",p->name); |
| 328 | assert(q != (PixelWand *) NULL); |
| 329 | assert(q->signature == WandSignature); |
| 330 | if (q->debug != MagickFalse) |
| 331 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",q->name); |
| 332 | p->pixel.fuzz=fuzz; |
| 333 | q->pixel.fuzz=fuzz; |
| 334 | return(IsMagickColorSimilar(&p->pixel,&q->pixel)); |
| 335 | } |
| 336 | |
| 337 | /* |
| 338 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 339 | % % |
| 340 | % % |
| 341 | % % |
| 342 | % I s P i x e l W a n d % |
| 343 | % % |
| 344 | % % |
| 345 | % % |
| 346 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 347 | % |
| 348 | % IsPixelWand() returns MagickTrue if the wand is verified as a pixel wand. |
| 349 | % |
| 350 | % The format of the IsPixelWand method is: |
| 351 | % |
| 352 | % MagickBooleanType IsPixelWand(const PixelWand *wand) |
| 353 | % |
| 354 | % A description of each parameter follows: |
| 355 | % |
| 356 | % o wand: the magick wand. |
| 357 | % |
| 358 | */ |
| 359 | WandExport MagickBooleanType IsPixelWand(const PixelWand *wand) |
| 360 | { |
| 361 | if (wand == (const PixelWand *) NULL) |
| 362 | return(MagickFalse); |
| 363 | if (wand->signature != WandSignature) |
| 364 | return(MagickFalse); |
| 365 | if (LocaleNCompare(wand->name,PixelWandId,strlen(PixelWandId)) != 0) |
| 366 | return(MagickFalse); |
| 367 | return(MagickTrue); |
| 368 | } |
| 369 | |
| 370 | /* |
| 371 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 372 | % % |
| 373 | % % |
| 374 | % % |
| 375 | % N e w P i x e l W a n d % |
| 376 | % % |
| 377 | % % |
| 378 | % % |
| 379 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 380 | % |
| 381 | % NewPixelWand() returns a new pixel wand. |
| 382 | % |
| 383 | % The format of the NewPixelWand method is: |
| 384 | % |
| 385 | % PixelWand *NewPixelWand(void) |
| 386 | % |
| 387 | */ |
| 388 | WandExport PixelWand *NewPixelWand(void) |
| 389 | { |
| 390 | const char |
| 391 | *quantum; |
| 392 | |
| 393 | PixelWand |
| 394 | *wand; |
| 395 | |
| 396 | unsigned long |
| 397 | depth; |
| 398 | |
| 399 | depth=MAGICKCORE_QUANTUM_DEPTH; |
| 400 | quantum=GetMagickQuantumDepth(&depth); |
| 401 | if (depth != MAGICKCORE_QUANTUM_DEPTH) |
| 402 | ThrowWandFatalException(WandError,"QuantumDepthMismatch",quantum); |
| 403 | wand=(PixelWand *) AcquireMagickMemory(sizeof(*wand)); |
| 404 | if (wand == (PixelWand *) NULL) |
| 405 | ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed", |
| 406 | strerror(errno)); |
| 407 | (void) ResetMagickMemory(wand,0,sizeof(*wand)); |
| 408 | wand->id=AcquireWandId(); |
| 409 | (void) FormatMagickString(wand->name,MaxTextExtent,"%s-%lu",PixelWandId, |
| 410 | wand->id); |
| 411 | wand->exception=AcquireExceptionInfo(); |
| 412 | GetMagickPixelPacket((Image *) NULL,&wand->pixel); |
| 413 | wand->debug=IsEventLogging(); |
| 414 | if (wand->debug != MagickFalse) |
| 415 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name); |
| 416 | wand->signature=WandSignature; |
| 417 | return(wand); |
| 418 | } |
| 419 | |
| 420 | /* |
| 421 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 422 | % % |
| 423 | % % |
| 424 | % % |
| 425 | % N e w P i x e l W a n d s % |
| 426 | % % |
| 427 | % % |
| 428 | % % |
| 429 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 430 | % |
| 431 | % NewPixelWands() returns an array of pixel wands. |
| 432 | % |
| 433 | % The format of the NewPixelWands method is: |
| 434 | % |
| 435 | % PixelWand **NewPixelWands(const unsigned long number_wands) |
| 436 | % |
| 437 | % A description of each parameter follows: |
| 438 | % |
| 439 | % o number_wands: the number of wands. |
| 440 | % |
| 441 | */ |
| 442 | WandExport PixelWand **NewPixelWands(const unsigned long number_wands) |
| 443 | { |
| 444 | register long |
| 445 | i; |
| 446 | |
| 447 | PixelWand |
| 448 | **wands; |
| 449 | |
| 450 | wands=(PixelWand **) AcquireQuantumMemory((size_t) number_wands, |
| 451 | sizeof(*wands)); |
| 452 | if (wands == (PixelWand **) NULL) |
| 453 | ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed", |
| 454 | strerror(errno)); |
| 455 | for (i=0; i < (long) number_wands; i++) |
| 456 | wands[i]=NewPixelWand(); |
| 457 | return(wands); |
| 458 | } |
| 459 | |
| 460 | /* |
| 461 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 462 | % % |
| 463 | % % |
| 464 | % % |
| 465 | % P i x e l C l e a r E x c e p t i o n % |
| 466 | % % |
| 467 | % % |
| 468 | % % |
| 469 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 470 | % |
| 471 | % PixelClearException() clear any exceptions associated with the iterator. |
| 472 | % |
| 473 | % The format of the PixelClearException method is: |
| 474 | % |
| 475 | % MagickBooleanType PixelClearException(PixelWand *wand) |
| 476 | % |
| 477 | % A description of each parameter follows: |
| 478 | % |
| 479 | % o wand: the pixel wand. |
| 480 | % |
| 481 | */ |
| 482 | WandExport MagickBooleanType PixelClearException(PixelWand *wand) |
| 483 | { |
| 484 | assert(wand != (PixelWand *) NULL); |
| 485 | assert(wand->signature == WandSignature); |
| 486 | if (wand->debug != MagickFalse) |
| 487 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name); |
| 488 | ClearMagickException(wand->exception); |
| 489 | return(MagickTrue); |
| 490 | } |
| 491 | |
| 492 | /* |
| 493 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 494 | % % |
| 495 | % % |
| 496 | % % |
| 497 | % P i x e l G e t A l p h a % |
| 498 | % % |
| 499 | % % |
| 500 | % % |
| 501 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 502 | % |
| 503 | % PixelGetAlpha() returns the normalized alpha color of the pixel wand. |
| 504 | % |
| 505 | % The format of the PixelGetAlpha method is: |
| 506 | % |
| 507 | % double PixelGetAlpha(const PixelWand *wand) |
| 508 | % |
| 509 | % A description of each parameter follows: |
| 510 | % |
| 511 | % o wand: the pixel wand. |
| 512 | % |
| 513 | */ |
| 514 | WandExport double PixelGetAlpha(const PixelWand *wand) |
| 515 | { |
| 516 | assert(wand != (const PixelWand *) NULL); |
| 517 | assert(wand->signature == WandSignature); |
| 518 | if (wand->debug != MagickFalse) |
| 519 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name); |
| 520 | return((double) QuantumScale*(QuantumRange-wand->pixel.opacity)); |
| 521 | } |
| 522 | |
| 523 | /* |
| 524 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 525 | % % |
| 526 | % % |
| 527 | % % |
| 528 | % P i x e l G e t A l p h a Q u a n t u m % |
| 529 | % % |
| 530 | % % |
| 531 | % % |
| 532 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 533 | % |
| 534 | % PixelGetAlphaQuantum() returns the alpha value of the pixel wand. |
| 535 | % |
| 536 | % The format of the PixelGetAlphaQuantum method is: |
| 537 | % |
| 538 | % Quantum PixelGetAlphaQuantum(const PixelWand *wand) |
| 539 | % |
| 540 | % A description of each parameter follows: |
| 541 | % |
| 542 | % o wand: the pixel wand. |
| 543 | % |
| 544 | */ |
| 545 | WandExport Quantum PixelGetAlphaQuantum(const PixelWand *wand) |
| 546 | { |
| 547 | assert(wand != (const PixelWand *) NULL); |
| 548 | assert(wand->signature == WandSignature); |
| 549 | if (wand->debug != MagickFalse) |
| 550 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name); |
| 551 | return((Quantum) QuantumRange-RoundToQuantum(wand->pixel.opacity)); |
| 552 | } |
| 553 | |
| 554 | /* |
| 555 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 556 | % % |
| 557 | % % |
| 558 | % % |
| 559 | % P i x e l G e t B l a c k % |
| 560 | % % |
| 561 | % % |
| 562 | % % |
| 563 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 564 | % |
| 565 | % PixelGetBlack() returns the normalized black color of the pixel wand. |
| 566 | % |
| 567 | % The format of the PixelGetBlack method is: |
| 568 | % |
| 569 | % double PixelGetBlack(const PixelWand *wand) |
| 570 | % |
| 571 | % A description of each parameter follows: |
| 572 | % |
| 573 | % o wand: the pixel wand. |
| 574 | % |
| 575 | */ |
| 576 | WandExport double PixelGetBlack(const PixelWand *wand) |
| 577 | { |
| 578 | assert(wand != (const PixelWand *) NULL); |
| 579 | assert(wand->signature == WandSignature); |
| 580 | if (wand->debug != MagickFalse) |
| 581 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name); |
| 582 | return((double) QuantumScale*wand->pixel.index); |
| 583 | } |
| 584 | |
| 585 | /* |
| 586 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 587 | % % |
| 588 | % % |
| 589 | % % |
| 590 | % P i x e l G e t B l a c k Q u a n t u m % |
| 591 | % % |
| 592 | % % |
| 593 | % % |
| 594 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 595 | % |
| 596 | % PixelGetBlackQuantum() returns the black color of the pixel wand. |
| 597 | % |
| 598 | % The format of the PixelGetBlackQuantum method is: |
| 599 | % |
| 600 | % Quantum PixelGetBlackQuantum(const PixelWand *wand) |
| 601 | % |
| 602 | % A description of each parameter follows: |
| 603 | % |
| 604 | % o wand: the pixel wand. |
| 605 | % |
| 606 | */ |
| 607 | WandExport Quantum PixelGetBlackQuantum(const PixelWand *wand) |
| 608 | { |
| 609 | assert(wand != (const PixelWand *) NULL); |
| 610 | assert(wand->signature == WandSignature); |
| 611 | if (wand->debug != MagickFalse) |
| 612 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name); |
| 613 | return(RoundToQuantum(wand->pixel.index)); |
| 614 | } |
| 615 | |
| 616 | /* |
| 617 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 618 | % % |
| 619 | % % |
| 620 | % % |
| 621 | % P i x e l G e t B l u e % |
| 622 | % % |
| 623 | % % |
| 624 | % % |
| 625 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 626 | % |
| 627 | % PixelGetBlue() returns the normalized blue color of the pixel wand. |
| 628 | % |
| 629 | % The format of the PixelGetBlue method is: |
| 630 | % |
| 631 | % double PixelGetBlue(const PixelWand *wand) |
| 632 | % |
| 633 | % A description of each parameter follows: |
| 634 | % |
| 635 | % o wand: the pixel wand. |
| 636 | % |
| 637 | */ |
| 638 | WandExport double PixelGetBlue(const PixelWand *wand) |
| 639 | { |
| 640 | assert(wand != (const PixelWand *) NULL); |
| 641 | assert(wand->signature == WandSignature); |
| 642 | if (wand->debug != MagickFalse) |
| 643 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name); |
| 644 | return((double) QuantumScale*wand->pixel.blue); |
| 645 | } |
| 646 | |
| 647 | /* |
| 648 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 649 | % % |
| 650 | % % |
| 651 | % % |
| 652 | % P i x e l G e t B l u e Q u a n t u m % |
| 653 | % % |
| 654 | % % |
| 655 | % % |
| 656 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 657 | % |
| 658 | % PixelGetBlueQuantum() returns the blue color of the pixel wand. |
| 659 | % |
| 660 | % The format of the PixelGetBlueQuantum method is: |
| 661 | % |
| 662 | % Quantum PixelGetBlueQuantum(const PixelWand *wand) |
| 663 | % |
| 664 | % A description of each parameter follows: |
| 665 | % |
| 666 | % o wand: the pixel wand. |
| 667 | % |
| 668 | */ |
| 669 | WandExport Quantum PixelGetBlueQuantum(const PixelWand *wand) |
| 670 | { |
| 671 | assert(wand != (const PixelWand *) NULL); |
| 672 | assert(wand->signature == WandSignature); |
| 673 | if (wand->debug != MagickFalse) |
| 674 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name); |
| 675 | return(RoundToQuantum(wand->pixel.blue)); |
| 676 | } |
| 677 | |
| 678 | /* |
| 679 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 680 | % % |
| 681 | % % |
| 682 | % % |
| 683 | % P i x e l G e t C o l o r A s S t r i n g % |
| 684 | % % |
| 685 | % % |
| 686 | % % |
| 687 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 688 | % |
| 689 | % PixelGetColorAsString() returnsd the color of the pixel wand as a string. |
| 690 | % |
| 691 | % The format of the PixelGetColorAsString method is: |
| 692 | % |
| 693 | % char *PixelGetColorAsString(PixelWand *wand) |
| 694 | % |
| 695 | % A description of each parameter follows: |
| 696 | % |
| 697 | % o wand: the pixel wand. |
| 698 | % |
| 699 | */ |
| 700 | WandExport char *PixelGetColorAsString(const PixelWand *wand) |
| 701 | { |
| 702 | char |
| 703 | *color; |
| 704 | |
| 705 | MagickPixelPacket |
| 706 | pixel; |
| 707 | |
| 708 | assert(wand != (const PixelWand *) NULL); |
| 709 | assert(wand->signature == WandSignature); |
| 710 | if (wand->debug != MagickFalse) |
| 711 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name); |
| 712 | pixel=wand->pixel; |
| 713 | color=AcquireString((const char *) NULL); |
| 714 | GetColorTuple(&pixel,MagickFalse,color); |
| 715 | return(color); |
| 716 | } |
| 717 | |
| 718 | /* |
| 719 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 720 | % % |
| 721 | % % |
| 722 | % % |
| 723 | % 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 % |
| 724 | % % |
| 725 | % % |
| 726 | % % |
| 727 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 728 | % |
| 729 | % PixelGetColorAsNormalizedString() returns the normalized color of the pixel |
| 730 | % wand as a string. |
| 731 | % |
| 732 | % The format of the PixelGetColorAsNormalizedString method is: |
| 733 | % |
| 734 | % char *PixelGetColorAsNormalizedString(PixelWand *wand) |
| 735 | % |
| 736 | % A description of each parameter follows: |
| 737 | % |
| 738 | % o wand: the pixel wand. |
| 739 | % |
| 740 | */ |
| 741 | WandExport char *PixelGetColorAsNormalizedString(const PixelWand *wand) |
| 742 | { |
| 743 | char |
| 744 | color[MaxTextExtent]; |
| 745 | |
| 746 | assert(wand != (const PixelWand *) NULL); |
| 747 | assert(wand->signature == WandSignature); |
| 748 | if (wand->debug != MagickFalse) |
| 749 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name); |
| 750 | (void) FormatMagickString(color,MaxTextExtent,"%g,%g,%g", |
| 751 | (double) (QuantumScale*wand->pixel.red), |
| 752 | (double) (QuantumScale*wand->pixel.green), |
| 753 | (double) (QuantumScale*wand->pixel.blue)); |
| 754 | if (wand->pixel.colorspace == CMYKColorspace) |
| 755 | (void) FormatMagickString(color+strlen(color),MaxTextExtent,",%g", |
| 756 | (double) (QuantumScale*wand->pixel.index)); |
| 757 | if (wand->pixel.matte != MagickFalse) |
| 758 | (void) FormatMagickString(color+strlen(color),MaxTextExtent,",%g", |
| 759 | (double) (QuantumScale*wand->pixel.opacity)); |
| 760 | return(ConstantString(color)); |
| 761 | } |
| 762 | |
| 763 | /* |
| 764 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 765 | % % |
| 766 | % % |
| 767 | % % |
| 768 | % P i x e l G e t C o l o r C o u n t % |
| 769 | % % |
| 770 | % % |
| 771 | % % |
| 772 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 773 | % |
| 774 | % PixelGetColorCount() returns the color count associated with this color. |
| 775 | % |
| 776 | % The format of the PixelGetColorCount method is: |
| 777 | % |
| 778 | % unsigned long PixelGetColorCount(const PixelWand *wand) |
| 779 | % |
| 780 | % A description of each parameter follows: |
| 781 | % |
| 782 | % o wand: the pixel wand. |
| 783 | % |
| 784 | */ |
| 785 | WandExport unsigned long PixelGetColorCount(const PixelWand *wand) |
| 786 | { |
| 787 | assert(wand != (const PixelWand *) NULL); |
| 788 | assert(wand->signature == WandSignature); |
| 789 | if (wand->debug != MagickFalse) |
| 790 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name); |
| 791 | return(wand->count); |
| 792 | } |
| 793 | |
| 794 | /* |
| 795 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 796 | % % |
| 797 | % % |
| 798 | % % |
| 799 | % P i x e l G e t C y a n % |
| 800 | % % |
| 801 | % % |
| 802 | % % |
| 803 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 804 | % |
| 805 | % PixelGetCyan() returns the normalized cyan color of the pixel wand. |
| 806 | % |
| 807 | % The format of the PixelGetCyan method is: |
| 808 | % |
| 809 | % double PixelGetCyan(const PixelWand *wand) |
| 810 | % |
| 811 | % A description of each parameter follows: |
| 812 | % |
| 813 | % o wand: the pixel wand. |
| 814 | % |
| 815 | */ |
| 816 | WandExport double PixelGetCyan(const PixelWand *wand) |
| 817 | { |
| 818 | assert(wand != (const PixelWand *) NULL); |
| 819 | assert(wand->signature == WandSignature); |
| 820 | if (wand->debug != MagickFalse) |
| 821 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name); |
| 822 | return((double) QuantumScale*wand->pixel.red); |
| 823 | } |
| 824 | |
| 825 | /* |
| 826 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 827 | % % |
| 828 | % % |
| 829 | % % |
| 830 | % P i x e l G e t C y a n Q u a n t u m % |
| 831 | % % |
| 832 | % % |
| 833 | % % |
| 834 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 835 | % |
| 836 | % PixelGetCyanQuantum() returns the cyan color of the pixel wand. |
| 837 | % |
| 838 | % The format of the PixelGetCyanQuantum method is: |
| 839 | % |
| 840 | % Quantum PixelGetCyanQuantum(const PixelWand *wand) |
| 841 | % |
| 842 | % A description of each parameter follows: |
| 843 | % |
| 844 | % o wand: the pixel wand. |
| 845 | % |
| 846 | */ |
| 847 | WandExport Quantum PixelGetCyanQuantum(const PixelWand *wand) |
| 848 | { |
| 849 | assert(wand != (const PixelWand *) NULL); |
| 850 | assert(wand->signature == WandSignature); |
| 851 | if (wand->debug != MagickFalse) |
| 852 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name); |
| 853 | return(RoundToQuantum(wand->pixel.red)); |
| 854 | } |
| 855 | |
| 856 | /* |
| 857 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 858 | % % |
| 859 | % % |
| 860 | % % |
| 861 | % P i x e l G e t E x c e p t i o n % |
| 862 | % % |
| 863 | % % |
| 864 | % % |
| 865 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 866 | % |
| 867 | % PixelGetException() returns the severity, reason, and description of any |
| 868 | % error that occurs when using other methods in this API. |
| 869 | % |
| 870 | % The format of the PixelGetException method is: |
| 871 | % |
| 872 | % char *PixelGetException(const PixelWand *wand,ExceptionType *severity) |
| 873 | % |
| 874 | % A description of each parameter follows: |
