#define FROM_BYTE 118 /*bitmap data area, from and to, inclusively*/ #define TO_BYTE 141558 /*equal to file size*/ #define MAX_X 640 /*maximum even x coordinate.(If maximum x is odd, then force add 1 to make even) */ #define MAX_Y 441 #define INTENSITY_FILTER 15 /*to ignore all points with color intensity fainter than the value we assign here (inclusively) ie. treat all those points as "not exist". 15 is purely white 0 is purely black.*/ #include main() { FILE *fr; FILE *ffww; char cr; int ir, x, x1, x2, y=441, stat, i, k=0, r=0, m=0, n=0, s1=9, s2=9,v,mx; int chkpnt(); long bytenumber, bn, p; fr= fopen("in.bmp", "r"); ffww= fopen("output.xy1", "w"); mx= MAX_X/2; /* skip over headers in order to arrive at the data section */ for(i=1; i=mx; bn-=mx, k++){} r=bn; x1=2*r; x2=2*r+1; /*Start to deal with the bits ie. content of the byte*/ for(m=0; ir>15; ir-=16, m++){} n=ir; if(m>=INTENSITY_FILTER) {s1=0;} else s1=1; if(n>=INTENSITY_FILTER) {s2=0;} else s2=1; if(s1==1){fprintf(ffww,"[0](%d,%d)\n",x1,y);} if(s2==1){fprintf(ffww,"[0](%d,%d)\n",x2,y);} y=MAX_Y-k; s1=9; s2=9; /*so that old values don't carry over to next round*/ } fclose(fr); fclose(ffww); } /* END of Main*/