汉字点阵显示程序是常用的模块,很多应用都要用到,为了便于给广大网友一个参考,贴上自己用的,如果大家有更好的,也欢迎贴上来. //下需是结构体定义
/*汉字X方向宽度*/ #define HZ_SIZE_X 2 /*汉字Y方向宽度*/ #define HZ_SIZE_Y 16
#define HZ_NUM 128
typedef struct _HzModel { /* 汉字内码 */ uint uiHZcode;
/* 点阵字模 向下为x,向右为y*/ uchar model[HZ_SIZE_X][HZ_SIZE_Y];
}HZ_MODEL
//定义结束
//下面是字库文件
#include "ZKFunc.h"
code HZ_MODEL ZK_Data[]= { { 0xD2F4, //音 0x02,0x00,0x01,0x10,0x3F,0xF8,0x08,0x20,0x04,0x20,0x04,0x44,0xFF,0xFE,0x00,0x10, 0x1F,0xF8,0x10,0x10,0x10,0x10,0x1F,0xF0,0x10,0x10,0x10,0x10,0x1F,0xF0,0x10,0x10},
{ 0xC0D6, //乐 0x00,0x20,0x00,0xF0,0x1F,0x00,0x10,0x00,0x11,0x00,0x11,0x00,0x21,0x04,0x7F,0xFE, 0x01,0x00,0x01,0x00,0x09,0x20,0x09,0x10,0x11,0x08,0x21,0x0C,0x45,0x04,0x02,0x00},
{ 0xD0C0, //欣 0x02,0x40,0x07,0x40,0x38,0x40,0x20,0x40,0x20,0x7E,0x20,0x82,0x3F,0x24,0x24,0x20, 0x24,0x20,0x24,0x20,0x24,0x50,0x24,0x50,0x44,0x88,0x44,0x88,0x85,0x06,0x02,0x04},
{ 0xC9CD, //赏 0x01,0x00,0x11,0x10,0x09,0x20,0x7F,0xFE,0x40,0x02,0x8F,0xE4,0x08,0x20,0x0F,0xE0, 0x00,0x10,0x1F,0xF8,0x10,0x10,0x11,0x10,0x11,0x10,0x02,0xC0,0x0C,0x30,0x30,0x08},
{ 0xCAB1, //时 0x00,0x08,0x04,0x08,0x7E,0x08,0x44,0x08,0x47,0xFE,0x44,0x08,0x44,0x08,0x7C,0x88, 0x44,0x48,0x44,0x48,0x44,0x08,0x44,0x08,0x7C,0x08,0x44,0x48,0x00,0x28,0x00,0x10},
{ 0xD6D3, //钟 0x10,0x20,0x10,0x20,0x10,0x20,0x1C,0x24,0x21,0xFE,0x21,0x24,0x7D,0x24,0x91,0x24, 0x11,0x24,0xFD,0xFC,0x11,0x24,0x10,0x20,0x14,0x20,0x18,0x20,0x10,0x20,0x00,0x20},
{ 0xB9DC, //管 0x10,0x40,0x1F,0x7C,0x28,0x90,0x45,0x08,0x01,0x00,0x7F,0xFE,0x40,0x02,0x9F,0xF4, 0x10,0x10,0x1F,0xF0,0x10,0x00,0x1F,0xF0,0x10,0x10,0x10,0x10,0x1F,0xF0,0x10,0x00},
{ 0xC0ED, //理 0x00,0x08,0x13,0xFC,0xFA,0x48,0x22,0x48,0x23,0xF8,0x22,0x48,0xFA,0x48,0x23,0xF8, 0x20,0x40,0x20,0x50,0x23,0xF8,0x3C,0x40,0xE0,0x40,0x40,0x44,0x0F,0xFE,0x00,0x00},
{ 0xD3CE, //游 0x02,0x10,0x41,0x14,0x20,0x1E,0x2F,0xE0,0x82,0x40,0x62,0x3E,0x23,0x84,0x02,0x88, 0x12,0x88,0x22,0xFE,0xE2,0x88,0x24,0x88,0x24,0x88,0x28,0x88,0x31,0xA8,0x20,0x10},
{ 0xCFB7, //戏 0x00,0x40,0x00,0x50,0x7E,0x48,0x02,0x40,0x43,0xFE,0x24,0x40,0x14,0x44,0x14,0x44, 0x08,0x48,0x14,0x48,0x12,0x50,0x22,0x20,0x40,0x60,0x80,0x92,0x01,0x0A,0x02,0x06},
{ 0xB9A6, //功 0x00,0x80,0x00,0x80,0x08,0x80,0xFC,0x80,0x10,0x84,0x17,0xFE,0x10,0x84,0x10,0x84, 0x10,0x84,0x10,0x84,0x1D,0x04,0xF1,0x04,0x41,0x04,0x02,0x44,0x04,0x28,0x08,0x10},
{ 0xC4DC, //能 0x10,0x80,0x10,0x88,0x24,0x98,0x44,0xA0,0xFE,0xC0,0x02,0x84,0x7C,0x84,0x44,0x7C, 0x7C,0x00,0x44,0x88,0x44,0x98,0x7C,0xA0,0x44,0xC0,0x44,0x82,0x54,0x82,0x48,0x7E},
{ 0xCEB4, //未 0x01,0x00,0x01,0x00,0x01,0x08,0x7F,0xFC,0x01,0x00,0x01,0x00,0x01,0x04,0xFF,0xFE, 0x03,0x80,0x05,0x40,0x09,0x20,0x11,0x10,0x21,0x0E,0x41,0x04,0x01,0x00,0x01,0x00},
{ 0xBFAA, //开 0x00,0x08,0x7F,0xFC,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x24,0xFF,0xFE, 0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0x10,0x20,0x10,0x20,0x20,0x20,0x40,0x20},
{ 0xCDA8, //通 0x03,0xF8,0x40,0x10,0x30,0xA0,0x10,0x48,0x03,0xFC,0x02,0x48,0xF2,0x48,0x13,0xF8, 0x12,0x48,0x12,0x48,0x13,0xF8,0x12,0x48,0x12,0x68,0x2A,0x50,0x44,0x06,0x03,0xFC},
{ 0xC9E8, //设 0x01,0xF0,0x21,0x10,0x11,0x10,0x11,0x10,0x01,0x10,0x02,0x0E,0xF4,0x00,0x13,0xF8, 0x11,0x08,0x11,0x10,0x10,0x90,0x10,0xA0,0x14,0x40,0x18,0xB0,0x13,0x0E,0x0C,0x04},
{ 0xB6A8, //定 0x02,0x00,0x01,0x00,0x7F,0xFE,0x40,0x02,0x80,0x24,0x1F,0xF0,0x01,0x00,0x01,0x00, 0x11,0x20,0x11,0xF0,0x11,0x00,0x11,0x00,0x11,0x00,0x29,0x06,0x47,0xFC,0x80,0x00},
{ 0xCDCB, //退 0x03,0xF8,0x42,0x08,0x32,0x08,0x13,0xF8,0x02,0x08,0x02,0x08,0xF3,0xFC,0x12,0x08, 0x12,0xD0,0x12,0x20,0x12,0x90,0x13,0x0C,0x12,0x04,0x28,0x00,0x44,0x06,0x03,0xFC},
{ 0xB3F6, //出 0x01,0x00,0x01,0x00,0x21,0x08,0x21,0x08,0x21,0x08,0x21,0x08,0x3F,0xF8,0x21,0x08, 0x01,0x00,0x41,0x04,0x41,0x04,0x41,0x04,0x41,0x04,0x41,0x04,0x7F,0xFC,0x40,0x04},
{ 0xC4EA, //年 0x08,0x00,0x08,0x08,0x1F,0xFC,0x11,0x00,0x21,0x00,0x41,0x10,0x1F,0xF8,0x11,0x00, 0x11,0x00,0x11,0x04,0xFF,0xFE,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00},
{ 0xD4C2, //月 0x00,0x10,0x0F,0xF8,0x08,0x10,0x08,0x10,0x08,0x10,0x0F,0xF0,0x08,0x10,0x08,0x10, 0x08,0x10,0x0F,0xF0,0x08,0x10,0x08,0x10,0x10,0x10,0x10,0x10,0x20,0x50,0x40,0x20},
{ 0xC8D5, //日 0x00,0x10,0x1F,0xF8,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x1F,0xF0, 0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x1F,0xF0,0x10,0x10,0x00,0x00},
{ 0xB7D6, //分 0x00,0x80,0x04,0x80,0x04,0x40,0x08,0x40,0x08,0x20,0x10,0x10,0x20,0x08,0x4F,0xEE, 0x84,0x24,0x04,0x20,0x04,0x20,0x04,0x20,0x04,0x20,0x08,0x20,0x11,0x40,0x20,0x80},
{ 0xC3EB, //秒 0x04,0x20,0x0E,0x20,0x78,0x20,0x08,0x20,0x08,0xA8,0xFE,0xA6,0x08,0xA2,0x1D,0x20, 0x1A,0x24,0x28,0x24,0x28,0x28,0x48,0x10,0x88,0x20,0x08,0x40,0x08,0x80,0x0B,0x00},
{ 0xC8B7, //确 0x00,0x40,0x04,0x40,0xFE,0x78,0x10,0x90,0x11,0x24,0x23,0xFE,0x25,0x24,0x7D,0x24, 0xA5,0xFC,0x25,0x24,0x25,0x24,0x25,0xFC,0x25,0x24,0x3D,0x24,0x22,0x24,0x04,0x0C},
{ 0xCEC2, //温 0x00,0x08,0x43,0xFC,0x32,0x08,0x12,0x08,0x83,0xF8,0x62,0x08,0x22,0x08,0x0B,0xF8, 0x10,0x00,0x27,0xFC,0xE4,0xA4,0x24,0xA4,0x24,0xA4,0x24,0xA4,0x2F,0xFE,0x20,0x00},
{ 0xB6C8, //度 0x01,0x00,0x00,0x84,0x3F,0xFE,0x22,0x20,0x22,0x28,0x3F,0xFC,0x22,0x20,0x23,0xE0, 0x20,0x00,0x2F,0xF0,0x22,0x20,0x21,0x40,0x20,0x80,0x43,0x60,0x8C,0x1E,0x30,0x04},
{ 0xFFFF, //字库结尾标志符 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF},
}; //end //总的有效字符数为27 //字库生成日期为:2008年7月16日 //字库生成时间为:22时36分17秒 //程序开发者:古道热肠,感谢您的使用! //作者联系邮箱:xg_2004_sy@126.com //---------------------------字库文件结束
//--------------------下面是字库查找的函数------------------- extern code HZ_MODEL ZK_Data[];
/*-在内存中根据汉字内码取16点阵字模-*/ /* 返回:true 成功取到字模 */ /* 返回:false 取字模失败 */ bool GetHzModelInMem(uint uiHZCode,HZ_MODEL ** pHzModel) { //顺序查找法
uint uiIndex; bool bResultFlag;
uiIndex = 0; while(1) { if(ZK_Data[uiIndex].uiHZcode == 0xFFFF) { *pHzModel = (HZ_MODEL *)&(ZK_Data[uiIndex]); bResultFlag = false; break; }
if(ZK_Data[uiIndex].uiHZcode == uiHZCode) { //-找到 *pHzModel = (HZ_MODEL *)&(ZK_Data[uiIndex]); bResultFlag = true; break; } else { uiIndex++; } }
return bResultFlag; }
void GetHZDot(uint uiHZCode,uchar *ucHZDotData) { HZ_MODEL *pHzModel; bool bReturnValue;
bReturnValue = GetHzModelInMem(uiHZCode,&pHzModel); memcpy(ucHZDotData,&pHzModel->model,32); }
/* void TestGetHZDot(void) { uchar xdata ucDataBuff[32]; uchar *ucDispString; code uchar ucCodeString[] ="古道热肠"; uint uiHZCode; ucDispString = ucCodeString; while(*ucDispString != '\0') { uiHZCode = *ucDispString++; uiHZCode <<=8; uiHZCode += *ucDispString++;
GetHZDot(uiHZCode,ucDataBuff); }
} */
//-----------------------------------------------------------
//备注:用二分法查找会提高查找速度,但字库文件要先排序. |