- prevent a cast to integer warning on x64 builds in datatypes.c
[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;
919e0000 26 int 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
TC
33 fprintf(stderr, "flines: parameters: (im %p)\n",im);
34 fprintf(stderr, "flines: image info:\n size (%d,%d)\n channels (%d)\n",
35 im->xsize,im->ysize,im->channels);
02d1d628
AMH
36
37 for(y = 0; y < im->ysize; y ++) {
38 for(x = 0; x < im->xsize; x ++ ) {
39 i_gpix(im,x,y,&vl);
40 if (!(y%2)) {
41 float yf = y/(float)im->ysize;
42 float mf = 1.2-0.8*yf;
43 vl.rgb.r = saturate(vl.rgb.r*mf);
44 vl.rgb.g = saturate(vl.rgb.g*mf);
45 vl.rgb.b = saturate(vl.rgb.b*mf);
46 } else {
47 float yf = (im->ysize-y)/(float)im->ysize;
48 float mf = 1.2-0.8*yf;
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 }
53 i_ppix(im,x,y,&vl);
54 }
55 }
56}
57
58
59
60func_ptr function_list[]={
61 {
62 "flines",
63 flines,
64 "callseq => ['image'], \
65 callsub => sub { my %hsh=@_; DSO_call($DSO_handle,0,\\%hsh); } \
66 "
67 },
68 {NULL,NULL,NULL}};
69
70
71/* Remember to double backslash backslashes within Double quotes in C */
72