avoid dead code in i_tt_glyph_names()
[imager.git] / DynTest / linstretch.c
CommitLineData
92bda632
TC
1#include "imext.h"
2
3char evalstr[]="Description string of plugin dyntest - kind of like";
4
5void 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
92bda632 21static
a6eb1f94 22unsigned char
92bda632
TC
23saturate(int in) {
24 if (in>255) { return 255; }
25 else if (in>0) return in;
26 return 0;
27}
28
29void lin_stretch(i_img *im, int a, int b) {
30
31 i_color rcolor;
8d14daab
TC
32 i_img_dim x,y;
33 int i;
92bda632
TC
34
35
36 /* fprintf(stderr,"parameters: (im 0x%x,a %d,b %d)\n",im,a,b);*/
92bda632
TC
37
38 for(y=0;y<im->ysize;y++) for(x=0;x<im->xsize;x++) {
39 i_gpix(im,x,y,&rcolor);
40 for(i=0;i<im->channels;i++) rcolor.channel[i]=saturate((255*(rcolor.channel[i]-a))/(b-a));
41 i_ppix(im,x,y,&rcolor);
42 }
43
44}
45
46