fixed nlsop for packaging ..
[physik/nlsop.git] / 3dplot.c
1 /* 3dplot.c -- 3d plot bmp image */
2
3 /*
4  * author: frank.zirkelbach@physik.uni-augsburg.de
5  *
6  */
7
8 #define _GNU_SOURCE
9 #include <stdio.h>
10
11 #include <stdio.h>
12 #include "bmp.h"
13
14 int main(int argc,char **argv) {
15
16   t_bmp bmp;
17   int x,y;
18   int help;
19   int val;
20
21   if(argc!=2) {
22     printf("usage: %s <filename>\n",argv[0]);
23     return -1;
24   }
25
26   bmp_init(&bmp,2);
27   bmp.mode=READ;
28   strcpy(bmp.file,argv[1]);
29
30   bmp_read_file(&bmp);
31
32   dprintf(2,"width = %d\n",bmp.info.width);
33
34   for(x=0;x<bmp.info.width;x++) {
35     for(y=0;y<bmp.info.height;y++) {
36       help=y*bmp.info.width+x;
37       val=(bmp.map[help].r+bmp.map[help].g+bmp.map[help].b)/3;
38       if(val!=0)
39         printf("%f %f %d\n",1.0*(x-bmp.info.width/2)/(bmp.info.width*3),
40                1.0*(y-bmp.info.height/2)/(bmp.info.height*3),val);
41     }
42   }
43
44   bmp_shutdown(&bmp);
45
46   return 1;
47 }