| 1 |
#define PERL_NO_GET_CONTEXT |
| 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 |
static unsigned char |
| 17 |
saturate(int in) { |
| 18 |
if (in>255) { return 255; } |
| 19 |
else if (in>0) return in; |
| 20 |
return 0; |
| 21 |
} |
| 22 |
|
| 23 |
static void |
| 24 |
flines(i_img *im) { |
| 25 |
i_color vl; |
| 26 |
i_img_dim x,y; |
| 27 |
|
| 28 |
for(y = 0; y < im->ysize; y ++) { |
| 29 |
float yf, mf; |
| 30 |
if (!(y%2)) { |
| 31 |
yf = y/(double)im->ysize; |
| 32 |
} |
| 33 |
else { |
| 34 |
yf = (im->ysize-y)/(double)im->ysize; |
| 35 |
} |
| 36 |
mf = 1.2-0.8*yf; |
| 37 |
|
| 38 |
for(x = 0; x < im->xsize; x ++ ) { |
| 39 |
i_gpix(im,x,y,&vl); |
| 40 |
vl.rgb.r = saturate(vl.rgb.r*mf); |
| 41 |
vl.rgb.g = saturate(vl.rgb.g*mf); |
| 42 |
vl.rgb.b = saturate(vl.rgb.b*mf); |
| 43 |
i_ppix(im,x,y,&vl); |
| 44 |
} |
| 45 |
} |
| 46 |
} |
| 47 |
|
| 48 |
|
| 49 |
DEFINE_IMAGER_CALLBACKS; |
| 50 |
|
| 51 |
MODULE = Imager::Filter::Flines PACKAGE = Imager::Filter::Flines |
| 52 |
|
| 53 |
PROTOTYPES: ENABLE |
| 54 |
|
| 55 |
void |
| 56 |
flines(im) |
| 57 |
Imager::ImgRaw im |
| 58 |
|
| 59 |
BOOT: |
| 60 |
PERL_INITIALIZE_IMAGER_CALLBACKS; |
| 61 |
|