updated estonian locale file
[wmaker-crm.git] / wrlib / view.c
blobae1bfeaddef27711c180496855134dce40c081e3
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 = RScaleImage(tmp, tmp->width*atol(argv[2]),
44 tmp->height*atol(argv[2]));
45 /*img = RSmoothScaleImage(tmp, tmp->width*atol(argv[2]),
46 tmp->height*atol(argv[2]));
49 RReleaseImage(tmp);
52 #if 0
53 if (argc > 2) {
54 img = RScaleImage(img, img->width*atof(argv[2]),
55 img->height*atof(argv[2]));
59 RImage *tmp = RCreateImage(200, 200, True);
60 RColor col = {0,0,255,255};
62 if (img->format == RRGBAFormat)
63 puts("alpha");
64 else
65 puts("no alpha");
67 RClearImage(tmp, &col);
69 RCombineArea(tmp, img, 0, 0, 20, 20, 10, 10);
70 img = tmp;
72 #endif
74 if (!RConvertImage(ctx, img, &pix)) {
75 puts(RMessageForError(RErrorCode));
76 exit(1);
79 printf("%ix%i\n", img->width, img->height);
83 win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 10, 10,
84 img->width, img->height, 0, 0, 0);
85 XSetWindowBackgroundPixmap(dpy, win, pix);
86 XClearWindow(dpy, win);
87 XMapRaised(dpy, win);
88 XFlush(dpy);
89 getchar();
91 return 0;