求助汉字转换点阵编程
我现在想把汉字转换成16*16的点阵代码(如0x23),一个汉字32个代码,不知如何编写源码,我是初学者。望各位高手不吝赐教,谢谢!
[解决办法]
要有字库。比如UCDOS里面有16x16的字模。
然后看你要转换成什么样的编码,照着写就成了,很简单的。
[解决办法]
点阵字模
[解决办法]
#include <mem.h>#include <stdlib.h>#include <stdio.h>#include <conio.h>#include <graphics.h>const unsigned char bit[8]={128,64,32,16,8,4,2,1};//--------------------void dis(xoff,code) unsigned int xoff,code;{ unsigned char *buffer; FILE *hzk; unsigned long offset; unsigned int q,w; int x,y,width; buffer=calloc(32,1); if ((code&0xFF00)!=0) { w=(code&0x00FF)-0xA1; q=((code>>8)&0x00FF)-0xA1; offset=q*0x5E+w; offset*=32; if ((hzk=fopen("HZK16","rb"))==NULL) { closegraph(); printf("Can not open HZK16\r\n"); exit(1); } fseek(hzk,offset,SEEK_SET); fread(buffer,1,32,hzk); fclose(hzk); width=2; } else { if ((hzk=fopen("ASC16","rb"))==NULL) { closegraph(); printf("Can not open ASC16\r\n"); exit(1); } offset=code*16; fseek(hzk,offset,SEEK_SET); fread(buffer,1,16,hzk); fclose(hzk); width=1; } for (y=0;y<16;y++) for (x=0;x<8*width;x++) { if (buffer[y*width+x/8]&bit[x%8]) putpixel(xoff+x,y,15); } free(buffer);}//--------------------void display(p) unsigned char *p;{ int i; unsigned int qw; i=0; while (1) { if (p[i]==0x0D||p[i]==0x1A) break; if (p[i]>0xA0) { qw=((unsigned int)p[i]<<8)|((unsigned int)p[i+1]&0x00FF); dis(8*i,qw); i+=2; } else { qw=(unsigned int)p[i]&0x00FF; dis(8*i,qw); i++; } }}//--------------------void main(){ int gdriver = DETECT, gmode, errorcode; long fl; FILE *hz; unsigned char *p; initgraph(&gdriver, &gmode, "c:\\borlandc\\bgi"); errorcode = graphresult(); if (errorcode != grOk) { printf("Graphics error: %s\n", grapherrormsg(errorcode)); exit(1); } hz=fopen("hz","rb"); fseek(hz,0,SEEK_END); fl=ftell(hz); p=calloc((int)fl,sizeof(unsigned char)); rewind(hz); fread(p,1,(int)fl,hz); fclose(hz); display(p); free(p); getch(); closegraph();}
[解决办法]