From 65f5627d9868a1a7247e0ed10ec33e63819c21b2 Mon Sep 17 00:00:00 2001 From: kojima Date: Sun, 27 Feb 2000 19:52:23 +0000 Subject: [PATCH] rotation test code --- wrlib/testrot.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 wrlib/testrot.c diff --git a/wrlib/testrot.c b/wrlib/testrot.c new file mode 100644 index 00000000..0f7f37e4 --- /dev/null +++ b/wrlib/testrot.c @@ -0,0 +1,67 @@ + + +#include +#include "wraster.h" +#include +#include +#include "tile.xpm" +Display *dpy; +Window win; +RContext *ctx; +RImage *img; +Pixmap pix; + + +#define MAX(a,b) (a)>(b) ? (a) : (b) + +int main(int argc, char **argv) +{ + RContextAttributes attr; + float a; + + dpy = XOpenDisplay(""); + if (!dpy) { + puts("cant open display"); + exit(1); + } + + attr.flags = RC_RenderMode | RC_ColorsPerChannel; + attr.render_mode = RDitheredRendering; + attr.colors_per_channel = 4; + ctx = RCreateContext(dpy, DefaultScreen(dpy), &attr); + + if (argc<2) + img = RGetImageFromXPMData(ctx, image_name); + else + img = RLoadImage(ctx, argv[1], 0); + + if (!img) { + puts(RMessageForError(RErrorCode)); + exit(1); + } + win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 10, 10, + MAX(img->width, img->height), + MAX(img->height, img->width), 0, 0, 0); + XMapRaised(dpy, win); + XFlush(dpy); + + a = 0; + while (1) { + RImage *tmp; + + a = a + 1.0; + + tmp = RRotateImage(img, a); + if (!RConvertImage(ctx, tmp, &pix)) { + puts(RMessageForError(RErrorCode)); + exit(1); + } + RDestroyImage(tmp); + + XSetWindowBackgroundPixmap(dpy, win, pix); + XClearWindow(dpy, win); + XSync(dpy, 0); + usleep(50000); + } + exit(0); +} -- 2.11.4.GIT