📄 gpcdraw.c
字号:
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;
// check radius <= 0
if ( xLength > pGC->width/2 || (xCenter + xLength) > (pGC->width - 1) || xLength > xCenter )
//if ( xLength > pGC->width/2 || (xCenter + xLength) > pGC->width || xLength > xCenter )
return GPC_ERR_FAILED;
if ( yLength > pGC->height/2 || (yCenter + yLength) > (pGC->height - 1) || yLength > yCenter )
//if ( yLength > pGC->height/2 || (yCenter + yLength) > pGC->height || yLength > yCenter )
return GPC_ERR_FAILED;
// if ( style < GPC_REPLACE_STYLE || style > GPC_NOT_STYLE )
// return GPC_ERR_FAILED;
seRGBtoIndex( rgb, &index ); //turn into colorindex
// 如果xLength=yLength则画圆
if ( xLength == yLength )
seDrawCircle( pGC, (SHORT) xCenter, (SHORT) yCenter, (SHORT) xLength, index, style );
/*
if ( xLength == yLength )
{
SHORT x, y, d;
x = (SHORT)xCenter;
y = (SHORT)(yCenter + xLength);
d = (SHORT)(3 - 2 * xLength);
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) );
}
*/
else
seEllipse( pGC, (SHORT)xCenter, (SHORT)yCenter, (SHORT)xLength, (SHORT)yLength, index,style );
if ( pGC == gSysTcbTbl[ gLcdOwnerTskId-1 ].gc && pGC->group_operation == 0 )
WRITELCD(xCenter - xLength, yCenter - yLength, xCenter + xLength, yCenter + yLength)
//seWrite2LCD( pGC->vram, 0);
return GPC_ERR_OK;
}
//---------------------------------------------------------------
// SysDrawVector()
//
// Draw lines to connect points according to the sequence of the data points input.
//
// Parameters:
// gc - Address value of graphic context.
// rgb - Color of the line.
// numberOfPoints - Number of points in the list.
// pointPtr - Pointer to the list of points to be connerted.
// style - Output style.
// mode - Decide whether the first point and the last point is connected.
//
// Returns:
// GPC_ERR_OK
//---------------------------------------------------------------
STATUS SysDrawVector( DWORD gc, DWORD rgb, WORD numberOfPoints, PPOINTS pointPtr, WORD style, WORD mode )
{
GC *pGC;
PIXEL index;
WORD i;
PPOINTS Point; //此处为自定义的一个结构体P_POINT指针
pGC = (GC *)gc;
if ( pGC == NULL || pGC->symbol != GPC_GC_SYMBOL )
return GPC_ERR_FAILED;
// if ( style < GPC_REPLACE_STYLE || style > GPC_NOT_STYLE )
// return GPC_ERR_FAILED;
if ( pGC->dotwidth != 1 )
return GPC_ERR_FAILED;
seRGBtoIndex( rgb, &index ); //turn into colorindex
Point = pointPtr; //记下矢量图的头指针,即第一个点的值
for ( i = 1; i < numberOfPoints; i++ )
{
if ( pointPtr[i].x > (pGC->width - 1) || pointPtr[i+1].x > (pGC->width - 1) ) //if ( (pointPtr[i].x > pGC->width) || (pointPtr[i+1].x > pGC->width) ) by zhuli 2002.2.3
return GPC_ERR_FAILED;
if ( pointPtr[i].y > (pGC->height - 1) || pointPtr[i+1].y > (pGC->height - 1) ) //if ( (pointPtr[i].y > pGC->height) || (pointPtr[i+1].y > pGC->height))
return GPC_ERR_FAILED;
if ( pointPtr[i].x == pointPtr[i+1].x )
{
seDrawVertLine( pGC, (SHORT)pointPtr[i].x , (SHORT)pointPtr[i].y,\
(SHORT)(pointPtr[i+1].y - pointPtr[i].y), index, GPC_SOLID_LINE, style );
}
else if ( pointPtr[i].y == pointPtr[i+1].y )
{
seDrawHorzLine( pGC, (SHORT)pointPtr[i].x , (SHORT)pointPtr[i].y,\
(SHORT)(pointPtr[i+1].x - pointPtr[i].x), index, GPC_SOLID_LINE, style );
}
else
seDrawLine( pGC, (SHORT)pointPtr[i].x , (SHORT)pointPtr[i].y,\
(SHORT)pointPtr[i+1].x, (SHORT)pointPtr[i+1].y, index, GPC_SOLID_LINE, style);
}
if ( mode == TRUE )
{
if ( Point[1].x > (pGC->width - 1)|| pointPtr[i].x > (pGC->width - 1) ) //if ( (Point[1].x > pGC->width)|| (pointPtr[i].x > pGC->width) ) by zhuli 2002.2.3
return GPC_ERR_FAILED;
if ( Point[1].y > (pGC->height - 1) || pointPtr[i].y > (pGC->height - 1) ) //if ( (Point[1].y > pGC->height) || (pointPtr[i].y > pGC->height) ) by zhuli 2002.2.3
return GPC_ERR_FAILED;
if ( Point[1].x == pointPtr[i].x)
{
seDrawVertLine( pGC, (SHORT)Point[1].x , (SHORT)Point[1].y, (SHORT)(pointPtr[i].y - Point[1].y ), index, GPC_SOLID_LINE, style );
}
else if ( Point[1].y == pointPtr[i].y )
{
seDrawHorzLine( pGC, (SHORT)Point[1].x , (SHORT)pointPtr[i].y, (SHORT)(pointPtr[i].x - Point[1].x), index, GPC_SOLID_LINE, style );
}
else
seDrawLine( pGC, (SHORT)Point[1].x , (SHORT)Point[1].y, (SHORT)pointPtr[i].x, (SHORT)pointPtr[i].y, index, GPC_SOLID_LINE, style);
}
if ( pGC == gSysTcbTbl[ gLcdOwnerTskId-1 ].gc && pGC->group_operation == 0 )
WRITELCD(Point[1].x, Point[1].y, Point[numberOfPoints].x, Point[numberOfPoints].y)
//seWrite2LCD( pGC->vram, 0);
return GPC_ERR_OK;
}
//---------------------------------------------------------------
// SysPutRec()
//
// Put a rectangular bitmap image from memory to the specified location of graphic context.
//
// Parameters:
// gc - Address value of graphic context.
// bitmap - Pointer to the bitmap image to be displayed.
// xSrc - Top left position X of where the bitmap image will be mapped.
// ySrc - Top left position Y of where the bitmap image will be mapped.
// width - Width of the image.
// height - Height of the image.
// style - Output style.
// reserved - Reserved for future use.
//
// Returns:
// GPC_ERR_OK
//---------------------------------------------------------------
STATUS SysPutRec(DWORD gc, PIXEL *bitmap, WORD xSrc, WORD ySrc, WORD width, WORD height, WORD style, WORD trColor )
{
GC *pGC;
VRAM vram;
pGC = (GC *)gc;
if ( pGC == NULL || pGC->symbol != GPC_GC_SYMBOL )
return GPC_ERR_FAILED;
if ( bitmap == NULL )//we should check the point anytime, anywhere!!!
return GPC_ERR_FAILED;//By Lingming 2001/11/19
if ( xSrc > (pGC->width -1) )
return GPC_ERR_FAILED;
if ( ySrc > (pGC->height -1) )
return GPC_ERR_FAILED;
if ( (xSrc + width) > pGC->width )
return GPC_ERR_FAILED;
if ( (ySrc + height) > pGC->height )
return GPC_ERR_FAILED;
// if ( style < GPC_MIN_STYLE || style > GPC_MAX_STYLE )
// return GPC_ERR_FAILED;
vram.ad = bitmap;
vram.lcdx = 0;
vram.lcdy = 0;
vram.widthInPixel = width;
vram.widthInBit = width << LOG_PIXEL_BITS;
vram.widthInUnit = ( vram.widthInBit + PIXEL_UNIT -1 ) >> LOG_UNIT;
vram.height = height;
// longn_qi 2002/04/05 revised for transparent style.
if ( style == GPC_TRANSPARENT_STYLE )
seDrawImage( pGC, (SHORT)xSrc , (SHORT)ySrc, (SHORT)width, (SHORT)height, &vram, LOWORD(pGC->fillmode), trColor );
else
seSetImage( pGC, (SHORT)xSrc , (SHORT)ySrc, (SHORT)width, (SHORT)height, &vram, style );
if ( pGC == gSysTcbTbl[ gLcdOwnerTskId-1 ].gc && pGC->group_operation == 0 )
WRITELCD(xSrc, ySrc, xSrc + width - 1, ySrc + height - 1)
//seWrite2LCD( pGC->vram, 0);
return GPC_ERR_OK;
}
//---------------------------------------------------------------
// SysSaveRec()
//
// Save a rectangular bitmap image from the specified location on graphic context to memory.
//
// Parameters:
// gc - Address value of graphic context.
// bitmap - Pointer to the bitmap image to be displayed.
// xSrc - Top left position X of where the bitmap image will be mapped.
// ySrc - Top left position Y of where the bitmap image will be mapped.
// width - Width of the image.
// height - Height of the image.
// reserved - Reserved for future use.
//
// Returns:
// GPC_ERR_OK
//---------------------------------------------------------------
STATUS SysSaveRec( DWORD gc, PIXEL *bitmap, WORD xSrc, WORD ySrc, WORD width, WORD height, WORD reserved )
{
GC *pGC;
VRAM vram;
pGC = (GC *)gc;
if ( pGC == NULL || pGC->symbol != GPC_GC_SYMBOL )
return GPC_ERR_FAILED;
if ( bitmap == NULL )//we should check the point anytime, anywhere!!!
return GPC_ERR_FAILED;//By Lingming 2001/11/19
if ( xSrc > (pGC->width -1) )
return GPC_ERR_FAILED;
if ( ySrc > (pGC->height -1) )
return GPC_ERR_FAILED;
if ( (xSrc + width) > pGC->width )
return GPC_ERR_FAILED;
if ( (ySrc + height) > pGC->height )
return GPC_ERR_FAILED;
vram.ad = bitmap;
vram.lcdx = 0;
vram.lcdy = 0;
vram.widthInPixel = width;
vram.widthInBit = width << LOG_PIXEL_BITS;
vram.widthInUnit = ( vram.widthInBit + PIXEL_UNIT -1 ) >> LOG_UNIT;
vram.height = height;
seGetImage( pGC, (SHORT)xSrc, (SHORT)ySrc, (SHORT)width, (SHORT)height, &vram );
return GPC_ERR_OK;
}
//---------------------------------------------------------------
// SysClearRec()
//
// Save a rectangular bitmap image from the specified location on graphic context to memory.
//
// Parameters:
// gc - Address value of graphic context.
// rgb - Color of the line.
// xSrc - Top left position X of the rectangular area.
// ySrc - Top left position Y of the rectangular area.
// width - Width of the rectangular area.
// height - Height of the rectangular area.
// style - Output style.
//
// Returns:
// GPC_ERR_OK
//---------------------------------------------------------------
STATUS SysClearRec( DWORD gc, DWORD rgb, WORD xSrc, WORD ySrc, WORD width, WORD height, 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) )
return GPC_ERR_FAILED;
if ( (xSrc + width) > pGC->width )
return GPC_ERR_FAILED;
if ( (ySrc + height) > pGC->height )
return GPC_ERR_FAILED;
seRGBtoIndex( rgb, &index ); //turn into colorindex
// if ( style < GPC_REPLACE_STYLE || style > GPC_NOT_STYLE )
// return GPC_ERR_FAILED;
seClearRec( pGC, (SHORT)xSrc, (SHORT)ySrc, (SHORT)width, (SHORT)height, index, style );
if( pGC == gSysTcbTbl[ gLcdOwnerTskId-1 ].gc && pGC->group_operation == 0 )
WRITELCD( xSrc, ySrc, xSrc + width - 1, ySrc + height - 1 )
// seWrite2LCD( pGC->vram, 0);
return GPC_ERR_OK;
}
//---------------------------------------------------------------
// SysInvRec()
//
// Invert the color of the specified rectangular area.
//
// Parameters:
// gc - Address value of graphic context.
// xSrc - Top left position X of the rectangular area.
// ySrc - Top left position Y of the rectangular area.
// width - Width of the rectangular area.
// height - Height of the rectangular area.
//
// Returns:
// GPC_ERR_OK
//---------------------------------------------------------------
STATUS SysInvRec( DWORD gc, WORD xSrc, WORD ySrc, WORD width, WORD height )
{
GC *pGC;
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) )
return GPC_ERR_FAILED;
if ( (xSrc + width) > pGC->width )
return GPC_ERR_FAILED;
if ( (ySrc + height) > pGC->height )
return GPC_ERR_FAILED;
seInvRec( pGC, (SHORT)xSrc, (SHORT)ySrc, (SHORT)width, (SHORT)height );
if( pGC == gSysTcbTbl[ gLcdOwnerTskId-1 ].gc && pGC->group_operation == 0 )
WRITELCD( xSrc, ySrc, xSrc + width - 1, ySrc + height - 1 ) //WRITELCD( x, x1, y, y1)
// seWrite2LCD( pGC->vram, 0);
return GPC_ERR_OK;
}
STATUS SysDrawMonoImage( DWORD gc, PBYTE bitmap, WORD xSrc, WORD ySrc, WORD width, WORD height, DWORD frntColor, DWORD bkColor )
{
GC *pGC;
PHYIMAGEINFO pii;
PIXEL index;
pGC = (GC *)gc;
if ( pGC == NULL || pGC->symbol != GPC_GC_SYMBOL )
return GPC_ERR_FAILED;
if ( bitmap == NULL )
return GPC_ERR_FAILED;
if ( xSrc > (pGC->width - 1) ) //if ( xSrc > pGC->width ) by zhuli 2002.2.3
return GPC_ERR_FAILED;
if ( ySrc > (pGC->height - 1) ) //if ( ySrc > pGC->height ) by zhuli 2002.2.3
return GPC_ERR_FAILED;
if ( (xSrc + width) > pGC->width )
return GPC_ERR_FAILED;
if ( (ySrc + height) > pGC->height )
return GPC_ERR_FAILED;
pii.buffer = bitmap;
pii.x = xSrc;
pii.y = ySrc;
pii.width = width;
pii.height = height;
seRGBtoIndex( frntColor, &index );
pii.ColorIndex = index;
seRGBtoIndex( bkColor, &index );
pii.BkColorIndex = index;
pii.method = GPC_REPLACE_STYLE;
pii.mode = GPC_PAINT_STYLE;
seSetMonoImage( pGC, &pii );
if( pGC == gSysTcbTbl[ gLcdOwnerTskId-1 ].gc && pGC->group_operation == 0 )
WRITELCD( xSrc, ySrc, xSrc + width - 1, ySrc + height - 1 )//WRITELCD( topx, endx, topy, endy )
// seWrite2LCD( pGC->vram, 0);
return GPC_ERR_OK;
}
// longn_qi 2002/04/05 added for transparent style.
STATUS SysSetBkFillMode( DWORD gc, DWORD style )
{
GC *pGC = (GC *)gc;
if( pGC == NULL || pGC->symbol != GPC_GC_SYMBOL )
return GPC_ERR_FAILED;
pGC->fillmode = style;
return GPC_ERR_OK;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -