当前位置: 代码迷 >> C语言 >> 24点阵"中"变成了"逍"怎么回事
  详细解决方案

24点阵"中"变成了"逍"怎么回事

热度:1006   发布时间:2007-10-22 08:01:42.0
24点阵"中"变成了"逍"怎么回事

我想做个24点阵的汉字显示,原本显示不出来,后来上网查了一下原来是24点阵字模横竖方向给倒了过来,我又用了个矩阵倒置的方摆正字模,不料显示是能显示了却不是原来的字了,"中"字变成了"逍",怎么回事?
#include<stdio.h>
#include<graphics.h>
void hanzi16(int x,int y,char *s,int colour)
{
FILE *fp;
char buffer[24][3];
register i,j,k;
unsigned char qh,wh;
unsigned long location;
if((fp=fopen("c:\\hzk24K","rb"))==NULL)
{
printf("can't open hzk16");
getch();
exit(0);
}
/*while(*s)
{ */
qh=*s-0xa0;
wh=*(s+1)-0xa0;
location=(94*(qh-1)+(wh-1))*72L;
fseek(fp,location,SEEK_SET);
fread(buffer,72,1,fp);
for(i=0;i<24;i++)
for(j=0;j<24;j++)
if(buffer[j][i/8]&(0x80>>i%8))
putpixel(x+j,y+i,colour);
/*s+=2;
x+=24;*/

fclose(fp);
}
main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"");
hanzi16(246,200,"中",BROWN);
getch();
closegraph();
}

搜索更多相关的解决方案: int  char  字模  unsigned  

----------------解决方案--------------------------------------------------------
我运行了你的程序!显示的是中啊!不过中是向右边横着的,是不是你的字库不对啊?还有失败的怎么提示是HZK16打不开,你不是用24的字库的吗?
----------------解决方案--------------------------------------------------------



#include<stdio.h>
#include<graphics.h>
void hanzi16(int x,int y,char *s,int colour)
{
FILE *fp;
char buffer[24][3];
register i,j,k;
unsigned char qh,wh;
unsigned long location;
if((fp=fopen("c:\\hzk24K","rb"))==NULL)
{
printf("can't open hzk16");
getch();
exit(0);
}
/*while(*s)
{ */
qh=*s-0xa0;
wh=*(s+1)-0xa0;
location=(94*(qh-1)+(wh-1))*72L;
fseek(fp,location,SEEK_SET);
fread(buffer,72,1,fp);
for(i=0;i<24;i++)
for(j=0;j<24;j++)
if(buffer[j][i/8]&(0x80>>i%8))
putpixel(x+i,y+j,colour);//原来是putpixel(x+j,y+i,colour);导致横了~
/*s+=2;
x+=24;*/

fclose(fp);
}
main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"");
hanzi16(246,200,"中",BROWN);
getch();
closegraph();
}

附件是我的24点阵字库!

[此贴子已经被作者于2007-10-22 8:53:19编辑过]


----------------解决方案--------------------------------------------------------

支持,学习!


----------------解决方案--------------------------------------------------------
谢谢大家
----------------解决方案--------------------------------------------------------

原来是字库出了问题,我想问一下有没有一种字库可以显示中英字的呢?


----------------解决方案--------------------------------------------------------
  相关解决方案