📄 gpcdraw.c
字号:
seSetPixel( pGC, (SHORT)xPos, (SHORT)yPos, index, style );
if( pGC == gSysTcbTbl[ gLcdOwnerTskId-1 ].gc && pGC->group_operation == 0 )
WRITELCD( xPos, yPos, xPos, yPos )
// seWrite2LCD( pGC->vram, 0);
return GPC_ERR_OK;
}
//---------------------------------------------------------------
// SysDrawHorz()
//
// Draw a horizontal line from (xSrc,ySrc) to the right for width dots.
//
// Parameters:
// gc - Address value of graphic context.
// rgb - Color of the line.
// xPos - Position X of the left end-point of the line.
// yPos - Position Y of the left end-point of the line.
// width - The length of the line.
// dotline - Dotted line drawing.
// style - Output style.
//
// Returns:
// GPC_ERR_OK
//---------------------------------------------------------------
STATUS SysDrawHorz( DWORD gc, DWORD rgb, WORD xSrc, WORD ySrc, WORD width, WORD dotLine, WORD style )
{
GC *pGC;
PIXEL index;
pGC = (GC *)gc;
if ( pGC == NULL || pGC->symbol != GPC_GC_SYMBOL )
return GPC_ERR_FAILED;
if ( xSrc > (pGC->width -1) )
return GPC_ERR_FAILED;
// if ( ySrc > (pGC->height -1) || ySrc - (pGC->dotwidth - 1) / 2 < 0 ) //by zl 2002.4.3
if ( ySrc + pGC->dotwidth / 2 > (pGC->height -1) || ySrc - (pGC->dotwidth - 1) / 2 < 0 )
return GPC_ERR_FAILED;
if ( (xSrc + width) > pGC->width )
return GPC_ERR_FAILED;
// if ( dotLine != GPC_SOLID_LINE && dotLine != GPC_DASH_LINE && dotLine != GPC_DOT_LINE && dotLine != GPC_DASHDOT_LINE ) 2002.2.5
// return GPC_ERR_FAILED;
seRGBtoIndex( rgb, &index ); //turn into colorindex
// if ( style < GPC_REPLACE_STYLE || style > GPC_NOT_STYLE )
// return GPC_ERR_FAILED;
seDrawHorzLine( pGC, (SHORT)xSrc, (SHORT)ySrc, (SHORT)width, index, dotLine, style);
if( pGC == gSysTcbTbl[ gLcdOwnerTskId-1 ].gc && pGC->group_operation == 0 )
{
if( pGC->dotwidth == GPC_NORM_WIDTH )
{
WRITELCD( xSrc, ySrc,xSrc + width - 1 , ySrc )
// seWrite2LCD( pGC->vram, 0);
}
else if( width == 1 )
{
WRITELCD( xSrc - (pGC->dotwidth - 1)/2, ySrc - (pGC->dotwidth - 1)/2, xSrc + pGC->dotwidth/2, ySrc + pGC->dotwidth/2)
// seWrite2LCD( pGC->vram, 0);
}
else
{
WRITELCD( xSrc, ySrc - (pGC->dotwidth - 1)/2, xSrc + width - 1, ySrc + (pGC->dotwidth)/2 )
// seWrite2LCD( pGC->vram, 0);
}
}
return GPC_ERR_OK;
}
//---------------------------------------------------------------
// SysDrawVert()
//
// Draw a vertical line from (xSrc,ySrc) down for height dots.
//
// Parameters:
// gc - Address value of graphic context.
// rgb - Color of the line.
// xPos - Position X of the top end-point of the line.
// yPos - Position Y of the top end-point of the line.
// height - The length of the line.
// dotline - Dotted line drawing.
// style - Output style.
//
// Returns:
// GPC_ERR_OK
//---------------------------------------------------------------
STATUS SysDrawVert(DWORD gc, DWORD rgb, WORD xSrc, WORD ySrc, WORD height, WORD dotLine, WORD style)
{
GC *pGC;
PIXEL index;
pGC = (GC *)gc;
if ( pGC == NULL || pGC->symbol != GPC_GC_SYMBOL )
return GPC_ERR_FAILED;
if ( (xSrc - (pGC->dotwidth - 1) / 2) < 0 ) //left the screen /added by zhuli 2002.2.3
return GPC_ERR_FAILED;
if ( xSrc > (pGC->width -1) )
return GPC_ERR_FAILED;
if ( ySrc > (pGC->height -1) )
return GPC_ERR_FAILED;
if ( (ySrc + height) > pGC->height )
return GPC_ERR_FAILED;
// if ( dotLine != GPC_SOLID_LINE && dotLine != GPC_DASH_LINE && dotLine != GPC_DOT_LINE && dotLine != GPC_DASHDOT_LINE ) 2002.2.5
// return GPC_ERR_FAILED;
// if ( ( style < GPC_REPLACE_STYLE ) || ( style > GPC_NOT_STYLE ) )
// return GPC_ERR_FAILED;
seRGBtoIndex( rgb, &index ); //turn into colorindex
seDrawVertLine( pGC, (SHORT)xSrc, (SHORT)ySrc, (SHORT)height, index, dotLine, style);
if( pGC == gSysTcbTbl[ gLcdOwnerTskId-1 ].gc && pGC->group_operation == 0 )
{
if( pGC->dotwidth == GPC_NORM_WIDTH )
{
WRITELCD( xSrc, ySrc, xSrc, ySrc + height )
// seWrite2LCD( pGC->vram, 0);
}
else if( height == 1 )
{
WRITELCD( xSrc - (pGC->dotwidth - 1)/2, ySrc - (pGC->dotwidth - 1)/2, xSrc + (pGC->dotwidth)/2, ySrc + (pGC->dotwidth)/2 )
// seWrite2LCD( pGC->vram, 0);
}
else
{
WRITELCD( xSrc - (pGC->dotwidth - 1)/2, ySrc, xSrc + (pGC->dotwidth)/2, ySrc + height - 1)
// seWrite2LCD( pGC->vram, 0);
}
}
return GPC_ERR_OK;
}
//---------------------------------------------------------------
// SysDrawLine()
//
// Draw a line from (xSrc,ySrc) to (xDest,yDest).
//
// Parameters:
// gc - Address value of graphic context.
// rgb - Color of the line.
// xPos - Position X of the source point.
// yPos - Position Y of the source point.
// xDest - Position X of the destination point.
// yDest - Position Y of the destination point.
// dotline - Dotted line drawing.
// style - Output style.
//
// Returns:
// GPC_ERR_OK
//---------------------------------------------------------------
STATUS SysDrawLine( DWORD gc, DWORD rgb, WORD xSrc, WORD ySrc, WORD xDest, WORD yDest, WORD dotLine, WORD style )
{
GC *pGC;
PIXEL index;
SHORT x1, x2, y1, y2;
pGC = (GC *)gc;
if ( pGC == NULL || pGC->symbol != GPC_GC_SYMBOL )
return GPC_ERR_FAILED;
if ( pGC->dotwidth != GPC_NORM_WIDTH ) //added by zhuli 2002.2.3
return GPC_ERR_FAILED;
if ( xSrc > (pGC->width -1) || xDest > (pGC->width -1) ) // right the screen
return GPC_ERR_FAILED;
if ( ySrc > (pGC->height - 1) || yDest > (pGC->height -1) ) // under the screen
return GPC_ERR_FAILED;
// if ( dotLine != GPC_SOLID_LINE && dotLine != GPC_DASH_LINE && dotLine != GPC_DOT_LINE && dotLine != GPC_DASHDOT_LINE ) 2002.2.5
// return GPC_ERR_FAILED;
// if ( style < GPC_REPLACE_STYLE || style > GPC_NOT_STYLE )
// return GPC_ERR_FAILED;
seRGBtoIndex( rgb, &index ); //turn into colorindex
if ( xSrc == xDest )
{
if( yDest >= ySrc )
seDrawVertLine( pGC, (SHORT)xSrc, (SHORT)ySrc, (SHORT)( yDest - ySrc + 1 ), index, dotLine, style );
else
seDrawVertLine( pGC, (SHORT)xDest, (SHORT)yDest, (SHORT)( ySrc - yDest + 1), index, dotLine, style ); //modified by zhuli 2002.2.2
}
else if ( ySrc == yDest )
{
if( xDest >= xSrc )
seDrawHorzLine( pGC, (SHORT)xSrc, (SHORT)ySrc, (SHORT)( xDest - xSrc + 1 ), index, dotLine, style );
else
seDrawHorzLine( pGC, (SHORT)xDest, (SHORT)yDest, (SHORT)( xSrc - xDest + 1), index, dotLine, style ); //modified by zhuli 2002.2.2
}
else
seDrawLine( pGC, (SHORT)xSrc, (SHORT)ySrc, (SHORT)xDest, (SHORT)yDest, index, dotLine, style);
if ( xSrc < xDest )
{
x1 = xSrc;
x2 = xDest;
}
else
{
x1 = xDest;
x2 = xSrc;
}
if ( ySrc < yDest )
{
y1 = ySrc;
y2 = yDest;
}
else
{
y1 = yDest;
y2 = ySrc;
}
if ( pGC == gSysTcbTbl[ gLcdOwnerTskId-1 ].gc && pGC->group_operation == 0 )
WRITELCD( x1, y1, x2, y2 )
//seWrite2LCD( pGC->vram, 0);
return GPC_ERR_OK;
}
//---------------------------------------------------------------
// SysDrawRec()
//
// Draw a rectangular outline with the top-left corner at (xSrc,ySrc) and bottom-right corner at (xDest,yDest).
//
// Parameters:
// gc - Address value of graphic context.
// rgb - Color of the line.
// xPos - Position X of the top-left corner.
// yPos - Position Y of the top-left corner.
// xDest - Position X of the bottom-right corner.
// yDest - Position Y of the bottom-right corner.
// dotline - Dotted line drawing.
// style - Output style.
//
// Returns:
// GPC_ERR_OK
//---------------------------------------------------------------
STATUS SysDrawRec( DWORD gc, DWORD rgb, WORD xSrc, WORD ySrc, WORD xDest, WORD yDest, WORD dotLine, WORD style )
{
GC *pGC;
PIXEL index;
pGC = (GC *)gc;
if ( pGC == NULL || pGC->symbol != GPC_GC_SYMBOL )
return GPC_ERR_FAILED;
//added by zhuli 2002.2.3
if ( (xSrc - (pGC->dotwidth - 1) / 2) < 0 || (xDest - (pGC->dotwidth - 1) / 2) < 0 ) //up the screen
return GPC_ERR_FAILED;
if ( (ySrc - (pGC->dotwidth - 1) / 2) < 0 || (yDest - (pGC->dotwidth - 1) / 2) < 0 ) //left the screen
return GPC_ERR_FAILED;
if ( (xSrc + pGC->dotwidth / 2) > (pGC->width - 1) || (xDest + pGC->dotwidth / 2) > (pGC->width - 1) ) // right the screen //if ( xSrc > (pGC->width -1) || xDest > (pGC->width -1) )
return GPC_ERR_FAILED;
if ( (ySrc + pGC->dotwidth / 2) > (pGC->height -1) || (yDest + pGC->dotwidth / 2) > (pGC->height -1) ) //if ( ySrc > (pGC->height -1) || yDest > (pGC->height -1) ) // under the screen
return GPC_ERR_FAILED;
// if ( dotLine != GPC_SOLID_LINE && dotLine != GPC_DASH_LINE && dotLine != GPC_DOT_LINE && dotLine != GPC_DASHDOT_LINE ) 2002.2.5
// return GPC_ERR_FAILED;
// if ( style < GPC_REPLACE_STYLE || style > GPC_NOT_STYLE )
// return GPC_ERR_FAILED;
seRGBtoIndex( rgb, &index ); //turn into colorindex
//added by zhuli 2002.2.3
if ( xSrc == xDest && ySrc == yDest )
seSetPixel( pGC, (SHORT)xSrc, (SHORT)ySrc, index, style );
else if( pGC->dotwidth == GPC_NORM_WIDTH ) //added by zhuli 2002.2.3
{
seDrawHorzLine( pGC, (SHORT)xSrc, (SHORT)ySrc, (SHORT)(xDest - xSrc + 1), index, dotLine, style );
// seDrawVertLine( pGC, (SHORT)xDest, (SHORT)ySrc , (SHORT)(yDest - ySrc + 1), index, dotLine, style );//by zl 2002.4.3
seDrawVertLine( pGC, (SHORT)xDest, (SHORT)(ySrc + 1) , (SHORT)(yDest - ySrc - 1), index, dotLine, style );
seDrawHorzLine( pGC, (SHORT)xSrc, (SHORT)yDest, (SHORT)(xDest - xSrc + 1), index, dotLine, style );
// seDrawVertLine( pGC, (SHORT)xSrc, (SHORT)ySrc, (SHORT)(yDest - ySrc + 1), index, dotLine, style );//by zl 2002.4.3
seDrawVertLine( pGC, (SHORT)xSrc , (SHORT)(ySrc + 1), (SHORT)(yDest - ySrc - 1), index, dotLine, style );
}
else
{
seDrawHorzLine( pGC, (SHORT)(xSrc + pGC->dotwidth/2 + 1), (SHORT)ySrc, (SHORT)(xDest - xSrc - pGC->dotwidth ), index, dotLine, style );
seDrawVertLine( pGC, (SHORT)xDest, (SHORT)(ySrc - (pGC->dotwidth - 1)/2), (SHORT)(yDest - ySrc + pGC->dotwidth ), index, dotLine, style );
seDrawHorzLine( pGC, (SHORT)(xSrc + pGC->dotwidth/2 + 1), (SHORT)yDest, (SHORT)(xDest - xSrc - pGC->dotwidth ), index, dotLine, style );
seDrawVertLine( pGC, (SHORT)xSrc, (SHORT)(ySrc - (pGC->dotwidth - 1)/2), (SHORT)(yDest - ySrc + pGC->dotwidth ), index, dotLine, style );
}
if ( pGC == gSysTcbTbl[ gLcdOwnerTskId-1 ].gc && pGC->group_operation == 0 && pGC->group_operation == 0 )
{
if ( pGC->dotwidth == 1 )
WRITELCD(xSrc, ySrc, xDest, yDest)
//seWrite2LCD( pGC->vram, 0);
else
WRITELCD(xSrc - (pGC->dotwidth - 1)/2, ySrc - (pGC->dotwidth - 1)/2, xDest + pGC->dotwidth/2, yDest + pGC->dotwidth/2)
//seWrite2LCD( pGC->vram, 0);
}
return GPC_ERR_OK;
}
//---------------------------------------------------------------
// SysDrawCircle()
//
// Draw a circle centered at (xCenter,yCenter) with radius and style as specified.
//
// Parameters:
// gc - Address value of graphic context.
// rgb - Color of the line.
// xCenter - Position X of the center of circle.
// yPos - Position Y of the center of circle.
// radius - Radius of the circle.
// style - Output style.
//
// Returns:
// GPC_ERR_OK
//---------------------------------------------------------------
STATUS SysDrawCircle( DWORD gc, DWORD rgb, WORD xCenter, WORD yCenter, WORD radius, WORD style )
{
GC *pGC;
PIXEL index;
//WORD m;
// SHORT x, y, d;
pGC = (GC *)gc;
if ( pGC == NULL || pGC->symbol != GPC_GC_SYMBOL )
return GPC_ERR_FAILED;
if ( pGC->dotwidth != GPC_NORM_WIDTH ) //added by zhuli 2002.2.3
return GPC_ERR_FAILED;
if ( xCenter > (pGC->width -1) )
return GPC_ERR_FAILED;
if ( yCenter > (pGC->height -1) )
return GPC_ERR_FAILED;
// m = ( pGC->width ) < ( pGC->height ) ? ( pGC->width ) : ( pGC->height ); //if ( pGC->width < pGC->height ) m = pGC->width;
// // else m = pGC->height;
// if ( radius > m/2 || (xCenter + radius) > m || (yCenter + radius) > m )
// return GPC_ERR_FAILED;
// longn_qi 2001/12/20 above check method is wrong, replaced with following (2)
if ( xCenter < radius || (xCenter + radius) > (pGC->width - 1)|| yCenter < radius || (yCenter + radius) > (pGC->height - 1) )
//if ( xCenter < radius || (xCenter + radius) > pGC->width || yCenter < radius || (yCenter + radius) > pGC->height )
return GPC_ERR_FAILED;
// if ( radius > xCenter || radius > yCenter )
// return GPC_ERR_FAILED;
// if ( style < GPC_REPLACE_STYLE || style > GPC_NOT_STYLE )
// return GPC_ERR_FAILED;
seRGBtoIndex( rgb, &index ); //turn into colorindex
seDrawCircle( pGC, (SHORT) xCenter, (SHORT) yCenter, (SHORT) radius, index, style );
/*
x = (SHORT)xCenter;
y = (SHORT)(yCenter + radius);
d = (SHORT)(3 - 2 * radius);
do
{
seSetPixel( pGC, x, y, index, style );
seSetPixel( pGC, x, (SHORT)(yCenter - (y - yCenter)), index, style );
seSetPixel( pGC, (SHORT)(xCenter - (x - xCenter)), y, index, style );
seSetPixel( pGC, (SHORT)(xCenter - (x - xCenter)), (SHORT)(yCenter - (y - yCenter)), index, style );
seSetPixel( pGC, (SHORT)(xCenter + (y - yCenter)), (SHORT)(yCenter + (x - xCenter)), index, style );
seSetPixel( pGC, (SHORT)(xCenter + (y - yCenter)), (SHORT)(yCenter - (x - xCenter)), index, style );
seSetPixel( pGC, (SHORT)(xCenter - (y - yCenter)), (SHORT)(yCenter + (x - xCenter)), index, style );
seSetPixel( pGC, (SHORT)(xCenter - (y - yCenter)), (SHORT)(yCenter - (x - xCenter)), index, style );
if ( d < 0 )
{
d = d + ((x - (SHORT)xCenter) << 2) + 6;
}
else
{
d = d + (((x - (SHORT)xCenter) - (y - (SHORT)yCenter)) << 2 ) + 10;
y--;
}
x++;
}
while ( (x - (SHORT)xCenter) <= (y - (SHORT)yCenter) );
*/
// if ( pGC == gSysTcbTbl[ gLcdOwnerTskId-1 ].gc )
if ( pGC == gSysTcbTbl[ gLcdOwnerTskId-1 ].gc && pGC->group_operation == 0 )
WRITELCD(xCenter - radius, yCenter - radius, xCenter + radius, yCenter + radius)
//seWrite2LCD( pGC->vram, 0);
return GPC_ERR_OK;
}
//---------------------------------------------------------------
// SysDrawEllipse()
//
// Draw an ellipse centered at (xCenter,yCenter) with the sLength // as the width and yLength as the height.
//
// Parameters:
// gc - Address value of graphic context.
// rgb - Color of the line.
// xCenter - Position X of the center of ellipse.
// yPos - Position Y of the center of ellipse.
// xLength - The length of the ellipse in X-axis.
// yLength - The length of the ellipse in Y-axis.
// style - Output style.
//
// Returns:
// GPC_ERR_OK
//---------------------------------------------------------------
STATUS SysDrawEllipse( DWORD gc, DWORD rgb, WORD xCenter, WORD yCenter, WORD xLength, WORD yLength, WORD style )
{
GC *pGC;
PIXEL index;
pGC = (GC *)gc;
if ( pGC == NULL || pGC->symbol != GPC_GC_SYMBOL )
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -