汉字显示技术
#include"stdio.h"#include"graphics.h"
void fnGet_hzm(char chIncode[],char chByte[]);/*获取汉字模*/
void fnDisp_hzm(int X,int Y,int Color,int Xscale,int Yscale,char chBuf[]);
/*按照指定大小显示汉字模*/
void fnDisHz16X16(int X,int Y,int Width,int Color,int Xcale,int Yscal,char *pStr);
/*按照指定大小显示汉字*/
FILE *pFile;
char *chMain[6]={"陕西航空职业技术学院",
"电子工程系"
"地址:中国陕西南郑县"
"Tel:0916-8624335 Fax:0916-8624335"
"E-mail:fanyanggang2008@
};
void fnGet_hzm(char chIncode[],char chBytes[])
{
unsigned char chQh,chWh;
unsigned long ulOffset;
chQh=chIncode[0]-0xa0;
chWh=chIncode[1]-0xa0;
if(chQh>9)
chQh-=6;
ulOffset=(94*(chQh-1)+(chWh-1))*32L;
fseek(pFile,ulOffset,SEEK_SET);
fread(chBytes,1,32,pFile);
}
void fnDisp_hzm(int X,int Y,int Color, int Xscale, int Yscale,char chBuf[])
{
int i,j,k,x,y;
for(i=0;i<16;i++)
for(j=0;j<2;j++)
for(k=0;k<8;k++)
if(chBuf[i*2+j]>>(7-k)&&0x01)
{
for(X1=0;X1<Xscale;X1++)
for(Y1=0;Y1<Yscale;Y1++)
putpixel((X+j*8+k)*Xscale+X1,(Y+i)*Yscale+Y1,Color);
}
}
void fnDisHz16X16(int X,int Y,int Width,int Color,int Xscale,int Yscale,char *pStr)
{
unsigned char chBuf[35];
while(*pStr)
{
if((pStr&0x80)&&(*(pStr+1)&0x80))
{
fnGet_hzm(pStr,chBuf);
fnDisp_ham(X,Y,Color,Xscale,Yscale,chBuf);
x+=(16+Width);
pStr+=2;
}
}
}
void main()
{
int GraphDriver,GraphMode,i;
pFile=fopen("hk16.dot","rb");
if(pFile==NULL)
exit();
detectgraph(&GraphDriver,&GraphMode);
initgraph(&GraphDriver,&GraphMode,"D:\\tc");
setfillestyle(1,1);
bar(10,10,400,320);
fnDisHz16X16(20,15,4,14,2,3,chMain[0]);
setcolor(14);
outtextxy(120,170,4,14,2,2,"范阳刚");
fnDisHz16X16(50,250,4,14,1,1,"副会长");
fnDisHz16X16(50,250,4,14,1,1,chMain[3]);
outtextxy(50,280,chMain[4]);
outtextxy(50,290,chMain[5]);
fclose(pFile);
getch();
closegraph();
}
中间哪有问题啊!!!调试不出结果!!!
[ 本帖最后由 bingshiwuyu 于 2010-6-1 12:41 编辑 ]