📄 display_hz.c
字号:
#include <errno.h>#include <fcntl.h>#include <unistd.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <sys/types.h>#include <sys/mman.h>#include <string.h>int fd1;void *address;intinit_file (void){ fd1 = open ("hzk16.bin", O_RDWR); if (fd1 < 0) { perror ("open() error"); return -1; } address = mmap (NULL, 256 * 1024, PROT_READ, MAP_SHARED, fd1, 0); if (address == MAP_FAILED) { perror ("munmap() error="); }}intclose_file (void){ if (munmap (address, 256 * 1024) < 0) { perror ("munmap() error"); } close (fd1);}voidget_buf (unsigned char *hanzi, char *buf){ unsigned long offset = ((hanzi[0] - 0xA1) * 94 + (hanzi[1] - 0xA1)) * 32L; memcpy (buf, address + offset, 32);}intget_bit (unsigned char a, int bit){ return (a & (1 << bit));}voiddisplay_buf (unsigned char *buf){ int i, j; unsigned char a1, a2; for (i = 0;i < 32; i++) { printf ("0x%02x ,",buf[i]); if (i%8==7)printf ("\n"); } for (i = 0; i < 32; i += 2) { a1 = buf[i]; a2 = buf[i + 1]; printf ("\n"); for (j = 7; j >= 0; j--) { if (get_bit (a1, j)) printf ("1"); else printf (" "); } for (j = 7; j >= 0; j--) { if (get_bit (a2, j)) printf ("1"); else printf (" "); } }}intmain (void){ char buf[32]; //1.) open hzk.bin file init_file (); //2.) get hanzi font get_buf ("啊", buf); //3.) display a hanzi display_buf (buf); //4.) exit all close_file ();}//啊你好
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -