怎样用c语言程序提取汉字库中的数据?急求!

如题所述

第1个回答  2011-04-28
FILE *PHZK16;
/*
*HZK16字库初始化_打开字库
*/
void _InitHzk16()
{
PHZK16=fopen("Hzk16","rb");
if(!PHZK16){
printf("error in Hzk16,not exist\n");
system("pause");
exit(1);
}
}
/*
*取得字码
*/
void _GetHzk16Code(unsigned char code[],unsigned char bytes[])
{
unsigned char qh,wh;
unsigned long offset;
qh=code[0]-0xa0; /*得到区号*/
wh=code[1]-0xa0; /*得到位号*/
offset=(94*(qh-1)+(wh-1))*32L; /*得到偏移位置*/
fseek(PHZK16,offset,SEEK_SET); /*移文件指针到要读取的汉字字模处*/
fread(bytes,32,1,PHZK16); /*读取32 个汉字的汉字字模*/
}

/******************************************************************************************************************/
/*下面这个代码 是C画图模式下可用*/
/*
*改变x、y(左上点)的位置,就可以实现文字的横向输出
*单个文字输出
*/
void _InputHzk16(int x,int y,unsigned char code[],int color)
{
int i,j,x0=0,y0=0;
unsigned char s,mat[32];

_GetHzk16Code(code,mat);

for(i=0;i<16;i++){
s=mat[2*i];
x0=x+7;
y0=y+i;
while(s){
if(s%2){
putpixel(x0,y0,color);
}
s=s/2;
x0--;
}
s=mat[2*i+1];
x0=x+15;
while(s){
if(s%2){
putpixel(x0,y0,color);
}
s=s/2;
x0--;
}
}
}
相似回答