📄 gpcdrv.c
字号:
mode = ppii->mode;
buffer = ppii->buffer;
style = ppii->method;
nByte = (ppii->width*ppii->height)>>3;
rByte = (ppii->width*ppii->height)&0x7;
m = 0;
nextLineAd = lineAd;
nextLineOffset = bitOffset;
nextPixelPos = nextLineAd;
nextPixelOffset = nextLineOffset;
for( k = 0; k < nByte; k++ )
{
for( j = 0; j < 8; j++ )
{
if( buffer[k] & mask[j] )
{
PixelOp( nextPixelPos, nextPixelOffset, ColorIndex, style );
}
else
{
if( mode != GPC_TRANSPARENT_STYLE )
PixelOp( nextPixelPos, nextPixelOffset, BkColorIndex, style );
}
GetNextPixelPosition( &nextPixelPos, &nextPixelOffset, nextPixelPos, nextPixelOffset );
m++;
if( m == ppii->width )
{
m = 0;
GetNextLine( &nextLineAd, &nextLineOffset, nextLineAd, nextLineOffset, gc->vram );
nextPixelPos = nextLineAd;
nextPixelOffset = nextLineOffset;
}
}
}
for( j = 0; j < rByte; j++ )
{
if( buffer[k] & mask[j] )
{
// ColorIndex1 = *(IniAdd + m); zhuli 2002.1.31
PixelOp( nextPixelPos, nextPixelOffset, ColorIndex, style );
}
else
{
if( mode != GPC_TRANSPARENT_STYLE )
// *(IniAdd + m) = BkColorIndex;
PixelOp( nextPixelPos, nextPixelOffset, BkColorIndex, style );
}
GetNextPixelPosition( &nextPixelPos, &nextPixelOffset, nextPixelPos, nextPixelOffset );
m++;
if( m == ppii->width )
{
m = 0;
// IniAdd += gc->width;
GetNextLine( &nextLineAd, &nextLineOffset, nextLineAd, nextLineOffset, gc->vram );
nextPixelPos = nextLineAd;
nextPixelOffset = nextLineOffset;
}
}
//zhuli 2002.1.31
// topx = ppii->x;
// topy = ppii->y;
// endx = topx + ppii->width - 1;
// endy = topy + ppii->height - 1;
// if( gc == gSysTcbTbl[ gLcdOwnerTskId-1 ].gc )
// WRITELCD( ppii->x, ppii->x + ppii->width - 1, ppii->y, ppii->y + ppii->height - 1 )//WRITELCD( topx, endx, topy, endy )
return;
}
/*
typedef struct tagPHYIMAGEINFO
{
SHORT x;
SHORT y;
SHORT width;
SHORT height;
BYTE *buffer;
BYTE method;
WORD ColorIndex;
WORD BkColorIndex;
} PHYIMAGEINFO, *PPHYIMAGEINFO;
*/
//-------------------------------------------------------------------------
// Function name :seSetImage()
//
// Description :to put a device depent image onto the screen. The image buffer format is device relative.
// The raster operation method defines how the color data for the source recangle is
// to be combined with the color data for the destination rectangle to achieve the final color
//
// Parameters:
// gc: the point that points the current task's gc
// x,y: specified the left-up position where the image will be placed
// width: specified the image width
// height: specified the image height
// buffer: the buffer contains the image data
// style : the style to be use to paint the pixel. consisted of:GPC_REPLACE_STYLE,
// GPC_AND_STYLE,GPC_OR_STYLE,GPC_XOR_STYLE,GPC_COPY_STYLE,GPC_NOT_STYLE
//
// No return value
//-------------------------------------------------------------------------
void seSetImage(GC *gc, SHORT x, SHORT y, SHORT width, SHORT height , VRAM *buffer, WORD style )
{
PIXEL *lineAd;
CHAR bitOffset;
// TurnOffLCD(); //Julias 2002/5/7
GetPixelPosition( &lineAd, &bitOffset, gc->vram, x, y );
BlockOp( lineAd, bitOffset, buffer->ad, 0, width, height, style, gc->vram, buffer );
}
//-------------------------------------------------------------------------
// Function name :seGetImage()
//
// Description :retrieves a block of screen data as an image into a buffer.
// the image buffer format is device relative.
//
// Parameters:
// gc: the point that points the current task's gc
// x,y: specified the left-up position where the image will be placed
// width: specified the image width
// height: specified the image height
// buffer: the buffer contains the image data
//
// No return value
//-------------------------------------------------------------------------
void seGetImage(GC *gc, SHORT x, SHORT y, SHORT width , SHORT height , VRAM *buffer)
{
PIXEL *lineAd;
CHAR bitOffset;
/*
x1 = x < (x + width) ? x : (x + width);
x2 = x < (x + width) ? (x + width): x;
y1 = y < (y + height) ? y : (y + height);
y2 = y < (y + height) ? (y + height) : y;
*/
// TurnOffLCD(); //Julias 2002/5/7
GetPixelPosition( &lineAd, &bitOffset, gc->vram, x, y );
BlockOp( buffer->ad, 0, lineAd, bitOffset, width, height, GPC_COPY_STYLE, buffer, gc->vram );
}
//-------------------------------------------------------------------------
// Function name :seEllipse()
//
// Description :Draw ellipse's Line in the x0, y0, a0, b0.
//
// Parameters:
// gc: the point that points the current task's gc
// x: Position x0 of Ellipse.
// y: Position y0 of Ellipse.
// a: Position width of Ellipse.
// b: Position height of Ellipse.
// ColorIndex : the color to be use to paint the pixel
// style : the style to be use to paint the pixel. consisted of:GPC_REPLACE_STYLE,
// GPC_AND_STYLE,GPC_OR_STYLE,GPC_XOR_STYLE,GPC_COPY_STYLE,GPC_NOT_STYLE
//
// No return value
//-------------------------------------------------------------------------
void seEllipse (GC *gc, SHORT x, SHORT y, SHORT a, SHORT b, PIXEL ColorIndex, WORD style)
{
// SHORT topx, topy;
SHORT x0 = 0;
SHORT y0 = b;
SHORT a0 = a;
SHORT b0 = b;
SHORT asqr = a0 * a0;
LONG two_asqr = asqr<<1;
SHORT bsqr = b0 * b0;
SHORT two_bsqr = bsqr<<1;
LONG d, dx, dy;
PIXEL *pixelPos;
CHAR bitOffset;
// WORD ColorIndex1; //暂存ColorIndex
d = bsqr - asqr * b0 + (asqr >> 2);
dx = 0;
dy = (LONG)two_asqr * b0;
// SETPIXEL((SHORT)x, (SHORT)(y + b)) //seSetPixel(x, (SHORT)(y + b));seSetPixel( gc, x, y+b, ColorIndex, style)
// SETPIXEL((SHORT)x, (SHORT)(y - b)) //seSetPixel(x, (SHORT)(y - b));
// SETPIXEL((SHORT)(x + a),(SHORT) y) //seSetPixel((SHORT)(x+a), y);
// SETPIXEL((SHORT)(x - a),(SHORT) y) //seSetPixel((SHORT)(x-a), y);
GetPixelPosition( &pixelPos, &bitOffset, gc->vram, x, (SHORT)(y+b) );
PixelOp( pixelPos, bitOffset, ColorIndex, style );
GetPixelPosition( &pixelPos, &bitOffset, gc->vram, x, (SHORT)(y-b) );
PixelOp( pixelPos, bitOffset, ColorIndex, style );
GetPixelPosition( &pixelPos, &bitOffset, gc->vram, (SHORT)(x+a), y );
PixelOp( pixelPos, bitOffset, ColorIndex, style );
GetPixelPosition( &pixelPos, &bitOffset, gc->vram, (SHORT)(x-a), y );
PixelOp( pixelPos, bitOffset, ColorIndex, style );
do
{
// SETPIXEL((SHORT)(x + x0), (SHORT)(y + y0)) //seSetPixel((SHORT)(x+x0),(SHORT)(y+y0));
// SETPIXEL((SHORT)(x - x0), (SHORT)(y + y0)) //seSetPixel((SHORT)(x-x0),(SHORT)(y+y0));
// SETPIXEL((SHORT)(x + x0), (SHORT)(y - y0)) //seSetPixel((SHORT)(x+x0),(SHORT)(y-y0));
// SETPIXEL((SHORT)(x - x0), (SHORT)(y - y0)) //seSetPixel((SHORT)(x-x0),(SHORT)(y-y0));
GetPixelPosition( &pixelPos, &bitOffset, gc->vram, (SHORT)(x+x0), (SHORT)(y+y0) );
PixelOp( pixelPos, bitOffset, ColorIndex, style );
GetPixelPosition( &pixelPos, &bitOffset, gc->vram, (SHORT)(x-x0), (SHORT)(y+y0) );
PixelOp( pixelPos, bitOffset, ColorIndex, style );
GetPixelPosition( &pixelPos, &bitOffset, gc->vram, (SHORT)(x+x0), (SHORT)(y-y0) );
PixelOp( pixelPos, bitOffset, ColorIndex, style );
GetPixelPosition( &pixelPos, &bitOffset, gc->vram, (SHORT)(x-x0), (SHORT)(y-y0) );
PixelOp( pixelPos, bitOffset, ColorIndex, style );
if ( d > 0 )
{
y0--;
dy -= two_asqr;
d -= dy;
}
x0++;
dx += two_bsqr;
d += (bsqr+dx);
} while ( dx < dy );
d += (3*(asqr-bsqr)/2 - (dx+dy))/2;
do
{
// SETPIXEL((SHORT)(x + x0), (SHORT)(y + y0)) //seSetPixel((SHORT)(x+x0), (SHORT)(y+y0));
// SETPIXEL((SHORT)(x - x0), (SHORT)(y + y0)) //seSetPixel((SHORT)(x-x0), (SHORT)(y+y0));
// SETPIXEL((SHORT)(x + x0), (SHORT)(y - y0)) //seSetPixel((SHORT)(x+x0), (SHORT)(y-y0));
// SETPIXEL((SHORT)(x - x0), (SHORT)(y - y0)) //seSetPixel((SHORT)(x-x0), (SHORT)(y-y0));
GetPixelPosition( &pixelPos, &bitOffset, gc->vram, (SHORT)(x+x0), (SHORT)(y+y0) );
PixelOp( pixelPos, bitOffset, ColorIndex, style );
GetPixelPosition( &pixelPos, &bitOffset, gc->vram, (SHORT)(x-x0), (SHORT)(y+y0) );
PixelOp( pixelPos, bitOffset, ColorIndex, style );
GetPixelPosition( &pixelPos, &bitOffset, gc->vram, (SHORT)(x+x0), (SHORT)(y-y0) );
PixelOp( pixelPos, bitOffset, ColorIndex, style );
GetPixelPosition( &pixelPos, &bitOffset, gc->vram, (SHORT)(x-x0), (SHORT)(y-y0) );
PixelOp( pixelPos, bitOffset, ColorIndex, style );
if ( d < 0 )
{
x0++;
dx += two_bsqr;
d += dx;
}
y0--;
dy -= two_asqr;
d += (asqr-dy);
} while (y0>=0);
// topx = x - a;
// topy = y - b;
// if( gc == gSysTcbTbl[ gLcdOwnerTskId-1 ].gc )
// WRITELCD( x - a, x + a, y - b, y+ b ) //应在前面已经定义好了px1,px2,py1,py2
}
//-------------------------------------------------------------------------
// Function name :seRGBtoIndex()
//
// Description : maps the color value in RGB to a closest color index
//
// Parameters:
// rgb: a color value in RGB format to be converted
// index: retrieves the index value corresponding to the rgb value
//
// No return value
//-------------------------------------------------------------------------
void seRGBtoIndex( DWORD rgb , PIXEL *index)
{
//tempR = (unsigned short)( rgb >> 12 ) & 0xf00;
//tempG = (unsigned short)( rgb >> 8 ) & 0x0f0;
//tempB = (unsigned short)( rgb >> 4 ) & 0xf;
//*index = tempR | tempG | tempB;
#if ( BITS_PER_PIXEL >= 8 )
// PIXEL tempR, tempG, tempB;
// tempR = (PIXEL)( rgb >> 8 ) & 0xf000; //Red color
// tempG = (PIXEL)( rgb >> 4 ) & 0x0f00; //Green color
// tempB = (PIXEL) rgb & 0xf0; //Blue color
// *index = tempR | tempG | tempB;
BYTE redIndex, greenIndex, blueIndex;
LinearColorMap( &redIndex, (BYTE)(( rgb >> 16 ) & 0xff), (BYTE)INDEX_RED_MASK, 0xff );
LinearColorMap( &greenIndex, (BYTE)(( rgb >> 8 ) & 0xff), (BYTE)INDEX_GREEN_MASK, 0xff );
LinearColorMap( &blueIndex, (BYTE)(rgb & 0xff), (BYTE)INDEX_BLUE_MASK, 0xff );
*index = (((PIXEL)redIndex) << INDEX_RED_OFFSET) | (((PIXEL)greenIndex) << INDEX_GREEN_OFFSET) | (((PIXEL)blueIndex) << INDEX_BLUE_OFFSET) ;
#else
DWORD gray;
// gray = (BYTE)( 0.3 * ( ( rgb >> 16 ) & 0xff ) + 0.59 * ( ( rgb >> 8 ) & 0xff ) + 0.11 * ( rgb & 0xff ) );
gray = ( 3 * ( ( rgb >> 16 ) & 0xff ) + 6 * ( ( rgb >> 8 ) & 0xff ) + ( rgb & 0xff ) );
{
WORD i;
for( i = 0; i <= PixelMask; i++ )
{
if( gray <= GRAMPalette[i].threshold )
break;
}
*index = (PIXEL)( GRAMPalette[i].rgb );
}
#endif
return;
}
//-------------------------------------------------------------------------
// Function name :seClearRec()
//
// Description : Fill a specified rectangular with specified color
//
// Parameters:
// gc: the point that points the current task's gc
// x: Top left x-coordinate of the rectangular image area
// y: Top left y-coordinate of the rectangular image area
// width: Width of the image in pixels
// heigth: Height of the image in pixels
// ColorIndex: specified color value
//
// No return value
//-------------------------------------------------------------------------
void seClearRec(GC *gc, SHORT x, SHORT y, SHORT width, SHORT height, PIXEL ColorIndex, WORD style)
{
PIXEL *lineAd;
CHAR bitOffset;
// TurnOffLCD(); //Julias 2002/5/7
GetPixelPosition( &lineAd, &bitOffset, gc->vram, x, y );
BlockUnicolorOp( lineAd, bitOffset, width, height, ColorIndex, style, gc->vram );
}
//-------------------------------------------------------------------------
// Function name :seInvRec()
//
// Description : Invert a specified rectangular
//
// Parameters:
// gc: the point that points the current task's gc
// x: Top left x-coordinate of the rectangular image area
// y: Top left y-coordinate of the rectangular image area
// width: Width of the image in pixels
// heigth: Height of the image in pixels
//
//
// No return value
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -