#include <conio.h> /*用到了RED宏定义*/
#include <graphics.h> /*进入图形显示模式*/
char han16S[]={
/* 以下是‘ 汉 ’字的点阵数组,32 byte(利用WIN TC点阵工具生成的,直接复制) */
0x20,0x00,0x10,0x00,0x17,0xFC,0x02,0x08,
0x82,0x08,0x49,0x10,0x49,0x10,0x11,0x10,
0x10,0xA0,0x20,0xA0,0xE0,0x40,0x20,0xA0,
0x21,0x18,0x26,0x0E,0x28,0x04,0x00,0x00,
};
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))
putpixel(x+i*8+k,y+j,color);
}
void initGraph()
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
/* initialize graphics mode */
initgraph(&gdriver, &gmode, "C://Win-TC//projects");
/* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk) /* an error occurred */
{
printf("Graphics error: %s/n", grapherrormsg(errorcode));
printf("ress any key to halt:");
getch();
exit(1); /* return with error code */
}
}
void main(void)
{
initGraph();
drawmat(han16S,16,300,250,RED);
getch();
}