2 * bmp2b.c - convert colored 24 bit bmp to the betty display ram format
4 * author: hackbard@hackdaworld.org
13 #include <sys/types.h>
26 int main(int argc,char **argv) {
44 strncpy(in,argv[++i],128);
47 strncpy(out,argv[++i],128);
57 printf("%s -i <bitmap> -o <out file> [-b/c]\n",
60 printf(" -b: binary out\n");
61 printf(" -c: char array\n\n");
66 /* the bitmap infile */
69 strncpy(src.file,in,128);
72 /* the bitmap outfile */
73 sprintf(blook,"blook_%s",in);
76 strncpy(dst.file,blook,128+8);
78 dst.height=src.height;
81 if((src.width!=DX)|(src.height=!DY)) {
82 printf("wrong dimensions: %d %d (need: %d %d)\n",
83 src.width,src.height,DX,DY);
88 fd=open(out,O_WRONLY|O_CREAT);
90 perror("open outfile");
95 dprintf(fd,"unsigned char default_logo[%d]={\n",DX*PM*2);
97 for(page=0;page<PM;page++) {
98 for(col=0;col<DX;col++) {
102 // bmp: bottom rows first ... (i forgot that!)
103 pix=((DY-1-(page*8+i))*DX)+col;
104 b=src.map[pix].r+src.map[pix].g+src.map[pix].b;
108 buf[1]|=(1<<i); // 1 1
115 buf[0]|=(1<<i); // 1 0
116 dst.map[pix].r=0.25*255;
117 dst.map[pix].g=0.25*255;
118 dst.map[pix].b=0.25*255;
122 buf[1]|=(1<<i); // 0 1
123 dst.map[pix].r=0.75*255;
124 dst.map[pix].g=0.75*255;
125 dst.map[pix].b=0.75*255;
128 // 0 0 .. do nothing!
140 printf("write failure\n");
144 else if(stat==CHAR) {
145 dprintf(fd,"\t0x%02x,0x%02x%c\n",buf[0],buf[1],
146 ((page+1==PM)&(col+1==DX))?' ':',');
154 bmp_write_file(&dst);