📄 osdwrap.c
字号:
/*****************************************************************************
File name: osdwrap.c
Description: osd opertaion
COPYRIGHT (C) 2004 STMicroelectronics
*****************************************************************************/
/* Includes --------------------------------------------------------------- */
#include <string.h>
#include "stlite.h"
#include "stddefs.h"
#include "stdevice.h"
#include "sttbx.h"
#include "stgxobj.h"
#include "sections.h" /* memory partitions */
#include "avmem.h" /* AV memory partition */
#include "errors.h"
#include "evt.h"
#include "layer.h"
#include "blit.h"
#include "gui.h"
#include "osdwrap.h"
#define MEMCPY
/* Private Types ---------------------------------------------------------- */
/* Private Constants ------------------------------------------------------ */
/* Private Variables ------------------------------------------------------ */
/* Private Macros --------------------------------------------------------- */
/* Private Function prototypes -------------------------------------------- */
/* Constants -------------------------------------------------------------- */
/* Global Variables ------------------------------------------------------- */
extern STLAYER_ViewPortSource_t VPSource;
extern STOSD_RegionParams_t ProviewWindowParams;
STEVT_SubscriberID_t BlitSubscriberID;
/* Functions -------------------------------------------------------------- */
ST_ErrorCode_t STOSD_FillRectangle(
STOSD_RegionHandle_t Handle,
S32 PositionX,
S32 PositionY,
U32 Width,
U32 Height,
STOSD_Color_t Color
)
{
S32 XStart = 0; /*PositionX Start in Memory for each field*/
S32 XStop = 0; /*PositionX Stop in Memory for each field*/
S32 YStart = 0; /*PositionY Start in Memory for each field*/
S32 YStop = 0; /*PositionY Stop in Memory for each field*/
S32 XMaxInRegion = 0;
S32 XMinInRegion = 0;
S32 YMaxInRegion = 0;
S32 YMinInRegion = 0;
U32 MemoryHeightToFill = 0;
U32 MemoryWidthToFill = 0;
STGXOBJ_Bitmap_t* DesBitmap_p;
int i;
U8 * u8datap1;
DesBitmap_p=VPSource.Data.BitMap_p;
MemoryWidthToFill = Width;
XStart = PositionX ;
XStop = XStart + (S32)MemoryWidthToFill - 1;
XMinInRegion = 0;
XMaxInRegion = DesBitmap_p->Width - 1;
/* if Rectangle completly out of region (according to Horizontal information)
* we fill nothing*/
if (XStop < XMinInRegion)
{
return (ST_NO_ERROR);
}
if (XStart > XMaxInRegion)
{
return (ST_NO_ERROR);
}
/* Horizontal settings correction */
if (XStart < XMinInRegion )
{
XStart = XMinInRegion;
}
if (XStop > XMaxInRegion)
{
XStop = XMaxInRegion;
}
MemoryWidthToFill = (U32)(XStop - XStart + 1);
/* Vertical setting*/
MemoryHeightToFill = Height;
YStart = PositionY;
YStop = YStart + (S32)MemoryHeightToFill - 1;
YMinInRegion = 0;
YMaxInRegion = DesBitmap_p->Height -1;
/* If the Rectangle is completly out of region (according to vertical information)
* we fill nothing */
if (YStop < YMinInRegion)
{
return (ST_NO_ERROR);
}
if (YStart > YMaxInRegion)
{
return (ST_NO_ERROR);
}
/* Vertical settings corrections */
if (YStart < YMinInRegion)
{
YStart = YMinInRegion;
}
if (YStop > YMaxInRegion)
{
YStop = YMaxInRegion;
}
MemoryHeightToFill = (U32)(YStop - YStart + 1);
if( XStart + MemoryWidthToFill > XMaxInRegion+1 ||
YStart + MemoryHeightToFill > YMaxInRegion+1 )
{
return ST_ERROR_BAD_PARAMETER;
}
//sttbx_Print("\n----------W=%d,H=%d\n",MemoryWidthToFill,MemoryHeightToFill);
#ifdef MEMCPY
//sttbx_Print("\n---DesBitmap_p->Offset = %d\n",DesBitmap_p->Offset);
u8datap1 = (U8 *) DesBitmap_p->Data1_p;
u8datap1 += DesBitmap_p->Pitch* YStart + XStart + DesBitmap_p->Offset;
for(i = 0; i < MemoryHeightToFill; i++)
{
memset(u8datap1,Color.Value.PaletteEntry,MemoryWidthToFill);
u8datap1+=MemoryWidthToFill;
u8datap1 = u8datap1 + DesBitmap_p->Pitch - MemoryWidthToFill;
}
#endif
return(ST_NO_ERROR);
}
ST_ErrorCode_t STOSD_PutRectangle(STOSD_RegionHandle_t Handle, S32 PositionX, S32 PositionY, STOSD_Bitmap_t * Bitmap_p)
{
S32 XStart = 0;
S32 XStop = 0;
S32 YStart = 0;
S32 YStop = 0;
S32 XMaxInRegion = 0;
S32 XMinInRegion = 0;
S32 YMinInRegion = 0;
S32 YMaxInRegion = 0;
U32 MemoryWidthToFill = 0;
U32 MemoryHeightToFill = 0;
S32 XOffset = 0;
S32 YOffset = 0;
STGXOBJ_Bitmap_t* DesBitmap_p;
U8 * u8src_p;
U8 * u8des_p;
int i;
/* Check Handle validity */
if (Bitmap_p == NULL)
{
return(ST_ERROR_BAD_PARAMETER);
}
if (Bitmap_p->Data_p == NULL)
{
return(ST_ERROR_BAD_PARAMETER);
}
if (Bitmap_p->ColorType != STOSD_COLOR_TYPE_PALETTE)
{
return(ST_ERROR_FEATURE_NOT_SUPPORTED);
}
if (Bitmap_p->Width == 0)
{
return (ST_ERROR_BAD_PARAMETER);
}
if (Bitmap_p->Height == 0)
{
return (ST_ERROR_BAD_PARAMETER);
}
/*--------- Initial settings concerning Horizontal stuff -----------------*/
DesBitmap_p=VPSource.Data.BitMap_p;
XStart = PositionX ;
MemoryWidthToFill = Bitmap_p->Width; /* Whatever resolution is */
XStop = XStart + (S32)MemoryWidthToFill - 1;
XMinInRegion = 0;
XMaxInRegion = XMinInRegion + (S32)DesBitmap_p->Width - 1;
/* if Rectangle completly out of region (according to Horizontal information)
* we fill nothing*/
if (XStop < XMinInRegion)
{
return (ST_NO_ERROR);
}
if (XStart > XMaxInRegion)
{
return (ST_NO_ERROR);
}
/* Horizontal settings correction */
if (XStart < XMinInRegion )
{
XOffset = XMinInRegion - XStart ;
XStart = XMinInRegion;
}
if (XStop > XMaxInRegion)
{
XStop = XMaxInRegion;
}
MemoryWidthToFill = (U32)(XStop - XStart + 1);
/*------------ Settings concerning vertical stuff ------------------------*/
YStart = PositionY;
MemoryHeightToFill = Bitmap_p->Height;
YStop = YStart + (S32)MemoryHeightToFill - 1;
YMinInRegion = 0;
YMaxInRegion = YMinInRegion + (S32)DesBitmap_p->Height - 1;
/* If the Rectangle is completly out of region (according to vertical information)
* we fill nothing */
if (YStop < YMinInRegion)
{
return (ST_NO_ERROR);
}
if (YStart > YMaxInRegion)
{
return (ST_NO_ERROR);
}
/* Vertical settings corrections */
if (YStart < YMinInRegion)
{
YOffset = YMinInRegion - YStart;
YStart = YMinInRegion;
}
if (YStop > YMaxInRegion)
{
YStop = YMaxInRegion;
}
MemoryHeightToFill = (U32)(YStop - YStart + 1);
if( XStart + MemoryWidthToFill > XMaxInRegion+1 ||
YStart + MemoryHeightToFill > YMaxInRegion+1 )
{
return ST_ERROR_BAD_PARAMETER;
}
#ifdef BLIT
#endif
#ifdef MEMCPY
u8des_p = (U8 *) DesBitmap_p->Data1_p;
u8src_p = (U8 *) Bitmap_p->Data_p;
u8des_p += DesBitmap_p->Pitch* YStart + XStart + DesBitmap_p->Offset;
for(i = 0; i < MemoryHeightToFill; i++)
{
memcpy(u8des_p,u8src_p,MemoryWidthToFill);
u8des_p+=MemoryWidthToFill;
u8src_p+=MemoryWidthToFill;
u8des_p = u8des_p + DesBitmap_p->Pitch - MemoryWidthToFill;
}
#endif
return(ST_NO_ERROR);
}
/*******************************************************************************
Name : STOSD_GetRectangle
Description : Extract a bitmap from a specified region
Parameters :
Assumptions :
Limitations :
Returns :
*******************************************************************************/
ST_ErrorCode_t STOSD_GetRectangle(
STOSD_RegionHandle_t Handle,
S32 PositionX,
S32 PositionY,
U32 Width,
U32 Height,
STOSD_Bitmap_t* Bitmap_p
)
{
S32 XStart = 0;
S32 XStop = 0;
S32 YStart = 0;
S32 YStop = 0;
S32 XMaxInRegion = 0;
S32 YMaxInRegion = 0;
U32 MemoryWidthToFill = 0;
U32 MemoryHeightToFill = 0;
ST_ErrorCode_t Err;
#ifdef BLIT
STBLIT_BlitContext_t Context;
STGXOBJ_Rectangle_t Rectangle;
STGXOBJ_Bitmap_t GxobjBitmap;
#endif
STGXOBJ_Bitmap_t* DesBitmap_p;
int i;
U8 * u8src_p;
U8 * u8des_p;
if (Bitmap_p == NULL)
{
return(ST_ERROR_BAD_PARAMETER);
}
if (Width == 0)
{
return (ST_ERROR_BAD_PARAMETER);
}
if (Height == 0)
{
return (ST_ERROR_BAD_PARAMETER);
}
DesBitmap_p=VPSource.Data.BitMap_p;
/*-------------- Some bitmap settings -----------------------------------*/
Bitmap_p->BitmapType = STOSD_BITMAP_TYPE_DIB_BYTE_ALIGN;
Bitmap_p->ColorType = STOSD_COLOR_TYPE_PALETTE;
Bitmap_p->BitsPerPel = 8;
/*--------- Initial settings concerning Horizontal stuff -----------------*/
XStart = PositionX ;
MemoryWidthToFill = Width;
XStop = XStart + (S32)MemoryWidthToFill - 1;
XMaxInRegion = (S32)(DesBitmap_p->Width - 1);
/* if Rectangle completly out of region (according to Horizontal information)
* we get nothing*/
if (XStop < 0)
{
return (ST_NO_ERROR);
}
if (XStart > XMaxInRegion)
{
return (ST_NO_ERROR);
}
/* Horizontal settings correction */
if (XStart < 0 )
{
MemoryWidthToFill = MemoryWidthToFill + XStart ;
XStart = 0;
}
if (XStop > XMaxInRegion)
{
XStop = XMaxInRegion;
MemoryWidthToFill = (U32)(XStop - XStart + 1);
}
/* Set Bitmap Width */
Bitmap_p->Width = MemoryWidthToFill;
/*------------ Settings concerning vertical stuff ------------------------*/
/* Full vertical resolution */
MemoryHeightToFill = Height ;
YStart = PositionY;
YMaxInRegion = (S32)(DesBitmap_p->Height - 1);
YStop = YStart + (S32)MemoryHeightToFill - 1;
/* If the Rectangle is completly out of region (according to vertical information)
* we get nothing */
if (YStop < 0)
{
return (ST_NO_ERROR);
}
if (YStart > YMaxInRegion)
{
return (ST_NO_ERROR);
}
/* Vertical settings corrections */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -