1、打印字符A
效果字符A的像素点阵
// 字符A像素点阵8x16
/*
00000000
00011000
00011000
00011000
00011000
00100100
00100100
00100100
00100100
01111110
01000010
01000010
01000010
11100111
00000000
00000000
*/
static char font_A[16] = {
0x00, 0x18, 0x18, 0x18, 0x18, 0x24, 0x24, 0x24,
0x24, 0x7e, 0x42, 0x42, 0x42, 0xe7, 0x00, 0x00,
};
打印函数
// 打印字符
void putfont8(char *vram, int xsize, int x, int y, char c, char *font){
for(int i = 0; i < 16; i++){
char *p = vram + (y + i) * xsize + x;
char d = font[i];
if((d & 0x80) != 0) { p[0] = c; }
if((d & 0x40) != 0) { p[1] = c; }
if((d & 0x20) != 0) { p[2] = c; }
if((d & 0x10) != 0) { p[3] = c; }
if((d & 0x08) != 0) { p[4] = c; }
if((d & 0x04) != 0) { p[5] = c; }
if((d & 0x02) != 0) { p[6] = c; }
if((d & 0x01) != 0) { p[7] = c; }
}
}
调用
:
// 打印字符A
putfont8(vram, xsize, 8, 8, COL8_FFFFFF, font_A);
网友评论