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