Fixed return of WMGetUDStringForKey to be only a reference, not an allocated
[wmaker-crm.git] / wrlib / view.c
blob31a74eef7ae4f6a11d1dc81fa6271222798c5ee9
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);
23 attr.flags = RC_RenderMode | RC_ColorsPerChannel;
24 attr.render_mode = RDitheredRendering;
25 attr.colors_per_channel = 4;
26 ctx = RCreateContext(dpy, DefaultScreen(dpy), &attr);
27 if (argc<2)
28 img = RGetImageFromXPMData(ctx, image_name);
29 else
30 img = RLoadImage(ctx, argv[1], 0);
32 if (!img) {
33 puts(RMessageForError(RErrorCode));
34 exit(1);
37 if (argc > 2) {
38 RImage *tmp = img;
40 img = RSmoothScaleImage(tmp, tmp->width*atol(argv[2]),
41 tmp->height*atol(argv[2]));
42 RDestroyImage(tmp);
46 if (argc > 2) {
47 img = RScaleImage(img, img->width*atof(argv[2]),
48 img->height*atof(argv[2]));
50 if (!RConvertImage(ctx, img, &pix)) {
51 puts(RMessageForError(RErrorCode));
52 exit(1);
55 win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 10, 10,
56 img->width,
57 img->height, 0, 0, 0);
58 RDestroyImage(img);
59 XSetWindowBackgroundPixmap(dpy, win, pix);
60 XClearWindow(dpy, win);
61 XMapRaised(dpy, win);
62 XFlush(dpy);
64 getchar();