Files
wmaker/wrlib/view.c
T

71 lines
1.4 KiB
C
Raw Normal View History

1998-09-29 22:36:29 +00:00
#include <X11/Xlib.h>
1998-10-21 14:43:47 +00:00
#include "wraster.h"
1998-09-29 22:36:29 +00:00
#include <stdlib.h>
#include <stdio.h>
#include "tile.xpm"
Display *dpy;
Window win;
RContext *ctx;
RImage *img;
Pixmap pix;
1999-01-11 12:28:12 +00:00
int main(int argc, char **argv)
1998-09-29 22:36:29 +00:00
{
RContextAttributes attr;
dpy = XOpenDisplay("");
if (!dpy) {
puts("cant open display");
exit(1);
}
1998-09-29 22:36:29 +00:00
attr.flags = RC_RenderMode | RC_ColorsPerChannel;
attr.render_mode = RDitheredRendering;
1998-09-29 22:36:29 +00:00
attr.colors_per_channel = 4;
ctx = RCreateContext(dpy, DefaultScreen(dpy), &attr);
1998-09-29 22:36:29 +00:00
if (argc<2)
img = RGetImageFromXPMData(ctx, image_name);
else
1999-04-28 20:37:39 +00:00
img = RLoadImage(ctx, argv[1], 0);
1998-09-29 22:36:29 +00:00
if (!img) {
1998-10-21 14:43:47 +00:00
puts(RMessageForError(RErrorCode));
1998-09-29 22:36:29 +00:00
exit(1);
}
/*
1999-04-28 20:37:39 +00:00
if (argc > 2) {
RImage *tmp = img;
img = RSmoothScaleImage(tmp, tmp->width*atol(argv[2]),
tmp->height*atol(argv[2]));
RDestroyImage(tmp);
}
*/
if (argc > 2) {
img = RScaleImage(img, img->width*atof(argv[2]),
img->height*atof(argv[2]));
1999-04-28 20:37:39 +00:00
}
1998-09-29 22:36:29 +00:00
if (!RConvertImage(ctx, img, &pix)) {
1998-10-21 14:43:47 +00:00
puts(RMessageForError(RErrorCode));
1998-09-29 22:36:29 +00:00
exit(1);
}
printf("%ix%i\n", img->width, img->height);
win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 10, 10,
img->width,
1998-09-29 22:36:29 +00:00
img->height, 0, 0, 0);
1999-04-28 20:37:39 +00:00
XSetWindowBackgroundPixmap(dpy, win, pix);
XClearWindow(dpy, win);
1998-09-29 22:36:29 +00:00
XMapRaised(dpy, win);
XFlush(dpy);
getchar();
exit(0);
1998-09-29 22:36:29 +00:00
}