gwe@cbdkc1.UUCP ( George Erhart ) (03/21/85)
Hello, this is a little program to convert a MacPaint style bitmap to a blit twid style bitmap. The format of the MacPaint data fork has already been post. The format of the blit twid bitmap is as follows: XXXX XXXX XXXX XXXX [non-encoded bitmap data here] The XXXX's are paired so that the first pair are the 16 bit numbers for the origin or upper left corner. The second pair are the 16 bit numbers for the corner or lower right hand side of the screen. All the data is in unencoded binary format. The twid program can read this data provided your window size and memory are big enough. Also note that the coordinates are byte swapped, but the bitmap data is not. To compile this program type: cc -o decode decode.c To use this program, first use xbin on the .hex file. (If you got it from the net.) Or upload the document using a terminal program. Then type decode <pic.data >pic.twid Invoke the twid program while in layers. Click button 3 and select the *unix* entry, click again and select *read*. Type "pic1.twid" to load the bitmap. This program has NOT been tested with twid running on the DMD (5620). I would like to hear from you if it does work. Happy Hacking!!! George Erhart ATT-NS/Bell Labs {ihnp4,cbosgd}!cbdkc1!gwe ________________________CUT_HERE_______________________________________ #include <stdio.h> main() { unsigned char head[512]; unsigned long vers; int byte; int tag; char x; int index; short screen[4]; /* a kluge to set up the Rectangle structure that twid expects */ screen[0] = 0; /* origin 0,0 */ screen[1] = 0; screen[2] = 16386; /* corner 576,720 - note the byte swab! */ screen[3] = 53250; /* read MacPaint header ... skip it */ for (index = 0 ; index < 512 ; index ++) if ((head[index] = (unsigned char) getchar()) == EOF) exit( 1 ); /* make the version number if you are interested * for (index = 0; index < 4; index++) * vers = head[index]<<(3 - index); */ /* write the rect. coordinates into the output */ write(1,(char *)screen, 8); /* expand the scan data */ /* get the count byte */ while ((tag = getchar()) != EOF) { x = (char) tag; /* is this a compressed byte? */ if ((x < -1) && (x > -127)) { byte = getchar(); /* expand the compress byte to proper size */ for (index = abs((int) x)+1; index > 0; index--) { putchar(byte); } } else { /* skip -128 counts ... they are obsolete */ if (x == -128) /* nothing */ ; else { /* read raw uncompressed bytes */ if ((x >= 0) && (x < 128)) { for (index = (int) x+1; index > 0; index --) putchar(getchar()); } } } } }