Changes updates
[imager.git] / dynfilt / flines.c
CommitLineData
02d1d628
AMH
1#include "pluginst.h"
2
3
4char evalstr[]="Fancy lines";
5
6/* input parameters
7 image is the image object.
8*/
9
10
11
12unsigned char
13static
14saturate(int in) {
15 if (in>255) { return 255; }
16 else if (in>0) return in;
17 return 0;
18}
19
20
21
22void
23flines(void *INP) {
24 i_img *im;
25 i_color vl;
8d14daab 26 i_img_dim x,y;
02d1d628
AMH
27
28 if ( !getOBJ("image","Imager::ImgRaw",&im) ) {
29 fprintf(stderr,"Error: image is missing\n");
30 return;
31 }
32
8a2cd317 33 fprintf(stderr, "flines: parameters: (im %p)\n",im);
8d14daab
TC
34 fprintf(stderr, "flines: image info:\n size (" i_DFp ")\n channels (%d)\n",
35 i_DFcp(im->xsize,im->ysize), im->channels);
02d1d628
AMH
36
37 for(y = 0; y < im->ysize; y ++) {
ac575c5f
TC
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
02d1d628
AMH
47 for(x = 0; x < im->xsize; x ++ ) {
48 i_gpix(im,x,y,&vl);
ac575c5f
TC
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);
02d1d628
AMH
53 }
54 }
55}
56
57
58
59func_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