终于可以在已经放进内存的resource里面读取hzk16的点阵了……折腾人啊!转换函数如下:
不爽ing……
// Function:void CharToPixel(CString *m_Str,int nLength) // Todo: Convert a CString to 16*16 font in CByteArray byDisplay. // Input: CString* m_Str, the pointer to the string to be converted. // Input: int nLength, the length of the string. // Return: None. Global variable CByteArray byDisplay contains the fonts. void CLedctrlDlg::CharToPixel(CString *m_Str, int nLength) { HRSRC hRes; HGLOBAL hglbData; HMODULE hm; unsigned char nSection, nPosition; long lHzkPosition; BYTE *lHzBase,*lp; int nChar,nByte; nLength=nLength/2; hm=AfxGetResourceHandle(); hRes=::FindResource(hm, MAKEINTRESOURCE(IDR_HZK16), "HZK16"); hglbData=::LoadResource(hm, hRes); lHzBase=(BYTE *)LockResource(hglbData); byDisplay.RemoveAll(); byDisplay.SetSize(nLength*32); m_Str->OemToAnsi(); for (nChar=0; nChar<nLength; nChar++) { nSection=m_Str->GetAt(nChar*2)-0xa0; nPosition=m_Str->GetAt(nChar*2+1)-0xa0; lHzkPosition=((nSection-1)*94+nPosition-1)*32; lp=lHzBase+lHzkPosition; for (nByte=nChar*32; nByte<(nChar+1)*32; nByte++) { byDisplay.SetAt(nByte,*(lp++)); } } FreeResource(hglbData); }
以上。
不弹此调久矣的老狼