Commit | Line | Data |
---|---|---|
92bda632 TC |
1 | #include "imext.h" |
2 | ||
3 | char evalstr[]="Description string of plugin dyntest - kind of like"; | |
4 | ||
5 | void null_plug(void *ptr) { } | |
6 | ||
7 | /* Example dynamic filter - level stretch (linear) - note it only stretches and doesn't compress */ | |
8 | ||
9 | /* input parameters | |
10 | a: the current black | |
11 | b: the current white | |
12 | ||
13 | 0 <= a < b <= 255; | |
14 | ||
15 | output pixel value calculated by: o=((i-a)*255)/(b-a); | |
16 | ||
17 | note that since we do not have the needed functions to manipulate the data structures *** YET *** | |
18 | */ | |
19 | ||
20 | ||
21 | unsigned char | |
22 | static | |
23 | saturate(int in) { | |
24 | if (in>255) { return 255; } | |
25 | else if (in>0) return in; | |
26 | return 0; | |
27 | } | |
28 | ||
29 | void lin_stretch(i_img *im, int a, int b) { | |
30 | ||
31 | i_color rcolor; | |
32 | int i,bytes,x,y; | |
33 | int info[4]; | |
34 | ||
35 | ||
36 | /* fprintf(stderr,"parameters: (im 0x%x,a %d,b %d)\n",im,a,b);*/ | |
37 | bytes=im->bytes; | |
38 | ||
39 | i_img_info(im,info); | |
40 | ||
41 | for(y=0;y<im->ysize;y++) for(x=0;x<im->xsize;x++) { | |
42 | i_gpix(im,x,y,&rcolor); | |
43 | for(i=0;i<im->channels;i++) rcolor.channel[i]=saturate((255*(rcolor.channel[i]-a))/(b-a)); | |
44 | i_ppix(im,x,y,&rcolor); | |
45 | } | |
46 | ||
47 | } | |
48 | ||
49 |