📄 drv_lcd.c
字号:
}
}
//return GPC_ERR_OK;
}
//-------------------------------------------------------------------------
// seInvertLine()
//
// Invert a line
//
// Parameters:
// x1,y1:specified the coordinate of the lines start point in pixel
// x2,y2:specified the coordinate of the lines end point in pixel
// mask:line style mask
//
// Returns:
// GPC_ERR_OK
//-------------------------------------------------------------------------
void seInvertLine( S16 x1, S16 y1, S16 x2, S16 y2, U16 mask )
{
S16 dx,dy,incrE,incrNE,d,x,y;
S16 x0, y0;
unsigned short invertcolor;
if (x2==x1)
{//*write stright line///
if (y1<y2)
{
for (y=y1;y<=y2;y++)
if( ( mask&0x8000 ) == 0x8000 )
{
seReadPixel(x1,y, &invertcolor);
seDrawPixel(x1,y,invertcolor^0x1);
mask=( mask<<1 )|0x0001 ;
}
else
mask=mask<<1;
}
else
{
for (y=y2;y<=y1;y++)
if( ( mask&0x8000 ) == 0x8000 )
{
seReadPixel(x1,y, &invertcolor);
seDrawPixel(x1,y,invertcolor^0x1);
mask=( mask<<1 )|0x0001 ;
}
else
mask=mask<<1;
}
}
else if (y2==y1)
{//*write horizental line///
if (x1<x2)
{
for (x=x1;x<=x2;x++)
if( ( mask&0x8000 ) == 0x8000 )
{
seReadPixel(x1,y, &invertcolor);
seDrawPixel(x1,y,invertcolor^0x1);
mask=( mask<<1 )|0x0001 ;
}
else
mask=mask<<1;
}
else
{
for (x=x2;x<=x1;x++)
if( ( mask&0x8000 ) == 0x8000 )
{
seReadPixel(x1,y, &invertcolor);
seDrawPixel(x1,y,invertcolor^0x1);
mask=( mask<<1 )|0x0001 ;
}
else
mask=mask<<1;
}
}
else
{// * start point definition///
if (x1<x2)
{ x0=x1;
y0=y1;
x1=x2;
y1=y2;
}
else
{ x0=x2;
y0=y2;
}
dx=x1-x0;
if (y0<y1)
{
dy=y1-y0;
if (dy<dx)
{ d=-(2*dy-dx); /*初始化判别式d//
incrE=-2*dy; /*取像素E时判别式的增量//
incrNE=-2*(dy-dx); /*取像素NE时判别式的增量//
x=x0,y=y0;
while (x<=x1)
{
if( ( mask&0x8000 ) == 0x8000 )
{
seReadPixel(x1,y, &invertcolor);
seDrawPixel(x1,y,invertcolor^0x1);
mask=( mask<<1 )|0x0001 ;
}
else
mask=mask<<1;
if (d>=0) /*取像素E//
{
d+=incrE;
x++;
}
else /*取像素NE//
{
d+=incrNE;
x++;
y++;
}
}
}
else
{ d=-(2*dx-dy); /*初始化判别式d//
incrE=-2*dx; /*取像素E时判别式的增量//
incrNE=-2*(dx-dy); /*取像素NE时判别式的增量//
x=x0,y=y0;
while (y<=y1)
{
if( ( mask&0x8000 ) == 0x8000 )
{
seReadPixel(x1,y, &invertcolor);
seDrawPixel(x1,y,invertcolor^0x1);
mask=( mask<<1 )|0x0001 ;
}
else
mask=mask<<1;
if (d>=0) /*取像素E//
{ d+=incrE;
y++;
}
else /*取像素NE//
{ d+=incrNE;
y++;
x++;
}
}
}
}
else
{ dy=y0-y1;
if (dy<dx)
{ d=-(2*dy-dx); /*初始化判别式d//
incrE=-2*dy; /*取像素E时判别式的增量//
incrNE=-2*(dy-dx); /*取像素NE时判别式的增量//
x=x0,y=y0;
while (x<=x1)
{
if( ( mask&0x8000 ) == 0x8000 )
{
seReadPixel(x,y, &invertcolor);
seDrawPixel(x,y,invertcolor^0x1);
mask=( mask<<1 )|0x0001 ;
}
else
mask=mask<<1;
if (d>=0) /*取像素E//
{ d+=incrE;
x++;
}
else /*取像素NE//
{ d+=incrNE;
x++;
y--;
}
}
}
else
{ d=-(2*dx-dy); /*初始化判别式d//
incrE=-2*dx; /*取像素E时判别式的增量//
incrNE=-2*(dx-dy); /*取像素NE时判别式的增量//
x=x0,y=y0;
while (y>=y1)
{
if( ( mask&0x8000 ) == 0x8000 )
{
seReadPixel(x1,y, &invertcolor);
seDrawPixel(x1,y,invertcolor^0x1);
mask=( mask<<1 )|0x0001 ;
}
else
mask=mask<<1;
if (d>=0) /*取像素E//
{ d+=incrE;
y--;
}
else /*取像素NE//
{ d+=incrNE;
y--;
x++;
}
}
}
}
}
//return GPC_ERR_OK;
}
//-------------------------------------------------------------------------
// seSetImage()
//
// This function 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:
// 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
// method: raster operation method
// Returns:
// GPC_ERR_OK
//-------------------------------------------------------------------------
void seSetImage( S16 x, S16 y, S16 width, S16 height , U16 *buffer, U8 method )
{
S16 x1,y1,x2,y2,i,j;
S16 tempY,tempX;
U8* usPtr;
//U16* usPtr;
U16 usData,usShift,usLeft,usGetData;
x1 = x;
y1 = y;
x2 = x1 + width;
y2 = y1 + height;
usShift=0x01;
usPtr=(unsigned char*)buffer;
usPtr=buffer;
switch(method)
{
case NOT_PUT:
//vDisableInterrupt();
for (tempY=y1;tempY<y2;tempY++){
for (tempX=x1;tempX<x2;tempX++){
usData=*usPtr++;
if ( usData & usShift)
seDrawPixel(tempX,tempY,0);
else
seDrawPixel(tempX,tempY,1);
}
}
//vEnableInterrupt();
break;
case XOR_PUT:
//vDisableInterrupt();
for (tempY=y1;tempY<y2;tempY++){
for (tempX=x1;tempX<x2;tempX++){
seReadPixel(tempX,tempY,&usGetData);
usData=(*usPtr++)&usShift;
seDrawPixel(tempX,tempY,usGetData ^ usData);
}
}
//vEnableInterrupt(); break;
break;
case OR_PUT:
//vDisableInterrupt();
for (tempY=y1;tempY<y2;tempY++){
for (tempX=x1;tempX<x2;tempX++){
seReadPixel(tempX,tempY,&usGetData);
usData=(*usPtr++)&usShift;
seDrawPixel(tempX,tempY,usGetData|usData);
}
}
//vEnableInterrupt(); break;
break;
case AND_PUT:
//vDisableInterrupt();
for (tempY=y1;tempY<y2;tempY++){
for (tempX=x1;tempX<x2;tempX++){
seReadPixel(tempX,tempY,&usGetData);
usData=(*usPtr++)&usShift;
seDrawPixel(tempX,tempY,usGetData & usData);
}
}
//vEnableInterrupt(); break;
default:// COPY_PUT
//vDisableInterrupt();
for (tempY=y1;tempY<y2;tempY++){
for (tempX=x1;tempX<x2;tempX++){
if (*usPtr++ & usShift)
seDrawPixel(tempX,tempY,1);
else
seDrawPixel(tempX,tempY,0);
}
}
//vEnableInterrupt();
}
//return GPC_ERR_OK;
}
//-------------------------------------------------------------------------
// seGetImage()
//
// This function retrieves a block of screen data as an image into a buffer.
// the image buffer format is device relative.
//
// Parameters:
// 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
// Returns:
// GPC_ERR_OK
//-------------------------------------------------------------------------
void seGetImage( S16 x, S16 y, S16 width, S16 height, U16 *buffer )
{
S16 x1,y1,x2,y2,i,j;
S16 tempY,tempX;
U8* usPtr;
//U16* usPtr;
U16 usData;
x1 = x;
y1 = y;
x2 = x1 + width;
y2 = y1 + height;
usPtr=(unsigned char*)buffer;
usPtr=buffer;
//vDisableInterrupt();
for (tempY=y1;tempY<y2;tempY++){
for (tempX=x1;tempX<x2;tempX++){
seReadPixel(tempX,tempY,&usData);
if (usData & 0x1)
*usPtr++=1;
else
*usPtr++=0;
}
}
//vEnableInterrupt();
}
//-------------------------------------------------------------------------
// seFillRect()
//
// This function clear ractangle
//
//
// Parameters:
// width - pointer to an integer to receive the width of the display
// height - pointer to an integer to receive the height of the display.
// Returns:
// GPC_ERR_OK
//-------------------------------------------------------------------------
void seFillRect(S16 x1, S16 y1, S16 x2, S16 y2,U16 ColorIndex){
S16 sCnt;
for (sCnt=x1;sCnt<=x2;sCnt++)
seDrawVLine(sCnt,y1,sCnt,y2,ColorIndex);
}*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -