diff options
author | dscho <dscho> | 2001-10-18 23:37:30 +0000 |
---|---|---|
committer | dscho <dscho> | 2001-10-18 23:37:30 +0000 |
commit | d44e3af64b3e224cdc2cba2549a9e84caefc2137 (patch) | |
tree | 292623a96fadac19145f5c85832bb5b03f5cf80e /draw.c | |
parent | 8e9f427a779eda4fe89d39b254a6ed475155dd00 (diff) | |
download | libtdevnc-d44e3af64b3e224cdc2cba2549a9e84caefc2137.tar.gz libtdevnc-d44e3af64b3e224cdc2cba2549a9e84caefc2137.zip |
add rfbDrawLine, rfbDrawPixel and vncev, an xev "lookalike"
Diffstat (limited to 'draw.c')
-rw-r--r-- | draw.c | 47 |
1 files changed, 46 insertions, 1 deletions
@@ -6,7 +6,7 @@ void rfbFillRect(rfbScreenInfoPtr s,int x1,int y1,int x2,int y2,Pixel col) int i,j; char* colour=(char*)&col; - if(!rfbEndianTest) + if(!rfbEndianTest) colour += 4-bpp; for(j=y1;j<y2;j++) for(i=x1;i<x2;i++) @@ -14,3 +14,48 @@ void rfbFillRect(rfbScreenInfoPtr s,int x1,int y1,int x2,int y2,Pixel col) rfbMarkRectAsModified(s,x1,y1,x2,y2); } +#define SETPIXEL(x,y) \ + memcpy(s->frameBuffer+(y)*rowstride+(x)*bpp,colour,bpp) + +void rfbDrawPixel(rfbScreenInfoPtr s,int x,int y,Pixel col) +{ + int rowstride = s->paddedWidthInBytes, bpp = s->bitsPerPixel>>3; + char* colour=(char*)&col; + + if(!rfbEndianTest) + colour += 4-bpp; + SETPIXEL(x,y); + rfbMarkRectAsModified(s,x,y,x+1,y+1); +} + +void rfbDrawLine(rfbScreenInfoPtr s,int x1,int y1,int x2,int y2,Pixel col) +{ + int rowstride = s->paddedWidthInBytes, bpp = s->bitsPerPixel>>3; + int i; + char* colour=(char*)&col; + + if(!rfbEndianTest) + colour += 4-bpp; + +#define SWAPPOINTS { i=x1; x1=x2; x2=i; i=y1; y1=y2; y2=i; } + if(abs(x1-x2)<abs(y1-y2)) { + if(y1>y2) + SWAPPOINTS + for(i=y1;i<=y2;i++) + SETPIXEL(x1+(i-y1)*(x2-x1)/(y2-y1),i); + /* TODO: Maybe make this more intelligently? */ + if(x2<x1) { i=x1; x1=x2; x2=i; } + rfbMarkRectAsModified(s,x1,y1,x2+1,y2+1); + } else { + if(x1>x2) + SWAPPOINTS + else if(x1==x2) { + rfbDrawPixel(s,x1,y1,col); + return; + } + for(i=x1;i<=x2;i++) + SETPIXEL(i,y1+(i-x1)*(y2-y1)/(x2-x1)); + if(y2<y1) { i=y1; y1=y2; y2=i; } + rfbMarkRectAsModified(s,x1,y1,x2+1,y2+1); + } +} |