Files
wmaker/wrlib/tests/testrot.c
T

67 lines
1.2 KiB
C
Raw Normal View History

2000-02-27 19:52:23 +00:00
#include <X11/Xlib.h>
#include "wraster.h"
#include <stdlib.h>
#include <stdio.h>
2000-09-24 02:31:58 +00:00
#include <unistd.h>
2000-02-27 19:52:23 +00:00
#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)
{
2009-08-20 00:59:40 +02:00
RContextAttributes attr;
float a;
2000-02-27 19:52:23 +00:00
2009-08-20 00:59:40 +02:00
dpy = XOpenDisplay("");
if (!dpy) {
puts("cant open display");
exit(1);
}
2000-02-27 19:52:23 +00:00
2009-08-20 00:59:40 +02:00
attr.flags = RC_RenderMode | RC_ColorsPerChannel;
attr.render_mode = RDitheredRendering;
attr.colors_per_channel = 4;
ctx = RCreateContext(dpy, DefaultScreen(dpy), &attr);
2000-02-27 19:52:23 +00:00
2009-08-20 00:59:40 +02:00
if (argc < 2)
img = RGetImageFromXPMData(ctx, image_name);
else
img = RLoadImage(ctx, argv[1], 0);
2000-02-27 19:52:23 +00:00
2009-08-20 00:59:40 +02:00
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);
2000-02-27 19:52:23 +00:00
2009-08-20 00:59:40 +02:00
a = 0;
while (1) {
RImage *tmp;
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
a = a + 1.0;
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
tmp = RRotateImage(img, a);
if (!RConvertImage(ctx, tmp, &pix)) {
puts(RMessageForError(RErrorCode));
exit(1);
}
RReleaseImage(tmp);
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
XSetWindowBackgroundPixmap(dpy, win, pix);
XFreePixmap(dpy, pix);
XClearWindow(dpy, win);
XSync(dpy, 0);
usleep(50000);
}
exit(0);
2000-02-27 19:52:23 +00:00
}