#define BINARY 1
#define CHAR 2
+#define SHOW 3
int main(int argc,char **argv) {
int i,fd;
- t_bmp src;
+ t_bmp src,dst;
char in[128];
char out[128];
+ char blook[128+8];
unsigned char stat;
unsigned char buf[2];
int page,col;
/* the bitmap infile */
bmp_init(&src,1);
src.mode=READ;
- strcpy(src.file,in);
+ strncpy(src.file,in,128);
bmp_read_file(&src);
+ /* the bitmap outfile */
+ sprintf(blook,"blook_%s",in);
+ bmp_init(&dst,1);
+ dst.mode=WRITE;
+ strncpy(dst.file,blook,128+8);
+ dst.width=src.width;
+ dst.height=src.height;
+ bmp_alloc_map(&dst);
+
if((src.width!=DX)|(src.height=!DY)) {
printf("wrong dimensions: %d %d (need: %d %d)\n",
src.width,src.height,DX,DY);
if(b<=(0.25*255)) {
buf[0]|=(1<<i);
buf[1]|=(1<<i); // 1 1
+ dst.map[pix].r=0;
+ dst.map[pix].g=0;
+ dst.map[pix].b=0;
continue;
}
if(b<=(0.5*255)) {
buf[0]|=(1<<i); // 1 0
+ dst.map[pix].r=0.25*255;
+ dst.map[pix].g=0.25*255;
+ dst.map[pix].b=0.25*255;
continue;
}
if(b<=(0.75*255)) {
buf[1]|=(1<<i); // 0 1
+ dst.map[pix].r=0.75*255;
+ dst.map[pix].g=0.75*255;
+ dst.map[pix].b=0.75*255;
continue;
}
// 0 0 .. do nothing!
+ dst.map[pix].r=255;
+ dst.map[pix].g=255;
+ dst.map[pix].b=255;
}
if(stat==BINARY) {
i=write(fd,buf,2);
if(stat==CHAR)
dprintf(fd,"};\n");
+ bmp_write_file(&dst);
+
close(fd);
bmp_shutdown(&src);
+ bmp_shutdown(&dst);
return 0;
}