add PROTOTYPES lines to XS that were missing them
[imager.git] / Flines / Flines.xs
CommitLineData
88666683
TC
1#ifdef __cplusplus
2extern "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
15unsigned char
16static
17saturate(int in) {
18 if (in>255) { return 255; }
19 else if (in>0) return in;
20 return 0;
21}
22
23
24
25void
26flines(i_img *im) {
27 i_color vl;
af070d99 28 int x,y;
88666683
TC
29
30 for(y = 0; y < im->ysize; y ++) {
31 for(x = 0; x < im->xsize; x ++ ) {
32 i_gpix(im,x,y,&vl);
33 if (!(y%2)) {
34 float yf = y/(float)im->ysize;
35 float mf = 1.2-0.8*yf;
36 vl.rgb.r = saturate(vl.rgb.r*mf);
37 vl.rgb.g = saturate(vl.rgb.g*mf);
38 vl.rgb.b = saturate(vl.rgb.b*mf);
39 } else {
40 float yf = (im->ysize-y)/(float)im->ysize;
41 float mf = 1.2-0.8*yf;
42 vl.rgb.r = saturate(vl.rgb.r*mf);
43 vl.rgb.g = saturate(vl.rgb.g*mf);
44 vl.rgb.b = saturate(vl.rgb.b*mf);
45 }
46 i_ppix(im,x,y,&vl);
47 }
48 }
49}
50
51
52DEFINE_IMAGER_CALLBACKS;
53
94022fed
TC
54PROTOTYPES: ENABLE
55
88666683
TC
56MODULE = Imager::Filter::Flines PACKAGE = Imager::Filter::Flines
57
58void
59flines(im)
60 Imager::ImgRaw im
61
62BOOT:
63 PERL_INITIALIZE_IMAGER_CALLBACKS;
64