📄 osdwrap.c
字号:
if (YStart < 0)
{
MemoryHeightToFill = MemoryHeightToFill + YStart;
YStart = 0;
}
if (YStop > YMaxInRegion)
{
YStop = YMaxInRegion;
MemoryHeightToFill = (U32)(YStop - YStart + 1);
}
/*Some other Bitmap settings in half res Vert */
Bitmap_p->Height = MemoryHeightToFill;
if( XStart + MemoryWidthToFill > XMaxInRegion+1 ||
YStart + MemoryHeightToFill > YMaxInRegion+1 )
{
return ST_ERROR_BAD_PARAMETER;
}
#ifdef BLIT
Context.EventSubscriberID = BlitSubscriberID;
/* ------------ Set Rectangle ------------ */
Rectangle.PositionX = XStart ;
Rectangle.PositionY = YStart ;
Rectangle.Width = MemoryWidthToFill ;
Rectangle.Height = MemoryHeightToFill ;
/* ------------ Set Bitmap ------------ */
GxobjBitmap.ColorType = VPSource.Data.BitMap_p->ColorType;
GxobjBitmap.BitmapType = VPSource.Data.BitMap_p->BitmapType;
GxobjBitmap.PreMultipliedColor = VPSource.Data.BitMap_p->PreMultipliedColor;
GxobjBitmap.ColorSpaceConversion = VPSource.Data.BitMap_p->ColorSpaceConversion;
GxobjBitmap.AspectRatio = VPSource.Data.BitMap_p->AspectRatio;
GxobjBitmap.Width = Bitmap_p->Width;
GxobjBitmap.Height = Bitmap_p->Height;
/* GxobjBitmap.Pitch = Bitmap_p->Width;*/
GxobjBitmap.Pitch = (Bitmap_p->Width * 8)/8;
/* Workarround for the ddts GNBvd37910 : will be deleted in the next release */
GxobjBitmap.Offset = 0;
GxobjBitmap.Data1_p = Bitmap_p->Data_p;
GxobjBitmap.Size1 = GxobjBitmap.Pitch * GxobjBitmap.Height;
GxobjBitmap.Data2_p = NULL;
GxobjBitmap.Size2 = 0;
GxobjBitmap.SubByteFormat = VPSource.Data.BitMap_p->SubByteFormat;
GxobjBitmap.BigNotLittle = VPSource.Data.BitMap_p->BigNotLittle;
/* ------------ Set Context ------------ */
Context.ColorKeyCopyMode = STBLIT_COLOR_KEY_MODE_NONE;
Context.AluMode = STBLIT_ALU_COPY;
Context.EnableMaskWord = FALSE;
Context.EnableMaskBitmap = FALSE;
Context.EnableColorCorrection = FALSE;
Context.Trigger.EnableTrigger = FALSE;
Context.GlobalAlpha = 50;
Context.EnableClipRectangle = FALSE;
Context.ClipRectangle = Rectangle;
Context.WriteInsideClipRectangle = TRUE;
Context.EnableFlickerFilter = FALSE;
Context.JobHandle = STBLIT_NO_JOB_HANDLE;
Context.NotifyBlitCompletion = TRUE;
/* ------------ Blit ------------ */
STTBX_Report ((STTBX_REPORT_LEVEL_INFO,"Start Fill rectangle \n"));
Err = STBLIT_CopyRectangle(BLIT_Handle,VPSource.Data.BitMap_p,&Rectangle,&GxobjBitmap,0,0,&Context );
if (Err != ST_NO_ERROR)
{
STTBX_Report ((STTBX_REPORT_LEVEL_INFO,"Err Blit : %d\n",Err));
return (TRUE);
}
#endif
#ifdef MEMCPY
u8src_p = (U8 *) DesBitmap_p->Data1_p;
u8des_p = (U8 *) Bitmap_p->Data_p;
u8src_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;
u8src_p = u8src_p + DesBitmap_p->Pitch - MemoryWidthToFill;
}
#endif
return (ST_NO_ERROR);
} /* STOSD_GetRectangle */
/*******************************************************************************
Name : STOSD_CopyRectangle
Description : Copies part of region to another one
Parameters :
Assumptions :
Limitations :
Returns :
*******************************************************************************/
ST_ErrorCode_t STOSD_CopyRectangle(
STOSD_RegionHandle_t SrcHandle,
S32 SrcPositionX,
S32 SrcPositionY,
U32 SrcWidth,
U32 SrcHeight,
STOSD_RegionHandle_t DstHandle,
S32 DstPositionX,
S32 DstPositionY
)
{
}
/*******************************************************************************
Name : STOSD_GetPixel
Description : Returns the specified pixel color
Parameters :
Assumptions :
Limitations :
Returns :
*******************************************************************************/
ST_ErrorCode_t STOSD_GetPixel(
STOSD_RegionHandle_t Handle,
U32 PositionX,
U32 PositionY,
STOSD_Color_t* Color_p
)
{
S32 XMaxInRegion = 0;
S32 XMinInRegion = 0;
S32 YMaxInRegion = 0;
S32 YMinInRegion = 0;
STGXOBJ_Bitmap_t* DesBitmap_p;
U8 * u8datap1;
DesBitmap_p=VPSource.Data.BitMap_p;
XMinInRegion = 0;
XMaxInRegion = DesBitmap_p->Width - 1;
/* if Rectangle completly out of region (according to Horizontal information)
* we fill nothing*/
if (PositionX < XMinInRegion)
{
return (ST_NO_ERROR);
}
if (PositionX > XMaxInRegion)
{
return (ST_NO_ERROR);
}
YMinInRegion = 0;
YMaxInRegion = DesBitmap_p->Height -1;
/* If the Rectangle is completly out of region (according to vertical information)
* we fill nothing */
if (PositionY < YMinInRegion)
{
return (ST_NO_ERROR);
}
if (PositionY > YMaxInRegion)
{
return (ST_NO_ERROR);
}
u8datap1 = (U8 *) DesBitmap_p->Data1_p;
u8datap1 += DesBitmap_p->Pitch* PositionY + PositionX + DesBitmap_p->Offset;
Color_p->Value.PaletteEntry = *u8datap1;
Color_p->Type = STOSD_COLOR_TYPE_PALETTE;
Color_p->MixWeight = 0x3f;
return (ST_NO_ERROR);
}
/*******************************************************************************
Name : STOSD_SetPixel
Description : Plots a pixel at a given position
Parameters :
Assumptions :
Limitations :
Returns :
*******************************************************************************/
ST_ErrorCode_t STOSD_SetPixel(
STOSD_RegionHandle_t Handle,
U32 PositionX,
U32 PositionY,
STOSD_Color_t Color
)
{
S32 XMaxInRegion = 0;
S32 XMinInRegion = 0;
S32 YMaxInRegion = 0;
S32 YMinInRegion = 0;
STGXOBJ_Bitmap_t* DesBitmap_p;
U8 * u8datap1;
DesBitmap_p=VPSource.Data.BitMap_p;
XMinInRegion = 0;
XMaxInRegion = DesBitmap_p->Width - 1;
/* if Rectangle completly out of region (according to Horizontal information)
* we fill nothing*/
if (PositionX < XMinInRegion)
{
return (ST_NO_ERROR);
}
if (PositionX > XMaxInRegion)
{
return (ST_NO_ERROR);
}
YMinInRegion = 0;
YMaxInRegion = DesBitmap_p->Height -1;
/* If the Rectangle is completly out of region (according to vertical information)
* we fill nothing */
if (PositionY < YMinInRegion)
{
return (ST_NO_ERROR);
}
if (PositionY > YMaxInRegion)
{
return (ST_NO_ERROR);
}
u8datap1 = (U8 *) DesBitmap_p->Data1_p;
u8datap1 += DesBitmap_p->Pitch* PositionY + PositionX + DesBitmap_p->Offset;
memset(u8datap1,Color.Value.PaletteEntry,1);
return (ST_NO_ERROR);
}
/*******************************************************************************
Name : STOSD_SetRegionMixWeight
Description : Set MixWeight for all Palette entries
Parameters :
Assumptions :
Limitations :
Returns :
*******************************************************************************/
ST_ErrorCode_t STOSD_SetRegionMixWeight (
STOSD_RegionHandle_t Handle,
U8 MixWeight)
{
MixWeight = 0x3f;
}
/*******************************************************************************
Name : STOSD_GetRegionMixWeight
Description : Get the region MixWeight
Parameters :
Assumptions :
Limitations :
Returns :
*******************************************************************************/
ST_ErrorCode_t STOSD_GetRegionMixWeight(
STOSD_RegionHandle_t Handle,
U8* MixWeight_p
)
{
*MixWeight_p = 0x3f;
}
/***********************************************************************************/
/**** Draws a line from (x1,y1) to (x2,y2) using Bresenham Algorithm ****/
/***********************************************************************************/
ST_ErrorCode_t STOSD_DrawLine(STOSD_RegionHandle_t Handle, U32 x1, U32 y1, U32 x2, U32 y2, STOSD_Color_t color)
{
ST_ErrorCode_t returnError;
//STOSD_RegionParams_t params;
/* starting point of line */
int x = x1, y = y1;
/* direction of line */
int dx = x2-x1, dy = y2-y1;
int ax, ay, decx, decy, max, var;
/* increment or decrement depending on direction of line */
int sx = (dx > 0 ? 1 : (dx < 0 ? -1 : 0));
int sy = (dy > 0 ? 1 : (dy < 0 ? -1 : 0));
/* decision parameters for voxel selection */
if ( dx < 0 ) dx = -dx;
if ( dy < 0 ) dy = -dy;
ax = 2*dx, ay = 2*dy;
/* determine largest direction component, single-step related variable */
max = dx;
var = 0;
if ( dy > max ) { var = 1; }
/* traverse Bresenham line */
switch ( var )
{
case 0: /* single-step in x-direction */
for (decy=ay-dx; /**/; x += sx, decy += ay)
{
/* process pixel */
/*callback(x,y);*/
STOSD_SetPixel(Handle, x, y, color);
/* take Bresenham step */
if ( x == x2 ) break;
if ( decy >= 0 ) { decy -= ax; y += sy; }
}
break;
case 1: /* single-step in y-direction */
for (decx=ax-dy; /**/; y += sy, decx += ax)
{
/* process pixel */
/*callback(x,y);*/
STOSD_SetPixel(Handle, x, y, color);
/* take Bresenham step */
if ( y == y2 ) break;
if ( decx >= 0 ) { decx -= ay; x += sx; }
}
break;
}
return ST_NO_ERROR;
}
/*****************************************************************************************/
/**** Draws a rectangle from upper left corner (x1,y1) with width and height ****/
/*****************************************************************************************/
ST_ErrorCode_t STOSD_DrawRectangle(STOSD_RegionHandle_t Handle, U32 x, U32 y, U32 width, U32 height, STOSD_Color_t color)
{
ST_ErrorCode_t returnError;
if ((returnError=STOSD_DrawLine(Handle, x, y, x+width-1, y, color)) != ST_NO_ERROR)
{
return returnError;
}
if ((returnError=STOSD_DrawLine(Handle, x+width-1, y, x+width-1, y+height-1, color)) != ST_NO_ERROR)
{
return returnError;
}
if ((returnError=STOSD_DrawLine(Handle, x+width-1, y+height-1, x, y+height-1, color)) != ST_NO_ERROR)
{
return returnError;
}
if ((returnError=STOSD_DrawLine(Handle, x, y+height-1, x, y, color)) != ST_NO_ERROR)
{
return returnError;
}
return ST_NO_ERROR;
}
ST_ErrorCode_t HL_STOSD_DrawRectangle(STOSD_RegionHandle_t Handle, U32 x, U32 y, U32 width, U32 height, STOSD_Color_t color)
{
ST_ErrorCode_t returnError;
returnError = STOSD_DrawRectangle(Handle, x, y, width, height, color);
return returnError;
}
ST_ErrorCode_t HL_STOSD_DrawBMP(STOSD_RegionHandle_t Handle, U32 positionX, U32 positionY, STOSD_Bitmap_t bitmap)
{
STOSD_PutRectangle(0,positionX,positionY,(STOSD_Bitmap_t *)&bitmap);
}
void EMC_DrawTriangle(Triangle_Type_e type,int x,int y,int length,STOSD_Color_t color)
{
int i,j;
if(length%2 == 0)
length+=1;
j = (length+1)/2;
switch(type)
{
case TRIANGLE_UP:
for(i = 0;i<j;i++)
{
STOSD_DrawLine(Handle_ProviewWindow,x+i,y-i,x+i+length-2*i, y-i,color);
}
break;
case TRIANGLE_DOWN:
for(i = 0;i<j;i++)
{
STOSD_DrawLine(Handle_ProviewWindow,x+i,y+i,x+i+length-2*i, y+i,color);
}
break;
case TRIANGLE_LEFT:
for(i = 0;i<j;i++)
{
STOSD_DrawLine(Handle_ProviewWindow,x-i,y+i,x-i, y+i+length-2*i,color);
}
break;
case TRIANGLE_RIGHT:
for(i = 0;i<j;i++)
{
STOSD_DrawLine(Handle_ProviewWindow,x+i,y+i,x+i, y+i+length-2*i,color);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -