diff --git a/configure.in b/configure.in index 3d3e046..1725e2f 100644 --- a/configure.in +++ b/configure.in @@ -49,5 +49,5 @@ fi LTLIBOBJS=`echo "$LIBOBJS" | sed 's,.o ,.lo ,g;s,.o$,.lo,'` AC_SUBST(LTLIBOBJS) -AC_OUTPUT(Makefile loaders/Makefile src/Makefile test/Makefile, +AC_OUTPUT(Makefile loaders/Makefile src/Makefile test/Makefil demo/Makefile, [test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h]) diff --git a/demo/Makefile.am b/demo/Makefile.am new file mode 100644 index 0000000..4127c07 --- /dev/null +++ b/demo/Makefile.am @@ -0,0 +1,18 @@ +## Process this file with automake to produce Makefile.in + +AUTOMAKE_OPTIONS = 1.4 foreign + +# A list of all the files in the current directory which can be regenerated +MAINTAINERCLEANFILES = Makefile.in + +LDFLAGS = -L/usr/X11R6/lib +INCLUDES = -I/usr/X11R6/include -I$(top_srcdir)/libltdl \ + $(X_CFLAGS) -I$(prefix)/include -I$(includedir) \ + -I. -I$(top_srcdir) -I$(top_srcdir)/src \ + -I$(top_srcdir)/loaders + +bin_PROGRAMS = imlib2_view +imlib2_view_SOURCES = view.c +imlib2_view_LDADD = @DLLDFLAGS@ $(top_builddir)/libltdl/libltdlc.la \ + -lX11 -lXext -lttf -lImlib2 + diff --git a/demo/view.c b/demo/view.c new file mode 100644 index 0000000..013afde --- /dev/null +++ b/demo/view.c @@ -0,0 +1,137 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "Imlib2.h" + +Display *disp; +Window win; +Pixmap pm; +Visual *vis; +Colormap cm; +int depth; +int image_width = 0, image_height = 0; + +static void +progress(Imlib_Image im, char percent, int update_x, int update_y, + int update_w, int update_h); + +static void +progress(Imlib_Image im, char percent, int update_x, int update_y, + int update_w, int update_h) +{ + static Imlib_Image bg_im = NULL; + + /* first time it's called */ + if (image_width == 0) + { + int x, y, onoff; + + image_width = imlib_image_get_width(im); + image_height = imlib_image_get_height(im); + pm = XCreatePixmap(disp, win, image_width, image_height, depth); + bg_im = imlib_create_image(image_width, image_height); + for (y = 0; y < image_height; y += 8) + { + onoff = y & 0x1; + for (x = 0; x < image_width; x += 8) + { + Imlib_Color col; + + if (onoff) + { + col.red = 144; + col.green = 144; + col.blue = 144; + col.alpha = 255; + } + else + { + col.red = 100; + col.green = 100; + col.blue = 100; + col.alpha = 255; + } + imlib_image_fill_rectangle(bg_im, x, y, 8, 8, &col, + IMLIB_OP_COPY); + onoff++; + if (onoff == 2) + onoff = 0; + } + } + imlib_render_image_part_on_drawable_at_size(bg_im, + disp, pm, vis, cm, depth, + 0, 1, 0, + 0, 0, + image_width, image_height, + 0, 0, + image_width, image_height, + NULL, IMLIB_OP_COPY); + XSetWindowBackgroundPixmap(disp, win, pm); + XResizeWindow(disp, win, image_width, image_height); + XMapWindow(disp, win); + XSync(disp, False); + } +/* + imlib_render_image_part_on_drawable_at_size(bg_im, + disp, pm, vis, cm, depth, + 0, 1, 0, + update_x, update_y, + update_w, update_h, + update_x, update_y, + update_w, update_h, + NULL, IMLIB_OP_COPY);*/ + XSetWindowBackgroundPixmap(disp, win, pm); + XClearArea(disp, win, update_x, update_y, update_w, update_h, False); +} + +int +main (int argc, char **argv) +{ + Imlib_Image *im = NULL; + char *file = NULL; + + file = argv[1]; + disp = XOpenDisplay(NULL); + vis = DefaultVisual(disp, DefaultScreen(disp)); + depth = DefaultDepth(disp, DefaultScreen(disp)); + cm = DefaultColormap(disp, DefaultScreen(disp)); + win = XCreateSimpleWindow(disp, DefaultRootWindow(disp), 0, 0, + 10, 10, 0, 0, 0); + XSelectInput(disp, win, ButtonPressMask | ButtonReleaseMask | + ButtonMotionMask | PointerMotionMask); + im = imlib_load_image_with_progress_callback(file, progress, 0); + if (!im) + { + fprintf(stderr, "Image format not available\n"); + exit(0); + } + for(;;) + { + int x, y, b; + XEvent ev; + + XNextEvent(disp, &ev); + switch (ev.type) + { + case Expose: + break; + case ButtonRelease: + exit(0); + break; + case MotionNotify: + x = ev.xmotion.x; + y = ev.xmotion.y; + default: + break; + + } + } + return 0; +} diff --git a/src/rgbadraw.c b/src/rgbadraw.c index f126804..c82f3a2 100644 --- a/src/rgbadraw.c +++ b/src/rgbadraw.c @@ -1152,7 +1152,7 @@ __imlib_draw_filled_box(ImlibImage *im, int x, int y, int w, int h, int yy, xx, tmp; DATA32 *p; DATA8 nr, ng, nb, rr, gg, bb, aa, na; - + if (x < 0) { w += x; @@ -1180,7 +1180,7 @@ __imlib_draw_filled_box(ImlibImage *im, int x, int y, int w, int h, case OP_COPY: for (yy = 0; yy < h; yy++) { - p = im->data + (y * im->w) + x; + p = im->data + ((y + yy) * im->w) + x; for (xx = 0; xx < w; xx++) { BLEND(r, g, b, a, *p); @@ -1191,7 +1191,7 @@ __imlib_draw_filled_box(ImlibImage *im, int x, int y, int w, int h, case OP_ADD: for (yy = 0; yy < h; yy++) { - p = im->data + (y * im->w) + x; + p = im->data + ((y + yy) * im->w) + x; for (xx = 0; xx < w; xx++) { BLEND_ADD(r, g, b, a, *p); @@ -1202,7 +1202,7 @@ __imlib_draw_filled_box(ImlibImage *im, int x, int y, int w, int h, case OP_SUBTRACT: for (yy = 0; yy < h; yy++) { - p = im->data + (y * im->w) + x; + p = im->data + ((y + yy) * im->w) + x; for (xx = 0; xx < w; xx++) { BLEND_SUB(r, g, b, a, *p); @@ -1213,7 +1213,7 @@ __imlib_draw_filled_box(ImlibImage *im, int x, int y, int w, int h, case OP_RESHADE: for (yy = 0; yy < h; yy++) { - p = im->data + (y * im->w) + x; + p = im->data + ((y + yy) * im->w) + x; for (xx = 0; xx < w; xx++) { BLEND_RE(r, g, b, a, *p);