testing new loginfo script
[wmaker-crm.git] / wrlib / view.c
blob7c3743011170570bb2890d6d7b4d54985ce4f410
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
15 main(int argc, char **argv)
17 RContextAttributes attr;
19 dpy = XOpenDisplay("");
20 if (!dpy) {
21 puts("cant open display");
22 exit(1);
25 attr.flags = RC_RenderMode | RC_ColorsPerChannel;
26 attr.render_mode = RDitheredRendering;
27 attr.colors_per_channel = 4;
28 ctx = RCreateContext(dpy, DefaultScreen(dpy), &attr);
30 if (argc<2)
31 img = RGetImageFromXPMData(ctx, image_name);
32 else
33 img = RLoadImage(ctx, argv[1], 0);
35 if (!img) {
36 puts(RMessageForError(RErrorCode));
37 exit(1);
40 if (argc > 2) {
41 RImage *tmp = img;
43 img = RSmoothScaleImage(tmp, tmp->width*atol(argv[2]),
44 tmp->height*atol(argv[2]));
45 RDestroyImage(tmp);
48 #if 0
49 if (argc > 2) {
50 img = RScaleImage(img, img->width*atof(argv[2]),
51 img->height*atof(argv[2]));
55 RImage *tmp = RCreateImage(200, 200, True);
56 RColor col = {0,0,255,255};
58 if (img->format == RRGBAFormat)
59 puts("alpha");
60 else
61 puts("no alpha");
63 RClearImage(tmp, &col);
65 RCombineArea(tmp, img, 0, 0, 20, 20, 10, 10);
66 img = tmp;
68 #endif
70 if (!RConvertImage(ctx, img, &pix)) {
71 puts(RMessageForError(RErrorCode));
72 exit(1);
75 printf("%ix%i\n", img->width, img->height);
79 win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 10, 10,
80 img->width, img->height, 0, 0, 0);
81 XSetWindowBackgroundPixmap(dpy, win, pix);
82 XClearWindow(dpy, win);
83 XMapRaised(dpy, win);
84 XFlush(dpy);
85 getchar();
87 return 0;