diff options
author | dscho <dscho> | 2006-04-27 01:01:41 +0000 |
---|---|---|
committer | dscho <dscho> | 2006-04-27 01:01:41 +0000 |
commit | 21b1fd476fb9a3e3bc52097af6ea21fda0e09a46 (patch) | |
tree | 06d57c0a60e2a22655e3ee371154b9201469d394 /examples/rotate.c | |
parent | 6370f25f136d837b66f56080e34e7773e6e020c9 (diff) | |
download | libtdevnc-21b1fd476fb9a3e3bc52097af6ea21fda0e09a46.tar.gz libtdevnc-21b1fd476fb9a3e3bc52097af6ea21fda0e09a46.zip |
add rotate and flip example
Diffstat (limited to 'examples/rotate.c')
-rw-r--r-- | examples/rotate.c | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/examples/rotate.c b/examples/rotate.c new file mode 100644 index 0000000..66fca80 --- /dev/null +++ b/examples/rotate.c @@ -0,0 +1,92 @@ +#include <stdio.h> +#include <rfb/rfb.h> +#include <rfb/keysym.h> + +static int gcd(int x, int y) +{ + if (x == 0) + return y; + return gcd((y % x), x); +} + +#define CONCAT2(a,b) a##b +#define CONCAT2E(a,b) CONCAT2(a,b) +#define CONCAT3(a,b,c) a##b##c +#define CONCAT3E(a,b,c) CONCAT3(a,b,c) + +#define FUNCNAME rfbRotate +#define FUNC(i, j) (h - 1 - j + i * h) +#define SWAPDIMENSIONS +#define OUT 8 +#include "rotatetemplate.c" +#define OUT 16 +#include "rotatetemplate.c" +#define OUT 32 +#include "rotatetemplate.c" +#undef FUNCNAME +#undef FUNC + +#define FUNCNAME rfbRotateCounterClockwise +#define FUNC(i, j) (j + (w - 1 - i) * h) +#define OUT 8 +#include "rotatetemplate.c" +#define OUT 16 +#include "rotatetemplate.c" +#define OUT 32 +#include "rotatetemplate.c" +#undef FUNCNAME +#undef FUNC +#undef SWAPDIMENSIONS + +#define FUNCNAME rfbFlipHorizontally +#define FUNC(i, j) ((w - 1 - i) + j * w) +#define OUT 8 +#include "rotatetemplate.c" +#define OUT 16 +#include "rotatetemplate.c" +#define OUT 32 +#include "rotatetemplate.c" +#undef FUNCNAME +#undef FUNC + +#define FUNCNAME rfbFlipVertically +#define FUNC(i, j) (i + (h - 1 - j) * w) +#define OUT 8 +#include "rotatetemplate.c" +#define OUT 16 +#include "rotatetemplate.c" +#define OUT 32 +#include "rotatetemplate.c" +#undef FUNCNAME +#undef FUNC + +#define FUNCNAME rfbRotateHundredAndEighty +#define FUNC(i, j) ((w - 1 - i) + (h - 1 - j) * w) +#define OUT 8 +#include "rotatetemplate.c" +#define OUT 16 +#include "rotatetemplate.c" +#define OUT 32 +#include "rotatetemplate.c" +#undef FUNCNAME +#undef FUNC + +static void HandleKey(rfbBool down,rfbKeySym key,rfbClientPtr cl) +{ + if(down) { + if (key==XK_Escape || key=='q' || key=='Q') + rfbCloseClient(cl); + else if (key == 'r') + rfbRotate(cl->screen); + else if (key == 'R') + rfbRotateCounterClockwise(cl->screen); + else if (key == 'f') + rfbFlipHorizontally(cl->screen); + else if (key == 'F') + rfbFlipVertically(cl->screen); + } +} + +#define HAVE_HANDLEKEY +#include "pnmshow.c" + |