*** empty log message ***
[wmaker-crm.git] / wrlib / view.c
blob4c964110d9763fce7fdcafdeed57e566966d9be6
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);
47 #if 1
48 if (argc > 2) {
49 img = RScaleImage(img, img->width*atof(argv[2]),
50 img->height*atof(argv[2]));
54 RImage *tmp = RCreateImage(200, 200, True);
55 RColor col = {0,0,255,255};
57 if (img->format == RRGBAFormat)
58 puts("aklpha");
59 else
60 puts("no alpha");
62 RClearImage(tmp, &col);
64 RCombineArea(tmp, img, 0, 0, 20, 20, 10, 10);
65 img = tmp;
67 #endif
69 if (!RConvertImage(ctx, img, &pix)) {
70 puts(RMessageForError(RErrorCode));
71 exit(1);
74 printf("%ix%i\n", img->width, img->height);
78 win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 10, 10,
79 400, 400, 0, 0, 0);
80 XSetWindowBackgroundPixmap(dpy, win, pix);
81 XClearWindow(dpy, win);
82 XMapRaised(dpy, win);
83 XFlush(dpy);
84 getchar();
85 exit(0);