Change to the linux kernel coding style
[wmaker-crm.git] / wrlib / tests / view.c
Commit [+]AuthorDateLineData
9d2e6ef9 scottc1998-09-29 22:36:29 +00001#include <X11/Xlib.h>
9af1c6c4 dan1998-10-21 14:43:47 +00002#include "wraster.h"
9d2e6ef9 scottc1998-09-29 22:36:29 +00003#include <stdlib.h>
4#include <stdio.h>
5#include "tile.xpm"
6Display *dpy;
7Window win;
8RContext *ctx;
9RImage *img;
10Pixmap pix;
11
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +020012int main(int argc, char **argv)
9d2e6ef9 scottc1998-09-29 22:36:29 +000013{
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +020014 RContextAttributes attr;
15
16 dpy = XOpenDisplay("");
17 if (!dpy) {
18 puts("cant open display");
19 exit(1);
20 }
21
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);
26
27 if (argc < 2)
28 img = RGetImageFromXPMData(ctx, image_name);
29 else
30 img = RLoadImage(ctx, argv[1], 0);
31
32 if (!img) {
33 puts(RMessageForError(RErrorCode));
34 exit(1);
35 }
36
37 if (argc > 2) {
38 RImage *tmp = img;
39
40 img = RScaleImage(tmp, tmp->width * atol(argv[2]), tmp->height * atol(argv[2]));
41 /*img = RSmoothScaleImage(tmp, tmp->width*atol(argv[2]),
42 tmp->height*atol(argv[2]));
43 */
44
45 RReleaseImage(tmp);
46 }
8d988e5e kojima2001-02-18 00:41:22 +000047#if 0
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +020048 if (argc > 2) {
49 img = RScaleImage(img, img->width * atof(argv[2]), img->height * atof(argv[2]));
50 }
6830b057 dan2004-10-12 21:28:27 +000051
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +020052 {
53 RImage *tmp = RCreateImage(200, 200, True);
54 RColor col = { 0, 0, 255, 255 };
6830b057 dan2004-10-12 21:28:27 +000055
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +020056 if (img->format == RRGBAFormat)
57 puts("alpha");
58 else
59 puts("no alpha");
6830b057 dan2004-10-12 21:28:27 +000060
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +020061 RClearImage(tmp, &col);
6830b057 dan2004-10-12 21:28:27 +000062
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +020063 RCombineArea(tmp, img, 0, 0, 20, 20, 10, 10);
64 img = tmp;
65 }
e7771be1 kojima2000-05-21 15:33:27 +000066#endif
6830b057 dan2004-10-12 21:28:27 +000067
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +020068 if (!RConvertImage(ctx, img, &pix)) {
69 puts(RMessageForError(RErrorCode));
70 exit(1);
71 }
6830b057 dan2004-10-12 21:28:27 +000072
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +020073 printf("%ix%i\n", img->width, img->height);
8f68cfd8 kojima1999-04-29 23:05:16 +000074
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +020075 win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 10, 10, img->width, img->height, 0, 0, 0);
76 XSetWindowBackgroundPixmap(dpy, win, pix);
77 XClearWindow(dpy, win);
78 XMapRaised(dpy, win);
79 XFlush(dpy);
80 getchar();
6830b057 dan2004-10-12 21:28:27 +000081
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +020082 return 0;
9d2e6ef9 scottc1998-09-29 22:36:29 +000083}