]>
Commit | Line | Data |
---|---|---|
92bda632 TC |
1 | #ifdef __cplusplus |
2 | extern "C" { | |
3 | #endif | |
4 | #include "EXTERN.h" | |
5 | #include "perl.h" | |
6 | #include "XSUB.h" | |
7 | #include "ppport.h" | |
8 | #ifdef __cplusplus | |
9 | } | |
10 | #endif | |
11 | ||
12 | #include "imext.h" | |
13 | #include "imperl.h" | |
14 | ||
15 | DEFINE_IMAGER_CALLBACKS; | |
16 | ||
17 | int | |
18 | count_color(i_img *im, i_color *color) { | |
19 | int x, y, chan; | |
20 | i_color c; | |
21 | int count = 0; | |
22 | ||
23 | for (x = 0; x < im->xsize; ++x) { | |
24 | for (y = 0; y < im->ysize; ++y) { | |
25 | i_gpix(im, x, y, &c); | |
26 | int match = 1; | |
27 | for (chan = 0; chan < im->channels; ++chan) { | |
28 | if (c.channel[chan] != color->channel[chan]) { | |
29 | match = 0; | |
30 | break; | |
31 | } | |
32 | } | |
33 | if (match) ++count; | |
34 | } | |
35 | } | |
36 | ||
37 | return count; | |
38 | } | |
39 | ||
40 | MODULE = Imager::CountColor PACKAGE = Imager::CountColor | |
41 | ||
42 | PROTOTYPES: ENABLE | |
43 | ||
44 | int | |
45 | count_color(im, color) | |
46 | Imager::ImgRaw im | |
47 | Imager::Color color | |
48 | ||
49 | BOOT: | |
50 | PERL_INITIALIZE_IMAGER_CALLBACKS; | |
51 |