This is the code I talked about earlier. Just rips the bottom 2 bits out of a 4-bit bitmap to make a 2-bit bitmap. So to use this you make a 4-bit bitmap with grayscale. Black, 50% Gray, 25% Gray, White. Paint is where I made the bitmaps. It must be 128×32. The program doesn’t do any checks on this, its fairly stupid.
#include <stdio.h>
void main(void)
{
char str[80];
char nstr[80];
int image[2048];
int ripped[1024];
int flipped[1024];
int i,j;
int header_junk;
FILE *fp, *nfp;
printf("4-Bit BMP File Name? : ");
gets(str);
printf("Opening File. : %s\n",str);
fp = fopen(str, "r");
if (fp == NULL)
{
fprintf(stderr, "File Can Not Be Opened.\n");
exit(1);
}
printf("File Opened Successful!\n");
printf("2-Bit DMD File Name? (format XXX.DMD) : ");
gets(nstr);
printf("\nCreating New File Named: %s.dmd\n",str);
nfp = fopen(nstr, "w");
printf("Reading Header.\n");
for( i = 0 ; i < 118 ; i++)
{
header_junk = fgetc (fp);
printf("0x%.2X ", header_junk);
}
printf("\nHeader Ripped.\n");
printf("Reading Image Data\n");
for( i = 0 ; i < 2048 ; i ++)
{
image[i] = fgetc (fp);
printf("0x%.2X ", image[i]);
}
printf("\nRipping bits out and Rotating!\n");
for( i = 0 ; i < 1024 ; i ++)
{
ripped[i] = (((image[2*i] & 0x80))| ((image[2*i] & 0x40)) | ((image[2*i] & 0x08)<<2) | ((image[2*i] & 0x04)<<2) | ((image[2*i+1] & 0x80) >> 4) | ((image[2*i+1] & 0x40) >> 4) | ((image[2*i+1] & 0x08) >>2) | ((image[2*i+1] & 0x04) >>2));
printf("0x%.2X ", ripped[i]);
}
printf("\nFlipping Image.\n");
for( j = 0 ; j < 32 ; j ++)
{
for( i = 0 ; i < 32 ; i++)
{
flipped [(992-(32*j))+i] = ripped[(32*j)+i];
}
}
printf("\nWriting To New File\n");
for( i = 0 ; i < 1024 ; i++)
{
fputc(flipped[i],nfp);
printf("0x%.2X ", flipped[i]);
}
fclose(nfp);
fclose(fp);
printf("\nDone!\n");
printf("Press Any Key To Quit...");
gets(str);
exit(1);
}