📄 tidtv_glibext.c
字号:
/*******************************************************************************
* @ModuleName :: TiDTV_GLib.c
*
* @Copyright :: Copyright 2005- Texas Instruments, Inc.
*
* @Description:: 2D Graphics library for TVP9000 OSD Controller
*
* @History ::
*---------------------------------------
* 03-05-2005 W.Shi Created
*******************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "ucos_ii.h"
#include "TvpError.h"
#include "TvpDefs.h"
#include "TiDTV_DataType.h"
#include "TiDTV_SysCtrl.h"
#include "TVP9K_OSD_Def.h"
#include "TVP9K_BG_Def.h"
#include "TVP9K_NV_Def.h"
#include "TVP9K_VC_Def.h"
#include "TiDTV_HW.h"
#include "TiDTV_Buffers.h"
#include "TvpHdm.h"
#include "TiDTV_GLib.h"
////////////////////////////////////////////
extern const unsigned char Tahoma32[];
/*******************************************************************************
* @RoutineName:: TiDTV_OsdDrawBitMap
*
* @Description:: Draw an Icon
*
* @Input ::
* USHORT IconCode : Icon code
*
* @Output ::
* pOsdScreen->pCurDrawWindow->CurX : next position
*
* @Return :: none
*******************************************************************************/
void TiDTV_OsdDrawBitMap(TI_DTV_OSD_SCREEN *pOsdScreen, USHORT IconCode)
{
TI_DTV_G_ICON *pIcon = (TI_DTV_G_ICON *) pDtvIconBase[IconCode & (~TI_DTV_CHAR_SET_CTRL_MASK)];
TvpBitmap TVPmemmap;
TvpOsdCoords srccoords;
TvpOsdCoords dstcoords;
TvpBitmap Screenmap;
Screenmap.pBitmap = (char*)pOsdScreen->pCurDrawWindow->pBitmapBase;
Screenmap.width = pOsdScreen->pOsdWindows->Area.w;
Screenmap.height = pOsdScreen->pOsdWindows->Area.h;
Screenmap.stride = pOsdScreen->pOsdWindows->Area.w; // all menu bitmaps must be 256 color
Screenmap.format = TVP_BITMAP8;
srccoords.pixX0 = 0;
srccoords.pixY0 = 0;
srccoords.pixX1 = pIcon->Width;
srccoords.pixY1 = pIcon->Height;
dstcoords.pixX0 = pOsdScreen->pCurDrawWindow->Area.x + pOsdScreen->pCurDrawWindow->CurX;
dstcoords.pixY0 = pOsdScreen->pCurDrawWindow->Area.y + pOsdScreen->pCurDrawWindow->CurY;
dstcoords.pixX1 = dstcoords.pixX0 + pIcon->Width - 1;
dstcoords.pixY1 = dstcoords.pixY0 + pIcon->Width - 1;
TVPmemmap.format = Screenmap.format;
TVPmemmap.height = pIcon->Height;
TVPmemmap.width = pIcon->Width;
TVPmemmap.stride = pIcon->Width;
TVPmemmap.pBitmap = (char*)pIcon->pBitmap;
tvpBltCopy(
&TVPmemmap,
&Screenmap,
&srccoords,
&dstcoords
);
}
/*******************************************************************************
* @RoutineName:: TiDTV_OsdGetStringLength
*
* @Description:: get a string's length info
*
* @Input ::
* USHORT *pString : pointer to the string
*
* @Output :: length
*
* @Return :: none
*******************************************************************************/
UINT32 TiDTV_OsdGetStringLength(TI_DTV_OSD_SCREEN *pOsdScreen, USHORT *pString)
{
TI_DTV_OSD_WINDOW *pCurDrawWindow = pOsdScreen->pCurDrawWindow;
TI_DTV_G_CHAR *pCurCharPattern = (TI_DTV_G_CHAR *) &(pCurDrawWindow->CurCharPattern);
UINT32 Length;
USHORT CharCode;
Length = 0;
while(*pString != 0)
{
CharCode = *pString;
pString++;
TiDTV_OsdGetCharPattern(CharCode, pCurDrawWindow);
Length = Length + pCurCharPattern->CellWidth;
}
return Length;
}
/*******************************************************************************
* @RoutineName:: TiDTV_OsdGetStringLength
*
* @Description:: get a string's length info
*
* @Input ::
* USHORT *pString : pointer to the string
*
* @Output :: Height
*
* @Return :: none
*******************************************************************************/
UINT32 TiDTV_OsdGetStringHeight(TI_DTV_OSD_SCREEN *pOsdScreen, USHORT *pString)
{
TI_DTV_OSD_WINDOW *pCurDrawWindow = pOsdScreen->pCurDrawWindow;
TI_DTV_G_CHAR *pCurCharPattern = (TI_DTV_G_CHAR *) &(pCurDrawWindow->CurCharPattern);
UINT32 Height;
USHORT CharCode;
Height = 0;
while(*pString != 0)
{
CharCode = *pString;
pString++;
TiDTV_OsdGetCharPattern(CharCode, pCurDrawWindow);
if(Height < pCurCharPattern->CellHeight)
{
Height = pCurCharPattern->CellHeight;
}
}
return Height;
}
/*******************************************************************************
* @RoutineName:: TiDTV_OsdDrawStringTest
*
* @Description::
*
* @Input ::
*
*
* @Output ::
*
*
* @Return :: none
*******************************************************************************/
/*void TiDTV_OsdDrawStringWithAreaInfo(USHORT AreaWidth, USHORT AreaHeight, TI_DTV_OSD_SCREEN *pOsdScreen, USHORT *pString)
{
ULONG j, x, y, xStart, xEnd, yStart, yEnd;
UCHAR *FontTablePt, *CurrentFontPt,temp8;
USHORT *StringPt;
UCHAR ForeColor, BackColor, CurrentCharWidth, CurrentCharHeigth;
TI_DTV_OSD_WINDOW *pCurDrawWindow;
UCHAR *pVRAM;
static UCHAR mask[8] = {0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01};
pCurDrawWindow = pOsdScreen->pCurDrawWindow;
ForeColor = pCurDrawWindow->CurCharForeColor;
BackColor = pCurDrawWindow->CurCharBackColor;
// pCurCharPattern = (TI_DTV_G_CHAR *) &(pCurDrawWindow->CurCharPattern);
pVRAM = pCurDrawWindow->pBitmapBase;
xStart = pCurDrawWindow->Area.x + pCurDrawWindow->CurX;
yStart = pCurDrawWindow->Area.y + pCurDrawWindow->CurY;
StringPt = pString;
FontTablePt = (UCHAR*)Tahoma32;
while((UCHAR)(*StringPt) != 0)
{
CurrentCharWidth = FontTablePt[(*StringPt - 0x20) * 132];// + 1;
if(CurrentCharWidth % 2 != 0)
{
CurrentCharWidth = CurrentCharWidth + 1;
}
CurrentCharHeigth = 32;
CurrentFontPt = FontTablePt + (*StringPt - 0x20) * 132 + 1;
xEnd = xStart + CurrentCharWidth;
yEnd = yStart + CurrentCharHeigth;
j = 0;
for(y = yStart; y < yEnd; y++)
{
for(x = 0; x < CurrentCharWidth; x++)
{
if (j % 8 == 0)
{
temp8 = (UCHAR)(*CurrentFontPt++);
}
if((mask[j % 8] & temp8) > 0)
{
pVRAM[pCurDrawWindow->Area.w * y + xStart + x] = ForeColor;
}
else if(BackColor != 0)
{
pVRAM[pCurDrawWindow->Area.w * y + xStart + x] = BackColor;
}
j++;
}
}
xStart = xEnd;
StringPt++;
}
}
*/
/*******************************************************************************
* @RoutineName:: TiDTV_OsdDrawStringTest
*
* @Description::
*
* @Input ::
*
*
* @Output ::
*
*
* @Return :: none
*******************************************************************************/
/*void TiDTV_OsdDrawASCIIStringWithAreaInfo(USHORT AreaWidth, USHORT AreaHeight, TI_DTV_OSD_SCREEN *pOsdScreen, char *pString)
{
ULONG j, x, y, xStart, xEnd, yStart, yEnd;
UCHAR *FontTablePt, *CurrentFontPt,temp8;
char *StringPt;
UCHAR ForeColor, BackColor, CurrentCharWidth, CurrentCharHeigth;
TI_DTV_OSD_WINDOW *pCurDrawWindow;
UCHAR *pVRAM;
static UCHAR mask[8] = {0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01};
pCurDrawWindow = pOsdScreen->pCurDrawWindow;
ForeColor = pCurDrawWindow->CurCharForeColor;
BackColor = pCurDrawWindow->CurCharBackColor;
// pCurCharPattern = (TI_DTV_G_CHAR *) &(pCurDrawWindow->CurCharPattern);
pVRAM = pCurDrawWindow->pBitmapBase;
xStart = pCurDrawWindow->Area.x + pCurDrawWindow->CurX;
yStart = pCurDrawWindow->Area.y + pCurDrawWindow->CurY;
StringPt = pString;
FontTablePt = (UCHAR*)Tahoma32;
while((UCHAR)(*StringPt) != '\0')
{
CurrentCharWidth = FontTablePt[(*StringPt - 0x20) * 132];// + 1;
if(CurrentCharWidth % 2 != 0)
{
CurrentCharWidth = CurrentCharWidth + 1;
}
CurrentCharHeigth = 32;
CurrentFontPt = FontTablePt + (*StringPt - 0x20) * 132 + 1;
xEnd = xStart + CurrentCharWidth;
yEnd = yStart + CurrentCharHeigth;
j = 0;
for(y = yStart; y < yEnd; y++)
{
for(x = 0; x < CurrentCharWidth; x++)
{
if (j % 8 == 0)
{
temp8 = (UCHAR)(*CurrentFontPt++);
}
if((mask[j % 8] & temp8) > 0)
{
pVRAM[pCurDrawWindow->Area.w * y + xStart + x] = ForeColor;
}
else if(BackColor != 0)
{
pVRAM[pCurDrawWindow->Area.w * y + xStart + x] = BackColor;
}
j++;
}
}
xStart = xEnd;
StringPt++;
}
}
*/
/*******************************************************************************
* @RoutineName:: TiDTV_BackupImage
*
* @Description:: Get image
*
* @Input ::
* short x, y : Upper Left Point coordinate
* short w, h : X size of the image
*
* @Output ::
* UCHAR *pImgBuf : pointer to Image data buffer
* The 1st two Hal-words will be used
* to store Width and Height
*
* @Return :: none
*******************************************************************************/
void TiDTV_BackupImage(TI_DTV_OSD_SCREEN *pOsdScreen, short x, short y, short w, short h, UCHAR *pImgBuf)
{
// TI_DTV_G_ICON *pIcon = (TI_DTV_G_ICON *) pDtvIconBase[IconCode & (~TI_DTV_CHAR_SET_CTRL_MASK)];
TvpBitmap Current_Screen;
TvpBitmap Backup_Screen;
TVP_FERROR error;
TvpOsdCoords srccoords;
TvpOsdCoords dstcoords;
Current_Screen.pBitmap = (char*)pOsdScreen->pCurDrawWindow->pBitmapBase;
Current_Screen.width = pOsdScreen->pOsdWindows->Area.w;
Current_Screen.height = pOsdScreen->pOsdWindows->Area.h;
Current_Screen.stride = pOsdScreen->pOsdWindows->Area.w; // all menu bitmaps must be 256 color
Current_Screen.format = TVP_BITMAP8;
srccoords.pixX0 = pOsdScreen->pCurDrawWindow->Area.x + x;
srccoords.pixY0 = pOsdScreen->pCurDrawWindow->Area.y + y;
srccoords.pixX1 = srccoords.pixX0 + w;
srccoords.pixY1 = srccoords.pixY0 + h;
dstcoords.pixX0 = pOsdScreen->pCurDrawWindow->Area.x + x;;
dstcoords.pixY0 = pOsdScreen->pCurDrawWindow->Area.y + y;
dstcoords.pixX1 = dstcoords.pixX0 + w - 1;
dstcoords.pixY1 = dstcoords.pixY0 + h - 1;
Backup_Screen.format = Current_Screen.format;
Backup_Screen.height = pOsdScreen->pOsdWindows->Area.h;
Backup_Screen.width = pOsdScreen->pOsdWindows->Area.w;
Backup_Screen.stride = pOsdScreen->pOsdWindows->Area.w;
Backup_Screen.pBitmap = (char*)pImgBuf;
error = tvpBltCopy(
&Current_Screen,
&Backup_Screen,
&srccoords,
&dstcoords
);
// prevent warning
error = error;
}
/*******************************************************************************
* @RoutineName:: TiDTV_RestoreImage
*
* @Description:: Get image
*
* @Input ::
* short x, y : Upper Left Point coordinate
* short w, h : X size of the image
*
* @Output ::
* UCHAR *pImgBuf : pointer to Image data buffer
* The 1st two Hal-words will be used
* to store Width and Height
*
* @Return :: none
*******************************************************************************/
void TiDTV_RestoreImage(TI_DTV_OSD_SCREEN *pOsdScreen, short x, short y, short w, short h, UCHAR *pImgBuf)
{
// TI_DTV_G_ICON *pIcon = (TI_DTV_G_ICON *) pDtvIconBase[IconCode & (~TI_DTV_CHAR_SET_CTRL_MASK)];
TvpBitmap Current_Screen;
TvpBitmap Backup_Screen;
TVP_FERROR error;
TvpOsdCoords srccoords;
TvpOsdCoords dstcoords;
Current_Screen.pBitmap = (char*)pOsdScreen->pCurDrawWindow->pBitmapBase;
Current_Screen.width = pOsdScreen->pOsdWindows->Area.w;
Current_Screen.height = pOsdScreen->pOsdWindows->Area.h;
Current_Screen.stride = pOsdScreen->pOsdWindows->Area.w; // all menu bitmaps must be 256 color
Current_Screen.format = TVP_BITMAP8;
srccoords.pixX0 = pOsdScreen->pCurDrawWindow->Area.x + x;
srccoords.pixY0 = pOsdScreen->pCurDrawWindow->Area.y + y;
srccoords.pixX1 = srccoords.pixX0 + w;
srccoords.pixY1 = srccoords.pixY0 + h;
dstcoords.pixX0 = pOsdScreen->pCurDrawWindow->Area.x + x;;
dstcoords.pixY0 = pOsdScreen->pCurDrawWindow->Area.y + y;
dstcoords.pixX1 = dstcoords.pixX0 + w - 1;
dstcoords.pixY1 = dstcoords.pixY0 + h - 1;
Backup_Screen.format = Current_Screen.format;
Backup_Screen.height = pOsdScreen->pOsdWindows->Area.h;
Backup_Screen.width = pOsdScreen->pOsdWindows->Area.w;
Backup_Screen.stride = pOsdScreen->pOsdWindows->Area.w;
Backup_Screen.pBitmap = (char*)pImgBuf;
error = tvpBltCopy(
&Backup_Screen,
&Current_Screen,
&srccoords,
&dstcoords
);
// prevent warning
error = error;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -