changed indentation to use spaces only
[wmaker-crm.git] / wrlib / testrot.c
blob026e6073f29ec883ef65f4aa10a4a0456f9907f7
3 #include <X11/Xlib.h>
4 #include "wraster.h"
5 #include <stdlib.h>
6 #include <stdio.h>
7 #include <unistd.h>
8 #include "tile.xpm"
9 Display *dpy;
10 Window win;
11 RContext *ctx;
12 RImage *img;
13 Pixmap pix;
16 #define MAX(a,b) (a)>(b) ? (a) : (b)
18 int main(int argc, char **argv)
20 RContextAttributes attr;
21 float a;
23 dpy = XOpenDisplay("");
24 if (!dpy) {
25 puts("cant open display");
26 exit(1);
29 attr.flags = RC_RenderMode | RC_ColorsPerChannel;
30 attr.render_mode = RDitheredRendering;
31 attr.colors_per_channel = 4;
32 ctx = RCreateContext(dpy, DefaultScreen(dpy), &attr);
34 if (argc<2)
35 img = RGetImageFromXPMData(ctx, image_name);
36 else
37 img = RLoadImage(ctx, argv[1], 0);
39 if (!img) {
40 puts(RMessageForError(RErrorCode));
41 exit(1);
43 win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 10, 10,
44 MAX(img->width, img->height),
45 MAX(img->height, img->width), 0, 0, 0);
46 XMapRaised(dpy, win);
47 XFlush(dpy);
49 a = 0;
50 while (1) {
51 RImage *tmp;
53 a = a + 1.0;
55 tmp = RRotateImage(img, a);
56 if (!RConvertImage(ctx, tmp, &pix)) {
57 puts(RMessageForError(RErrorCode));
58 exit(1);
60 RReleaseImage(tmp);
62 XSetWindowBackgroundPixmap(dpy, win, pix);
63 XFreePixmap(dpy, pix);
64 XClearWindow(dpy, win);
65 XSync(dpy, 0);
66 usleep(50000);
68 exit(0);