add PROTOTYPES lines to XS that were missing them
[imager.git] / Flines / Flines.xs
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 unsigned char
16 static
17 saturate(int in) {
18   if (in>255) { return 255; }
19   else if (in>0) return in;
20   return 0;
21 }
22
23
24
25 void
26 flines(i_img *im) {
27   i_color vl;
28   int x,y;
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
52 DEFINE_IMAGER_CALLBACKS;
53
54 PROTOTYPES: ENABLE
55
56 MODULE = Imager::Filter::Flines   PACKAGE = Imager::Filter::Flines
57
58 void
59 flines(im)
60         Imager::ImgRaw im
61
62 BOOT:
63         PERL_INITIALIZE_IMAGER_CALLBACKS;
64