tool to create a color fade table
[physik/nlsop.git] / create_color_table.c
1 /*
2  * unable to use gimp?
3  * me too!
4  *
5  */
6
7 #include <stdio.h>
8 #include "bmp.h"
9
10 int main(int argc,char **argv) {
11
12         t_bmp bmp;
13         int i,j;
14         char val;
15         int off;
16
17         bmp_init(&bmp,2);
18
19         bmp.width=40;
20         bmp.height=120;
21         bmp.mode=WRITE;
22         if(argv[1][0]=='c') strcpy(bmp.file,"c-col.bmp");
23         else strcpy(bmp.file,"p-col.bmp");
24
25         bmp_alloc_map(&bmp);
26         
27         for(i=0;i<bmp.height;i++) {
28                 if(argv[1][0]=='c') {
29                         for(j=0;j<bmp.width;j++) {
30                                 off=i*bmp.width+j;
31                                 val=i*255/bmp.height;
32                                 bmp.map[off].r=val;
33                                 bmp.map[off].g=val;
34                                 bmp.map[off].b=0xff;
35                         }
36                 } else {
37                         for(j=0;j<bmp.width;j++) {
38                                 off=i*bmp.width+j;
39                                 if(i<bmp.height/2) {
40                                         val=i*255/(bmp.height/2); 
41                                         bmp.map[off].b=val;
42                                         bmp.map[off].g=0;
43                                         bmp.map[off].g=0;
44                                 } else {
45                                         val=(i-bmp.height/2)*255/(bmp.height/2);
46                                         bmp.map[off].b=0xff;
47                                         bmp.map[off].g=val;
48                                         bmp.map[off].b=0;
49                                 }
50                         }
51
52                 }
53         }
54
55         bmp_write_file(&bmp);
56
57         bmp_shutdown(&bmp);
58
59         return 1;
60 }