- standard colormap support for PseudoColor visuals
[wmaker-crm.git] / wrlib / view.c
blob8dcb14aba48c45c06a5343e595563c7564137b30
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);
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 win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 10, 10,
58 img->width,
59 img->height, 0, 0, 0);
60 RDestroyImage(img);
61 XSetWindowBackgroundPixmap(dpy, win, pix);
62 XClearWindow(dpy, win);
63 XMapRaised(dpy, win);
64 XFlush(dpy);
66 getchar();
67 exit(0);