Change to the linux kernel coding style
[wmaker-crm.git] / plugins / libwmfun / bilinear.c
blob148d7a14d970303febe280d6b81a767aaf74bfec
1 /*
2 * libwmfun - WindowMaker texture function library
3 * Copyright (C) 1999 Tobias Gloth
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
18 * USA.
22 * $Id$
24 * $Log$
25 * Revision 1.1 2000/12/03 18:58:41 id
26 * initiate plugins branch
28 * Revision 1.1.1.1 1999/02/21 17:16:47 gloth
29 * initial revision
33 #include "generic.h"
35 RImage *bilinear(int argc, char **argv, int width, int height, int relief)
38 int color[4][3];
39 RImage *image;
40 unsigned char *cptr;
41 int i, j, k;
43 argc--;
44 argv++;
46 if (!start_image("bilinear", argc, 4, 5, width, height, &image)) {
47 return (RImage *) 0;
50 for (i = 0; i < 4; i++) {
51 if (!parse_color(argv[i], color[i])) {
52 error("can't parse color: \"%s\"\n", argv[i]);
53 return 0;
57 cptr = image->data;
58 for (i = 0; i < height; i++) {
59 int b = 0xff * i / height;
60 int t = 0xff - b;
62 for (j = 0; j < width; j++) {
63 int r = 0xff * j / width;
64 int l = 0xff - r;
65 int f[4];
67 f[0] = (l * t) >> 8;
68 f[1] = (r * t) >> 8;
69 f[2] = (l * b) >> 8;
70 f[3] = (r * b) >> 8;
72 for (k = 0; k < 3; k++) {
73 *cptr++ =
74 (f[0] * color[0][k] +
75 f[1] * color[1][k] + f[2] * color[2][k] + f[3] * color[3][k]) >> 8;
78 if (RRGBAFormat == image->format)
79 cptr++;
82 return image;