forked from old/legacy-imlib2
oops - fix that filled rect drawing code
SVN revision: 1139
This commit is contained in:
parent
961c5b6447
commit
2c99df3cd7
|
@ -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])
|
||||
|
|
|
@ -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
|
||||
|
|
@ -0,0 +1,137 @@
|
|||
#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>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#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;
|
||||
}
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue