fsGUIShowFont.c
资源名称:8202s.rar [点击查看]
上传用户:poi891205
上传日期:2013-07-15
资源大小:9745k
文件大小:8k
源码类别:
DVD
开发平台:
C/C++
- #ifndef _FSGUISHOWFONT_C_
- #define _FSGUISHOWFONT_C_
- #include "global.h"
- #include "graph.h"
- #include "LanguageUtil.h"
- #define DWORD_WIDTH_NORMAL 14
- #define SWORD_WIDTH_NORMAL 9
- #define DWORD_WIDTH_LARGE 26
- #define SWORD_WIDTH_LARGE 16
- void EnlargeFontSizeToDouble( UINT8 *pDest, const UINT8 *pSrc, BYTE uiWidth, BYTE uiHeight )
- {
- BYTE i, j, k, m, n;
- UINT16 my16bits=0;
- for (i=0;i<uiHeight;i++)
- for(n=0;n<2;n++)
- for(j=0;j<(uiWidth/8);j++)
- {
- for(k=0;k<8;k++)
- for(m=0;m<2;m++)
- if((pSrc[i*2+j]>>(7-k))&0x01)
- my16bits |= (1<<(uiWidth-1-(k*2+m)));
- pDest[(i*2+n)*4+j*2]=(my16bits>>8);
- pDest[(i*2+n)*4+j*2+1]=my16bits&0xff;
- my16bits=0;
- }
- }
- void ReduceFontSizeToHalf( UINT8 *pDest, const UINT8 *pSrc, BYTE uiWidth, BYTE uiHeight )
- {
- UINT8 i, j;
- uiHeight = uiHeight >> 1;
- for( i = 0; i < uiHeight; i++ )
- {
- const UINT8* pData = &pSrc[ (i<<2) ];
- UINT16 uiData1 = ( pData[0] << 8 ) | pData[1];
- UINT8 uiData2 = 0;
- for( j = 0; j < 8; j++ )
- uiData2 |= (UINT8) ( ( uiData1 & ( 0x01 << ( j << 1 ) ) ) >> j );
- pDest[i] = uiData2;
- }
- }
- void ResampleWidthFrom12PixelTo16Pixel( UINT8* pDest, const UINT8* pSrc, UINT32 uiHeight )
- {
- UINT8 i = 0, uiToggle = 0;
- for( ; i < ( uiHeight << 1 ); i += 2 )
- {
- if( uiToggle )
- {
- pDest[ i ] = pSrc[1];
- pDest[ i + 1 ] = (pSrc[0] & 0x0f ) << 4;
- pSrc += 2;
- }
- else
- {
- pDest[ i ] = pSrc[0];
- pDest[ i + 1 ] = pSrc[1] & 0xf0;
- pSrc += 1;
- }
- uiToggle = !uiToggle;
- }
- }
- void FSGUI_DrawMonoBitmap( BYTE video_buf, const BYTE* pFont, UINT16 x, UINT16 y, UINT16 uiWidth, UINT16 uiHeight, UINT8 uiY, UINT16 uiCbCr, UINT8 uiScaleMode )
- {
- // uiScaleMode == 0, Direct draw
- // uiScaleMode == 1, Enlarge input bmp by 2 x 2
- // uiScaleMode == 2, Reduce input bmp by 2 x 2
- UINT8 i, j;
- UINT8 aFont[96]; // 24 * 2 * 2
- const BYTE* pDestFont;
- switch( uiScaleMode )
- {
- case 2:
- ReduceFontSizeToHalf( aFont, pFont, uiWidth, uiHeight );
- uiWidth = uiWidth >> 1;
- uiHeight = uiHeight >> 1;
- pDestFont = aFont;
- break;
- case 1:
- EnlargeFontSizeToDouble( aFont, pFont, uiWidth, uiHeight );
- uiWidth = uiWidth << 1;
- uiHeight = uiHeight << 1;
- pDestFont = aFont;
- break;
- default:
- pDestFont = pFont;
- break;
- }
- for( j = 0; j < uiHeight; j++ )
- {
- UINT8 uiOffset = 0;
- UINT8 uiCurWidth = uiWidth;
- while( uiCurWidth > 0 )
- {
- UINT8 uiCount = uiCurWidth >= 8 ? 8 : uiCurWidth;
- uiCurWidth -= uiCount;
- UINT8 uiData = *pDestFont;
- for( i = 0; i < uiCount; i++, uiOffset++ )
- {
- if( uiData & ( 0x80 >> i ) )
- {
- UINT16 uiDestX = x + uiOffset;
- UINT16 uiDestY = y + j;
- if( video_buf == 0 )
- {
- *Y_XY( uiDestX, uiDestY ) = uiY;
- *C_XY( uiDestX, uiDestY ) = uiCbCr;
- }
- else if( video_buf == 1 )
- {
- *Y_XY1( uiDestX, uiDestY ) = uiY;
- *C_XY1( uiDestX, uiDestY ) = uiCbCr;
- }
- else if( video_buf == 2 )
- {
- *Y_XYB( uiDestX, uiDestY ) = uiY;
- *C_XYB( uiDestX, uiDestY ) = uiCbCr;
- }
- }
- }
- pDestFont++;
- }
- }
- }
- UINT32 FSGUI_ShowChar_Internal( BYTE video_buf, UINT16 x, UINT16 y, BYTE c, BYTE iY, UINT16 iCbCr, UINT8 uiMode ) //Jeff 20020823
- {
- // uiMode == 0, normal font size
- // uiMode == 1, large font size( double )
- BYTE* pFont = get_font_entry(0,c);
- if( !pFont )
- return 0;
- pFont += 3;
- #ifdef USE_SMALL_FONT
- UINT8 aData[32];
- ResampleWidthFrom12PixelTo16Pixel( aData, pFont, 16 );
- FSGUI_DrawMonoBitmap( video_buf, aData, x, y, 16, 16, iY, iCbCr, uiMode ? 0 : 2 );
- #else
- FSGUI_DrawMonoBitmap( video_buf, pFont, x, y, 16, 24, iY, iCbCr, uiMode ? 0 : 2 );
- #endif
- return uiMode ? SWORD_WIDTH_LARGE : SWORD_WIDTH_NORMAL;
- }
- void FSGUI_ShowChar( BYTE video_buf, int x, int y, BYTE c, BYTE iY, UINT16 iCbCr ) //Jeff 20020823
- {
- #if defined (MP3_LARGE_GUI) || defined (FS_BMP_GUI)
- FSGUI_ShowChar_Internal( video_buf, x, y, c, iY, iCbCr, 1 );
- #else
- FSGUI_ShowChar_Internal( video_buf, x, y, c, iY, iCbCr, 0 );
- #endif
- }
- UINT32 FSGUI_FontShowChar( UINT16 x, UINT16 y, const BYTE* pBmp, UINT8 uiY, UINT16 uiCbCr, UINT8 uiMode )
- {
- UINT8 aFont[ 48 ];
- ENUM_FONT_TYPE enType = GetFontType();
- if( enType == FONT_BIG5 || enType == FONT_BIG5_COMMON ||
- enType == FONT_GB2312 || enType == FONT_JIS ||
- enType == FONT_KSC || enType == FONT_RUSSIAN )
- {
- ResampleWidthFrom12PixelTo16Pixel( aFont, pBmp, 12 );
- FSGUI_DrawMonoBitmap( 0, aFont, x, y, 16, 12, uiY, uiCbCr, uiMode );
- return uiMode ? DWORD_WIDTH_LARGE : DWORD_WIDTH_NORMAL;
- }
- else if( enType == FONT_ISO_8859_1 || enType == FONT_ISO_8859_2 || enType == FONT_ISO_8859_5|| enType == FONT_ISO_8859_9 )
- {
- ResampleWidthFrom12PixelTo16Pixel( aFont, pBmp, 24 );
- FSGUI_DrawMonoBitmap( 0, aFont, x, y, 16, 24, uiY, uiCbCr, ( uiMode ? 0 : 2 ) );
- return uiMode ? SWORD_WIDTH_LARGE : SWORD_WIDTH_NORMAL;
- }
- return 0;
- }
- void FSGUI_ShowString_Internal( UINT16 x, UINT16 y, const UINT8 *pStr, BYTE uiY, UINT16 uiCbCr, UINT8 uiMode )
- {
- // uiMode == 0, normal font size
- // uiMode == 1, large font size( double )
- #ifdef FS_BMP_GUI
- #define SENTENCE_LEN_NORMAL 300
- #else
- #define SENTENCE_LEN_NORMAL 260
- #endif
- #define SENTENCE_LEN_LARGE 540
- UINT16 uiCount = 0;
- UINT16 uiSentenceLen = uiMode ? SENTENCE_LEN_LARGE : SENTENCE_LEN_NORMAL;
- while( *pStr )
- {
- const UINT8* pBmp = NULL;
- UINT32 uiRtnVal = GetCharacterBmp( pStr, &pBmp );
- ENUM_FONT_TYPE enType = GetFontType();
- // 2004/01/19 yltseng, temporarily usage, should be removed after font size is unified
- if( ( uiRtnVal != FONT_NOT_IN_RANGE ) &&
- ( enType == FONT_BIG5 || enType == FONT_BIG5_COMMON || enType == FONT_GB2312 ) )
- {
- UINT32 uiOffset = FSGUI_FontShowChar( x + uiCount, y, pBmp, uiY, uiCbCr, uiMode ); // 2004/09/23 yltseng
- if( uiRtnVal == FONT_ONE_BYTE )
- pStr++;
- else
- pStr += 2;
- //liweihua mod 2004-11-23
- //for display more Russian characters
- #ifdef ETON_DVD
- if( GetFontType() == FONT_GB2312 && pStr[0] == 0xA7 )
- uiCount += 10;
- else
- #endif
- uiCount += uiOffset;
- }
- else
- {
- BYTE c = *pStr;
- if ( (c < 32) || (c > 126) )
- c = '_';
- uiCount += FSGUI_ShowChar_Internal( 0, x + uiCount, y, c, uiY, uiCbCr, uiMode );
- pStr++;
- }
- if( uiCount > uiSentenceLen )
- break; // yhwang, for limiting the length of FSGUI_ShowString
- }
- }
- void FSGUI_ShowString(int x, int y, const UINT8 *s, BYTE iY, UINT16 iCbCr)
- {
- #if defined (MP3_LARGE_GUI) || defined (FS_BMP_GUI)
- FSGUI_ShowString_Internal( x, y, s, iY, iCbCr, 1 );
- #else
- FSGUI_ShowString_Internal( x, y, s, iY, iCbCr, 0 );
- #endif
- }
- #ifdef FS_BMP_GUI
- /*
- Function:In order to show little string in Sunplus New GUI
- Creator:Feeling
- */
- void FSGUI_ShowLittleString(int x, int y, const char *s, BYTE iY, UINT16 iCbCr)
- {
- FSGUI_ShowString_Internal( x, y, s, iY, iCbCr, 0 );
- }
- #endif
- #endif