1999-08-01 15:14:11 -07:00
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#include <X11/extensions/XShm.h>
|
|
|
|
#include <X11/Xutil.h>
|
|
|
|
#include <X11/extensions/shape.h>
|
|
|
|
#include <X11/Xatom.h>
|
|
|
|
#include <X11/Xos.h>
|
1999-08-05 19:08:36 -07:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
/*
|
1999-08-01 15:14:11 -07:00
|
|
|
#include <sys/time.h>
|
|
|
|
#include "common.h"
|
|
|
|
#include "image.h"
|
|
|
|
#include "rend.h"
|
|
|
|
#include "rgba.h"
|
1999-08-05 19:08:36 -07:00
|
|
|
#include "ximage.h"
|
|
|
|
#include "color.h"
|
|
|
|
*/
|
|
|
|
#include "api.h"
|
1999-08-01 15:14:11 -07:00
|
|
|
|
|
|
|
Display *disp;
|
1999-09-10 11:11:47 -07:00
|
|
|
Window win;
|
|
|
|
Visual *vis;
|
|
|
|
Colormap cm;
|
|
|
|
int depth;
|
|
|
|
|
1999-10-22 04:19:11 -07:00
|
|
|
void progress(Imlib_Image *im, char percent, int update_x, int update_y,
|
|
|
|
int update_w, int update_h);
|
|
|
|
|
1999-09-12 18:56:57 -07:00
|
|
|
void
|
1999-09-10 11:11:47 -07:00
|
|
|
progress(Imlib_Image *im, char percent,
|
|
|
|
int update_x, int update_y,
|
|
|
|
int update_w, int update_h)
|
|
|
|
{
|
|
|
|
imlib_render_image_part_on_drawable_at_size(im, disp, win, vis, cm, depth,
|
|
|
|
0, 0, 0,
|
|
|
|
update_x, update_y,
|
|
|
|
update_w, update_h,
|
1999-09-12 18:56:57 -07:00
|
|
|
update_x, update_y,
|
1999-09-10 11:11:47 -07:00
|
|
|
update_w, update_h,
|
1999-09-13 21:21:29 -07:00
|
|
|
NULL, IMLIB_OP_COPY);
|
1999-09-10 11:11:47 -07:00
|
|
|
}
|
1999-08-01 15:14:11 -07:00
|
|
|
|
1999-09-08 10:27:40 -07:00
|
|
|
#if 1
|
1999-08-01 15:14:11 -07:00
|
|
|
int main (int argc, char **argv)
|
|
|
|
{
|
|
|
|
int i, j;
|
1999-10-22 04:19:11 -07:00
|
|
|
Imlib_Image *im = NULL;
|
1999-08-01 15:14:11 -07:00
|
|
|
int sec1, usec1, sec2, usec2;
|
|
|
|
int pixels = 0;
|
|
|
|
struct timeval timev;
|
|
|
|
double sec;
|
1999-09-14 18:15:55 -07:00
|
|
|
char *file = NULL;
|
1999-09-27 15:52:02 -07:00
|
|
|
char *fon = NULL, *str = NULL;
|
1999-08-01 15:14:11 -07:00
|
|
|
|
|
|
|
int root = 0;
|
|
|
|
int scale = 0;
|
1999-09-12 18:56:57 -07:00
|
|
|
int w = 20;
|
|
|
|
int h = 20;
|
1999-08-01 15:14:11 -07:00
|
|
|
int aa = 0;
|
|
|
|
int dith = 0;
|
1999-09-12 18:56:57 -07:00
|
|
|
int loop = 0;
|
|
|
|
int blend = 1;
|
|
|
|
int interactive = 1;
|
1999-09-13 21:21:29 -07:00
|
|
|
int blendtest = 0;
|
1999-08-01 15:14:11 -07:00
|
|
|
|
|
|
|
for (i = 1; i < argc; i++)
|
|
|
|
{
|
|
|
|
if (!strcmp(argv[i], "-root"))
|
|
|
|
root = 1;
|
|
|
|
else if (!strcmp(argv[i], "-smooth"))
|
|
|
|
aa = 1;
|
1999-10-30 04:22:48 -07:00
|
|
|
else if (!strcmp(argv[i], "-blast"))
|
|
|
|
interactive = 0;
|
1999-09-26 14:36:51 -07:00
|
|
|
else if (!strcmp(argv[i], "-loop"))
|
1999-09-08 10:27:40 -07:00
|
|
|
{
|
1999-09-12 18:56:57 -07:00
|
|
|
interactive = 0;
|
|
|
|
loop = 1;
|
1999-09-08 10:27:40 -07:00
|
|
|
}
|
1999-08-01 15:14:11 -07:00
|
|
|
else if (!strcmp(argv[i], "-blend"))
|
|
|
|
blend = 1;
|
1999-09-13 21:21:29 -07:00
|
|
|
else if (!strcmp(argv[i], "-blendtest"))
|
|
|
|
{
|
|
|
|
blendtest = 1;
|
|
|
|
interactive = 0;
|
|
|
|
}
|
1999-08-01 15:14:11 -07:00
|
|
|
else if (!strcmp(argv[i], "-dither"))
|
|
|
|
dith = 1;
|
|
|
|
else if (!strcmp(argv[i], "-scale"))
|
|
|
|
scale = 1;
|
|
|
|
else if (!strcmp(argv[i], "-noloop"))
|
|
|
|
loop = 0;
|
|
|
|
else if (!strcmp(argv[i], "-size"))
|
|
|
|
{
|
|
|
|
i++;
|
|
|
|
w = atoi(argv[i++]);
|
|
|
|
h = atoi(argv[i]);
|
|
|
|
}
|
1999-09-12 21:06:57 -07:00
|
|
|
else if (!strcmp(argv[i], "-maxcolors"))
|
|
|
|
{
|
|
|
|
i++;
|
|
|
|
imlib_set_color_usage(atoi(argv[i]));
|
|
|
|
}
|
1999-09-27 15:52:02 -07:00
|
|
|
else if (!strcmp(argv[i], "-font"))
|
|
|
|
{
|
|
|
|
i++;
|
|
|
|
fon = argv[i];
|
|
|
|
}
|
|
|
|
else if (!strcmp(argv[i], "-text"))
|
|
|
|
{
|
|
|
|
i++;
|
|
|
|
str = argv[i];
|
|
|
|
}
|
1999-08-01 15:14:11 -07:00
|
|
|
else
|
|
|
|
file = argv[i];
|
|
|
|
}
|
|
|
|
printf("init\n");
|
|
|
|
disp = XOpenDisplay(NULL);
|
1999-09-10 11:11:47 -07:00
|
|
|
vis = DefaultVisual(disp, DefaultScreen(disp));
|
1999-09-19 15:05:59 -07:00
|
|
|
depth = DefaultDepth(disp, DefaultScreen(disp));
|
1999-09-10 11:11:47 -07:00
|
|
|
cm = DefaultColormap(disp, DefaultScreen(disp));
|
|
|
|
if (root)
|
|
|
|
win = DefaultRootWindow(disp);
|
|
|
|
else
|
1999-09-26 14:36:51 -07:00
|
|
|
{
|
|
|
|
win = XCreateSimpleWindow(disp, DefaultRootWindow(disp), 0, 0, 10, 10, 0, 0, 0);
|
1999-09-27 15:52:02 -07:00
|
|
|
XSelectInput(disp, win, ButtonPressMask | ButtonReleaseMask |
|
|
|
|
ButtonMotionMask | PointerMotionMask | ExposureMask);
|
1999-09-26 14:36:51 -07:00
|
|
|
}
|
1999-09-12 18:56:57 -07:00
|
|
|
if (!interactive)
|
1999-08-01 15:14:11 -07:00
|
|
|
{
|
1999-09-12 18:56:57 -07:00
|
|
|
im = imlib_load_image_with_progress_callback(file, progress, 0);
|
|
|
|
if (!im)
|
|
|
|
{
|
|
|
|
printf("load fialed\n");
|
|
|
|
exit(0);
|
|
|
|
}
|
1999-09-13 21:21:29 -07:00
|
|
|
w = imlib_image_get_width(im);
|
|
|
|
h = imlib_image_get_height(im);
|
1999-08-01 15:14:11 -07:00
|
|
|
}
|
1999-09-10 11:11:47 -07:00
|
|
|
if (!root)
|
1999-08-01 15:14:11 -07:00
|
|
|
{
|
1999-09-10 11:11:47 -07:00
|
|
|
XResizeWindow(disp, win, w, h);
|
1999-08-01 15:14:11 -07:00
|
|
|
XMapWindow(disp, win);
|
|
|
|
}
|
|
|
|
if (scale)
|
|
|
|
{
|
|
|
|
Window d;
|
|
|
|
int dd;
|
|
|
|
|
|
|
|
XGetGeometry(disp, win, &d, &dd, &dd, &w, &h, &dd, &dd);
|
|
|
|
}
|
|
|
|
XSync(disp, False);
|
|
|
|
printf("rend\n");
|
|
|
|
gettimeofday(&timev,NULL);
|
|
|
|
sec1=(int)timev.tv_sec; /* and stores it so we can time outselves */
|
|
|
|
usec1=(int)timev.tv_usec; /* we will use this to vary speed of rot */
|
1999-09-27 15:52:02 -07:00
|
|
|
|
1999-08-01 15:14:11 -07:00
|
|
|
if (loop)
|
|
|
|
{
|
|
|
|
for (i = 0; i < w; i++)
|
|
|
|
{
|
1999-09-08 10:27:40 -07:00
|
|
|
imlib_render_image_on_drawable_at_size(im, disp, win, vis,
|
1999-09-10 11:11:47 -07:00
|
|
|
cm,
|
1999-09-08 10:27:40 -07:00
|
|
|
depth,
|
|
|
|
aa, dith, blend,
|
|
|
|
0, 0,
|
|
|
|
w - i, (((w - i) * h) / w),
|
1999-09-13 21:21:29 -07:00
|
|
|
NULL, IMLIB_OP_COPY);
|
1999-08-01 15:14:11 -07:00
|
|
|
pixels += (w - i) * (((w - i) * h) / w);
|
|
|
|
}
|
|
|
|
}
|
1999-09-13 21:21:29 -07:00
|
|
|
else if (blendtest)
|
|
|
|
{
|
|
|
|
Imlib_Image im2;
|
|
|
|
|
|
|
|
im2 = imlib_create_image(w, h);
|
|
|
|
w = imlib_image_get_width(im);
|
|
|
|
h = imlib_image_get_height(im);
|
|
|
|
for (i = 0; i < 1024; i++)
|
|
|
|
{
|
|
|
|
imlib_blend_image_onto_image(im, im2,
|
|
|
|
0, 0, 0,
|
|
|
|
0, 0, w, h,
|
|
|
|
0, 0, w, h, NULL, IMLIB_OP_COPY);
|
|
|
|
pixels += (w * h);
|
|
|
|
}
|
|
|
|
}
|
1999-09-08 10:27:40 -07:00
|
|
|
else if (interactive)
|
|
|
|
{
|
1999-09-26 14:36:51 -07:00
|
|
|
int wo, ho, px, py, first = 1;
|
|
|
|
Imlib_Image im_bg, im_sh1, im_sh2, im_sh3, im_ic[13], im_tmp;
|
1999-10-22 04:19:11 -07:00
|
|
|
/* Imlib_Border border; */
|
1999-09-26 14:36:51 -07:00
|
|
|
Imlib_Updates up = NULL;
|
1999-10-22 04:19:11 -07:00
|
|
|
int x, y, /* dum, */ i, j;
|
|
|
|
/*
|
1999-09-26 14:36:51 -07:00
|
|
|
unsigned int dui;
|
|
|
|
Window rt;
|
1999-10-22 04:19:11 -07:00
|
|
|
*/
|
1999-09-26 14:36:51 -07:00
|
|
|
XEvent ev;
|
1999-10-22 04:19:11 -07:00
|
|
|
Imlib_Font fn=NULL;
|
1999-09-26 14:36:51 -07:00
|
|
|
|
1999-09-27 15:52:02 -07:00
|
|
|
/* "ARIAL/30" "COMIC/30" "IMPACT/30" "Prole/30" "Proteron/30" */
|
|
|
|
/* "TIMES/30" "badacid/30" "bajoran/30" "bigfish/30" */
|
1999-09-28 16:48:39 -07:00
|
|
|
imlib_add_path_to_font_path("./ttfonts");
|
1999-09-27 15:52:02 -07:00
|
|
|
if (fon)
|
1999-09-27 15:55:56 -07:00
|
|
|
{
|
1999-09-28 16:48:39 -07:00
|
|
|
fn = imlib_load_font(fon);
|
1999-09-27 15:55:56 -07:00
|
|
|
if (!fn)
|
|
|
|
fon = NULL;
|
|
|
|
}
|
1999-09-26 14:36:51 -07:00
|
|
|
|
1999-09-14 18:15:55 -07:00
|
|
|
if (file)
|
|
|
|
im_bg = imlib_load_image(file);
|
|
|
|
else
|
|
|
|
im_bg = imlib_load_image("test_images/bg.png");
|
1999-09-26 14:36:51 -07:00
|
|
|
im_tmp = imlib_clone_image(im_bg);
|
1999-09-12 18:56:57 -07:00
|
|
|
w = imlib_image_get_width(im_bg);
|
1999-09-18 00:50:37 -07:00
|
|
|
h = imlib_image_get_height(im_bg);
|
|
|
|
wo = w;
|
|
|
|
ho = h;
|
1999-09-18 23:28:54 -07:00
|
|
|
w *= 1;
|
|
|
|
h *= 1;
|
1999-09-12 18:56:57 -07:00
|
|
|
XResizeWindow(disp, win, w, h);
|
1999-09-26 14:36:51 -07:00
|
|
|
XSync(disp, False);
|
1999-09-12 18:56:57 -07:00
|
|
|
im = imlib_create_image(w, h);
|
|
|
|
imlib_set_cache_size(4 * 1024 * 1024);
|
1999-09-26 14:36:51 -07:00
|
|
|
i = 0;
|
|
|
|
up = imlib_update_append_rect(up, 0, 0, w, h);
|
|
|
|
x = -9999;
|
|
|
|
y = -9999;
|
1999-09-08 10:27:40 -07:00
|
|
|
while (1)
|
|
|
|
{
|
1999-09-26 14:36:51 -07:00
|
|
|
px = x;
|
|
|
|
py = y;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
XNextEvent(disp, &ev);
|
|
|
|
switch (ev.type)
|
|
|
|
{
|
|
|
|
case Expose:
|
|
|
|
up = imlib_update_append_rect(up,
|
|
|
|
ev.xexpose.x, ev.xexpose.y,
|
|
|
|
ev.xexpose.width, ev.xexpose.height);
|
|
|
|
break;
|
1999-09-27 15:52:02 -07:00
|
|
|
case ButtonRelease:
|
1999-09-26 14:36:51 -07:00
|
|
|
exit(0);
|
|
|
|
break;
|
|
|
|
case MotionNotify:
|
|
|
|
x = ev.xmotion.x;
|
|
|
|
y = ev.xmotion.y;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while (XPending(disp));
|
1999-09-08 10:27:40 -07:00
|
|
|
|
1999-09-12 18:56:57 -07:00
|
|
|
im_sh1 = imlib_load_image("test_images/sh1.png");
|
|
|
|
im_sh2 = imlib_load_image("test_images/sh2.png");
|
|
|
|
im_sh3 = imlib_load_image("test_images/sh3.png");
|
|
|
|
im_ic[0] = imlib_load_image("test_images/audio.png");
|
|
|
|
im_ic[1] = imlib_load_image("test_images/folder.png");
|
|
|
|
im_ic[2] = imlib_load_image("test_images/mush.png");
|
|
|
|
im_ic[3] = imlib_load_image("test_images/paper.png");
|
1999-09-12 22:32:36 -07:00
|
|
|
im_ic[4] = imlib_load_image("test_images/mail.png");
|
|
|
|
im_ic[5] = imlib_load_image("test_images/calc.png");
|
|
|
|
im_ic[6] = imlib_load_image("test_images/cal.png");
|
|
|
|
im_ic[7] = imlib_load_image("test_images/stop.png");
|
|
|
|
im_ic[8] = imlib_load_image("test_images/globe.png");
|
|
|
|
im_ic[9] = imlib_load_image("test_images/menu.png");
|
|
|
|
im_ic[10] = imlib_load_image("test_images/tnt.png");
|
|
|
|
im_ic[11] = imlib_load_image("test_images/bulb.png");
|
|
|
|
im_ic[12] = imlib_load_image("test_images/lock.png");
|
1999-09-26 14:36:51 -07:00
|
|
|
|
|
|
|
if (first)
|
1999-09-12 18:56:57 -07:00
|
|
|
{
|
1999-09-26 14:36:51 -07:00
|
|
|
imlib_blend_image_onto_image(im_bg, im,
|
|
|
|
0, 0, 0,
|
|
|
|
0, 0, w, h,
|
|
|
|
0, 0, w, h,
|
|
|
|
NULL, IMLIB_OP_COPY);
|
|
|
|
first = 0;
|
|
|
|
}
|
1999-09-30 09:46:04 -07:00
|
|
|
{
|
|
|
|
Imlib_Updates uu;
|
1999-10-25 09:36:24 -07:00
|
|
|
Imlib_Color col;
|
1999-09-30 09:46:04 -07:00
|
|
|
|
1999-10-25 09:36:24 -07:00
|
|
|
col.red = 255;
|
|
|
|
col.green = 255;
|
|
|
|
col.blue = 255;
|
|
|
|
col.alpha = 255;
|
|
|
|
uu = imlib_image_draw_line(im, 200, 200, x, y, &col,
|
|
|
|
IMLIB_OP_COPY, 1);
|
1999-09-30 09:46:04 -07:00
|
|
|
up = imlib_updates_append_updates(up, uu);
|
|
|
|
}
|
1999-10-25 09:36:24 -07:00
|
|
|
{
|
1999-10-27 07:08:28 -07:00
|
|
|
Imlib_Color_Range rg = NULL;
|
1999-10-25 09:36:24 -07:00
|
|
|
|
|
|
|
if (!rg)
|
|
|
|
{
|
1999-10-27 07:08:28 -07:00
|
|
|
Imlib_Color cl;
|
|
|
|
|
|
|
|
rg = imlib_create_color_range();
|
|
|
|
cl.red = 255; cl.green = 255; cl.blue = 255; cl.alpha = 255;
|
|
|
|
imlib_add_color_to_color_range(rg, &cl, 0);
|
|
|
|
cl.red = 255; cl.green = 255; cl.blue = 160; cl.alpha = 200;
|
|
|
|
imlib_add_color_to_color_range(rg, &cl, 1);
|
|
|
|
cl.red = 255; cl.green = 160; cl.blue = 120; cl.alpha = 140;
|
|
|
|
imlib_add_color_to_color_range(rg, &cl, 1);
|
|
|
|
cl.red = 100; cl.green = 80; cl.blue = 100; cl.alpha = 80;
|
|
|
|
imlib_add_color_to_color_range(rg, &cl, 1);
|
|
|
|
cl.red = 32; cl.green = 48; cl.blue = 80; cl.alpha = 0;
|
|
|
|
imlib_add_color_to_color_range(rg, &cl, 1);
|
1999-10-25 09:36:24 -07:00
|
|
|
}
|
1999-10-27 10:44:15 -07:00
|
|
|
imlib_image_fill_color_range_rectangle(im, 60, 60, 256, 256,
|
1999-10-27 07:08:28 -07:00
|
|
|
rg, (double)x,
|
|
|
|
IMLIB_OP_COPY);
|
1999-10-27 10:44:15 -07:00
|
|
|
up = imlib_update_append_rect(up, 60, 60, 256, 256);
|
1999-10-25 09:36:24 -07:00
|
|
|
}
|
1999-09-27 15:52:02 -07:00
|
|
|
if (fon)
|
|
|
|
{
|
1999-09-29 10:25:52 -07:00
|
|
|
int retw, reth, ty, nx, ny, cx, cy, cw, ch, cp;
|
1999-09-27 15:52:02 -07:00
|
|
|
|
|
|
|
if (!str)
|
|
|
|
str = "This is a test string";
|
1999-09-29 10:25:52 -07:00
|
|
|
ty = 50;
|
1999-09-27 15:52:02 -07:00
|
|
|
for (i = 0; i < 16; i++)
|
|
|
|
{
|
1999-09-28 16:48:39 -07:00
|
|
|
Imlib_Color cl;
|
1999-09-27 15:52:02 -07:00
|
|
|
int al;
|
1999-09-28 16:48:39 -07:00
|
|
|
|
1999-09-27 15:52:02 -07:00
|
|
|
al = (15 - i) * 16;
|
|
|
|
if (al > 255)
|
|
|
|
al = 255;
|
1999-09-28 16:48:39 -07:00
|
|
|
cl.red = 255;
|
|
|
|
cl.green = 255;
|
|
|
|
cl.blue = 255;
|
|
|
|
cl.alpha = al;
|
|
|
|
|
1999-09-29 10:25:52 -07:00
|
|
|
imlib_text_draw_with_return_metrics(fn, im, 50, ty,
|
1999-09-28 16:48:39 -07:00
|
|
|
IMLIB_TEXT_TO_RIGHT,
|
|
|
|
str, &cl,
|
|
|
|
IMLIB_OP_COPY,
|
|
|
|
&retw, &reth,
|
|
|
|
&nx, &ny);
|
1999-09-29 10:25:52 -07:00
|
|
|
/* up = imlib_update_append_rect(up, px, ty + (py - y), retw, reth);*/
|
|
|
|
up = imlib_update_append_rect(up, 50, ty, retw, reth);
|
1999-09-27 19:13:49 -07:00
|
|
|
ty += ny;
|
1999-09-27 15:52:02 -07:00
|
|
|
}
|
1999-09-29 10:25:52 -07:00
|
|
|
cp = imlib_text_get_index_and_location(fn,
|
|
|
|
IMLIB_TEXT_TO_RIGHT,
|
|
|
|
str, x - 50, y - 50,
|
|
|
|
&cx, &cy, &cw, &ch);
|
|
|
|
if (cp >= 0)
|
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
GC gc;
|
|
|
|
XGCValues gcv;
|
|
|
|
|
|
|
|
gc = XCreateGC(disp, win, 0, &gcv);
|
|
|
|
XSetForeground(disp, gc, 0xffff);
|
|
|
|
XDrawRectangle(disp, win, gc, 50 + cx, 50 + cy, cw, ch);
|
|
|
|
XFreeGC(disp, gc);
|
|
|
|
#endif
|
|
|
|
printf("over char %c\n", str[cp]);
|
|
|
|
}
|
1999-09-27 15:52:02 -07:00
|
|
|
}
|
1999-09-26 14:36:51 -07:00
|
|
|
if ((px != x) || (py != y))
|
|
|
|
{
|
|
|
|
for (j = 0; j < 32; j++)
|
1999-09-12 18:56:57 -07:00
|
|
|
{
|
1999-09-26 14:36:51 -07:00
|
|
|
for (i = 0; i < 32; i++)
|
|
|
|
{
|
|
|
|
int ic, iw, ih, ww, hh;
|
|
|
|
|
|
|
|
ic = ((j * 32) + i) % 13;
|
|
|
|
iw = imlib_image_get_width(im_ic[ic]);
|
|
|
|
ih = imlib_image_get_height(im_ic[ic]);
|
|
|
|
ww = iw;
|
|
|
|
hh = ih;
|
|
|
|
up = imlib_update_append_rect(up, x + (i * iw * 2),
|
|
|
|
y + (j * ih * 2), ww, hh);
|
|
|
|
up = imlib_update_append_rect(up, px + (i * iw * 2),
|
|
|
|
py + (j * ih * 2), ww, hh);
|
|
|
|
imlib_blend_image_onto_image(im_ic[ic], im,
|
|
|
|
aa, blend, 0,
|
|
|
|
0, 0, iw, ih,
|
|
|
|
x + (i * iw * 2),
|
|
|
|
y + (j * ih * 2),
|
|
|
|
ww, hh,
|
|
|
|
NULL, IMLIB_OP_COPY);
|
|
|
|
}
|
1999-09-12 18:56:57 -07:00
|
|
|
}
|
|
|
|
}
|
1999-09-18 23:28:54 -07:00
|
|
|
imlib_blend_image_onto_image(im_sh1, im,
|
1999-09-12 18:56:57 -07:00
|
|
|
aa, blend, 0,
|
|
|
|
0, 0, 50, 50,
|
1999-09-13 21:21:29 -07:00
|
|
|
0, 0, 50, 50, NULL, IMLIB_OP_COPY);
|
1999-09-26 14:36:51 -07:00
|
|
|
up = imlib_update_append_rect(up, 0, 0, 50, 50);
|
1999-09-12 18:56:57 -07:00
|
|
|
imlib_blend_image_onto_image(im_sh2, im,
|
|
|
|
aa, blend, 0,
|
|
|
|
0, 0, 50, 50,
|
1999-09-13 21:21:29 -07:00
|
|
|
50, 0, w - 50, 50, NULL, IMLIB_OP_COPY);
|
1999-09-26 14:36:51 -07:00
|
|
|
up = imlib_update_append_rect(up, 50, 0, w - 50, 50);
|
1999-09-12 18:56:57 -07:00
|
|
|
imlib_blend_image_onto_image(im_sh3, im,
|
|
|
|
aa, blend, 0,
|
|
|
|
0, 0, 50, 50,
|
1999-09-13 21:21:29 -07:00
|
|
|
0, 50, 50, h - 50, NULL, IMLIB_OP_COPY);
|
1999-09-26 14:36:51 -07:00
|
|
|
up = imlib_update_append_rect(up, 0, 50, 50, h - 50);
|
1999-09-29 10:25:52 -07:00
|
|
|
up = imlib_updates_merge_for_rendering(up, w, h);
|
1999-09-26 14:36:51 -07:00
|
|
|
imlib_render_image_updates_on_drawable(im, up, disp, win, vis, cm,
|
|
|
|
depth, dith, 0, 0, NULL);
|
|
|
|
if ((px != x) || (py != y))
|
|
|
|
{
|
|
|
|
Imlib_Updates u;
|
|
|
|
|
|
|
|
u = up;
|
|
|
|
while (u)
|
|
|
|
{
|
|
|
|
int ux, uy, uw, uh;
|
|
|
|
|
|
|
|
imlib_updates_get_coordinates(u, &ux, &uy, &uw, &uh);
|
|
|
|
imlib_blend_image_onto_image(im_bg, im,
|
|
|
|
0, 0, 0,
|
|
|
|
ux, uy, uw, uh,
|
|
|
|
ux, uy, uw, uh,
|
|
|
|
NULL, IMLIB_OP_COPY);
|
|
|
|
u = imlib_updates_get_next(u);
|
|
|
|
}
|
|
|
|
}
|
1999-09-29 10:25:52 -07:00
|
|
|
#if 0
|
1999-09-26 14:36:51 -07:00
|
|
|
{
|
|
|
|
Imlib_Updates up2;
|
|
|
|
GC gc;
|
|
|
|
XGCValues gcv;
|
|
|
|
|
|
|
|
gc = XCreateGC(disp, win, 0, &gcv);
|
|
|
|
XSetForeground(disp, gc, 0xffff);
|
|
|
|
up2 = up;
|
|
|
|
while(up2)
|
|
|
|
{
|
|
|
|
int ux, uy, uw, uh;
|
|
|
|
|
|
|
|
imlib_updates_get_coordinates(up2, &ux, &uy, &uw, &uh);
|
|
|
|
XDrawRectangle(disp, win, gc, ux, uy, uw - 1, uh - 1);
|
|
|
|
up2 = imlib_updates_get_next(up2);
|
|
|
|
}
|
|
|
|
XFreeGC(disp, gc);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
imlib_updates_free(up);
|
|
|
|
up = NULL;
|
1999-09-12 18:56:57 -07:00
|
|
|
imlib_free_image(im_sh1);
|
|
|
|
imlib_free_image(im_sh2);
|
|
|
|
imlib_free_image(im_sh3);
|
|
|
|
imlib_free_image(im_ic[0]);
|
|
|
|
imlib_free_image(im_ic[1]);
|
|
|
|
imlib_free_image(im_ic[2]);
|
|
|
|
imlib_free_image(im_ic[3]);
|
1999-09-08 10:27:40 -07:00
|
|
|
}
|
|
|
|
}
|
1999-08-01 15:14:11 -07:00
|
|
|
else
|
|
|
|
{
|
1999-09-08 10:27:40 -07:00
|
|
|
for (i = 0; i < w; i++)
|
|
|
|
{
|
|
|
|
imlib_render_image_on_drawable_at_size(im, disp, win, vis,
|
1999-09-10 11:11:47 -07:00
|
|
|
cm,
|
1999-09-08 10:27:40 -07:00
|
|
|
depth,
|
|
|
|
aa, dith, blend,
|
|
|
|
0, 0,
|
|
|
|
w, h,
|
1999-09-13 21:21:29 -07:00
|
|
|
NULL, IMLIB_OP_COPY);
|
1999-09-08 10:27:40 -07:00
|
|
|
pixels += w * h;
|
|
|
|
}
|
1999-08-01 15:14:11 -07:00
|
|
|
}
|
|
|
|
gettimeofday(&timev,NULL);
|
|
|
|
sec2=(int)timev.tv_sec; /* and stores it so we can time outselves */
|
|
|
|
usec2=(int)timev.tv_usec; /* we will use this to vary speed of rot */
|
|
|
|
printf("done\n");
|
|
|
|
i = sec2 - sec1;
|
|
|
|
j = usec2 - usec1;
|
|
|
|
while (j < 0)
|
|
|
|
{
|
|
|
|
i++;
|
|
|
|
j += 1000000;
|
|
|
|
}
|
|
|
|
sec = (double)i + ((double)j / 1000000);
|
|
|
|
printf("%3.3f sec\n", sec);
|
|
|
|
printf("%3.3f Mpixels / sec\n", (double)(pixels) / (sec * 1000000));
|
|
|
|
return 0;
|
|
|
|
}
|
1999-09-08 10:27:40 -07:00
|
|
|
#else
|
1999-08-05 19:08:36 -07:00
|
|
|
int main (int argc, char **argv)
|
|
|
|
{
|
|
|
|
Window win;
|
|
|
|
/*
|
|
|
|
Pixmap back, scratch;
|
|
|
|
GC gc;
|
|
|
|
*/
|
|
|
|
XGCValues gcv;
|
|
|
|
Imlib_Image *im = NULL, tmp, grab;
|
|
|
|
int x, y, start, i, w, h;
|
|
|
|
Visual *vis;
|
|
|
|
int depth;
|
|
|
|
int dith = 0;
|
|
|
|
int blend = 0;
|
|
|
|
DATA32 *data1, *data2;
|
|
|
|
Colormap cm;
|
|
|
|
|
|
|
|
start = 1;
|
|
|
|
x = 0;
|
|
|
|
y = 0;
|
|
|
|
for (i = 1; i < argc; i++)
|
|
|
|
{
|
|
|
|
if (!strcmp(argv[i], "-blend"))
|
|
|
|
blend = 1;
|
|
|
|
else if (!strcmp(argv[i], "-dither"))
|
|
|
|
dith = 1;
|
|
|
|
else if (!strcmp(argv[i], "-pos"))
|
|
|
|
{
|
|
|
|
i++;
|
|
|
|
x = atoi(argv[i++]);
|
|
|
|
y = atoi(argv[i]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
start = i;
|
|
|
|
i = argc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
disp = XOpenDisplay(NULL);
|
|
|
|
printf("load\n");
|
|
|
|
im = malloc(sizeof(Imlib_Image) * (argc - start));
|
|
|
|
for (i = start; i < argc; i++)
|
|
|
|
im[i - start] = imlib_load_image(argv[i]);
|
|
|
|
win = DefaultRootWindow(disp);
|
|
|
|
vis = DefaultVisual(disp, DefaultScreen(disp));
|
|
|
|
depth = DefaultDepth(disp, DefaultScreen(disp));
|
|
|
|
cm = DefaultColormap(disp, DefaultScreen(disp));
|
|
|
|
__imlib_SetMaxXImageCount(disp, 0);
|
|
|
|
XSync(disp, False);
|
|
|
|
printf("init\n");
|
1999-08-28 11:18:29 -07:00
|
|
|
w = imlib_image_get_width(im[0]);
|
|
|
|
h = imlib_image_get_height(im[0]);
|
1999-08-05 19:08:36 -07:00
|
|
|
/*
|
|
|
|
gc = XCreateGC(disp, win, 0, &gcv);
|
|
|
|
back = XCreatePixmap(disp, win, w, h, depth);
|
|
|
|
scratch = XCreatePixmap(disp, win, w, h, depth);
|
|
|
|
XCopyArea(disp, win, back, gc, x, y, w, h, 0, 0);
|
|
|
|
XCopyArea(disp, back, scratch, gc, 0, 0, w, h, 0, 0);
|
|
|
|
*/
|
|
|
|
grab = imlib_create_image_from_drawable(disp, win, 0, vis, cm, depth,
|
|
|
|
x, y, w, h);
|
|
|
|
tmp = imlib_clone_image(grab);
|
|
|
|
|
1999-08-28 11:18:29 -07:00
|
|
|
data1 = imlib_image_get_data(grab);
|
|
|
|
data2 = imlib_image_get_data(tmp);
|
1999-08-05 19:08:36 -07:00
|
|
|
|
|
|
|
printf("animate\n");
|
|
|
|
for(;;)
|
|
|
|
{
|
|
|
|
for (i = 0; i < (argc - start); i++)
|
|
|
|
{
|
1999-09-08 10:27:40 -07:00
|
|
|
/* imlib_blend_image_onto_image(im[i], tmp, 0, 0, w, h, 0, 0, w, h);*/
|
|
|
|
imlib_render_image_on_drawable(im[i], disp, win, vis, cm, depth,
|
1999-09-01 10:36:17 -07:00
|
|
|
dith, 0,
|
1999-08-05 19:08:36 -07:00
|
|
|
x, y);
|
|
|
|
memcpy(data2, data1, w * h *sizeof(DATA32));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
1999-09-08 10:27:40 -07:00
|
|
|
#endif
|