这个是用来生成ASCII点阵字库给液晶用的,在12232上测试通过。不过本程序只要倒序输出这一种功用。
请自行下载好ASC16文件。或许发邮件到我的信箱:dv.xw@qq.com讨取。BYET流量伤不起啊!
上代码(读取ASC16在他人的代码上改动完结):
/**************************************************** FILE qm.c* Write by 万致远 * 输出8x8字体* ************************************************/#include#include #include #include #include #include #include #include #ifdef DEBUG#define debug(fmt, ...) printf(fmt, #__VA_ARGS__)#else#define debug(fmt, ...)#endifvoid display_font_ascii(char *asc){int i, j,k=0;unsigned char outbuf[20];//8*8字体debug("=================");for(i=0;i<20;i++){outbuf[i]=0x00;}for(i=2;i<12;i++){if(i==9 || i == 10) continue;for(j=0;j<8;j++){/* 逐位相与,为1者打印“*”,不然打印空格 */if(asc[i] & (0x80>>j)){if(i==11){k=7;}else{k=i-2;}k=7-k;outbuf[j]=outbuf[j] | (0x80>>k);//printf("j=%d,value=0x%X,k=%d",j,0x80>>k,k);}else{//printf("0");}}//printf("");}printf("{");for(i=0;i<8;i++){if(i!=7){printf("0x%X,",outbuf[i]);}else{printf("0x%X}",outbuf[i]);}}debug("=================");}int main(){int i;unsigned char *p;//unsigned char asciicode[] = "B";unsigned long offset;FILE *asc;char ascii[16];if((asc=fopen("ASC16","rb"))==NULL){perror("Cant Open ASC16");exit(0);}printf("unsigned char __code ASCII[][8]={");/* ASCII字库文件 */for (i = 32; i < 127; i++){// debug("%c %x", asciicode[i], asciicode[i]); /* 打印数值 */offset = i*16;debug("offset: %x", offset); /* 打印偏移量 */fseek(asc,offset,SEEK_SET);fread(ascii,16,1,asc); /* 读取16字节 */display_font_ascii(ascii); /* 显现 */if(i==126){printf("};");}else{printf(",");}}fclose(asc);return 0;}