| 1 |
#include "pluginst.h" |
| 2 |
|
| 3 |
|
| 4 |
char evalstr[]="Fancy lines"; |
| 5 |
|
| 6 |
/* input parameters |
| 7 |
image is the image object. |
| 8 |
*/ |
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
unsigned char |
| 13 |
static |
| 14 |
saturate(int in) { |
| 15 |
if (in>255) { return 255; } |
| 16 |
else if (in>0) return in; |
| 17 |
return 0; |
| 18 |
} |
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
void |
| 23 |
flines(void *INP) { |
| 24 |
i_img *im; |
| 25 |
i_color vl; |
| 26 |
i_img_dim x,y; |
| 27 |
|
| 28 |
if ( !getOBJ("image","Imager::ImgRaw",&im) ) { |
| 29 |
fprintf(stderr,"Error: image is missing\n"); |
| 30 |
return; |
| 31 |
} |
| 32 |
|
| 33 |
fprintf(stderr, "flines: parameters: (im %p)\n",im); |
| 34 |
fprintf(stderr, "flines: image info:\n size (" i_DFp ")\n channels (%d)\n", |
| 35 |
i_DFcp(im->xsize,im->ysize), im->channels); |
| 36 |
|
| 37 |
for(y = 0; y < im->ysize; y ++) { |
| 38 |
float yf, mf; |
| 39 |
if (!(y%2)) { |
| 40 |
yf = y/(double)im->ysize; |
| 41 |
} |
| 42 |
else { |
| 43 |
yf = (im->ysize-y)/(double)im->ysize; |
| 44 |
} |
| 45 |
mf = 1.2-0.8*yf; |
| 46 |
|
| 47 |
for(x = 0; x < im->xsize; x ++ ) { |
| 48 |
i_gpix(im,x,y,&vl); |
| 49 |
vl.rgb.r = saturate(vl.rgb.r*mf); |
| 50 |
vl.rgb.g = saturate(vl.rgb.g*mf); |
| 51 |
vl.rgb.b = saturate(vl.rgb.b*mf); |
| 52 |
i_ppix(im,x,y,&vl); |
| 53 |
} |
| 54 |
} |
| 55 |
} |
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
func_ptr function_list[]={ |
| 60 |
{ |
| 61 |
"flines", |
| 62 |
flines, |
| 63 |
"callseq => ['image'], \ |
| 64 |
callsub => sub { my %hsh=@_; DSO_call($DSO_handle,0,\\%hsh); } \ |
| 65 |
" |
| 66 |
}, |
| 67 |
{NULL,NULL,NULL}}; |
| 68 |
|
| 69 |
|
| 70 |
/* Remember to double backslash backslashes within Double quotes in C */ |
| 71 |
|