X-Git-Url: https://hackdaworld.org/gitweb/?a=blobdiff_plain;f=betty%2Fbmp2b.c;h=e006609d2dfe245d5b3d13d5d1d144543e3e7bc1;hb=96c6e10b97b3cce49a3c2090108ea29d23ec3950;hp=9baf3b57b1da11ad14d545e67036deb192f0cf38;hpb=69c590669acb39977d264c7c2103e0d2582b2e36;p=my-code%2Farm.git diff --git a/betty/bmp2b.c b/betty/bmp2b.c index 9baf3b5..e006609 100644 --- a/betty/bmp2b.c +++ b/betty/bmp2b.c @@ -21,13 +21,15 @@ #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; @@ -64,9 +66,18 @@ int main(int argc,char **argv) { /* 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); @@ -88,23 +99,36 @@ int main(int argc,char **argv) { buf[0]=0; buf[1]=0; for(i=0;i<8;i++) { - pix=((page*8+i)*DX)+col; + // bmp: bottom rows first ... (i forgot that!) + pix=((DY-1-(page*8+i))*DX)+col; b=src.map[pix].r+src.map[pix].g+src.map[pix].b; b/=3; if(b<=(0.25*255)) { buf[0]|=(1<