C语言点阵字模编程之一
汉字点阵式编程之一,DOS下64点阵“我爱你!”的实现。我是在Win-TC编程环境下通过汉字点阵生成工具直接产生512byte的64点阵数组,然后再对起进行操作的来实现的。代码很简单。原代码如下:
#include <Conio.h>
#include <graphics.h>
#define closegr closegraph
/*初始化运行环境,注册驱动程序以实现程序的独立运行(脱离与Win-TC之间的关系)的功能*/
void initgr(void){
int gd = DETECT, gm = 0;
registerbgidriver(EGAVGA_driver);
initgraph(&gd, &gm, "");
}
/*实现制图的方法*/
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);
}
char wo64H[]={
/* 以下是 '我' 的 64点阵华文彩云 字模,512 byte */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x03,0xC0,0x00,0x00,
0x00,0x00,0x01,0xFF,0x1F,0xF8,0x00,0x00,
0x00,0x00,0x3F,0x00,0xF8,0x04,0x00,0x00,
0x00,0xFF,0xE0,0x00,0x70,0x07,0x80,0x00,
0x03,0x80,0x00,0x00,0x60,0x07,0xF0,0x00,
0x06,0x00,0x00,0x00,0x20,0x08,0x08,0x00,
0x04,0x00,0x00,0x00,0x20,0x10,0x08,0x00,
0x0C,0x00,0x00,0x00,0x20,0x20,0x04,0x00,
0x08,0x00,0x00,0x00,0x00,0x20,0x02,0x00,
0x08,0x00,0x00,0x00,0x00,0x60,0x01,0x00,
0x08,0x00,0x00,0x00,0x00,0x60,0x01,0x00,
0x08,0x00,0x00,0x00,0x00,0x20,0x00,0x80,
0x08,0x00,0x00,0x00,0x40,0x20,0x00,0xC0,
0x08,0x00,0x00,0x00,0xC0,0x20,0x00,0x40,
0x0C,0x00,0x00,0x03,0xC0,0x10,0x00,0x40,
0x06,0x00,0x00,0x1F,0xC0,0x10,0x00,0x60,
0x07,0x80,0x00,0x1F,0xC0,0x08,0x00,0x60,
0x0E,0x00,0x00,0x00,0x00,0x04,0x00,0x40,
0x10,0x00,0x00,0x00,0x00,0x02,0x00,0x60,
0x10,0x00,0x00,0x00,0x00,0x03,0x00,0x90,
0x30,0x00,0x00,0x00,0x00,0x01,0x83,0x08,
0x20,0x00,0x00,0x00,0x00,0x00,0xFE,0x08,
0x20,0x00,0x00,0x00,0x00,0x00,0x18,0x08,
0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,
0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,
0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x08,
0x30,0x00,0x00,0x00,0x00,0x00,0xF8,0x08,
0x10,0x00,0x00,0x00,0x00,0x01,0x86,0x08,
0x18,0x00,0x00,0x00,0x00,0x02,0x01,0x10,
0x0F,0xFC,0x00,0x1F,0xE0,0x00,0x00,0xE0,
0x07,0xFE,0x00,0x1F,0xE0,0x00,0x00,0xC0,
0x03,0xF0,0x00,0x00,0x60,0x00,0x00,0x40,
0x06,0x00,0x00,0x00,0x20,0x00,0x00,0x40,
0x0C,0x00,0x00,0x00,0x20,0x00,0x00,0x40,
0x08,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,
0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x80,
0x18,0x00,0x00,0x00,0x10,0x00,0x01,0x80,
0x18,0x00,0x00,0x00,0x10,0x00,0x01,0x00,
0x18,0x00,0x00,0x00,0x10,0x00,0x03,0x00,
0x18,0x00,0x00,0x00,0x38,0x00,0x07,0x00,
0x08,0x00,0x00,0x00,0x30,0x00,0x1F,0xC0,
0x08,0x00,0x00,0x00,0x40,0x00,0x30,0x70,
0x08,0x00,0x00,0x01,0x80,0x00,0x60,0x18,
0x0C,0x00,0x00,0x1F,0x00,0x00,0x40,0x0C,
0x07,0x00,0x00,0x1E,0x00,0x00,0x00,0x04,
0x03,0xFE,0x00,0x1C,0x00,0x00,0x00,0x04,
0x03,0xFC,0x00,0x10,0x00,0x00,0x00,0x04,
0x03,0x80,0x00,0x20,0x00,0x00,0x00,0x04,
0x03,0x00,0x00,0x40,0x00,0x00,0x00,0x04,
0x02,0x00,0x00,0x40,0x00,0x00,0x00,0x04,
0x06,0x00,0x00,0x80,0x00,0x00,0x00,0x08,
0x06,0x00,0x00,0x80,0x00,0x00,0x00,0x08,
0x06,0x00,0x00,0x80,0x00,0x20,0x00,0x08,
0x06,0x00,0x00,0x80,0x00,0x70,0x00,0x10,
0x02,0x00,0x00,0x40,0x01,0x98,0x00,0x10,
0x02,0x00,0x00,0x40,0x03,0x08,0x00,0x20,
0x02,0x00,0x00,0x60,0x04,0x04,0x00,0x20,
0x03,0x00,0x00,0x70,0x18,0x06,0x00,0x40,
0x01,0x80,0x01,0x8F,0xE0,0x01,0x80,0x80,
0x00,0xFF,0xFF,0x03,0x00,0x00,0xFF,0x00,
0x00,0x1F,0xF8,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
char ai64H[]={
/* 以下是 '爱' 的 64点阵华文彩云 字模,512 byte */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x00,
0x00,0x00,0x00,0x00,0x01,0xFF,0xFE,0x00,
0x00,0x7F,0xFF,0xFF,0xFF,0xC0,0x01,0x00,
0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x80,
0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x80,
0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x80,
0x04,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,
0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,
0x0C,0x00,0x00,0x03,0x00,0x04,0x00,0xC0,
0x0C,0x00,0xE0,0x0F,0xC0,0x1F,0x80,0xC0,
0x0C,0x03,0x88,0x18,0x10,0x30,0x60,0x80,
0x04,0x06,0x06,0x20,0x08,0x60,0x30,0x80,
0x04,0x0C,0x01,0xE0,0x0C,0x40,0x1D,0x80,
0x06,0x08,0x01,0xC0,0x07,0xC0,0x0F,0x80,
0x03,0x18,0x00,0xC0,0x03,0x80,0x0F,0x00,
0x01,0xF8,0x00,0x60,0x03,0x80,0x1F,0x00,
0x03,0xF8,0x00,0x20,0x01,0x00,0x1F,0x00,
0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,
0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x60,
0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x20,
0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x20,
0x30,0x00,0x00,0x18,0x00,0x00,0x00,0x30,
0x30,0x00,0x00,0x63,0x00,0x00,0x00,0x30,
0x30,0x00,0x00,0x80,0xC0,0x00,0x00,0x30,
0x30,0x00,0x01,0x00,0x20,0x00,0x00,0x30,
0x30,0x01,0xFE,0x00,0x3F,0xFE,0x00,0x30,
0x30,0x01,0xFC,0x00,0x3F,0xFF,0x00,0x30,
0x10,0x01,0x00,0x00,0x00,0x01,0x00,0x20,
0x10,0x02,0x00,0x00,0x00,0x00,0x00,0x20,
0x1C,0x06,0x00,0x00,0x00,0x00,0xC0,0xE0,
0x0F,0xF8,0x00,0x00,0x00,0x00,0x3F,0xC0,
0x03,0x00,0x00,0x00,0x00,0x00,0x07,0x00,
0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0xF8,0x00,0x01,0xFF,0xFF,0xFC,0x00,
0x01,0xE0,0x00,0x03,0xFF,0xFF,0xFC,0x00,
0x07,0x00,0x00,0x00,0x00,0x00,0x04,0x00,
0x0C,0x00,0x00,0x00,0x00,0x00,0x04,0x00,
0x18,0x00,0x00,0x00,0x00,0x00,0x04,0x00,
0x10,0x00,0x00,0x00,0x00,0x00,0x04,0x00,
0x30,0x00,0x00,0x00,0x00,0x00,0x04,0x00,
0x10,0x00,0x00,0x00,0x00,0x00,0x04,0x00,
0x10,0x00,0x00,0x00,0x00,0x00,0x04,0x00,
0x10,0x00,0x00,0x03,0xFE,0x00,0x08,0x00,
0x08,0x00,0x00,0x00,0x40,0x00,0x08,0x00,
0x0C,0x00,0x00,0x00,0x00,0x00,0x10,0x00,
0x06,0x03,0xC0,0x00,0x00,0x00,0x3F,0x00,
0x07,0xFC,0x00,0x00,0x00,0x00,0x7F,0xC0,
0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x60,
0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x10,
0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x10,
0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x10,
0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x18,
0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x18,
0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x18,
0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x10,
0x30,0x00,0x00,0x03,0xF8,0x00,0x00,0x10,
0x10,0x00,0x00,0x3E,0x0F,0x00,0x00,0x10,
0x18,0x00,0x07,0xE0,0x01,0xF8,0x00,0x30,
0x07,0xFF,0xFC,0x00,0x00,0x0F,0xFF,0xE0,
0x00,0x7E,0x00,0x00,0x00,0x00,0x3F,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
char ni64H[]={
/* 以下是 '你' 的 64点阵华文彩云 字模,512 byte */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x1C,0x01,0x80,0x00,0x00,0x00,
0x00,0x00,0xFF,0x87,0xF8,0x00,0x00,0x00,
0x00,0x01,0x00,0x7C,0x1E,0x00,0x00,0x00,
0x00,0x02,0x00,0x38,0x03,0x00,0x00,0x00,
0x00,0x06,0x00,0x30,0x01,0x80,0x00,0x00,
0x00,0x04,0x00,0x20,0x01,0x80,0x00,0x00,
0x00,0x04,0x00,0x20,0x01,0x80,0x00,0x00,
0x00,0x08,0x00,0x60,0x01,0xFF,0xFF,0x80,
0x00,0x08,0x00,0x40,0x01,0xFF,0xFF,0xF0,
0x00,0x08,0x00,0x40,0x00,0x00,0x00,0x18,
0x00,0x18,0x00,0x80,0x00,0x00,0x00,0x0C,
0x00,0x10,0x00,0x80,0x00,0x00,0x00,0x04,
0x00,0x10,0x01,0x80,0x00,0x00,0x00,0x04,
0x00,0x20,0x01,0x00,0x00,0x00,0x00,0x06,
0x00,0x20,0x03,0x00,0x00,0x00,0x00,0x06,
0x00,0x20,0x02,0x00,0x00,0x00,0x00,0x06,
0x00,0x40,0x06,0x00,0x00,0x00,0x00,0x04,
0x00,0x40,0x04,0x00,0x00,0x00,0x00,0x04,
0x00,0x80,0x0C,0x00,0x00,0x00,0x00,0x04,
0x00,0x80,0x08,0x00,0x00,0x00,0x00,0x08,
0x01,0x00,0x08,0x00,0x00,0x01,0x00,0x08,
0x01,0x00,0x08,0x00,0x00,0x00,0x00,0x08,
0x02,0x00,0x08,0x00,0x38,0x02,0x00,0x10,
0x02,0x00,0x04,0x00,0x78,0x02,0x00,0x10,
0x04,0x00,0x04,0x00,0xF8,0x01,0x00,0x20,
0x04,0x00,0x01,0x01,0x88,0x03,0x80,0x40,
0x0C,0x00,0x00,0xFF,0x04,0x03,0xFF,0xC0,
0x08,0x00,0x00,0x78,0x02,0x06,0x3F,0xC0,
0x08,0x00,0x00,0x40,0x02,0x06,0x00,0x20,
0x08,0x00,0x00,0x40,0x03,0x06,0x00,0x20,
0x08,0x00,0x00,0x40,0x03,0x02,0x00,0x20,
0x08,0x00,0x00,0x80,0x02,0x02,0x00,0x10,
0x08,0x00,0x00,0x80,0x02,0x02,0x00,0x10,
0x08,0x00,0x00,0x80,0x02,0x02,0x00,0x10,
0x04,0x00,0x01,0x00,0x02,0x02,0x00,0x08,
0x06,0x00,0x01,0x00,0x04,0x01,0x00,0x08,
0x03,0xE0,0x03,0x00,0x04,0x01,0x00,0x08,
0x00,0x70,0x02,0x00,0x04,0x01,0x00,0x04,
0x00,0x30,0x02,0x00,0x00,0x00,0x00,0x04,
0x00,0x30,0x04,0x00,0x08,0x00,0x80,0x04,
0x00,0x30,0x04,0x00,0x08,0x00,0x80,0x02,
0x00,0x30,0x04,0x00,0x08,0x00,0x00,0x02,
0x00,0x30,0x0C,0x00,0x18,0x00,0x40,0x03,
0x00,0x30,0x0C,0x00,0x18,0x00,0x40,0x03,
0x00,0x30,0x04,0x00,0x28,0x00,0x00,0x02,
0x00,0x30,0x04,0x00,0x20,0x00,0x20,0x02,
0x00,0x30,0x02,0x00,0x78,0x00,0x00,0x00,
0x00,0x30,0x03,0x00,0xF0,0x00,0x10,0x04,
0x00,0x30,0x00,0xFF,0x00,0x00,0x10,0x00,
0x00,0x30,0x00,0x7E,0x00,0x00,0x1C,0x20,
0x00,0x30,0x00,0x62,0x00,0x00,0x18,0x00,
0x00,0x30,0x00,0x66,0x00,0x00,0x18,0x00,
0x00,0x30,0x00,0x66,0x00,0x00,0x18,0x00,
0x00,0x10,0x00,0x66,0x00,0x00,0x10,0x00,
0x00,0x10,0x00,0x66,0x00,0x00,0x10,0x00,
0x00,0x10,0x00,0x62,0x00,0x00,0x10,0x00,
0x00,0x10,0x00,0x42,0x00,0x00,0x10,0x00,
0x00,0x18,0x00,0x42,0x00,0x00,0x20,0x00,
0x00,0x0C,0x00,0x81,0x00,0x00,0x40,0x00,
0x00,0x07,0xFF,0x00,0xFF,0xFF,0x80,0x00,
0x00,0x00,0x78,0x00,0x1F,0xF8,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
char plaint64H[]={
/* 以下是 '!' 的 64点阵华文彩云 字模,512 byte */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,
0x00,0x0F,0xF0,0x00,0x00,0x00,0x00,0x00,
0x00,0x10,0x08,0x00,0x00,0x00,0x00,0x00,
0x00,0x20,0x04,0x00,0x00,0x00,0x00,0x00,
0x00,0x40,0x02,0x00,0x00,0x00,0x00,0x00,
0x00,0x80,0x02,0x00,0x00,0x00,0x00,0x00,
0x00,0x80,0x01,0x00,0x00,0x00,0x00,0x00,
0x00,0x80,0x01,0x00,0x00,0x00,0x00,0x00,
0x00,0x80,0x01,0x00,0x00,0x00,0x00,0x00,
0x00,0x80,0x01,0x00,0x00,0x00,0x00,0x00,
0x00,0x80,0x01,0x00,0x00,0x00,0x00,0x00,
0x00,0x80,0x01,0x00,0x00,0x00,0x00,0x00,
0x00,0x80,0x01,0x00,0x00,0x00,0x00,0x00,
0x00,0x80,0x01,0x00,0x00,0x00,0x00,0x00,
0x00,0x80,0x01,0x00,0x00,0x00,0x00,0x00,
0x00,0x80,0x01,0x00,0x00,0x00,0x00,0x00,
0x00,0x80,0x01,0x00,0x00,0x00,0x00,0x00,
0x00,0xC0,0x03,0x00,0x00,0x00,0x00,0x00,
0x00,0xC0,0x03,0x00,0x00,0x00,0x00,0x00,
0x00,0xC0,0x03,0x00,0x00,0x00,0x00,0x00,
0x00,0xC0,0x02,0x00,0x00,0x00,0x00,0x00,
0x00,0x40,0x02,0x00,0x00,0x00,0x00,0x00,
0x00,0x40,0x02,0x00,0x00,0x00,0x00,0x00,
0x00,0x40,0x02,0x00,0x00,0x00,0x00,0x00,
0x00,0x40,0x02,0x00,0x00,0x00,0x00,0x00,
0x00,0x40,0x02,0x00,0x00,0x00,0x00,0x00,
0x00,0x40,0x02,0x00,0x00,0x00,0x00,0x00,
0x00,0x40,0x02,0x00,0x00,0x00,0x00,0x00,
0x00,0x40,0x02,0x00,0x00,0x00,0x00,0x00,
0x00,0x40,0x02,0x00,0x00,0x00,0x00,0x00,
0x00,0x40,0x02,0x00,0x00,0x00,0x00,0x00,
0x00,0x40,0x02,0x00,0x00,0x00,0x00,0x00,
0x00,0x40,0x02,0x00,0x00,0x00,0x00,0x00,
0x00,0x40,0x02,0x00,0x00,0x00,0x00,0x00,
0x00,0x40,0x02,0x00,0x00,0x00,0x00,0x00,
0x00,0x60,0x06,0x00,0x00,0x00,0x00,0x00,
0x00,0x60,0x06,0x00,0x00,0x00,0x00,0x00,
0x00,0x60,0x06,0x00,0x00,0x00,0x00,0x00,
0x00,0x20,0x04,0x00,0x00,0x00,0x00,0x00,
0x00,0x20,0x04,0x00,0x00,0x00,0x00,0x00,
0x00,0x30,0x0C,0x00,0x00,0x00,0x00,0x00,
0x00,0x18,0x18,0x00,0x00,0x00,0x00,0x00,
0x00,0x0F,0xF0,0x00,0x00,0x00,0x00,0x00,
0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x01,0xC0,0x00,0x00,0x00,0x00,0x00,
0x00,0x0F,0xF8,0x00,0x00,0x00,0x00,0x00,
0x00,0x18,0x0C,0x00,0x00,0x00,0x00,0x00,
0x00,0x20,0x02,0x00,0x00,0x00,0x00,0x00,
0x00,0x60,0x03,0x00,0x00,0x00,0x00,0x00,
0x00,0x40,0x01,0x00,0x00,0x00,0x00,0x00,
0x00,0x40,0x01,0x00,0x00,0x00,0x00,0x00,
0x00,0xC0,0x01,0x80,0x00,0x00,0x00,0x00,
0x00,0xC0,0x01,0x80,0x00,0x00,0x00,0x00,
0x00,0x40,0x01,0x00,0x00,0x00,0x00,0x00,
0x00,0x40,0x01,0x00,0x00,0x00,0x00,0x00,
0x00,0x60,0x03,0x00,0x00,0x00,0x00,0x00,
0x00,0x20,0x02,0x00,0x00,0x00,0x00,0x00,
0x00,0x18,0x0C,0x00,0x00,0x00,0x00,0x00,
0x00,0x07,0xF0,0x00,0x00,0x00,0x00,0x00,
0x00,0x01,0xC0,0x00,0x00,0x00,0x00,0x00,
};
int main(void){
int i, j;
initgr();
drawmat(wo64H, 64, 200, 100, RED);
drawmat(ai64H, 64, 250, 150, YELLOW);
drawmat(ni64H, 64, 300, 200, CYAN);
drawmat(plaint64H, 64, 350, 250, GREEN);
getch();
closegr();
return 0;
}
很简单吧。 自己动手试一试。