Update Serbian translation from master branch
[wmaker-crm.git] / wrlib / tests / view.c
blob52c3adedd34371f3ff356fec78da139942292f93
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;
12 int main(int argc, char **argv)
14 RContextAttributes attr;
16 dpy = XOpenDisplay("");
17 if (!dpy) {
18 puts("cant open display");
19 exit(1);
22 attr.flags = RC_RenderMode | RC_ColorsPerChannel;
23 attr.render_mode = RDitheredRendering;
24 attr.colors_per_channel = 4;
25 ctx = RCreateContext(dpy, DefaultScreen(dpy), &attr);
27 if (argc < 2) {
28 printf("using default image as none was provided\n");
29 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 = RScaleImage(tmp, tmp->width * atol(argv[2]), tmp->height * atol(argv[2]));
43 /*img = RSmoothScaleImage(tmp, tmp->width*atol(argv[2]),
44 tmp->height*atol(argv[2]));
47 RReleaseImage(tmp);
49 #if 0
50 if (argc > 2) {
51 img = RScaleImage(img, img->width * atof(argv[2]), 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("size is %ix%i\n", img->width, img->height);
77 win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 10, 10, img->width, img->height, 0, 0, 0);
78 XSetWindowBackgroundPixmap(dpy, win, pix);
79 XClearWindow(dpy, win);
80 XMapRaised(dpy, win);
81 XFlush(dpy);
82 getchar();
84 return 0;