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

📄 char_subpict.c

📁 ct952 source code use for Digital Frame Photo
💻 C
📖 第 1 页 / 共 4 页
字号:
    //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;        while (wReadByteNum < _pSP_HeaderPt->bLen && bLineIndex < CHAR_SP_MAX_LINE_NUM)     {        bReadBuffer[0] = *pString;  // Get the first byte        // Translate UTF8 -> Unicode        if (0x80 > bReadBuffer[0])           // 0xxxxxxx        {            wOutputCode = (WORD) bReadBuffer[0];            wReadByteNum++;        }        else if (0xE0> bReadBuffer[0])       // 110xxxxx 10xxxxxx        {            if (((wReadByteNum+1) < _pSP_HeaderPt->bLen) && (*(pString+1) != 0x0D))            {                bReadBuffer[1] = *(pString+1);  // Get the second byte                wOutputCode = ((WORD)(bReadBuffer[0] & 0x1F)) << 6;                wOutputCode |= (WORD) (bReadBuffer[1] & 0x3F);                wReadByteNum += 2;		            }	      else // it's not two byte character, we can't read the next byte.            {                wOutputCode = (WORD) bReadBuffer[0];                wReadByteNum++;            }                    }        else if (0xF0 > bReadBuffer[0])      // 1110xxxx 10xxxxxx 10xxxxxx        {            if (((wReadByteNum+2) < _pSP_HeaderPt->bLen) && (*(pString+1) != 0x0D) && (*(pString+2) != 0x0D))            {                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 // it's not three byte character, we can't read following byte.            {                wOutputCode = (WORD) bReadBuffer[0];                wReadByteNum++;            }                         }        else if (0xF8 > bReadBuffer[0])      // 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx        {            if (((wReadByteNum+3) < _pSP_HeaderPt->bLen) && (*(pString+1) != 0x0D) && (*(pString+2) != 0x0D) && (*(pString+3) != 0x0D))            {                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;            }	      else // it's not four byte character, we can't read following byte.            {                wOutputCode = (WORD) bReadBuffer[0];                wReadByteNum++;            }                        }	  else // it's not UTF-8 character, we add protection here to avoid do nothing        {            wOutputCode = (WORD) bReadBuffer[0];            wReadByteNum++;        }   		         // Exchange HBTYE and LBYTE        /*        bTempCode = wOutputCode;                wOutputCode = wOutputCode >> 8;        wOutputCode |=  bTempCode << 8;        */        if (0x0D != wOutputCode)        {            bCharNum++;                         _aString[bBufferIndex] = 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 //SUPPORT_UNICODE_CODING#ifdef ISO_8859_8_FONTvoid _Change_Word_Direction(){#ifdef HEBREW_IE_FORMAT    BYTE CharIndex, SentenceIndex, NumberIndex;    WORD SentenceBuffer[ONE_LINE_CHAR_NUMBER];    WORD	WordBuffer[MAX_WORD_LENGTH];    #elif defined(HEBREW_WORD_FORMAT)    BYTE CharIndex, WordIndex;    WORD WordBuffer[MAX_WORD_LENGTH];#else    WORD WordBuffer[ONE_LINE_CHAR_NUMBER];    BYTE Index1, Index2;#endif#ifdef HEBREW_IE_FORMAT    // change direction of number word    for (NumberIndex = 0; NumberIndex < _bHebNumberIndex; NumberIndex += 2)    {        // save a number word to buffer	  for (CharIndex = 0; CharIndex < _bHebNumberInfo[NumberIndex+1]; CharIndex++)        {            WordBuffer[CharIndex] = _aString[_bHebNumberInfo[NumberIndex]+CharIndex];        }        // change direction and return it to subtitle strings        for (CharIndex = 0; CharIndex < _bHebNumberInfo[NumberIndex+1]; CharIndex++)        {            _aString[_bHebNumberInfo[NumberIndex]+CharIndex] = WordBuffer[_bHebNumberInfo[NumberIndex+1]-CharIndex-1];        }    }    // change directioni of sentence    for (SentenceIndex = 0; SentenceIndex < _bHebSentenceIndex; SentenceIndex += 2)    {        // save a hebrew sentence to buffer	  for (CharIndex = 0; CharIndex < _bHebSentenceInfo[SentenceIndex+1]; CharIndex++)        {            SentenceBuffer[CharIndex] = _aString[_bHebSentenceInfo[SentenceIndex]+CharIndex];        }        // change direction and return it to subtitle strings        for (CharIndex = 0; CharIndex < _bHebSentenceInfo[SentenceIndex+1]; CharIndex++)        {            _aString[_bHebSentenceInfo[SentenceIndex]+CharIndex] = SentenceBuffer[_bHebSentenceInfo[SentenceIndex+1]-CharIndex-1];        }    }    #elif defined(HEBREW_WORD_FORMAT)    for (WordIndex = 0; WordIndex < _bHebWordIndex; WordIndex += 2)    {        // save a hebrew word to buffer	  for (CharIndex = 0; CharIndex < _bHebWordInfo[WordIndex+1]; CharIndex++)        {            WordBuffer[CharIndex] = _aString[_bHebWordInfo[WordIndex]+CharIndex];        }        // change direction and return it to subtitle strings        for (CharIndex = 0; CharIndex < _bHebWordInfo[WordIndex+1]; CharIndex++)        {            _aString[_bHebWordInfo[WordIndex]+CharIndex] = WordBuffer[_bHebWordInfo[WordIndex+1]-CharIndex-1];        }    }#else    // inverse word    Index1 = 0;    while (_aLinePtr[Index1] && Index1 < CHAR_SP_MAX_LINE_NUM)     {        for (Index2 = 0; Index2 < (BYTE)_aLinePtr[Index1][0]; Index2++)        {                       WordBuffer[Index2] = _aLinePtr[Index1][Index2+1];        }        // change direction and return it to subtitle strings        for (Index2 = 0; Index2 < (BYTE)_aLinePtr[Index1][0]; Index2++)        {            _aLinePtr[Index1][Index2+1] = WordBuffer[_aLinePtr[Index1][0]-Index2-1];        }               Index1++;    }#endif}#endifBYTE _SP_Autowrap(){    BOOL   blAutowrap;    BYTE   bCharNum = 0, bLineIndex, bCutCharNum;#ifdef SUPPORT_UNICODE_CODING    BYTE   bIndex, bTemp = 0;#endif    bLineIndex = 0;    // The string in buffer has been translated before    /*    if (_pSP_LastHeaderPt == _pSP_HeaderPt)    {        for (__bTemp = 0; __bTemp < CHAR_SP_MAX_LINE_NUM; __bTemp++)        {            if (NULL != _aLinePtr[__bTemp])                bLineIndex++;        }        return bLineIndex;    }    */    if (__bEnCodeType == CHAR_ENCODE_ISO_CP)    {    // Check whether need to do the auto-wrap    bLineIndex = 0;    while (_aLinePtr[bLineIndex] && bLineIndex < CHAR_SP_MAX_LINE_NUM)    {        blAutowrap = FALSE;        __dwTemp = GDI_GetStringWidth_909(_aLinePtr[bLineIndex]);        bCutCharNum = 0;        while (CHAR_SP_REG_WIDTH < __dwTemp)    // Need to cut the line        {            blAutowrap = TRUE;            bCharNum = _aLinePtr[bLineIndex][0];             while (CHAR_ASCII_SPACE != _aLinePtr[bLineIndex][bCharNum] && bCharNum > 0)            {                bCharNum--;            }            if (0 != bCharNum)            {                bCharNum--;    // Don't need the space in the end of this line                bCutCharNum += _aLinePtr[bLineIndex][0] - bCharNum;                _aLinePtr[bLineIndex][0] = bCharNum;            }            else            {                blAutowrap = FALSE;                while (CHAR_SP_REG_WIDTH < GDI_GetStringWidth_909(_aLinePtr[bLineIndex]))                {                    _aLinePtr[bLineIndex][0]--;                }            }            __dwTemp = GDI_GetStringWidth_909(_aLinePtr[bLineIndex]);        }        if (blAutowrap)        {            if (CHAR_SP_MAX_LINE_NUM - 1 > bLineIndex)            {                // bBufferIndex plus the char number of the next line                if (NULL != _aLinePtr[bLineIndex+1])                    bCutCharNum += _aLinePtr[bLineIndex+1][0];                else                    bCutCharNum--;  // Skip the first char, SPACE, in the line                                               _aLinePtr[bLineIndex+1][0] = CHAR_ASCII_SPACE;                _aLinePtr[bLineIndex+1] = _aLinePtr[bLineIndex] + _aLinePtr[bLineIndex][0] + 1;                _aLinePtr[bLineIndex+1][0] = bCutCharNum;            }         }        bLineIndex++;   // Next string    }    }#ifdef SUPPORT_UNICODE_CODING    else //CHAR_SP_CODE_UNICODE    {        // Check whether need to do the auto-wrap    bLineIndex = 0;        while (_aLinePtr[bLineIndex] && bLineIndex < CHAR_SP_MAX_LINE_NUM)        {            blAutowrap = FALSE;            __dwTemp = GDI_GetUniStringWidth(_aLinePtr[bLineIndex]);            bCutCharNum = 0;            if (CHAR_SP_REG_WIDTH < __dwTemp)    // Need to cut the line    {                blAutowrap = TRUE;                bCharNum = _aLinePtr[bLineIndex][0];                 while (CHAR_SP_REG_WIDTH < GDI_GetUniStringWidth(_aLinePtr[bLineIndex]))                {                    _aLinePtr[bLineIndex][0]--;                }                bCutCharNum = bCharNum - _aLinePtr[bLineIndex][0];                bTemp = bCutCharNum;                bCharNum = _aLinePtr[bLineIndex][0];                             }            if (blAutowrap)        {                if (CHAR_SP_MAX_LINE_NUM - 1 > bLineIndex)            {                    // bBufferIndex plus the char number of the next line                    if (NULL != _aLinePtr[bLineIndex+1])            {                        bCutCharNum += _aLinePtr[bLineIndex+1][0];            }						       // shift the exceeded character to next line                     for (bIndex = bTemp; bIndex > 0; bIndex--)            {                         _aLinePtr[bLineIndex][bCharNum+bIndex+1] = _aLinePtr[bLineIndex][bCharNum+bIndex];            }		                       _aLinePtr[bLineIndex+1] = _aLinePtr[bLineIndex] + _aLinePtr[bLineIndex][0] + 1;                    _aLinePtr[bLineIndex+1][0] = bCutCharNum;        }    }            bLineIndex++;   // Next string        }    }#endif    _pSP_LastHeaderPt = _pSP_HeaderPt;    return bLineIndex;}void  _CHAR_SP_InitPalette(void){    // If EX_SP_USE_SPU_BUFFER is define,    // CHAR_SP_ENTRY_COLOR_FG index must be 2 and    // CHAR_SP_ENTRY_COLOR_BG index must be 3.    // Becuase in SPU, the foreground index of font is 2 and    // the background index of font is 3    // The colors index are shared with OSDND and dont need to init the color./* Alan2.30, don't need to init the colors, they are initialized by normal display.    GDI_ChangePALEntry(CHAR_SP_ENTRY_COLOR_FG, CHAR_SP_VALUE_COLOR_FG, FALSE);    GDI_ChangePALEntry(CHAR_SP_ENTRY_COLOR_BG, CHAR_SP_VALUE_COLOR_BG, TRUE);*/}#ifdef EX_SP_USE_SPU_BUFFERvoid _CHAR_SP_InitSPU(void){            SPU_BMP_Init();            SPU_BMP_SetDisplayArea(0, 51, CHAR_SP_REG_TOP, __RegionList[GDI_SP_REGION_ID].wWidth,                __RegionList[GDI_SP_REGION_ID].wHeight, (const BYTE*)__RegionList[GDI_SP_REGION_ID].dwTAddr);            SPU_BMP_SetColorContrast(0, 0, COMUTL_RGB2YUV(0x000000), 0);            SPU_BMP_SetColorContrast(0, 1, COMUTL_RGB2YUV(0x000000), 0);            SPU_BMP_SetColorContrast(0, 2, COMUTL_RGB2YUV(CHAR_SP_VALUE_COLOR_FG), 15);            SPU_BMP_SetColorContrast(0, 3, COMUTL_RGB2YUV(CHAR_SP_VALUE_COLOR_BG), 8);            GDI_ClearRegion(GDI_SP_REGION_ID);}#endif void CHAR_SP_ClearRegion(void){#ifdef EX_SP_USE_SPU_BUFFER    SPU_BMP_SetDisplay(0, FALSE);    GDI_ClearRegion(GDI_SP_REGION_ID);#else    GDI_FillRect_909(0, &_CHAR_SP_RectAttr);#endif    _blAlreadyDisplay = FALSE;}#if (FONT_TABLE_METHOD == CREATE_DYNAMICALLY)void _CHAR_SP_UseExSPFontTable(BOOL bUseExSPFontTable){/*    if (bUseExSPFontTable)    {        switch (__SetupInfo.bExSPSTLanguage)        {#ifdef ISO_8859_15_FONT        case SETUP_LANGUAGE_EX_SP_WESTERN_EUROPEAN:            OSD_SetCurFontTable(FONTTABLE_8859_15);            break;#endif#ifdef ISO_8859_2_FONT        case SETUP_LANGUAGE_EX_SP_CENTRAL_EUROPEAN:            OSD_SetCurFontTable(FONTTABLE_8859_2);            break;#endif#ifdef ISO_8859_7_FONT        case SETUP_LANGUAGE_EX_SP_GREEK:            OSD_SetCurFontTable(FONTTABLE_8859_7);            break;#endif// elmer2.51, add Damon's code for Hebrew#ifdef ISO_8859_8_FONT        case SETUP_LANGUAGE_EX_SP_HEBREW:            OSD_SetCurFontTable(FONTTABLE_8859_8);            break;#endif#ifdef ISO_8859_9_FONT        case SETUP_LANGUAGE_EX_SP_TURKISH:            OSD_SetCurFontTable(FONTTABLE_8859_9);            break;#endif#ifdef CP_1250_FONT        case SETUP_LANGUAGE_EX_SP_CP1250:            OSD_SetCurFontTable(FONTTABLE_8859_2);            break;#endif#ifdef CP_1251_FONT        case SETUP_LANGUAGE_EX_SP_CYRILLIC:            OSD_SetCurFontTable(FONTTABLE_CP_1251);            break;#endif#ifdef SUPPORT_UNICODE_CODING//        case SETUP_LANGUAGE_EX_SP_UNICODE://		OSD_SetCurFontTable(FONTABLE_UNICODE);//		break;#endif#ifdef SUPPORT_CHINESE_SUBTITLE_BIG5        case SETUP_LANGUAGE_EX_SP_BIG5:		OSD_SetCurFontTable(FONTABLE_UNICODE);		break;#endif#ifdef SUPPORT_JAPANESE_SUBTITLE_JIS        case SETUP_LANGUAGE_EX_SP_SHIFT_JIS:		OSD_SetCurFontTable(FONTABLE_UNICODE);		break;#endif        case SETUP_LANGUAGE_EX_SP_ASCII:        default:            break;        }        //GDI_SetFontHeightInTable(_bFontHeightInTable);     }    else    {        OSD_SetCurFontTable(FONTABLE_OSD);        //GDI_SetFontHeightInTable(OSD_FONT_HEIGHT);     }*/}#endif // #if (FONT_TABLE_METHOD == CREATE_DYNAMICALLY)#endif  // #ifdef SUPPORT_CHAR_SUBPICTURE

⌨️ 快捷键说明

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