Change to the linux kernel coding style
[wmaker-crm.git] / wrlib / tests / testrot.c
Commit [+]AuthorDateLineData
65f5627d kojima2000-02-27 19:52:23 +00001
65f5627d kojima2000-02-27 19:52:23 +00002#include <X11/Xlib.h>
3#include "wraster.h"
4#include <stdlib.h>
5#include <stdio.h>
ccbb6e8e dan2000-09-24 02:31:58 +00006#include <unistd.h>
65f5627d kojima2000-02-27 19:52:23 +00007#include "tile.xpm"
8Display *dpy;
9Window win;
10RContext *ctx;
11RImage *img;
12Pixmap pix;
13
65f5627d kojima2000-02-27 19:52:23 +000014#define MAX(a,b) (a)>(b) ? (a) : (b)
15
16int main(int argc, char **argv)
17{
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +020018 RContextAttributes attr;
19 float a;
65f5627d kojima2000-02-27 19:52:23 +000020
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +020021 dpy = XOpenDisplay("");
22 if (!dpy) {
23 puts("cant open display");
24 exit(1);
25 }
65f5627d kojima2000-02-27 19:52:23 +000026
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +020027 attr.flags = RC_RenderMode | RC_ColorsPerChannel;
28 attr.render_mode = RDitheredRendering;
29 attr.colors_per_channel = 4;
30 ctx = RCreateContext(dpy, DefaultScreen(dpy), &attr);
65f5627d kojima2000-02-27 19:52:23 +000031
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +020032 if (argc < 2)
33 img = RGetImageFromXPMData(ctx, image_name);
34 else
35 img = RLoadImage(ctx, argv[1], 0);
65f5627d kojima2000-02-27 19:52:23 +000036
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +020037 if (!img) {
38 puts(RMessageForError(RErrorCode));
39 exit(1);
40 }
41 win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 10, 10,
42 MAX(img->width, img->height), MAX(img->height, img->width), 0, 0, 0);
43 XMapRaised(dpy, win);
44 XFlush(dpy);
65f5627d kojima2000-02-27 19:52:23 +000045
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +020046 a = 0;
47 while (1) {
48 RImage *tmp;
6830b057 dan2004-10-12 21:28:27 +000049
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +020050 a = a + 1.0;
6830b057 dan2004-10-12 21:28:27 +000051
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +020052 tmp = RRotateImage(img, a);
53 if (!RConvertImage(ctx, tmp, &pix)) {
54 puts(RMessageForError(RErrorCode));
55 exit(1);
56 }
57 RReleaseImage(tmp);
6830b057 dan2004-10-12 21:28:27 +000058
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +020059 XSetWindowBackgroundPixmap(dpy, win, pix);
60 XFreePixmap(dpy, pix);
61 XClearWindow(dpy, win);
62 XSync(dpy, 0);
63 usleep(50000);
64 }
65 exit(0);
65f5627d kojima2000-02-27 19:52:23 +000066}