如何将将字库或图片以数组的形式储存在.c 文件中
我们新建一个xx.c文件,利用工具将我们所需要的汉字,字符,标点,生成16进制的数组码表,如下,
#definehzNum109
constunsignedcharhzIndex[218]={
0xc9,0xf9,0xd1,0xb8,0xb5,0xe7,0xd7,0xd3,
0xc9,0xe8,0xd6,0xc3,0xbf,0xec,0xbd,0xdd,
0xc7,0xeb,0xca,0xe4,0xc8,0xeb,0xb2,0xd9,
0xd7,0xf7,0xbf,0xda,0xc1,0xee,0xc8,0xb7,
0xb6,0xa8,0xc8,0xa1,0xcf,0xfb,0xca,0xfd,
0xc9,0xbe,0xb3,0xfd,0xb3,0xb7,0xb7,0xc0,
0xd4,0xda,0xbc,0xd2,0xb2,0xbc,0xcd,0xe2,
0xb3,0xf6,0xd1,0xa1,0xd4,0xf1,0xcd,0xcb,
0xd6,0xd0,0xb8,0xfc,0xb8,0xc4,0xd6,0xd8,
0xb7,0xb5,0xbb,0xd8,0xb1,0xa3,0xb4,0xe6,
0xca,0xc7,0xb7,0xf1,0xcf,0xfa,0xd6,0xf7,
0xd5,0xfd,0xb3,0xa3,0xb5,0xf4,0xb3,0xd8,
0xb3,0xe4,0xb7,0xc5,0xb1,0xa8,0xbe,0xaf,
0xce,0xfc,0xba,0xcf,0xb9,0xca,0xd5,0xcf,
0xcf,0xc2,0xd4,0xd8,0xcd,0xea,0xb3,0xc9,
0xce,0xde,0xb4,0xcb,0xc7,0xf8,0xb7,0xb6,
0xce,0xa7,0xc3,0xdc,0xc2,0xeb,0xa3,0xba,
0xa3,0xac,0xb4,0xed,0xce,0xf3,0xce,0xb4,
0xd0,0xe8,0xb9,0xa6,0xa3,0xa1,0xb2,0xbb,
}
constunsignedcharhzdot[3488]={
/*声CC9F9*/
0x02,0x12,0xD2,0x52,0x52,0x52,0x52,0xDF,
0x52,0x52,0x52,0x52,0xD2,0x12,0x02,0x00,
0x40,0x30,0x0F,0x02,0x02,0x02,0x02,0x03,
0x02,0x02,0x02,0x02,0x07,0x00,0x00,0x00,
.
.
.
.
.}
此只是举例而已,切记,此处生成的数组定义时要使用const来定义,不用static和extern,否则编译时仍会报内存不足情况,const就是修饰为常量,编译器通常不为普通const常量分配存储空间,而是将它们保存在符号表中,这使得它成为一个编译期间的常量,没有了存储与读内存的操作,使得它的效率也很高,这就是const的神奇之处。
Xx.c文件中就是这些内容,
Xx.H的内容就是声明和定义了,
#ifndef__xx_H__
#define__xx_H__
#definehzNum109
externconstunsignedcharchardot_8x16[];
externconstunsignedcharhzIndex[];
externconstunsignedcharhzdot[];
#endif
此文件中需要供外部使用,声明前加上extern,在使用的开头,#include”xx.h”就成功了!
字库图片数组c文 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)