Coverity complained colors could be left uninitialized.
[imager.git] / CountColor / CountColor.xs
CommitLineData
b13a3ddb 1#define PERL_NO_GET_CONTEXT
92bda632
TC
2#ifdef __cplusplus
3extern "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
16DEFINE_IMAGER_CALLBACKS;
17
18int
19count_color(i_img *im, i_color *color) {
8d14daab
TC
20 i_img_dim x, y;
21 int chan;
92bda632
TC
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) {
92bda632 27 int match = 1;
06d470b1 28 i_gpix(im, x, y, &c);
92bda632
TC
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
42MODULE = Imager::CountColor PACKAGE = Imager::CountColor
43
44PROTOTYPES: ENABLE
45
46int
47count_color(im, color)
48 Imager::ImgRaw im
49 Imager::Color color
50
51BOOT:
52 PERL_INITIALIZE_IMAGER_CALLBACKS;
53