File: mapping.c

package info (click to toggle)
xpaint 2.7.6-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 2,532 kB
  • ctags: 3,405
  • sloc: ansic: 36,749; makefile: 49; sh: 18
file content (32 lines) | stat: -rw-r--r-- 853 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/* XPaint-filter */

#include <Xpaint.h>

/* 
 * The key-word "FilterProcess" is reserved for user-defined filter routines;
 * Such a filter processes an "input" image and renders an "output" image.
 * 
 * Pixels are unsigned char arrays p[0]=red, p[1]=green, p[2]=blue
 * (thus each value should be in the range 0..255)
 *
 * In the example below, op = output pixel (input image is not used!)
 * The procedure below just creates an image by mapping given functions
 * as red, green, blue components...
 */

void FilterProcess(Image * input, Image * output)
{
    unsigned char *ip, *op;
    int x, y;

    for (y = 0; y < input->height; y++) {
        for (x = 0; x < input->width; x++) {
            op = ImagePixel(output, x, y);
            op[0] = (x+y+x*(1000-x)/500)%256;
            op[1] = y%256;
            op[2] = x%256;
        }
    }
}