예제 #1
0
파일: rfbregion.c 프로젝트: AlexWMF/Carberp
/* pipe the output to sort|uniq -u and you'll get the errors. */
int main(int argc, char** argv)
{
    sraRegionPtr region, region1, region2;
    sraRectangleIterator* i;
    sraRect rect;
    rfbBool b;

    region = sraRgnCreateRect(10, 10, 600, 300);
    region1 = sraRgnCreateRect(40, 50, 350, 200);
    region2 = sraRgnCreateRect(0, 0, 20, 40);

    sraRgnPrint(region);
    printf("\n[(10-300)[(10-600)]]\n\n");

    b = sraRgnSubtract(region, region1);
    printf("%s ",b?"true":"false");
    sraRgnPrint(region);
    printf("\ntrue [(10-50)[(10-600)](50-200)[(10-40)(350-600)](200-300)[(10-600)]]\n\n");

    sraRgnOr(region, region2);
    printf("%ld\n6\n\n", sraRgnCountRects(region));

    i = sraRgnGetIterator(region);
    while(sraRgnIteratorNext(i, &rect))
        printf("%dx%d+%d+%d ",
               rect.x2-rect.x1,rect.y2-rect.y1,
               rect.x1,rect.y1);
    sraRgnReleaseIterator(i);
    printf("\n20x10+0+0 600x30+0+10 590x10+10+40 30x150+10+50 250x150+350+50 590x100+10+200 \n\n");

    i = sraRgnGetReverseIterator(region,1,0);
    while(sraRgnIteratorNext(i, &rect))
        printf("%dx%d+%d+%d ",
               rect.x2-rect.x1,rect.y2-rect.y1,
               rect.x1,rect.y1);
    sraRgnReleaseIterator(i);
    printf("\n20x10+0+0 600x30+0+10 590x10+10+40 250x150+350+50 30x150+10+50 590x100+10+200 \n\n");

    i = sraRgnGetReverseIterator(region,1,1);
    while(sraRgnIteratorNext(i, &rect))
        printf("%dx%d+%d+%d ",
               rect.x2-rect.x1,rect.y2-rect.y1,
               rect.x1,rect.y1);
    sraRgnReleaseIterator(i);
    printf("\n590x100+10+200 250x150+350+50 30x150+10+50 590x10+10+40 600x30+0+10 20x10+0+0 \n\n");

    sraRgnDestroy(region);
    sraRgnDestroy(region1);
    sraRgnDestroy(region2);

    return(0);
}
예제 #2
0
파일: main.c 프로젝트: 21hub/libvncserver
void rfbDoCopyRegion(rfbScreenInfoPtr screen,sraRegionPtr copyRegion,int dx,int dy)
{
   sraRectangleIterator* i;
   sraRect rect;
   int j,widthInBytes,bpp=screen->serverFormat.bitsPerPixel/8,
    rowstride=screen->paddedWidthInBytes;
   char *in,*out;

   /* copy it, really */
   i = sraRgnGetReverseIterator(copyRegion,dx<0,dy<0);
   while(sraRgnIteratorNext(i,&rect)) {
     widthInBytes = (rect.x2-rect.x1)*bpp;
     out = screen->frameBuffer+rect.x1*bpp+rect.y1*rowstride;
     in = screen->frameBuffer+(rect.x1-dx)*bpp+(rect.y1-dy)*rowstride;
     if(dy<0)
       for(j=rect.y1;j<rect.y2;j++,out+=rowstride,in+=rowstride)
	 memmove(out,in,widthInBytes);
     else {
       out += rowstride*(rect.y2-rect.y1-1);
       in += rowstride*(rect.y2-rect.y1-1);
       for(j=rect.y2-1;j>=rect.y1;j--,out-=rowstride,in-=rowstride)
	 memmove(out,in,widthInBytes);
     }
   }
   sraRgnReleaseIterator(i);
  
   rfbScheduleCopyRegion(screen,copyRegion,dx,dy);
}
예제 #3
0
double rect_overlap(int x1, int y1, int x2, int y2, int X1, int Y1,
    int X2, int Y2) {
	double a, A, o;
	sraRegionPtr r, R;
	sraRectangleIterator *iter;
	sraRect rt;

	a = nabs((x2 - x1) * (y2 - y1));
	A = nabs((X2 - X1) * (Y2 - Y1));

	r = sraRgnCreateRect(x1, y1, x2, y2);
	R = sraRgnCreateRect(X1, Y1, X2, Y2);

	sraRgnAnd(r, R);
	
	o = 0.0;
	iter = sraRgnGetIterator(r);
	while (sraRgnIteratorNext(iter, &rt)) {
		o += nabs( (rt.x2 - rt.x1) * (rt.y2 - rt.y1) );
	}
	sraRgnReleaseIterator(iter);

	sraRgnDestroy(r);
	sraRgnDestroy(R);

	if (a < A) {
		o = o/a;
	} else {
		o = o/A;
	}
	return o;
}