bag tree finished.. updated code to new bags
[wmaker-crm.git] / wrlib / testrot.c
blob68cc49122234f6cc343b51b071552226c49edeb0
3 #include <X11/Xlib.h>
4 #include "wraster.h"
5 #include <stdlib.h>
6 #include <stdio.h>
7 #include "tile.xpm"
8 Display *dpy;
9 Window win;
10 RContext *ctx;
11 RImage *img;
12 Pixmap pix;
15 #define MAX(a,b) (a)>(b) ? (a) : (b)
17 int main(int argc, char **argv)
19 RContextAttributes attr;
20 float a;
22 dpy = XOpenDisplay("");
23 if (!dpy) {
24 puts("cant open display");
25 exit(1);
28 attr.flags = RC_RenderMode | RC_ColorsPerChannel;
29 attr.render_mode = RDitheredRendering;
30 attr.colors_per_channel = 4;
31 ctx = RCreateContext(dpy, DefaultScreen(dpy), &attr);
33 if (argc<2)
34 img = RGetImageFromXPMData(ctx, image_name);
35 else
36 img = RLoadImage(ctx, argv[1], 0);
38 if (!img) {
39 puts(RMessageForError(RErrorCode));
40 exit(1);
42 win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 10, 10,
43 MAX(img->width, img->height),
44 MAX(img->height, img->width), 0, 0, 0);
45 XMapRaised(dpy, win);
46 XFlush(dpy);
48 a = 0;
49 while (1) {
50 RImage *tmp;
52 a = a + 1.0;
54 tmp = RRotateImage(img, a);
55 if (!RConvertImage(ctx, tmp, &pix)) {
56 puts(RMessageForError(RErrorCode));
57 exit(1);
59 RDestroyImage(tmp);
61 XSetWindowBackgroundPixmap(dpy, win, pix);
62 XFreePixmap(dpy, pix);
63 XClearWindow(dpy, win);
64 XSync(dpy, 0);
65 usleep(50000);
67 exit(0);