map

For Filter Factory compatibility only

Syntax

int map(int i, int n)

Arguments

i
The index number, divided by two, of the first of two consecutive slider controls
n
The value to map between the range.

Return

The pixel value mapped to the narrower range of values.

Description

The map function takes two consecutive STANDARD values and maps the given pixel value between them. Lowering the Map 1 slider value causes the image to brighten, while raising the Map 2 slider value causes it to darken, if applied to an entire image.

Internally, the map function works like this:

(n < MAP2) ? 0 : (n > MAP1) ? 255 : (MAP1 == MAP2) ? 255 : (n-MAP2)*255/(MAP1-MAP2);

Example

%ffp

ctl[2]: "Map 1", Range=(0,255), Val=255
ctl[3]: "Map 2", Range=(0,255), Val=0

ForEveryTile: {
  for (y = y_start; y &lt; y_end; y++) {
    for (x = x_start; x &lt; x_end; x++) {
       for (z=0; z &lt; 3; z++) {
          pset(x,y,z, map(1, src(x,y,z)) );
       }
    }
  }
  return true;
}