00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
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
00057
00058 #define PixelWandId "PixelWand"
00059
00060
00061
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
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
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
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
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
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
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 GetExceptionMessage(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
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
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
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
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
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
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
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
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
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
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 GetExceptionMessage(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
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
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 GetExceptionMessage(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
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
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
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
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
00529
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539
00540
00541
00542
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
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
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
00591
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604
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
00622
00623
00624
00625
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635
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
00653
00654
00655
00656
00657
00658
00659
00660
00661
00662
00663
00664
00665
00666
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
00684
00685
00686
00687
00688
00689
00690
00691
00692
00693
00694
00695
00696
00697
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
00724
00725
00726
00727
00728
00729
00730
00731
00732
00733
00734
00735
00736
00737
00738
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
00769
00770
00771
00772
00773
00774
00775
00776
00777
00778
00779
00780
00781
00782
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
00800
00801
00802
00803
00804
00805
00806
00807
00808
00809
00810
00811
00812
00813
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
00831
00832
00833
00834
00835
00836
00837
00838
00839
00840
00841
00842
00843
00844
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
00862
00863
00864
00865
00866
00867
00868
00869
00870
00871
00872
00873
00874
00875
00876
00877
00878
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
00918
00919
00920
00921
00922
00923
00924
00925
00926
00927
00928
00929
00930
00931
00932
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
00950
00951
00952
00953
00954
00955
00956
00957
00958
00959
00960
00961
00962
00963
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
00981
00982
00983
00984
00985
00986
00987
00988
00989
00990
00991
00992
00993
00994
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
01012
01013
01014
01015
01016
01017
01018
01019
01020
01021
01022
01023
01024
01025
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
01043
01044
01045
01046
01047
01048
01049
01050
01051
01052
01053
01054
01055
01056
01057
01058
01059
01060
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
01081
01082
01083
01084
01085
01086
01087
01088
01089
01090
01091
01092
01093
01094
01095
01096
01097 WandExport IndexPacket PixelGetIndex(const PixelWand *wand)
01098 {
01099 assert(wand != (const PixelWand *) NULL);
01100 assert(wand->signature == WandSignature);
01101 if (wand->debug != MagickFalse)
01102 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
01103 return((IndexPacket) wand->pixel.index);
01104 }
01105
01106
01107
01108
01109
01110
01111
01112
01113
01114
01115
01116
01117
01118
01119
01120
01121
01122
01123
01124
01125
01126
01127
01128 WandExport double PixelGetMagenta(const PixelWand *wand)
01129 {
01130 assert(wand != (const PixelWand *) NULL);
01131 assert(wand->signature == WandSignature);
01132 if (wand->debug != MagickFalse)
01133 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
01134 return((double) QuantumScale*wand->pixel.green);
01135 }
01136
01137
01138
01139
01140
01141
01142
01143
01144
01145
01146
01147
01148
01149
01150
01151
01152
01153
01154
01155
01156
01157
01158
01159 WandExport Quantum PixelGetMagentaQuantum(const PixelWand *wand)
01160 {
01161 assert(wand != (const PixelWand *) NULL);
01162 assert(wand->signature == WandSignature);
01163 if (wand->debug != MagickFalse)
01164 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
01165 return(RoundToQuantum(wand->pixel.green));
01166 }
01167
01168
01169
01170
01171
01172
01173
01174
01175
01176
01177
01178
01179
01180
01181
01182
01183
01184
01185
01186
01187
01188
01189
01190
01191
01192 WandExport void PixelGetMagickColor(const PixelWand *wand,
01193 MagickPixelPacket *color)
01194 {
01195 assert(wand != (const PixelWand *) NULL);
01196 assert(wand->signature == WandSignature);
01197 if (wand->debug != MagickFalse)
01198 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
01199 assert(color != (MagickPixelPacket *) NULL);
01200 *color=wand->pixel;
01201 }
01202
01203
01204
01205
01206
01207
01208
01209
01210
01211
01212
01213
01214
01215
01216
01217
01218
01219
01220
01221
01222
01223
01224
01225 WandExport double PixelGetOpacity(const PixelWand *wand)
01226 {
01227 assert(wand != (const PixelWand *) NULL);
01228 assert(wand->signature == WandSignature);
01229 if (wand->debug != MagickFalse)
01230 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
01231 return((double) QuantumScale*wand->pixel.opacity);
01232 }
01233
01234
01235
01236
01237
01238
01239
01240
01241
01242
01243
01244
01245
01246
01247
01248
01249
01250
01251
01252
01253
01254
01255
01256 WandExport Quantum PixelGetOpacityQuantum(const PixelWand *wand)
01257 {
01258 assert(wand != (const PixelWand *) NULL);
01259 assert(wand->signature == WandSignature);
01260 if (wand->debug != MagickFalse)
01261 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
01262 return(RoundToQuantum(wand->pixel.opacity));
01263 }
01264
01265
01266
01267
01268
01269
01270
01271
01272
01273
01274
01275
01276
01277
01278
01279
01280
01281
01282
01283
01284
01285
01286
01287
01288
01289 WandExport void PixelGetQuantumColor(const PixelWand *wand,PixelPacket *color)
01290 {
01291 assert(wand != (const PixelWand *) NULL);
01292 assert(wand->signature == WandSignature);
01293 if (wand->debug != MagickFalse)
01294 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
01295 assert(color != (PixelPacket *) NULL);
01296 color->opacity=RoundToQuantum(wand->pixel.opacity);
01297 if (wand->pixel.colorspace == CMYKColorspace)
01298 {
01299 color->red=RoundToQuantum((MagickRealType) QuantumRange-
01300 (wand->pixel.red*(QuantumRange-wand->pixel.index)+wand->pixel.index));
01301 color->green=RoundToQuantum((MagickRealType) QuantumRange-
01302 (wand->pixel.green*(QuantumRange-wand->pixel.index)+wand->pixel.index));
01303 color->blue=RoundToQuantum((MagickRealType) QuantumRange-
01304 (wand->pixel.blue*(QuantumRange-wand->pixel.index)+wand->pixel.index));
01305 return;
01306 }
01307 color->red=RoundToQuantum(wand->pixel.red);
01308 color->green=RoundToQuantum(wand->pixel.green);
01309 color->blue=RoundToQuantum(wand->pixel.blue);
01310 }
01311
01312
01313
01314
01315
01316
01317
01318
01319
01320
01321
01322
01323
01324
01325
01326
01327
01328
01329
01330
01331
01332
01333
01334 WandExport double PixelGetRed(const PixelWand *wand)
01335 {
01336 assert(wand != (const PixelWand *) NULL);
01337 assert(wand->signature == WandSignature);
01338 if (wand->debug != MagickFalse)
01339 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
01340 return((double) QuantumScale*wand->pixel.red);
01341 }
01342
01343
01344
01345
01346
01347
01348
01349
01350
01351
01352
01353
01354
01355
01356
01357
01358
01359
01360
01361
01362
01363
01364
01365 WandExport Quantum PixelGetRedQuantum(const PixelWand *wand)
01366 {
01367 assert(wand != (const PixelWand *) NULL);
01368 assert(wand->signature == WandSignature);
01369 if (wand->debug != MagickFalse)
01370 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
01371 return(RoundToQuantum(wand->pixel.red));
01372 }
01373
01374
01375
01376
01377
01378
01379
01380
01381
01382
01383
01384
01385
01386
01387
01388
01389
01390
01391
01392
01393
01394
01395
01396 WandExport double PixelGetYellow(const PixelWand *wand)
01397 {
01398 assert(wand != (const PixelWand *) NULL);
01399 assert(wand->signature == WandSignature);
01400 if (wand->debug != MagickFalse)
01401 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
01402 return((double) QuantumScale*wand->pixel.blue);
01403 }
01404
01405
01406
01407
01408
01409
01410
01411
01412
01413
01414
01415
01416
01417
01418
01419
01420
01421
01422
01423
01424
01425
01426
01427 WandExport Quantum PixelGetYellowQuantum(const PixelWand *wand)
01428 {
01429 assert(wand != (const PixelWand *) NULL);
01430 assert(wand->signature == WandSignature);
01431 if (wand->debug != MagickFalse)
01432 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
01433 return(RoundToQuantum(wand->pixel.blue));
01434 }
01435
01436
01437
01438
01439
01440
01441
01442
01443
01444
01445
01446
01447
01448
01449
01450
01451
01452
01453
01454
01455
01456
01457
01458
01459
01460
01461 WandExport void PixelSetAlpha(PixelWand *wand,const double alpha)
01462 {
01463 assert(wand != (const PixelWand *) NULL);
01464 assert(wand->signature == WandSignature);
01465 if (wand->debug != MagickFalse)
01466 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
01467 wand->pixel.opacity=(MagickRealType) (QuantumRange-
01468 RoundToQuantum((MagickRealType) QuantumRange*alpha));
01469 }
01470
01471
01472
01473
01474
01475
01476
01477
01478
01479
01480
01481
01482
01483
01484
01485
01486
01487
01488
01489
01490
01491
01492
01493
01494
01495
01496 WandExport void PixelSetAlphaQuantum(PixelWand *wand,const Quantum opacity)
01497 {
01498 assert(wand != (const PixelWand *) NULL);
01499 assert(wand->signature == WandSignature);
01500 if (wand->debug != MagickFalse)
01501 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
01502 wand->pixel.opacity=(MagickRealType) (QuantumRange-opacity);
01503 }
01504
01505
01506
01507
01508
01509
01510
01511
01512
01513
01514
01515
01516
01517
01518
01519
01520
01521
01522
01523
01524
01525
01526
01527
01528
01529 WandExport void PixelSetBlack(PixelWand *wand,const double black)
01530 {
01531 assert(wand != (const PixelWand *) NULL);
01532 assert(wand->signature == WandSignature);
01533 if (wand->debug != MagickFalse)
01534 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
01535 wand->pixel.index=(MagickRealType) RoundToQuantum((MagickRealType)
01536 QuantumRange*black);
01537 }
01538
01539
01540
01541
01542
01543
01544
01545
01546
01547
01548
01549
01550
01551
01552
01553
01554
01555
01556
01557
01558
01559
01560
01561
01562
01563 WandExport void PixelSetBlackQuantum(PixelWand *wand,const Quantum black)
01564 {
01565 assert(wand != (const PixelWand *) NULL);
01566 assert(wand->signature == WandSignature);
01567 if (wand->debug != MagickFalse)
01568 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
01569 wand->pixel.index=(MagickRealType) black;
01570 }
01571
01572
01573
01574
01575
01576
01577
01578
01579
01580
01581
01582
01583
01584
01585
01586
01587
01588
01589
01590
01591
01592
01593
01594
01595
01596 WandExport void PixelSetBlue(PixelWand *wand,const double blue)
01597 {
01598 assert(wand != (const PixelWand *) NULL);
01599 assert(wand->signature == WandSignature);
01600 if (wand->debug != MagickFalse)
01601 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
01602 wand->pixel.blue=(MagickRealType) RoundToQuantum((MagickRealType)
01603 QuantumRange*blue);
01604 }
01605
01606
01607
01608
01609
01610
01611
01612
01613
01614
01615
01616
01617
01618
01619
01620
01621
01622
01623
01624
01625
01626
01627
01628
01629
01630 WandExport void PixelSetBlueQuantum(PixelWand *wand,const Quantum blue)
01631 {
01632 assert(wand != (const PixelWand *) NULL);
01633 assert(wand->signature == WandSignature);
01634 if (wand->debug != MagickFalse)
01635 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
01636 wand->pixel.blue=(MagickRealType) blue;
01637 }
01638
01639
01640
01641
01642
01643
01644
01645
01646
01647
01648
01649
01650
01651
01652
01653
01654
01655
01656
01657
01658
01659
01660
01661
01662
01663
01664 WandExport MagickBooleanType PixelSetColor(PixelWand *wand,const char *color)
01665 {
01666 MagickBooleanType
01667 status;
01668
01669 MagickPixelPacket
01670 pixel;
01671
01672 assert(wand != (const PixelWand *) NULL);
01673 assert(wand->signature == WandSignature);
01674 if (wand->debug != MagickFalse)
01675 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
01676 status=QueryMagickColor(color,&pixel,wand->exception);
01677 if (status != MagickFalse)
01678 wand->pixel=pixel;
01679 return(status);
01680 }
01681
01682
01683
01684
01685
01686
01687
01688
01689
01690
01691
01692
01693
01694
01695
01696
01697
01698
01699
01700
01701
01702
01703
01704
01705
01706 WandExport void PixelSetColorCount(PixelWand *wand,const unsigned long count)
01707 {
01708 assert(wand != (const PixelWand *) NULL);
01709 assert(wand->signature == WandSignature);
01710 if (wand->debug != MagickFalse)
01711 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
01712 wand->count=count;
01713 }
01714
01715
01716
01717
01718
01719
01720
01721
01722
01723
01724
01725
01726
01727
01728
01729
01730
01731
01732
01733
01734
01735
01736
01737
01738
01739 WandExport void PixelSetColorFromWand(PixelWand *wand,const PixelWand *color)
01740 {
01741 assert(wand != (const PixelWand *) NULL);
01742 assert(wand->signature == WandSignature);
01743 if (wand->debug != MagickFalse)
01744 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
01745 assert(color != (const PixelWand *) NULL);
01746 wand->pixel=color->pixel;
01747 }
01748
01749
01750
01751
01752
01753
01754
01755
01756
01757
01758
01759
01760
01761
01762
01763
01764
01765
01766
01767
01768
01769
01770
01771
01772
01773 WandExport void PixelSetCyan(PixelWand *wand,const double cyan)
01774 {
01775 assert(wand != (const PixelWand *) NULL);
01776 assert(wand->signature == WandSignature);
01777 if (wand->debug != MagickFalse)
01778 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
01779 wand->pixel.red=(MagickRealType) RoundToQuantum((MagickRealType)
01780 QuantumRange*cyan);
01781 }
01782
01783
01784
01785
01786
01787
01788
01789
01790
01791
01792
01793
01794
01795
01796
01797
01798
01799
01800
01801
01802
01803
01804
01805
01806
01807 WandExport void PixelSetCyanQuantum(PixelWand *wand,const Quantum cyan)
01808 {
01809 assert(wand != (const PixelWand *) NULL);
01810 assert(wand->signature == WandSignature);
01811 if (wand->debug != MagickFalse)
01812 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
01813 wand->pixel.red=(MagickRealType) cyan;
01814 }
01815
01816
01817
01818
01819
01820
01821
01822
01823
01824
01825
01826
01827
01828
01829
01830
01831
01832
01833
01834
01835
01836
01837
01838
01839
01840 WandExport void PixelSetFuzz(PixelWand *wand,const double fuzz)
01841 {
01842 assert(wand != (const PixelWand *) NULL);
01843 assert(wand->signature == WandSignature);
01844 if (wand->debug != MagickFalse)
01845 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
01846 wand->pixel.fuzz=(MagickRealType) fuzz;
01847 }
01848
01849
01850
01851
01852
01853
01854
01855
01856
01857
01858
01859
01860
01861
01862
01863
01864
01865
01866
01867
01868
01869
01870
01871
01872
01873 WandExport void PixelSetGreen(PixelWand *wand,const double green)
01874 {
01875 assert(wand != (const PixelWand *) NULL);
01876 assert(wand->signature == WandSignature);
01877 if (wand->debug != MagickFalse)
01878 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
01879 wand->pixel.green=(MagickRealType) RoundToQuantum((MagickRealType)
01880 QuantumRange*green);
01881 }
01882
01883
01884
01885
01886
01887
01888
01889
01890
01891
01892
01893
01894
01895
01896
01897
01898
01899
01900
01901
01902
01903
01904
01905
01906
01907 WandExport void PixelSetGreenQuantum(PixelWand *wand,const Quantum green)
01908 {
01909 assert(wand != (const PixelWand *) NULL);
01910 assert(wand->signature == WandSignature);
01911 if (wand->debug != MagickFalse)
01912 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
01913 wand->pixel.green=(MagickRealType) green;
01914 }
01915
01916
01917
01918
01919
01920
01921
01922
01923
01924
01925
01926
01927
01928
01929
01930
01931
01932
01933
01934
01935
01936
01937
01938
01939
01940
01941
01942 WandExport void PixelSetHSL(PixelWand *wand,const double hue,
01943 const double saturation,const double lightness)
01944 {
01945 Quantum
01946 blue,
01947 green,
01948 red;
01949
01950 assert(wand != (const PixelWand *) NULL);
01951 assert(wand->signature == WandSignature);
01952 if (wand->debug != MagickFalse)
01953 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
01954 ConvertHSLToRGB(hue,saturation,lightness,&red,&green,&blue);
01955 wand->pixel.red=(MagickRealType) red;
01956 wand->pixel.green=(MagickRealType) green;
01957 wand->pixel.blue=(MagickRealType) blue;
01958 }
01959
01960
01961
01962
01963
01964
01965
01966
01967
01968
01969
01970
01971
01972
01973
01974
01975
01976
01977
01978
01979
01980
01981
01982
01983
01984 WandExport void PixelSetIndex(PixelWand *wand,const IndexPacket index)
01985 {
01986 assert(wand != (const PixelWand *) NULL);
01987 assert(wand->signature == WandSignature);
01988 if (wand->debug != MagickFalse)
01989 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
01990 wand->pixel.index=(MagickRealType) index;
01991 }
01992
01993
01994
01995
01996
01997
01998
01999
02000
02001
02002
02003
02004
02005
02006
02007
02008
02009
02010
02011
02012
02013
02014
02015
02016
02017 WandExport void PixelSetMagenta(PixelWand *wand,const double magenta)
02018 {
02019 assert(wand != (const PixelWand *) NULL);
02020 assert(wand->signature == WandSignature);
02021 if (wand->debug != MagickFalse)
02022 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
02023 wand->pixel.green=(MagickRealType) RoundToQuantum((MagickRealType)
02024 QuantumRange*magenta);
02025 }
02026
02027
02028
02029
02030
02031
02032
02033
02034
02035
02036
02037
02038
02039
02040
02041
02042
02043
02044
02045
02046
02047
02048
02049
02050
02051
02052 WandExport void PixelSetMagentaQuantum(PixelWand *wand,const Quantum magenta)
02053 {
02054 assert(wand != (const PixelWand *) NULL);
02055 assert(wand->signature == WandSignature);
02056 if (wand->debug != MagickFalse)
02057 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
02058 wand->pixel.green=(MagickRealType) magenta;
02059 }
02060
02061
02062
02063
02064
02065
02066
02067
02068
02069
02070
02071
02072
02073
02074
02075
02076
02077
02078
02079
02080
02081
02082
02083
02084
02085 WandExport void PixelSetMagickColor(PixelWand *wand,
02086 const MagickPixelPacket *color)
02087 {
02088 assert(wand != (const PixelWand *) NULL);
02089 assert(wand->signature == WandSignature);
02090 if (wand->debug != MagickFalse)
02091 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
02092 assert(color != (const MagickPixelPacket *) NULL);
02093 wand->pixel=(*color);
02094 }
02095
02096
02097
02098
02099
02100
02101
02102
02103
02104
02105
02106
02107
02108
02109
02110
02111
02112
02113
02114
02115
02116
02117
02118
02119
02120 WandExport void PixelSetOpacity(PixelWand *wand,const double opacity)
02121 {
02122 assert(wand != (const PixelWand *) NULL);
02123 assert(wand->signature == WandSignature);
02124 if (wand->debug != MagickFalse)
02125 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
02126 wand->pixel.matte=MagickTrue;
02127 wand->pixel.opacity=(MagickRealType) RoundToQuantum((MagickRealType)
02128 QuantumRange*opacity);
02129 }
02130
02131
02132
02133
02134
02135
02136
02137
02138
02139
02140
02141
02142
02143
02144
02145
02146
02147
02148
02149
02150
02151
02152
02153
02154
02155
02156 WandExport void PixelSetOpacityQuantum(PixelWand *wand,const Quantum opacity)
02157 {
02158 assert(wand != (const PixelWand *) NULL);
02159 assert(wand->signature == WandSignature);
02160 if (wand->debug != MagickFalse)
02161 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
02162 wand->pixel.opacity=(MagickRealType) opacity;
02163 }
02164
02165
02166
02167
02168
02169
02170
02171
02172
02173
02174
02175
02176
02177
02178
02179
02180
02181
02182
02183
02184
02185
02186
02187
02188
02189 WandExport void PixelSetQuantumColor(PixelWand *wand,const PixelPacket *color)
02190 {
02191 assert(wand != (const PixelWand *) NULL);
02192 assert(wand->signature == WandSignature);
02193 if (wand->debug != MagickFalse)
02194 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
02195 assert(color != (PixelPacket *) NULL);
02196 wand->pixel.red=(MagickRealType) color->red;
02197 wand->pixel.green=(MagickRealType) color->green;
02198 wand->pixel.blue=(MagickRealType) color->blue;
02199 wand->pixel.opacity=(MagickRealType) color->opacity;
02200 wand->pixel.matte=color->opacity != OpaqueOpacity ? MagickTrue : MagickFalse;
02201 }
02202
02203
02204
02205
02206
02207
02208
02209
02210
02211
02212
02213
02214
02215
02216
02217
02218
02219
02220
02221
02222
02223
02224
02225
02226
02227 WandExport void PixelSetRed(PixelWand *wand,const double red)
02228 {
02229 assert(wand != (const PixelWand *) NULL);
02230 assert(wand->signature == WandSignature);
02231 if (wand->debug != MagickFalse)
02232 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
02233 wand->pixel.red=(MagickRealType) RoundToQuantum((MagickRealType)
02234 QuantumRange*red);
02235 }
02236
02237
02238
02239
02240
02241
02242
02243
02244
02245
02246
02247
02248
02249
02250
02251
02252
02253
02254
02255
02256
02257
02258
02259
02260
02261 WandExport void PixelSetRedQuantum(PixelWand *wand,const Quantum red)
02262 {
02263 assert(wand != (const PixelWand *) NULL);
02264 assert(wand->signature == WandSignature);
02265 if (wand->debug != MagickFalse)
02266 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
02267 wand->pixel.red=(MagickRealType) red;
02268 }
02269
02270
02271
02272
02273
02274
02275
02276
02277
02278
02279
02280
02281
02282
02283
02284
02285
02286
02287
02288
02289
02290
02291
02292
02293
02294 WandExport void PixelSetYellow(PixelWand *wand,const double yellow)
02295 {
02296 assert(wand != (const PixelWand *) NULL);
02297 assert(wand->signature == WandSignature);
02298 if (wand->debug != MagickFalse)
02299 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
02300 wand->pixel.blue=(MagickRealType) RoundToQuantum((MagickRealType)
02301 QuantumRange*yellow);
02302 }
02303
02304
02305
02306
02307
02308
02309
02310
02311
02312
02313
02314
02315
02316
02317
02318
02319
02320
02321
02322
02323
02324
02325
02326
02327
02328 WandExport void PixelSetYellowQuantum(PixelWand *wand,const Quantum yellow)
02329 {
02330 assert(wand != (const PixelWand *) NULL);
02331 assert(wand->signature == WandSignature);
02332 if (wand->debug != MagickFalse)
02333 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
02334 wand->pixel.blue=(MagickRealType) yellow;
02335 }