Files
wmaker/wrlib/view.c
T

94 lines
1.9 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;
int
main(int argc, char **argv)
1998-09-29 22:36:29 +00:00
{
RContextAttributes attr;
dpy = XOpenDisplay("");
if (!dpy) {
2004-10-12 21:28:27 +00:00
puts("cant open display");
exit(1);
1998-09-29 22:36:29 +00:00
}
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);
2004-10-12 21:28:27 +00:00
if (argc<2)
img = RGetImageFromXPMData(ctx, image_name);
1998-09-29 22:36:29 +00:00
else
2004-10-12 21:28:27 +00:00
img = RLoadImage(ctx, argv[1], 0);
1998-09-29 22:36:29 +00:00
if (!img) {
2004-10-12 21:28:27 +00:00
puts(RMessageForError(RErrorCode));
exit(1);
1998-09-29 22:36:29 +00:00
}
1999-04-28 20:37:39 +00:00
if (argc > 2) {
2004-10-12 21:28:27 +00:00
RImage *tmp = img;
img = RScaleImage(tmp, tmp->width*atol(argv[2]),
tmp->height*atol(argv[2]));
2004-10-12 21:28:27 +00:00
/*img = RSmoothScaleImage(tmp, tmp->width*atol(argv[2]),
tmp->height*atol(argv[2]));
*/
2004-10-12 21:28:27 +00:00
RReleaseImage(tmp);
}
2001-02-18 00:41:22 +00:00
#if 0
if (argc > 2) {
2004-10-12 21:28:27 +00:00
img = RScaleImage(img, img->width*atof(argv[2]),
img->height*atof(argv[2]));
1999-04-28 20:37:39 +00:00
}
2004-10-12 21:28:27 +00:00
2000-03-07 01:12:12 +00:00
{
2004-10-12 21:28:27 +00:00
RImage *tmp = RCreateImage(200, 200, True);
RColor col = {0,0,255,255};
if (img->format == RRGBAFormat)
puts("alpha");
else
puts("no alpha");
RClearImage(tmp, &col);
RCombineArea(tmp, img, 0, 0, 20, 20, 10, 10);
img = tmp;
2000-03-07 01:12:12 +00:00
}
2000-05-21 15:33:27 +00:00
#endif
2004-10-12 21:28:27 +00:00
1998-09-29 22:36:29 +00:00
if (!RConvertImage(ctx, img, &pix)) {
2004-10-12 21:28:27 +00:00
puts(RMessageForError(RErrorCode));
exit(1);
1998-09-29 22:36:29 +00:00
}
2004-10-12 21:28:27 +00:00
printf("%ix%i\n", img->width, img->height);
2004-10-12 21:28:27 +00:00
win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 10, 10,
img->width, 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();
return 0;
1998-09-29 22:36:29 +00:00
}
2004-10-12 21:28:27 +00:00