added spec for rpm..
[wmaker-crm.git] / wrlib / view.c
blob990a9879882a4ad3814d200963bd59fc4805c353
1 #include <X11/Xlib.h>
2 #include "wraster.h"
3 #include <stdlib.h>
4 #include <stdio.h>
5 #include "tile.xpm"
6 Display *dpy;
7 Window win;
8 RContext *ctx;
9 RImage *img;
10 Pixmap pix;
14 int main(int argc, char **argv)
16 RContextAttributes attr;
18 dpy = XOpenDisplay("");
19 if (!dpy) {
20 puts("cant open display");
21 exit(1);
24 attr.flags = RC_RenderMode | RC_ColorsPerChannel;
25 attr.render_mode = RDitheredRendering;
26 attr.colors_per_channel = 4;
27 ctx = RCreateContext(dpy, DefaultScreen(dpy), &attr);
29 if (argc<2)
30 img = RGetImageFromXPMData(ctx, image_name);
31 else
32 img = RLoadImage(ctx, argv[1], 0);
34 if (!img) {
35 puts(RMessageForError(RErrorCode));
36 exit(1);
39 if (argc > 2) {
40 RImage *tmp = img;
42 img = RSmoothScaleImage(tmp, tmp->width*atol(argv[2]),
43 tmp->height*atol(argv[2]));
44 RDestroyImage(tmp);
48 if (argc > 2) {
49 img = RScaleImage(img, img->width*atof(argv[2]),
50 img->height*atof(argv[2]));
52 if (!RConvertImage(ctx, img, &pix)) {
53 puts(RMessageForError(RErrorCode));
54 exit(1);
57 printf("%ix%i\n", img->width, img->height);
61 win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 10, 10,
62 img->width,
63 img->height, 0, 0, 0);
64 XSetWindowBackgroundPixmap(dpy, win, pix);
65 XClearWindow(dpy, win);
66 XMapRaised(dpy, win);
67 XFlush(dpy);
68 getchar();
69 exit(0);