From 6fb77fb0c15fdc8185a160704db4c87891ace742 Mon Sep 17 00:00:00 2001 From: dscho Date: Tue, 24 May 2005 08:56:35 +0000 Subject: fix off by one bug --- examples/example.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'examples') diff --git a/examples/example.c b/examples/example.c index 15bedec..536497f 100644 --- a/examples/example.c +++ b/examples/example.c @@ -107,7 +107,6 @@ static void drawline(unsigned char* buffer,int rowstride,int bpp,int x1,int y1,i if(j<0) j=-j; if(iy2) { i=y2; y2=y1; y1=i; i=x2; x2=x1; x1=i; } - if(y2==y1) { if(y2>0) y1--; else y2++; } for(j=y1;j<=y2;j++) for(i=0;ioldButton==buttonMask) { /* draw a line */ drawline((unsigned char*)cl->screen->frameBuffer,cl->screen->paddedWidthInBytes,bpp, x,y,cd->oldx,cd->oldy); + x1=x; y1=y; + if(x1>cd->oldx) x1++; else cd->oldx++; + if(y1>cd->oldy) y1++; else cd->oldy++; rfbMarkRectAsModified(cl->screen,x,y,cd->oldx,cd->oldy); } else { /* draw a point (diameter depends on button) */ int w=cl->screen->paddedWidthInBytes; @@ -143,7 +145,7 @@ static void doptr(int buttonMask,int x,int y,rfbClientPtr cl) for(i=x1*bpp;iscreen->frameBuffer[j*w+i]=(char)0xff; - rfbMarkRectAsModified(cl->screen,x1,y1,x2-1,y2-1); + rfbMarkRectAsModified(cl->screen,x1,y1,x2,y2); } /* we could get a selection like that: -- cgit v1.2.1