⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 char_subpict.c

📁 ct952 source code use for Digital Frame Photo
💻 C
📖 第 1 页 / 共 4 页
字号:
    while (wReadByteNum < _pSP_HeaderPt->bLen && bLineIndex < CHAR_SP_MAX_LINE_NUM)     {        if (*pString != 0x0D)        {#ifdef ISO_8859_8_FONT   #ifdef HEBREW_IE_FORMAT              // Damon2.56, find each Hebrew sentence and save it's position & length            // we will use this info to change each sentence's direction            if ((*pString >= 0xE0 && *pString <= 0xFA) ||(*pString >= 0x30 && *pString <= 0x39))	// find Hebrew Character & number Character            {                 if (!bHebNewSentence)                 {                     bHebCharNum = bCharNum - bHebCharStart + 1;                      if (*pString <= 0x39) // it's number character                     {                         bHebNumberWord = TRUE;                     }                 }                 else if (*pString >= 0xE0) // it's Hebrew character                 {                     bHebCharStart = bCharNum;                     _bHebSentenceInfo[_bHebSentenceIndex++] = bBufferIndex; // the Hebrew sentence start point                     bHebNewSentence = FALSE;                 }                 				             }             // find number word, it need to chang again            else if ((*pString == 0x20) && (!bHebNewSentence))             {                if (!bHebNumberWord)                {                    bSpaceIndex = bBufferIndex;                }                else                {                    _bHebNumberInfo[_bHebNumberIndex++] = bSpaceIndex + 1;                    _bHebNumberInfo[_bHebNumberIndex++] = bBufferIndex - bSpaceIndex -1;                    bHebNumberWord = FALSE;	                    bSpaceIndex = bBufferIndex;                }				            }#elif defined(HEBREW_WORD_FORMAT)            // Damon2.56, find each Hebrew word and save it's position & length            // we will use this info to change each word's direction            if (*pString >= 0xE0 && *pString <= 0xFA)	// find Hebrew Characters             {                 if (!bHebChar)                 {		        bHebChar = TRUE;                     // save the position of the first character of a word                       _bHebWordInfo[_bHebWordIndex++] = bBufferIndex;	                 }                                                      bHebCharNum++;                 		                }            else            {                 if (bHebChar)                 {		        bHebChar = FALSE;			  // save word length	                     _bHebWordInfo[_bHebWordIndex++] = bHebCharNum;                     bHebCharNum = 0;                                      }            }#endif#endif	            bCharNum++;             _aString[bBufferIndex] = CONVCHAR_ISO_CP_To_CTK(*pString);                                }        else         {#ifdef ISO_8859_8_FONT #ifdef HEBREW_IE_FORMAT               if (!bHebNewSentence)            {                bHebNewSentence = TRUE;                // save word length	                _bHebSentenceInfo[_bHebSentenceIndex++] = bHebCharNum;                bHebCharNum = 0;                  bHebCharStart = 0;                if (bHebNumberWord)                {                    _bHebNumberInfo[_bHebNumberIndex++] = bSpaceIndex + 1;                    _bHebNumberInfo[_bHebNumberIndex++] = bBufferIndex - bSpaceIndex -1;                    bHebNumberWord = FALSE;	                                    }            }#elif defined(HEBREW_WORD_FORMAT)            if (bHebChar)            {                bHebChar = FALSE;                // save word length	                _bHebWordInfo[_bHebWordIndex++] = bHebCharNum;                bHebCharNum = 0;                                 }   #endif           #endif	            if (bLineIndex < CHAR_SP_MAX_LINE_NUM)            {                _aLinePtr[bLineIndex] = _aString + bBufferIndex - bCharNum - 1;                *(_aLinePtr[bLineIndex]) = bCharNum;            }            bLineIndex++;            bCharNum = 0;        }        bBufferIndex++;         pString++;        wReadByteNum++;    }#ifdef ISO_8859_8_FONT#ifdef HEBREW_IE_FORMAT       if (!bHebNewSentence)    {                         // save word length	         _bHebSentenceInfo[_bHebSentenceIndex++] = bHebCharNum;             if (bHebNumberWord)         {             _bHebNumberInfo[_bHebNumberIndex++] = bSpaceIndex + 1;             _bHebNumberInfo[_bHebNumberIndex++] = bBufferIndex - bSpaceIndex -1;                             }				     } #elif defined(HEBREW_WORD_FORMAT)    if (bHebChar)    {        bHebChar = FALSE;        // save word length	        _bHebWordInfo[_bHebWordIndex++] = bHebCharNum;        bHebCharNum = 0;                         }   #endif           #endif    if (bLineIndex < CHAR_SP_MAX_LINE_NUM)    {        _aLinePtr[bLineIndex] = _aString + bBufferIndex - bCharNum - 1;        *(_aLinePtr[bLineIndex]) = bCharNum;    }}#ifdef SUPPORT_UTF8 void _Convert_UTF8_To_CTK_Strings(void){/*    WORD   wReadByteNum;    WORD   wOutputCode;    BYTE   bReadBuffer[4];    BYTE   bCharNum, bLineIndex, bBufferIndex;    PBYTE  pString;     // Point to the start address of the string    // The string in buffer has been translated into CTK before    //    if (_pSP_LastHeaderPt == _pSP_HeaderPt)//        return;        for (bLineIndex = 0; bLineIndex < CHAR_SP_MAX_LINE_NUM; bLineIndex++)        _aLinePtr[bLineIndex] = NULL;    pString = ((PBYTE)_pSP_HeaderPt) + PARSER_SPTXT_HEADER_SIZE;    wReadByteNum = 0;    bCharNum = 0;    bBufferIndex = 1;    bLineIndex = 0;    _aLinePtr[bLineIndex] = _aString;    // Translate the UTF8 -> UTF -> CTK Font Index    while (wReadByteNum < _pSP_HeaderPt->bLen && bLineIndex < CHAR_SP_MAX_LINE_NUM)     {        bReadBuffer[0] = *pString;  // Get the first byte        if (0x80 > bReadBuffer[0])           // 0xxxxxxx        {            wOutputCode = (WORD) bReadBuffer[0];            wReadByteNum++;        }        else if (0xE0> bReadBuffer[0])       // 110xxxxx 10xxxxxx        {            bReadBuffer[1] = *(pString+1);  // Get the second byte            wOutputCode = ((WORD)(bReadBuffer[0] & 0x1F)) << 6;            wOutputCode |= (WORD) (bReadBuffer[1] & 0x3F);            wReadByteNum += 2;        }        else if (0xF0 > bReadBuffer[0])      // 1110xxxx 10xxxxxx 10xxxxxx        {            bReadBuffer[1] = *(pString+1);  // Get the second byte            bReadBuffer[2] = *(pString+2);  // Get the third byte            wOutputCode = ((WORD)(bReadBuffer[0] & 0x0F)) << 12;            wOutputCode |= ((WORD)(bReadBuffer[1] & 0x3F)) << 6;            wOutputCode |= (WORD)(bReadBuffer[2] & 0x3F);            wReadByteNum += 3;        }        else if (0xF8 > bReadBuffer[0])      // 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx        {            bReadBuffer[1] = *(pString+1);  // Get the second byte            bReadBuffer[2] = *(pString+2);  // Get the third byte            bReadBuffer[3] = *(pString+3);  // Get the fourth byte            wOutputCode = ((WORD)(bReadBuffer[0] & 0x07)) << 18;            wOutputCode |= ((WORD)(bReadBuffer[1] & 0x3F)) << 12;            wOutputCode |= ((WORD)(bReadBuffer[2] & 0x3F)) << 6;            wOutputCode |= (WORD)(bReadBuffer[3] & 0x3F);            wReadByteNum += 4;        }        if (0x0D != wOutputCode)        {            _pwMappingTable = (WORD*) (_aAsciiMappingTable[0]);            for (__bTemp = 1; __bTemp < _pwMappingTable[0]; __bTemp++)            {                if (_pwMappingTable[__bTemp * 2] == wOutputCode)                {                    break;                }            }            if (__bTemp == _pwMappingTable[0] && NULL != _pwCurrentUnicodeTable &&                ((WORD*) (_aAsciiMappingTable[0])) != _pwCurrentUnicodeTable)            {                _pwMappingTable = _pwCurrentUnicodeTable;                for (__bTemp = 1; __bTemp < _pwMappingTable[0]; __bTemp++)                {                    if (_pwMappingTable[__bTemp * 2] == wOutputCode)                    {                        break;                    }                }            }    // not Found            bCharNum++;             if (__bTemp == _pwMappingTable[0])                _aString[bBufferIndex] = CHAR_ASCII_SPACE;             else                _aString[bBufferIndex] = _pwMappingTable[__bTemp * 2 + 1];         }        else         {            if (bLineIndex < CHAR_SP_MAX_LINE_NUM)            {                _aLinePtr[bLineIndex] = _aString + bBufferIndex - bCharNum - 1;                *(_aLinePtr[bLineIndex]) = bCharNum;            }            bLineIndex++;            bCharNum = 0;        }        bBufferIndex++;         pString = ((PBYTE)_pSP_HeaderPt) + PARSER_SPTXT_HEADER_SIZE + wReadByteNum;    }    if (bLineIndex < CHAR_SP_MAX_LINE_NUM)    {        _aLinePtr[bLineIndex] = _aString + bBufferIndex - bCharNum - 1;        *(_aLinePtr[bLineIndex]) = bCharNum;    }*/}#endif#ifdef SUPPORT_CHAR_ENCODING_BIG5void _Convert_Big5_To_Unicode(void){    WORD   wReadByteNum;    WORD   wOutputCode;    BYTE   bReadBuffer[2];    BYTE   bCharNum, bLineIndex, bBufferIndex;    PBYTE  pString;     // Point to the start address of the string     // The string in buffer has been translated before    /*    if (_pSP_LastHeaderPt == _pSP_HeaderPt)        return;    */    for (bLineIndex = 0; bLineIndex < CHAR_SP_MAX_LINE_NUM; bLineIndex++)        _aLinePtr[bLineIndex] = NULL;    pString = ((PBYTE)_pSP_HeaderPt) + PARSER_SPTXT_HEADER_SIZE;    wReadByteNum = 0;    bCharNum = 0;    bBufferIndex = 1;    bLineIndex = 0;    _aLinePtr[bLineIndex] = _aString;    // Translate Big5 -> Unicode    while (wReadByteNum < _pSP_HeaderPt->bLen && bLineIndex < CHAR_SP_MAX_LINE_NUM)     {        bReadBuffer[0] = *pString;  // Get the first byte        if (0x80 > bReadBuffer[0])	// ASCII Code        {            wOutputCode = (WORD) bReadBuffer[0];            wReadByteNum++;        }        else // Chinese character	         {            if (((wReadByteNum+1) < _pSP_HeaderPt->bLen) && (*(pString+1) != 0x0D))            {                bReadBuffer[1] = *(pString+1);  // Get the second byte                wOutputCode = ((WORD)(bReadBuffer[0])) << 8;                wOutputCode |= (WORD) (bReadBuffer[1]);                wReadByteNum += 2;		            }	      else // it's not two byte character, we can't read the next byte.            {                wOutputCode = (WORD) bReadBuffer[0];                wReadByteNum++;            }        }        if (0x0D != wOutputCode)        {            if (0x80 > wOutputCode)	// ASCII Code            {                bCharNum++;                             _aString[bBufferIndex] = wOutputCode;                        }                        else	// Chinese character		             {                bCharNum++;                _aString[bBufferIndex] = CONVCHAR_To_Uni(wOutputCode);            }        }        else         {            if (bLineIndex < CHAR_SP_MAX_LINE_NUM)            {                _aLinePtr[bLineIndex] = _aString + bBufferIndex - bCharNum - 1;                *(_aLinePtr[bLineIndex]) = bCharNum;            }            bLineIndex++;            bCharNum = 0;        }        bBufferIndex++;         pString = ((PBYTE)_pSP_HeaderPt) + PARSER_SPTXT_HEADER_SIZE + wReadByteNum;    }    if (bLineIndex < CHAR_SP_MAX_LINE_NUM)    {        _aLinePtr[bLineIndex] = _aString + bBufferIndex - bCharNum - 1;        *(_aLinePtr[bLineIndex]) = bCharNum;    }}#endif#ifdef SUPPORT_CHAR_ENCODING_SHIFT_JISvoid _Convert_Shift_JIS_To_Unicode(){    WORD   wReadByteNum;    WORD   wOutputCode;    BYTE   bReadBuffer[2];    BYTE   bCharNum, bLineIndex, bBufferIndex;    PBYTE  pString;     // Point to the start address of the string     // The string in buffer has been translated before    /*    if (_pSP_LastHeaderPt == _pSP_HeaderPt)        return;    */    for (bLineIndex = 0; bLineIndex < CHAR_SP_MAX_LINE_NUM; bLineIndex++)        _aLinePtr[bLineIndex] = NULL;    pString = ((PBYTE)_pSP_HeaderPt) + PARSER_SPTXT_HEADER_SIZE;    wReadByteNum = 0;    bCharNum = 0;    bBufferIndex = 1;    bLineIndex = 0;    _aLinePtr[bLineIndex] = _aString;    // Translate Shift JIS -> Unicode    while (wReadByteNum < _pSP_HeaderPt->bLen && bLineIndex < CHAR_SP_MAX_LINE_NUM)     {        bReadBuffer[0] = *pString;  // Get the first byte        if ((0x80 > bReadBuffer[0]) ||(0xA0 < bReadBuffer[0] && 0xE0 > bReadBuffer[0]))	// ASCII Code or JIS X 0201 Code        {            wOutputCode = (WORD) bReadBuffer[0];            wReadByteNum++;        }        else        {            if (((wReadByteNum+1) < _pSP_HeaderPt->bLen) && (*(pString+1) != 0x0D))            {                bReadBuffer[1] = *(pString+1);  // Get the second byte                wOutputCode = ((WORD)(bReadBuffer[0])) << 8;                wOutputCode |= (WORD) (bReadBuffer[1]);                wReadByteNum += 2;		            }	      else // it's not two byte character, we can't read the next byte.            {                wOutputCode = (WORD) bReadBuffer[0];                wReadByteNum++;            }        }                if (0x0D != wOutputCode)        {            if (0x80 > wOutputCode)	// ASCII Code            {                bCharNum++;                             _aString[bBufferIndex] = wOutputCode;                   if (_aString[bBufferIndex] == 0x5C)    // Remapping the character                 {                    _aString[bBufferIndex] = _aString[bBufferIndex] + 0xA9;                  }            }            else if (0xA0 < wOutputCode && 0xE0 > wOutputCode)	// JIS X 0201 Code            {                bCharNum++;                             _aString[bBufferIndex] = 0;	            }            else	// JIS X 0208 Code		             {                bCharNum++;                _aString[bBufferIndex] = CONVCHAR_To_Uni(wOutputCode);            }        }        else         {            if (bLineIndex < CHAR_SP_MAX_LINE_NUM)            {                _aLinePtr[bLineIndex] = _aString + bBufferIndex - bCharNum - 1;                *(_aLinePtr[bLineIndex]) = bCharNum;            }            bLineIndex++;            bCharNum = 0;        }        bBufferIndex++;         pString = ((PBYTE)_pSP_HeaderPt) + PARSER_SPTXT_HEADER_SIZE + wReadByteNum;    }    if (bLineIndex < CHAR_SP_MAX_LINE_NUM)    {        _aLinePtr[bLineIndex] = _aString + bBufferIndex - bCharNum - 1;        *(_aLinePtr[bLineIndex]) = bCharNum;    }}#endif#ifdef SUPPORT_UNICODE_CODINGvoid _Convert_UTF8_To_Unicode(){    WORD   wReadByteNum;    WORD   wOutputCode = 0;    BYTE   bReadBuffer[4];    BYTE   bCharNum, bLineIndex, bBufferIndex;    PBYTE  pString;     // Point to the start address of the string    

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -