
#include <X11/Xlib.h>
#include "../wraster.h"


Display *dpy;
Window win;
RContext *ctx;
RImage *img, *tile, *new;
Pixmap pix;

void main()
{
    int i;
    RContextAttributes attr;
    
    dpy = XOpenDisplay("");
    if (!dpy) {
	puts("cant open display");
	exit(1);
    }
    win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 10, 10, 100, 100,
			      0, 0, 0);
    XMapRaised(dpy, win);
    XFlush(dpy);
    attr.flags = RC_RenderMode;
    attr.render_mode = RM_DITHER;
    ctx = RCreateContext(dpy, DefaultScreen(dpy), &attr);
    for (i=0; i<100; i++) {
    img = RLoadImage(ctx, "Clipboard.xpm");
    if (!img) {
	puts(RErrorString);
	exit(1);
    }
    new = RLoadImage(ctx, "tile.xpm");
    if (!new) {
	puts(RErrorString);
	exit(1);
    }
    RCombineArea(new, img, 0, 0, img->width, img->height, 8, 8);
    RConvertImage(ctx, new, &pix);
    XCopyArea(dpy, pix, win, ctx->copy_gc, 0, 0, new->width, new->height, 
	      0, 0);
	RDestroyImage(img); RDestroyImage(new);
}	
    XFlush(dpy);
}
