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

📄 msapi_osd.c

📁 mstar 776 开发的车载dvd
💻 C
📖 第 1 页 / 共 5 页
字号:
            {
                MDrv_GE_GetGlyphDispInfo(font_handle, pu8Str[i], &pGlyphDispInfo[i]);
                pGlyphDispInfo[i].u8Width = pGlyphDispInfo[i].u8Width * scale;
            }
        }
        else
        {
            pu16Str = (U16*) pu8Str;
            for (i=0; i<len; i++)
            {
                MDrv_GE_GetGlyphDispInfo(font_handle, pu16Str[i], &pGlyphDispInfo[i]);
                pGlyphDispInfo[i].u8Width = pGlyphDispInfo[i].u8Width * scale - kerningX_(pu16Str[i], pu16Str[i+1]);
            }
        }
    }
    else
    {
        if(pclrBtn->bStringIndexWidth == CHAR_IDX_1BYTE)
        {
            for (i=0; i<len; i++)
            {
                MDrv_GE_GetGlyphDispInfo(font_handle, pu8Str[i], &pGlyphDispInfo[i]);
            }
        }
        else
        {
            pu16Str = (U16*) pu8Str;
            for (i=0; i<len; i++)
            {
                MDrv_GE_GetGlyphDispInfo(font_handle, pu16Str[i], &pGlyphDispInfo[i]);
            }
        }
    }

    u16StrWidth = 0;
    if(pclrBtn->Fontfmt.flag & GEFONT_FLAG_VARWIDTH)
    {
        for (i=0; i< len; i++)
        {
            u16StrWidth += pGlyphDispInfo[i].u8Width;
        }

        if (pclrBtn->Fontfmt.flag & GEFONT_FLAG_GAP)
        {
            u16StrWidth += ((len-1) * pclrBtn->Fontfmt.ifont_gap);
        }
    }
    else  // gap/compact + italic
    {
        // italic or default
        u16StrWidth = finfo.width * scale * len;

        // with gap or compact, only one of two
        if (pclrBtn->Fontfmt.flag & GEFONT_FLAG_GAP)
        {
            u16StrWidth +=  ((len-1) * pclrBtn->Fontfmt.ifont_gap);
        }
        else if (pclrBtn->Fontfmt.flag & GEFONT_FLAG_COMPACT)
        {
            u16StrWidth -=  ((len-1) * pclrBtn->Fontfmt.dis);
        }
    }

    /* draw string */
    switch(pclrBtn->enTextAlign)
    {
        case EN_ALIGNMENT_DEFAULT: //without BTN_TEXT_GAP
            cpoint.x = pclrBtn->x;
            break;

        case EN_ALIGNMENT_LEFT:
            cpoint.x = pclrBtn->x + BTN_TEXT_GAP;
            break;

        case EN_ALIGNMENT_RIGHT:
			if (u16StrWidth + BTN_TEXT_GAP > pclrBtn->width)
				cpoint.x = pclrBtn->x;
			else
            	cpoint.x = pclrBtn->x + pclrBtn->width - BTN_TEXT_GAP - u16StrWidth;
            break;

        case EN_ALIGNMENT_CENTER:
			if (u16StrWidth > pclrBtn->width)
				cpoint.x = pclrBtn->x;
			else
            	cpoint.x = pclrBtn->x + (pclrBtn->width - u16StrWidth) / 2;
            break;
    }

    if(pclrBtn->Fontfmt.flag & GEFONT_FLAG_SCALE)
        cpoint.y = pclrBtn->y + (S16)(pclrBtn->height - finfo.height * scale / 100) / 2;
    else
        cpoint.y = pclrBtn->y + (S16)(pclrBtn->height - finfo.height) / 2;

    memcpy(&cpoint.clr, &pclrBtn->t_clr, 4);

#if GE_DRIVER_TEST
    //MDrv_GE_TextOut(font_handle, pu8Str, pclrBtn->bStringIndexWidth, &cpoint,  &pclrBtn->Fontfmt, pGlyphDispInfo);

    FontInfo.FontCoordinate.v0_x =  cpoint.x;
    FontInfo.FontCoordinate.v0_y =  cpoint.y;

    FontInfo.FontCoordinate.width = pclrBtn->Fontfmt.width;
    FontInfo.FontCoordinate.height = pclrBtn->Fontfmt.height;

    FontInfo.Font_SCK_Flag = GESCK_FLAG_SELE_TURNON | GESCK_FLAG_SELE_FOREGROUND;
    FontInfo.Font_Bitblt_Flag = GE_I1_FONT_BITBLT | GE_FONT_FLAG_VARWIDTH | GE_FONT_FLAG_GAP;
    FontInfo.BasicFontInfo.ifont_gap = 2;
    FontInfo.ARGBClr.ForeGroundColor.u32Num
    = (pclrBtn->t_clr&0xff00ff00) + ((pclrBtn->t_clr&0xff)<<16) +((pclrBtn->t_clr>>16)&0xff);
    //FontInfo.ARGBClr.ForeGroundColor.u32Num = (pclrBtn->t_clr&0xff00);

    FontInfo.ARGBClr.BackGroundColor.u32Num = 0;
    FontInfo.BasicFontInfo.fhandle = font_handle;
    FontInfo.Font_Type_Flag          = GEFONT_OSD_TYPE;
     #if 1
      MDrv_GE_FontBitBlt(&FontInfo, pGlyphDispInfo, g_au8OsdTempStr,pclrBtn->bStringIndexWidth);
     #else
    MDrv_GE_FontBitBlt(&FontInfo,fontAttr, pu8Str,pclrBtn->bStringIndexWidth);
     #endif
    PESet.PE_Enable_Flag = GE_PE_FLAG_DEFAULT;
    MDrv_GE_PixelEngine(&PESet);
#else

    #if 1
     MDrv_GE_TextOut(font_handle, g_au8OsdTempStr, pclrBtn->bStringIndexWidth, &cpoint,  &pclrBtn->Fontfmt, pGlyphDispInfo);
    #else
    MDrv_GE_TextOut(font_handle, pu8Str, pclrBtn->bStringIndexWidth, &cpoint,  &pclrBtn->Fontfmt, pGlyphDispInfo);
    #endif
#endif

    if(pGlyphDispInfo != NULL)
    {
        MSAPI_MEMORY_FREE(pGlyphDispInfo);
    }
}

#if 1// kevin 071224 //(!BOOTLOADER_SYSTEM)
/******************************************************************************/
/// API for draw Punctuated text::
/// @param font_handle \b IN font handle
/// @param pu8Str \b IN pointer to string
/// @param pclrBtn \b IN color
/// @param max_row_num \b IN max row count
/******************************************************************************/
void msAPI_OSD_DrawPunctuatedString(FONTHANDLE font_handle, U16 *pu16Str, OSDClrBtn *pclrBtn, U8 max_row_num)
{
    S8 gap;
    U8 scale, i, offset_len, cut_strlen;
    U16 total_strlen, width;
    U16 max_width, buf_y;
    FONT_INFO finfo;
    GLYPH_BBOX_X BBox_X_Info;
    //For Last one Space character(ASCII code 0x20) of current string to be displayed in current OSD line.
    BOOLEAN bGetLastSpaceinSingleLine;
    U8 u8LastSpaceIndex;
    U16 u16LastSpace_Width;
    U8 bExceed = FALSE;

    /*prevent error*/
    if(pclrBtn->bStringIndexWidth!=CHAR_IDX_2BYTE)
    {
        APIOSD_DBG(printf("Only support 2 bytes strubg\n"));
        return;
    }

    //For Last one Space character(ASCII code 0x20) of current string to be displayed in current OSD line.
    if(max_row_num == 0)
    {
        APIOSD_DBG(printf("E_DrawSmartText>> max_row_num = 0\n"));
        return;
    }
    else if ((total_strlen = msAPI_OSD_GetStrLength((U8*)pu16Str, pclrBtn->bStringIndexWidth)) == 0)
    {
        APIOSD_DBG(printf("E_DrawSmartText>> strlen = 0\n"));
        return;
    }

    MDrv_GE_GetFontInfo(font_handle, &finfo);
    scale = 1;
    if(pclrBtn->Fontfmt.flag & GEFONT_FLAG_SCALE)
    {
        scale = (U8)((U16)pclrBtn->Fontfmt.height / (U16)finfo.height);
        pclrBtn->Fontfmt.height = finfo.height * scale;

        scale = (U8)((U16)pclrBtn->Fontfmt.width / (U16)finfo.width);
        pclrBtn->Fontfmt.width = finfo.width * scale;
    }

    gap = 0;
    if(pclrBtn->Fontfmt.flag & GEFONT_FLAG_VARWIDTH)
    {
        if(pclrBtn->Fontfmt.flag & GEFONT_FLAG_GAP)
        {
            gap = pclrBtn->Fontfmt.ifont_gap;
        }
    }
    else
    {
        if(pclrBtn->Fontfmt.flag & GEFONT_FLAG_GAP)
        {
            gap = pclrBtn->Fontfmt.ifont_gap;
        }
        else if (pclrBtn->Fontfmt.flag & GEFONT_FLAG_COMPACT)
        {
            gap = -pclrBtn->Fontfmt.dis;
        }
    }

    offset_len = 2;
    buf_y = pclrBtn->y;

    max_width = pclrBtn->width - 2*BTN_TEXT_GAP;

    for(i=0; i<max_row_num && total_strlen; i++)
    {
        width = 0;
        cut_strlen = 0;
        bGetLastSpaceinSingleLine=FALSE;//Reset variable
        u8LastSpaceIndex = 0;//Reset variable
        u16LastSpace_Width = 0; //Reset variable

        if(pclrBtn->Fontfmt.flag & GEFONT_FLAG_VARWIDTH)
        {
            while(width<max_width && cut_strlen<total_strlen)
            {
                MDrv_GE_GetBBox_X(font_handle, pu16Str[cut_strlen++], &BBox_X_Info);
                width += (BBox_X_Info.u8Width*scale + gap);

                if ((pu16Str[(cut_strlen-1)]==0x20)||((pu16Str[(cut_strlen-1)]>=0x80)&&(pu16Str[(cut_strlen-1)]<=0x9F)) )//if Space Char or Control code
                {
                    u8LastSpaceIndex =  cut_strlen;//Set the LastSpaceIndex to current string index.
                    u16LastSpace_Width = width; //Set the LastSpace_Width to current string width.
                    bGetLastSpaceinSingleLine = TRUE;

                    if ( pu16Str[(cut_strlen-1)]==0x8A )
                    {
                        pu16Str[(cut_strlen-1)]=0x20;
                        break;
                    }
                    else
                    {
                        pu16Str[(cut_strlen-1)]=0x20;
                    }
                }
            }
        }
        else
        {
            while(width<max_width && cut_strlen<total_strlen)
            {
                cut_strlen++;
                width += (finfo.width + gap);
                if ((pu16Str[(cut_strlen-1)]==0x20)||((pu16Str[(cut_strlen-1)]>=0x80)&&(pu16Str[(cut_strlen-1)]<=0x9F)) )//if Space Char or Control code
                {
                    u8LastSpaceIndex =  cut_strlen;//Set the LastSpaceIndex to current string index.
                    u16LastSpace_Width = width; //Set the LastSpace_Width to current string width.
                    bGetLastSpaceinSingleLine = TRUE;

                    if ( pu16Str[(cut_strlen-1)]==0x8A )
                    {
                        pu16Str[(cut_strlen-1)]=0x20;
                        break;
                    }
                    else
                    {
                        pu16Str[(cut_strlen-1)]=0x20;
                    }
                }
            }
        }

        if(width >= max_width)
        {
            cut_strlen--;
            bExceed = TRUE;
        }

        //Set new cut string length to last Space index
        if (bGetLastSpaceinSingleLine&&u8LastSpaceIndex&&(total_strlen > cut_strlen))
        {
            #if (Very_Long_Word_Case==1)
            if ( u16LastSpace_Width>((U16)(max_width/2)) )
            #endif
            {
               //if (i < max_row_num-1)
               cut_strlen = u8LastSpaceIndex;
            }
        }
        //Set new cut string length to last Space index

        APIOSD_DBG(printf("DrawSmartText>> cut_strlen = %bu\n", cut_strlen));

        if(cut_strlen == 0)
        {
            break;
        }
        else
        {
            width = (cut_strlen+1) * offset_len;
            if (bExceed && i == max_row_num-1)
            {
                pu16Str[cut_strlen-1] = 0x01; // ...
            }
            pu16Str[cut_strlen] = 0;
            msAPI_OSD_DrawText(font_handle, (U8*)pu16Str, pclrBtn);

            total_strlen -= cut_strlen;
            pu16Str += (cut_strlen*offset_len);
        }
        pclrBtn->y += pclrBtn->height;
    }

    pclrBtn->y = buf_y;
}

#if USE_EPG
/******************************************************************************/
void msAPI_OSD_DrawPunctuatedString_S1(FONTHANDLE font_handle, U8 *pu8Str, OSDClrBtn *pclrBtn, U8 max_row_num)
{

	S8 gap;
    U8 scale, i, offset_len, cut_strlen;
	U16 total_strlen, width;
	U16 max_width, buf_y;
	U8 *pStr;
	U16 *pu16Str;
	FONT_INFO finfo;
	GLYPH_BBOX_X BBox_X_Info;

//For Last one Space character(ASCII code 0x20) of current string to be displayed in current OSD line.
	BOOLEAN bGetLastSpaceinSingleLine;
	U8 u8LastSpaceIndex;
	U16 u16LastSpace_Width;

//For Last one Space character(ASCII code 0x20) of current string to be displayed in current OSD line.

	if(max_row_num == 0)
	{
		APIOSD_DBG(printf("E_DrawSmartText>> max_row_num = 0\n"));
		return;
	}
	else if ((total_strlen = msAPI_OSD_GetStrLength(pu8Str, pclrBtn->bStringIndexWidth)) == 0)
	{
		APIOSD_DBG(printf("E_DrawSmartText>> strlen = 0\n"));
		return;
	}

    MDrv_GE_GetFontInfo(font_handle, &finfo);
    scale = 1;
    if(pclrBtn->Fontfmt.flag & GEFONT_FLAG_SCALE)
    {
        scale = (U8)((U16)pclrBtn->Fontfmt.height / (U16)finfo.height);
        pclrBtn->Fontfmt.height = finfo.height * scale;

        scale = (U8)((U16)pclrBtn->Fontfmt.width / (U16)finfo.width);
        pclrBtn->Fontfmt.width = finfo.width * scale;
    }

	gap = 0;
	if(pclrBtn->Fontfmt.flag & GEFONT_FLAG_VARWIDTH)
	{
		if(pclrBtn->Fontfmt.flag & GEFONT_FLAG_GAP)
		{
			gap = pclrBtn->Fontfmt.ifont_gap;
		}
	}
	else
	{
		if(pclrBtn->Fontfmt.flag & GEFONT_FLAG_GAP)
		{
			gap = pclrBtn->Fontfmt.ifont_gap;
		}
              else if (pclrBtn->Fontfmt.flag & GEFONT_FLAG_COMPACT)
		{
			gap = -pclrBtn->Fontfmt.dis;
		}
	}

	if(pclrBtn->bStringIndexWidth == CHAR_IDX_1BYTE)
	{
    	offset_len = 1;
	}
	else
	{
    	offset_len = 2;
	}

	buf_y = pclrBtn->y;

	max_width = pclrBtn->width - 2*BTN_TEXT_GAP;
	for(i=0; i<max_row_num && total_strlen; i++)
	{
		width = 0;
		cut_strlen = 0;
		bGetLastSpaceinSingleLine=FALSE;//Reset variable

⌨️ 快捷键说明

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