diff options
author | runge <runge> | 2006-01-15 03:58:48 +0000 |
---|---|---|
committer | runge <runge> | 2006-01-15 03:58:48 +0000 |
commit | 5993dd757e5af00af6565b3411ea10fd46eafbdf (patch) | |
tree | 7450fdde25310857c88221a719f026a1a09336f7 /x11vnc/util.c | |
parent | 60918e6664cd62ea3d71b48cdfda8b89ab82029c (diff) | |
download | libtdevnc-5993dd757e5af00af6565b3411ea10fd46eafbdf.tar.gz libtdevnc-5993dd757e5af00af6565b3411ea10fd46eafbdf.zip |
x11vnc: add -8to24 option for some multi-depth displays.
Diffstat (limited to 'x11vnc/util.c')
-rw-r--r-- | x11vnc/util.c | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/x11vnc/util.c b/x11vnc/util.c index 4d5dfe2..0d73ace 100644 --- a/x11vnc/util.c +++ b/x11vnc/util.c @@ -14,6 +14,8 @@ MUTEX(scrollMutex); #endif int nfix(int i, int n); +int nmin(int n, int m); +int nmax(int n, int m); int nabs(int n); double dabs(double x); void lowercase(char *str); @@ -42,6 +44,9 @@ double rfac(void); void rfbPE(long usec); void rfbCFD(long usec); +double rect_overlap(int x1, int y1, int x2, int y2, int X1, int Y1, + int X2, int Y2); + /* * routine to keep 0 <= i < n, should use in more places... @@ -55,6 +60,22 @@ int nfix(int i, int n) { return i; } +int nmin(int n, int m) { + if (n < m) { + return n; + } else { + return m; + } +} + +int nmax(int n, int m) { + if (n > m) { + return n; + } else { + return m; + } +} + int nabs(int n) { if (n < 0) { return -n; @@ -394,4 +415,39 @@ void rfbCFD(long usec) { } } +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, overlap; + 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); + + overlap = sraRgnCreateRect(x1, y1, x2, y2); + + sraRgnAnd(overlap, R); + + o = 0.0; + iter = sraRgnGetIterator(overlap); + while (sraRgnIteratorNext(iter, &rt)) { + o += nabs( (rt.x2 - rt.x1) * (rt.y2 - rt.y1) ); + } + sraRgnReleaseIterator(iter); + + sraRgnDestroy(r); + sraRgnDestroy(R); + sraRgnDestroy(overlap); + + if (a < A) { + o = o/a; + } else { + o = o/A; + } + return o; +} |