From edf5558a665707d19984c957d2ffdf6d902e2d49 Mon Sep 17 00:00:00 2001 From: Carsten Haitzler Date: Tue, 7 Dec 1999 18:20:56 +0000 Subject: [PATCH] fixe view to compile & work SVN revision: 1537 --- demo/Makefile.am | 5 --- demo/blend.c | 104 ------------------------------------------ demo/view.c | 114 ++++++++++++++++++++++------------------------- 3 files changed, 53 insertions(+), 170 deletions(-) delete mode 100644 demo/blend.c diff --git a/demo/Makefile.am b/demo/Makefile.am index 4f854c2..6e0f7b4 100644 --- a/demo/Makefile.am +++ b/demo/Makefile.am @@ -15,8 +15,3 @@ bin_PROGRAMS = imlib2_view imlib2_blend imlib2_view_SOURCES = view.c imlib2_view_LDADD = @DLLDFLAGS@ $(top_builddir)/libltdl/libltdlc.la \ -lX11 -lXext -lttf -lImlib2 - -imlib2_blend_SOURCES = blend.c -imlib2_blend_LDADD = @DLLDFLAGS@ $(top_builddir)/libltdl/libltdlc.la \ - -lX11 -lXext -lttf -lImlib2 - diff --git a/demo/blend.c b/demo/blend.c deleted file mode 100644 index 4a82313..0000000 --- a/demo/blend.c +++ /dev/null @@ -1,104 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "Imlib2.h" - -Display *disp; -Window win; -Pixmap pm = 0; -Visual *vis; -Colormap cm; -int depth; -int image_width = 0, image_height = 0; -Imlib_Image im = NULL; -Imlib_Image bg_im = NULL; -Imlib_Image fog1_im = NULL; -Imlib_Image fog2_im = NULL; -Imlib_Image logo_im = NULL; -Imlib_Image fog3_im = NULL; -Imlib_Image fog4_im = NULL; - -int -main (int argc, char **argv) -{ - int x1, x2, x3, x4; - if (argc < 2) - return 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); - bg_im = imlib_load_image(argv[1]); - image_width = imlib_image_get_width(bg_im); - image_height = imlib_image_get_height(bg_im); - XResizeWindow(disp, win, image_width, image_height); - XMapWindow(disp, win); - XSync(disp, False); - im = imlib_create_image(image_width, image_height); - fog1_im = imlib_load_image(argv[2]); - fog2_im = imlib_load_image(argv[3]); - logo_im = imlib_load_image(argv[4]); - fog3_im = imlib_load_image(argv[5]); - fog4_im = imlib_load_image(argv[6]); - - imlib_image_tile_horizontal(fog1_im); - imlib_image_tile_horizontal(fog2_im); - imlib_image_tile_horizontal(fog3_im); - imlib_image_tile_horizontal(fog4_im); - - x1 = 0; - x2 = 0; - x3 = 0; - x4 = 0; - for(;;) - { - imlib_blend_image_onto_image(bg_im, im, 0, 0, 0, 0, 0, image_width, image_height, 0, 0, image_width, image_height, NULL, IMLIB_OP_COPY); - imlib_blend_image_onto_image(fog1_im, im, 0, 1, 0, 0, 0, image_width, image_height, - x1, 0, image_width, image_height, NULL, IMLIB_OP_COPY); - imlib_blend_image_onto_image(fog1_im, im, 0, 1, 0, 0, 0, image_width, image_height, image_width - x1, 0, image_width, image_height, NULL, IMLIB_OP_COPY); -/* - imlib_blend_image_onto_image(fog2_im, im, 0, 1, 0, 0, 0, image_width, image_height, - x2, 0, image_width, image_height, NULL, IMLIB_OP_COPY); - imlib_blend_image_onto_image(fog2_im, im, 0, 1, 0, 0, 0, image_width, image_height, image_width - x2, 0, image_width, image_height, NULL, IMLIB_OP_COPY); - */ - imlib_blend_image_onto_image(logo_im, im, 0, 1, 0, 0, 0, image_width, image_height, 0, 0, image_width, image_height, NULL, IMLIB_OP_COPY); -/* - imlib_blend_image_onto_image(fog3_im, im, 0, 1, 0, 0, 0, image_width, image_height, - x3, 0, image_width, image_height, NULL, IMLIB_OP_COPY); - imlib_blend_image_onto_image(fog3_im, im, 0, 1, 0, 0, 0, image_width, image_height, image_width - x3, 0, image_width, image_height, NULL, IMLIB_OP_COPY); - */ - imlib_blend_image_onto_image(fog4_im, im, 0, 1, 0, 0, 0, image_width, image_height, - x4, 0, image_width, image_height, NULL, IMLIB_OP_COPY); - imlib_blend_image_onto_image(fog4_im, im, 0, 1, 0, 0, 0, image_width, image_height, image_width - x4, 0, image_width, image_height, NULL, IMLIB_OP_COPY); - imlib_render_image_part_on_drawable_at_size(im, - disp, win, vis, cm, depth, - 0, 1, 0, - 0, 0, image_width, image_height, - 0, 0, image_width, image_height, - NULL, IMLIB_OP_COPY); - x1 -=1; - x2 -=2; - x3 -=4; - x4 -=8; - if (x1 < 0) - x1 += image_width; - if (x2 < 0) - x2 += image_width; - if (x3 < 0) - x3 += image_width; - if (x4 < 0) - x4 += image_width; - } - return 0; -} diff --git a/demo/view.c b/demo/view.c index 297f14e..c2d3fc3 100644 --- a/demo/view.c +++ b/demo/view.c @@ -31,73 +31,58 @@ progress(Imlib_Image im, char percent, int update_x, int update_y, int update_w, int update_h) { /* first time it's called */ + imlib_context_set_drawable(pm); + imlib_context_set_anti_alias(0); + imlib_context_set_dither(0); + imlib_context_set_blend(0); if (image_width == 0) { int x, y, onoff; - image_width = imlib_image_get_width(im); - image_height = imlib_image_get_height(im); + imlib_context_set_image(im); + image_width = imlib_image_get_width(); + image_height = imlib_image_get_height(); if (pm) XFreePixmap(disp, pm); pm = XCreatePixmap(disp, win, image_width, image_height, depth); if (bg_im) - imlib_free_image_and_decache(bg_im); + { + imlib_context_set_image(bg_im); + imlib_free_image_and_decache(); + } bg_im = imlib_create_image(image_width, image_height); + imlib_context_set_image(bg_im); for (y = 0; y < image_height; y += 8) { onoff = (y / 8) & 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; - } + imlib_context_set_color(144, 144, 144, 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); + imlib_context_set_color(100, 100, 100, 255); + imlib_image_fill_rectangle(x, y, 8, 8); onoff++; if (onoff == 2) onoff = 0; } } - imlib_render_image_part_on_drawable_at_size(bg_im, - disp, pm, vis, cm, depth, - 0, 0, 0, - 0, 0, - image_width, image_height, - 0, 0, - image_width, image_height, - NULL, IMLIB_OP_COPY); + imlib_render_image_part_on_drawable_at_size(0, 0, image_width, image_height, + 0, 0, image_width, image_height); XSetWindowBackgroundPixmap(disp, win, pm); XResizeWindow(disp, win, image_width, image_height); XMapWindow(disp, win); XSync(disp, False); } - imlib_blend_image_onto_image(im, bg_im, 0, 1, 0, + imlib_blend_image_onto_image(im, 0, update_x, update_y, update_w, update_h, update_x, update_y, - update_w, update_h, - NULL, IMLIB_OP_COPY); - 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); + imlib_render_image_part_on_drawable_at_size(update_x, update_y, update_w, update_h, update_x, update_y, - update_w, update_h, - NULL, IMLIB_OP_COPY); + update_w, update_h); XSetWindowBackgroundPixmap(disp, win, pm); XClearArea(disp, win, update_x, update_y, update_w, update_h, False); XFlush(disp); @@ -122,7 +107,12 @@ main (int argc, char **argv) 10, 10, 0, 0, 0); XSelectInput(disp, win, ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | PointerMotionMask); - im = imlib_load_image_with_progress_callback(file, progress, 10); + imlib_context_set_display(disp); + imlib_context_set_visual(vis); + imlib_context_set_colormap(cm); + imlib_context_set_progress_function(progress); + imlib_context_set_progress_granularity(10); + im = imlib_load_image(file); while (!im) { no++; @@ -130,7 +120,8 @@ main (int argc, char **argv) exit(0); file = argv[no]; image_width = 0; - im = imlib_load_image_with_progress_callback(file, progress, 10); + im = imlib_load_image(file); + imlib_context_set_image(im); } if (!im) { @@ -143,7 +134,6 @@ main (int argc, char **argv) XEvent ev; static int zoom_mode = 0, zx, zy; static double zoom = 1.0; - char aa = 0, dith = 0; struct timeval tval; fd_set fdset; double t1; @@ -163,13 +153,11 @@ main (int argc, char **argv) zoom_mode = 1; zx = x; zy = y; + imlib_context_set_drawable(pm); + imlib_context_set_image(bg_im); 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); + (0, 0, image_width, image_height, + 0, 0, image_width, image_height); XSetWindowBackgroundPixmap(disp, win, pm); XClearWindow(disp, win); } @@ -189,8 +177,9 @@ main (int argc, char **argv) image_width = 0; zoom = 1.0; zoom_mode = 0; - imlib_free_image_and_decache(im); - im = imlib_load_image_with_progress_callback(file, progress, 10); + imlib_context_set_image(im); + imlib_free_image_and_decache(); + im = imlib_load_image(file); while (!im) { no++; @@ -198,8 +187,9 @@ main (int argc, char **argv) exit(0); file = argv[no]; image_width = 0; - im = imlib_load_image_with_progress_callback(file, progress, 10); + im = imlib_load_image(file); } + imlib_context_set_image(im); } if (b == 2) { @@ -210,8 +200,9 @@ main (int argc, char **argv) image_width = 0; zoom = 1.0; zoom_mode = 0; - imlib_free_image_and_decache(im); - im = imlib_load_image_with_progress_callback(file, progress, 10); + imlib_context_set_image(im); + imlib_free_image_and_decache(); + im = imlib_load_image(file); while (!im) { no--; @@ -219,8 +210,9 @@ main (int argc, char **argv) no = 1; file = argv[no]; image_width = 0; - im = imlib_load_image_with_progress_callback(file, progress, 10); + im = imlib_load_image(file); } + imlib_context_set_image(im); } break; case MotionNotify: @@ -262,12 +254,12 @@ main (int argc, char **argv) sw = image_width; sh = image_height; } + imlib_context_set_anti_alias(1); + imlib_context_set_dither(1); + imlib_context_set_blend(0); + imlib_context_set_image(bg_im); imlib_render_image_part_on_drawable_at_size - (bg_im, - disp, pm, vis, cm, depth, - aa, dith, 0, - sx, sy, sw, sh, dx, dy, dw, dh, - NULL, IMLIB_OP_COPY); + (sx, sy, sw, sh, dx, dy, dw, dh); XSetWindowBackgroundPixmap(disp, win, pm); XClearWindow(disp, win); XFlush(disp); @@ -322,12 +314,12 @@ main (int argc, char **argv) sw = image_width; sh = image_height; } + imlib_context_set_anti_alias(1); + imlib_context_set_dither(1); + imlib_context_set_blend(0); + imlib_context_set_image(bg_im); imlib_render_image_part_on_drawable_at_size - (bg_im, - disp, pm, vis, cm, depth, - 1, 1, 0, - sx, sy, sw, sh, dx, dy, dw, dh, - NULL, IMLIB_OP_COPY); + (sx, sy, sw, sh, dx, dy, dw, dh); XSetWindowBackgroundPixmap(disp, win, pm); XClearWindow(disp, win); XFlush(disp);