Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 52 lines (43 sloc) 0.897 kb
b13a3ddb » Tony Cook
2010-05-06 - use PERL_NO_GET_CONTEXT to slightly improve performance on threaded
1 #define PERL_NO_GET_CONTEXT
92bda632 » Tony Cook
2006-01-10 - start of external Imager API access:
2 #ifdef __cplusplus
3 extern "C" {
4 #endif
5 #include "EXTERN.h"
6 #include "perl.h"
7 #include "XSUB.h"
8 #include "ppport.h"
9 #ifdef __cplusplus
10 }
11 #endif
12
13 #include "imext.h"
14 #include "imperl.h"
15
16 DEFINE_IMAGER_CALLBACKS;
17
18 int
19 count_color(i_img *im, i_color *color) {
8d14daab »
2011-06-14 switch to using size_t and i_img_dim strictly
20 i_img_dim x, y;
21 int chan;
92bda632 » Tony Cook
2006-01-10 - start of external Imager API access:
22 i_color c;
23 int count = 0;
24
25 for (x = 0; x < im->xsize; ++x) {
26 for (y = 0; y < im->ysize; ++y) {
27 int match = 1;
06d470b1 » Tony Cook
2006-01-10 make more C89 compliant
28 i_gpix(im, x, y, &c);
92bda632 » Tony Cook
2006-01-10 - start of external Imager API access:
29 for (chan = 0; chan < im->channels; ++chan) {
30 if (c.channel[chan] != color->channel[chan]) {
31 match = 0;
32 break;
33 }
34 }
35 if (match) ++count;
36 }
37 }
38
39 return count;
40 }
41
42 MODULE = Imager::CountColor PACKAGE = Imager::CountColor
43
44 PROTOTYPES: ENABLE
45
46 int
47 count_color(im, color)
48 Imager::ImgRaw im
49 Imager::Color color
50
51 BOOT:
52 PERL_INITIALIZE_IMAGER_CALLBACKS;
53
Something went wrong with that request. Please try again.