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 pix=((page*8+i)*DX)+col;
103 b=src.map[pix].r+src.map[pix].g+src.map[pix].b;
107 buf[1]|=(1<<i); // 1 1
114 buf[0]|=(1<<i); // 1 0
115 dst.map[pix].r=0.25*255;
116 dst.map[pix].g=0.25*255;
117 dst.map[pix].b=0.25*255;
121 buf[1]|=(1<<i); // 0 1
122 dst.map[pix].r=0.75*255;
123 dst.map[pix].g=0.75*255;
124 dst.map[pix].b=0.75*255;
127 // 0 0 .. do nothing!
139 printf("write failure\n");
143 else if(stat==CHAR) {
144 dprintf(fd,"\t0x%02x,0x%02x%c\n",buf[0],buf[1],
145 ((page+1==PM)&(col+1==DX))?' ':',');
153 bmp_write_file(&dst);