可能有人会说:不使用GUI,将汉字字库下载到SD卡中,然后使用下边的函数GetGBKCode_from_sd()也可以获得字模,而且这种字库所有的分区都是连续排放的。为什么要与上一种情况单独分开呢?
- /*******************************************************************************
- * Function Name : GetGBKCode_from_sd
- * Description : 从SD卡字库中读取自摸数据到指定的缓冲区
- * Input : pBuffer---数据保存地址
- * c--汉字字符低字节码
- * Output : None
- * Return : 0(success) -1(fail)
- * Attention : None
- *******************************************************************************/
- int GetGBKCode_from_sd(unsigned char* pBuffer,const unsigned char * c)
- {
- unsigned char High8bit,Low8bit;
- unsigned int pos;
- High8bit=*c; /* 取高8位数据 */
- Low8bit=*(c+1); /* 取低8位数据 */
-
- pos = ((High8bit-0xa0-16)*94+Low8bit-0xa0-1)*2*16;
-
- f_mount(0, &myfs[0]);
- myres = f_open(&myfsrc , "0:/HZLIB.bin", FA_OPEN_EXISTING | FA_READ);
-
- if ( myres == FR_OK )
- {
- f_lseek (&myfsrc, pos); //指针偏移
- myres = f_read( &myfsrc, pBuffer, 32, &mybr ); //16*16大小的汉字 其字模 占用16*2个字节
- f_close(&myfsrc);
-
- return 0;
- }
- else
- return -1;
- }
|