平时写东西是总想写的东西输出汉字,今天用turboc for windows的时候看到了汉字取模表,看了说明,传说这个东西可以让C输出中文(图形模式).
如说明:
本程序必须在图形模式下使用,请使用以下的函数输出汉字。
void drawmat(char *mat,int matsize,int x,int y,int color)
/*依次:字模指针、点阵大小、起始坐标(x,y)、颜色*/
{int i,j,k,n;
n=(matsize-1)/8+1;
for(j=0;j<matsize;j++)
for(i=0;i<n;i++)
for(k=0;k<8;k++)
if(mat[j*n+i]&(0x80>>k)) /*测试为1的位则显示*/
putpixel(x+i*8+k,y+j,color);
}
在比如汉字"帅":
16*16:
char shuai[]={
0x08,0x20,0x08,0x20,0x08,0x20,0x4B,0xFE,
0x4A,0x22,0x4A,0x22,0x4A,0x22,0x4A,0x22,
0x4A,0x22,0x4A,0x22,0x4A,0x22,0x12,0x2E,
0x12,0x24,0x20,0x20,0x40,0x20,0x80,0x20,
};
32*32
char shuai[]={
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x70,0x0C,0x00,0x00,0x70,0x0E,0x00,
0x00,0x70,0x0C,0x00,0x00,0x70,0x0C,0x00,
0x08,0x70,0x0C,0x00,0x0E,0x70,0x0C,0x00,
0x0E,0x73,0x0C,0x38,0x0C,0x73,0xFF,0xF8,
0x0C,0x73,0x0C,0x30,0x0C,0x73,0x0C,0x30,
0x0C,0x73,0x0C,0x30,0x0C,0x73,0x0C,0x30,
0x0C,0x73,0x0C,0x30,0x0C,0x63,0x0C,0x30,
0x0C,0x63,0x0C,0x30,0x0C,0x63,0x0C,0x30,
0x0C,0x63,0x0C,0x30,0x0C,0x63,0x0C,0x30,
0x0C,0xE3,0x0C,0x30,0x0C,0xE3,0x0C,0x38,
0x0C,0xC3,0x0D,0xF0,0x08,0xC3,0x0D,0xF0,
0x01,0xC3,0x0C,0x60,0x03,0x83,0x0C,0x40,
0x03,0x00,0x0C,0x00,0x06,0x00,0x0C,0x00,
0x0C,0x00,0x0C,0x00,0x18,0x00,0x0C,0x00,
0x30,0x00,0x0C,0x00,0x00,0x00,0x08,0x00,
};
=================================================================
但是我一直不知道怎么用,哪个仁兄做一个示范啊?
要求输出: 帅 帅 帅
帅
=================================================================
----------------解决方案--------------------------------------------------------
#include <graphics.h>
char shuai[]={
0x08,0x20,0x08,0x20,0x08,0x20,0x4B,0xFE,
0x4A,0x22,0x4A,0x22,0x4A,0x22,0x4A,0x22,
0x4A,0x22,0x4A,0x22,0x4A,0x22,0x12,0x2E,
0x12,0x24,0x20,0x20,0x40,0x20,0x80,0x20,
};
void drawmat(char *mat,int matsize,int x,int y,int color)
{int i,j,k,n;
n=(matsize-1)/8+1;
for(j=0;j<matsize;j++)
for(i=0;i<n;i++)
for(k=0;k<8;k++)
if(mat[j*n+i]&(0x80>>k))
putpixel(x+i*8+k,y+j,color);
}
int main()
{
int gdriver=DETECT,gmode;
registerbgidriver(EGAVGA_driver);
initgraph(&gdriver,&gmode,"");
drawmat(shuai,16,50,50,WHITE);
drawmat(shuai,16,70,50,WHITE);
drawmat(shuai,16,90,50,WHITE);
drawmat(shuai,16,50,70,WHITE);
getch();
closegraph();
return 0;
}
这样应该可以吧
----------------解决方案--------------------------------------------------------
#include <graphics.h>
char shuai[]={
0x08,0x20,0x08,0x20,0x08,0x20,0x4B,0xFE,
0x4A,0x22,0x4A,0x22,0x4A,0x22,0x4A,0x22,
0x4A,0x22,0x4A,0x22,0x4A,0x22,0x12,0x2E,
0x12,0x24,0x20,0x20,0x40,0x20,0x80,0x20,
};
void drawmat(char *mat,int matsize,int x,int y,int color)
{int i,j,k,n;
n=(matsize-1)/8+1;
for(j=0;j<matsize;j++)
for(i=0;i<n;i++)
for(k=0;k<8;k++)
if(mat[j*n+i]&(0x80>>k))
putpixel(x+i*8+k,y+j,color);
}
int main()
{
int gdriver=DETECT,gmode;
registerbgidriver(EGAVGA_driver);
initgraph(&gdriver,&gmode,"");
drawmat(shuai,16,50,50,WHITE);
drawmat(shuai,16,70,50,WHITE);
drawmat(shuai,16,90,50,WHITE);
drawmat(shuai,16,50,70,WHITE);
getch();
closegraph();
return 0;
}
这样应该可以吧
好象你写的不对劲啊.
----------------解决方案--------------------------------------------------------
竟有这种事啊....不过我在WIN-TC下过了啊....
----------------解决方案--------------------------------------------------------
这个是可执行文件
----------------解决方案--------------------------------------------------------
无效指令?~~~
试着把这句删了:registerbgidriver(EGAVGA_driver);
----------------解决方案--------------------------------------------------------
这个是可执行文件
竟然公开欺负我良家俊男~~该当何罪?!
!!!!!!!!!!!!还请高手斧正!!!!!!!!!!!!
**********************************************************************
[此贴子已经被作者于2007-7-24 16:59:05编辑过]
----------------解决方案--------------------------------------------------------
呕饭....
----------------解决方案--------------------------------------------------------
help me ~!
----------------解决方案--------------------------------------------------------