/*************** 点阵字模工具编程辅助效果示例 ***************/
#include "Conio.h"
#include "graphics.h"
#define closegr closegraph
void initgr(void) /* BGI初始化 */
{
int gd = DETECT, gm = 0; /* 和gd=VGA,gm=VGAHI是同样效果 */
registerbgidriver(EGAVGA_driver);/* 注册BGI驱动后可以不需要.BGI文件的支持运行 */
initgraph(&gd, &gm, "");
}
下面红色的显示我一点都不懂,这是WIN-TC下的一个示例,希望你们给我解释一下.我可能来不及看,明天我一定会仔细研究,先谢谢了.
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);
}
char guan48[]={
/* 以下是 '灌' 的 48点阵黑体 字模,288 byte */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x03,0xC0,0x38,0x00,
0x03,0x00,0x03,0xC0,0x38,0x00,0x07,0x80,
0x03,0xC0,0x38,0x00,0x07,0xC0,0x03,0xC0,
0x38,0x00,0x03,0xF1,0xFF,0xFF,0xFF,0xFC,
0x01,0xF9,0xFF,0xFF,0xFF,0xFC,0x00,0x79,
0xF1,0xC0,0x39,0xFC,0x00,0x30,0x01,0xC0,
0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xFF,0xF0,0xFF,0xE0,0x00,0x00,0xFF,0xF0,
0xFF,0xE0,0x00,0x00,0xE0,0x70,0xE0,0xE0,
0x0E,0x00,0xE0,0x70,0xE0,0xE0,0x1F,0x80,
0xE0,0x70,0xE0,0xE0,0x1F,0xE0,0xFF,0xF0,
0xFF,0xE0,0x07,0xF0,0xFF,0xF0,0xFF,0xE0,
0x01,0xF0,0xFF,0xF1,0xFF,0xE0,0x00,0x60,
0x08,0x07,0x00,0x00,0x00,0x20,0x1E,0x03,
0x80,0x00,0x00,0x00,0x1E,0x03,0x00,0x00,
0x00,0x00,0x1F,0xFF,0xFF,0xF0,0x00,0x00,
0x3F,0xFF,0xFF,0xF0,0x00,0x00,0x3F,0xFF,
0xFF,0xF0,0x00,0x00,0x7C,0x03,0x80,0x00,
0x00,0x20,0x7C,0x03,0x80,0x00,0x00,0x70,
0xFC,0x03,0x80,0x00,0x00,0x71,0xFF,0xFF,
0xFF,0xE0,0x00,0x73,0xFF,0xFF,0xFF,0xE0,
0x00,0xF3,0xBC,0x03,0x80,0x60,0x00,0xE3,
0xBC,0x03,0x80,0x00,0x01,0xE1,0x3C,0x03,
0x80,0x00,0x01,0xC0,0x3F,0xFF,0xFF,0xE0,
0x01,0xC0,0x3F,0xFF,0xFF,0xE0,0x03,0xC0,
0x3F,0xFF,0xFF,0xE0,0x03,0x80,0x3C,0x03,
0x80,0x00,0x07,0x80,0x3C,0x03,0x80,0x00,
0x0F,0x80,0x3C,0x03,0x80,0x00,0x0F,0x00,
0x3F,0xFF,0xFF,0xF8,0x1F,0x00,0x3F,0xFF,
0xFF,0xF8,0x1F,0x00,0x3C,0x00,0x00,0x00,
0x06,0x00,0x3C,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
int main(void)
{
int i, j;
initgr(); /* BGI初始化 */
drawmat(guan48, 48, 350, 110, RED);
getch(); /* 暂停一下,看看前面绘图代码的运行结果 */
closegr(); /* 恢复TEXT屏幕模式 */
return 0;
}