asm optimization for 8bpp (no mmx)
[wmaker-crm.git] / wrlib / view.c
blob59490cc6611428cb246c5c599e786041f0fb588e
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);
48 if (argc > 2) {
49 img = RScaleImage(img, img->width*atof(argv[2]),
50 img->height*atof(argv[2]));
52 {int i;
53 for (i=0; i<10;i++)
54 if (!RConvertImage(ctx, img, &pix)) {
55 puts(RMessageForError(RErrorCode));
56 exit(1);
60 printf("%ix%i\n", img->width, img->height);
64 win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 10, 10,
65 img->width,
66 img->height, 0, 0, 0);
67 XSetWindowBackgroundPixmap(dpy, win, pix);
68 XClearWindow(dpy, win);
69 XMapRaised(dpy, win);
70 XFlush(dpy);
71 getchar();
72 exit(0);