summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Jennings <mej@kainx.org>2003-07-13 01:09:17 +0000
committerMichael Jennings <mej@kainx.org>2003-07-13 01:09:17 +0000
commit7c65468d34b2bc7b8a32e86ae6e58c54f45b5cfa (patch)
tree4fd53d75d5b013d632c293da8c5ed71112c50114
parent0896467998fa73fcbad683aeb364c845ba4b2cbd (diff)
downloadimlib2-7c65468d34b2bc7b8a32e86ae6e58c54f45b5cfa.tar.gz
Sat Jul 12 21:06:14 EDT 2003
(KainX) Patch from Yuri Hudobin <glassy_ape@users.sourceforge.net> for Freetype2 support. SVN revision: 7158
-rw-r--r--AUTHORS1
-rw-r--r--ChangeLog8
-rw-r--r--TODO4
-rw-r--r--configure.ac84
-rw-r--r--configure.in81
-rw-r--r--demo/imconvert.c130
-rw-r--r--demo/view.c564
-rw-r--r--filters/filter_bumpmap.c424
-rw-r--r--filters/filter_colormod.c332
-rw-r--r--filters/filter_test.c159
-rw-r--r--imlib2.pc.in2
-rw-r--r--loaders/loader_argb.c252
-rw-r--r--loaders/loader_bmp.c1206
-rw-r--r--loaders/loader_gif.c362
-rw-r--r--loaders/loader_gzbz2.c20
-rw-r--r--loaders/loader_jpeg.c412
-rw-r--r--loaders/loader_png.c553
-rw-r--r--loaders/loader_pnm.c1409
-rw-r--r--loaders/loader_tga.c1058
-rw-r--r--loaders/loader_tiff.c626
-rw-r--r--loaders/loader_xpm.c1060
-rw-r--r--src/Makefile.am12
-rw-r--r--src/api.c3349
-rw-r--r--src/blend.c1185
-rw-r--r--src/color.c841
-rw-r--r--src/color_helpers.c340
-rw-r--r--src/colormod.c266
-rw-r--r--src/context.c208
-rw-r--r--src/draw.c63
-rw-r--r--src/dynamic_filters.c221
-rw-r--r--src/file.c462
-rw-r--r--src/filter.c249
-rw-r--r--src/font.h311
-rw-r--r--src/grab.c1059
-rw-r--r--src/grad.c841
-rw-r--r--src/image.c1322
-rw-r--r--src/rend.c780
-rw-r--r--src/rgba.c5726
-rw-r--r--src/rgbadraw.c3723
-rw-r--r--src/rotate.c723
-rw-r--r--src/scale.c2658
-rw-r--r--src/script.c389
-rw-r--r--src/updates.c233
-rw-r--r--src/ximage.c425
-rw-r--r--test/bmtest.c132
-rw-r--r--test/color_spaces.c160
-rw-r--r--test/imlib2_test.c434
-rw-r--r--test/main.c2427
-rw-r--r--test/polytest.c106
49 files changed, 19208 insertions, 18184 deletions
diff --git a/AUTHORS b/AUTHORS
index a194e47..148057a 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -23,3 +23,4 @@ Lightman (Franz Marini) <marini@pcmenelao.mi.infn.it>
Mark Bainter <mark-e@cymry.org>
Brian Lindholm <lindholm@aol.com>
Renchi Raju <renchi@pooh.tam.uiuc.edu>
+Yuri Hudobin <glassy_ape@users.sourceforge.net>
diff --git a/ChangeLog b/ChangeLog
index 237f46e..0753478 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2974,3 +2974,11 @@ Thu Apr 3 20:48:27 EST 2003
Minor Makefile.am tweak which apparently helps portability.
_______________________________________________
+
+Sat Jul 12 21:06:14 EDT 2003
+(KainX)
+
+Patch from Yuri Hudobin <glassy_ape@users.sourceforge.net>
+for Freetype2 support.
+
+_______________________________________________
diff --git a/TODO b/TODO
index 95dae4e..e754229 100644
--- a/TODO
+++ b/TODO
@@ -1,6 +1,6 @@
* line code doesnt draw nice liens when clipping - fix
* filled polygons can break fill bounds on corner cases - fix
-* imlib2 needs freetype 1.x - shoudl graduate to 2.x
+* go thru TODOs and FIXMEs
-evas2 has fixed code for these 3 in it that work just fine. just need to
+evas2 has fixed code for these 2 in it that work just fine. just need to
port over (should be fairly easy).
diff --git a/configure.ac b/configure.ac
index cc161de..937488a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -7,14 +7,30 @@ AM_INIT_AUTOMAKE(imlib2, 1.0.7)
AM_CONFIG_HEADER(config.h)
-freetype_libs=-lttf
-AC_ARG_WITH(ttf,
- [ --with-ttf=DIR use freetype rooted at <DIR>],
- [freetype_libs="$freetype_libs -L$withval/lib"
- freetype_includes="-I$withval/include"
- CPPFLAGS="$CPPFLAGS $freetype_includes"
- LIBS="$LIBS $freetype_libs"
- ])
+dnl here was freetype stuff (1)
+
+# check for freetype
+
+AC_ARG_WITH(freetype-config,
+ [ --with-freetype-config=FREETYPE_CONFIG use freetype-config specified ],
+ [
+ PROG_CONFIG=$withval;
+ echo "using "$PROG_CONFIG" for freetype-config";
+ ],[
+ PROG="freetype-config";
+ AC_PATH_PROG(PROG_CONFIG, $PROG, "", $PATH)
+ ])
+if [ test -z $PROG_CONFIG ]; then
+ echo $PROG " is not in your \$PATH. Please ensure it is.";
+ echo "You may need to install the librarya and/or development packages";
+ echo "that contain this configure-script.";
+ echo "FATAL ERROR. ABORT.";
+ exit -1;
+fi
+freetype_cflags=`$PROG_CONFIG --cflags`
+freetype_libs=`$PROG_CONFIG --libs`
+
+dnl /here was freetype stuff (1)
mmx=no
AC_ARG_ENABLE(mmx,[ --enable-mmx attempt compiling using mmx assembly [default=yes]],
@@ -138,47 +154,12 @@ LTLIBOBJS=`echo "$LIB@&t@OBJS" |
sed 's,\.[[^.]]* ,.lo ,g;s,\.[[^.]]*$,.lo,'`
AC_SUBST(LTLIBOBJS)
-AC_CHECK_LIB(ttf, TT_Init_FreeType, TTF_LIBS=-lttf, [
-echo ""
-echo "ERROR: Imlib 2 needs a system with libttf.so (TrueType Font Library)"
-echo "You can obtain it from:"
-echo "ftp://ftp.enlightenment.org/pub/enlightenment/"
-echo "ftp://www.rasterman.com/pub/enlightenment/"
-echo "You can also obtain it from:"
-echo "http://www.freetype.org/"
-echo "You can obtain some truetype fonts from:"
-echo "http://voyager.cns.ohiou.edu/~sadkins/web_library/fonts/font_archive/"
-echo ""
-AC_MSG_ERROR([Fatal Error: no FreeType detected.])], -lm)
-
-AC_CHECK_HEADERS(freetype.h freetype/freetype.h freetype1/freetype/freetype.h, [ break])
-AC_CHECK_HEADER(freetype.h, [ ftype=yes ], [ ftype=no ])
-AC_CHECK_HEADER(freetype/freetype.h, [ ftype_ftype=yes ], [ ftype_ftype=no ])
-AC_CHECK_HEADER(freetype1/freetype/freetype.h, [ ftype1_ftype=yes ], [ ftype1_ftype=no ])
-
-if test x$ftype = xno; then
-if test x$ftype_ftype = xno; then
-if test x$ftype1_ftype = xno; then
-echo ""
-echo "ERROR: freetype.h not found in freetype.h or freetype/freetype.h include"
-echo "paths. (ie /usr/include, /usr/local/include etc.). You need the freetype"
-echo "header files to build Imlib 2. This may mean you have to install the"
-echo "freetype-devel packages for your distribution or if all else fails"
-echo "find the source for freetype and install that somewhere where Imlib 2"
-echo "can find the header files."
-echo ""
-echo "You can obtain it from:"
-echo "ftp://ftp.enlightenment.org/pub/enlightenment/"
-echo "ftp://www.rasterman.com/pub/enlightenment/"
-echo "You can also obtain it from:"
-echo "http://www.freetype.org/"
-echo "You can obtain some truetype fonts from:"
-echo "http://voyager.cns.ohiou.edu/~sadkins/web_library/fonts/font_archive/"
-echo ""
-AC_MSG_ERROR([Fatal Error: no FreeType header files detected.])
-fi
-fi
-fi
+dnl here was freetype headers checking
+
+
+
+dnl /here was freetype headers checking
+
AC_CHECK_LIB(dl, dlopen, dlopen_libs=-ldl)
EXTRA_LIBS="-L/usr/local/lib -L/usr/X11R6/lib"
@@ -323,8 +304,11 @@ AC_SUBST(x_includes)
AC_SUBST(x_ldflags)
AC_SUBST(x_libs)
AC_SUBST(dlopen_libs)
+AC_SUBST(freetype_cflags)
AC_SUBST(freetype_libs)
-AC_SUBST(freetype_includes)
+
+dnl AC_SUBST(freetype_libs)
+dnl AC_SUBST(freetype_includes)
AC_CONFIG_FILES([imlib2-config imlib2.pc Makefile loaders/Makefile src/Makefile test/Makefile \
filters/Makefile demo/Makefile doc/Makefile \
diff --git a/configure.in b/configure.in
index b91c7a0..2c21b9f 100644
--- a/configure.in
+++ b/configure.in
@@ -6,14 +6,28 @@ AM_INIT_AUTOMAKE(imlib2, 1.0.7)
AM_CONFIG_HEADER(config.h)
-freetype_libs=-lttf
-AC_ARG_WITH(ttf,
- [ --with-ttf=DIR use freetype rooted at <DIR>],
- [freetype_libs="$freetype_libs -L$withval/lib"
- freetype_includes="-I$withval/include"
- CPPFLAGS="$CPPFLAGS $freetype_includes"
- LIBS="$LIBS $freetype_libs"
+dnl here was freetype stuff (1)
+
+AC_ARG_WITH(freetype-config,
+ [ --with-freetype-config=FREETYPE_CONFIG use freetype-config specified ],
+ [
+ PROG_CONFIG=$withval;
+ echo "using "$PROG_CONFIG" for freetype-config";
+ ],[
+ PROG="freetype-config";
+ AC_PATH_PROG(PROG_CONFIG, $PROG, "", $PATH)
])
+if [ test -z $PROG_CONFIG ]; then
+ echo $PROG " is not in your \$PATH. Please ensure it is.";
+ echo "You may need to install the librarya and/or development packages";
+ echo "that contain this configure-script.";
+ echo "FATAL ERROR. ABORT.";
+ exit -1;
+fi
+freetype_cflags=`$PROG_CONFIG --cflags`
+freetype_libs=`$PROG_CONFIG --libs`
+
+dnl /here was freetype stuff (1)
mmx=no
AC_ARG_ENABLE(mmx,[ --enable-mmx attempt compiling using mmx assembly [default=yes]],
@@ -120,45 +134,15 @@ AC_SUBST(X_OBJS)
LTLIBOBJS=`echo "$LIBOBJS" | sed 's,.o ,.lo ,g;s,.o$,.lo,'`
AC_SUBST(LTLIBOBJS)
-AC_CHECK_LIB(ttf, TT_Init_FreeType, TTF_LIBS=-lttf, [
-echo ""
-echo "ERROR: Imlib 2 needs a system with libttf.so (TrueType Font Library)"
-echo "You can obtain it from:"
-echo "ftp://ftp.enlightenment.org/pub/enlightenment/"
-echo "ftp://www.rasterman.com/pub/enlightenment/"
-echo "You can also obtain it from:"
-echo "http://www.freetype.org/"
-echo ""
-AC_MSG_ERROR([Fatal Error: no FreeType detected.])], -lm)
-
-AC_CHECK_HEADERS(freetype.h freetype/freetype.h freetype1/freetype/freetype.h, [ break])
-AC_CHECK_HEADER(freetype.h, [ ftype=yes ], [ ftype=no ])
-AC_CHECK_HEADER(freetype/freetype.h, [ ftype_ftype=yes ], [ ftype_ftype=no ])
-AC_CHECK_HEADER(freetype1/freetype/freetype.h, [ ftype1_ftype=yes ], [ ftype1_ftype=no ])
-
-if test x$ftype = xno; then
-if test x$ftype_ftype = xno; then
-if test x$ftype1_ftype = xno; then
-echo ""
-echo "ERROR: freetype.h not found in freetype.h or freetype/freetype.h include"
-echo "paths. (ie /usr/include, /usr/local/include etc.). You need the freetype"
-echo "header files to build Imlib 2. This may mean you have to install the"
-echo "freetype-devel packages for your distribution or if all else fails"
-echo "find the source for freetype and install that somewhere where Imlib 2"
-echo "can find the header files."
-echo ""
-echo "You can obtain it from:"
-echo "ftp://ftp.enlightenment.org/pub/enlightenment/"
-echo "ftp://www.rasterman.com/pub/enlightenment/"
-echo "You can also obtain it from:"
-echo "http://www.freetype.org/"
-echo "You can obtain some truetype fonts from:"
-echo "http://voyager.cns.ohiou.edu/~sadkins/web_library/fonts/font_archive/"
-echo ""
-AC_MSG_ERROR([Fatal Error: no FreeType header files detected.])
-fi
-fi
-fi
+
+dnl here was freetype headers checking
+
+
+
+dnl /here was freetype headers checking
+
+
+
AC_CHECK_LIB(dl, dlopen, dlopen_libs=-ldl)
EXTRA_LIBS="-L/usr/local/lib -L/usr/X11R6/lib"
@@ -304,7 +288,10 @@ AC_SUBST(x_ldflags)
AC_SUBST(x_libs)
AC_SUBST(dlopen_libs)
AC_SUBST(freetype_libs)
-AC_SUBST(freetype_includes)
+AC_SUBST(freetype_cflags)
+
+dnl AC_SUBST(freetype_libs)
+dnl AC_SUBST(freetype_includes)
AC_OUTPUT(imlib2-config imlib2.pc Makefile loaders/Makefile src/Makefile test/Makefile \
filters/Makefile demo/Makefile doc/Makefile \
diff --git a/demo/imconvert.c b/demo/imconvert.c
index 6cd70a3..7be8352 100644
--- a/demo/imconvert.c
+++ b/demo/imconvert.c
@@ -12,80 +12,80 @@
#define PROG_NAME "imconvert"
-static void usage(int exit_status);
-
+static void usage(int exit_status);
int
-main(int argc,
- char **argv)
+main(int argc, char **argv)
{
- char *dot, *colon, *n, *oldn;
- Imlib_Image im;
+ char *dot, *colon, *n, *oldn;
+ Imlib_Image im;
- /* I'm just plain being lazy here.. get our basename. */
- for (oldn = n = argv[0]; n; oldn = n) n = strchr(++oldn, '/');
- if (argc < 3 || !strcmp(argv[1], "-h")) usage(-1);
- if((im = imlib_load_image(argv[1])) == NULL)
- {
- fprintf(stderr, PROG_NAME ": Error loading image: %s\n", argv[1]);
- exit(-1);
- }
+ /* I'm just plain being lazy here.. get our basename. */
+ for (oldn = n = argv[0]; n; oldn = n)
+ n = strchr(++oldn, '/');
+ if (argc < 3 || !strcmp(argv[1], "-h"))
+ usage(-1);
+ if ((im = imlib_load_image(argv[1])) == NULL)
+ {
+ fprintf(stderr, PROG_NAME ": Error loading image: %s\n", argv[1]);
+ exit(-1);
+ }
- /* we only care what format the export format is. */
- imlib_context_set_image(im);
- /* hopefully the last one will be the one we want.. */
- dot = strrchr(argv[2], '.');
- /* if there's a format, snarf it and set the format. */
- if (dot && *(dot + 1))
- {
- colon = strrchr(++dot, ':');
- /* if a db file with a key, export it to a db. */
- if (colon && *(colon + 1))
- {
- *colon = 0;
- /* beats having to look for strcasecmp() */
- if (!strncmp(dot, "db", 2) || !strncmp(dot, "dB", 2) ||
- !strncmp(dot, "DB", 2) || !strncmp(dot, "Db", 2))
- {
- imlib_image_set_format("db");
- }
- *colon = ':';
- }
- else
- {
- char *p, *q;
+ /* we only care what format the export format is. */
+ imlib_context_set_image(im);
+ /* hopefully the last one will be the one we want.. */
+ dot = strrchr(argv[2], '.');
+ /* if there's a format, snarf it and set the format. */
+ if (dot && *(dot + 1))
+ {
+ colon = strrchr(++dot, ':');
+ /* if a db file with a key, export it to a db. */
+ if (colon && *(colon + 1))
+ {
+ *colon = 0;
+ /* beats having to look for strcasecmp() */
+ if (!strncmp(dot, "db", 2) || !strncmp(dot, "dB", 2) ||
+ !strncmp(dot, "DB", 2) || !strncmp(dot, "Db", 2))
+ {
+ imlib_image_set_format("db");
+ }
+ *colon = ':';
+ }
+ else
+ {
+ char *p, *q;
- /* max length of 8 for format name. seems reasonable. */
- q = p = malloc(8);
- memset(p, 0, 8);
- strncpy(p, dot, (strlen(dot) < 9) ? strlen(dot) : 8);
- /* Imlib2 only recognizes lowercase formats. convert it. */
- for (q[8] = 0; *q; q++) *q = tolower(*q);
- imlib_image_set_format(p);
- free(p);
- }
- dot--;
- }
- else
- imlib_image_set_format("jpg");
+ /* max length of 8 for format name. seems reasonable. */
+ q = p = malloc(8);
+ memset(p, 0, 8);
+ strncpy(p, dot, (strlen(dot) < 9) ? strlen(dot) : 8);
+ /* Imlib2 only recognizes lowercase formats. convert it. */
+ for (q[8] = 0; *q; q++)
+ *q = tolower(*q);
+ imlib_image_set_format(p);
+ free(p);
+ }
+ dot--;
+ }
+ else
+ imlib_image_set_format("jpg");
- imlib_save_image(argv[2]);
+ imlib_save_image(argv[2]);
- return 0;
+ return 0;
}
-static void usage(int exit_status)
+static void
+usage(int exit_status)
{
- fprintf(exit_status?stderr:stdout,
- PROG_NAME ": Convert images between formats (part of the " \
- "Imlib2 package)\n\n" \
- "Usage: " PROG_NAME " [ -h | <image1> <image2[.fmt]> ]\n" \
- " <fmt> defaults to jpg if not provided; images in " \
- "edb files are supported via\n" \
- " the file.db:/key/name convention.\n" \
- " -h shows this help.\n\n");
-
- exit(exit_status);
-}
+ fprintf(exit_status ? stderr : stdout,
+ PROG_NAME ": Convert images between formats (part of the "
+ "Imlib2 package)\n\n"
+ "Usage: " PROG_NAME " [ -h | <image1> <image2[.fmt]> ]\n"
+ " <fmt> defaults to jpg if not provided; images in "
+ "edb files are supported via\n"
+ " the file.db:/key/name convention.\n"
+ " -h shows this help.\n\n");
-
+ exit(exit_status);
+}
diff --git a/demo/view.c b/demo/view.c
index b47a2f6..1b319bd 100644
--- a/demo/view.c
+++ b/demo/view.c
@@ -13,22 +13,22 @@
#include <errno.h>
#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 bg_im = NULL;
+Display *disp;
+Window win;
+Pixmap pm = 0;
+Visual *vis;
+Colormap cm;
+int depth;
+int image_width = 0, image_height = 0;
+Imlib_Image bg_im = NULL;
static int
-progress(Imlib_Image im, char percent, int update_x, int update_y,
- int update_w, int update_h);
+ progress(Imlib_Image im, char percent, int update_x, int update_y,
+ int update_w, int update_h);
static int
progress(Imlib_Image im, char percent, int update_x, int update_y,
- int update_w, int update_h)
+ int update_w, int update_h)
{
/* first time it's called */
imlib_context_set_drawable(pm);
@@ -37,82 +37,82 @@ progress(Imlib_Image im, char percent, int update_x, int update_y,
imlib_context_set_blend(0);
if (image_width == 0)
{
- int x, y, onoff;
-
- 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);
- imlib_context_set_drawable(pm);
- if (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)
- {
- if (onoff)
- imlib_context_set_color(144, 144, 144, 255);
- else
- 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(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);
+ int x, y, onoff;
+
+ 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);
+ imlib_context_set_drawable(pm);
+ if (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)
+ {
+ if (onoff)
+ imlib_context_set_color(144, 144, 144, 255);
+ else
+ 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(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_context_set_anti_alias(0);
imlib_context_set_dither(0);
imlib_context_set_blend(1);
- imlib_blend_image_onto_image(im, 0,
- update_x, update_y,
- update_w, update_h,
- update_x, update_y,
- update_w, update_h);
+ imlib_blend_image_onto_image(im, 0,
+ update_x, update_y,
+ update_w, update_h,
+ update_x, update_y, update_w, update_h);
imlib_context_set_blend(0);
imlib_render_image_part_on_drawable_at_size(update_x, update_y,
- update_w, update_h,
- update_x, update_y,
- update_w, update_h);
+ update_w, update_h,
+ update_x, update_y,
+ update_w, update_h);
XSetWindowBackgroundPixmap(disp, win, pm);
XClearArea(disp, win, update_x, update_y, update_w, update_h, False);
XFlush(disp);
return 1;
}
-int
-main (int argc, char **argv)
+int
+main(int argc, char **argv)
{
- Imlib_Image *im = NULL;
- char *file = NULL;
- int no = 1;
+ Imlib_Image *im = NULL;
+ char *file = NULL;
+ int no = 1;
if (argc < 2)
return 1;
-
- file = argv[no];
- 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);
+
+ file = argv[no];
+ 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);
imlib_context_set_display(disp);
imlib_context_set_visual(vis);
imlib_context_set_colormap(cm);
@@ -122,222 +122,224 @@ main (int argc, char **argv)
im = imlib_load_image(file);
while (!im)
{
- no++;
- if (no == argc)
- exit(0);
- file = argv[no];
- image_width = 0;
- im = imlib_load_image(file);
- imlib_context_set_image(im);
+ no++;
+ if (no == argc)
+ exit(0);
+ file = argv[no];
+ image_width = 0;
+ im = imlib_load_image(file);
+ imlib_context_set_image(im);
}
if (!im)
{
- fprintf(stderr, "Image format not available\n");
- exit(0);
+ fprintf(stderr, "Image format not available\n");
+ exit(0);
}
- for(;;)
+ for (;;)
{
- int x, y, b, count, fdsize, xfd, timeout = 0;
- XEvent ev;
- static int zoom_mode = 0, zx, zy;
- static double zoom = 1.0;
- struct timeval tval;
- fd_set fdset;
- double t1;
-
- XFlush(disp);
+ int x, y, b, count, fdsize, xfd, timeout = 0;
+ XEvent ev;
+ static int zoom_mode = 0, zx, zy;
+ static double zoom = 1.0;
+ struct timeval tval;
+ fd_set fdset;
+ double t1;
+
+ XFlush(disp);
while (XPending(disp))
- {
- XNextEvent(disp, &ev);
- switch (ev.type)
- {
- case ButtonPress:
- b = ev.xbutton.button;
- x = ev.xbutton.x;
- y = ev.xbutton.y;
- if (b == 3)
- {
- zoom_mode = 1;
- zx = x;
- zy = y;
- imlib_context_set_drawable(pm);
- imlib_context_set_image(bg_im);
- imlib_context_set_anti_alias(0);
- imlib_context_set_dither(0);
- imlib_context_set_blend(0);
- imlib_render_image_part_on_drawable_at_size
- (0, 0, image_width, image_height,
- 0, 0, image_width, image_height);
- XSetWindowBackgroundPixmap(disp, win, pm);
- XClearWindow(disp, win);
- }
- break;
- case ButtonRelease:
- b = ev.xbutton.button;
- x = ev.xbutton.x;
- y = ev.xbutton.y;
- if (b == 3)
- zoom_mode = 0;
- if (b == 1)
- {
- no++;
- if (no == argc)
- no = argc - 1;
- file = argv[no];
- image_width = 0;
- zoom = 1.0;
- zoom_mode = 0;
- imlib_context_set_image(im);
- imlib_free_image_and_decache();
- im = imlib_load_image(file);
- while (!im)
- {
- no++;
- if (no == argc)
- exit(0);
- file = argv[no];
- image_width = 0;
- im = imlib_load_image(file);
- }
- imlib_context_set_image(im);
- }
- if (b == 2)
- {
- no--;
- if (no == 0)
- no = 1;
- file = argv[no];
- image_width = 0;
- zoom = 1.0;
- zoom_mode = 0;
- imlib_context_set_image(im);
- imlib_free_image_and_decache();
- im = imlib_load_image(file);
- while (!im)
- {
- no--;
- if (no == 0)
- no = 1;
- file = argv[no];
- image_width = 0;
- im = imlib_load_image(file);
- }
- imlib_context_set_image(im);
- }
- break;
- case MotionNotify:
- while (XCheckTypedWindowEvent(disp, win, MotionNotify, &ev));
- x = ev.xmotion.x;
- y = ev.xmotion.y;
- if (zoom_mode)
- {
- int sx, sy, sw, sh, dx, dy, dw, dh;
-
- zoom = ((double)x - (double)zx) / 32.0;
- if (zoom < 0)
- zoom = 1.0 + ((zoom * 32.0) / ((double)(zx + 1)));
- else
- zoom += 1.0;
- if (zoom <= 0.0001)
- zoom = 0.0001;
- if (zoom > 1.0)
- {
- dx = 0;
- dy = 0;
- dw = image_width;
- dh = image_height;
-
- sx = zx - (zx / zoom);
- sy = zy - (zy / zoom);
- sw = image_width / zoom;
- sh = image_height / zoom;
- }
- else
- {
- dx = zx - (zx * zoom);
- dy = zy - (zy * zoom);
- dw = image_width * zoom;
- dh = image_height * zoom;
-
- sx = 0;
- sy = 0;
- sw = image_width;
- sh = image_height;
- }
- imlib_context_set_anti_alias(0);
- imlib_context_set_dither(0);
- imlib_context_set_blend(0);
- imlib_context_set_image(bg_im);
- imlib_render_image_part_on_drawable_at_size
- (sx, sy, sw, sh, dx, dy, dw, dh);
- XSetWindowBackgroundPixmap(disp, win, pm);
- XClearWindow(disp, win);
- XFlush(disp);
- timeout = 1;
- }
- default:
- break;
- }
- t1 = 0.2;
- tval.tv_sec = (long)t1;
- tval.tv_usec = (long)((t1 - ((double)tval.tv_sec)) * 1000000);
- xfd = ConnectionNumber(disp);
- fdsize = xfd + 1;
- FD_ZERO(&fdset);
- FD_SET(xfd, &fdset);
- if (timeout)
- count = select(fdsize, &fdset, NULL, NULL, &tval);
- else
- count = select(fdsize, &fdset, NULL, NULL, NULL);
- if (count < 0)
- {
- if ((errno == ENOMEM) || (errno == EINVAL) || (errno == EBADF))
- exit(1);
- }
- else
- {
- if ((count == 0) && (timeout))
- {
- int sx, sy, sw, sh, dx, dy, dw, dh;
-
- if (zoom > 1.0)
- {
- dx = 0;
- dy = 0;
- dw = image_width;
- dh = image_height;
-
- sx = zx - (zx / zoom);
- sy = zy - (zy / zoom);
- sw = image_width / zoom;
- sh = image_height / zoom;
- }
- else
- {
- dx = zx - (zx * zoom);
- dy = zy - (zy * zoom);
- dw = image_width * zoom;
- dh = image_height * zoom;
-
- sx = 0;
- sy = 0;
- 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
- (sx, sy, sw, sh, dx, dy, dw, dh);
- XSetWindowBackgroundPixmap(disp, win, pm);
- XClearWindow(disp, win);
- XFlush(disp);
- timeout = 0;
- }
- }
-
- }
+ {
+ XNextEvent(disp, &ev);
+ switch (ev.type)
+ {
+ case ButtonPress:
+ b = ev.xbutton.button;
+ x = ev.xbutton.x;
+ y = ev.xbutton.y;
+ if (b == 3)
+ {
+ zoom_mode = 1;
+ zx = x;
+ zy = y;
+ imlib_context_set_drawable(pm);
+ imlib_context_set_image(bg_im);
+ imlib_context_set_anti_alias(0);
+ imlib_context_set_dither(0);
+ imlib_context_set_blend(0);
+ imlib_render_image_part_on_drawable_at_size
+ (0, 0, image_width, image_height,
+ 0, 0, image_width, image_height);
+ XSetWindowBackgroundPixmap(disp, win, pm);
+ XClearWindow(disp, win);
+ }
+ break;
+ case ButtonRelease:
+ b = ev.xbutton.button;
+ x = ev.xbutton.x;
+ y = ev.xbutton.y;
+ if (b == 3)
+ zoom_mode = 0;
+ if (b == 1)
+ {
+ no++;
+ if (no == argc)
+ no = argc - 1;
+ file = argv[no];
+ image_width = 0;
+ zoom = 1.0;
+ zoom_mode = 0;
+ imlib_context_set_image(im);
+ imlib_free_image_and_decache();
+ im = imlib_load_image(file);
+ while (!im)
+ {
+ no++;
+ if (no == argc)
+ exit(0);
+ file = argv[no];
+ image_width = 0;
+ im = imlib_load_image(file);
+ }
+ imlib_context_set_image(im);
+ }
+ if (b == 2)
+ {
+ no--;
+ if (no == 0)
+ no = 1;
+ file = argv[no];
+ image_width = 0;
+ zoom = 1.0;
+ zoom_mode = 0;
+ imlib_context_set_image(im);
+ imlib_free_image_and_decache();
+ im = imlib_load_image(file);
+ while (!im)
+ {
+ no--;
+ if (no == 0)
+ no = 1;
+ file = argv[no];
+ image_width = 0;
+ im = imlib_load_image(file);
+ }
+ imlib_context_set_image(im);
+ }
+ break;
+ case MotionNotify:
+ while (XCheckTypedWindowEvent
+ (disp, win, MotionNotify, &ev));
+ x = ev.xmotion.x;
+ y = ev.xmotion.y;
+ if (zoom_mode)
+ {
+ int sx, sy, sw, sh, dx, dy, dw, dh;
+
+ zoom = ((double)x - (double)zx) / 32.0;
+ if (zoom < 0)
+ zoom = 1.0 + ((zoom * 32.0) / ((double)(zx + 1)));
+ else
+ zoom += 1.0;
+ if (zoom <= 0.0001)
+ zoom = 0.0001;
+ if (zoom > 1.0)
+ {
+ dx = 0;
+ dy = 0;
+ dw = image_width;
+ dh = image_height;
+
+ sx = zx - (zx / zoom);
+ sy = zy - (zy / zoom);
+ sw = image_width / zoom;
+ sh = image_height / zoom;
+ }
+ else
+ {
+ dx = zx - (zx * zoom);
+ dy = zy - (zy * zoom);
+ dw = image_width * zoom;
+ dh = image_height * zoom;
+
+ sx = 0;
+ sy = 0;
+ sw = image_width;
+ sh = image_height;
+ }
+ imlib_context_set_anti_alias(0);
+ imlib_context_set_dither(0);
+ imlib_context_set_blend(0);
+ imlib_context_set_image(bg_im);
+ imlib_render_image_part_on_drawable_at_size
+ (sx, sy, sw, sh, dx, dy, dw, dh);
+ XSetWindowBackgroundPixmap(disp, win, pm);
+ XClearWindow(disp, win);
+ XFlush(disp);
+ timeout = 1;
+ }
+ default:
+ break;
+ }
+ t1 = 0.2;
+ tval.tv_sec = (long)t1;
+ tval.tv_usec = (long)((t1 - ((double)tval.tv_sec)) * 1000000);
+ xfd = ConnectionNumber(disp);
+ fdsize = xfd + 1;
+ FD_ZERO(&fdset);
+ FD_SET(xfd, &fdset);
+ if (timeout)
+ count = select(fdsize, &fdset, NULL, NULL, &tval);
+ else
+ count = select(fdsize, &fdset, NULL, NULL, NULL);
+ if (count < 0)
+ {
+ if ((errno == ENOMEM) || (errno == EINVAL)
+ || (errno == EBADF))
+ exit(1);
+ }
+ else
+ {
+ if ((count == 0) && (timeout))
+ {
+ int sx, sy, sw, sh, dx, dy, dw, dh;
+
+ if (zoom > 1.0)
+ {
+ dx = 0;
+ dy = 0;
+ dw = image_width;
+ dh = image_height;
+
+ sx = zx - (zx / zoom);
+ sy = zy - (zy / zoom);
+ sw = image_width / zoom;
+ sh = image_height / zoom;
+ }
+ else
+ {
+ dx = zx - (zx * zoom);
+ dy = zy - (zy * zoom);
+ dw = image_width * zoom;
+ dh = image_height * zoom;
+
+ sx = 0;
+ sy = 0;
+ 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
+ (sx, sy, sw, sh, dx, dy, dw, dh);
+ XSetWindowBackgroundPixmap(disp, win, pm);
+ XClearWindow(disp, win);
+ XFlush(disp);
+ timeout = 0;
+ }
+ }
+
+ }
}
return 0;
}
diff --git a/filters/filter_bumpmap.c b/filters/filter_bumpmap.c
index be3204f..b08c151 100644
--- a/filters/filter_bumpmap.c
+++ b/filters/filter_bumpmap.c
@@ -16,245 +16,273 @@
#define PI (4 * atan(1))
-static Imlib_Image
+static Imlib_Image
bump_map(Imlib_Image im, pIFunctionParam par)
{
- Imlib_Image map = im;
- pIFunctionParam ptr;
- double an = 0, el = 30, d = 0x200;
- double red = 0x200, green = 0x200, blue = 0x200;
- double ambient = 0;
+ Imlib_Image map = im;
+ pIFunctionParam ptr;
+ double an = 0, el = 30, d = 0x200;
+ double red = 0x200, green = 0x200, blue = 0x200;
+ double ambient = 0;
- int free_map = 0;
- DATA32 *src;
- DATA32 *mp, *mpy, *mpp;
- double z, z_2, x2, y2;
- int w, h, i, j, w2, h2, wh2, mx, my;
+ int free_map = 0;
+ DATA32 *src;
+ DATA32 *mp, *mpy, *mpp;
+ double z, z_2, x2, y2;
+ int w, h, i, j, w2, h2, wh2, mx, my;
- for (ptr = par; ptr; ptr = ptr->next) {
- ASSIGN_IMAGE("map", map);
- ASSIGN_INT ("angle", an);
- ASSIGN_INT ("elevation", el);
- ASSIGN_INT ("depth", d);
- ASSIGN_INT ("red", red);
- ASSIGN_INT ("green", green);
- ASSIGN_INT ("blue", blue);
- ASSIGN_INT ("ambient", ambient);
- }
- if (!map) return im;
+ for (ptr = par; ptr; ptr = ptr->next)
+ {
+ ASSIGN_IMAGE("map", map);
+ ASSIGN_INT("angle", an);
+ ASSIGN_INT("elevation", el);
+ ASSIGN_INT("depth", d);
+ ASSIGN_INT("red", red);
+ ASSIGN_INT("green", green);
+ ASSIGN_INT("blue", blue);
+ ASSIGN_INT("ambient", ambient);
+ }
+ if (!map)
+ return im;
- red /= 0x100;
- green /= 0x100;
- blue /= 0x100;
- ambient /= 0x100;
- d /= 0x100;
+ red /= 0x100;
+ green /= 0x100;
+ blue /= 0x100;
+ ambient /= 0x100;
+ d /= 0x100;
- imlib_context_set_image(im);
- src = imlib_image_get_data();
- w = imlib_image_get_width();
- h = imlib_image_get_height();
+ imlib_context_set_image(im);
+ src = imlib_image_get_data();
+ w = imlib_image_get_width();
+ h = imlib_image_get_height();
- imlib_context_set_image(map);
- mpp = imlib_image_get_data_for_reading_only();
- w2 = imlib_image_get_width();
- h2 = imlib_image_get_height();
- wh2 = w2 * h2;
+ imlib_context_set_image(map);
+ mpp = imlib_image_get_data_for_reading_only();
+ w2 = imlib_image_get_width();
+ h2 = imlib_image_get_height();
+ wh2 = w2 * h2;
- an *= (PI / 180);
- el *= (PI / 180);
+ an *= (PI / 180);
+ el *= (PI / 180);
- x2 = sin(an) * cos(el);
- y2 = cos(an) * cos(el);
- z = sin(el);
+ x2 = sin(an) * cos(el);
+ y2 = cos(an) * cos(el);
+ z = sin(el);
- d /= (255 * (255 + 255 + 255));
- z_2 = z * z;
+ d /= (255 * (255 + 255 + 255));
+ z_2 = z * z;
- my = h2;
- for (j = h; --j >= 0; ) {
- mp = mpp;
- mpp += w2;
- if (--my <= 0) {
- mpp -= wh2;
- my = h2;
- }
- mpy = mpp;
- mx = w2;
- for (i = w; --i >= 0; ) {
- double x1, y1, v;
- int r, g, b, gr;
+ my = h2;
+ for (j = h; --j >= 0;)
+ {
+ mp = mpp;
+ mpp += w2;
+ if (--my <= 0)
+ {
+ mpp -= wh2;
+ my = h2;
+ }
+ mpy = mpp;
+ mx = w2;
+ for (i = w; --i >= 0;)
+ {
+ double x1, y1, v;
+ int r, g, b, gr;
- gr = A_VAL(mp) * (R_VAL(mp) + G_VAL(mp) + B_VAL(mp));
- y1 = d * (double)(A_VAL(mpy) * (R_VAL(mpy) +
- G_VAL(mpy) + B_VAL(mpy)) - gr);
- mp++;
- mpy++;
- if (--mx <= 0) {
- mp -= w2;
- mpy -= w2;
- mx = w2;
- }
- x1 = d * (double)(A_VAL(mp) * (R_VAL(mp) +
- G_VAL(mp) + B_VAL(mp)) - gr);
- v = x1 * x2 + y1 * y2 + z;
- v /= sqrt((x1 * x1) + (y1 * y1) + 1.0);
- v += ambient;
- r = v * R_VAL(src) * red;
- g = v * G_VAL(src) * green;
- b = v * B_VAL(src) * blue;
- if (r < 0) r = 0;
- if (r > 255) r = 255;
- if (g < 0) g = 0;
- if (g > 255) g = 255;
- if (b < 0) b = 0;
- if (b > 255) b = 255;
- R_VAL(src) = r;
- G_VAL(src) = g;
- B_VAL(src) = b;
+ gr = A_VAL(mp) * (R_VAL(mp) + G_VAL(mp) + B_VAL(mp));
+ y1 = d * (double)(A_VAL(mpy) * (R_VAL(mpy) +
+ G_VAL(mpy) + B_VAL(mpy)) - gr);
+ mp++;
+ mpy++;
+ if (--mx <= 0)
+ {
+ mp -= w2;
+ mpy -= w2;
+ mx = w2;
+ }
+ x1 = d * (double)(A_VAL(mp) * (R_VAL(mp) +
+ G_VAL(mp) + B_VAL(mp)) - gr);
+ v = x1 * x2 + y1 * y2 + z;
+ v /= sqrt((x1 * x1) + (y1 * y1) + 1.0);
+ v += ambient;
+ r = v * R_VAL(src) * red;
+ g = v * G_VAL(src) * green;
+ b = v * B_VAL(src) * blue;
+ if (r < 0)
+ r = 0;
+ if (r > 255)
+ r = 255;
+ if (g < 0)
+ g = 0;
+ if (g > 255)
+ g = 255;
+ if (b < 0)
+ b = 0;
+ if (b > 255)
+ b = 255;
+ R_VAL(src) = r;
+ G_VAL(src) = g;
+ B_VAL(src) = b;
- src++;
- }
- }
- if (free_map) {
- imlib_context_set_image(map);
- imlib_free_image();
- }
- return im;
+ src++;
+ }
+ }
+ if (free_map)
+ {
+ imlib_context_set_image(map);
+ imlib_free_image();
+ }
+ return im;
}
-static Imlib_Image
+static Imlib_Image
bump_map_point(Imlib_Image im, pIFunctionParam par)
{
- Imlib_Image map = im;
- pIFunctionParam ptr;
- double x = 0, y = 0, z = 30, d = 0x200;
- double red = 0x200, green = 0x200, blue = 0x200;
- double ambient = 0;
+ Imlib_Image map = im;
+ pIFunctionParam ptr;
+ double x = 0, y = 0, z = 30, d = 0x200;
+ double red = 0x200, green = 0x200, blue = 0x200;
+ double ambient = 0;
- int free_map = 0;
- DATA32 *src;
- DATA32 *mp, *mpy, *mpp;
- double z_2, x2, y2;
- int w, h, i, j, w2, h2, wh2, mx, my;
+ int free_map = 0;
+ DATA32 *src;
+ DATA32 *mp, *mpy, *mpp;
+ double z_2, x2, y2;
+ int w, h, i, j, w2, h2, wh2, mx, my;
- for (ptr = par; ptr; ptr = ptr->next) {
- ASSIGN_IMAGE("map", map);
- ASSIGN_INT ("x", x);
- ASSIGN_INT ("y", y);
- ASSIGN_INT ("z", z);
- ASSIGN_INT ("depth", d);
- ASSIGN_INT ("red", red);
- ASSIGN_INT ("green", green);
- ASSIGN_INT ("blue", blue);
- ASSIGN_INT ("ambient", ambient);
- }
- if (!map) return im;
+ for (ptr = par; ptr; ptr = ptr->next)
+ {
+ ASSIGN_IMAGE("map", map);
+ ASSIGN_INT("x", x);
+ ASSIGN_INT("y", y);
+ ASSIGN_INT("z", z);
+ ASSIGN_INT("depth", d);
+ ASSIGN_INT("red", red);
+ ASSIGN_INT("green", green);
+ ASSIGN_INT("blue", blue);
+ ASSIGN_INT("ambient", ambient);
+ }
+ if (!map)
+ return im;
- red /= 0x100;
- green /= 0x100;
- blue /= 0x100;
- ambient /= 0x100;
- d /= 0x100;
+ red /= 0x100;
+ green /= 0x100;
+ blue /= 0x100;
+ ambient /= 0x100;
+ d /= 0x100;
- imlib_context_set_image(im);
- src = imlib_image_get_data();
- w = imlib_image_get_width();
- h = imlib_image_get_height();
+ imlib_context_set_image(im);
+ src = imlib_image_get_data();
+ w = imlib_image_get_width();
+ h = imlib_image_get_height();
- imlib_context_set_image(map);
- mpp = imlib_image_get_data_for_reading_only();
- w2 = imlib_image_get_width();
- h2 = imlib_image_get_height();
- wh2 = w2 * h2;
+ imlib_context_set_image(map);
+ mpp = imlib_image_get_data_for_reading_only();
+ w2 = imlib_image_get_width();
+ h2 = imlib_image_get_height();
+ wh2 = w2 * h2;
- d /= (255 * (255 + 255 + 255));
- z_2 = z * z;
+ d /= (255 * (255 + 255 + 255));
+ z_2 = z * z;
- my = h2;
- y2 = -y;
- for (j = h; --j >= 0; ) {
- mp = mpp;
- mpp += w2;
- if (--my <= 0) {
- mpp -= wh2;
- my = h2;
- }
- mpy = mpp;
- mx = w2;
- x2 = -x;
- for (i = w; --i >= 0; ) {
- double x1, y1, v;
- int r, g, b, gr;
+ my = h2;
+ y2 = -y;
+ for (j = h; --j >= 0;)
+ {
+ mp = mpp;
+ mpp += w2;
+ if (--my <= 0)
+ {
+ mpp -= wh2;
+ my = h2;
+ }
+ mpy = mpp;
+ mx = w2;
+ x2 = -x;
+ for (i = w; --i >= 0;)
+ {
+ double x1, y1, v;
+ int r, g, b, gr;
- gr = A_VAL(mp) * (R_VAL(mp) + G_VAL(mp) + B_VAL(mp));
- y1 = d * (double)(A_VAL(mpy) * (R_VAL(mpy) +
- G_VAL(mpy) + B_VAL(mpy)) - gr);
- mp++;
- mpy++;
- if (--mx <= 0) {
- mp -= w2;
- mpy -= w2;
- mx = w2;
- }
- x1 = d * (double)(A_VAL(mp) * (R_VAL(mp) +
- G_VAL(mp) + B_VAL(mp)) - gr);
- v = x1 * x2 + y1 * y2 + z;
- v /= sqrt((x1 * x1) + (y1 * y1) + 1.0);
- v /= sqrt((x2 * x2) + (y2 * y2) + z_2);
- v += ambient;
- r = v * R_VAL(src) * red;
- g = v * G_VAL(src) * green;
- b = v * B_VAL(src) * blue;
- if (r < 0) r = 0;
- if (r > 255) r = 255;
- if (g < 0) g = 0;
- if (g > 255) g = 255;
- if (b < 0) b = 0;
- if (b > 255) b = 255;
- R_VAL(src) = r;
- G_VAL(src) = g;
- B_VAL(src) = b;
+ gr = A_VAL(mp) * (R_VAL(mp) + G_VAL(mp) + B_VAL(mp));
+ y1 = d * (double)(A_VAL(mpy) * (R_VAL(mpy) +
+ G_VAL(mpy) + B_VAL(mpy)) - gr);
+ mp++;
+ mpy++;
+ if (--mx <= 0)
+ {
+ mp -= w2;
+ mpy -= w2;
+ mx = w2;
+ }
+ x1 = d * (double)(A_VAL(mp) * (R_VAL(mp) +
+ G_VAL(mp) + B_VAL(mp)) - gr);
+ v = x1 * x2 + y1 * y2 + z;
+ v /= sqrt((x1 * x1) + (y1 * y1) + 1.0);
+ v /= sqrt((x2 * x2) + (y2 * y2) + z_2);
+ v += ambient;
+ r = v * R_VAL(src) * red;
+ g = v * G_VAL(src) * green;
+ b = v * B_VAL(src) * blue;
+ if (r < 0)
+ r = 0;
+ if (r > 255)
+ r = 255;
+ if (g < 0)
+ g = 0;
+ if (g > 255)
+ g = 255;
+ if (b < 0)
+ b = 0;
+ if (b > 255)
+ b = 255;
+ R_VAL(src) = r;
+ G_VAL(src) = g;
+ B_VAL(src) = b;
- x2++;
- src++;
- }
- y2++;
- }
- if (free_map) {
- imlib_context_set_image(map);
- imlib_free_image();
- }
- return im;
+ x2++;
+ src++;
+ }
+ y2++;
+ }
+ if (free_map)
+ {
+ imlib_context_set_image(map);
+ imlib_free_image();
+ }
+ return im;
}
void
init(struct imlib_filter_info *info)
{
- char *filters[] = { "bump_map_point", "bump_map" };
- int i = (sizeof(filters) / sizeof(*filters));
-
- info->name = strdup( "Bump Mapping" );
- info->author = strdup( "Willem Monsuwe (willem@stack.nl)" );
- info->description = strdup( "Provides bumpmapping to a point and bumpmapping from an infinite light source. *very* cool." );
+ char *filters[] = { "bump_map_point", "bump_map" };
+ int i = (sizeof(filters) / sizeof(*filters));
+
+ info->name = strdup("Bump Mapping");
+ info->author = strdup("Willem Monsuwe (willem@stack.nl)");
+ info->description =
+ strdup
+ ("Provides bumpmapping to a point and bumpmapping from an infinite light source. *very* cool.");
info->num_filters = i;
info->filters = malloc(sizeof(char *) * i);
while (--i >= 0)
- info->filters[i] = strdup(filters[i]);
-
+ info->filters[i] = strdup(filters[i]);
+
}
void
deinit()
{
- return;
+ return;
}
-void *
+void *
exec(char *filter, void *im, pIFunctionParam par)
{
- if (!strcmp(filter, "bump_map"))
- return bump_map((Imlib_Image)im, par);
- if (!strcmp(filter, "bump_map_point"))
- return bump_map_point((Imlib_Image)im, par);
- return im;
+ if (!strcmp(filter, "bump_map"))
+ return bump_map((Imlib_Image) im, par);
+ if (!strcmp(filter, "bump_map_point"))
+ return bump_map_point((Imlib_Image) im, par);
+ return im;
}
diff --git a/filters/filter_colormod.c b/filters/filter_colormod.c
index dbc49c8..c106f2c 100644
--- a/filters/filter_colormod.c
+++ b/filters/filter_colormod.c
@@ -27,173 +27,239 @@
static void
mod_brightness(double t[256], double v)
{
- int i;
- for (i = 256; --i >= 0; )
- t[i] += v;
+ int i;
+
+ for (i = 256; --i >= 0;)
+ t[i] += v;
}
static void
mod_contrast(double t[256], double v)
{
- int i;
- for (i = 256; --i >= 0; )
- t[i] = ((t[i] - 0.5) * v) + 0.5;
+ int i;
+
+ for (i = 256; --i >= 0;)
+ t[i] = ((t[i] - 0.5) * v) + 0.5;
}
static void
mod_gamma(double t[256], double v)
{
- int i;
- for (i = 256; --i >= 0; )
- t[i] = pow(t[i], 1 / v);
+ int i;
+
+ for (i = 256; --i >= 0;)
+ t[i] = pow(t[i], 1 / v);
}
static void
mod_tint(double t[256], double v)
{
- int i;
- for (i = 256; --i >= 0; )
- t[i] *= v;
+ int i;
+
+ for (i = 256; --i >= 0;)
+ t[i] *= v;
}
-static Imlib_Image
+static Imlib_Image
colormod(Imlib_Image im, pIFunctionParam par)
{
- double a_d[256], r_d[256], g_d[256], b_d[256];
- DATA8 a_b[256], r_b[256], g_b[256], b_b[256];
- pIFunctionParam ptr;
- int x = 0, y = 0, h, w, i;
- double v=0.0;
-
- imlib_context_set_image(im);
- w = imlib_image_get_width();
- h = imlib_image_get_height();
-
- for (i = 256; --i >= 0; )
- a_d[i] = r_d[i] = g_d[i] = b_d[i] = (double)i / 255;
-
- for (ptr = par; ptr; ptr = ptr->next) {
- if (!strcmp("x", ptr->key)) {
- GET_INT(x, ptr);
- } else if (!strcmp("y", ptr->key)) {
- GET_INT(y, ptr);
- } else if (!strcmp("w", ptr->key)) {
- GET_INT(w, ptr);
- } else if (!strcmp("h", ptr->key)) {
- GET_INT(h, ptr);
- } else if (!memcmp("brightness", ptr->key, 10)) {
- GET_DOUBLE(v, ptr);
- if (!ptr->key[10]) {
- mod_brightness(r_d, v);
- mod_brightness(g_d, v);
- mod_brightness(b_d, v);
- mod_brightness(a_d, v);
- } else if (!strcmp("_r", ptr->key + 10)) {
- mod_brightness(r_d, v);
- } else if (!strcmp("_g", ptr->key + 10)) {
- mod_brightness(g_d, v);
- } else if (!strcmp("_b", ptr->key + 10)) {
- mod_brightness(b_d, v);
- } else if (!strcmp("_a", ptr->key + 10)) {
- mod_brightness(a_d, v);
- }
- } else if (!memcmp("contrast", ptr->key, 8)) {
- GET_DOUBLE(v, ptr);
- if (!ptr->key[8]) {
- mod_contrast(r_d, v);
- mod_contrast(g_d, v);
- mod_contrast(b_d, v);
- mod_contrast(a_d, v);
- } else if (!strcmp("_r", ptr->key + 8)) {
- mod_contrast(r_d, v);
- } else if (!strcmp("_g", ptr->key + 8)) {
- mod_contrast(g_d, v);
- } else if (!strcmp("_b", ptr->key + 8)) {
- mod_contrast(b_d, v);
- } else if (!strcmp("_a", ptr->key + 8)) {
- mod_contrast(a_d, v);
- }
- } else if (!memcmp("gamma", ptr->key, 5)) {
- GET_DOUBLE(v, ptr);
- if (!ptr->key[5]) {
- mod_gamma(r_d, v);
- mod_gamma(g_d, v);
- mod_gamma(b_d, v);
- mod_gamma(a_d, v);
- } else if (!strcmp("_r", ptr->key + 5)) {
- mod_gamma(r_d, v);
- } else if (!strcmp("_g", ptr->key + 5)) {
- mod_gamma(g_d, v);
- } else if (!strcmp("_b", ptr->key + 5)) {
- mod_gamma(b_d, v);
- } else if (!strcmp("_a", ptr->key + 5)) {
- mod_gamma(a_d, v);
- }
- } else if (!memcmp("tint", ptr->key, 4)) {
- GET_DOUBLE(v, ptr);
- if (!ptr->key[4]) {
- mod_tint(r_d, v);
- mod_tint(g_d, v);
- mod_tint(b_d, v);
- mod_tint(a_d, v);
- } else if (!strcmp("_r", ptr->key + 4)) {
- mod_tint(r_d, v);
- } else if (!strcmp("_g", ptr->key + 4)) {
- mod_tint(g_d, v);
- } else if (!strcmp("_b", ptr->key + 4)) {
- mod_tint(b_d, v);
- } else if (!strcmp("_a", ptr->key + 4)) {
- mod_tint(a_d, v);
- }
- }
- }
- for (i = 256; --i >= 0; ) {
- if (a_d[i] < 0) a_d[i] = 0;
- if (a_d[i] > 1) a_d[i] = 1;
- a_b[i] = a_d[i] * 255;
- if (r_d[i] < 0) r_d[i] = 0;
- if (r_d[i] > 1) r_d[i] = 1;
- r_b[i] = r_d[i] * 255;
- if (g_d[i] < 0) g_d[i] = 0;
- if (g_d[i] > 1) g_d[i] = 1;
- g_b[i] = g_d[i] * 255;
- if (b_d[i] < 0) b_d[i] = 0;
- if (b_d[i] > 1) b_d[i] = 1;
- b_b[i] = b_d[i] * 255;
- }
- imlib_context_set_color_modifier(imlib_create_color_modifier());
- imlib_set_color_modifier_tables(r_b, g_b, b_b, a_b);
- imlib_apply_color_modifier_to_rectangle(x, y, w, h);
- imlib_free_color_modifier();
- return im;
+ double a_d[256], r_d[256], g_d[256], b_d[256];
+ DATA8 a_b[256], r_b[256], g_b[256], b_b[256];
+ pIFunctionParam ptr;
+ int x = 0, y = 0, h, w, i;
+ double v = 0.0;
+
+ imlib_context_set_image(im);
+ w = imlib_image_get_width();
+ h = imlib_image_get_height();
+
+ for (i = 256; --i >= 0;)
+ a_d[i] = r_d[i] = g_d[i] = b_d[i] = (double)i / 255;
+
+ for (ptr = par; ptr; ptr = ptr->next)
+ {
+ if (!strcmp("x", ptr->key))
+ {
+ GET_INT(x, ptr);
+ }
+ else if (!strcmp("y", ptr->key))
+ {
+ GET_INT(y, ptr);
+ }
+ else if (!strcmp("w", ptr->key))
+ {
+ GET_INT(w, ptr);
+ }
+ else if (!strcmp("h", ptr->key))
+ {
+ GET_INT(h, ptr);
+ }
+ else if (!memcmp("brightness", ptr->key, 10))
+ {
+ GET_DOUBLE(v, ptr);
+ if (!ptr->key[10])
+ {
+ mod_brightness(r_d, v);
+ mod_brightness(g_d, v);
+ mod_brightness(b_d, v);
+ mod_brightness(a_d, v);
+ }
+ else if (!strcmp("_r", ptr->key + 10))
+ {
+ mod_brightness(r_d, v);
+ }
+ else if (!strcmp("_g", ptr->key + 10))
+ {
+ mod_brightness(g_d, v);
+ }
+ else if (!strcmp("_b", ptr->key + 10))
+ {
+ mod_brightness(b_d, v);
+ }
+ else if (!strcmp("_a", ptr->key + 10))
+ {
+ mod_brightness(a_d, v);
+ }
+ }
+ else if (!memcmp("contrast", ptr->key, 8))
+ {
+ GET_DOUBLE(v, ptr);
+ if (!ptr->key[8])
+ {
+ mod_contrast(r_d, v);
+ mod_contrast(g_d, v);
+ mod_contrast(b_d, v);
+ mod_contrast(a_d, v);
+ }
+ else if (!strcmp("_r", ptr->key + 8))
+ {
+ mod_contrast(r_d, v);
+ }
+ else if (!strcmp("_g", ptr->key + 8))
+ {
+ mod_contrast(g_d, v);
+ }
+ else if (!strcmp("_b", ptr->key + 8))
+ {
+ mod_contrast(b_d, v);
+ }
+ else if (!strcmp("_a", ptr->key + 8))
+ {
+ mod_contrast(a_d, v);
+ }
+ }
+ else if (!memcmp("gamma", ptr->key, 5))
+ {
+ GET_DOUBLE(v, ptr);
+ if (!ptr->key[5])
+ {
+ mod_gamma(r_d, v);
+ mod_gamma(g_d, v);
+ mod_gamma(b_d, v);
+ mod_gamma(a_d, v);
+ }
+ else if (!strcmp("_r", ptr->key + 5))
+ {
+ mod_gamma(r_d, v);
+ }
+ else if (!strcmp("_g", ptr->key + 5))
+ {
+ mod_gamma(g_d, v);
+ }
+ else if (!strcmp("_b", ptr->key + 5))
+ {
+ mod_gamma(b_d, v);
+ }
+ else if (!strcmp("_a", ptr->key + 5))
+ {
+ mod_gamma(a_d, v);
+ }
+ }
+ else if (!memcmp("tint", ptr->key, 4))
+ {
+ GET_DOUBLE(v, ptr);
+ if (!ptr->key[4])
+ {
+ mod_tint(r_d, v);
+ mod_tint(g_d, v);
+ mod_tint(b_d, v);
+ mod_tint(a_d, v);
+ }
+ else if (!strcmp("_r", ptr->key + 4))
+ {
+ mod_tint(r_d, v);
+ }
+ else if (!strcmp("_g", ptr->key + 4))
+ {
+ mod_tint(g_d, v);
+ }
+ else if (!strcmp("_b", ptr->key + 4))
+ {
+ mod_tint(b_d, v);
+ }
+ else if (!strcmp("_a", ptr->key + 4))
+ {
+ mod_tint(a_d, v);
+ }
+ }
+ }
+ for (i = 256; --i >= 0;)
+ {
+ if (a_d[i] < 0)
+ a_d[i] = 0;
+ if (a_d[i] > 1)
+ a_d[i] = 1;
+ a_b[i] = a_d[i] * 255;
+ if (r_d[i] < 0)
+ r_d[i] = 0;
+ if (r_d[i] > 1)
+ r_d[i] = 1;
+ r_b[i] = r_d[i] * 255;
+ if (g_d[i] < 0)
+ g_d[i] = 0;
+ if (g_d[i] > 1)
+ g_d[i] = 1;
+ g_b[i] = g_d[i] * 255;
+ if (b_d[i] < 0)
+ b_d[i] = 0;
+ if (b_d[i] > 1)
+ b_d[i] = 1;
+ b_b[i] = b_d[i] * 255;
+ }
+ imlib_context_set_color_modifier(imlib_create_color_modifier());
+ imlib_set_color_modifier_tables(r_b, g_b, b_b, a_b);
+ imlib_apply_color_modifier_to_rectangle(x, y, w, h);
+ imlib_free_color_modifier();
+ return im;
}
void
init(struct imlib_filter_info *info)
{
- char *filters[] = { "colormod" };
- int i = (sizeof(filters) / sizeof(*filters));
-
- info->name = strdup( "Tinting" );
- info->author = strdup( "Willem Monsuwe (willem@stack.nl)" );
- info->description = strdup( "Provides most common color modification filters." );
+ char *filters[] = { "colormod" };
+ int i = (sizeof(filters) / sizeof(*filters));
+
+ info->name = strdup("Tinting");
+ info->author = strdup("Willem Monsuwe (willem@stack.nl)");
+ info->description =
+ strdup("Provides most common color modification filters.");
info->num_filters = i;
info->filters = malloc(sizeof(char *) * i);
while (--i >= 0)
- info->filters[i] = strdup(filters[i]);
-
+ info->filters[i] = strdup(filters[i]);
+
}
void
deinit()
{
- return;
+ return;
}
-void *
+void *
exec(char *filter, void *im, pIFunctionParam par)
{
- if (!strcmp(filter, "colormod"))
- return colormod((Imlib_Image)im, par);
- return im;
+ if (!strcmp(filter, "colormod"))
+ return colormod((Imlib_Image) im, par);
+ return im;
}
diff --git a/filters/filter_test.c b/filters/filter_test.c
index 50e76b8..4d3f11a 100644
--- a/filters/filter_test.c
+++ b/filters/filter_test.c
@@ -11,101 +11,108 @@
#include "script.h"
#include "dynamic_filters.h"
-void init( struct imlib_filter_info *info );
-void deinit(void);
-void *exec( char *filter, void *im, pIFunctionParam params );
+void init(struct imlib_filter_info *info);
+void deinit(void);
+void *exec(char *filter, void *im, pIFunctionParam params);
-void init( struct imlib_filter_info *info )
+void
+init(struct imlib_filter_info *info)
{
- char *filters[] = { "tint", "cool_text", "gradient" };
- int i = 0;
+ char *filters[] = { "tint", "cool_text", "gradient" };
+ int i = 0;
- info->name = strdup( "Test Filter" );
- info->author = strdup( "Chris Ross - Boris - chris@darkrock.co.uk" );
- info->description = strdup( "This filter is used to show that the imlib2 filter system works!" );
+ info->name = strdup("Test Filter");
+ info->author = strdup("Chris Ross - Boris - chris@darkrock.co.uk");
+ info->description =
+ strdup
+ ("This filter is used to show that the imlib2 filter system works!");
info->num_filters = 3;
- info->filters = malloc(sizeof(char *)*3);
+ info->filters = malloc(sizeof(char *) * 3);
for (i = 0; i < info->num_filters; i++)
info->filters[i] = strdup(filters[i]);
}
-void deinit(void)
+void
+deinit(void)
{
return;
}
-void *exec( char *filter, void *im, pIFunctionParam params )
+void *
+exec(char *filter, void *im, pIFunctionParam params)
{
- Imlib_Image imge = im;
- Imlib_Image anoim;
- IFunctionParam *ptr;
-
- if( strcmp( filter, "tint" ) == 0 )
- {
- Imlib_Color_Modifier cm;
- DATA8 atab[256];
- int x = 0, y = 0, w = 0, h = 0;
- DATA8 r = 255, b = 255, g = 255, a = 255;
+ Imlib_Image imge = im;
+ Imlib_Image anoim;
+ IFunctionParam *ptr;
+
+ if (strcmp(filter, "tint") == 0)
+ {
+ Imlib_Color_Modifier cm;
+ DATA8 atab[256];
+ int x = 0, y = 0, w = 0, h = 0;
+ DATA8 r = 255, b = 255, g = 255, a = 255;
+
/*
printf( "filter_test.c: tint called\n" );
*/
- /* Set friendly defaults */
- imlib_context_set_image( imge );
- w = imlib_image_get_width();
- h = imlib_image_get_height();
-
- for( ptr = params; ptr != NULL; ptr = ptr->next )
- {
- ASSIGN_DATA8( "red", r );
- ASSIGN_DATA8( "blue", b );
- ASSIGN_DATA8( "green", g );
- ASSIGN_INT( "x", x );
- ASSIGN_INT( "y", y );
- ASSIGN_INT( "w", w );
- ASSIGN_INT( "h", h );
- ASSIGN_DATA8( "alpha", a );
- }
+ /* Set friendly defaults */
+ imlib_context_set_image(imge);
+ w = imlib_image_get_width();
+ h = imlib_image_get_height();
+
+ for (ptr = params; ptr != NULL; ptr = ptr->next)
+ {
+ ASSIGN_DATA8("red", r);
+ ASSIGN_DATA8("blue", b);
+ ASSIGN_DATA8("green", g);
+ ASSIGN_INT("x", x);
+ ASSIGN_INT("y", y);
+ ASSIGN_INT("w", w);
+ ASSIGN_INT("h", h);
+ ASSIGN_DATA8("alpha", a);
+ }
/*
printf( "Using values red=%d,blue=%d,green=%d,x=%d,y=%d,height=%d,width=%d,alpha=%d\n", r,b,g,x,y,w,h,a );
*/
- anoim = imlib_create_image( w, h );
- cm = imlib_create_color_modifier();
- imlib_context_set_color_modifier(cm);
- imlib_context_set_image(anoim);
-
- imlib_context_set_color(r, g, b, 255);
- imlib_image_fill_rectangle(0, 0, w, h);
- imlib_context_set_blend(1);
- imlib_image_set_has_alpha(1);
-
- memset(atab, a, sizeof(atab));
- imlib_set_color_modifier_tables(NULL, NULL, NULL, atab);
- imlib_apply_color_modifier_to_rectangle(0, 0, w, h);
-
- imlib_context_set_image( imge );
- imlib_blend_image_onto_image( anoim, 0, 0, 0, w, h, x, y, w, h);
-
- imlib_free_color_modifier();
- imlib_context_set_image(anoim);
- imlib_free_image_and_decache();
- imlib_context_set_image(imge);
-
- return imge;
- }
-
- if( strcmp( filter, "cool_text" ) == 0 )
- {
- return imge;
- }
- if( strcmp( filter, "gradient" ) == 0 )
- {
- int angle = 0;
- for( ptr = params; ptr != NULL; ptr = ptr->next )
- {
- ASSIGN_INT( "angle", angle );
- }
- return imge;
- }
+ anoim = imlib_create_image(w, h);
+ cm = imlib_create_color_modifier();
+ imlib_context_set_color_modifier(cm);
+ imlib_context_set_image(anoim);
+
+ imlib_context_set_color(r, g, b, 255);
+ imlib_image_fill_rectangle(0, 0, w, h);
+ imlib_context_set_blend(1);
+ imlib_image_set_has_alpha(1);
+
+ memset(atab, a, sizeof(atab));
+ imlib_set_color_modifier_tables(NULL, NULL, NULL, atab);
+ imlib_apply_color_modifier_to_rectangle(0, 0, w, h);
+
+ imlib_context_set_image(imge);
+ imlib_blend_image_onto_image(anoim, 0, 0, 0, w, h, x, y, w, h);
+
+ imlib_free_color_modifier();
+ imlib_context_set_image(anoim);
+ imlib_free_image_and_decache();
+ imlib_context_set_image(imge);
+
+ return imge;
+ }
+
+ if (strcmp(filter, "cool_text") == 0)
+ {
+ return imge;
+ }
+ if (strcmp(filter, "gradient") == 0)
+ {
+ int angle = 0;
+
+ for (ptr = params; ptr != NULL; ptr = ptr->next)
+ {
+ ASSIGN_INT("angle", angle);
+ }
+ return imge;
+ }
return imge;
}
diff --git a/imlib2.pc.in b/imlib2.pc.in
index 42a989b..a8a7548 100644
--- a/imlib2.pc.in
+++ b/imlib2.pc.in
@@ -8,5 +8,5 @@ Description: Powerful image loading and rendering library
Version: @VERSION@
Requires: @REQUIREMENTS@
Libs: -L${libdir} -lImlib2 @freetype_libs@ -lm @x_libs@ @x_ldflags@ @dlopen_libs@
-Cflags: -I${includedir} @x_includes@ @freetype_includes@
+Cflags: -I${includedir} @x_includes@ @freetype_cflags@
diff --git a/loaders/loader_argb.c b/loaders/loader_argb.c
index 556de19..78a92ec 100644
--- a/loaders/loader_argb.c
+++ b/loaders/loader_argb.c
@@ -9,11 +9,11 @@
#include <X11/Xutil.h>
#include "image.h"
-char load (ImlibImage *im, ImlibProgressFunction progress,
- char progress_granularity, char immediate_load);
-char save (ImlibImage *im, ImlibProgressFunction progress,
- char progress_granularity);
-void formats (ImlibLoader *l);
+char load(ImlibImage * im, ImlibProgressFunction progress,
+ char progress_granularity, char immediate_load);
+char save(ImlibImage * im, ImlibProgressFunction progress,
+ char progress_granularity);
+void formats(ImlibLoader * l);
#define SWAP32(x) (x) = \
((((x) & 0x000000ff ) << 24) |\
@@ -21,13 +21,13 @@ void formats (ImlibLoader *l);
(((x) & 0x00ff0000 ) >> 8) |\
(((x) & 0xff000000 ) >> 24))
-char
-load (ImlibImage *im, ImlibProgressFunction progress,
- char progress_granularity, char immediate_load)
+char
+load(ImlibImage * im, ImlibProgressFunction progress,
+ char progress_granularity, char immediate_load)
{
- int w, h, alpha;
+ int w, h, alpha;
FILE *f;
-
+
if (im->data)
return 0;
f = fopen(im->real_file, "rb");
@@ -35,95 +35,95 @@ load (ImlibImage *im, ImlibProgressFunction progress,
return 0;
/* header */
- {
- char buf[256], buf2[256];
-
- if (!fgets(buf, 255, f))
- {
- fclose(f);
- return 0;
- }
- sscanf(buf, "%s %i %i %i", buf2, &w, &h, &alpha);
- if (strcmp(buf2, "ARGB"))
- {
- fclose(f);
- return 0;
- }
- im->w = w;
- im->h = h;
- if (!im->format)
- {
- if (alpha)
- SET_FLAG(im->flags, F_HAS_ALPHA);
- else
- UNSET_FLAG(im->flags, F_HAS_ALPHA);
- im->format = strdup("argb");
- }
- }
+ {
+ char buf[256], buf2[256];
+
+ if (!fgets(buf, 255, f))
+ {
+ fclose(f);
+ return 0;
+ }
+ sscanf(buf, "%s %i %i %i", buf2, &w, &h, &alpha);
+ if (strcmp(buf2, "ARGB"))
+ {
+ fclose(f);
+ return 0;
+ }
+ im->w = w;
+ im->h = h;
+ if (!im->format)
+ {
+ if (alpha)
+ SET_FLAG(im->flags, F_HAS_ALPHA);
+ else
+ UNSET_FLAG(im->flags, F_HAS_ALPHA);
+ im->format = strdup("argb");
+ }
+ }
if (((!im->data) && (im->loader)) || (immediate_load) || (progress))
{
- DATA32 *ptr;
- int y, pl = 0;
- char pper = 0;
-
- /* must set the im->data member before callign progress function */
- ptr = im->data = malloc(w * h * sizeof(DATA32));
- if (!im->data)
- {
- fclose(f);
- return 0;
- }
- for (y = 0; y < h; y++)
- {
+ DATA32 *ptr;
+ int y, pl = 0;
+ char pper = 0;
+
+ /* must set the im->data member before callign progress function */
+ ptr = im->data = malloc(w * h * sizeof(DATA32));
+ if (!im->data)
+ {
+ fclose(f);
+ return 0;
+ }
+ for (y = 0; y < h; y++)
+ {
#ifdef WORDS_BIGENDIAN
- {
- int x;
-
- fread(ptr, im->w, 4, f);
- for (x = 0; x < im->w; x++)
- SWAP32(ptr[x]);
- }
+ {
+ int x;
+
+ fread(ptr, im->w, 4, f);
+ for (x = 0; x < im->w; x++)
+ SWAP32(ptr[x]);
+ }
#else
- fread(ptr, im->w, 4, f);
-#endif
- ptr += im->w;
- if (progress)
- {
- char per;
- int l;
-
- per = (char)((100 * y) / im->h);
- if (((per - pper) >= progress_granularity) ||
- (y == (im->h - 1)))
- {
- l = y - pl;
- if(!progress(im, per, 0, (y - l), im->w, l))
- {
- fclose(f);
- return 2;
- }
- pper = per;
- pl = y;
- }
- }
- }
+ fread(ptr, im->w, 4, f);
+#endif
+ ptr += im->w;
+ if (progress)
+ {
+ char per;
+ int l;
+
+ per = (char)((100 * y) / im->h);
+ if (((per - pper) >= progress_granularity) ||
+ (y == (im->h - 1)))
+ {
+ l = y - pl;
+ if (!progress(im, per, 0, (y - l), im->w, l))
+ {
+ fclose(f);
+ return 2;
+ }
+ pper = per;
+ pl = y;
+ }
+ }
+ }
}
fclose(f);
return 1;
}
-char
-save (ImlibImage *im, ImlibProgressFunction progress,
- char progress_granularity)
+char
+save(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity)
{
FILE *f;
DATA32 *ptr;
int y, pl = 0, alpha = 0;
char pper = 0;
+
#ifdef WORDS_BIGENDIAN
DATA32 *buf = (DATA32 *) malloc(im->w * 4);
#endif
-
+
/* no image data? abort */
if (!im->data)
return 0;
@@ -132,47 +132,45 @@ save (ImlibImage *im, ImlibProgressFunction progress,
return 0;
if (im->flags & F_HAS_ALPHA)
alpha = 1;
- fprintf(f, "ARGB %i %i %i\n",
- im->w, im->h, alpha);
+ fprintf(f, "ARGB %i %i %i\n", im->w, im->h, alpha);
ptr = im->data;
for (y = 0; y < im->h; y++)
{
#ifdef WORDS_BIGENDIAN
- {
- int x;
-
- memcpy(buf, ptr, im->w * 4);
- for (x = 0; x < im->w; x++)
- SWAP32(buf[x]);
- fwrite(buf, im->w, 4, f);
- }
+ {
+ int x;
+
+ memcpy(buf, ptr, im->w * 4);
+ for (x = 0; x < im->w; x++)
+ SWAP32(buf[x]);
+ fwrite(buf, im->w, 4, f);
+ }
#else
- fwrite(ptr, im->w, 4, f);
+ fwrite(ptr, im->w, 4, f);
#endif
- ptr += im->w;
- if (progress)
- {
- char per;
- int l;
-
- per = (char)((100 * y) / im->h);
- if (((per - pper) >= progress_granularity) ||
- (y == (im->h - 1)))
- {
+ ptr += im->w;
+ if (progress)
+ {
+ char per;
+ int l;
+
+ per = (char)((100 * y) / im->h);
+ if (((per - pper) >= progress_granularity) || (y == (im->h - 1)))
+ {
l = y - pl;
- if(!progress(im, per, 0, (y - l), im->w, l))
- {
+ if (!progress(im, per, 0, (y - l), im->w, l))
+ {
#ifdef WORDS_BIGENDIAN
- if (buf)
- free(buf);
+ if (buf)
+ free(buf);
#endif
- fclose(f);
- return 2;
- }
- pper = per;
- pl = y;
- }
- }
+ fclose(f);
+ return 2;
+ }
+ pper = per;
+ pl = y;
+ }
+ }
}
/* finish off */
#ifdef WORDS_BIGENDIAN
@@ -183,19 +181,17 @@ save (ImlibImage *im, ImlibProgressFunction progress,
return 1;
}
-void
-formats (ImlibLoader *l)
-{
- char *list_formats[] =
- { "argb", "arg" };
+void
+formats(ImlibLoader * l)
+{
+ char *list_formats[] = { "argb", "arg" };
+
+ {
+ int i;
- {
- int i;
-
- l->num_formats = (sizeof(list_formats) / sizeof (char *));
- l->formats = malloc(sizeof(char *) * l->num_formats);
- for (i = 0; i < l->num_formats; i++)
- l->formats[i] = strdup(list_formats[i]);
- }
+ l->num_formats = (sizeof(list_formats) / sizeof(char *));
+ l->formats = malloc(sizeof(char *) * l->num_formats);
+ for (i = 0; i < l->num_formats; i++)
+ l->formats[i] = strdup(list_formats[i]);
+ }
}
-
diff --git a/loaders/loader_bmp.c b/loaders/loader_bmp.c
index 71fe5dd..21fb662 100644
--- a/loaders/loader_bmp.c
+++ b/loaders/loader_bmp.c
@@ -15,622 +15,706 @@
#include <X11/Xutil.h>
#include "image.h"
-char load (ImlibImage *im, ImlibProgressFunction progress,
- char progress_granularity, char immediate_load);
-char save (ImlibImage *im, ImlibProgressFunction progress,
- char progress_granularity);
-void formats (ImlibLoader *l);
+char load(ImlibImage * im, ImlibProgressFunction progress,
+ char progress_granularity, char immediate_load);
+char save(ImlibImage * im, ImlibProgressFunction progress,
+ char progress_granularity);
+void formats(ImlibLoader * l);
-typedef struct tagRGBQUAD
-{
- unsigned char rgbBlue;
- unsigned char rgbGreen;
- unsigned char rgbRed;
- unsigned char rgbReserved;
-}
-RGBQUAD;
+typedef struct tagRGBQUAD {
+ unsigned char rgbBlue;
+ unsigned char rgbGreen;
+ unsigned char rgbRed;
+ unsigned char rgbReserved;
+} RGBQUAD;
#define BI_RGB 0
#define BI_RLE8 1
#define BI_RLE4 2
#define BI_BITFIELDS 3
-static int ReadleShort(FILE *file, unsigned short *ret)
+static int
+ReadleShort(FILE * file, unsigned short *ret)
{
- unsigned char b[2];
-
+ unsigned char b[2];
+
if (fread(b, sizeof(unsigned char), 2, file) != 2)
return 0;
-
+
*ret = (b[1] << 8) | b[0];
return 1;
}
-static int ReadleLong(FILE *file, unsigned long *ret)
+static int
+ReadleLong(FILE * file, unsigned long *ret)
{
- unsigned char b[4];
-
+ unsigned char b[4];
+
if (fread(b, sizeof(unsigned char), 4, file) != 4)
return 0;
-
+
*ret = (b[3] << 24) | (b[2] << 16) | (b[1] << 8) | b[0];
return 1;
}
-char
-load (ImlibImage *im, ImlibProgressFunction progress,
- char progress_granularity, char immediate_load)
+char
+load(ImlibImage * im, ImlibProgressFunction progress,
+ char progress_granularity, char immediate_load)
{
- FILE *f;
- char pper = 0;
- int pl = 0;
- char type[2];
- unsigned long size, offset, headSize, comp, imgsize, j, k, l;
- unsigned short tmpShort, planes, bitcount, ncols, skip;
- unsigned char tempchar, byte = 0, g, b, r;
- unsigned long i, w, h;
- unsigned short x, y;
- DATA32 *ptr, *data_end;
- unsigned char *buffer_ptr, *buffer, *buffer_end;
- RGBQUAD rgbQuads[256];
- unsigned long rmask = 0xff, gmask = 0xff, bmask = 0xff;
- unsigned long rshift = 0, gshift = 0, bshift = 0;
-
+ FILE *f;
+ char pper = 0;
+ int pl = 0;
+ char type[2];
+ unsigned long size, offset, headSize, comp, imgsize, j, k, l;
+ unsigned short tmpShort, planes, bitcount, ncols, skip;
+ unsigned char tempchar, byte = 0, g, b, r;
+ unsigned long i, w, h;
+ unsigned short x, y;
+ DATA32 *ptr, *data_end;
+ unsigned char *buffer_ptr, *buffer, *buffer_end;
+ RGBQUAD rgbQuads[256];
+ unsigned long rmask = 0xff, gmask = 0xff, bmask = 0xff;
+ unsigned long rshift = 0, gshift = 0, bshift = 0;
+
if (im->data)
return 0;
f = fopen(im->real_file, "rb");
if (!f)
return 0;
-
+
/* header */
- {
- struct stat statbuf;
- if (stat(im->real_file, &statbuf) == -1) {
- fclose(f);
- return 0;
+ {
+ struct stat statbuf;
+
+ if (stat(im->real_file, &statbuf) == -1)
+ {
+ fclose(f);
+ return 0;
}
- size = statbuf.st_size;
-
- if (fread(type, 1, 2, f) != 2) {
- fclose(f);
- return 0;
+ size = statbuf.st_size;
+
+ if (fread(type, 1, 2, f) != 2)
+ {
+ fclose(f);
+ return 0;
}
- if (strncmp(type, "BM", 2)) {
- fclose(f);
- return 0;
+ if (strncmp(type, "BM", 2))
+ {
+ fclose(f);
+ return 0;
}
-
- fseek(f, 8, SEEK_CUR);
- ReadleLong(f, &offset);
- ReadleLong(f, &headSize);
- if (headSize == 12) {
- ReadleShort(f, &tmpShort);
- w = tmpShort;
- ReadleShort(f, &tmpShort);
- h = tmpShort;
- ReadleShort(f, &planes);
- ReadleShort(f, &bitcount);
- imgsize = size - offset;
- comp = BI_RGB;
+
+ fseek(f, 8, SEEK_CUR);
+ ReadleLong(f, &offset);
+ ReadleLong(f, &headSize);
+ if (headSize == 12)
+ {
+ ReadleShort(f, &tmpShort);
+ w = tmpShort;
+ ReadleShort(f, &tmpShort);
+ h = tmpShort;
+ ReadleShort(f, &planes);
+ ReadleShort(f, &bitcount);
+ imgsize = size - offset;
+ comp = BI_RGB;
}
- else if (headSize == 40) {
- ReadleLong(f, &w);
- ReadleLong(f, &h);
- ReadleShort(f, &planes);
- ReadleShort(f, &bitcount);
- ReadleLong(f, &comp);
- ReadleLong(f, &imgsize);
- imgsize = size - offset;
-
- fseek(f, 16, SEEK_CUR);
+ else if (headSize == 40)
+ {
+ ReadleLong(f, &w);
+ ReadleLong(f, &h);
+ ReadleShort(f, &planes);
+ ReadleShort(f, &bitcount);
+ ReadleLong(f, &comp);
+ ReadleLong(f, &imgsize);
+ imgsize = size - offset;
+
+ fseek(f, 16, SEEK_CUR);
+ }
+ else
+ {
+ fclose(f);
+ return 0;
}
- else {
- fclose(f);
- return 0;
+
+ if (bitcount < 16)
+ {
+ ncols = (offset - headSize - 14);
+ if (headSize == 12)
+ {
+ ncols /= 3;
+ for (i = 0; i < ncols; i++)
+ fread(&rgbQuads[i], 3, 1, f);
+ }
+ else
+ {
+ ncols /= 4;
+ fread(rgbQuads, 4, ncols, f);
+ }
}
-
- if (bitcount < 16) {
- ncols = (offset - headSize - 14);
- if (headSize == 12) {
- ncols /= 3;
- for (i = 0; i < ncols; i++)
- fread(&rgbQuads[i], 3, 1, f);
- }
- else {
- ncols /= 4;
- fread(rgbQuads, 4, ncols, f);
- }
+ else if (bitcount == 16 || bitcount == 32)
+ {
+ if (comp == BI_BITFIELDS)
+ {
+ int bit;
+
+ ReadleLong(f, &bmask);
+ ReadleLong(f, &gmask);
+ ReadleLong(f, &rmask);
+ for (bit = bitcount - 1; bit >= 0; bit--)
+ {
+ if (bmask & (1 << bit))
+ bshift = bit;
+ if (gmask & (1 << bit))
+ gshift = bit;
+ if (rmask & (1 << bit))
+ rshift = bit;
+ }
+ }
+ else if (bitcount == 16)
+ {
+ rmask = 0x7C00;
+ gmask = 0x03E0;
+ bmask = 0x001F;
+ rshift = 10;
+ gshift = 5;
+ bshift = 0;
+ }
+ else if (bitcount == 32)
+ {
+ rmask = 0x00FF0000;
+ gmask = 0x0000FF00;
+ bmask = 0x000000FF;
+ rshift = 16;
+ gshift = 8;
+ bshift = 0;
+ }
}
- else if (bitcount == 16 || bitcount == 32) {
- if (comp == BI_BITFIELDS) {
- int bit;
- ReadleLong(f, &bmask);
- ReadleLong(f, &gmask);
- ReadleLong(f, &rmask);
- for (bit = bitcount - 1; bit >= 0; bit--) {
- if (bmask & (1 << bit))
- bshift = bit;
- if (gmask & (1 << bit))
- gshift = bit;
- if (rmask & (1 << bit))
- rshift = bit;
- }
- }
- else if (bitcount == 16) {
- rmask = 0x7C00;
- gmask = 0x03E0;
- bmask = 0x001F;
- rshift = 10;
- gshift = 5;
- bshift = 0;
- }
- else if (bitcount == 32) {
- rmask = 0x00FF0000;
- gmask = 0x0000FF00;
- bmask = 0x000000FF;
- rshift = 16;
- gshift = 8;
- bshift = 0;
- }
+
+ im->w = w;
+ im->h = h;
+ if (!im->format)
+ {
+ UNSET_FLAG(im->flags, F_HAS_ALPHA);
+ im->format = strdup("bmp");
}
-
- im->w = w;
- im->h = h;
- if (!im->format)
- {
- UNSET_FLAG(im->flags, F_HAS_ALPHA);
- im->format = strdup("bmp");
- }
- }
+ }
if (((!im->data) && (im->loader)) || (immediate_load) || (progress))
{
fseek(f, offset, SEEK_SET);
buffer = malloc(imgsize);
- if (!buffer) {
- fclose(f);
- return 0;
- }
+ if (!buffer)
+ {
+ fclose(f);
+ return 0;
+ }
im->data = malloc(w * h * sizeof(DATA32));
- if (!im->data) {
- fclose(f);
- free(buffer);
- return 0;
- }
-
+ if (!im->data)
+ {
+ fclose(f);
+ free(buffer);
+ return 0;
+ }
+
fread(buffer, imgsize, 1, f);
fclose(f);
buffer_ptr = buffer;
buffer_end = buffer + imgsize;
-
+
data_end = im->data + w * h;
ptr = im->data + ((h - 1) * w);
-
- if (bitcount == 1) {
- if (comp == BI_RGB) {
- skip = ((((w + 31) / 32) * 32) - w) / 8;
- for (y = 0; y < h; y++) {
- for (x = 0; x < w && buffer_ptr < buffer_end; x++) {
- if ((x & 7) == 0) byte = *(buffer_ptr++);
- k = (byte >> 7) & 1;
- *ptr++ = 0xff000000 |
- (rgbQuads[k].rgbRed << 16) |
- (rgbQuads[k].rgbGreen << 8) |
- rgbQuads[k].rgbBlue;
- byte <<= 1;
- }
- buffer_ptr += skip;
- ptr -= w * 2;
- if (progress) {
- char per;
- int l;
-
- per = (char)((100 * y) / im->h);
- if (((per - pper) >= progress_granularity) ||
- (y == (im->h - 1)))
- {
- l = y - pl;
- if(!progress(im, per, 0, im->h - y - 1, im->w, im->h - y + l))
- {
- free(buffer);
- return 2;
- }
- pper = per;
- pl = y;
- }
- }
- }
- }
- }
- if (bitcount == 4) {
- if (comp == BI_RLE4) {
- x = 0;
- y = 0;
-
- for (i = 0, g = 1; i < imgsize && g && buffer_ptr < buffer_end; i++) {
- byte = *(buffer_ptr++);
- if (byte) {
- unsigned char t1, t2;
-
- l = byte;
- byte = *(buffer_ptr++);
- t1 = byte & 0xF;
- t2 = (byte >> 4) & 0xF;
- for (j = 0; j < l; j++) {
- k = (j & 1) ? t1 : t2;
-
- if (x >= w)
- break;
-
- *ptr++ = 0xff000000 |
- (rgbQuads[k].rgbRed << 16) |
- (rgbQuads[k].rgbGreen << 8) |
- rgbQuads[k].rgbBlue;
- x++;
- if (ptr > data_end)
- ptr = data_end;
- }
- }
- else {
- byte = *(buffer_ptr++);
- switch (byte) {
- case 0:
- x = 0;
- y++;
- ptr = im->data + ((h - y - 1)
- * w * sizeof(DATA32));
- if (ptr > data_end)
- ptr = data_end;
- break;
- case 1:
- g = 0;
- break;
- case 2:
- x += *(buffer_ptr++);
- y += *(buffer_ptr++);
- ptr = im->data + ((h - y - 1) * w *
- sizeof(DATA32)) + x;
- if (ptr > data_end)
- ptr = data_end;
- break;
- default:
- l = byte;
- for (j = 0; j < l; j++) {
- char t1 = '\0', t2 = '\0';
-
- if ((j & 1) == 0) {
- byte = *(buffer_ptr++);
- t1 = byte & 0xF;
- t2 = (byte >> 4) & 0xF;
- }
- k = (j & 1) ? t1 : t2;
-
- if (x >= w) {
- buffer_ptr += (l - j) / 2;
- break;
- }
-
- *ptr++ = 0xff000000 |
- (rgbQuads[k].rgbRed << 16) |
- (rgbQuads[k].rgbGreen << 8) |
- rgbQuads[k].rgbBlue;
- x++;
-
- if (ptr > data_end)
- ptr = data_end;
-
- }
-
- if ((l & 3) == 1) {
- tempchar = *(buffer_ptr++);
- tempchar = *(buffer_ptr++);
- }
- else if ((l & 3) == 2)
- buffer_ptr++;
- break;
- }
- }
- if (progress) {
- char per;
- int l;
-
- per = (char)((100 * y) / im->h);
- if (((per - pper) >= progress_granularity) ||
- (y == (im->h - 1)))
- {
- l = y - pl;
- if(!progress(im, per, 0, im->h - y - 1, im->w, im->h - y + l))
- {
- free(buffer);
- return 2;
- }
- pper = per;
- pl = y;
- }
- }
-
- }
- }
- else if (comp == BI_RGB) {
- skip = ((((w + 7) / 8) * 8) - w) / 2;
- for (y = 0; y < h; y++) {
- for (x = 0; x < w && buffer_ptr < buffer_end; x++) {
- if ((x & 1) == 0)
- byte = *(buffer_ptr++);
- k = (byte & 0xF0) >> 4;
- *ptr++ = 0xff000000 |
- (rgbQuads[k].rgbRed << 16) |
- (rgbQuads[k].rgbGreen << 8) |
- rgbQuads[k].rgbBlue;
- byte <<= 4;
- }
- buffer_ptr += skip;
- ptr -= w * 2;
- if (progress) {
- char per;
- int l;
-
- per = (char)((100 * y) / im->h);
- if (((per - pper) >= progress_granularity) ||
- (y == (im->h - 1)))
- {
- l = y - pl;
- if(!progress(im, per, 0, im->h - y - 1, im->w, im->h - y + l))
- {
- free(buffer);
- return 2;
- }
- pper = per;
- pl = y;
- }
- }
- }
- }
- }
- if (bitcount == 8) {
- if (comp == BI_RLE8) {
- x = 0;
- y = 0;
- for (i = 0, g = 1; i < imgsize && buffer_ptr < buffer_end && g; i++) {
- byte = *(buffer_ptr++);
- if (byte) {
- l = byte;
- byte = *(buffer_ptr++);
- for (j = 0; j < l; j++) {
- if (x >= w)
- break;
-
- *ptr++ = 0xff000000 |
- (rgbQuads[byte].rgbRed << 16) |
- (rgbQuads[byte].rgbGreen << 8) |
- rgbQuads[byte].rgbBlue;
-
- x++;
- if (ptr > data_end)
- ptr = data_end;
- }
- }
- else {
- byte = *(buffer_ptr++);
- switch (byte) {
- case 0:
- x = 0;
- y++;
- ptr = im->data + ((h - y - 1)
- * w * sizeof(DATA32));
- if (ptr > data_end)
- ptr = data_end;
- break;
- case 1:
- g = 0;
- break;
- case 2:
- x += *(buffer_ptr++);
- y += *(buffer_ptr++);
- ptr = im->data + ((h - y - 1)
- * w *
- sizeof(DATA32)) + (x * sizeof(DATA32));
- if (ptr > data_end)
- ptr = data_end;
- break;
- default:
- l = byte;
- for (j = 0; j < l; j++) {
- byte = *(buffer_ptr++);
-
- if (x >= w) {
- buffer_ptr += l - j;
- break;
- }
-
- *ptr++ = 0xff000000 |
- (rgbQuads[byte].rgbRed << 16) |
- (rgbQuads[byte].rgbGreen << 8) |
- rgbQuads[byte].rgbBlue;
- x++;
-
- if (ptr > data_end)
- ptr = data_end;
- }
- if (l & 1)
- buffer_ptr++;
- break;
- }
- }
- }
- if (progress) {
- char per;
- int l;
-
- per = (char)((100 * y) / im->h);
- if (((per - pper) >= progress_granularity) ||
- (y == (im->h - 1)))
- {
- l = y - pl;
- if(!progress(im, per, 0, im->h - y - 1, im->w, im->h - y + l))
- {
- free(buffer);
- return 2;
- }
- pper = per;
- pl = y;
- }
- }
- }
- else if (comp == BI_RGB) {
- skip = (((w + 3) / 4) * 4) - w;
- for (y = 0; y < h; y++) {
- for (x = 0; x < w && buffer_ptr < buffer_end; x++) {
- byte = *(buffer_ptr++);
- *ptr++ = 0xff000000 |
- (rgbQuads[byte].rgbRed << 16) |
- (rgbQuads[byte].rgbGreen << 8) |
- rgbQuads[byte].rgbBlue;
- }
- ptr -= w * 2;
- buffer_ptr += skip;
- if (progress) {
- char per;
- int l;
-
- per = (char)((100 * y) / im->h);
- if (((per - pper) >= progress_granularity) ||
- (y == (im->h - 1)))
- {
- l = y - pl;
- if(!progress(im, per, 0, im->h - y - 1, im->w, im->h - y + l))
- {
- free(buffer);
- return 2;
- }
- pper = per;
- pl = y;
- }
- }
- }
- }
-
- }
- else if (bitcount == 16) {
- skip = (((w * 16 + 31) / 32) * 4) - (w * 2);
- for (y = 0; y < h; y++) {
- for (x = 0; x < w && buffer_ptr < buffer_end; x++) {
- r = ((unsigned short)(*buffer_ptr) & rmask) >> rshift;
- g = ((unsigned short)(*buffer_ptr) & gmask) >> gshift;
- b = ((unsigned short)(*(buffer_ptr++)) & bmask) >> bshift;
- *ptr++ = 0xff000000 | (r << 16) | (g << 8) | b;
- }
- ptr -= w * 2;
- buffer_ptr += skip;
- if (progress) {
- char per;
- int l;
-
- per = (char)((100 * y) / im->h);
- if (((per - pper) >= progress_granularity) ||
- (y == (im->h - 1)))
- {
- l = y - pl;
- if(!progress(im, per, 0, im->h - y - 1, im->w, im->h - y + l))
- {
- free(buffer);
- return 2;
- }
- pper = per;
- pl = y;
- }
- }
- }
- }
- else if (bitcount == 24) {
- skip = (4 - ((w * 3) % 4)) & 3;
- for (y = 0; y < h; y++) {
- for (x = 0; x < w && buffer_ptr < buffer_end; x++) {
- b = *(buffer_ptr++);
- g = *(buffer_ptr++);
- r = *(buffer_ptr++);
- *ptr++ = 0xff000000 | (r << 16) | (g << 8) | b;
- }
- ptr -= w * 2;
- buffer_ptr += skip;
- if (progress) {
- char per;
- int l;
-
- per = (char)((100 * y) / im->h);
- if (((per - pper) >= progress_granularity) ||
- (y == (im->h - 1)))
- {
- l = y - pl;
- if(!progress(im, per, 0, im->h - y - 1, im->w, im->h - y + l))
- {
- free(buffer);
- return 2;
- }
- pper = per;
- pl = y;
- }
- }
- }
- }
- else if (bitcount == 32) {
- skip = (((w * 32 + 31) / 32) * 4) - (w * 4);
- for (y = 0; y < h; y++) {
- for (x = 0; x < w && buffer_ptr < buffer_end; x++) {
- r = ((unsigned long)(*buffer_ptr) & rmask) >> rshift;
- g = ((unsigned long)(*buffer_ptr) & gmask) >> gshift;
- b = ((unsigned long)(*buffer_ptr) & bmask) >> bshift;
- *ptr++ = 0xff000000 | (r << 16) | (g << 8) | b;
- r = *(buffer_ptr++);
- r = *(buffer_ptr++);
- }
- ptr -= w * 2;
- buffer_ptr += skip;
- if (progress) {
- char per;
- int l;
-
- per = (char)((100 * y) / im->h);
- if (((per - pper) >= progress_granularity) ||
- (y == (im->h - 1)))
- {
- l = y - pl;
- if(!progress(im, per, 0, im->h - y - 1, im->w, im->h - y + l))
- {
- free(buffer);
- return 2;
- }
- pper = per;
- pl = y;
- }
- }
- }
- }
+
+ if (bitcount == 1)
+ {
+ if (comp == BI_RGB)
+ {
+ skip = ((((w + 31) / 32) * 32) - w) / 8;
+ for (y = 0; y < h; y++)
+ {
+ for (x = 0; x < w && buffer_ptr < buffer_end; x++)
+ {
+ if ((x & 7) == 0)
+ byte = *(buffer_ptr++);
+ k = (byte >> 7) & 1;
+ *ptr++ = 0xff000000 |
+ (rgbQuads[k].rgbRed << 16) |
+ (rgbQuads[k].rgbGreen << 8) |
+ rgbQuads[k].rgbBlue;
+ byte <<= 1;
+ }
+ buffer_ptr += skip;
+ ptr -= w * 2;
+ if (progress)
+ {
+ char per;
+ int l;
+
+ per = (char)((100 * y) / im->h);
+ if (((per - pper) >= progress_granularity) ||
+ (y == (im->h - 1)))
+ {
+ l = y - pl;
+ if (!progress
+ (im, per, 0, im->h - y - 1, im->w,
+ im->h - y + l))
+ {
+ free(buffer);
+ return 2;
+ }
+ pper = per;
+ pl = y;
+ }
+ }
+ }
+ }
+ }
+ if (bitcount == 4)
+ {
+ if (comp == BI_RLE4)
+ {
+ x = 0;
+ y = 0;
+
+ for (i = 0, g = 1;
+ i < imgsize && g && buffer_ptr < buffer_end; i++)
+ {
+ byte = *(buffer_ptr++);
+ if (byte)
+ {
+ unsigned char t1, t2;
+
+ l = byte;
+ byte = *(buffer_ptr++);
+ t1 = byte & 0xF;
+ t2 = (byte >> 4) & 0xF;
+ for (j = 0; j < l; j++)
+ {
+ k = (j & 1) ? t1 : t2;
+
+ if (x >= w)
+ break;
+
+ *ptr++ = 0xff000000 |
+ (rgbQuads[k].rgbRed << 16) |
+ (rgbQuads[k].rgbGreen << 8) |
+ rgbQuads[k].rgbBlue;
+ x++;
+ if (ptr > data_end)
+ ptr = data_end;
+ }
+ }
+ else
+ {
+ byte = *(buffer_ptr++);
+ switch (byte)
+ {
+ case 0:
+ x = 0;
+ y++;
+ ptr = im->data + ((h - y - 1)
+ * w * sizeof(DATA32));
+ if (ptr > data_end)
+ ptr = data_end;
+ break;
+ case 1:
+ g = 0;
+ break;
+ case 2:
+ x += *(buffer_ptr++);
+ y += *(buffer_ptr++);
+ ptr = im->data + ((h - y - 1) * w *
+ sizeof(DATA32)) + x;
+ if (ptr > data_end)
+ ptr = data_end;
+ break;
+ default:
+ l = byte;
+ for (j = 0; j < l; j++)
+ {
+ char t1 = '\0', t2 =
+ '\0';
+
+ if ((j & 1) == 0)
+ {
+ byte = *(buffer_ptr++);
+ t1 = byte & 0xF;
+ t2 = (byte >> 4) & 0xF;
+ }
+ k = (j & 1) ? t1 : t2;
+
+ if (x >= w)
+ {
+ buffer_ptr += (l - j) / 2;
+ break;
+ }
+
+ *ptr++ = 0xff000000 |
+ (rgbQuads[k].rgbRed << 16) |
+ (rgbQuads[k].rgbGreen << 8) |
+ rgbQuads[k].rgbBlue;
+ x++;
+
+ if (ptr > data_end)
+ ptr = data_end;
+
+ }
+
+ if ((l & 3) == 1)
+ {
+ tempchar = *(buffer_ptr++);
+ tempchar = *(buffer_ptr++);
+ }
+ else if ((l & 3) == 2)
+ buffer_ptr++;
+ break;
+ }
+ }
+ if (progress)
+ {
+ char per;
+ int l;
+
+ per = (char)((100 * y) / im->h);
+ if (((per - pper) >= progress_granularity) ||
+ (y == (im->h - 1)))
+ {
+ l = y - pl;
+ if (!progress
+ (im, per, 0, im->h - y - 1, im->w,
+ im->h - y + l))
+ {
+ free(buffer);
+ return 2;
+ }
+ pper = per;
+ pl = y;
+ }
+ }
+
+ }
+ }
+ else if (comp == BI_RGB)
+ {
+ skip = ((((w + 7) / 8) * 8) - w) / 2;
+ for (y = 0; y < h; y++)
+ {
+ for (x = 0; x < w && buffer_ptr < buffer_end; x++)
+ {
+ if ((x & 1) == 0)
+ byte = *(buffer_ptr++);
+ k = (byte & 0xF0) >> 4;
+ *ptr++ = 0xff000000 |
+ (rgbQuads[k].rgbRed << 16) |
+ (rgbQuads[k].rgbGreen << 8) |
+ rgbQuads[k].rgbBlue;
+ byte <<= 4;
+ }
+ buffer_ptr += skip;
+ ptr -= w * 2;
+ if (progress)
+ {
+ char per;
+ int l;
+
+ per = (char)((100 * y) / im->h);
+ if (((per - pper) >= progress_granularity) ||
+ (y == (im->h - 1)))
+ {
+ l = y - pl;
+ if (!progress
+ (im, per, 0, im->h - y - 1, im->w,
+ im->h - y + l))
+ {
+ free(buffer);
+ return 2;
+ }
+ pper = per;
+ pl = y;
+ }
+ }
+ }
+ }
+ }
+ if (bitcount == 8)
+ {
+ if (comp == BI_RLE8)
+ {
+ x = 0;
+ y = 0;
+ for (i = 0, g = 1;
+ i < imgsize && buffer_ptr < buffer_end && g; i++)
+ {
+ byte = *(buffer_ptr++);
+ if (byte)
+ {
+ l = byte;
+ byte = *(buffer_ptr++);
+ for (j = 0; j < l; j++)
+ {
+ if (x >= w)
+ break;
+
+ *ptr++ = 0xff000000 |
+ (rgbQuads[byte].rgbRed << 16) |
+ (rgbQuads[byte].rgbGreen << 8) |
+ rgbQuads[byte].rgbBlue;
+
+ x++;
+ if (ptr > data_end)
+ ptr = data_end;
+ }
+ }
+ else
+ {
+ byte = *(buffer_ptr++);
+ switch (byte)
+ {
+ case 0:
+ x = 0;
+ y++;
+ ptr = im->data + ((h - y - 1)
+ * w * sizeof(DATA32));
+ if (ptr > data_end)
+ ptr = data_end;
+ break;
+ case 1:
+ g = 0;
+ break;
+ case 2:
+ x += *(buffer_ptr++);
+ y += *(buffer_ptr++);
+ ptr = im->data + ((h - y - 1)
+ * w *
+ sizeof(DATA32)) +
+ (x * sizeof(DATA32));
+ if (ptr > data_end)
+ ptr = data_end;
+ break;
+ default:
+ l = byte;
+ for (j = 0; j < l; j++)
+ {
+ byte = *(buffer_ptr++);
+
+ if (x >= w)
+ {
+ buffer_ptr += l - j;
+ break;
+ }
+
+ *ptr++ = 0xff000000 |
+ (rgbQuads[byte].rgbRed << 16) |
+ (rgbQuads[byte].rgbGreen << 8) |
+ rgbQuads[byte].rgbBlue;
+ x++;
+
+ if (ptr > data_end)
+ ptr = data_end;
+ }
+ if (l & 1)
+ buffer_ptr++;
+ break;
+ }
+ }
+ }
+ if (progress)
+ {
+ char per;
+ int l;
+
+ per = (char)((100 * y) / im->h);
+ if (((per - pper) >= progress_granularity) ||
+ (y == (im->h - 1)))
+ {
+ l = y - pl;
+ if (!progress
+ (im, per, 0, im->h - y - 1, im->w,
+ im->h - y + l))
+ {
+ free(buffer);
+ return 2;
+ }
+ pper = per;
+ pl = y;
+ }
+ }
+ }
+ else if (comp == BI_RGB)
+ {
+ skip = (((w + 3) / 4) * 4) - w;
+ for (y = 0; y < h; y++)
+ {
+ for (x = 0; x < w && buffer_ptr < buffer_end; x++)
+ {
+ byte = *(buffer_ptr++);
+ *ptr++ = 0xff000000 |
+ (rgbQuads[byte].rgbRed << 16) |
+ (rgbQuads[byte].rgbGreen << 8) |
+ rgbQuads[byte].rgbBlue;
+ }
+ ptr -= w * 2;
+ buffer_ptr += skip;
+ if (progress)
+ {
+ char per;
+ int l;
+
+ per = (char)((100 * y) / im->h);
+ if (((per - pper) >= progress_granularity) ||
+ (y == (im->h - 1)))
+ {
+ l = y - pl;
+ if (!progress
+ (im, per, 0, im->h - y - 1, im->w,
+ im->h - y + l))
+ {
+ free(buffer);
+ return 2;
+ }
+ pper = per;
+ pl = y;
+ }
+ }
+ }
+ }
+
+ }
+ else if (bitcount == 16)
+ {
+ skip = (((w * 16 + 31) / 32) * 4) - (w * 2);
+ for (y = 0; y < h; y++)
+ {
+ for (x = 0; x < w && buffer_ptr < buffer_end; x++)
+ {
+ r = ((unsigned short)(*buffer_ptr) & rmask) >> rshift;
+ g = ((unsigned short)(*buffer_ptr) & gmask) >> gshift;
+ b = ((unsigned short)(*(buffer_ptr++)) & bmask) >>
+ bshift;
+ *ptr++ = 0xff000000 | (r << 16) | (g << 8) | b;
+ }
+ ptr -= w * 2;
+ buffer_ptr += skip;
+ if (progress)
+ {
+ char per;
+ int l;
+
+ per = (char)((100 * y) / im->h);
+ if (((per - pper) >= progress_granularity) ||
+ (y == (im->h - 1)))
+ {
+ l = y - pl;
+ if (!progress
+ (im, per, 0, im->h - y - 1, im->w,
+ im->h - y + l))
+ {
+ free(buffer);
+ return 2;
+ }
+ pper = per;
+ pl = y;
+ }
+ }
+ }
+ }
+ else if (bitcount == 24)
+ {
+ skip = (4 - ((w * 3) % 4)) & 3;
+ for (y = 0; y < h; y++)
+ {
+ for (x = 0; x < w && buffer_ptr < buffer_end; x++)
+ {
+ b = *(buffer_ptr++);
+ g = *(buffer_ptr++);
+ r = *(buffer_ptr++);
+ *ptr++ = 0xff000000 | (r << 16) | (g << 8) | b;
+ }
+ ptr -= w * 2;
+ buffer_ptr += skip;
+ if (progress)
+ {
+ char per;
+ int l;
+
+ per = (char)((100 * y) / im->h);
+ if (((per - pper) >= progress_granularity) ||
+ (y == (im->h - 1)))
+ {
+ l = y - pl;
+ if (!progress
+ (im, per, 0, im->h - y - 1, im->w,
+ im->h - y + l))
+ {
+ free(buffer);
+ return 2;
+ }
+ pper = per;
+ pl = y;
+ }
+ }
+ }
+ }
+ else if (bitcount == 32)
+ {
+ skip = (((w * 32 + 31) / 32) * 4) - (w * 4);
+ for (y = 0; y < h; y++)
+ {
+ for (x = 0; x < w && buffer_ptr < buffer_end; x++)
+ {
+ r = ((unsigned long)(*buffer_ptr) & rmask) >> rshift;
+ g = ((unsigned long)(*buffer_ptr) & gmask) >> gshift;
+ b = ((unsigned long)(*buffer_ptr) & bmask) >> bshift;
+ *ptr++ = 0xff000000 | (r << 16) | (g << 8) | b;
+ r = *(buffer_ptr++);
+ r = *(buffer_ptr++);
+ }
+ ptr -= w * 2;
+ buffer_ptr += skip;
+ if (progress)
+ {
+ char per;
+ int l;
+
+ per = (char)((100 * y) / im->h);
+ if (((per - pper) >= progress_granularity) ||
+ (y == (im->h - 1)))
+ {
+ l = y - pl;
+ if (!progress
+ (im, per, 0, im->h - y - 1, im->w,
+ im->h - y + l))
+ {
+ free(buffer);
+ return 2;
+ }
+ pper = per;
+ pl = y;
+ }
+ }
+ }
+ }
free(buffer);
}
return 1;
}
-char
-save (ImlibImage *im, ImlibProgressFunction progress,
- char progress_granularity)
+char
+save(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity)
{
/* TODO */
return 0;
}
-void
-formats (ImlibLoader *l)
-{
- char *list_formats[] =
- { "bmp" };
-
- {
- int i;
-
- l->num_formats = (sizeof(list_formats) / sizeof (char *));
- l->formats = malloc(sizeof(char *) * l->num_formats);
- for (i = 0; i < l->num_formats; i++)
- l->formats[i] = strdup(list_formats[i]);
- }
-}
+void
+formats(ImlibLoader * l)
+{
+ char *list_formats[] = { "bmp" };
+
+ {
+ int i;
+ l->num_formats = (sizeof(list_formats) / sizeof(char *));
+ l->formats = malloc(sizeof(char *) * l->num_formats);
+ for (i = 0; i < l->num_formats; i++)
+ l->formats[i] = strdup(list_formats[i]);
+ }
+}
diff --git a/loaders/loader_gif.c b/loaders/loader_gif.c
index b11291f..6511312 100644
--- a/loaders/loader_gif.c
+++ b/loaders/loader_gif.c
@@ -14,171 +14,211 @@
#include "image.h"
#include <gif_lib.h>
-char load(ImlibImage *im, ImlibProgressFunction progress,char progress_granularity, char immediate_load);
-char save(ImlibImage *im, ImlibProgressFunction progress, char progress_granularity);
-void formats(ImlibLoader *l);
+char load(ImlibImage * im, ImlibProgressFunction progress,
+ char progress_granularity, char immediate_load);
+char save(ImlibImage * im, ImlibProgressFunction progress,
+ char progress_granularity);
+void formats(ImlibLoader * l);
-char
-load(ImlibImage *im, ImlibProgressFunction progress, char progress_granularity, char immediate_load)
+char
+load(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity,
+ char immediate_load)
{
- DATA32 *ptr;
- GifFileType *gif;
- GifRowType *rows;
- GifRecordType rec;
- ColorMapObject *cmap;
- int i, j, done, bg, r, g, b, w = 0, h = 0;
- float per = 0.0, per_inc;
- int last_per = 0, last_y = 0;
- int intoffset[] = {0, 4, 2, 1};
- int intjump[] = {8, 8, 4, 2};
- int transp;
- int fd;
+ DATA32 *ptr;
+ GifFileType *gif;
+ GifRowType *rows;
+ GifRecordType rec;
+ ColorMapObject *cmap;
+ int i, j, done, bg, r, g, b, w = 0, h = 0;
+ float per = 0.0, per_inc;
+ int last_per = 0, last_y = 0;
+ int intoffset[] = { 0, 4, 2, 1 };
+ int intjump[] = { 8, 8, 4, 2 };
+ int transp;
+ int fd;
- done = 0;
- rows = NULL;
- transp = -1;
+ done = 0;
+ rows = NULL;
+ transp = -1;
- /* if immediate_load is 1, then dont delay image laoding as below, or */
- /* already data in this image - dont load it again */
- if (im->data)
+ /* if immediate_load is 1, then dont delay image laoding as below, or */
+ /* already data in this image - dont load it again */
+ if (im->data)
return 0;
-#ifndef __EMX__
- fd = open(im->real_file, O_RDONLY);
-#else
- fd = open(im->real_file, O_RDONLY | O_BINARY);
-#endif
- if (fd < 0)
- return 0;
- gif = DGifOpenFileHandle(fd);
- if (!gif) {
- close(fd);
+#ifndef __EMX__
+ fd = open(im->real_file, O_RDONLY);
+#else
+ fd = open(im->real_file, O_RDONLY | O_BINARY);
+#endif
+ if (fd < 0)
return 0;
- }
- do {
- if (DGifGetRecordType(gif, &rec) == GIF_ERROR) {
- /* PrintGifError(); */
- rec = TERMINATE_RECORD_TYPE;
- }
- if ((rec == IMAGE_DESC_RECORD_TYPE) && (!done)) {
- if (DGifGetImageDesc(gif) == GIF_ERROR) {
- /* PrintGifError(); */
- rec = TERMINATE_RECORD_TYPE;
- }
- w = gif->Image.Width;
- h = gif->Image.Height;
- rows = malloc(h * sizeof(GifRowType *));
- if (!rows) {
- DGifCloseFile(gif);
+ gif = DGifOpenFileHandle(fd);
+ if (!gif)
+ {
+ close(fd);
return 0;
- }
- for (i = 0; i < h; i++) {
- rows[i] = NULL;
- }
- for (i = 0; i < h; i++) {
- rows[i] = malloc(w * sizeof(GifPixelType));
- if (!rows[i]) {
- DGifCloseFile(gif);
- for (i = 0; i < h; i++) {
- if (rows[i]) {
- free(rows[i]);
- }
+ }
+ do
+ {
+ if (DGifGetRecordType(gif, &rec) == GIF_ERROR)
+ {
+ /* PrintGifError(); */
+ rec = TERMINATE_RECORD_TYPE;
}
- free(rows);
- return 0;
- }
- }
- if (gif->Image.Interlace) {
- for (i = 0; i < 4; i++) {
- for (j = intoffset[i]; j < h; j += intjump[i]) {
- DGifGetLine(gif, rows[j], w);
+ if ((rec == IMAGE_DESC_RECORD_TYPE) && (!done))
+ {
+ if (DGifGetImageDesc(gif) == GIF_ERROR)
+ {
+ /* PrintGifError(); */
+ rec = TERMINATE_RECORD_TYPE;
+ }
+ w = gif->Image.Width;
+ h = gif->Image.Height;
+ rows = malloc(h * sizeof(GifRowType *));
+ if (!rows)
+ {
+ DGifCloseFile(gif);
+ return 0;
+ }
+ for (i = 0; i < h; i++)
+ {
+ rows[i] = NULL;
+ }
+ for (i = 0; i < h; i++)
+ {
+ rows[i] = malloc(w * sizeof(GifPixelType));
+ if (!rows[i])
+ {
+ DGifCloseFile(gif);
+ for (i = 0; i < h; i++)
+ {
+ if (rows[i])
+ {
+ free(rows[i]);
+ }
+ }
+ free(rows);
+ return 0;
+ }
+ }
+ if (gif->Image.Interlace)
+ {
+ for (i = 0; i < 4; i++)
+ {
+ for (j = intoffset[i]; j < h; j += intjump[i])
+ {
+ DGifGetLine(gif, rows[j], w);
+ }
+ }
+ }
+ else
+ {
+ for (i = 0; i < h; i++)
+ {
+ DGifGetLine(gif, rows[i], w);
+ }
+ }
+ done = 1;
}
- }
- } else {
- for (i = 0; i < h; i++) {
- DGifGetLine(gif, rows[i], w);
- }
- }
- done = 1;
- } else if (rec == EXTENSION_RECORD_TYPE) {
- int ext_code;
- GifByteType *ext;
+ else if (rec == EXTENSION_RECORD_TYPE)
+ {
+ int ext_code;
+ GifByteType *ext;
- ext = NULL;
- DGifGetExtension(gif, &ext_code, &ext);
- while (ext) {
- if ((ext_code == 0xf9) && (ext[1] & 1) && (transp < 0)) {
- transp = (int) ext[4];
- }
- ext = NULL;
- DGifGetExtensionNext(gif, &ext);
- }
- }
- } while (rec != TERMINATE_RECORD_TYPE);
- if (transp >= 0) {
- SET_FLAG(im->flags, F_HAS_ALPHA);
- } else {
- UNSET_FLAG(im->flags, F_HAS_ALPHA);
- }
- /* set the format string member to the lower-case full extension */
- /* name for the format - so example names would be: */
- /* "png", "jpeg", "tiff", "ppm", "pgm", "pbm", "gif", "xpm" ... */
+ ext = NULL;
+ DGifGetExtension(gif, &ext_code, &ext);
+ while (ext)
+ {
+ if ((ext_code == 0xf9) && (ext[1] & 1) && (transp < 0))
+ {
+ transp = (int)ext[4];
+ }
+ ext = NULL;
+ DGifGetExtensionNext(gif, &ext);
+ }
+ }
+ } while (rec != TERMINATE_RECORD_TYPE);
+ if (transp >= 0)
+ {
+ SET_FLAG(im->flags, F_HAS_ALPHA);
+ }
+ else
+ {
+ UNSET_FLAG(im->flags, F_HAS_ALPHA);
+ }
+ /* set the format string member to the lower-case full extension */
+ /* name for the format - so example names would be: */
+ /* "png", "jpeg", "tiff", "ppm", "pgm", "pbm", "gif", "xpm" ... */
im->w = w;
im->h = h;
if (!im->format)
im->format = strdup("gif");
- if (im->loader || immediate_load || progress) {
- bg = gif->SBackGroundColor;
- cmap = (gif->Image.ColorMap ? gif->Image.ColorMap : gif->SColorMap);
- im->data = (DATA32 *) malloc(sizeof(DATA32) * w * h);
- if (!im->data) {
- DGifCloseFile(gif);
- free(rows);
- return 0;
- }
- ptr = im->data;
- per_inc = 100.0 / (((float) w) * h);
- for (i = 0; i < h; i++) {
- for (j = 0; j < w; j++) {
- if (rows[i][j] == transp) {
- r = cmap->Colors[bg].Red;
- g = cmap->Colors[bg].Green;
- b = cmap->Colors[bg].Blue;
- *ptr++ = 0x00ffffff & ((r << 16) | (g << 8) | b);
- } else {
- r = cmap->Colors[rows[i][j]].Red;
- g = cmap->Colors[rows[i][j]].Green;
- b = cmap->Colors[rows[i][j]].Blue;
- *ptr++ = (0xff << 24) | (r << 16) | (g << 8) | b;
- }
- per += per_inc;
- if (progress && (((int) per) != last_per) && (((int) per) % progress_granularity == 0)) {
- last_per = (int) per;
- if (!(progress(im, (int) per, 0, last_y, w, i))) {
- DGifCloseFile(gif);
- for (i = 0; i < h; i++) {
- free(rows[i]);
- }
- free(rows);
- return 2;
+ if (im->loader || immediate_load || progress)
+ {
+ bg = gif->SBackGroundColor;
+ cmap = (gif->Image.ColorMap ? gif->Image.ColorMap : gif->SColorMap);
+ im->data = (DATA32 *) malloc(sizeof(DATA32) * w * h);
+ if (!im->data)
+ {
+ DGifCloseFile(gif);
+ free(rows);
+ return 0;
}
- last_y = i;
- }
- }
- }
- }
- if (progress) {
- progress(im, 100, 0, last_y, w, h);
- }
- DGifCloseFile(gif);
- for (i = 0; i < h; i++) {
- free(rows[i]);
- }
- free(rows);
- return 1;
+ ptr = im->data;
+ per_inc = 100.0 / (((float)w) * h);
+ for (i = 0; i < h; i++)
+ {
+ for (j = 0; j < w; j++)
+ {
+ if (rows[i][j] == transp)
+ {
+ r = cmap->Colors[bg].Red;
+ g = cmap->Colors[bg].Green;
+ b = cmap->Colors[bg].Blue;
+ *ptr++ = 0x00ffffff & ((r << 16) | (g << 8) | b);
+ }
+ else
+ {
+ r = cmap->Colors[rows[i][j]].Red;
+ g = cmap->Colors[rows[i][j]].Green;
+ b = cmap->Colors[rows[i][j]].Blue;
+ *ptr++ = (0xff << 24) | (r << 16) | (g << 8) | b;
+ }
+ per += per_inc;
+ if (progress && (((int)per) != last_per)
+ && (((int)per) % progress_granularity == 0))
+ {
+ last_per = (int)per;
+ if (!(progress(im, (int)per, 0, last_y, w, i)))
+ {
+ DGifCloseFile(gif);
+ for (i = 0; i < h; i++)
+ {
+ free(rows[i]);
+ }
+ free(rows);
+ return 2;
+ }
+ last_y = i;
+ }
+ }
+ }
+ }
+ if (progress)
+ {
+ progress(im, 100, 0, last_y, w, h);
+ }
+ DGifCloseFile(gif);
+ for (i = 0; i < h; i++)
+ {
+ free(rows[i]);
+ }
+ free(rows);
+ return 1;
}
-char
-save(ImlibImage *im, ImlibProgressFunction progress, char progress_granularity)
+char
+save(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity)
{
return 0;
im = NULL;
@@ -193,22 +233,20 @@ save(ImlibImage *im, ImlibProgressFunction progress, char progress_granularity)
/* your laoder CAN load more than one format if it likes - like: */
/* loader->formats = { "gif", "png", "jpeg", "jpg"} */
/* if it can load those formats. */
-void
-formats (ImlibLoader *l)
-{
+void
+formats(ImlibLoader * l)
+{
/* this is the only bit you have to change... */
- char *list_formats[] =
- { "gif" };
+ char *list_formats[] = { "gif" };
/* don't bother changing any of this - it just reads this in and sets */
/* the struct values and makes copies */
- {
- int i;
-
- l->num_formats = (sizeof(list_formats) / sizeof (char *));
- l->formats = malloc(sizeof(char *) * l->num_formats);
- for (i = 0; i < l->num_formats; i++)
- l->formats[i] = strdup(list_formats[i]);
- }
-}
+ {
+ int i;
+ l->num_formats = (sizeof(list_formats) / sizeof(char *));
+ l->formats = malloc(sizeof(char *) * l->num_formats);
+ for (i = 0; i < l->num_formats; i++)
+ l->formats[i] = strdup(list_formats[i]);
+ }
+}
diff --git a/loaders/loader_gzbz2.c b/loaders/loader_gzbz2.c
index a3c1a5c..1c95e89 100644
--- a/loaders/loader_gzbz2.c
+++ b/loaders/loader_gzbz2.c
@@ -23,9 +23,9 @@
#include "image.h"
char load(ImlibImage * im, ImlibProgressFunction progress,
- char progress_granularity, char immediate_load);
+ char progress_granularity, char immediate_load);
char save(ImlibImage * im, ImlibProgressFunction progress,
- char progress_granularity);
+ char progress_granularity);
void formats(ImlibLoader * l);
static int
@@ -83,16 +83,16 @@ load(ImlibImage * im, ImlibProgressFunction progress,
if ((strlen(ptr + 1) >= 2) && (!strcmp(ptr + 1, "gz")))
{
- sprintf(str_gz, "gzip -d %s -c > %s/%s", im->real_file, tmpdir,
- pure_filename(file));
+ sprintf(str_gz, "gzip -d %s -c > %s/%s", im->real_file, tmpdir,
+ pure_filename(file));
}
else if ((strlen(ptr + 1) >= 3) && (!strcmp(ptr + 1, "bz2")))
{
- sprintf(str_gz, "bzip2 -d %s -c > %s/%s", im->real_file, tmpdir,
- pure_filename(file));
+ sprintf(str_gz, "bzip2 -d %s -c > %s/%s", im->real_file, tmpdir,
+ pure_filename(file));
}
else
- return 0; /* Eeek why we are here? */
+ return 0; /* Eeek why we are here? */
if (system(str_gz) < 0)
return 0;
free(im->real_file);
@@ -105,8 +105,8 @@ load(ImlibImage * im, ImlibProgressFunction progress,
sub_loader->load(im, progress, progress_granularity, 1);
else
{
- unlink(im->real_file);
- return 0;
+ unlink(im->real_file);
+ return 0;
}
unlink(im->real_file);
free(im->real_file);
@@ -133,6 +133,6 @@ formats(ImlibLoader * l)
l->num_formats = (sizeof(list_formats) / sizeof(char *));
l->formats = malloc(sizeof(char *) * l->num_formats);
for (i = 0; i < l->num_formats; i++)
- l->formats[i] = strdup(list_formats[i]);
+ l->formats[i] = strdup(list_formats[i]);
}
}
diff --git a/loaders/loader_jpeg.c b/loaders/loader_jpeg.c
index 24bc87d..dd48f8f 100644
--- a/loaders/loader_jpeg.c
+++ b/loaders/loader_jpeg.c
@@ -11,27 +11,25 @@
#include <jpeglib.h>
#include <setjmp.h>
-struct ImLib_JPEG_error_mgr
-{
+struct ImLib_JPEG_error_mgr {
struct jpeg_error_mgr pub;
- sigjmp_buf setjmp_buffer;
+ sigjmp_buf setjmp_buffer;
};
typedef struct ImLib_JPEG_error_mgr *emptr;
-void _JPEGFatalErrorHandler(j_common_ptr cinfo);
-void _JPEGErrorHandler(j_common_ptr cinfo);
-void _JPEGErrorHandler2(j_common_ptr cinfo, int msg_level);
-char load(ImlibImage * im, ImlibProgressFunction progress,
- char progress_granularity, char immediate_load);
-char save(ImlibImage * im, ImlibProgressFunction progress,
-
- char progress_granularity);
-void formats(ImlibLoader * l);
+void _JPEGFatalErrorHandler(j_common_ptr cinfo);
+void _JPEGErrorHandler(j_common_ptr cinfo);
+void _JPEGErrorHandler2(j_common_ptr cinfo, int msg_level);
+char load(ImlibImage * im, ImlibProgressFunction progress,
+ char progress_granularity, char immediate_load);
+char save(ImlibImage * im, ImlibProgressFunction progress,
+ char progress_granularity);
+void formats(ImlibLoader * l);
void
_JPEGFatalErrorHandler(j_common_ptr cinfo)
{
- emptr errmgr;
+ emptr errmgr;
errmgr = (emptr) cinfo->err;
/* cinfo->err->output_message(cinfo);*/
@@ -42,7 +40,7 @@ _JPEGFatalErrorHandler(j_common_ptr cinfo)
void
_JPEGErrorHandler(j_common_ptr cinfo)
{
- emptr errmgr;
+ emptr errmgr;
errmgr = (emptr) cinfo->err;
/* cinfo->err->output_message(cinfo);*/
@@ -53,7 +51,7 @@ _JPEGErrorHandler(j_common_ptr cinfo)
void
_JPEGErrorHandler2(j_common_ptr cinfo, int msg_level)
{
- emptr errmgr;
+ emptr errmgr;
errmgr = (emptr) cinfo->err;
/* cinfo->err->output_message(cinfo);*/
@@ -66,10 +64,10 @@ char
load(ImlibImage * im, ImlibProgressFunction progress,
char progress_granularity, char immediate_load)
{
- int w, h;
+ int w, h;
struct jpeg_decompress_struct cinfo;
struct ImLib_JPEG_error_mgr jerr;
- FILE *f;
+ FILE *f;
if (im->data)
return 0;
@@ -81,11 +79,11 @@ load(ImlibImage * im, ImlibProgressFunction progress,
jerr.pub.emit_message = _JPEGErrorHandler2;
jerr.pub.output_message = _JPEGErrorHandler;
if (sigsetjmp(jerr.setjmp_buffer, 1))
- {
- jpeg_destroy_decompress(&cinfo);
- fclose(f);
- return 0;
- }
+ {
+ jpeg_destroy_decompress(&cinfo);
+ fclose(f);
+ return 0;
+ }
jpeg_create_decompress(&cinfo);
jpeg_stdio_src(&cinfo, f);
jpeg_read_header(&cinfo, TRUE);
@@ -93,135 +91,139 @@ load(ImlibImage * im, ImlibProgressFunction progress,
cinfo.do_block_smoothing = FALSE;
jpeg_start_decompress(&cinfo);
if ((!im->loader) && (!im->data))
- {
- im->w = w = cinfo.output_width;
- im->h = h = cinfo.output_height;
- UNSET_FLAG(im->flags, F_HAS_ALPHA);
- im->format = strdup("jpeg");
- }
+ {
+ im->w = w = cinfo.output_width;
+ im->h = h = cinfo.output_height;
+ UNSET_FLAG(im->flags, F_HAS_ALPHA);
+ im->format = strdup("jpeg");
+ }
if (((!im->data) && (im->loader)) || (immediate_load) || (progress))
- {
- DATA8 *ptr, *line[16], *data;
- DATA32 *ptr2;
- int x, y, l, i, scans, count, prevy;
+ {
+ DATA8 *ptr, *line[16], *data;
+ DATA32 *ptr2;
+ int x, y, l, i, scans, count, prevy;
- im->w = w = cinfo.output_width;
- im->h = h = cinfo.output_height;
+ im->w = w = cinfo.output_width;
+ im->h = h = cinfo.output_height;
- if (cinfo.rec_outbuf_height > 16)
- {
- jpeg_destroy_decompress(&cinfo);
- fclose(f);
- return 0;
- }
- data = malloc(w * 16 * 3);
- if (!data)
- {
- jpeg_destroy_decompress(&cinfo);
- fclose(f);
- return 0;
- }
- /* must set the im->data member before callign progress function */
- ptr2 = im->data = malloc(w * h * sizeof(DATA32));
- if (!im->data)
- {
- free(data);
- jpeg_destroy_decompress(&cinfo);
- fclose(f);
- return 0;
- }
- count = 0;
- prevy = 0;
- if (cinfo.output_components == 3)
- {
- for (i = 0; i < cinfo.rec_outbuf_height; i++)
- line[i] = data + (i * w * 3);
- for (l = 0; l < h; l += cinfo.rec_outbuf_height)
- {
- jpeg_read_scanlines(&cinfo, line, cinfo.rec_outbuf_height);
- scans = cinfo.rec_outbuf_height;
- if ((h - l) < scans)
- scans = h - l;
- ptr = data;
- for (y = 0; y < scans; y++)
- {
- for (x = 0; x < w; x++)
+ if (cinfo.rec_outbuf_height > 16)
+ {
+ jpeg_destroy_decompress(&cinfo);
+ fclose(f);
+ return 0;
+ }
+ data = malloc(w * 16 * 3);
+ if (!data)
+ {
+ jpeg_destroy_decompress(&cinfo);
+ fclose(f);
+ return 0;
+ }
+ /* must set the im->data member before callign progress function */
+ ptr2 = im->data = malloc(w * h * sizeof(DATA32));
+ if (!im->data)
+ {
+ free(data);
+ jpeg_destroy_decompress(&cinfo);
+ fclose(f);
+ return 0;
+ }
+ count = 0;
+ prevy = 0;
+ if (cinfo.output_components == 3)
+ {
+ for (i = 0; i < cinfo.rec_outbuf_height; i++)
+ line[i] = data + (i * w * 3);
+ for (l = 0; l < h; l += cinfo.rec_outbuf_height)
{
- *ptr2 =
- (0xff000000) | ((ptr[0]) << 16) | ((ptr[1]) << 8) |
- (ptr[2]);
- ptr += 3;
- ptr2++;
- }
- }
- if (progress)
- {
- int per;
+ jpeg_read_scanlines(&cinfo, line, cinfo.rec_outbuf_height);
+ scans = cinfo.rec_outbuf_height;
+ if ((h - l) < scans)
+ scans = h - l;
+ ptr = data;
+ for (y = 0; y < scans; y++)
+ {
+ for (x = 0; x < w; x++)
+ {
+ *ptr2 =
+ (0xff000000) | ((ptr[0]) << 16) | ((ptr[1]) <<
+ 8) |
+ (ptr[2]);
+ ptr += 3;
+ ptr2++;
+ }
+ }
+ if (progress)
+ {
+ int per;
- per = (l * 100) / h;
- if (((per - count) >= progress_granularity)
- || ((h - l) <= cinfo.rec_outbuf_height))
- {
- count = per;
- if (!progress(im, per, 0, prevy, w, scans + l - prevy))
- {
- free(data);
- jpeg_finish_decompress(&cinfo);
- jpeg_destroy_decompress(&cinfo);
- fclose(f);
- return 2;
- }
- prevy = l + scans;
+ per = (l * 100) / h;
+ if (((per - count) >= progress_granularity)
+ || ((h - l) <= cinfo.rec_outbuf_height))
+ {
+ count = per;
+ if (!progress
+ (im, per, 0, prevy, w, scans + l - prevy))
+ {
+ free(data);
+ jpeg_finish_decompress(&cinfo);
+ jpeg_destroy_decompress(&cinfo);
+ fclose(f);
+ return 2;
+ }
+ prevy = l + scans;
+ }
+ }
}
- }
- }
- }
- else if (cinfo.output_components == 1)
- {
- for (i = 0; i < cinfo.rec_outbuf_height; i++)
- line[i] = data + (i * w);
- for (l = 0; l < h; l += cinfo.rec_outbuf_height)
- {
- jpeg_read_scanlines(&cinfo, line, cinfo.rec_outbuf_height);
- scans = cinfo.rec_outbuf_height;
- if ((h - l) < scans)
- scans = h - l;
- ptr = data;
- for (y = 0; y < scans; y++)
- {
- for (x = 0; x < w; x++)
+ }
+ else if (cinfo.output_components == 1)
+ {
+ for (i = 0; i < cinfo.rec_outbuf_height; i++)
+ line[i] = data + (i * w);
+ for (l = 0; l < h; l += cinfo.rec_outbuf_height)
{
- *ptr2 =
- (0xff000000) | ((ptr[0]) << 16) | ((ptr[0]) << 8) |
- (ptr[0]);
- ptr++;
- ptr2++;
- }
- }
- if (progress)
- {
- int per;
+ jpeg_read_scanlines(&cinfo, line, cinfo.rec_outbuf_height);
+ scans = cinfo.rec_outbuf_height;
+ if ((h - l) < scans)
+ scans = h - l;
+ ptr = data;
+ for (y = 0; y < scans; y++)
+ {
+ for (x = 0; x < w; x++)
+ {
+ *ptr2 =
+ (0xff000000) | ((ptr[0]) << 16) | ((ptr[0]) <<
+ 8) |
+ (ptr[0]);
+ ptr++;
+ ptr2++;
+ }
+ }
+ if (progress)
+ {
+ int per;
- per = (l * 100) / h;
- if (((per - count) >= progress_granularity)
- || ((h - l) <= cinfo.rec_outbuf_height))
- {
- count = per;
- if (!progress(im, per, 0, prevy, w, l + scans - prevy))
- {
- free(data);
- jpeg_finish_decompress(&cinfo);
- jpeg_destroy_decompress(&cinfo);
- fclose(f);
- return 2;
- }
- prevy = l + scans;
+ per = (l * 100) / h;
+ if (((per - count) >= progress_granularity)
+ || ((h - l) <= cinfo.rec_outbuf_height))
+ {
+ count = per;
+ if (!progress
+ (im, per, 0, prevy, w, l + scans - prevy))
+ {
+ free(data);
+ jpeg_finish_decompress(&cinfo);
+ jpeg_destroy_decompress(&cinfo);
+ fclose(f);
+ return 2;
+ }
+ prevy = l + scans;
+ }
+ }
}
- }
- }
- }
- free(data);
- }
+ }
+ free(data);
+ }
jpeg_finish_decompress(&cinfo);
jpeg_destroy_decompress(&cinfo);
fclose(f);
@@ -229,20 +231,18 @@ load(ImlibImage * im, ImlibProgressFunction progress,
}
char
-save(ImlibImage * im, ImlibProgressFunction progress,
- char progress_granularity)
+save(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity)
{
struct jpeg_compress_struct cinfo;
struct ImLib_JPEG_error_mgr jerr;
- FILE *f;
- DATA8 *buf;
- DATA32 *ptr;
- JSAMPROW *jbuf;
- int y = 0, quality = 75, compression = 2;
- ImlibImageTag *tag;
- int i, j, pl = 0;
- char pper = 0;
-
+ FILE *f;
+ DATA8 *buf;
+ DATA32 *ptr;
+ JSAMPROW *jbuf;
+ int y = 0, quality = 75, compression = 2;
+ ImlibImageTag *tag;
+ int i, j, pl = 0;
+ char pper = 0;
/* no image data? abort */
if (!im->data)
@@ -253,22 +253,22 @@ save(ImlibImage * im, ImlibProgressFunction progress,
return 0;
f = fopen(im->real_file, "wb");
if (!f)
- {
- free(buf);
- return 0;
- }
+ {
+ free(buf);
+ return 0;
+ }
/* set up error handling */
jerr.pub.error_exit = _JPEGFatalErrorHandler;
jerr.pub.emit_message = _JPEGErrorHandler2;
jerr.pub.output_message = _JPEGErrorHandler;
cinfo.err = jpeg_std_error(&(jerr.pub));
if (sigsetjmp(jerr.setjmp_buffer, 1))
- {
- jpeg_destroy_compress(&cinfo);
- free(buf);
- fclose(f);
- return 0;
- }
+ {
+ jpeg_destroy_compress(&cinfo);
+ free(buf);
+ fclose(f);
+ return 0;
+ }
/* setup compress params */
jpeg_create_compress(&cinfo);
jpeg_stdio_dest(&cinfo, f);
@@ -284,13 +284,13 @@ save(ImlibImage * im, ImlibProgressFunction progress,
/* compression */
tag = __imlib_GetTag(im, "compression");
if (tag)
- {
- compression = tag->val;
- if (compression < 0)
- compression = 0;
- if (compression > 9)
- compression = 9;
- }
+ {
+ compression = tag->val;
+ if (compression < 0)
+ compression = 0;
+ if (compression > 9)
+ compression = 9;
+ }
/* convert to quality */
quality = (9 - compression) * 10;
quality = quality * 10 / 9;
@@ -311,41 +311,41 @@ save(ImlibImage * im, ImlibProgressFunction progress,
ptr = im->data;
/* go one scanline at a time... and save */
while (cinfo.next_scanline < cinfo.image_height)
- {
- /* convcert scaline from ARGB to RGB packed */
- for (j = 0, i = 0; i < im->w; i++)
- {
- buf[j++] = ((*ptr) >> 16) & 0xff;
- buf[j++] = ((*ptr) >> 8) & 0xff;
- buf[j++] = ((*ptr)) & 0xff;
- ptr++;
- }
- /* write scanline */
- jbuf = (JSAMPROW *) (&buf);
- jpeg_write_scanlines(&cinfo, jbuf, 1);
- y++;
- if (progress)
- {
- char per;
- int l;
+ {
+ /* convcert scaline from ARGB to RGB packed */
+ for (j = 0, i = 0; i < im->w; i++)
+ {
+ buf[j++] = ((*ptr) >> 16) & 0xff;
+ buf[j++] = ((*ptr) >> 8) & 0xff;
+ buf[j++] = ((*ptr)) & 0xff;
+ ptr++;
+ }
+ /* write scanline */
+ jbuf = (JSAMPROW *) (&buf);
+ jpeg_write_scanlines(&cinfo, jbuf, 1);
+ y++;
+ if (progress)
+ {
+ char per;
+ int l;
- per = (char) ((100 * y) / im->h);
- if (((per - pper) >= progress_granularity) || (y == (im->h - 1)))
- {
- l = y - pl;
- if (!progress(im, per, 0, (y - l), im->w, l))
- {
- jpeg_finish_compress(&cinfo);
- jpeg_destroy_compress(&cinfo);
- free(buf);
- fclose(f);
- return 2;
- }
- pper = per;
- pl = y;
- }
- }
- }
+ per = (char)((100 * y) / im->h);
+ if (((per - pper) >= progress_granularity) || (y == (im->h - 1)))
+ {
+ l = y - pl;
+ if (!progress(im, per, 0, (y - l), im->w, l))
+ {
+ jpeg_finish_compress(&cinfo);
+ jpeg_destroy_compress(&cinfo);
+ free(buf);
+ fclose(f);
+ return 2;
+ }
+ pper = per;
+ pl = y;
+ }
+ }
+ }
/* finish off */
jpeg_finish_compress(&cinfo);
jpeg_destroy_compress(&cinfo);
@@ -358,10 +358,10 @@ save(ImlibImage * im, ImlibProgressFunction progress,
void
formats(ImlibLoader * l)
{
- char *list_formats[] = { "jpg", "jpeg", "jfif", "jfi" };
+ char *list_formats[] = { "jpg", "jpeg", "jfif", "jfi" };
{
- int i;
+ int i;
l->num_formats = (sizeof(list_formats) / sizeof(char *));
l->formats = malloc(sizeof(char *) * l->num_formats);
diff --git a/loaders/loader_png.c b/loaders/loader_png.c
index 4b209d7..1298cf3 100644
--- a/loaders/loader_png.c
+++ b/loaders/loader_png.c
@@ -15,14 +15,13 @@
/* PNG stuff */
#define PNG_BYTES_TO_CHECK 4
-char load(ImlibImage * im, ImlibProgressFunction progress,
- char progress_granularity, char immediate_load);
-char save(ImlibImage * im, ImlibProgressFunction progress,
+char load(ImlibImage * im, ImlibProgressFunction progress,
+ char progress_granularity, char immediate_load);
+char save(ImlibImage * im, ImlibProgressFunction progress,
+ char progress_granularity);
+void formats(ImlibLoader * l);
- char progress_granularity);
-void formats(ImlibLoader * l);
-
-static void comment_free(ImlibImage *im, void *data);
+static void comment_free(ImlibImage * im, void *data);
static void
comment_free(ImlibImage * im, void *data)
{
@@ -33,13 +32,13 @@ char
load(ImlibImage * im, ImlibProgressFunction progress,
char progress_granularity, char immediate_load)
{
- png_uint_32 w32, h32;
- int w, h;
- char hasa = 0, hasg = 0;
- FILE *f;
- png_structp png_ptr = NULL;
- png_infop info_ptr = NULL;
- int bit_depth, color_type, interlace_type;
+ png_uint_32 w32, h32;
+ int w, h;
+ char hasa = 0, hasg = 0;
+ FILE *f;
+ png_structp png_ptr = NULL;
+ png_infop info_ptr = NULL;
+ int bit_depth, color_type, interlace_type;
/* if immediate_load is 1, then dont delay image laoding as below, or */
/* already data in this image - dont load it again */
@@ -50,249 +49,249 @@ load(ImlibImage * im, ImlibProgressFunction progress,
return 0;
/* read header */
if (!im->data)
- {
- unsigned char buf[PNG_BYTES_TO_CHECK];
+ {
+ unsigned char buf[PNG_BYTES_TO_CHECK];
- /* if we havent read the header before, set the header data */
- fread(buf, 1, PNG_BYTES_TO_CHECK, f);
- if (!png_check_sig(buf, PNG_BYTES_TO_CHECK))
- {
- fclose(f);
- return 0;
- }
- rewind(f);
- png_ptr =
- png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
- if (!png_ptr)
- {
- fclose(f);
- return 0;
- }
- info_ptr = png_create_info_struct(png_ptr);
- if (!info_ptr)
- {
- png_destroy_read_struct(&png_ptr, NULL, NULL);
- fclose(f);
- return 0;
- }
- if (setjmp(png_ptr->jmpbuf))
- {
- png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
- fclose(f);
- return 0;
- }
- png_init_io(png_ptr, f);
- png_read_info(png_ptr, info_ptr);
- png_get_IHDR(png_ptr, info_ptr, (png_uint_32 *) (&w32),
- (png_uint_32 *) (&h32), &bit_depth, &color_type,
- &interlace_type, NULL, NULL);
- im->w = (int) w32;
- im->h = (int) h32;
- if (color_type == PNG_COLOR_TYPE_PALETTE)
- png_set_expand(png_ptr);
- if (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
- hasa = 1;
- if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
- {
- hasa = 1;
- hasg = 1;
- }
- if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY)
- hasg = 1;
- if (hasa)
- SET_FLAG(im->flags, F_HAS_ALPHA);
- else
- UNSET_FLAG(im->flags, F_HAS_ALPHA);
- /* set the format string member to the lower-case full extension */
- /* name for the format - so example names would be: */
- /* "png", "jpeg", "tiff", "ppm", "pgm", "pbm", "gif", "xpm" ... */
- if (!im->loader)
- im->format = strdup("png");
- }
+ /* if we havent read the header before, set the header data */
+ fread(buf, 1, PNG_BYTES_TO_CHECK, f);
+ if (!png_check_sig(buf, PNG_BYTES_TO_CHECK))
+ {
+ fclose(f);
+ return 0;
+ }
+ rewind(f);
+ png_ptr =
+ png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
+ if (!png_ptr)
+ {
+ fclose(f);
+ return 0;
+ }
+ info_ptr = png_create_info_struct(png_ptr);
+ if (!info_ptr)
+ {
+ png_destroy_read_struct(&png_ptr, NULL, NULL);
+ fclose(f);
+ return 0;
+ }
+ if (setjmp(png_ptr->jmpbuf))
+ {
+ png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
+ fclose(f);
+ return 0;
+ }
+ png_init_io(png_ptr, f);
+ png_read_info(png_ptr, info_ptr);
+ png_get_IHDR(png_ptr, info_ptr, (png_uint_32 *) (&w32),
+ (png_uint_32 *) (&h32), &bit_depth, &color_type,
+ &interlace_type, NULL, NULL);
+ im->w = (int)w32;
+ im->h = (int)h32;
+ if (color_type == PNG_COLOR_TYPE_PALETTE)
+ png_set_expand(png_ptr);
+ if (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
+ hasa = 1;
+ if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
+ {
+ hasa = 1;
+ hasg = 1;
+ }
+ if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY)
+ hasg = 1;
+ if (hasa)
+ SET_FLAG(im->flags, F_HAS_ALPHA);
+ else
+ UNSET_FLAG(im->flags, F_HAS_ALPHA);
+ /* set the format string member to the lower-case full extension */
+ /* name for the format - so example names would be: */
+ /* "png", "jpeg", "tiff", "ppm", "pgm", "pbm", "gif", "xpm" ... */
+ if (!im->loader)
+ im->format = strdup("png");
+ }
/* if its the second phase load OR its immediate load or a progress */
/* callback is set then load the data */
if ((im->loader) || (immediate_load) || (progress))
- {
- unsigned char **lines;
- int i;
+ {
+ unsigned char **lines;
+ int i;
- w = im->w;
- h = im->h;
- if (hasa)
- png_set_expand(png_ptr);
- /* we want ARGB */
+ w = im->w;
+ h = im->h;
+ if (hasa)
+ png_set_expand(png_ptr);
+ /* we want ARGB */
/* note form raster: */
/* thanks to mustapha for helping debug this on PPC Linux remotely by */
/* sending across screenshots all the tiem and me figuring out form them */
/* what the hell was up with the colors */
/* now png loading shoudl work on big endian machines nicely */
#ifdef WORDS_BIGENDIAN
- png_set_swap_alpha(png_ptr);
- png_set_filler(png_ptr, 0xff, PNG_FILLER_BEFORE);
+ png_set_swap_alpha(png_ptr);
+ png_set_filler(png_ptr, 0xff, PNG_FILLER_BEFORE);
#else
- png_set_bgr(png_ptr);
- png_set_filler(png_ptr, 0xff, PNG_FILLER_AFTER);
+ png_set_bgr(png_ptr);
+ png_set_filler(png_ptr, 0xff, PNG_FILLER_AFTER);
#endif
- /* 16bit color -> 8bit color */
- png_set_strip_16(png_ptr);
- /* pack all pixels to byte boundaires */
- png_set_packing(png_ptr);
- if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
- png_set_expand(png_ptr);
- if (im->data)
- free(im->data);
- im->data = malloc(w * h * sizeof(DATA32));
- if (!im->data)
- {
- png_read_end(png_ptr, info_ptr);
- png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp) NULL);
- fclose(f);
- return 0;
- }
- lines = (unsigned char **) malloc(h * sizeof(unsigned char *));
+ /* 16bit color -> 8bit color */
+ png_set_strip_16(png_ptr);
+ /* pack all pixels to byte boundaires */
+ png_set_packing(png_ptr);
+ if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
+ png_set_expand(png_ptr);
+ if (im->data)
+ free(im->data);
+ im->data = malloc(w * h * sizeof(DATA32));
+ if (!im->data)
+ {
+ png_read_end(png_ptr, info_ptr);
+ png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp) NULL);
+ fclose(f);
+ return 0;
+ }
+ lines = (unsigned char **)malloc(h * sizeof(unsigned char *));
- if (!lines)
- {
- free(im->data);
- im->data = NULL;
- png_read_end(png_ptr, info_ptr);
- png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp) NULL);
- fclose(f);
- return 0;
- }
- if (hasg)
- {
- png_set_gray_to_rgb(png_ptr);
- if (png_get_bit_depth(png_ptr, info_ptr) < 8)
- png_set_gray_1_2_4_to_8(png_ptr);
- }
- for (i = 0; i < h; i++)
- lines[i] =
- ((unsigned char *) (im->data)) + (i * w * sizeof(DATA32));
- if (progress)
- {
- int y, count, prevy, pass, number_passes, per, nrows = 1;
-
- count = 0;
- number_passes = png_set_interlace_handling(png_ptr);
- for (pass = 0; pass < number_passes; pass++)
- {
- prevy = 0;
- per = 0;
- for (y = 0; y < h; y += nrows)
- {
- png_read_rows(png_ptr, &lines[y], NULL, nrows);
-
- per = (((pass * h) + y) * 100) / (h * number_passes);
- if ((per - count) >= progress_granularity)
- {
- count = per;
- if (!progress(im, per, 0, prevy, w, y - prevy + 1))
- {
- free(lines);
- png_read_end(png_ptr, info_ptr);
- png_destroy_read_struct(&png_ptr, &info_ptr,
- (png_infopp) NULL);
- fclose(f);
- return 2;
- }
- prevy = y + 1;
+ if (!lines)
+ {
+ free(im->data);
+ im->data = NULL;
+ png_read_end(png_ptr, info_ptr);
+ png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp) NULL);
+ fclose(f);
+ return 0;
+ }
+ if (hasg)
+ {
+ png_set_gray_to_rgb(png_ptr);
+ if (png_get_bit_depth(png_ptr, info_ptr) < 8)
+ png_set_gray_1_2_4_to_8(png_ptr);
+ }
+ for (i = 0; i < h; i++)
+ lines[i] = ((unsigned char *)(im->data)) + (i * w * sizeof(DATA32));
+ if (progress)
+ {
+ int y, count, prevy, pass, number_passes, per,
+ nrows = 1;
+
+ count = 0;
+ number_passes = png_set_interlace_handling(png_ptr);
+ for (pass = 0; pass < number_passes; pass++)
+ {
+ prevy = 0;
+ per = 0;
+ for (y = 0; y < h; y += nrows)
+ {
+ png_read_rows(png_ptr, &lines[y], NULL, nrows);
+
+ per = (((pass * h) + y) * 100) / (h * number_passes);
+ if ((per - count) >= progress_granularity)
+ {
+ count = per;
+ if (!progress(im, per, 0, prevy, w, y - prevy + 1))
+ {
+ free(lines);
+ png_read_end(png_ptr, info_ptr);
+ png_destroy_read_struct(&png_ptr, &info_ptr,
+ (png_infopp) NULL);
+ fclose(f);
+ return 2;
+ }
+ prevy = y + 1;
+ }
+ }
+ if (!progress(im, per, 0, prevy, w, y - prevy + 1))
+ {
+ free(lines);
+ png_read_end(png_ptr, info_ptr);
+ png_destroy_read_struct(&png_ptr, &info_ptr,
+ (png_infopp) NULL);
+ fclose(f);
+ return 2;
+ }
}
- }
- if (!progress(im, per, 0, prevy, w, y - prevy + 1))
- {
- free(lines);
- png_read_end(png_ptr, info_ptr);
- png_destroy_read_struct(&png_ptr, &info_ptr,
- (png_infopp) NULL);
- fclose(f);
- return 2;
- }
- }
- }
- else
- png_read_image(png_ptr, lines);
- free(lines);
- png_read_end(png_ptr, info_ptr);
- }
-#ifdef PNG_TEXT_SUPPORTED
- {
- png_textp text;
- int num;
- int i;
-
- num = 0;
- png_get_text(png_ptr, info_ptr, &text, &num);
- for(i = 0; i < num; i++)
- {
- if (!strcmp(text[i].key, "Imlib2-Comment"))
- __imlib_AttachTag(im, "comment", 0, strdup(text[i].text), comment_free);
- }
+ }
+ else
+ png_read_image(png_ptr, lines);
+ free(lines);
+ png_read_end(png_ptr, info_ptr);
}
-#endif
+#ifdef PNG_TEXT_SUPPORTED
+ {
+ png_textp text;
+ int num;
+ int i;
+
+ num = 0;
+ png_get_text(png_ptr, info_ptr, &text, &num);
+ for (i = 0; i < num; i++)
+ {
+ if (!strcmp(text[i].key, "Imlib2-Comment"))
+ __imlib_AttachTag(im, "comment", 0, strdup(text[i].text),
+ comment_free);
+ }
+ }
+#endif
png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp) NULL);
fclose(f);
return 1;
}
char
-save(ImlibImage * im, ImlibProgressFunction progress,
- char progress_granularity)
+save(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity)
{
- FILE *f;
- png_structp png_ptr;
- png_infop info_ptr;
- DATA32 *ptr;
- int x, y, j;
- png_bytep row_ptr, data = NULL;
- png_color_8 sig_bit;
- int pl = 0;
- char pper = 0;
- ImlibImageTag *tag;
- int quality = 75, compression = 3;
+ FILE *f;
+ png_structp png_ptr;
+ png_infop info_ptr;
+ DATA32 *ptr;
+ int x, y, j;
+ png_bytep row_ptr, data = NULL;
+ png_color_8 sig_bit;
+ int pl = 0;
+ char pper = 0;
+ ImlibImageTag *tag;
+ int quality = 75, compression = 3;
f = fopen(im->real_file, "wb");
if (!f)
return 0;
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (!png_ptr)
- {
- fclose(f);
- return 0;
- }
+ {
+ fclose(f);
+ return 0;
+ }
info_ptr = png_create_info_struct(png_ptr);
if (info_ptr == NULL)
- {
- fclose(f);
- png_destroy_write_struct(&png_ptr, (png_infopp) NULL);
- return 0;
- }
+ {
+ fclose(f);
+ png_destroy_write_struct(&png_ptr, (png_infopp) NULL);
+ return 0;
+ }
if (setjmp(png_ptr->jmpbuf))
- {
- fclose(f);
- png_destroy_write_struct(&png_ptr, (png_infopp) &info_ptr);
- png_destroy_info_struct(png_ptr, (png_infopp) &info_ptr);
- return 0;
- }
+ {
+ fclose(f);
+ png_destroy_write_struct(&png_ptr, (png_infopp) & info_ptr);
+ png_destroy_info_struct(png_ptr, (png_infopp) & info_ptr);
+ return 0;
+ }
png_init_io(png_ptr, f);
if (im->flags & F_HAS_ALPHA)
- {
- png_set_IHDR(png_ptr, info_ptr, im->w, im->h, 8,
- PNG_COLOR_TYPE_RGB_ALPHA, PNG_INTERLACE_NONE,
- PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
+ {
+ png_set_IHDR(png_ptr, info_ptr, im->w, im->h, 8,
+ PNG_COLOR_TYPE_RGB_ALPHA, PNG_INTERLACE_NONE,
+ PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
#ifdef WORDS_BIGENDIAN
- png_set_swap_alpha(png_ptr);
+ png_set_swap_alpha(png_ptr);
#else
- png_set_bgr(png_ptr);
+ png_set_bgr(png_ptr);
#endif
- }
+ }
else
- {
- png_set_IHDR(png_ptr, info_ptr, im->w, im->h, 8, PNG_COLOR_TYPE_RGB,
- PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE,
- PNG_FILTER_TYPE_BASE);
- data = malloc(im->w * 3 * sizeof(char));
- }
+ {
+ png_set_IHDR(png_ptr, info_ptr, im->w, im->h, 8, PNG_COLOR_TYPE_RGB,
+ PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE,
+ PNG_FILTER_TYPE_BASE);
+ data = malloc(im->w * 3 * sizeof(char));
+ }
sig_bit.red = 8;
sig_bit.green = 8;
sig_bit.blue = 8;
@@ -301,13 +300,13 @@ save(ImlibImage * im, ImlibProgressFunction progress,
/* quality */
tag = __imlib_GetTag(im, "quality");
if (tag)
- {
- quality = tag->val;
- if (quality < 1)
- quality = 1;
- if (quality > 99)
- quality = 99;
- }
+ {
+ quality = tag->val;
+ if (quality < 1)
+ quality = 1;
+ if (quality > 99)
+ quality = 99;
+ }
/* convert to compression */
quality = quality / 10;
compression = 9 - quality;
@@ -323,13 +322,13 @@ save(ImlibImage * im, ImlibProgressFunction progress,
if (tag)
{
#ifdef PNG_TEXT_SUPPORTED
- png_text text;
-
- text.key = "Imlib2-Comment";
- text.text = tag->data;
- text.compression = PNG_TEXT_COMPRESSION_zTXt;
- png_set_text(png_ptr, info_ptr, &(text), 1);
-#endif
+ png_text text;
+
+ text.key = "Imlib2-Comment";
+ text.text = tag->data;
+ text.compression = PNG_TEXT_COMPRESSION_zTXt;
+ png_set_text(png_ptr, info_ptr, &(text), 1);
+#endif
}
png_set_compression_level(png_ptr, compression);
png_write_info(png_ptr, info_ptr);
@@ -338,51 +337,53 @@ save(ImlibImage * im, ImlibProgressFunction progress,
ptr = im->data;
for (y = 0; y < im->h; y++)
- {
- if (im->flags & F_HAS_ALPHA)
- row_ptr = (png_bytep) ptr;
- else
- {
- for (j = 0, x = 0; x < im->w; x++)
- {
- data[j++] = (ptr[x] >> 16) & 0xff;
- data[j++] = (ptr[x] >> 8) & 0xff;
- data[j++] = (ptr[x]) & 0xff;
- }
- row_ptr = (png_bytep) data;
- }
- png_write_rows(png_ptr, &row_ptr, 1);
- if (progress)
- {
- char per;
- int l;
+ {
+ if (im->flags & F_HAS_ALPHA)
+ row_ptr = (png_bytep) ptr;
+ else
+ {
+ for (j = 0, x = 0; x < im->w; x++)
+ {
+ data[j++] = (ptr[x] >> 16) & 0xff;
+ data[j++] = (ptr[x] >> 8) & 0xff;
+ data[j++] = (ptr[x]) & 0xff;
+ }
+ row_ptr = (png_bytep) data;
+ }
+ png_write_rows(png_ptr, &row_ptr, 1);
+ if (progress)
+ {
+ char per;
+ int l;
- per = (char) ((100 * y) / im->h);
- if ((per - pper) >= progress_granularity)
- {
- l = y - pl;
- if (!progress(im, per, 0, (y - l), im->w, l))
- {
- if (data)
- free(data);
- png_write_end(png_ptr, info_ptr);
- png_destroy_write_struct(&png_ptr, (png_infopp) &info_ptr);
- png_destroy_info_struct(png_ptr, (png_infopp) &info_ptr);
- fclose(f);
- return 2;
- }
- pper = per;
- pl = y;
- }
- }
- ptr += im->w;
- }
+ per = (char)((100 * y) / im->h);
+ if ((per - pper) >= progress_granularity)
+ {
+ l = y - pl;
+ if (!progress(im, per, 0, (y - l), im->w, l))
+ {
+ if (data)
+ free(data);
+ png_write_end(png_ptr, info_ptr);
+ png_destroy_write_struct(&png_ptr,
+ (png_infopp) & info_ptr);
+ png_destroy_info_struct(png_ptr,
+ (png_infopp) & info_ptr);
+ fclose(f);
+ return 2;
+ }
+ pper = per;
+ pl = y;
+ }
+ }
+ ptr += im->w;
+ }
if (data)
free(data);
png_write_end(png_ptr, info_ptr);
- png_destroy_write_struct(&png_ptr, (png_infopp) &info_ptr);
- png_destroy_info_struct(png_ptr, (png_infopp) &info_ptr);
-
+ png_destroy_write_struct(&png_ptr, (png_infopp) & info_ptr);
+ png_destroy_info_struct(png_ptr, (png_infopp) & info_ptr);
+
fclose(f);
return 1;
}
@@ -398,12 +399,12 @@ void
formats(ImlibLoader * l)
{
/* this is the only bit you have to change... */
- char *list_formats[] = { "png" };
+ char *list_formats[] = { "png" };
/* don't bother changing any of this - it just reads this in and sets */
/* the struct values and makes copies */
{
- int i;
+ int i;
l->num_formats = (sizeof(list_formats) / sizeof(char *));
l->formats = malloc(sizeof(char *) * l->num_formats);
diff --git a/loaders/loader_pnm.c b/loaders/loader_pnm.c
index bcd9003..edabf8a 100644
--- a/loaders/loader_pnm.c
+++ b/loaders/loader_pnm.c
@@ -10,21 +10,20 @@
#include <ctype.h>
#include "image.h"
-char load(ImlibImage * im, ImlibProgressFunction progress,
- char progress_granularity, char immediate_load);
-char save(ImlibImage * im, ImlibProgressFunction progress,
-
- char progress_granularity);
-void formats(ImlibLoader * l);
+char load(ImlibImage * im, ImlibProgressFunction progress,
+ char progress_granularity, char immediate_load);
+char save(ImlibImage * im, ImlibProgressFunction progress,
+ char progress_granularity);
+void formats(ImlibLoader * l);
char
load(ImlibImage * im, ImlibProgressFunction progress,
char progress_granularity, char immediate_load)
{
- char p = ' ', numbers = 3, count = 0;
- int w = 0, h = 0, v = 255, c = 0;
- char buf[256];
- FILE *f = NULL;
+ char p = ' ', numbers = 3, count = 0;
+ int w = 0, h = 0, v = 255, c = 0;
+ char buf[256];
+ FILE *f = NULL;
if (im->data)
return 0;
@@ -43,667 +42,667 @@ load(ImlibImage * im, ImlibProgressFunction progress,
c = fgetc(f);
if (c != 'P')
- {
- fclose(f);
- return 0;
- }
+ {
+ fclose(f);
+ return 0;
+ }
p = fgetc(f);
if (p == '1' || p == '4')
- numbers = 2; /* bitimages don't have max value */
+ numbers = 2; /* bitimages don't have max value */
if ((p < '1') || (p > '8'))
{
- fclose(f);
- return 0;
+ fclose(f);
+ return 0;
}
count = 0;
while (count < numbers)
- {
- c = fgetc(f);
-
- if (c == EOF)
- {
- fclose(f);
- return 0;
- }
-
- /* eat whitespace */
- while (isspace(c))
- c = fgetc(f);
- /* if comment, eat that */
- if (c == '#')
- {
- do
- c = fgetc(f);
- while (c != '\n' && c != EOF);
- }
- /* no comment -> proceed */
- else
- {
- int i = 0;
-
- /* read numbers */
- while (c != EOF && !isspace(c))
- {
- buf[i++] = c;
- c = fgetc(f);
- }
- if (i)
- {
- buf[i] = 0;
- count++;
- switch (count)
- {
- /* width */
- case 1:
- w = atoi(buf);
- break;
- /* height */
- case 2:
- h = atoi(buf);
- break;
- /* max value, only for color and greyscale */
- case 3:
- v = atoi(buf);
- break;
- }
- }
- }
- }
- if ((w <= 0) || (w > 8192) ||
- (h <= 0) || (h > 8192) ||
- (v < 0) || (v > 255))
{
- fclose(f);
- return 0;
+ c = fgetc(f);
+
+ if (c == EOF)
+ {
+ fclose(f);
+ return 0;
+ }
+
+ /* eat whitespace */
+ while (isspace(c))
+ c = fgetc(f);
+ /* if comment, eat that */
+ if (c == '#')
+ {
+ do
+ c = fgetc(f);
+ while (c != '\n' && c != EOF);
+ }
+ /* no comment -> proceed */
+ else
+ {
+ int i = 0;
+
+ /* read numbers */
+ while (c != EOF && !isspace(c))
+ {
+ buf[i++] = c;
+ c = fgetc(f);
+ }
+ if (i)
+ {
+ buf[i] = 0;
+ count++;
+ switch (count)
+ {
+ /* width */
+ case 1:
+ w = atoi(buf);
+ break;
+ /* height */
+ case 2:
+ h = atoi(buf);
+ break;
+ /* max value, only for color and greyscale */
+ case 3:
+ v = atoi(buf);
+ break;
+ }
+ }
+ }
+ }
+ if ((w <= 0) || (w > 8192) || (h <= 0) || (h > 8192) || (v < 0) || (v > 255))
+ {
+ fclose(f);
+ return 0;
}
im->w = w;
im->h = h;
if (!im->format)
- {
- if (p == '8')
- SET_FLAG(im->flags, F_HAS_ALPHA);
- else
- UNSET_FLAG(im->flags, F_HAS_ALPHA);
- im->format = strdup("pnm");
- }
+ {
+ if (p == '8')
+ SET_FLAG(im->flags, F_HAS_ALPHA);
+ else
+ UNSET_FLAG(im->flags, F_HAS_ALPHA);
+ im->format = strdup("pnm");
+ }
if (((!im->data) && (im->loader)) || (immediate_load) || (progress))
- {
- DATA8 *data = NULL; /* for the binary versions */
- DATA8 *ptr;
- int *idata = NULL; /* for the ASCII versions */
- int *iptr;
- char buf2[256];
- DATA32 *ptr2;
- int i, j, x, y, pl = 0;
- char pper = 0;
-
- /* must set the im->data member before callign progress function */
- ptr2 = im->data = malloc(w * h * sizeof(DATA32));
- if (!im->data)
- {
- fclose(f);
- return 0;
- }
- /* start reading the data */
- switch (p)
- {
- case '1': /* ASCII monochrome */
- buf[0] = 0;
- i = 0;
- for (y = 0; y < h; y++)
- {
- x = 0;
- while (x < w)
- {
- if (!buf[i]) /* fill buffer */
- {
- if (!fgets(buf, 255, f))
- {
- fclose(f);
- return 0;
- }
- i = 0;
- }
- while (buf[i] && isspace(buf[i]))
- i++;
- if (buf[i])
- {
- if (buf[i] == '1')
- *ptr2 = 0xff000000;
- else if (buf[i] == '0')
- *ptr2 = 0xffffffff;
- else
- {
- fclose(f);
- return 0;
- }
- ptr2++;
- i++;
- }
- }
- if (progress)
- {
- char per;
- int l;
-
- per = (char) ((100 * y) / im->h);
- if (((per - pper) >= progress_granularity)
- || (y == (im->h - 1)))
- {
- l = y - pl;
-
- /* fix off by one in case of the last line */
- if (y == (im->h -1))
- l++;
-
- if (!progress(im, per, 0, pl, im->w, l))
- {
- fclose(f);
- return 2;
- }
- pper = per;
- pl = y;
- }
- }
- }
- break;
- case '2': /* ASCII greyscale */
- idata = malloc(sizeof(int) * w);
-
- if (!idata)
- {
- fclose(f);
- return 0;
- }
- buf[0] = 0;
- i = 0;
- j = 0;
- for (y = 0; y < h; y++)
- {
- iptr = idata;
- x = 0;
- while (x < w)
- {
- if (!buf[i]) /* fill buffer */
+ {
+ DATA8 *data = NULL; /* for the binary versions */
+ DATA8 *ptr;
+ int *idata = NULL; /* for the ASCII versions */
+ int *iptr;
+ char buf2[256];
+ DATA32 *ptr2;
+ int i, j, x, y, pl = 0;
+ char pper = 0;
+
+ /* must set the im->data member before callign progress function */
+ ptr2 = im->data = malloc(w * h * sizeof(DATA32));
+ if (!im->data)
+ {
+ fclose(f);
+ return 0;
+ }
+ /* start reading the data */
+ switch (p)
+ {
+ case '1': /* ASCII monochrome */
+ buf[0] = 0;
+ i = 0;
+ for (y = 0; y < h; y++)
{
- if (!fgets(buf, 255, f))
- {
- free(idata);
- fclose(f);
- return 0;
- }
- i = 0;
+ x = 0;
+ while (x < w)
+ {
+ if (!buf[i]) /* fill buffer */
+ {
+ if (!fgets(buf, 255, f))
+ {
+ fclose(f);
+ return 0;
+ }
+ i = 0;
+ }
+ while (buf[i] && isspace(buf[i]))
+ i++;
+ if (buf[i])
+ {
+ if (buf[i] == '1')
+ *ptr2 = 0xff000000;
+ else if (buf[i] == '0')
+ *ptr2 = 0xffffffff;
+ else
+ {
+ fclose(f);
+ return 0;
+ }
+ ptr2++;
+ i++;
+ }
+ }
+ if (progress)
+ {
+ char per;
+ int l;
+
+ per = (char)((100 * y) / im->h);
+ if (((per - pper) >= progress_granularity)
+ || (y == (im->h - 1)))
+ {
+ l = y - pl;
+
+ /* fix off by one in case of the last line */
+ if (y == (im->h - 1))
+ l++;
+
+ if (!progress(im, per, 0, pl, im->w, l))
+ {
+ fclose(f);
+ return 2;
+ }
+ pper = per;
+ pl = y;
+ }
+ }
}
- while (buf[i] && isspace(buf[i]))
- i++;
- while (buf[i] && !isspace(buf[i]))
- buf2[j++] = buf[i++];
- if (j)
+ break;
+ case '2': /* ASCII greyscale */
+ idata = malloc(sizeof(int) * w);
+
+ if (!idata)
{
- buf2[j] = 0;
- *(iptr++) = atoi(buf2);
- j = 0;
- x++;
+ fclose(f);
+ return 0;
}
- }
- iptr = idata;
- if (v == 255)
- {
- for (x = 0; x < w; x++)
+ buf[0] = 0;
+ i = 0;
+ j = 0;
+ for (y = 0; y < h; y++)
{
- *ptr2 =
- 0xff000000 | (iptr[0] << 16) | (iptr[0] << 8) |
- iptr[0];
- ptr2++;
- iptr++;
+ iptr = idata;
+ x = 0;
+ while (x < w)
+ {
+ if (!buf[i]) /* fill buffer */
+ {
+ if (!fgets(buf, 255, f))
+ {
+ free(idata);
+ fclose(f);
+ return 0;
+ }
+ i = 0;
+ }
+ while (buf[i] && isspace(buf[i]))
+ i++;
+ while (buf[i] && !isspace(buf[i]))
+ buf2[j++] = buf[i++];
+ if (j)
+ {
+ buf2[j] = 0;
+ *(iptr++) = atoi(buf2);
+ j = 0;
+ x++;
+ }
+ }
+ iptr = idata;
+ if (v == 255)
+ {
+ for (x = 0; x < w; x++)
+ {
+ *ptr2 =
+ 0xff000000 | (iptr[0] << 16) | (iptr[0] << 8)
+ | iptr[0];
+ ptr2++;
+ iptr++;
+ }
+ }
+ else
+ {
+ for (x = 0; x < w; x++)
+ {
+ *ptr2 =
+ 0xff000000 | (((iptr[0] * 255) / v) << 16) |
+ (((iptr[0] * 255) / v) << 8) | ((iptr[0] *
+ 255) / v);
+ ptr2++;
+ iptr++;
+ }
+ }
+ if (progress)
+ {
+ char per;
+ int l;
+
+ per = (char)((100 * y) / im->h);
+ if (((per - pper) >= progress_granularity)
+ || (y == (im->h - 1)))
+ {
+
+ l = y - pl;
+
+ /* fix off by one in case of the last line */
+ if (y == (im->h - 1))
+ l++;
+
+ if (!progress(im, per, 0, pl, im->w, l))
+ {
+ if (idata)
+ free(idata);
+ fclose(f);
+ return 2;
+ }
+ pper = per;
+ pl = y;
+ }
+ }
}
- }
- else
- {
- for (x = 0; x < w; x++)
+ break;
+ case '3': /* ASCII RGB */
+ idata = malloc(3 * sizeof(int) * w);
+
+ if (!idata)
{
- *ptr2 =
- 0xff000000 | (((iptr[0] * 255) / v) << 16) |
- (((iptr[0] * 255) / v) << 8) | ((iptr[0] * 255) / v);
- ptr2++;
- iptr++;
- }
- }
- if (progress)
- {
- char per;
- int l;
-
- per = (char) ((100 * y) / im->h);
- if (((per - pper) >= progress_granularity)
- || (y == (im->h - 1)))
- {
-
- l = y - pl;
-
- /* fix off by one in case of the last line */
- if (y == (im->h -1))
- l++;
-
- if (!progress(im, per, 0, pl, im->w, l))
- {
- if (idata)
- free(idata);
- fclose(f);
- return 2;
- }
- pper = per;
- pl = y;
+ fclose(f);
+ return 0;
}
- }
- }
- break;
- case '3': /* ASCII RGB */
- idata = malloc(3 * sizeof(int) * w);
-
- if (!idata)
- {
- fclose(f);
- return 0;
- }
- buf[0] = 0;
- i = 0;
- j = 0;
- for (y = 0; y < h; y++)
- {
- int w3 = 3 * w;
-
- iptr = idata;
- x = 0;
- while (x < w3)
- {
- if (!buf[i]) /* fill buffer */
+ buf[0] = 0;
+ i = 0;
+ j = 0;
+ for (y = 0; y < h; y++)
{
- if (!fgets(buf, 255, f))
- {
- free(idata);
- fclose(f);
- return 0;
- }
- i = 0;
+ int w3 = 3 * w;
+
+ iptr = idata;
+ x = 0;
+ while (x < w3)
+ {
+ if (!buf[i]) /* fill buffer */
+ {
+ if (!fgets(buf, 255, f))
+ {
+ free(idata);
+ fclose(f);
+ return 0;
+ }
+ i = 0;
+ }
+ while (buf[i] && isspace(buf[i]))
+ i++;
+ while (buf[i] && !isspace(buf[i]))
+ buf2[j++] = buf[i++];
+ if (j)
+ {
+ buf2[j] = 0;
+ *(iptr++) = atoi(buf2);
+ j = 0;
+ x++;
+ }
+ }
+ iptr = idata;
+ if (v == 255)
+ {
+ for (x = 0; x < w; x++)
+ {
+ *ptr2 =
+ 0xff000000 | (iptr[0] << 16) | (iptr[1] << 8)
+ | iptr[2];
+ ptr2++;
+ iptr += 3;
+ }
+ }
+ else
+ {
+ for (x = 0; x < w; x++)
+ {
+ *ptr2 =
+ 0xff000000 | (((ptr[0] * 255) / v) << 16) |
+ (((iptr[1] * 255) / v) << 8) | ((iptr[2] *
+ 255) / v);
+ ptr2++;
+ iptr += 3;
+ }
+ }
+ if (progress)
+ {
+ char per;
+ int l;
+
+ per = (char)((100 * y) / im->h);
+ if (((per - pper) >= progress_granularity)
+ || (y == (im->h - 1)))
+ {
+ l = y - pl;
+
+ /* fix off by one in case of the last line */
+ if (y == (im->h - 1))
+ l++;
+
+ if (!progress(im, per, 0, pl, im->w, l))
+ {
+ if (idata)
+ free(idata);
+ fclose(f);
+ return 2;
+ }
+ pper = per;
+ pl = y;
+ }
+ }
}
- while (buf[i] && isspace(buf[i]))
- i++;
- while (buf[i] && !isspace(buf[i]))
- buf2[j++] = buf[i++];
- if (j)
+ break;
+ case '4': /* binary 1bit monochrome */
+ data = malloc(1 * sizeof(DATA8));
+ if (!data)
{
- buf2[j] = 0;
- *(iptr++) = atoi(buf2);
- j = 0;
- x++;
+ fclose(f);
+ return 0;
}
- }
- iptr = idata;
- if (v == 255)
- {
- for (x = 0; x < w; x++)
+ ptr2 = im->data;
+ j = 0;
+ while ((fread(data, 1, 1, f)) && (j < (w * h)))
{
- *ptr2 =
- 0xff000000 | (iptr[0] << 16) | (iptr[1] << 8) |
- iptr[2];
- ptr2++;
- iptr += 3;
+ for (i = 7; i >= 0; i--)
+ {
+ if (j < (w * h))
+ {
+ if (data[0] & (1 << i))
+ *ptr2 = 0xff000000;
+ else
+ *ptr2 = 0xffffffff;
+ ptr2++;
+ }
+ j++;
+ }
}
- }
- else
- {
- for (x = 0; x < w; x++)
+ break;
+ case '5': /* binary 8bit grayscale GGGGGGGG */
+ data = malloc(1 * sizeof(DATA8) * w);
+ if (!data)
{
- *ptr2 =
- 0xff000000 | (((ptr[0] * 255) / v) << 16) |
- (((iptr[1] * 255) / v) << 8) | ((iptr[2] * 255) / v);
- ptr2++;
- iptr += 3;
- }
- }
- if (progress)
- {
- char per;
- int l;
-
- per = (char) ((100 * y) / im->h);
- if (((per - pper) >= progress_granularity)
- || (y == (im->h - 1)))
- {
- l = y - pl;
-
- /* fix off by one in case of the last line */
- if (y == (im->h -1))
- l++;
-
- if (!progress(im, per, 0, pl, im->w, l))
- {
- if (idata)
- free(idata);
- fclose(f);
- return 2;
- }
- pper = per;
- pl = y;
+ fclose(f);
+ return 0;
}
- }
- }
- break;
- case '4': /* binary 1bit monochrome */
- data = malloc(1 * sizeof(DATA8));
- if (!data)
- {
- fclose(f);
- return 0;
- }
- ptr2 = im->data;
- j = 0;
- while ((fread(data, 1, 1, f)) && (j < (w * h)))
- {
- for (i = 7; i >= 0; i--)
- {
- if (j < (w * h))
+ ptr2 = im->data;
+ for (y = 0; y < h; y++)
{
- if (data[0] & (1 << i))
- *ptr2 = 0xff000000;
+ if (!fread(data, w * 1, 1, f))
+ {
+ free(data);
+ fclose(f);
+ return 1;
+ }
+ ptr = data;
+ if (v == 255)
+ {
+ for (x = 0; x < w; x++)
+ {
+ *ptr2 =
+ 0xff000000 | (ptr[0] << 16) | (ptr[0] << 8) |
+ ptr[0];
+ ptr2++;
+ ptr++;
+ }
+ }
else
- *ptr2 = 0xffffffff;
- ptr2++;
- }
- j++;
- }
- }
- break;
- case '5': /* binary 8bit grayscale GGGGGGGG */
- data = malloc(1 * sizeof(DATA8) * w);
- if (!data)
- {
- fclose(f);
- return 0;
- }
- ptr2 = im->data;
- for (y = 0; y < h; y++)
- {
- if (!fread(data, w * 1, 1, f))
- {
- free(data);
- fclose(f);
- return 1;
- }
- ptr = data;
- if (v == 255)
- {
- for (x = 0; x < w; x++)
- {
- *ptr2 =
- 0xff000000 | (ptr[0] << 16) | (ptr[0] << 8) | ptr[0];
- ptr2++;
- ptr++;
- }
- }
- else
- {
- for (x = 0; x < w; x++)
- {
- *ptr2 =
- 0xff000000 | (((ptr[0] * 255) / v) << 16) |
- (((ptr[0] * 255) / v) << 8) | ((ptr[0] * 255) / v);
- ptr2++;
- ptr++;
+ {
+ for (x = 0; x < w; x++)
+ {
+ *ptr2 =
+ 0xff000000 | (((ptr[0] * 255) / v) << 16) |
+ (((ptr[0] * 255) / v) << 8) | ((ptr[0] *
+ 255) / v);
+ ptr2++;
+ ptr++;
+ }
+ }
+ if (progress)
+ {
+ char per;
+ int l;
+
+ per = (char)((100 * y) / im->h);
+ if (((per - pper) >= progress_granularity)
+ || (y == (im->h - 1)))
+ {
+ l = y - pl;
+
+ /* fix off by one in case of the last line */
+ if (y == (im->h - 1))
+ l++;
+
+ if (!progress(im, per, 0, pl, im->w, l))
+ {
+ if (data)
+ free(data);
+ fclose(f);
+ return 2;
+ }
+ pper = per;
+ pl = y;
+ }
+ }
}
- }
- if (progress)
- {
- char per;
- int l;
-
- per = (char) ((100 * y) / im->h);
- if (((per - pper) >= progress_granularity)
- || (y == (im->h - 1)))
+ break;
+ case '6': /* 24bit binary RGBRGBRGB */
+ data = malloc(3 * sizeof(DATA8) * w);
+ if (!data)
{
- l = y - pl;
-
- /* fix off by one in case of the last line */
- if (y == (im->h -1))
- l++;
-
- if (!progress(im, per, 0, pl, im->w, l))
- {
- if (data)
- free(data);
- fclose(f);
- return 2;
- }
- pper = per;
- pl = y;
- }
- }
- }
- break;
- case '6': /* 24bit binary RGBRGBRGB */
- data = malloc(3 * sizeof(DATA8) * w);
- if (!data)
- {
- fclose(f);
- return 0;
- }
- ptr2 = im->data;
- for (y = 0; y < h; y++)
- {
- if (!fread(data, w * 3, 1, f))
- {
- free(data);
- fclose(f);
- return 1;
- }
- ptr = data;
- if (v == 255)
- {
- for (x = 0; x < w; x++)
- {
- *ptr2 =
- 0xff000000 | (ptr[0] << 16) | (ptr[1] << 8) | ptr[2];
- ptr2++;
- ptr += 3;
+ fclose(f);
+ return 0;
}
- }
- else
- {
- for (x = 0; x < w; x++)
+ ptr2 = im->data;
+ for (y = 0; y < h; y++)
{
- *ptr2 =
- 0xff000000 | (((ptr[0] * 255) / v) << 16) |
- (((ptr[1] * 255) / v) << 8) | ((ptr[2] * 255) / v);
- ptr2++;
- ptr += 3;
- }
- }
- if (progress)
- {
- char per;
- int l;
-
- per = (char) ((100 * y) / im->h);
- if (((per - pper) >= progress_granularity)
- || (y == (im->h - 1)))
- {
- l = y - pl;
-
- /* fix off by one in case of the last line */
- if (y == (im->h -1))
- l++;
-
- if (!progress(im, per, 0, pl, im->w, l))
- {
- if (data)
- free(data);
- fclose(f);
- return 2;
- }
- pper = per;
- pl = y;
+ if (!fread(data, w * 3, 1, f))
+ {
+ free(data);
+ fclose(f);
+ return 1;
+ }
+ ptr = data;
+ if (v == 255)
+ {
+ for (x = 0; x < w; x++)
+ {
+ *ptr2 =
+ 0xff000000 | (ptr[0] << 16) | (ptr[1] << 8) |
+ ptr[2];
+ ptr2++;
+ ptr += 3;
+ }
+ }
+ else
+ {
+ for (x = 0; x < w; x++)
+ {
+ *ptr2 =
+ 0xff000000 | (((ptr[0] * 255) / v) << 16) |
+ (((ptr[1] * 255) / v) << 8) | ((ptr[2] *
+ 255) / v);
+ ptr2++;
+ ptr += 3;
+ }
+ }
+ if (progress)
+ {
+ char per;
+ int l;
+
+ per = (char)((100 * y) / im->h);
+ if (((per - pper) >= progress_granularity)
+ || (y == (im->h - 1)))
+ {
+ l = y - pl;
+
+ /* fix off by one in case of the last line */
+ if (y == (im->h - 1))
+ l++;
+
+ if (!progress(im, per, 0, pl, im->w, l))
+ {
+ if (data)
+ free(data);
+ fclose(f);
+ return 2;
+ }
+ pper = per;
+ pl = y;
+ }
+ }
}
- }
- }
- break;
- case '7': /* XV's 8bit 332 format */
- data = malloc(1 * sizeof(DATA8) * w);
- if (!data)
- {
- fclose(f);
- return 0;
- }
- ptr2 = im->data;
- for (y = 0; y < h; y++)
- {
- if (!fread(data, w * 1, 1, f))
- {
- free(data);
- fclose(f);
- return 1;
- }
- ptr = data;
- for (x = 0; x < w; x++)
- {
- int r, g, b;
-
- r = (*ptr >> 5) & 0x7;
- g = (*ptr >> 2) & 0x7;
- b = (*ptr) & 0x3;
- *ptr2 =
- 0xff000000 | (((r << 21) | (r << 18) | (r << 15)) &
- 0xff0000) | (((g << 13) | (g << 10) |
- (g << 7)) & 0xff00) | ((b <<
- 6) |
- (b <<
- 4) |
- (b <<
- 2) |
- (b <<
- 0));
- ptr2++;
- ptr++;
- }
- if (progress)
- {
- char per;
- int l;
-
- per = (char) ((100 * y) / im->h);
- if (((per - pper) >= progress_granularity)
- || (y == (im->h - 1)))
+ break;
+ case '7': /* XV's 8bit 332 format */
+ data = malloc(1 * sizeof(DATA8) * w);
+ if (!data)
{
- /* fix off by one in case of the last line */
- if (y == (im->h -1))
- l++;
-
- if (!progress(im, per, 0, pl, im->w, l))
- {
- if (data)
- free(data);
- fclose(f);
- return 2;
- }
- pper = per;
- pl = y;
+ fclose(f);
+ return 0;
}
- }
- }
- break;
- case '8': /* 24bit binary RGBARGBARGBA */
- data = malloc(4 * sizeof(DATA8) * w);
- if (!data)
- {
- fclose(f);
- return 0;
- }
- ptr2 = im->data;
- for (y = 0; y < h; y++)
- {
- if (!fread(data, w * 4, 1, f))
- {
- free(data);
- fclose(f);
- return 1;
- }
- ptr = data;
- if (v == 255)
- {
- for (x = 0; x < w; x++)
+ ptr2 = im->data;
+ for (y = 0; y < h; y++)
{
- *ptr2 =
- (ptr[3] << 24) | (ptr[0] << 16) | (ptr[1] << 8) |
- ptr[2];
- ptr2++;
- ptr += 4;
+ if (!fread(data, w * 1, 1, f))
+ {
+ free(data);
+ fclose(f);
+ return 1;
+ }
+ ptr = data;
+ for (x = 0; x < w; x++)
+ {
+ int r, g, b;
+
+ r = (*ptr >> 5) & 0x7;
+ g = (*ptr >> 2) & 0x7;
+ b = (*ptr) & 0x3;
+ *ptr2 =
+ 0xff000000 | (((r << 21) | (r << 18) | (r << 15)) &
+ 0xff0000) | (((g << 13) | (g << 10) |
+ (g << 7)) & 0xff00) |
+ ((b << 6) | (b << 4) | (b << 2) | (b << 0));
+ ptr2++;
+ ptr++;
+ }
+ if (progress)
+ {
+ char per;
+ int l;
+
+ per = (char)((100 * y) / im->h);
+ if (((per - pper) >= progress_granularity)
+ || (y == (im->h - 1)))
+ {
+ /* fix off by one in case of the last line */
+ if (y == (im->h - 1))
+ l++;
+
+ if (!progress(im, per, 0, pl, im->w, l))
+ {
+ if (data)
+ free(data);
+ fclose(f);
+ return 2;
+ }
+ pper = per;
+ pl = y;
+ }
+ }
}
- }
- else
- {
- for (x = 0; x < w; x++)
+ break;
+ case '8': /* 24bit binary RGBARGBARGBA */
+ data = malloc(4 * sizeof(DATA8) * w);
+ if (!data)
{
- *ptr2 =
- (((ptr[3] * 255) / v) << 24) | (((ptr[0] * 255) / v) <<
- 16) |
- (((ptr[1] * 255) / v) << 8) | ((ptr[2] * 255) / v);
- ptr2++;
- ptr += 4;
+ fclose(f);
+ return 0;
}
- }
- if (progress)
- {
- char per;
- int l;
-
- per = (char) ((100 * y) / im->h);
- if (((per - pper) >= progress_granularity)
- || (y == (im->h - 1)))
+ ptr2 = im->data;
+ for (y = 0; y < h; y++)
{
- /* fix off by one in case of the last line */
- if (y == (im->h -1))
- l++;
-
- if (!progress(im, per, 0, pl, im->w, l))
- {
- if (data)
- free(data);
- fclose(f);
- return 2;
- }
- pper = per;
- pl = y;
+ if (!fread(data, w * 4, 1, f))
+ {
+ free(data);
+ fclose(f);
+ return 1;
+ }
+ ptr = data;
+ if (v == 255)
+ {
+ for (x = 0; x < w; x++)
+ {
+ *ptr2 =
+ (ptr[3] << 24) | (ptr[0] << 16) | (ptr[1] <<
+ 8) |
+ ptr[2];
+ ptr2++;
+ ptr += 4;
+ }
+ }
+ else
+ {
+ for (x = 0; x < w; x++)
+ {
+ *ptr2 =
+ (((ptr[3] * 255) /
+ v) << 24) | (((ptr[0] * 255) /
+ v) << 16) | (((ptr[1] * 255) /
+ v) << 8) |
+ ((ptr[2] * 255) / v);
+ ptr2++;
+ ptr += 4;
+ }
+ }
+ if (progress)
+ {
+ char per;
+ int l;
+
+ per = (char)((100 * y) / im->h);
+ if (((per - pper) >= progress_granularity)
+ || (y == (im->h - 1)))
+ {
+ /* fix off by one in case of the last line */
+ if (y == (im->h - 1))
+ l++;
+
+ if (!progress(im, per, 0, pl, im->w, l))
+ {
+ if (data)
+ free(data);
+ fclose(f);
+ return 2;
+ }
+ pper = per;
+ pl = y;
+ }
+ }
}
- }
- }
- break;
- default:
- fclose(f);
- return 0;
- break;
- }
- if (idata)
- free(idata);
- if (data)
- free(data);
- }
+ break;
+ default:
+ fclose(f);
+ return 0;
+ break;
+ }
+ if (idata)
+ free(idata);
+ if (data)
+ free(data);
+ }
fclose(f);
return 1;
}
char
-save(ImlibImage * im, ImlibProgressFunction progress,
- char progress_granularity)
+save(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity)
{
- FILE *f;
- DATA8 *buf, *bptr;
- DATA32 *ptr;
- int x, y, pl = 0;
- char pper = 0;
+ FILE *f;
+ DATA8 *buf, *bptr;
+ DATA32 *ptr;
+ int x, y, pl = 0;
+ char pper = 0;
/* no image data? abort */
if (!im->data)
@@ -713,96 +712,98 @@ save(ImlibImage * im, ImlibProgressFunction progress,
return 0;
/* if the image has a useful alpha channel */
if (im->flags & F_HAS_ALPHA)
- {
- /* allocate a small buffer to convert image data */
- buf = malloc(im->w * 4 * sizeof(DATA8));
- if (!buf)
- {
- fclose(f);
- return 0;
- }
- ptr = im->data;
- fprintf(f, "P8\n" "# PNM File written by Imlib2\n" "%i %i\n" "255\n",
- im->w, im->h);
- for (y = 0; y < im->h; y++)
- {
- bptr = buf;
- for (x = 0; x < im->w; x++)
- {
- bptr[0] = ((*ptr) >> 16) & 0xff;
- bptr[1] = ((*ptr) >> 8) & 0xff;
- bptr[2] = ((*ptr)) & 0xff;
- bptr[3] = ((*ptr) >> 24) & 0xff;
- bptr += 4;
- ptr++;
- }
- fwrite(buf, im->w * 4, 1, f);
- if (progress)
- {
- char per;
- int l;
-
- per = (char) ((100 * y) / im->h);
- if (((per - pper) >= progress_granularity) || (y == (im->h - 1)))
- {
- l = y - pl;
- if (!progress(im, per, 0, (y - l), im->w, l))
+ {
+ /* allocate a small buffer to convert image data */
+ buf = malloc(im->w * 4 * sizeof(DATA8));
+ if (!buf)
+ {
+ fclose(f);
+ return 0;
+ }
+ ptr = im->data;
+ fprintf(f, "P8\n" "# PNM File written by Imlib2\n" "%i %i\n" "255\n",
+ im->w, im->h);
+ for (y = 0; y < im->h; y++)
+ {
+ bptr = buf;
+ for (x = 0; x < im->w; x++)
{
- free(buf);
- fclose(f);
- return 2;
+ bptr[0] = ((*ptr) >> 16) & 0xff;
+ bptr[1] = ((*ptr) >> 8) & 0xff;
+ bptr[2] = ((*ptr)) & 0xff;
+ bptr[3] = ((*ptr) >> 24) & 0xff;
+ bptr += 4;
+ ptr++;
}
- pper = per;
- pl = y;
- }
- }
- }
- }
+ fwrite(buf, im->w * 4, 1, f);
+ if (progress)
+ {
+ char per;
+ int l;
+
+ per = (char)((100 * y) / im->h);
+ if (((per - pper) >= progress_granularity)
+ || (y == (im->h - 1)))
+ {
+ l = y - pl;
+ if (!progress(im, per, 0, (y - l), im->w, l))
+ {
+ free(buf);
+ fclose(f);
+ return 2;
+ }
+ pper = per;
+ pl = y;
+ }
+ }
+ }
+ }
else
- {
- /* allocate a small buffer to convert image data */
- buf = malloc(im->w * 3 * sizeof(DATA8));
- if (!buf)
- {
- fclose(f);
- return 0;
- }
- ptr = im->data;
- fprintf(f, "P6\n" "# PNM File written by Imlib2\n" "%i %i\n" "255\n",
- im->w, im->h);
- for (y = 0; y < im->h; y++)
- {
- bptr = buf;
- for (x = 0; x < im->w; x++)
- {
- bptr[0] = ((*ptr) >> 16) & 0xff;
- bptr[1] = ((*ptr) >> 8) & 0xff;
- bptr[2] = ((*ptr)) & 0xff;
- bptr += 3;
- ptr++;
- }
- fwrite(buf, im->w * 3, 1, f);
- if (progress)
- {
- char per;
- int l;
-
- per = (char) ((100 * y) / im->h);
- if (((per - pper) >= progress_granularity) || (y == (im->h - 1)))
- {
- l = y - pl;
- if (!progress(im, per, 0, (y - l), im->w, l))
+ {
+ /* allocate a small buffer to convert image data */
+ buf = malloc(im->w * 3 * sizeof(DATA8));
+ if (!buf)
+ {
+ fclose(f);
+ return 0;
+ }
+ ptr = im->data;
+ fprintf(f, "P6\n" "# PNM File written by Imlib2\n" "%i %i\n" "255\n",
+ im->w, im->h);
+ for (y = 0; y < im->h; y++)
+ {
+ bptr = buf;
+ for (x = 0; x < im->w; x++)
{
- free(buf);
- fclose(f);
- return 2;
+ bptr[0] = ((*ptr) >> 16) & 0xff;
+ bptr[1] = ((*ptr) >> 8) & 0xff;
+ bptr[2] = ((*ptr)) & 0xff;
+ bptr += 3;
+ ptr++;
}
- pper = per;
- pl = y;
- }
- }
- }
- }
+ fwrite(buf, im->w * 3, 1, f);
+ if (progress)
+ {
+ char per;
+ int l;
+
+ per = (char)((100 * y) / im->h);
+ if (((per - pper) >= progress_granularity)
+ || (y == (im->h - 1)))
+ {
+ l = y - pl;
+ if (!progress(im, per, 0, (y - l), im->w, l))
+ {
+ free(buf);
+ fclose(f);
+ return 2;
+ }
+ pper = per;
+ pl = y;
+ }
+ }
+ }
+ }
/* finish off */
free(buf);
fclose(f);
@@ -813,10 +814,10 @@ save(ImlibImage * im, ImlibProgressFunction progress,
void
formats(ImlibLoader * l)
{
- char *list_formats[] = { "pnm", "ppm", "pgm", "pbm", "pam" };
+ char *list_formats[] = { "pnm", "ppm", "pgm", "pbm", "pam" };
{
- int i;
+ int i;
l->num_formats = (sizeof(list_formats) / sizeof(char *));
l->formats = malloc(sizeof(char *) * l->num_formats);
diff --git a/loaders/loader_tga.c b/loaders/loader_tga.c
index b454bd0..1184746 100644
--- a/loaders/loader_tga.c
+++ b/loaders/loader_tga.c
@@ -15,8 +15,8 @@
#endif
#include "common.h"
-#include <stdio.h>
-#include <string.h>
+#include <stdio.h>
+#include <string.h>
#include <sys/stat.h>
#include <X11/Xlib.h>
#include <X11/extensions/XShm.h>
@@ -25,170 +25,171 @@
#include "colormod.h"
#include "blend.h"
-char load (ImlibImage *im, ImlibProgressFunction progress,
- char progress_granularity, char immediate_load);
-char save (ImlibImage *im, ImlibProgressFunction progress,
- char progress_granularity);
-void formats (ImlibLoader *l);
+char load(ImlibImage * im, ImlibProgressFunction progress,
+ char progress_granularity, char immediate_load);
+char save(ImlibImage * im, ImlibProgressFunction progress,
+ char progress_granularity);
+void formats(ImlibLoader * l);
/* flip an inverted image - see RLE reading below */
-static DATA32* flip(DATA32* in, int w, int h);
+static DATA32 *flip(DATA32 * in, int w, int h);
/* TGA pixel formats */
-#define TGA_TYPE_MAPPED 1
-#define TGA_TYPE_COLOR 2
-#define TGA_TYPE_GRAY 3
-#define TGA_TYPE_MAPPED_RLE 9
-#define TGA_TYPE_COLOR_RLE 10
-#define TGA_TYPE_GRAY_RLE 11
+#define TGA_TYPE_MAPPED 1
+#define TGA_TYPE_COLOR 2
+#define TGA_TYPE_GRAY 3
+#define TGA_TYPE_MAPPED_RLE 9
+#define TGA_TYPE_COLOR_RLE 10
+#define TGA_TYPE_GRAY_RLE 11
/* TGA header flags */
-#define TGA_DESC_ABITS 0x0f
-#define TGA_DESC_HORIZONTAL 0x10
-#define TGA_DESC_VERTICAL 0x20
-
-#define TGA_SIGNATURE "TRUEVISION-XFILE"
-
-typedef struct {
- unsigned char idLength;
- unsigned char colorMapType;
- unsigned char imageType;
- unsigned char colorMapIndexLo, colorMapIndexHi;
- unsigned char colorMapLengthLo, colorMapLengthHi;
- unsigned char colorMapSize;
- unsigned char xOriginLo, xOriginHi;
- unsigned char yOriginLo, yOriginHi;
- unsigned char widthLo, widthHi;
- unsigned char heightLo, heightHi;
- unsigned char bpp;
- unsigned char descriptor;
-} tga_header;
-
-typedef struct {
- unsigned int extensionAreaOffset;
- unsigned int developerDirectoryOffset;
- char signature[16];
- char dot;
- char null;
-} tga_footer;
+#define TGA_DESC_ABITS 0x0f
+#define TGA_DESC_HORIZONTAL 0x10
+#define TGA_DESC_VERTICAL 0x20
+#define TGA_SIGNATURE "TRUEVISION-XFILE"
+
+typedef struct {
+ unsigned char idLength;
+ unsigned char colorMapType;
+ unsigned char imageType;
+ unsigned char colorMapIndexLo, colorMapIndexHi;
+ unsigned char colorMapLengthLo, colorMapLengthHi;
+ unsigned char colorMapSize;
+ unsigned char xOriginLo, xOriginHi;
+ unsigned char yOriginLo, yOriginHi;
+ unsigned char widthLo, widthHi;
+ unsigned char heightLo, heightHi;
+ unsigned char bpp;
+ unsigned char descriptor;
+} tga_header;
+
+typedef struct {
+ unsigned int extensionAreaOffset;
+ unsigned int developerDirectoryOffset;
+ char signature[16];
+ char dot;
+ char null;
+} tga_footer;
/*
* Write an uncompressed RGBA 24- or 32-bit targa to disk
* (If anyone wants to write a RLE saver, feel free =)
*/
-char
-save (ImlibImage *im, ImlibProgressFunction progress,
- char progress_granularity)
+char
+save(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity)
{
- FILE *f;
- DATA32 *dataptr;
- unsigned char *buf, *bufptr;
- int y, pl = 0;
- char pper = 0;
-
- tga_header header;
-
- if(!im->data)
+ FILE *f;
+ DATA32 *dataptr;
+ unsigned char *buf, *bufptr;
+ int y, pl = 0;
+ char pper = 0;
+
+ tga_header header;
+
+ if (!im->data)
return 0;
-
+
f = fopen(im->real_file, "wb");
- if(!f)
+ if (!f)
return 0;
-
-
+
/* assemble the TGA header information */
-
+
/* most entries are zero... */
- memset(&header, 0x0, sizeof(header));
-
+ memset(&header, 0x0, sizeof(header));
+
/* uncompressed RGB Targa identifier */
- header.imageType = TGA_TYPE_COLOR;
-
+ header.imageType = TGA_TYPE_COLOR;
+
/* image width, low byte */
- header.widthLo = im->w & 0xFF;
+ header.widthLo = im->w & 0xFF;
/* image width, high byte */
- header.widthHi = im->w >> 8;
-
+ header.widthHi = im->w >> 8;
+
/* image height, low byte */
- header.heightLo = im->h & 0xFF;
- /* image height, high byte */
- header.heightHi = im->h >> 8;
-
- /* total number of bits per pixel */
- header.bpp = (im->flags & F_HAS_ALPHA) ? 32 : 24;
+ header.heightLo = im->h & 0xFF;
+ /* image height, high byte */
+ header.heightHi = im->h >> 8;
+
+ /* total number of bits per pixel */
+ header.bpp = (im->flags & F_HAS_ALPHA) ? 32 : 24;
/* number of extra (alpha) bits per pixel */
- header.descriptor = (im->flags & F_HAS_ALPHA) ? 8 : 0;
-
+ header.descriptor = (im->flags & F_HAS_ALPHA) ? 8 : 0;
+
/* top-to-bottom storage */
header.descriptor |= TGA_DESC_VERTICAL;
-
+
/* allocate a buffer to receive the BGRA-swapped pixel values */
- buf = malloc(im->w * im->h * ((im->flags & F_HAS_ALPHA) ? 4 : 3) );
- if(!buf) {
- fclose(f);
- return 0;
- }
-
+ buf = malloc(im->w * im->h * ((im->flags & F_HAS_ALPHA) ? 4 : 3));
+ if (!buf)
+ {
+ fclose(f);
+ return 0;
+ }
+
/* now we have to read from im->data into buf, swapping RGBA to BGRA */
- dataptr = im->data; bufptr = buf;
-
+ dataptr = im->data;
+ bufptr = buf;
+
/* for each row */
- for(y = 0; y < im->h; y++)
- {
- int x;
- unsigned char r, g, b, a;
-
- /* for each pixel in the row */
- for(x = 0; x < im->w; x++) {
- if(im->flags & F_HAS_ALPHA) {
- READ_RGBA(dataptr, r, g, b, a);
- *bufptr++ = b;
- *bufptr++ = g;
- *bufptr++ = r;
- *bufptr++ = a;
- } else {
- READ_RGB(dataptr, r, g, b);
- *bufptr++ = b;
- *bufptr++ = g;
- *bufptr++ = r;
- }
- dataptr++;
- } /* end for (each pixel in row) */
-
-
- /* report progress every row */
- if (progress)
- {
- char per;
- int l;
-
- per = (char)((100 * y) / im->h);
- if (((per - pper) >= progress_granularity) ||
- (y == (im->h - 1)))
- {
+ for (y = 0; y < im->h; y++)
+ {
+ int x;
+ unsigned char r, g, b, a;
+
+ /* for each pixel in the row */
+ for (x = 0; x < im->w; x++)
+ {
+ if (im->flags & F_HAS_ALPHA)
+ {
+ READ_RGBA(dataptr, r, g, b, a);
+ *bufptr++ = b;
+ *bufptr++ = g;
+ *bufptr++ = r;
+ *bufptr++ = a;
+ }
+ else
+ {
+ READ_RGB(dataptr, r, g, b);
+ *bufptr++ = b;
+ *bufptr++ = g;
+ *bufptr++ = r;
+ }
+ dataptr++;
+ } /* end for (each pixel in row) */
+
+ /* report progress every row */
+ if (progress)
+ {
+ char per;
+ int l;
+
+ per = (char)((100 * y) / im->h);
+ if (((per - pper) >= progress_granularity) || (y == (im->h - 1)))
+ {
l = y - pl;
- if(!progress(im, per, 0, (y - l), im->w, l))
- {
- if(buf)
- free(buf);
- fclose(f);
- return 2;
- }
- pper = per;
- pl = y;
- }
- }
- }
-
+ if (!progress(im, per, 0, (y - l), im->w, l))
+ {
+ if (buf)
+ free(buf);
+ fclose(f);
+ return 2;
+ }
+ pper = per;
+ pl = y;
+ }
+ }
+ }
+
/* write the header */
- fwrite(&header, sizeof(header), 1, f);
-
+ fwrite(&header, sizeof(header), 1, f);
+
/* write the image data */
- fwrite(buf, 1, im->w * im->h * ((im->flags & F_HAS_ALPHA) ? 4 : 3), f);
-
- if(buf)
+ fwrite(buf, 1, im->w * im->h * ((im->flags & F_HAS_ALPHA) ? 4 : 3), f);
+
+ if (buf)
free(buf);
fclose(f);
return 1;
@@ -204,410 +205,410 @@ save (ImlibImage *im, ImlibProgressFunction progress,
* There are several other (uncommon) Targa formats which this function can't currently handle
*/
-char
-load (ImlibImage *im, ImlibProgressFunction progress,
- char progress_granularity, char immediate_load)
-{
- FILE *fp;
- int bpp, vinverted = 0;
- int rle = 0, footer_present = 0;
-
- tga_header header;
- tga_footer footer;
-
- if(im->data)
+char
+load(ImlibImage * im, ImlibProgressFunction progress,
+ char progress_granularity, char immediate_load)
+{
+ FILE *fp;
+ int bpp, vinverted = 0;
+ int rle = 0, footer_present = 0;
+
+ tga_header header;
+ tga_footer footer;
+
+ if (im->data)
return 0;
-
- fp = fopen(im->real_file, "rb");
- if(!fp)
+
+ fp = fopen(im->real_file, "rb");
+ if (!fp)
return 0;
-
+
/* read the footer first */
- fseek (fp, 0L - (sizeof (tga_footer)), SEEK_END);
- if (fread (&footer, sizeof (tga_footer), 1, fp) != 1)
- {
- fclose(fp);
- return 0;
- }
-
+ fseek(fp, 0L - (sizeof(tga_footer)), SEEK_END);
+ if (fread(&footer, sizeof(tga_footer), 1, fp) != 1)
+ {
+ fclose(fp);
+ return 0;
+ }
+
/* check the footer to see if we have a v2.0 TGA file */
- if (memcmp(footer.signature, TGA_SIGNATURE, sizeof (footer.signature)) == 0)
+ if (memcmp(footer.signature, TGA_SIGNATURE, sizeof(footer.signature)) == 0)
footer_present = 1;
-
+
if (!footer_present)
{
- fclose(fp);
- return 0;
+ fclose(fp);
+ return 0;
}
-
+
/* now read the header */
- if (fseek (fp, 0, SEEK_SET) || fread (&header, sizeof (header), 1, fp) != 1)
- {
- fclose(fp);
- return 0;
+ if (fseek(fp, 0, SEEK_SET) || fread(&header, sizeof(header), 1, fp) != 1)
+ {
+ fclose(fp);
+ return 0;
}
-
+
/* skip over alphanumeric ID field */
- if (header.idLength && fseek (fp, header.idLength, SEEK_CUR))
- {
- fclose(fp);
- return 0;
- }
-
+ if (header.idLength && fseek(fp, header.idLength, SEEK_CUR))
+ {
+ fclose(fp);
+ return 0;
+ }
+
/* now parse the header */
-
+
/* this flag indicated bottom-up pixel storage */
- vinverted = header.descriptor ^ TGA_DESC_VERTICAL;
-
- switch (header.imageType)
- {
- case TGA_TYPE_COLOR_RLE:
- case TGA_TYPE_GRAY_RLE:
- rle = 1;
- break;
-
- case TGA_TYPE_COLOR:
- case TGA_TYPE_GRAY:
- rle = 0;
- break;
-
- default:
- fclose(fp);
- return 0;
- }
-
+ vinverted = header.descriptor ^ TGA_DESC_VERTICAL;
+
+ switch (header.imageType)
+ {
+ case TGA_TYPE_COLOR_RLE:
+ case TGA_TYPE_GRAY_RLE:
+ rle = 1;
+ break;
+
+ case TGA_TYPE_COLOR:
+ case TGA_TYPE_GRAY:
+ rle = 0;
+ break;
+
+ default:
+ fclose(fp);
+ return 0;
+ }
+
/* bits per pixel */
- bpp = header.bpp;
-
- if( ! ((bpp == 32) || (bpp == 24) || (bpp == 8)) )
- {
- fclose(fp);
- return 0;
- }
-
+ bpp = header.bpp;
+
+ if (!((bpp == 32) || (bpp == 24) || (bpp == 8)))
+ {
+ fclose(fp);
+ return 0;
+ }
+
/* endian-safe loading of 16-bit sizes */
- im->w = (header.widthHi << 8) | header.widthLo;
- im->h = (header.heightHi << 8) | header.heightLo;
-
+ im->w = (header.widthHi << 8) | header.widthLo;
+ im->h = (header.heightHi << 8) | header.heightLo;
+
if ((im->w > 32767) || (im->w < 1) || (im->h > 32767) || (im->h < 1))
{
- im->w = 0;
- fclose(fp);
- return 0;
+ im->w = 0;
+ fclose(fp);
+ return 0;
}
-
- if(!im->format)
+
+ if (!im->format)
{
- if (bpp == 32)
- SET_FLAG(im->flags, F_HAS_ALPHA);
- else
- UNSET_FLAG(im->flags, F_HAS_ALPHA);
- im->format = strdup("tga");
+ if (bpp == 32)
+ SET_FLAG(im->flags, F_HAS_ALPHA);
+ else
+ UNSET_FLAG(im->flags, F_HAS_ALPHA);
+ im->format = strdup("tga");
}
-
+
/* if we need to actually read the pixel data... */
if (((!im->data) && (im->loader)) || (immediate_load) || (progress))
{
- unsigned long datasize;
- struct stat ss;
- unsigned char *buf, *bufptr;
- DATA32 *dataptr;
-
- int y, pl = 0;
- char pper = 0;
-
- /* allocate the destination buffer */
- im->data = malloc(im->w * im->h * sizeof(DATA32));
- if(!im->data)
- {
- im->w = 0;
- fclose(fp);
- return 0;
- }
-
- /* first we read the file data into a buffer for parsing */
- /* then we decode from RAM */
-
- /* find out how much data must be read from the file */
- /* (this is NOT simply width*height*4, due to compression) */
-
- stat(im->real_file, &ss);
- datasize = ss.st_size - sizeof(tga_header) - header.idLength -
- (footer_present ? sizeof(tga_footer) : 0);
-
- buf = malloc(datasize);
- if(!buf)
- {
- im->w = 0;
- fclose(fp);
- return 0;
- }
-
- /* read in the pixel data */
- if( fread(buf, 1, datasize, fp) != datasize)
- {
- fclose(fp);
- return 0;
- }
-
- /* buffer is ready for parsing */
-
- /* bufptr is the next byte to be read from the buffer */
- bufptr = buf;
-
- /* dataptr is the next 32-bit pixel to be filled in */
- dataptr = im->data;
-
- /* decode uncompressed BGRA data */
- if(!rle)
- {
- for(y = 0; y < im->h; y++) /* for each row */
- {
- int x;
-
- /* point dataptr at the beginning of the row */
- if(vinverted)
- /* some TGA's are stored upside-down! */
- dataptr = im->data + (im->h - (y+1)) * im->w;
- else
- dataptr = im->data + y * im->w;
-
-
- for(x = 0; x < im->w; x++) /* for each pixel in the row */
- {
- switch(bpp) {
-
- /* 32-bit BGRA pixels */
- case 32:
- WRITE_RGBA(dataptr,
- *(bufptr + 2), /* R */
- *(bufptr + 1), /* G */
- *(bufptr + 0), /* B */
- *(bufptr + 3) /* A */
- );
- dataptr++;
- bufptr += 4;
- break;
-
- /* 24-bit BGR pixels */
- case 24:
- WRITE_RGBA(dataptr,
- *(bufptr + 2), /* R */
- *(bufptr + 1), /* G */
- *(bufptr + 0), /* B */
- (char) 0xff /* A */
- );
- dataptr++;
- bufptr += 3;
- break;
-
- /* 8-bit grayscale */
- case 8:
- WRITE_RGBA(dataptr,
- *bufptr, /* grayscale */
- *bufptr,
- *bufptr,
- (char) 0xff
- );
- dataptr++;
- bufptr += 1;
- break;
- }
-
- } /* end for (each pixel) */
-
- /* report progress every row */
- if(progress)
- {
- char per;
- int l;
-
- per = (char)((100*y) / im->h);
- if (((per - pper) >= progress_granularity) ||
- (y == (im->h - 1)))
- {
- l = y - pl;
- if(!progress(im, per, 0, (y - l), im->w, l))
- {
- free(buf);
- fclose(fp);
- return 2;
- }
- pper = per;
- pl = y;
- }
- }
-
- } /* end for (each row) */
-
- } /* end if (RLE) */
-
- /* decode RLE compressed data */
- else
- {
- unsigned char curbyte, red, green, blue, alpha;
- DATA32 *final_pixel = dataptr + im->w * im->h;
-
- /* loop until we've got all the pixels */
- while(dataptr < final_pixel)
- {
- int count;
-
- curbyte = *bufptr++;
- count = (curbyte & 0x7F) + 1;
-
- if(curbyte & 0x80) /* RLE packet */
- {
- int i;
-
- switch(bpp) {
- case 32:
- blue = *bufptr++; green = *bufptr++; red = *bufptr++;
- alpha = *bufptr++;
- for(i = 0; i < count; i++) {
- WRITE_RGBA(dataptr, red, green, blue, alpha);
- dataptr++;
- }
- break;
-
- case 24:
- blue = *bufptr++; green = *bufptr++; red = *bufptr++;
- for(i = 0; i < count; i++) {
- WRITE_RGBA(dataptr, red, green, blue, (char) 0xff);
- dataptr++;
- }
- break;
-
- case 8:
- alpha = *bufptr++;
- for(i = 0; i < count; i++) {
- WRITE_RGBA(dataptr, alpha, alpha, alpha, (char) 0xff);
- dataptr++;
- }
- break;
- }
-
- } /* end if (RLE packet) */
-
- else /* raw packet */
- {
- int i;
-
- for(i = 0; i < count; i++)
- {
- switch(bpp) {
-
- /* 32-bit BGRA pixels */
- case 32:
- WRITE_RGBA(dataptr,
- *(bufptr + 2), /* R */
- *(bufptr + 1), /* G */
- *(bufptr + 0), /* B */
- *(bufptr + 3) /* A */
- );
- dataptr++;
- bufptr += 4;
- break;
-
- /* 24-bit BGR pixels */
- case 24:
- WRITE_RGBA(dataptr,
- *(bufptr + 2), /* R */
- *(bufptr + 1), /* G */
- *(bufptr + 0), /* B */
- (char) 0xff /* A */
- );
- dataptr++;
- bufptr += 3;
- break;
-
- /* 8-bit grayscale */
- case 8:
- WRITE_RGBA(dataptr,
- *bufptr, /* pseudo-grayscale */
- *bufptr,
- *bufptr,
- (char) 0xff
- );
- dataptr++;
- bufptr += 1;
- break;
- }
- }
- } /* end if (raw packet) */
-
- /* report progress every packet */
- if(progress)
- {
- char per;
- int l;
-
- /* compute an approximate y value */
- /* can't be exact since packets don't necessarily */
- /* end at the end of a row */
- y = (dataptr - im->data) / im->w;
-
- per = (char)((100*y) / im->h);
-
- if (((per - pper) >= progress_granularity) ||
- (y == (im->h - 1)))
- {
- l = y - pl;
- if(!progress(im, per, 0, (y - l), im->w, l))
- {
- free(buf);
- fclose(fp);
- return 2;
- }
- pper = per;
- pl = y;
- }
- } /* end progress report */
-
- } /* end for (each packet) */
-
- /* must now flip a bottom-up image */
-
- /* This is the best of several ugly implementations
- * I considered. It's not very good since the image
- * will be upside-down throughout the loading process.
- * This could be done in-line with the de-RLE code
- * above, but that would be messy to code. There's
- * probably a better way... */
-
- if(vinverted) {
- im->data = flip(im->data, im->w, im->h);
- if(!im->data) {
- fclose(fp);
- free(buf);
- return 0;
- }
- }
-
- } /* end if (image is RLE) */
-
- free(buf);
-
- } /* end if (loading pixel data) */
-
+ unsigned long datasize;
+ struct stat ss;
+ unsigned char *buf, *bufptr;
+ DATA32 *dataptr;
+
+ int y, pl = 0;
+ char pper = 0;
+
+ /* allocate the destination buffer */
+ im->data = malloc(im->w * im->h * sizeof(DATA32));
+ if (!im->data)
+ {
+ im->w = 0;
+ fclose(fp);
+ return 0;
+ }
+
+ /* first we read the file data into a buffer for parsing */
+ /* then we decode from RAM */
+
+ /* find out how much data must be read from the file */
+ /* (this is NOT simply width*height*4, due to compression) */
+
+ stat(im->real_file, &ss);
+ datasize = ss.st_size - sizeof(tga_header) - header.idLength -
+ (footer_present ? sizeof(tga_footer) : 0);
+
+ buf = malloc(datasize);
+ if (!buf)
+ {
+ im->w = 0;
+ fclose(fp);
+ return 0;
+ }
+
+ /* read in the pixel data */
+ if (fread(buf, 1, datasize, fp) != datasize)
+ {
+ fclose(fp);
+ return 0;
+ }
+
+ /* buffer is ready for parsing */
+
+ /* bufptr is the next byte to be read from the buffer */
+ bufptr = buf;
+
+ /* dataptr is the next 32-bit pixel to be filled in */
+ dataptr = im->data;
+
+ /* decode uncompressed BGRA data */
+ if (!rle)
+ {
+ for (y = 0; y < im->h; y++) /* for each row */
+ {
+ int x;
+
+ /* point dataptr at the beginning of the row */
+ if (vinverted)
+ /* some TGA's are stored upside-down! */
+ dataptr = im->data + (im->h - (y + 1)) * im->w;
+ else
+ dataptr = im->data + y * im->w;
+
+ for (x = 0; x < im->w; x++) /* for each pixel in the row */
+ {
+ switch (bpp)
+ {
+
+ /* 32-bit BGRA pixels */
+ case 32:
+ WRITE_RGBA(dataptr, *(bufptr + 2), /* R */
+ *(bufptr + 1), /* G */
+ *(bufptr + 0), /* B */
+ *(bufptr + 3) /* A */
+ );
+ dataptr++;
+ bufptr += 4;
+ break;
+
+ /* 24-bit BGR pixels */
+ case 24:
+ WRITE_RGBA(dataptr, *(bufptr + 2), /* R */
+ *(bufptr + 1), /* G */
+ *(bufptr + 0), /* B */
+ (char)0xff /* A */
+ );
+ dataptr++;
+ bufptr += 3;
+ break;
+
+ /* 8-bit grayscale */
+ case 8:
+ WRITE_RGBA(dataptr, *bufptr, /* grayscale */
+ *bufptr, *bufptr, (char)0xff);
+ dataptr++;
+ bufptr += 1;
+ break;
+ }
+
+ } /* end for (each pixel) */
+
+ /* report progress every row */
+ if (progress)
+ {
+ char per;
+ int l;
+
+ per = (char)((100 * y) / im->h);
+ if (((per - pper) >= progress_granularity) ||
+ (y == (im->h - 1)))
+ {
+ l = y - pl;
+ if (!progress(im, per, 0, (y - l), im->w, l))
+ {
+ free(buf);
+ fclose(fp);
+ return 2;
+ }
+ pper = per;
+ pl = y;
+ }
+ }
+
+ } /* end for (each row) */
+
+ } /* end if (RLE) */
+
+ /* decode RLE compressed data */
+ else
+ {
+ unsigned char curbyte, red, green, blue, alpha;
+ DATA32 *final_pixel = dataptr + im->w * im->h;
+
+ /* loop until we've got all the pixels */
+ while (dataptr < final_pixel)
+ {
+ int count;
+
+ curbyte = *bufptr++;
+ count = (curbyte & 0x7F) + 1;
+
+ if (curbyte & 0x80) /* RLE packet */
+ {
+ int i;
+
+ switch (bpp)
+ {
+ case 32:
+ blue = *bufptr++;
+ green = *bufptr++;
+ red = *bufptr++;
+ alpha = *bufptr++;
+ for (i = 0; i < count; i++)
+ {
+ WRITE_RGBA(dataptr, red, green, blue, alpha);
+ dataptr++;
+ }
+ break;
+
+ case 24:
+ blue = *bufptr++;
+ green = *bufptr++;
+ red = *bufptr++;
+ for (i = 0; i < count; i++)
+ {
+ WRITE_RGBA(dataptr, red, green, blue,
+ (char)0xff);
+ dataptr++;
+ }
+ break;
+
+ case 8:
+ alpha = *bufptr++;
+ for (i = 0; i < count; i++)
+ {
+ WRITE_RGBA(dataptr, alpha, alpha, alpha,
+ (char)0xff);
+ dataptr++;
+ }
+ break;
+ }
+
+ } /* end if (RLE packet) */
+
+ else /* raw packet */
+ {
+ int i;
+
+ for (i = 0; i < count; i++)
+ {
+ switch (bpp)
+ {
+
+ /* 32-bit BGRA pixels */
+ case 32:
+ WRITE_RGBA(dataptr, *(bufptr + 2), /* R */
+ *(bufptr + 1), /* G */
+ *(bufptr + 0), /* B */
+ *(bufptr + 3) /* A */
+ );
+ dataptr++;
+ bufptr += 4;
+ break;
+
+ /* 24-bit BGR pixels */
+ case 24:
+ WRITE_RGBA(dataptr, *(bufptr + 2), /* R */
+ *(bufptr + 1), /* G */
+ *(bufptr + 0), /* B */
+ (char)0xff /* A */
+ );
+ dataptr++;
+ bufptr += 3;
+ break;
+
+ /* 8-bit grayscale */
+ case 8:
+ WRITE_RGBA(dataptr, *bufptr, /* pseudo-grayscale */
+ *bufptr, *bufptr, (char)0xff);
+ dataptr++;
+ bufptr += 1;
+ break;
+ }
+ }
+ } /* end if (raw packet) */
+
+ /* report progress every packet */
+ if (progress)
+ {
+ char per;
+ int l;
+
+ /* compute an approximate y value */
+ /* can't be exact since packets don't necessarily */
+ /* end at the end of a row */
+ y = (dataptr - im->data) / im->w;
+
+ per = (char)((100 * y) / im->h);
+
+ if (((per - pper) >= progress_granularity) ||
+ (y == (im->h - 1)))
+ {
+ l = y - pl;
+ if (!progress(im, per, 0, (y - l), im->w, l))
+ {
+ free(buf);
+ fclose(fp);
+ return 2;
+ }
+ pper = per;
+ pl = y;
+ }
+ } /* end progress report */
+
+ } /* end for (each packet) */
+
+ /* must now flip a bottom-up image */
+
+ /* This is the best of several ugly implementations
+ * I considered. It's not very good since the image
+ * will be upside-down throughout the loading process.
+ * This could be done in-line with the de-RLE code
+ * above, but that would be messy to code. There's
+ * probably a better way... */
+
+ if (vinverted)
+ {
+ im->data = flip(im->data, im->w, im->h);
+ if (!im->data)
+ {
+ fclose(fp);
+ free(buf);
+ return 0;
+ }
+ }
+
+ } /* end if (image is RLE) */
+
+ free(buf);
+
+ } /* end if (loading pixel data) */
+
fclose(fp);
- return 1;
+ return 1;
}
-void
-formats (ImlibLoader *l)
-{
- char *list_formats[] =
- { "tga" };
-
- {
- int i;
-
- l->num_formats = (sizeof(list_formats) / sizeof (char *));
- l->formats = malloc(sizeof(char *) * l->num_formats);
- for (i = 0; i < l->num_formats; i++)
- l->formats[i] = strdup(list_formats[i]);
- }
+void
+formats(ImlibLoader * l)
+{
+ char *list_formats[] = { "tga" };
+
+ {
+ int i;
+
+ l->num_formats = (sizeof(list_formats) / sizeof(char *));
+ l->formats = malloc(sizeof(char *) * l->num_formats);
+ for (i = 0; i < l->num_formats; i++)
+ l->formats[i] = strdup(list_formats[i]);
+ }
}
/**********************/
@@ -617,25 +618,26 @@ formats (ImlibLoader *l)
* the rows in reverse order
*/
-static DATA32*
-flip(DATA32* in, int w, int h)
+static DATA32 *
+flip(DATA32 * in, int w, int h)
{
- int adv, adv2, i;
- DATA32* out;
-
+ int adv, adv2, i;
+ DATA32 *out;
+
out = malloc(w * h * sizeof(DATA32));
- if(!out)
+ if (!out)
return NULL;
-
- adv = 0; adv2 = w * h;
-
- for(i = 0; i < h; i++) {
- adv2 -= w;
- memmove(out + adv, in + adv2, w * sizeof(DATA32));
- adv += w;
- }
-
+
+ adv = 0;
+ adv2 = w * h;
+
+ for (i = 0; i < h; i++)
+ {
+ adv2 -= w;
+ memmove(out + adv, in + adv2, w * sizeof(DATA32));
+ adv += w;
+ }
+
free(in);
return out;
}
-
diff --git a/loaders/loader_tiff.c b/loaders/loader_tiff.c
index a5b80a2..f303023 100644
--- a/loaders/loader_tiff.c
+++ b/loaders/loader_tiff.c
@@ -19,174 +19,175 @@
/* This is a wrapper data structure for TIFFRGBAImage, so that data can be */
/* passed into the callbacks. More elegent, I think, than a bunch of globals */
-
-struct TIFFRGBAImage_Extra
-{
- TIFFRGBAImage rgba;
- tileContigRoutine put_contig;
- tileSeparateRoutine put_separate;
- ImlibImage *image;
- ImlibProgressFunction progress;
- char pper;
- char progress_granularity;
- uint32 num_pixels;
- uint32 py;
+struct TIFFRGBAImage_Extra {
+ TIFFRGBAImage rgba;
+ tileContigRoutine put_contig;
+ tileSeparateRoutine put_separate;
+ ImlibImage *image;
+ ImlibProgressFunction progress;
+ char pper;
+ char progress_granularity;
+ uint32 num_pixels;
+ uint32 py;
};
typedef struct TIFFRGBAImage_Extra TIFFRGBAImage_Extra;
-static void put_contig_and_raster(TIFFRGBAImage*, uint32*,
- uint32, uint32, uint32, uint32, int32, int32, unsigned char*);
-static void put_separate_and_raster(TIFFRGBAImage*, uint32*,
- uint32, uint32, uint32, uint32, int32, int32,
- unsigned char*, unsigned char*, unsigned char*, unsigned char*);
-static void raster(TIFFRGBAImage_Extra* img, uint32* raster,
- uint32 x, uint32 y, uint32 w, uint32 h);
-static void error_handler(const char *module, const char *fmt, va_list ap);
-char load (ImlibImage *im, ImlibProgressFunction progress,
- char progress_granularity, char immediate_load);
-char save (ImlibImage *im, ImlibProgressFunction progress,
- char progress_granularity);
-void formats (ImlibLoader *l);
+static void put_contig_and_raster(TIFFRGBAImage *, uint32 *,
+ uint32, uint32, uint32, uint32, int32,
+ int32, unsigned char *);
+static void put_separate_and_raster(TIFFRGBAImage *, uint32 *, uint32,
+ uint32, uint32, uint32, int32,
+ int32, unsigned char *,
+ unsigned char *, unsigned char *,
+ unsigned char *);
+static void raster(TIFFRGBAImage_Extra * img, uint32 * raster, uint32 x,
+ uint32 y, uint32 w, uint32 h);
+static void error_handler(const char *module, const char *fmt,
+ va_list ap);
+char load(ImlibImage * im, ImlibProgressFunction progress,
+ char progress_granularity, char immediate_load);
+char save(ImlibImage * im, ImlibProgressFunction progress,
+ char progress_granularity);
+void formats(ImlibLoader * l);
static void
-put_contig_and_raster(TIFFRGBAImage* img, uint32* rast,
- uint32 x, uint32 y, uint32 w, uint32 h,
- int32 fromskew, int32 toskew,
- unsigned char* cp)
+put_contig_and_raster(TIFFRGBAImage * img, uint32 * rast,
+ uint32 x, uint32 y, uint32 w, uint32 h,
+ int32 fromskew, int32 toskew, unsigned char *cp)
{
- (*(((TIFFRGBAImage_Extra *)img)->put_contig))(img, rast, x, y, w, h,
- fromskew, toskew, cp);
- raster((TIFFRGBAImage_Extra *) img, rast, x, y, w, h);
+ (*(((TIFFRGBAImage_Extra *) img)->put_contig)) (img, rast, x, y, w, h,
+ fromskew, toskew, cp);
+ raster((TIFFRGBAImage_Extra *) img, rast, x, y, w, h);
}
static void
-put_separate_and_raster(TIFFRGBAImage* img, uint32* rast,
- uint32 x, uint32 y, uint32 w, uint32 h,
- int32 fromskew, int32 toskew,
- unsigned char* r, unsigned char* g, unsigned char* b, unsigned char* a)
+put_separate_and_raster(TIFFRGBAImage * img, uint32 * rast,
+ uint32 x, uint32 y, uint32 w, uint32 h,
+ int32 fromskew, int32 toskew,
+ unsigned char *r, unsigned char *g, unsigned char *b,
+ unsigned char *a)
{
- (*(((TIFFRGBAImage_Extra *)img)->put_separate))
- (img, rast, x, y, w, h, fromskew, toskew, r, g, b, a);
- raster((TIFFRGBAImage_Extra *) img, rast, x, y, w, h);
+ (*(((TIFFRGBAImage_Extra *) img)->put_separate))
+ (img, rast, x, y, w, h, fromskew, toskew, r, g, b, a);
+ raster((TIFFRGBAImage_Extra *) img, rast, x, y, w, h);
}
/* needs orientation code */
static void
-raster(TIFFRGBAImage_Extra *img, uint32* rast,
+raster(TIFFRGBAImage_Extra * img, uint32 * rast,
uint32 x, uint32 y, uint32 w, uint32 h)
{
- uint32 image_width, image_height;
- uint32 *pixel, pixel_value;
- int i, j, dy, rast_offset;
- DATA32 *buffer_pixel, *buffer = img->image->data;
-
+ uint32 image_width, image_height;
+ uint32 *pixel, pixel_value;
+ int i, j, dy, rast_offset;
+ DATA32 *buffer_pixel, *buffer = img->image->data;
+
image_width = img->image->w;
image_height = img->image->h;
-
- dy = h > y ? -1 : y - h;
-
+
+ dy = h > y ? -1 : y - h;
+
/* rast seems to point to the beginning of the last strip processed */
/* so you need use negative offsets. Bizzare. Someone please check this */
/* I don't understand why, but that seems to be what's going on. */
/* libtiff needs better docs! */
-
+
for (i = y, rast_offset = 0; i > dy; i--, rast_offset--)
{
- pixel = rast + (rast_offset * image_width);
- buffer_pixel = buffer + ((((image_height - 1) - i) * image_width) + x);
-
- for (j = 0; j < w; j++)
- {
- pixel_value = (*(pixel++));
- (*(buffer_pixel++)) =
- (TIFFGetA(pixel_value) << 24) |
- (TIFFGetR(pixel_value) << 16) | (TIFFGetG(pixel_value) << 8) |
- TIFFGetB(pixel_value);
- }
+ pixel = rast + (rast_offset * image_width);
+ buffer_pixel = buffer + ((((image_height - 1) - i) * image_width) + x);
+
+ for (j = 0; j < w; j++)
+ {
+ pixel_value = (*(pixel++));
+ (*(buffer_pixel++)) =
+ (TIFFGetA(pixel_value) << 24) |
+ (TIFFGetR(pixel_value) << 16) | (TIFFGetG(pixel_value) << 8) |
+ TIFFGetB(pixel_value);
+ }
}
-
+
if (img->progress)
{
- char per;
- uint32 real_y = (image_height - 1) - y;
-
- if (w >= image_width)
- {
- per = (char)(((real_y + h - 1) * 100)/image_height);
-
- if (((per - img->pper) >= img->progress_granularity) ||
- (real_y + h) >= image_height)
- {
- (*img->progress)(img->image, per, 0, img->py, w,
- (real_y + h) - img->py);
- img->py = real_y + h;
- img->pper = per;
- }
- }
- else
- {
- /* for tile based images, we just progress each tile because */
- /* of laziness. Couldn't think of a good way to do this */
- per = (char)((w * h * 100) / img->num_pixels);
- img->pper += per;
- (*img->progress)(img->image, img->pper, x,
- (image_height - 1) - y, w, h);
- }
+ char per;
+ uint32 real_y = (image_height - 1) - y;
+
+ if (w >= image_width)
+ {
+ per = (char)(((real_y + h - 1) * 100) / image_height);
+
+ if (((per - img->pper) >= img->progress_granularity) ||
+ (real_y + h) >= image_height)
+ {
+ (*img->progress) (img->image, per, 0, img->py, w,
+ (real_y + h) - img->py);
+ img->py = real_y + h;
+ img->pper = per;
+ }
+ }
+ else
+ {
+ /* for tile based images, we just progress each tile because */
+ /* of laziness. Couldn't think of a good way to do this */
+ per = (char)((w * h * 100) / img->num_pixels);
+ img->pper += per;
+ (*img->progress) (img->image, img->pper, x,
+ (image_height - 1) - y, w, h);
+ }
}
}
-
-char
-load (ImlibImage *im, ImlibProgressFunction progress,
- char progress_granularity, char immediate_load)
+char
+load(ImlibImage * im, ImlibProgressFunction progress,
+ char progress_granularity, char immediate_load)
{
- TIFF *tif = NULL;
- FILE *file;
- int fd;
- uint16 magic_number;
- TIFFRGBAImage_Extra rgba_image;
- uint32 *rast = NULL;
- uint32 width, height, num_pixels;
-
+ TIFF *tif = NULL;
+ FILE *file;
+ int fd;
+ uint16 magic_number;
+ TIFFRGBAImage_Extra rgba_image;
+ uint32 *rast = NULL;
+ uint32 width, height, num_pixels;
+
if (im->data)
return 0;
-
+
file = fopen(im->real_file, "rb");
-
+
if (!file)
return 0;
-
+
fread(&magic_number, sizeof(uint16), 1, file);
/* Apparently rewind(f) isn't sufficient */
fseek(file, (long)0, SEEK_SET);
-
+
if ((magic_number != TIFF_BIGENDIAN) /* Checks if actually tiff file */
&& (magic_number != TIFF_LITTLEENDIAN))
{
- fclose(file);
- return 0;
+ fclose(file);
+ return 0;
}
-
+
fd = fileno(file);
fd = dup(fd);
lseek(fd, (long)0, SEEK_SET);
fclose(file);
-
+
tif = TIFFFdOpen(fd, im->real_file, "r");
-
+
if (!tif)
return 0;
-
- if ((!TIFFRGBAImageOK(tif, "Cannot be processed by libtiff"))
- || (!TIFFRGBAImageBegin((TIFFRGBAImage *) &rgba_image, tif, 0,
- "Error reading tiff")))
+
+ if ((!TIFFRGBAImageOK(tif, "Cannot be processed by libtiff"))
+ || (!TIFFRGBAImageBegin((TIFFRGBAImage *) & rgba_image, tif, 0,
+ "Error reading tiff")))
{
- TIFFClose(tif);
- return 0;
+ TIFFClose(tif);
+ return 0;
}
-
+
rgba_image.image = im;
im->w = width = rgba_image.rgba.width;
im->h = height = rgba_image.rgba.height;
@@ -197,77 +198,77 @@ load (ImlibImage *im, ImlibProgressFunction progress,
UNSET_FLAG(im->flags, F_HAS_ALPHA);
if (!im->format)
im->format = strdup("tiff");
-
+
if ((im->loader) || (immediate_load) || (progress))
- {
- rgba_image.progress = progress;
- rgba_image.pper = rgba_image.py = 0;
- rgba_image.progress_granularity = progress_granularity;
- rast = (uint32 *) _TIFFmalloc(sizeof(uint32) * num_pixels);
- im->data = (DATA32 *) malloc(sizeof(DATA32) * num_pixels);
-
- if ((!rast) || (!im->data)) /* Error checking */
- {
- fprintf(stderr, "imlib2-tiffloader: Out of memory\n");
-
- if (!rast)
- _TIFFfree(rast);
- if (!im->data)
- {
- free(im->data);
- im->data = NULL;
- }
-
- TIFFRGBAImageEnd((TIFFRGBAImage *) &rgba_image);
- TIFFClose(tif);
-
- return 0;
- }
-
- if (rgba_image.rgba.put.any == NULL)
- {
- fprintf(stderr, "imlib2-tiffloader: No put function");
-
- _TIFFfree(rast);
- free(im->data);
- im->data = NULL;
- TIFFRGBAImageEnd((TIFFRGBAImage *) &rgba_image);
- TIFFClose(tif);
-
- return 0;
- }
- else
- {
- if (rgba_image.rgba.isContig)
- {
- rgba_image.put_contig = rgba_image.rgba.put.contig;
- rgba_image.rgba.put.contig = put_contig_and_raster;
- }
- else
- {
- rgba_image.put_separate = rgba_image.rgba.put.separate;
- rgba_image.rgba.put.separate = put_separate_and_raster;
- }
- }
-
- if (!TIFFRGBAImageGet((TIFFRGBAImage *) &rgba_image,
- rast, width, height))
- {
- _TIFFfree(rast);
- free(im->data);
- im->data = NULL;
- TIFFRGBAImageEnd((TIFFRGBAImage *) &rgba_image);
- TIFFClose(tif);
-
- return 0;
- }
-
- _TIFFfree(rast);
+ {
+ rgba_image.progress = progress;
+ rgba_image.pper = rgba_image.py = 0;
+ rgba_image.progress_granularity = progress_granularity;
+ rast = (uint32 *) _TIFFmalloc(sizeof(uint32) * num_pixels);
+ im->data = (DATA32 *) malloc(sizeof(DATA32) * num_pixels);
+
+ if ((!rast) || (!im->data)) /* Error checking */
+ {
+ fprintf(stderr, "imlib2-tiffloader: Out of memory\n");
+
+ if (!rast)
+ _TIFFfree(rast);
+ if (!im->data)
+ {
+ free(im->data);
+ im->data = NULL;
+ }
+
+ TIFFRGBAImageEnd((TIFFRGBAImage *) & rgba_image);
+ TIFFClose(tif);
+
+ return 0;
+ }
+
+ if (rgba_image.rgba.put.any == NULL)
+ {
+ fprintf(stderr, "imlib2-tiffloader: No put function");
+
+ _TIFFfree(rast);
+ free(im->data);
+ im->data = NULL;
+ TIFFRGBAImageEnd((TIFFRGBAImage *) & rgba_image);
+ TIFFClose(tif);
+
+ return 0;
+ }
+ else
+ {
+ if (rgba_image.rgba.isContig)
+ {
+ rgba_image.put_contig = rgba_image.rgba.put.contig;
+ rgba_image.rgba.put.contig = put_contig_and_raster;
+ }
+ else
+ {
+ rgba_image.put_separate = rgba_image.rgba.put.separate;
+ rgba_image.rgba.put.separate = put_separate_and_raster;
+ }
+ }
+
+ if (!TIFFRGBAImageGet((TIFFRGBAImage *) & rgba_image,
+ rast, width, height))
+ {
+ _TIFFfree(rast);
+ free(im->data);
+ im->data = NULL;
+ TIFFRGBAImageEnd((TIFFRGBAImage *) & rgba_image);
+ TIFFClose(tif);
+
+ return 0;
+ }
+
+ _TIFFfree(rast);
}
-
- TIFFRGBAImageEnd((TIFFRGBAImage *) &rgba_image);
+
+ TIFFRGBAImageEnd((TIFFRGBAImage *) & rgba_image);
TIFFClose(tif);
-
+
return 1;
}
@@ -275,34 +276,34 @@ load (ImlibImage *im, ImlibProgressFunction progress,
/* this is a problem in libtiff */
char
-save (ImlibImage *im, ImlibProgressFunction progress,
- char progress_granularity)
+save(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity)
{
- TIFF *tif = NULL;
- uint8 *buf = NULL;
- DATA32 pixel, *data = im->data;
- double alpha_factor;
- uint32 x, y;
- uint8 r, g, b, a;
- int has_alpha = IMAGE_HAS_ALPHA(im);
- int i = 0, pl = 0;
- char pper = 0;
+ TIFF *tif = NULL;
+ uint8 *buf = NULL;
+ DATA32 pixel, *data = im->data;
+ double alpha_factor;
+ uint32 x, y;
+ uint8 r, g, b, a;
+ int has_alpha = IMAGE_HAS_ALPHA(im);
+ int i = 0, pl = 0;
+ char pper = 0;
+
/* By default uses patent-free use COMPRESSION_DEFLATE,
- another lossless compression technique */
- ImlibImageTag *tag;
- int compression_type = COMPRESSION_DEFLATE;
+ * another lossless compression technique */
+ ImlibImageTag *tag;
+ int compression_type = COMPRESSION_DEFLATE;
if (!im->data)
return 0;
-
+
tif = TIFFOpen(im->real_file, "w");
-
+
if (!tif)
return 0;
-
+
/* None of the TIFFSetFields are checked for errors, but since they */
/* shouldn't fail, this shouldn't be a problem */
-
+
TIFFSetField(tif, TIFFTAG_IMAGELENGTH, im->h);
TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, im->w);
TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
@@ -316,112 +317,138 @@ save (ImlibImage *im, ImlibProgressFunction progress,
/* compression */
tag = __imlib_GetTag(im, "compression_type");
- if (tag) {
- compression_type = tag->val;
- switch (compression_type) {
- case COMPRESSION_NONE: break;
- case COMPRESSION_CCITTRLE: break;
- case COMPRESSION_CCITTFAX3: break;
- case COMPRESSION_CCITTFAX4: break;
- case COMPRESSION_LZW: break;
- case COMPRESSION_OJPEG: break;
- case COMPRESSION_JPEG: break;
- case COMPRESSION_NEXT: break;
- case COMPRESSION_CCITTRLEW: break;
- case COMPRESSION_PACKBITS: break;
- case COMPRESSION_THUNDERSCAN: break;
- case COMPRESSION_IT8CTPAD: break;
- case COMPRESSION_IT8LW: break;
- case COMPRESSION_IT8MP: break;
- case COMPRESSION_IT8BL: break;
- case COMPRESSION_PIXARFILM: break;
- case COMPRESSION_PIXARLOG: break;
- case COMPRESSION_DEFLATE: break;
- case COMPRESSION_ADOBE_DEFLATE: break;
- case COMPRESSION_DCS: break;
- case COMPRESSION_JBIG: break;
- case COMPRESSION_SGILOG: break;
- case COMPRESSION_SGILOG24: break;
- default: compression_type = COMPRESSION_DEFLATE;
- }
+ if (tag)
+ {
+ compression_type = tag->val;
+ switch (compression_type)
+ {
+ case COMPRESSION_NONE:
+ break;
+ case COMPRESSION_CCITTRLE:
+ break;
+ case COMPRESSION_CCITTFAX3:
+ break;
+ case COMPRESSION_CCITTFAX4:
+ break;
+ case COMPRESSION_LZW:
+ break;
+ case COMPRESSION_OJPEG:
+ break;
+ case COMPRESSION_JPEG:
+ break;
+ case COMPRESSION_NEXT:
+ break;
+ case COMPRESSION_CCITTRLEW:
+ break;
+ case COMPRESSION_PACKBITS:
+ break;
+ case COMPRESSION_THUNDERSCAN:
+ break;
+ case COMPRESSION_IT8CTPAD:
+ break;
+ case COMPRESSION_IT8LW:
+ break;
+ case COMPRESSION_IT8MP:
+ break;
+ case COMPRESSION_IT8BL:
+ break;
+ case COMPRESSION_PIXARFILM:
+ break;
+ case COMPRESSION_PIXARLOG:
+ break;
+ case COMPRESSION_DEFLATE:
+ break;
+ case COMPRESSION_ADOBE_DEFLATE:
+ break;
+ case COMPRESSION_DCS:
+ break;
+ case COMPRESSION_JBIG:
+ break;
+ case COMPRESSION_SGILOG:
+ break;
+ case COMPRESSION_SGILOG24:
+ break;
+ default:
+ compression_type = COMPRESSION_DEFLATE;
+ }
- }
+ }
TIFFSetField(tif, TIFFTAG_COMPRESSION, compression_type);
if (has_alpha)
{
- TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 4);
- TIFFSetField(tif, TIFFTAG_EXTRASAMPLES, EXTRASAMPLE_ASSOCALPHA);
+ TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 4);
+ TIFFSetField(tif, TIFFTAG_EXTRASAMPLES, EXTRASAMPLE_ASSOCALPHA);
}
else
{
- TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 3);
+ TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 3);
}
TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8);
TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, TIFFDefaultStripSize(tif, 0));
-
+
buf = (uint8 *) _TIFFmalloc(TIFFScanlineSize(tif));
-
+
if (!buf)
{
- TIFFClose(tif);
- return 0;
+ TIFFClose(tif);
+ return 0;
}
-
+
for (y = 0; y < im->h; y++)
{
- i = 0;
- for (x = 0; x < im->w; x++)
- {
- pixel = data[(y * im->w) + x];
-
- r = (pixel >> 16) & 0xff;
- g = (pixel >> 8) & 0xff;
- b = pixel & 0xff;
- if (has_alpha)
- {
- /* TIFF makes you pre-mutiply the rgb components by alpha */
- a = (pixel >> 24) & 0xff;
- alpha_factor = ((double) a / 255.0);
- r *= alpha_factor;
- g *= alpha_factor;
- b *= alpha_factor;
- }
-
- /* This might be endian dependent */
- buf[i++] = r;
- buf[i++] = g;
- buf[i++] = b;
- if (has_alpha)
- buf[i++] = a;
- }
-
- if (!TIFFWriteScanline(tif, buf, y, 0))
- {
- _TIFFfree(buf);
- TIFFClose(tif);
- return 0;
- }
-
- if (progress)
- {
- char per;
- int l;
-
- per = (char)((100 * y) / im->h);
- if ((per - pper) >= progress_granularity)
- {
- l = y - pl;
- (*progress)(im, per, 0, (y - l), im->w, l);
- pper = per;
- pl = y;
- }
- }
+ i = 0;
+ for (x = 0; x < im->w; x++)
+ {
+ pixel = data[(y * im->w) + x];
+
+ r = (pixel >> 16) & 0xff;
+ g = (pixel >> 8) & 0xff;
+ b = pixel & 0xff;
+ if (has_alpha)
+ {
+ /* TIFF makes you pre-mutiply the rgb components by alpha */
+ a = (pixel >> 24) & 0xff;
+ alpha_factor = ((double)a / 255.0);
+ r *= alpha_factor;
+ g *= alpha_factor;
+ b *= alpha_factor;
+ }
+
+ /* This might be endian dependent */
+ buf[i++] = r;
+ buf[i++] = g;
+ buf[i++] = b;
+ if (has_alpha)
+ buf[i++] = a;
+ }
+
+ if (!TIFFWriteScanline(tif, buf, y, 0))
+ {
+ _TIFFfree(buf);
+ TIFFClose(tif);
+ return 0;
+ }
+
+ if (progress)
+ {
+ char per;
+ int l;
+
+ per = (char)((100 * y) / im->h);
+ if ((per - pper) >= progress_granularity)
+ {
+ l = y - pl;
+ (*progress) (im, per, 0, (y - l), im->w, l);
+ pper = per;
+ pl = y;
+ }
+ }
}
-
+
_TIFFfree(buf);
TIFFClose(tif);
-
+
return 1;
}
@@ -432,21 +459,20 @@ save (ImlibImage *im, ImlibProgressFunction progress,
/* your laoder CAN load more than one format if it likes - like: */
/* loader->formats = { "gif", "png", "jpeg", "jpg"} */
/* if it can load those formats. */
-void
-formats (ImlibLoader *l)
-{
+void
+formats(ImlibLoader * l)
+{
/* this is the only bit you have to change... */
- char *list_formats[] =
- { "tiff", "tif" };
-
+ char *list_formats[] = { "tiff", "tif" };
+
/* don't bother changing any of this - it just reads this in and sets */
/* the struct values and makes copies */
- {
- int i;
-
- l->num_formats = (sizeof(list_formats) / sizeof (char *));
- l->formats = malloc(sizeof(char *) * l->num_formats);
- for (i = 0; i < l->num_formats; i++)
- l->formats[i] = strdup(list_formats[i]);
- }
+ {
+ int i;
+
+ l->num_formats = (sizeof(list_formats) / sizeof(char *));
+ l->formats = malloc(sizeof(char *) * l->num_formats);
+ for (i = 0; i < l->num_formats; i++)
+ l->formats[i] = strdup(list_formats[i]);
+ }
}
diff --git a/loaders/loader_xpm.c b/loaders/loader_xpm.c
index 55433d8..d936f1b 100644
--- a/loaders/loader_xpm.c
+++ b/loaders/loader_xpm.c
@@ -13,79 +13,84 @@
#include <X11/Xutil.h>
#include "image.h"
-char load(ImlibImage *im, ImlibProgressFunction progress,char progress_granularity, char immediate_load);
-char save(ImlibImage *im, ImlibProgressFunction progress, char progress_granularity);
-void formats(ImlibLoader *l);
+char load(ImlibImage * im, ImlibProgressFunction progress,
+ char progress_granularity, char immediate_load);
+char save(ImlibImage * im, ImlibProgressFunction progress,
+ char progress_granularity);
+void formats(ImlibLoader * l);
-static FILE *rgb_txt = NULL;
+static FILE *rgb_txt = NULL;
static void
xpm_parse_color(char *color, int *r, int *g, int *b)
{
- char buf[4096];
-
+ char buf[4096];
+
/* is a #ff00ff like color */
if (color[0] == '#')
{
- int len;
- char val[32];
-
- len = strlen(color) - 1;
- if (len < 96)
- {
- int i;
-
- len /= 3;
- for (i = 0; i < len; i++) val[i] = color[1 + i + (0 * len)];
- val[i] = 0;
- sscanf(val, "%x", r);
- for (i = 0; i < len; i++) val[i] = color[1 + i + (1 * len)];
- val[i] = 0;
- sscanf(val, "%x", g);
- for (i = 0; i < len; i++) val[i] = color[1 + i + (2 * len)];
- val[i] = 0;
- sscanf(val, "%x", b);
- if (len == 1)
- {
- *r = (*r << 4) | *r;
- *g = (*g << 4) | *g;
- *b = (*b << 4) | *b;
- }
- else if (len > 2)
- {
- *r >>= (len - 2) * 4;
- *g >>= (len - 2) * 4;
- *b >>= (len - 2) * 4;
- }
- }
- return;
+ int len;
+ char val[32];
+
+ len = strlen(color) - 1;
+ if (len < 96)
+ {
+ int i;
+
+ len /= 3;
+ for (i = 0; i < len; i++)
+ val[i] = color[1 + i + (0 * len)];
+ val[i] = 0;
+ sscanf(val, "%x", r);
+ for (i = 0; i < len; i++)
+ val[i] = color[1 + i + (1 * len)];
+ val[i] = 0;
+ sscanf(val, "%x", g);
+ for (i = 0; i < len; i++)
+ val[i] = color[1 + i + (2 * len)];
+ val[i] = 0;
+ sscanf(val, "%x", b);
+ if (len == 1)
+ {
+ *r = (*r << 4) | *r;
+ *g = (*g << 4) | *g;
+ *b = (*b << 4) | *b;
+ }
+ else if (len > 2)
+ {
+ *r >>= (len - 2) * 4;
+ *g >>= (len - 2) * 4;
+ *b >>= (len - 2) * 4;
+ }
+ }
+ return;
}
/* look in rgb txt database */
if (!rgb_txt)
-#ifndef __EMX__
+#ifndef __EMX__
rgb_txt = fopen("/usr/X11R6/lib/X11/rgb.txt", "r");
-#else
+#else
rgb_txt = fopen(__XOS2RedirRoot("/XFree86/lib/X11/rgb.txt"), "rt");
-#endif
+#endif
if (!rgb_txt)
return;
fseek(rgb_txt, 0, SEEK_SET);
while (fgets(buf, 4000, rgb_txt))
{
- if (buf[0] != '!')
- {
- int rr, gg, bb;
- char name[4096];
-
- sscanf(buf, "%i %i %i %[^\n]", &rr, &gg, &bb, name);
- if (!strcasecmp(name, color))
- {
- *r = rr;
- *g = gg;
- *b = bb;
- return;
- }
- }
+ if (buf[0] != '!')
+ {
+ int rr, gg, bb;
+ char name[4096];
+
+ sscanf(buf, "%i %i %i %[^\n]", &rr, &gg, &bb, name);
+ if (!strcasecmp(name, color))
+ {
+ *r = rr;
+ *g = gg;
+ *b = bb;
+ return;
+ }
+ }
}
}
@@ -97,55 +102,55 @@ xpm_parse_done(void)
rgb_txt = NULL;
}
-char
-load(ImlibImage *im, ImlibProgressFunction progress, char progress_granularity, char immediate_load)
+char
+load(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity,
+ char immediate_load)
{
DATA32 *ptr, *end;
FILE *f;
-
- int pc, c, i, j, k, w, h, ncolors, cpp, comment, transp, quote,
- context, len, done, r, g, b;
- char *line, s[256], tok[128], col[256];
+
+ int pc, c, i, j, k, w, h, ncolors, cpp, comment, transp,
+ quote, context, len, done, r, g, b;
+ char *line, s[256], tok[128], col[256];
int lsz = 256;
- struct _cmap
- {
- unsigned char str[6];
- unsigned char transp;
- short r, g, b;
- } *cmap;
-
+ struct _cmap {
+ unsigned char str[6];
+ unsigned char transp;
+ short r, g, b;
+ } *cmap;
+
short lookup[128 - 32][128 - 32];
float per = 0.0, per_inc = 0.0;
int last_per = 0, last_y = 0;
int count, pixels;
-
+
done = 0;
transp = -1;
-
+
/* if immediate_load is 1, then dont delay image laoding as below, or */
/* already data in this image - dont load it again */
-
+
if (im->data)
{
- xpm_parse_done();
- return 0;
+ xpm_parse_done();
+ return 0;
}
f = fopen(im->real_file, "rb");
if (!f)
{
- xpm_parse_done();
- return 0;
+ xpm_parse_done();
+ return 0;
}
fread(s, 1, 9, f);
rewind(f);
s[9] = 0;
if (strcmp("/* XPM */", s))
{
- fclose(f);
- xpm_parse_done();
- return 0;
+ fclose(f);
+ xpm_parse_done();
+ return 0;
}
-
+
i = 0;
j = 0;
cmap = NULL;
@@ -163,400 +168,501 @@ load(ImlibImage *im, ImlibProgressFunction progress, char progress_granularity,
memset(lookup, 0, sizeof(lookup));
while (!done)
{
- pc = c;
- c = fgetc(f);
- if (c == EOF)
- break;
- if (!quote)
- {
- if ((pc == '/') && (c == '*'))
- comment = 1;
- else if ((pc == '*') && (c == '/') && (comment))
- comment = 0;
- }
- if (!comment)
- {
- if ((!quote) && (c == '"'))
- {
- quote = 1;
- i = 0;
- }
- else if ((quote) && (c == '"'))
- {
- line[i] = 0;
- quote = 0;
- if (context == 0)
- {
- /* Header */
- sscanf(line, "%i %i %i %i", &w, &h, &ncolors, &cpp);
- if (ncolors > 32766)
- {
- fprintf(stderr, "IMLIB ERROR: XPM files with colors > 32766 not supported\n");
- free(line);
- fclose(f);
- xpm_parse_done();
- return 0;
- }
- if (cpp > 5)
- {
- fprintf(stderr, "IMLIB ERROR: XPM files with characters per pixel > 5 not supported\n");
- free(line);
- fclose(f);
- xpm_parse_done();
- return 0;
- }
- if (w > 32767)
- {
- fprintf(stderr, "IMLIB ERROR: Image width > 32767 pixels for file\n");
- free(line);
- fclose(f);
- xpm_parse_done();
- return 0;
- }
- if (h > 32767)
- {
- fprintf(stderr, "IMLIB ERROR: Image height > 32767 pixels for file\n");
- free(line);
- fclose(f);
- xpm_parse_done();
- return 0;
- }
- im->w = w;
- im->h = h;
- if (!im->format)
- im->format = strdup("xpm");
-
- cmap = malloc(sizeof(struct _cmap) * ncolors);
-
- if (!cmap)
- {
- free(line);
- fclose(f);
- xpm_parse_done();
- return 0;
- }
-
- per_inc = 100.0 / (((float) w) * h);
-
- j = 0;
- context++;
- }
- else if (context == 1)
- {
- /* Color Table */
- if (j < ncolors)
- {
- int slen;
- int hascolor, iscolor;
-
- iscolor = 0;
- hascolor = 0;
- tok[0] = 0;
- col[0] = 0;
- s[0] = 0;
- len = strlen(line);
- strncpy(cmap[j].str, line, cpp);
- cmap[j].str[cpp] = 0;
- cmap[j].r = -1;
- cmap[j].transp = 0;
- for (k = cpp; k < len; k++)
- {
- if (line[k] != ' ')
- {
- s[0] = 0;
- sscanf(&line[k], "%65535s", s);
- slen = strlen(s);
- k += slen;
- if (!strcmp(s, "c"))
- iscolor = 1;
- if ((!strcmp(s, "m")) || (!strcmp(s, "s")) ||
- (!strcmp(s, "g4")) || (!strcmp(s, "g")) ||
- (!strcmp(s, "c")) || (k >= len))
- {
- if (k >= len)
- {
- if (col[0])
- strcat(col, " ");
- if (strlen(col) + strlen(s) < sizeof(col))
- strcat(col, s);
- }
- if (col[0])
- {
- if (!strcasecmp(col, "none"))
- {
- transp = 1;
- cmap[j].transp = 1;
- }
- else
- {
- if ((((cmap[j].r < 0) ||
- (!strcmp(tok, "c"))) &&
- (!hascolor)))
- {
- r = 0; g = 0; b = 0;
- xpm_parse_color(col, &r, &g, &b);
- cmap[j].r = r;
- cmap[j].g = g;
- cmap[j].b = b;
- if (iscolor)
- hascolor = 1;
- }
- }
- }
- strcpy(tok, s);
- col[0] = 0;
- }
- else
- {
- if (col[0])
- strcat(col, " ");
- strcat(col, s);
- }
- }
- }
- }
- j++;
- if (j >= ncolors)
- {
- if (cpp == 1)
- for (i = 0; i < ncolors; i++)
- lookup[(int)cmap[i].str[0] - 32][0] = i;
- if (cpp == 2)
- for (i = 0; i < ncolors; i++)
- lookup[(int)cmap[i].str[0] - 32][(int)cmap[i].str[1] - 32] = i;
- context++;
- }
-
- if (transp >= 0) {
- SET_FLAG(im->flags, F_HAS_ALPHA);
- } else {
- UNSET_FLAG(im->flags, F_HAS_ALPHA);
- }
-
- if (im->loader || immediate_load || progress)
- {
- im->data = (DATA32 *) malloc(sizeof(DATA32) * im->w * im->h);
- if (!im->data)
- {
- free(cmap);
- free(line);
- fclose(f);
- xpm_parse_done();
- return 0;
- }
- ptr = im->data;
- end = ptr + (sizeof(DATA32) * w * h);
- pixels = w * h;
- }
- else
- {
- free(cmap);
- free(line);
- fclose(f);
- xpm_parse_done();
- return 1;
- }
- }
- else
- {
- /* Image Data */
- i = 0;
- if (cpp == 0)
- {
- /* Chars per pixel = 0? well u never know */
- }
- if (cpp == 1)
- {
- if (transp)
- {
- for (i = 0; ((i < 65536) && (ptr < end) && (line[i])); i++)
- {
- col[0] = line[i];
- if (cmap[lookup[(int)col[0] - 32][0]].transp)
- {
- r = (unsigned char)cmap[lookup[(int)col[0] - 32][0]].r;
- g = (unsigned char)cmap[lookup[(int)col[0] - 32][0]].g;
- b = (unsigned char)cmap[lookup[(int)col[0] - 32][0]].b;
- *ptr++ = 0x00ffffff & ((r << 16) | (g << 8) | b);
- count++;
- }
- else
- {
- r = (unsigned char)cmap[lookup[(int)col[0] - 32][0]].r;
- g = (unsigned char)cmap[lookup[(int)col[0] - 32][0]].g;
- b = (unsigned char)cmap[lookup[(int)col[0] - 32][0]].b;
- *ptr++ = (0xff << 24) | (r << 16) | (g << 8) | b;
- count++;
- }
- }
- }
- else
- {
- for (i = 0; ((i < 65536) && (ptr < end) && (line[i])); i++)
- {
- col[0] = line[i];
- r = (unsigned char)cmap[lookup[(int)col[0] - 32][0]].r;
- g = (unsigned char)cmap[lookup[(int)col[0] - 32][0]].g;
- b = (unsigned char)cmap[lookup[(int)col[0] - 32][0]].b;
- *ptr++ = (0xff << 24) | (r << 16) | (g << 8) | b;
- count++;
- }
- }
- }
- else if (cpp == 2)
- {
- if (transp)
- {
- for (i = 0; ((i < 65536) && (ptr < end) && (line[i])); i++)
- {
- col[0] = line[i++];
- col[1] = line[i];
- if (cmap[lookup[(int)col[0] - 32][(int)col[1] - 32]].transp)
- {
- r = (unsigned char)cmap[lookup[(int)col[0] - 32][(int)col[1] - 32]].r;
- g = (unsigned char)cmap[lookup[(int)col[0] - 32][(int)col[1] - 32]].g;
- b = (unsigned char)cmap[lookup[(int)col[0] - 32][(int)col[1] - 32]].b;
- *ptr++ = 0x00ffffff & ((r << 16) | (g << 8) | b);
- count++;
- }
- else
- {
- r = (unsigned char)cmap[lookup[(int)col[0] - 32][(int)col[1] - 32]].r;
- g = (unsigned char)cmap[lookup[(int)col[0] - 32][(int)col[1] - 32]].g;
- b = (unsigned char)cmap[lookup[(int)col[0] - 32][(int)col[1] - 32]].b;
- *ptr++ = (0xff << 24) | (r << 16) | (g << 8) | b;
- count++;
- }
- }
- }
- else
- {
- for (i = 0; ((i < 65536) && (ptr < end) && (line[i])); i++)
- {
- col[0] = line[i++];
- col[1] = line[i];
- r = (unsigned char)cmap[lookup[(int)col[0] - 32][(int)col[1] - 32]].r;
- g = (unsigned char)cmap[lookup[(int)col[0] - 32][(int)col[1] - 32]].g;
- b = (unsigned char)cmap[lookup[(int)col[0] - 32][(int)col[1] - 32]].b;
- *ptr++ = (0xff << 24) | (r << 16) | (g << 8) | b;
- count++;
- }
- }
- }
- else
- {
- if (transp)
- {
- for (i = 0; ((i < 65536) && (ptr < end) && (line[i])); i++)
- {
- for (j = 0; j < cpp; j++, i++)
- {
- col[j] = line[i];
- }
- col[j] = 0;
- i--;
- for (j = 0; j < ncolors; j++)
- {
- if (!strcmp(col, cmap[j].str))
- {
- if (cmap[j].transp)
- {
- r = (unsigned char)cmap[lookup[(int)col[0] - 32][0]].r;
- g = (unsigned char)cmap[lookup[(int)col[0] - 32][0]].g;
- b = (unsigned char)cmap[lookup[(int)col[0] - 32][0]].b;
- *ptr++ = 0x00ffffff & ((r << 16) | (g << 8) | b);
- count++;
- }
- else
- {
- r = (unsigned char)cmap[j].r;
- g = (unsigned char)cmap[j].g;
- b = (unsigned char)cmap[j].b;
- *ptr++ = (0xff << 24) | (r << 16) | (g << 8) | b;
- count++;
- }
- j = ncolors;
- }
- }
- }
- }
- else
- {
- for (i = 0; ((i < 65536) && (ptr < end) && (line[i])); i++)
- {
- for (j = 0; j < cpp; j++, i++)
- {
- col[j] = line[i];
- }
- col[j] = 0;
- i--;
- for (j = 0; j < ncolors; j++)
- {
- if (!strcmp(col, cmap[j].str))
- {
- r = (unsigned char)cmap[j].r;
- g = (unsigned char)cmap[j].g;
- b = (unsigned char)cmap[j].b;
- *ptr++ = (0xff << 24) | (r << 16) | (g << 8) | b;
- count++;
- j = ncolors;
- }
- }
- }
- }
- }
- per += per_inc;
- if (progress && (((int) per) != last_per) && (((int) per) % progress_granularity == 0))
- {
- last_per = (int) per;
- if (!(progress(im, (int) per, 0, last_y, w, i)))
- {
- fclose(f);
- free(cmap);
- free(line);
- xpm_parse_done();
- return 2;
- }
- last_y = i;
- }
- }
- }
- }
- /* Scan in line from XPM file */
- if ((!comment) && (quote) && (c != '"'))
- {
- if (c < 32)
- c = 32;
- else if (c > 127)
- c = 127;
- line[i++] = c;
- }
- if (i >= lsz)
- {
- lsz += 256;
- line = realloc(line, lsz);
- }
- if (((ptr) && ((ptr - im->data) >= (w * h * sizeof(DATA32)))) ||
- ((context > 1) && (count >= pixels)))
- done = 1;
+ pc = c;
+ c = fgetc(f);
+ if (c == EOF)
+ break;
+ if (!quote)
+ {
+ if ((pc == '/') && (c == '*'))
+ comment = 1;
+ else if ((pc == '*') && (c == '/') && (comment))
+ comment = 0;
+ }
+ if (!comment)
+ {
+ if ((!quote) && (c == '"'))
+ {
+ quote = 1;
+ i = 0;
+ }
+ else if ((quote) && (c == '"'))
+ {
+ line[i] = 0;
+ quote = 0;
+ if (context == 0)
+ {
+ /* Header */
+ sscanf(line, "%i %i %i %i", &w, &h, &ncolors, &cpp);
+ if (ncolors > 32766)
+ {
+ fprintf(stderr,
+ "IMLIB ERROR: XPM files with colors > 32766 not supported\n");
+ free(line);
+ fclose(f);
+ xpm_parse_done();
+ return 0;
+ }
+ if (cpp > 5)
+ {
+ fprintf(stderr,
+ "IMLIB ERROR: XPM files with characters per pixel > 5 not supported\n");
+ free(line);
+ fclose(f);
+ xpm_parse_done();
+ return 0;
+ }
+ if (w > 32767)
+ {
+ fprintf(stderr,
+ "IMLIB ERROR: Image width > 32767 pixels for file\n");
+ free(line);
+ fclose(f);
+ xpm_parse_done();
+ return 0;
+ }
+ if (h > 32767)
+ {
+ fprintf(stderr,
+ "IMLIB ERROR: Image height > 32767 pixels for file\n");
+ free(line);
+ fclose(f);
+ xpm_parse_done();
+ return 0;
+ }
+ im->w = w;
+ im->h = h;
+ if (!im->format)
+ im->format = strdup("xpm");
+
+ cmap = malloc(sizeof(struct _cmap) * ncolors);
+
+ if (!cmap)
+ {
+ free(line);
+ fclose(f);
+ xpm_parse_done();
+ return 0;
+ }
+
+ per_inc = 100.0 / (((float)w) * h);
+
+ j = 0;
+ context++;
+ }
+ else if (context == 1)
+ {
+ /* Color Table */
+ if (j < ncolors)
+ {
+ int slen;
+ int hascolor, iscolor;
+
+ iscolor = 0;
+ hascolor = 0;
+ tok[0] = 0;
+ col[0] = 0;
+ s[0] = 0;
+ len = strlen(line);
+ strncpy(cmap[j].str, line, cpp);
+ cmap[j].str[cpp] = 0;
+ cmap[j].r = -1;
+ cmap[j].transp = 0;
+ for (k = cpp; k < len; k++)
+ {
+ if (line[k] != ' ')
+ {
+ s[0] = 0;
+ sscanf(&line[k], "%65535s", s);
+ slen = strlen(s);
+ k += slen;
+ if (!strcmp(s, "c"))
+ iscolor = 1;
+ if ((!strcmp(s, "m")) || (!strcmp(s, "s"))
+ || (!strcmp(s, "g4"))
+ || (!strcmp(s, "g"))
+ || (!strcmp(s, "c")) || (k >= len))
+ {
+ if (k >= len)
+ {
+ if (col[0])
+ strcat(col, " ");
+ if (strlen(col) + strlen(s) <
+ sizeof(col))
+ strcat(col, s);
+ }
+ if (col[0])
+ {
+ if (!strcasecmp(col, "none"))
+ {
+ transp = 1;
+ cmap[j].transp = 1;
+ }
+ else
+ {
+ if ((((cmap[j].r < 0) ||
+ (!strcmp(tok, "c")))
+ && (!hascolor)))
+ {
+ r = 0;
+ g = 0;
+ b = 0;
+ xpm_parse_color(col,
+ &r,
+ &g,
+ &b);
+ cmap[j].r = r;
+ cmap[j].g = g;
+ cmap[j].b = b;
+ if (iscolor)
+ hascolor = 1;
+ }
+ }
+ }
+ strcpy(tok, s);
+ col[0] = 0;
+ }
+ else
+ {
+ if (col[0])
+ strcat(col, " ");
+ strcat(col, s);
+ }
+ }
+ }
+ }
+ j++;
+ if (j >= ncolors)
+ {
+ if (cpp == 1)
+ for (i = 0; i < ncolors; i++)
+ lookup[(int)cmap[i].str[0] - 32][0] = i;
+ if (cpp == 2)
+ for (i = 0; i < ncolors; i++)
+ lookup[(int)cmap[i].str[0] -
+ 32][(int)cmap[i].str[1] - 32] = i;
+ context++;
+ }
+
+ if (transp >= 0)
+ {
+ SET_FLAG(im->flags, F_HAS_ALPHA);
+ }
+ else
+ {
+ UNSET_FLAG(im->flags, F_HAS_ALPHA);
+ }
+
+ if (im->loader || immediate_load || progress)
+ {
+ im->data =
+ (DATA32 *) malloc(sizeof(DATA32) * im->w *
+ im->h);
+ if (!im->data)
+ {
+ free(cmap);
+ free(line);
+ fclose(f);
+ xpm_parse_done();
+ return 0;
+ }
+ ptr = im->data;
+ end = ptr + (sizeof(DATA32) * w * h);
+ pixels = w * h;
+ }
+ else
+ {
+ free(cmap);
+ free(line);
+ fclose(f);
+ xpm_parse_done();
+ return 1;
+ }
+ }
+ else
+ {
+ /* Image Data */
+ i = 0;
+ if (cpp == 0)
+ {
+ /* Chars per pixel = 0? well u never know */
+ }
+ if (cpp == 1)
+ {
+ if (transp)
+ {
+ for (i = 0;
+ ((i < 65536) && (ptr < end) && (line[i]));
+ i++)
+ {
+ col[0] = line[i];
+ if (cmap[lookup[(int)col[0] - 32][0]].
+ transp)
+ {
+ r = (unsigned char)
+ cmap[lookup[(int)col[0] - 32]
+ [0]].r;
+ g = (unsigned char)
+ cmap[lookup[(int)col[0] - 32]
+ [0]].g;
+ b = (unsigned char)
+ cmap[lookup[(int)col[0] - 32]
+ [0]].b;
+ *ptr++ =
+ 0x00ffffff & ((r << 16) |
+ (g << 8) | b);
+ count++;
+ }
+ else
+ {
+ r = (unsigned char)
+ cmap[lookup[(int)col[0] - 32]
+ [0]].r;
+ g = (unsigned char)
+ cmap[lookup[(int)col[0] - 32]
+ [0]].g;
+ b = (unsigned char)
+ cmap[lookup[(int)col[0] - 32]
+ [0]].b;
+ *ptr++ =
+ (0xff << 24) | (r << 16) | (g <<
+ 8) |
+ b;
+ count++;
+ }
+ }
+ }
+ else
+ {
+ for (i = 0;
+ ((i < 65536) && (ptr < end) && (line[i]));
+ i++)
+ {
+ col[0] = line[i];
+ r = (unsigned char)
+ cmap[lookup[(int)col[0] - 32][0]].r;
+ g = (unsigned char)
+ cmap[lookup[(int)col[0] - 32][0]].g;
+ b = (unsigned char)
+ cmap[lookup[(int)col[0] - 32][0]].b;
+ *ptr++ =
+ (0xff << 24) | (r << 16) | (g << 8) |
+ b;
+ count++;
+ }
+ }
+ }
+ else if (cpp == 2)
+ {
+ if (transp)
+ {
+ for (i = 0;
+ ((i < 65536) && (ptr < end) && (line[i]));
+ i++)
+ {
+ col[0] = line[i++];
+ col[1] = line[i];
+ if (cmap
+ [lookup[(int)col[0] - 32]
+ [(int)col[1] - 32]].transp)
+ {
+ r = (unsigned char)
+ cmap[lookup[(int)col[0] - 32]
+ [(int)col[1] - 32]].r;
+ g = (unsigned char)
+ cmap[lookup[(int)col[0] - 32]
+ [(int)col[1] - 32]].g;
+ b = (unsigned char)
+ cmap[lookup[(int)col[0] - 32]
+ [(int)col[1] - 32]].b;
+ *ptr++ =
+ 0x00ffffff & ((r << 16) |
+ (g << 8) | b);
+ count++;
+ }
+ else
+ {
+ r = (unsigned char)
+ cmap[lookup[(int)col[0] - 32]
+ [(int)col[1] - 32]].r;
+ g = (unsigned char)
+ cmap[lookup[(int)col[0] - 32]
+ [(int)col[1] - 32]].g;
+ b = (unsigned char)
+ cmap[lookup[(int)col[0] - 32]
+ [(int)col[1] - 32]].b;
+ *ptr++ =
+ (0xff << 24) | (r << 16) | (g <<
+ 8) |
+ b;
+ count++;
+ }
+ }
+ }
+ else
+ {
+ for (i = 0;
+ ((i < 65536) && (ptr < end) && (line[i]));
+ i++)
+ {
+ col[0] = line[i++];
+ col[1] = line[i];
+ r = (unsigned char)
+ cmap[lookup[(int)col[0] - 32]
+ [(int)col[1] - 32]].r;
+ g = (unsigned char)
+ cmap[lookup[(int)col[0] - 32]
+ [(int)col[1] - 32]].g;
+ b = (unsigned char)
+ cmap[lookup[(int)col[0] - 32]
+ [(int)col[1] - 32]].b;
+ *ptr++ =
+ (0xff << 24) | (r << 16) | (g << 8) |
+ b;
+ count++;
+ }
+ }
+ }
+ else
+ {
+ if (transp)
+ {
+ for (i = 0;
+ ((i < 65536) && (ptr < end) && (line[i]));
+ i++)
+ {
+ for (j = 0; j < cpp; j++, i++)
+ {
+ col[j] = line[i];
+ }
+ col[j] = 0;
+ i--;
+ for (j = 0; j < ncolors; j++)
+ {
+ if (!strcmp(col, cmap[j].str))
+ {
+ if (cmap[j].transp)
+ {
+ r = (unsigned char)
+ cmap[lookup
+ [(int)col[0] -
+ 32][0]].r;
+ g = (unsigned char)
+ cmap[lookup
+ [(int)col[0] -
+ 32][0]].g;
+ b = (unsigned char)
+ cmap[lookup
+ [(int)col[0] -
+ 32][0]].b;
+ *ptr++ =
+ 0x00ffffff & ((r << 16)
+ | (g <<
+ 8) |
+ b);
+ count++;
+ }
+ else
+ {
+ r = (unsigned char)cmap[j].
+ r;
+ g = (unsigned char)cmap[j].
+ g;
+ b = (unsigned char)cmap[j].
+ b;
+ *ptr++ =
+ (0xff << 24) | (r <<
+ 16) |
+ (g << 8) | b;
+ count++;
+ }
+ j = ncolors;
+ }
+ }
+ }
+ }
+ else
+ {
+ for (i = 0;
+ ((i < 65536) && (ptr < end) && (line[i]));
+ i++)
+ {
+ for (j = 0; j < cpp; j++, i++)
+ {
+ col[j] = line[i];
+ }
+ col[j] = 0;
+ i--;
+ for (j = 0; j < ncolors; j++)
+ {
+ if (!strcmp(col, cmap[j].str))
+ {
+ r = (unsigned char)cmap[j].r;
+ g = (unsigned char)cmap[j].g;
+ b = (unsigned char)cmap[j].b;
+ *ptr++ =
+ (0xff << 24) | (r << 16) |
+ (g << 8) | b;
+ count++;
+ j = ncolors;
+ }
+ }
+ }
+ }
+ }
+ per += per_inc;
+ if (progress && (((int)per) != last_per)
+ && (((int)per) % progress_granularity == 0))
+ {
+ last_per = (int)per;
+ if (!(progress(im, (int)per, 0, last_y, w, i)))
+ {
+ fclose(f);
+ free(cmap);
+ free(line);
+ xpm_parse_done();
+ return 2;
+ }
+ last_y = i;
+ }
+ }
+ }
+ }
+ /* Scan in line from XPM file */
+ if ((!comment) && (quote) && (c != '"'))
+ {
+ if (c < 32)
+ c = 32;
+ else if (c > 127)
+ c = 127;
+ line[i++] = c;
+ }
+ if (i >= lsz)
+ {
+ lsz += 256;
+ line = realloc(line, lsz);
+ }
+ if (((ptr) && ((ptr - im->data) >= (w * h * sizeof(DATA32)))) ||
+ ((context > 1) && (count >= pixels)))
+ done = 1;
}
-
+
if (progress)
{
- progress(im, 100, 0, last_y, w, h);
+ progress(im, 100, 0, last_y, w, h);
}
-
- fclose(f);
+
+ fclose(f);
free(cmap);
free(line);
-
+
xpm_parse_done();
-
+
return 1;
}
-char
-save(ImlibImage *im, ImlibProgressFunction progress, char progress_granularity)
+char
+save(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity)
{
return 0;
im = NULL;
@@ -571,22 +677,20 @@ save(ImlibImage *im, ImlibProgressFunction progress, char progress_granularity)
/* your laoder CAN load more than one format if it likes - like: */
/* loader->formats = { "gif", "png", "jpeg", "jpg"} */
/* if it can load those formats. */
-void
-formats (ImlibLoader *l)
-{
+void
+formats(ImlibLoader * l)
+{
/* this is the only bit you have to change... */
- char *list_formats[] =
- { "xpm" };
-
+ char *list_formats[] = { "xpm" };
+
/* don't bother changing any of this - it just reads this in and sets */
/* the struct values and makes copies */
- {
- int i;
-
- l->num_formats = (sizeof(list_formats) / sizeof (char *));
- l->formats = malloc(sizeof(char *) * l->num_formats);
- for (i = 0; i < l->num_formats; i++)
- l->formats[i] = strdup(list_formats[i]);
- }
-}
+ {
+ int i;
+ l->num_formats = (sizeof(list_formats) / sizeof(char *));
+ l->formats = malloc(sizeof(char *) * l->num_formats);
+ for (i = 0; i < l->num_formats; i++)
+ l->formats[i] = strdup(list_formats[i]);
+ }
+}
diff --git a/src/Makefile.am b/src/Makefile.am
index a6c4083..aa0de8b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -9,7 +9,8 @@ LDFLAGS = -L/usr/X11R6/lib
INCLUDES = -I. -I$(top_srcdir) -I$(top_srcdir)/src \
-I$(top_srcdir)/loaders -I$(top_srcdir)/libltdl \
-I/usr/X11R6/include $(X_CFLAGS) \
- -I$(prefix)/include -I$(includedir)
+ -I$(prefix)/include -I$(includedir) \
+ $(freetype_cflags)
MMX_SRCS = asm_blend.S asm_rgba.S asm_scale.S asm_rotate.S \
asm_blend_cmod.S
MMX_OBJS = $(MMX_SRCS:.S=.lo)
@@ -17,12 +18,13 @@ MMX_OBJS = $(MMX_SRCS:.S=.lo)
lib_LTLIBRARIES = libImlib2.la
include_HEADERS = Imlib2.h
libImlib2_la_SOURCES = scale.c image.c blend.c file.c rgbadraw.c api.c \
- updates.c colormod.c font.c format.c grad.c rotate.c \
+ updates.c colormod.c format.c grad.c rotate.c \
filter.c script.c dynamic_filters.c color_helpers.c \
+ font_main.c font_load.c font_query.c font_draw.c \
Imlib2.h image.h scale.h blend.h updates.h colormod.h \
file.h common.h rgbadraw.h font.h format.h \
rotate.h grad.h filter.h script.h dynamic_filters.h \
- color_helpers.h
+ color_helpers.h
EXTRA_libImlib2_la_SOURCES = rend.c ximage.c rgba.c color.c grab.c draw.c \
context.c color.h context.h draw.h grab.h rend.h \
@@ -32,12 +34,12 @@ libImlib2_la_LDFLAGS = -version-info 1:4:0
if HAVE_MMX
libImlib2_la_LIBADD = $(X_OBJS) @DLLDFLAGS@ $(MMX_OBJS) \
$(top_builddir)/libltdl/libltdlc.la \
- $(x_libs) -lttf $(LDFLAGS)
+ $(x_libs) $(freetype_libs) $(LDFLAGS)
libImlib2_la_DEPENDENCIES = $(top_builddir)/config.h $(X_OBJS) $(MMX_OBJS)
else
libImlib2_la_LIBADD = $(X_OBJS) @DLLDFLAGS@ \
$(top_builddir)/libltdl/libltdlc.la \
- $(x_libs) -lttf $(LDFLAGS)
+ $(x_libs) $(freetype_libs) $(LDFLAGS)
libImlib2_la_DEPENDENCIES = $(top_builddir)/config.h $(X_OBJS)
endif
diff --git a/src/api.c b/src/api.c
index 622e129..ca4984b 100644
--- a/src/api.c
+++ b/src/api.c
@@ -24,13 +24,16 @@
#include "updates.h"
#include "rgbadraw.h"
#include "Imlib2.h"
-#ifdef HAVE_FREETYPE1_FREETYPE_FREETYPE_H
+#include <ft2build.h>
+#include FT_FREETYPE_H
+/*#ifdef HAVE_FREETYPE1_FREETYPE_FREETYPE_H
#include <freetype1/freetype/freetype.h>
#elif defined(HAVE_FREETYPE_FREETYPE_H)
#include <freetype/freetype.h>
#else
#include <freetype.h>
#endif
+*/
#include "font.h"
#include "grad.h"
#include "rotate.h"
@@ -70,129 +73,136 @@ if (!(param)) \
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
/* internal typedefs for function pointers */
-typedef void (*Imlib_Internal_Progress_Function) (void *, char, int, int, int,
-
- int);
-typedef void (*Imlib_Internal_Data_Destructor_Function) (void *, void *);
+typedef void (*Imlib_Internal_Progress_Function) (void *, char, int, int,
+ int, int);
+typedef void (*Imlib_Internal_Data_Destructor_Function) (void *, void *);
struct _imlibcontext;
typedef struct _imlibcontext ImlibContext;
-struct _imlibcontext
-{
+struct _imlibcontext {
#ifndef X_DISPLAY_MISSING
- Display *display;
- Visual *visual;
- Colormap colormap;
- int depth;
- Drawable drawable;
- Pixmap mask;
+ Display *display;
+ Visual *visual;
+ Colormap colormap;
+ int depth;
+ Drawable drawable;
+ Pixmap mask;
#endif
- char anti_alias;
- char dither;
- char blend;
- Imlib_Color_Modifier color_modifier;
- Imlib_Operation operation;
- Imlib_Font font;
- Imlib_Text_Direction direction;
- double angle;
- Imlib_Color color;
- Imlib_Color_Range color_range;
- Imlib_Image image;
- Imlib_Progress_Function progress_func;
- char progress_granularity;
- char dither_mask;
- Imlib_Filter filter;
- Imlib_Rectangle cliprect;
- Imlib_TTF_Encoding encoding;
-
- int references;
- char dirty;
+ char anti_alias;
+ char dither;
+ char blend;
+ Imlib_Color_Modifier color_modifier;
+ Imlib_Operation operation;
+ Imlib_Font font;
+ Imlib_Text_Direction direction;
+ double angle;
+ Imlib_Color color;
+ Imlib_Color_Range color_range;
+ Imlib_Image image;
+ Imlib_Progress_Function progress_func;
+ char progress_granularity;
+ char dither_mask;
+ Imlib_Filter filter;
+ Imlib_Rectangle cliprect;
+ Imlib_TTF_Encoding encoding;
+
+ int references;
+ char dirty;
};
struct _imlibcontextitem;
typedef struct _imlibcontextitem ImlibContextItem;
-struct _imlibcontextitem
-{
- ImlibContext *context;
- ImlibContextItem *below;
+struct _imlibcontextitem {
+ ImlibContext *context;
+ ImlibContextItem *below;
};
/* a stack of contexts -- only used by context-handling functions. */
-static ImlibContextItem *contexts = NULL;/* (ImlibContext*) imlib_context_new(); */
+static ImlibContextItem *contexts = NULL; /* (ImlibContext*) imlib_context_new(); */
+
/* this is the context all functions use rely on */
-static ImlibContext *ctx = NULL; /* contexts->context; */
+static ImlibContext *ctx = NULL; /* contexts->context; */
/* frees the given context including all its members */
-void
-__imlib_free_context(ImlibContext *context)
-{
- ImlibContextItem *next = contexts;
-
- if ( ctx == context ) {
- next = contexts->below;
- free(contexts);
- contexts = next;
- }
-
- ctx = context;
-
- if (ctx->image) {
- imlib_free_image();
- ctx->image = NULL;
- }
- if (ctx->font) {
- imlib_free_font();
- ctx->font = NULL;
- }
- if (ctx->color_modifier) {
- imlib_free_color_modifier();
- ctx->color_modifier = NULL;
- }
- if (ctx->filter) {
- imlib_free_filter();
- ctx->filter = NULL;
- }
-
- free (ctx);
- ctx = next->context;
+void
+__imlib_free_context(ImlibContext * context)
+{
+ ImlibContextItem *next = contexts;
+
+ if (ctx == context)
+ {
+ next = contexts->below;
+ free(contexts);
+ contexts = next;
+ }
+
+ ctx = context;
+
+ if (ctx->image)
+ {
+ imlib_free_image();
+ ctx->image = NULL;
+ }
+ if (ctx->font)
+ {
+ imlib_free_font();
+ ctx->font = NULL;
+ }
+ if (ctx->color_modifier)
+ {
+ imlib_free_color_modifier();
+ ctx->color_modifier = NULL;
+ }
+ if (ctx->filter)
+ {
+ imlib_free_filter();
+ ctx->filter = NULL;
+ }
+
+ free(ctx);
+ ctx = next->context;
}
Imlib_Context
imlib_context_new(void)
{
- ImlibContext *context = malloc(sizeof(ImlibContext));
+ ImlibContext *context = malloc(sizeof(ImlibContext));
#ifndef X_DISPLAY_MISSING
- context->display = NULL;
- context->visual = NULL;
- context->colormap = 0;
- context->depth = 0;
- context->drawable = 0;
- context->mask = 0;
+ context->display = NULL;
+ context->visual = NULL;
+ context->colormap = 0;
+ context->depth = 0;
+ context->drawable = 0;
+ context->mask = 0;
#endif
- context->anti_alias = 1;
- context->dither = 0;
- context->blend = 1;
- context->color_modifier = NULL;
- context->operation = IMLIB_OP_COPY;
- context->font = NULL;
- context->direction = IMLIB_TEXT_TO_RIGHT;
- context->angle = 0.0;
- context->color = (Imlib_Color) { 255, 255, 255, 255 };
- context->color_range = NULL;
- context->image = NULL;
- context->progress_func = NULL;
- context->progress_granularity = 0;
- context->dither_mask = 0;
- context->filter = NULL;
- context->cliprect = (Imlib_Rectangle) { 0, 0, 0, 0 };
- context->encoding = IMLIB_TTF_ENCODING_ISO_8859_1;
-
- context->references = 0;
- context->dirty = 0;
-
- return (Imlib_Context) context;
+ context->anti_alias = 1;
+ context->dither = 0;
+ context->blend = 1;
+ context->color_modifier = NULL;
+ context->operation = IMLIB_OP_COPY;
+ context->font = NULL;
+ context->direction = IMLIB_TEXT_TO_RIGHT;
+ context->angle = 0.0;
+ context->color = (Imlib_Color)
+ {
+ 255, 255, 255, 255};
+ context->color_range = NULL;
+ context->image = NULL;
+ context->progress_func = NULL;
+ context->progress_granularity = 0;
+ context->dither_mask = 0;
+ context->filter = NULL;
+ context->cliprect = (Imlib_Rectangle)
+ {
+ 0, 0, 0, 0};
+ context->encoding = IMLIB_TTF_ENCODING_ISO_8859_1;
+
+ context->references = 0;
+ context->dirty = 0;
+
+ return (Imlib_Context) context;
}
/* frees the given context if it doesn't have any reference anymore. The
@@ -200,57 +210,59 @@ imlib_context_new(void)
If context is the current context, the context below will be made the
current context.
*/
-void
+void
imlib_context_free(Imlib_Context context)
{
- ImlibContext *c = (ImlibContext*) context;
- CHECK_PARAM_POINTER("imlib_context_free", "context", context);
- if (c == ctx && !contexts->below)
- return;
-
- if (c->references == 0)
- __imlib_free_context(c);
- else
- c->dirty = 1;
-}
-
-void
+ ImlibContext *c = (ImlibContext *) context;
+
+ CHECK_PARAM_POINTER("imlib_context_free", "context", context);
+ if (c == ctx && !contexts->below)
+ return;
+
+ if (c->references == 0)
+ __imlib_free_context(c);
+ else
+ c->dirty = 1;
+}
+
+void
imlib_context_push(Imlib_Context context)
{
- ImlibContextItem *item;
- CHECK_PARAM_POINTER("imlib_context_push", "context", context);
- ctx = (ImlibContext*) context;
-
- item = malloc(sizeof(ImlibContextItem));
- item->context = ctx;
- item->below = contexts;
- contexts = item;
-
- ctx->references++;
+ ImlibContextItem *item;
+
+ CHECK_PARAM_POINTER("imlib_context_push", "context", context);
+ ctx = (ImlibContext *) context;
+
+ item = malloc(sizeof(ImlibContextItem));
+ item->context = ctx;
+ item->below = contexts;
+ contexts = item;
+
+ ctx->references++;
}
-void
+void
imlib_context_pop(void)
{
- ImlibContextItem *item = contexts;
- ImlibContext *current_ctx = item->context;
+ ImlibContextItem *item = contexts;
+ ImlibContext *current_ctx = item->context;
- if (!item->below)
- return;
+ if (!item->below)
+ return;
- contexts = item->below;
- ctx = contexts->context;
- current_ctx->references--;
- if (current_ctx->dirty && current_ctx->references <= 0)
- __imlib_free_context(current_ctx);
+ contexts = item->below;
+ ctx = contexts->context;
+ current_ctx->references--;
+ if (current_ctx->dirty && current_ctx->references <= 0)
+ __imlib_free_context(current_ctx);
- free(item);
+ free(item);
}
Imlib_Context
imlib_context_get(void)
{
- return (Imlib_Context) ctx;
+ return (Imlib_Context) ctx;
}
/* context setting/getting functions */
@@ -258,7 +270,8 @@ imlib_context_get(void)
void
imlib_context_set_cliprect(int x, int y, int w, int h)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
ctx->cliprect.x = x;
ctx->cliprect.y = y;
ctx->cliprect.w = w;
@@ -268,7 +281,8 @@ imlib_context_set_cliprect(int x, int y, int w, int h)
void
imlib_context_get_cliprect(int *x, int *y, int *w, int *h)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
*x = ctx->cliprect.x;
*y = ctx->cliprect.y;
*w = ctx->cliprect.w;
@@ -279,71 +293,81 @@ imlib_context_get_cliprect(int *x, int *y, int *w, int *h)
void
imlib_context_set_display(Display * display)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
ctx->display = display;
}
-Display *
+Display *
imlib_context_get_display(void)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
return ctx->display;
}
void
imlib_context_set_visual(Visual * visual)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
ctx->visual = visual;
ctx->depth = imlib_get_visual_depth(ctx->display, ctx->visual);
}
-Visual *
+Visual *
imlib_context_get_visual(void)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
return ctx->visual;
}
void
imlib_context_set_colormap(Colormap colormap)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
ctx->colormap = colormap;
}
Colormap
imlib_context_get_colormap(void)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
return ctx->colormap;
}
void
imlib_context_set_drawable(Drawable drawable)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
ctx->drawable = drawable;
}
Drawable
imlib_context_get_drawable(void)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
return ctx->drawable;
}
void
imlib_context_set_mask(Pixmap mask)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
ctx->mask = mask;
}
Pixmap
imlib_context_get_mask(void)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
return ctx->mask;
}
#endif
@@ -351,133 +375,152 @@ imlib_context_get_mask(void)
void
imlib_context_set_dither_mask(char dither_mask)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
ctx->dither_mask = dither_mask;
}
char
imlib_context_get_dither_mask(void)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
return ctx->dither_mask;
}
void
imlib_context_set_anti_alias(char anti_alias)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
ctx->anti_alias = anti_alias;
}
char
imlib_context_get_anti_alias(void)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
return ctx->anti_alias;
}
void
imlib_context_set_dither(char dither)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
ctx->dither = dither;
}
char
imlib_context_get_dither(void)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
return ctx->dither;
}
void
imlib_context_set_blend(char blend)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
ctx->blend = blend;
}
char
imlib_context_get_blend(void)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
return ctx->blend;
}
void
imlib_context_set_color_modifier(Imlib_Color_Modifier color_modifier)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
ctx->color_modifier = color_modifier;
}
Imlib_Color_Modifier
imlib_context_get_color_modifier(void)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
return ctx->color_modifier;
}
void
imlib_context_set_operation(Imlib_Operation operation)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
ctx->operation = operation;
}
Imlib_Operation
imlib_context_get_operation(void)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
return ctx->operation;
}
void
imlib_context_set_font(Imlib_Font font)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
ctx->font = font;
}
Imlib_Font
imlib_context_get_font(void)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
return ctx->font;
}
void
imlib_context_set_direction(Imlib_Text_Direction direction)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
ctx->direction = direction;
}
void
imlib_context_set_angle(double angle)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
ctx->angle = angle;
}
double
imlib_context_get_angle(void)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
return ctx->angle;
}
Imlib_Text_Direction
imlib_context_get_direction(void)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
return ctx->direction;
}
void
imlib_context_set_color(int red, int green, int blue, int alpha)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
ctx->color.red = red;
ctx->color.green = green;
ctx->color.blue = blue;
@@ -487,52 +530,58 @@ imlib_context_set_color(int red, int green, int blue, int alpha)
void
imlib_context_get_color(int *red, int *green, int *blue, int *alpha)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
*red = ctx->color.red;
*green = ctx->color.green;
*blue = ctx->color.blue;
*alpha = ctx->color.alpha;
}
-Imlib_Color *
+Imlib_Color *
imlib_context_get_imlib_color(void)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
return &ctx->color;
}
void
-imlib_context_set_color_hsva(float hue, float saturation, float value, int alpha)
+imlib_context_set_color_hsva(float hue, float saturation, float value,
+ int alpha)
{
- int r,g,b;
+ int r, g, b;
- __imlib_hsv_to_rgb(hue, saturation, value, &r, &g, &b);
- imlib_context_set_color(r, g, b, alpha);
+ __imlib_hsv_to_rgb(hue, saturation, value, &r, &g, &b);
+ imlib_context_set_color(r, g, b, alpha);
}
void
-imlib_context_get_color_hsva(float *hue, float *saturation, float *value, int *alpha)
+imlib_context_get_color_hsva(float *hue, float *saturation, float *value,
+ int *alpha)
{
- int r,g,b,f;
- float i,j,k,max,min,d;
+ int r, g, b, f;
+ float i, j, k, max, min, d;
imlib_context_get_color(&r, &g, &b, alpha);
- __imlib_rgb_to_hsv(r, g, b, hue, saturation, value);
+ __imlib_rgb_to_hsv(r, g, b, hue, saturation, value);
}
void
-imlib_context_set_color_hlsa(float hue, float lightness, float saturation, int alpha)
+imlib_context_set_color_hlsa(float hue, float lightness, float saturation,
+ int alpha)
{
- int r,g,b;
+ int r, g, b;
__imlib_hls_to_rgb(hue, lightness, saturation, &r, &g, &b);
imlib_context_set_color(r, g, b, alpha);
}
void
-imlib_context_get_color_hlsa(float *hue, float *lightness, float *saturation, int *alpha)
+imlib_context_get_color_hlsa(float *hue, float *lightness, float *saturation,
+ int *alpha)
{
- int r,g,b;
+ int r, g, b;
imlib_context_get_color(&r, &g, &b, alpha);
__imlib_rgb_to_hls(r, g, b, hue, lightness, saturation);
@@ -541,7 +590,8 @@ imlib_context_get_color_hlsa(float *hue, float *lightness, float *saturation, in
void
imlib_context_set_color_cmya(int cyan, int magenta, int yellow, int alpha)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
ctx->color.red = 255 - cyan;
ctx->color.green = 255 - magenta;
ctx->color.blue = 255 - yellow;
@@ -551,7 +601,8 @@ imlib_context_set_color_cmya(int cyan, int magenta, int yellow, int alpha)
void
imlib_context_get_color_cmya(int *cyan, int *magenta, int *yellow, int *alpha)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
*cyan = 255 - ctx->color.red;
*magenta = 255 - ctx->color.green;
*yellow = 255 - ctx->color.blue;
@@ -561,95 +612,107 @@ imlib_context_get_color_cmya(int *cyan, int *magenta, int *yellow, int *alpha)
void
imlib_context_set_color_range(Imlib_Color_Range color_range)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
ctx->color_range = color_range;
}
Imlib_Color_Range
imlib_context_get_color_range(void)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
return ctx->color_range;
}
void
imlib_context_set_progress_function(Imlib_Progress_Function progress_function)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
ctx->progress_func = progress_function;
}
Imlib_Progress_Function
imlib_context_get_progress_function(void)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
return ctx->progress_func;
}
void
imlib_context_set_progress_granularity(char progress_granularity)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
ctx->progress_granularity = progress_granularity;
}
char
imlib_context_get_progress_granularity(void)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
return ctx->progress_granularity;
}
void
imlib_context_set_image(Imlib_Image image)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
ctx->image = image;
}
Imlib_Image
imlib_context_get_image(void)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
return ctx->image;
}
-void
-imlib_context_set_TTF_encoding(Imlib_TTF_Encoding encoding)
+void
+imlib_context_set_TTF_encoding(Imlib_TTF_Encoding encoding)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
ctx->encoding = encoding;
- __imlib_set_TTF_encoding(encoding);
}
-Imlib_TTF_Encoding
-imlib_context_get_TTF_encoding(void)
+Imlib_TTF_Encoding
+imlib_context_get_TTF_encoding(void)
{
- if (!ctx) ctx = imlib_context_new();
- return ctx->encoding;
+ if (!ctx)
+ ctx = imlib_context_new();
+ return ctx->encoding;
}
/* imlib api */
int
imlib_get_cache_size(void)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
return __imlib_GetCacheSize();
}
void
imlib_set_cache_size(int bytes)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
__imlib_SetCacheSize(bytes);
}
int
imlib_get_color_usage(void)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
#ifndef X_DISPLAY_MISSING
- return (int) _max_colors;
+ return (int)_max_colors;
#else
return 256;
#endif
@@ -658,7 +721,8 @@ imlib_get_color_usage(void)
void
imlib_set_color_usage(int max)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
#ifndef X_DISPLAY_MISSING
if (max < 2)
max = 2;
@@ -671,7 +735,8 @@ imlib_set_color_usage(int max)
void
imlib_flush_loaders(void)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
__imlib_RemoveAllLoaders();
LTDL_Exit();
}
@@ -680,17 +745,18 @@ imlib_flush_loaders(void)
int
imlib_get_visual_depth(Display * display, Visual * visual)
{
- if (!ctx) ctx = imlib_context_new();
- CHECK_PARAM_POINTER_RETURN("imlib_get_visual_depth", "display", display,
- 0);
+ if (!ctx)
+ ctx = imlib_context_new();
+ CHECK_PARAM_POINTER_RETURN("imlib_get_visual_depth", "display", display, 0);
CHECK_PARAM_POINTER_RETURN("imlib_get_visual_depth", "visual", visual, 0);
return __imlib_XActualDepth(display, visual);
}
-Visual *
+Visual *
imlib_get_best_visual(Display * display, int screen, int *depth_return)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER_RETURN("imlib_get_best_visual", "display", display,
NULL);
CHECK_PARAM_POINTER_RETURN("imlib_get_best_visual", "depth_return",
@@ -702,15 +768,15 @@ imlib_get_best_visual(Display * display, int screen, int *depth_return)
Imlib_Image
imlib_load_image(const char *file)
{
- Imlib_Image im = NULL;
- Imlib_Image prev_ctxt_image;
+ Imlib_Image im = NULL;
+ Imlib_Image prev_ctxt_image;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER_RETURN("imlib_load_image", "file", file, NULL);
prev_ctxt_image = ctx->image;
- im =
- __imlib_LoadImage(file, (ImlibProgressFunction) ctx->progress_func,
- ctx->progress_granularity, 0, 0, NULL);
+ im = __imlib_LoadImage(file, (ImlibProgressFunction) ctx->progress_func,
+ ctx->progress_granularity, 0, 0, NULL);
ctx->image = prev_ctxt_image;
return (Imlib_Image) im;
}
@@ -718,16 +784,16 @@ imlib_load_image(const char *file)
Imlib_Image
imlib_load_image_immediately(const char *file)
{
- Imlib_Image im = NULL;
- Imlib_Image prev_ctxt_image;
+ Imlib_Image im = NULL;
+ Imlib_Image prev_ctxt_image;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER_RETURN("imlib_load_image_immediately", "file", file,
NULL);
prev_ctxt_image = ctx->image;
- im =
- __imlib_LoadImage(file, (ImlibProgressFunction) ctx->progress_func,
- ctx->progress_granularity, 1, 0, NULL);
+ im = __imlib_LoadImage(file, (ImlibProgressFunction) ctx->progress_func,
+ ctx->progress_granularity, 1, 0, NULL);
ctx->image = prev_ctxt_image;
return (Imlib_Image) im;
}
@@ -735,16 +801,16 @@ imlib_load_image_immediately(const char *file)
Imlib_Image
imlib_load_image_without_cache(const char *file)
{
- Imlib_Image im = NULL;
- Imlib_Image prev_ctxt_image;
+ Imlib_Image im = NULL;
+ Imlib_Image prev_ctxt_image;
- if (!ctx) ctx = imlib_context_new();
- CHECK_PARAM_POINTER_RETURN("imlib_load_image_without_cache", "file",
- file, NULL);
+ if (!ctx)
+ ctx = imlib_context_new();
+ CHECK_PARAM_POINTER_RETURN("imlib_load_image_without_cache", "file",
+ file, NULL);
prev_ctxt_image = ctx->image;
- im =
- __imlib_LoadImage(file, (ImlibProgressFunction) ctx->progress_func,
- ctx->progress_granularity, 0, 1, NULL);
+ im = __imlib_LoadImage(file, (ImlibProgressFunction) ctx->progress_func,
+ ctx->progress_granularity, 0, 1, NULL);
ctx->image = prev_ctxt_image;
return (Imlib_Image) im;
}
@@ -752,16 +818,16 @@ imlib_load_image_without_cache(const char *file)
Imlib_Image
imlib_load_image_immediately_without_cache(const char *file)
{
- Imlib_Image im = NULL;
- Imlib_Image prev_ctxt_image;
+ Imlib_Image im = NULL;
+ Imlib_Image prev_ctxt_image;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER_RETURN("imlib_load_image_immediately_without_cache",
"file", file, NULL);
prev_ctxt_image = ctx->image;
- im =
- __imlib_LoadImage(file, (ImlibProgressFunction) ctx->progress_func,
- ctx->progress_granularity, 1, 1, NULL);
+ im = __imlib_LoadImage(file, (ImlibProgressFunction) ctx->progress_func,
+ ctx->progress_granularity, 1, 1, NULL);
ctx->image = prev_ctxt_image;
return (Imlib_Image) im;
}
@@ -770,51 +836,52 @@ Imlib_Image
imlib_load_image_with_error_return(const char *file,
Imlib_Load_Error * error_return)
{
- Imlib_Image im = NULL;
- ImlibLoadError er;
- Imlib_Image prev_ctxt_image;
+ Imlib_Image im = NULL;
+ ImlibLoadError er;
+ Imlib_Image prev_ctxt_image;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER_RETURN("imlib_load_image_with_error_return", "file",
file, NULL);
if (!__imlib_FileExists(file))
- {
- *error_return = IMLIB_LOAD_ERROR_FILE_DOES_NOT_EXIST;
- return NULL;
- }
+ {
+ *error_return = IMLIB_LOAD_ERROR_FILE_DOES_NOT_EXIST;
+ return NULL;
+ }
if (__imlib_FileIsDir(file))
- {
- *error_return = IMLIB_LOAD_ERROR_FILE_IS_DIRECTORY;
- return NULL;
- }
+ {
+ *error_return = IMLIB_LOAD_ERROR_FILE_IS_DIRECTORY;
+ return NULL;
+ }
if (!__imlib_FileCanRead(file))
- {
- *error_return = IMLIB_LOAD_ERROR_PERMISSION_DENIED_TO_READ;
- return NULL;
- }
+ {
+ *error_return = IMLIB_LOAD_ERROR_PERMISSION_DENIED_TO_READ;
+ return NULL;
+ }
prev_ctxt_image = ctx->image;
- im =
- (Imlib_Image) __imlib_LoadImage(file,
- (ImlibProgressFunction)
- ctx->progress_func,
- ctx->progress_granularity, 1, 0, &er);
+ im = (Imlib_Image) __imlib_LoadImage(file,
+ (ImlibProgressFunction)
+ ctx->progress_func,
+ ctx->progress_granularity, 1, 0, &er);
ctx->image = prev_ctxt_image;
if (im)
*error_return = IMLIB_LOAD_ERROR_NONE;
else
- {
- if (er == IMLIB_LOAD_ERROR_NONE)
- *error_return = IMLIB_LOAD_ERROR_NO_LOADER_FOR_FILE_FORMAT;
- else
- *error_return = (Imlib_Load_Error) er;
- }
+ {
+ if (er == IMLIB_LOAD_ERROR_NONE)
+ *error_return = IMLIB_LOAD_ERROR_NO_LOADER_FOR_FILE_FORMAT;
+ else
+ *error_return = (Imlib_Load_Error) er;
+ }
return im;
}
void
imlib_free_image(void)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_free_image", "image", ctx->image);
__imlib_FreeImage(ctx->image);
ctx->image = NULL;
@@ -823,9 +890,10 @@ imlib_free_image(void)
void
imlib_free_image_and_decache(void)
{
- ImlibImage *im;
+ ImlibImage *im;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_free_image_and_decache", "image", ctx->image);
CAST_IMAGE(im, ctx->image);
SET_FLAG(im->flags, F_INVALID);
@@ -836,11 +904,11 @@ imlib_free_image_and_decache(void)
int
imlib_image_get_width(void)
{
- ImlibImage *im;
+ ImlibImage *im;
- if (!ctx) ctx = imlib_context_new();
- CHECK_PARAM_POINTER_RETURN("imlib_image_get_width", "image", ctx->image,
- 0);
+ if (!ctx)
+ ctx = imlib_context_new();
+ CHECK_PARAM_POINTER_RETURN("imlib_image_get_width", "image", ctx->image, 0);
CAST_IMAGE(im, ctx->image);
return im->w;
}
@@ -848,34 +916,36 @@ imlib_image_get_width(void)
int
imlib_image_get_height(void)
{
- ImlibImage *im;
+ ImlibImage *im;
- if (!ctx) ctx = imlib_context_new();
- CHECK_PARAM_POINTER_RETURN("imlib_image_get_height", "image", ctx->image,
- 0);
+ if (!ctx)
+ ctx = imlib_context_new();
+ CHECK_PARAM_POINTER_RETURN("imlib_image_get_height", "image", ctx->image, 0);
CAST_IMAGE(im, ctx->image);
return im->h;
}
-const char *
+const char *
imlib_image_get_filename(void)
{
- ImlibImage *im;
+ ImlibImage *im;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER_RETURN("imlib_image_get_filename", "image", ctx->image,
0);
CAST_IMAGE(im, ctx->image);
/* strdup() the returned value if you want to alter it! */
- return (const char *) (im->file);
+ return (const char *)(im->file);
}
-DATA32 *
+DATA32 *
imlib_image_get_data(void)
{
- ImlibImage *im;
+ ImlibImage *im;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER_RETURN("imlib_image_get_data", "image", ctx->image,
NULL);
CAST_IMAGE(im, ctx->image);
@@ -888,12 +958,13 @@ imlib_image_get_data(void)
return im->data;
}
-DATA32 *
+DATA32 *
imlib_image_get_data_for_reading_only(void)
{
- ImlibImage *im;
+ ImlibImage *im;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER_RETURN("imlib_image_get_data_for_reading_only",
"image", ctx->image, NULL);
CAST_IMAGE(im, ctx->image);
@@ -907,9 +978,10 @@ imlib_image_get_data_for_reading_only(void)
void
imlib_image_put_back_data(DATA32 * data)
{
- ImlibImage *im;
+ ImlibImage *im;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_image_put_back_data", "image", ctx->image);
CHECK_PARAM_POINTER("imlib_image_put_back_data", "data", data);
CAST_IMAGE(im, ctx->image);
@@ -921,11 +993,11 @@ imlib_image_put_back_data(DATA32 * data)
char
imlib_image_has_alpha(void)
{
- ImlibImage *im;
+ ImlibImage *im;
- if (!ctx) ctx = imlib_context_new();
- CHECK_PARAM_POINTER_RETURN("imlib_image_has_alpha", "image", ctx->image,
- 0);
+ if (!ctx)
+ ctx = imlib_context_new();
+ CHECK_PARAM_POINTER_RETURN("imlib_image_has_alpha", "image", ctx->image, 0);
CAST_IMAGE(im, ctx->image);
if (IMAGE_HAS_ALPHA(im))
return 1;
@@ -935,9 +1007,10 @@ imlib_image_has_alpha(void)
void
imlib_image_set_changes_on_disk(void)
{
- ImlibImage *im;
+ ImlibImage *im;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_image_set_never_changes_on_disk", "image",
ctx->image);
CAST_IMAGE(im, ctx->image);
@@ -947,9 +1020,10 @@ imlib_image_set_changes_on_disk(void)
void
imlib_image_get_border(Imlib_Border * border)
{
- ImlibImage *im;
+ ImlibImage *im;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_image_get_border", "image", ctx->image);
CHECK_PARAM_POINTER("imlib_image_get_border", "border", border);
CAST_IMAGE(im, ctx->image);
@@ -962,9 +1036,10 @@ imlib_image_get_border(Imlib_Border * border)
void
imlib_image_set_border(Imlib_Border * border)
{
- ImlibImage *im;
+ ImlibImage *im;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_image_set_border", "image", ctx->image);
CHECK_PARAM_POINTER("imlib_image_set_border", "border", border);
CAST_IMAGE(im, ctx->image);
@@ -983,9 +1058,10 @@ imlib_image_set_border(Imlib_Border * border)
void
imlib_image_set_format(const char *format)
{
- ImlibImage *im;
+ ImlibImage *im;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_image_set_format", "image", ctx->image);
CHECK_PARAM_POINTER("imlib_image_set_format", "format", format);
CAST_IMAGE(im, ctx->image);
@@ -993,80 +1069,82 @@ imlib_image_set_format(const char *format)
free(im->format);
if (format)
im->format = strdup(format);
- else
+ else
im->format = NULL;
if (!(im->flags & F_FORMAT_IRRELEVANT))
- {
- __imlib_DirtyImage(im);
- __imlib_DirtyPixmapsForImage(im);
- }
+ {
+ __imlib_DirtyImage(im);
+ __imlib_DirtyPixmapsForImage(im);
+ }
}
void
imlib_image_set_irrelevant_format(char irrelevant)
{
- ImlibImage *im;
+ ImlibImage *im;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_image_set_irrelevant_format", "image",
ctx->image);
CAST_IMAGE(im, ctx->image);
if (irrelevant)
- {
- SET_FLAG(im->flags, F_FORMAT_IRRELEVANT);
- }
+ {
+ SET_FLAG(im->flags, F_FORMAT_IRRELEVANT);
+ }
else
- {
- UNSET_FLAG(im->flags, F_FORMAT_IRRELEVANT);
- }
+ {
+ UNSET_FLAG(im->flags, F_FORMAT_IRRELEVANT);
+ }
}
void
imlib_image_set_irrelevant_border(char irrelevant)
{
- ImlibImage *im;
+ ImlibImage *im;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_image_set_irrelevant_border", "image",
ctx->image);
CAST_IMAGE(im, ctx->image);
if (irrelevant)
- {
- SET_FLAG(im->flags, F_BORDER_IRRELEVANT);
- }
+ {
+ SET_FLAG(im->flags, F_BORDER_IRRELEVANT);
+ }
else
- {
- UNSET_FLAG(im->flags, F_BORDER_IRRELEVANT);
- }
+ {
+ UNSET_FLAG(im->flags, F_BORDER_IRRELEVANT);
+ }
}
void
imlib_image_set_irrelevant_alpha(char irrelevant)
{
- ImlibImage *im;
+ ImlibImage *im;
- if (!ctx) ctx = imlib_context_new();
- CHECK_PARAM_POINTER("imlib_image_set_irrelevant_alpha", "image",
- ctx->image);
+ if (!ctx)
+ ctx = imlib_context_new();
+ CHECK_PARAM_POINTER("imlib_image_set_irrelevant_alpha", "image", ctx->image);
CAST_IMAGE(im, ctx->image);
if (irrelevant)
- {
- SET_FLAG(im->flags, F_ALPHA_IRRELEVANT);
- }
+ {
+ SET_FLAG(im->flags, F_ALPHA_IRRELEVANT);
+ }
else
- {
- UNSET_FLAG(im->flags, F_ALPHA_IRRELEVANT);
- }
+ {
+ UNSET_FLAG(im->flags, F_ALPHA_IRRELEVANT);
+ }
}
-char *
+char *
imlib_image_format(void)
{
- ImlibImage *im;
+ ImlibImage *im;
- if (!ctx) ctx = imlib_context_new();
- CHECK_PARAM_POINTER_RETURN("imlib_image_format", "image", ctx->image,
- NULL);
+ if (!ctx)
+ ctx = imlib_context_new();
+ CHECK_PARAM_POINTER_RETURN("imlib_image_format", "image", ctx->image, NULL);
CAST_IMAGE(im, ctx->image);
return im->format;
}
@@ -1074,9 +1152,10 @@ imlib_image_format(void)
void
imlib_image_set_has_alpha(char has_alpha)
{
- ImlibImage *im;
+ ImlibImage *im;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_image_set_has_alpha", "image", ctx->image);
CAST_IMAGE(im, ctx->image);
if (has_alpha)
@@ -1090,9 +1169,10 @@ void
imlib_render_pixmaps_for_whole_image(Pixmap * pixmap_return,
Pixmap * mask_return)
{
- ImlibImage *im;
+ ImlibImage *im;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_render_pixmaps_for_whole_image", "image",
ctx->image);
CHECK_PARAM_POINTER("imlib_render_pixmaps_for_whole_image",
@@ -1116,9 +1196,10 @@ imlib_render_pixmaps_for_whole_image_at_size(Pixmap * pixmap_return,
Pixmap * mask_return, int width,
int height)
{
- ImlibImage *im;
+ ImlibImage *im;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_render_pixmaps_for_whole_image_at_size",
"image", ctx->image);
CHECK_PARAM_POINTER("imlib_render_pixmaps_for_whole_image_at_size",
@@ -1141,16 +1222,18 @@ imlib_render_pixmaps_for_whole_image_at_size(Pixmap * pixmap_return,
void
imlib_free_pixmap_and_mask(Pixmap pixmap)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
__imlib_FreePixmap(ctx->display, pixmap);
}
void
imlib_render_image_on_drawable(int x, int y)
{
- ImlibImage *im;
+ ImlibImage *im;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_render_image_on_drawable", "image", ctx->image);
CAST_IMAGE(im, ctx->image);
if ((!(im->data)) && (im->loader) && (im->loader->load))
@@ -1166,9 +1249,10 @@ imlib_render_image_on_drawable(int x, int y)
void
imlib_render_image_on_drawable_at_size(int x, int y, int width, int height)
{
- ImlibImage *im;
+ ImlibImage *im;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_render_image_on_drawable_at_size", "image",
ctx->image);
CAST_IMAGE(im, ctx->image);
@@ -1189,9 +1273,10 @@ imlib_render_image_part_on_drawable_at_size(int source_x, int source_y,
int source_height, int x, int y,
int width, int height)
{
- ImlibImage *im;
+ ImlibImage *im;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_render_image_part_on_drawable_at_size", "image",
ctx->image);
CAST_IMAGE(im, ctx->image);
@@ -1209,11 +1294,13 @@ imlib_render_image_part_on_drawable_at_size(int source_x, int source_y,
DATA32
imlib_render_get_pixel_color(void)
{
- if (!ctx) ctx = imlib_context_new();
- return __imlib_RenderGetPixel(ctx->display, ctx->drawable, ctx->visual, ctx->colormap, ctx->depth,
- (DATA8)ctx->color.red,
- (DATA8)ctx->color.green,
- (DATA8)ctx->color.blue);
+ if (!ctx)
+ ctx = imlib_context_new();
+ return __imlib_RenderGetPixel(ctx->display, ctx->drawable, ctx->visual,
+ ctx->colormap, ctx->depth,
+ (DATA8) ctx->color.red,
+ (DATA8) ctx->color.green,
+ (DATA8) ctx->color.blue);
}
#endif
@@ -1225,10 +1312,11 @@ imlib_blend_image_onto_image(Imlib_Image source_image, char merge_alpha,
int destination_y, int destination_width,
int destination_height)
{
- ImlibImage *im_src, *im_dst;
- int aa;
-
- if (!ctx) ctx = imlib_context_new();
+ ImlibImage *im_src, *im_dst;
+ int aa;
+
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_blend_image_onto_image", "source_image",
source_image);
CHECK_PARAM_POINTER("imlib_blend_image_onto_image", "image", ctx->image);
@@ -1247,22 +1335,24 @@ imlib_blend_image_onto_image(Imlib_Image source_image, char merge_alpha,
/* FIXME: hack to get around infinite loops for scaling down too far */
aa = ctx->anti_alias;
if ((abs(destination_width) < (source_width >> 7))
- || (abs(destination_height) < (source_height >> 7))) aa = 0;
+ || (abs(destination_height) < (source_height >> 7)))
+ aa = 0;
__imlib_BlendImageToImage(im_src, im_dst, aa, ctx->blend,
- merge_alpha, source_x, source_y, source_width,
- source_height, destination_x, destination_y,
- destination_width, destination_height,
- ctx->color_modifier, ctx->operation,
- ctx->cliprect.x, ctx->cliprect.y,
- ctx->cliprect.w, ctx->cliprect.h);
+ merge_alpha, source_x, source_y, source_width,
+ source_height, destination_x, destination_y,
+ destination_width, destination_height,
+ ctx->color_modifier, ctx->operation,
+ ctx->cliprect.x, ctx->cliprect.y,
+ ctx->cliprect.w, ctx->cliprect.h);
}
Imlib_Image
imlib_create_image(int width, int height)
{
- DATA32 *data;
+ DATA32 *data;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
if ((width <= 0) || (height <= 0))
return NULL;
data = malloc(width * height * sizeof(DATA32));
@@ -1274,9 +1364,10 @@ imlib_create_image(int width, int height)
Imlib_Image
imlib_create_image_using_data(int width, int height, DATA32 * data)
{
- ImlibImage *im;
+ ImlibImage *im;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER_RETURN("imlib_create_image_using_data", "data", data,
NULL);
if ((width <= 0) || (height <= 0))
@@ -1290,9 +1381,10 @@ imlib_create_image_using_data(int width, int height, DATA32 * data)
Imlib_Image
imlib_create_image_using_copied_data(int width, int height, DATA32 * data)
{
- ImlibImage *im;
+ ImlibImage *im;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER_RETURN("imlib_create_image_using_copied_data", "data",
data, NULL);
if ((width <= 0) || (height <= 0))
@@ -1302,10 +1394,10 @@ imlib_create_image_using_copied_data(int width, int height, DATA32 * data)
return NULL;
im->data = malloc(width * height * sizeof(DATA32));
if (data)
- {
- memcpy(im->data, data, width * height * sizeof(DATA32));
- return (Imlib_Image) im;
- }
+ {
+ memcpy(im->data, data, width * height * sizeof(DATA32));
+ return (Imlib_Image) im;
+ }
else
__imlib_FreeImage(im);
return NULL;
@@ -1316,10 +1408,11 @@ Imlib_Image
imlib_create_image_from_drawable(Pixmap mask, int x, int y, int width,
int height, char need_to_grab_x)
{
- ImlibImage *im;
- char domask = 0;
+ ImlibImage *im;
+ char domask = 0;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
if (mask)
domask = 1;
im = __imlib_CreateImage(width, height, NULL);
@@ -1332,21 +1425,21 @@ imlib_create_image_from_drawable(Pixmap mask, int x, int y, int width,
}
Imlib_Image
-imlib_create_image_from_ximage(XImage *image, XImage *mask, int x, int y, int width,
- int height, char need_to_grab_x)
+imlib_create_image_from_ximage(XImage * image, XImage * mask, int x, int y,
+ int width, int height, char need_to_grab_x)
{
- ImlibImage *im;
- char domask = 0;
+ ImlibImage *im;
+ char domask = 0;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
if (mask)
domask = 1;
im = __imlib_CreateImage(width, height, NULL);
im->data = malloc(width * height * sizeof(DATA32));
__imlib_GrabXImageToRGBA(im->data, 0, 0, width, height,
- ctx->display, image, mask, ctx->visual,
- ctx->depth, x, y,
- width, height, need_to_grab_x);
+ ctx->display, image, mask, ctx->visual,
+ ctx->depth, x, y, width, height, need_to_grab_x);
return (Imlib_Image) im;
}
@@ -1359,73 +1452,72 @@ imlib_create_scaled_image_from_drawable(Pixmap mask, int source_x,
char need_to_grab_x,
char get_mask_from_shape)
{
- ImlibImage *im;
- char domask = 0, tmpmask = 0;
- int x, xx;
- XGCValues gcv;
- GC gc = 0, mgc = 0;
- Pixmap p, m;
+ ImlibImage *im;
+ char domask = 0, tmpmask = 0;
+ int x, xx;
+ XGCValues gcv;
+ GC gc = 0, mgc = 0;
+ Pixmap p, m;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
if ((mask) || (get_mask_from_shape))
domask = 1;
- p =
- XCreatePixmap(ctx->display, ctx->drawable, destination_width,
- source_height, ctx->depth);
+ p = XCreatePixmap(ctx->display, ctx->drawable, destination_width,
+ source_height, ctx->depth);
gcv.foreground = 0;
gcv.subwindow_mode = IncludeInferiors;
if (domask)
- {
- m =
- XCreatePixmap(ctx->display, ctx->drawable, destination_width,
- source_height, 1);
- mgc = XCreateGC(ctx->display, m, GCForeground, &gcv);
- }
+ {
+ m = XCreatePixmap(ctx->display, ctx->drawable, destination_width,
+ source_height, 1);
+ mgc = XCreateGC(ctx->display, m, GCForeground, &gcv);
+ }
else
m = None;
gc = XCreateGC(ctx->display, ctx->drawable, GCSubwindowMode, &gcv);
if ((domask) && (!mask))
- {
- XRectangle *rect;
- int rect_num, rect_ord;
-
- tmpmask = 1;
- mask =
- XCreatePixmap(ctx->display, ctx->drawable, source_width,
- source_height, 1);
- rect =
- XShapeGetRectangles(ctx->display, ctx->drawable, ShapeBounding,
- &rect_num, &rect_ord);
- XFillRectangle(ctx->display, mask, mgc, 0, 0, source_width,
- source_height);
- if (rect)
- {
- XSetForeground(ctx->display, mgc, 1);
- for (x = 0; x < rect_num; x++)
- XFillRectangle(ctx->display, mask, mgc, rect[x].x, rect[x].y,
- rect[x].width, rect[x].height);
- XFree(rect);
- }
- /* build mask from window shape rects */
- }
+ {
+ XRectangle *rect;
+ int rect_num, rect_ord;
+
+ tmpmask = 1;
+ mask =
+ XCreatePixmap(ctx->display, ctx->drawable, source_width,
+ source_height, 1);
+ rect =
+ XShapeGetRectangles(ctx->display, ctx->drawable, ShapeBounding,
+ &rect_num, &rect_ord);
+ XFillRectangle(ctx->display, mask, mgc, 0, 0, source_width,
+ source_height);
+ if (rect)
+ {
+ XSetForeground(ctx->display, mgc, 1);
+ for (x = 0; x < rect_num; x++)
+ XFillRectangle(ctx->display, mask, mgc, rect[x].x, rect[x].y,
+ rect[x].width, rect[x].height);
+ XFree(rect);
+ }
+ /* build mask from window shape rects */
+ }
for (x = 0; x < destination_width; x++)
- {
- xx = (source_width * x) / destination_width;
- XCopyArea(ctx->display, ctx->drawable, p, gc, source_x + xx, 0, 1,
- source_height, xx, 0);
- if (m != None)
- XCopyArea(ctx->display, mask, m, mgc, xx, 0, 1, source_height, xx,
- 0);
- }
+ {
+ xx = (source_width * x) / destination_width;
+ XCopyArea(ctx->display, ctx->drawable, p, gc, source_x + xx, 0, 1,
+ source_height, xx, 0);
+ if (m != None)
+ XCopyArea(ctx->display, mask, m, mgc, xx, 0, 1, source_height, xx,
+ 0);
+ }
for (x = 0; x < destination_height; x++)
- {
- xx = (source_height * x) / destination_height;
- XCopyArea(ctx->display, ctx->drawable, p, gc, 0, source_y + xx,
- destination_width, 1, 0, xx);
- if (m != None)
- XCopyArea(ctx->display, mask, m, mgc, 0, source_y + xx,
- destination_width, 1, 0, xx);
- }
+ {
+ xx = (source_height * x) / destination_height;
+ XCopyArea(ctx->display, ctx->drawable, p, gc, 0, source_y + xx,
+ destination_width, 1, 0, xx);
+ if (m != None)
+ XCopyArea(ctx->display, mask, m, mgc, 0, source_y + xx,
+ destination_width, 1, 0, xx);
+ }
im = __imlib_CreateImage(destination_width, destination_height, NULL);
im->data = malloc(destination_width * destination_height * sizeof(DATA32));
__imlib_GrabDrawableToRGBA(im->data, 0, 0, destination_width,
@@ -1435,12 +1527,12 @@ imlib_create_scaled_image_from_drawable(Pixmap mask, int source_x,
need_to_grab_x);
XFreePixmap(ctx->display, p);
if (m != None)
- {
- XFreeGC(ctx->display, mgc);
- XFreePixmap(ctx->display, m);
- if (tmpmask)
- XFreePixmap(ctx->display, mask);
- }
+ {
+ XFreeGC(ctx->display, mgc);
+ XFreePixmap(ctx->display, m);
+ if (tmpmask)
+ XFreePixmap(ctx->display, mask);
+ }
XFreeGC(ctx->display, gc);
return (Imlib_Image) im;
}
@@ -1450,11 +1542,12 @@ imlib_copy_drawable_to_image(Pixmap mask, int x, int y, int width, int height,
int destination_x, int destination_y,
char need_to_grab_x)
{
- ImlibImage *im;
- char domask = 0;
- int pre_adj;
+ ImlibImage *im;
+ char domask = 0;
+ int pre_adj;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER_RETURN("imlib_copy_drawable_to_image", "image",
ctx->image, 0);
if (mask)
@@ -1468,37 +1561,37 @@ imlib_copy_drawable_to_image(Pixmap mask, int x, int y, int width, int height,
pre_adj = 0;
if (x < 0)
- {
- width += x;
- pre_adj = x;
- x = 0;
- }
+ {
+ width += x;
+ pre_adj = x;
+ x = 0;
+ }
if (width < 0)
width = 0;
if (destination_x < 0)
- {
- width += destination_x;
- x -= destination_x - pre_adj;
- destination_x = 0;
- }
+ {
+ width += destination_x;
+ x -= destination_x - pre_adj;
+ destination_x = 0;
+ }
if ((destination_x + width) >= im->w)
width = im->w - destination_x;
pre_adj = 0;
if (y < 0)
- {
- height += y;
- pre_adj = y;
- y = 0;
- }
+ {
+ height += y;
+ pre_adj = y;
+ y = 0;
+ }
if (height < 0)
height = 0;
if (destination_y < 0)
- {
- height += destination_y;
- y -= destination_y - pre_adj;
- destination_y = 0;
- }
+ {
+ height += destination_y;
+ y -= destination_y - pre_adj;
+ destination_y = 0;
+ }
if ((destination_y + height) >= im->h)
height = im->h - destination_y;
@@ -1517,9 +1610,10 @@ imlib_copy_drawable_to_image(Pixmap mask, int x, int y, int width, int height,
Imlib_Image
imlib_clone_image(void)
{
- ImlibImage *im, *im_old;
+ ImlibImage *im, *im_old;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER_RETURN("imlib_clone_image", "image", ctx->image, NULL);
CAST_IMAGE(im_old, ctx->image);
if ((!(im_old->data)) && (im_old->loader) && (im_old->loader->load))
@@ -1531,10 +1625,10 @@ imlib_clone_image(void)
return NULL;
im->data = malloc(im->w * im->h * sizeof(DATA32));
if (!(im->data))
- {
- __imlib_FreeImage(im);
- return NULL;
- }
+ {
+ __imlib_FreeImage(im);
+ return NULL;
+ }
memcpy(im->data, im_old->data, im->w * im->h * sizeof(DATA32));
im->flags = im_old->flags;
SET_FLAG(im->flags, F_UNCACHEABLE);
@@ -1542,24 +1636,25 @@ imlib_clone_image(void)
im->border = im_old->border;
im->loader = im_old->loader;
if (im_old->format)
- {
- im->format = malloc(strlen(im_old->format) + 1);
- strcpy(im->format, im_old->format);
- }
+ {
+ im->format = malloc(strlen(im_old->format) + 1);
+ strcpy(im->format, im_old->format);
+ }
if (im_old->file)
- {
- im->file = malloc(strlen(im_old->file) + 1);
- strcpy(im->file, im_old->file);
- }
+ {
+ im->file = malloc(strlen(im_old->file) + 1);
+ strcpy(im->file, im_old->file);
+ }
return (Imlib_Image) im;
}
Imlib_Image
imlib_create_cropped_image(int x, int y, int width, int height)
{
- ImlibImage *im, *im_old;
+ ImlibImage *im, *im_old;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER_RETURN("imlib_create_cropped_image", "image",
ctx->image, NULL);
CAST_IMAGE(im_old, ctx->image);
@@ -1570,27 +1665,27 @@ imlib_create_cropped_image(int x, int y, int width, int height)
im = __imlib_CreateImage(abs(width), abs(height), NULL);
im->data = malloc(abs(width * height) * sizeof(DATA32));
if (!(im->data))
- {
- __imlib_FreeImage(im);
- return NULL;
- }
+ {
+ __imlib_FreeImage(im);
+ return NULL;
+ }
__imlib_BlendImageToImage(im_old, im, 0, 0, 0, x, y, abs(width),
abs(height), 0, 0, width, height, NULL,
IMLIB_OP_COPY,
- ctx->cliprect.x, ctx->cliprect.y,
- ctx->cliprect.w, ctx->cliprect.h);
+ ctx->cliprect.x, ctx->cliprect.y,
+ ctx->cliprect.w, ctx->cliprect.h);
return (Imlib_Image) im;
}
Imlib_Image
imlib_create_cropped_scaled_image(int source_x, int source_y,
int source_width, int source_height,
- int destination_width,
- int destination_height)
+ int destination_width, int destination_height)
{
- ImlibImage *im, *im_old;
+ ImlibImage *im, *im_old;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER_RETURN("imlib_create_cropped_scaled_image", "image",
ctx->image, NULL);
CAST_IMAGE(im_old, ctx->image);
@@ -1598,44 +1693,44 @@ imlib_create_cropped_scaled_image(int source_x, int source_y,
im_old->loader->load(im_old, NULL, 0, 1);
if (!(im_old->data))
return NULL;
- im =
- __imlib_CreateImage(abs(destination_width), abs(destination_height),
- NULL);
+ im = __imlib_CreateImage(abs(destination_width), abs(destination_height),
+ NULL);
im->data =
- malloc(abs(destination_width * destination_height) * sizeof(DATA32));
+ malloc(abs(destination_width * destination_height) * sizeof(DATA32));
if (!(im->data))
- {
- __imlib_FreeImage(im);
- return NULL;
- }
+ {
+ __imlib_FreeImage(im);
+ return NULL;
+ }
if (IMAGE_HAS_ALPHA(im_old))
- {
- SET_FLAG(im->flags, F_HAS_ALPHA);
- __imlib_BlendImageToImage(im_old, im, ctx->anti_alias, 0, 1, source_x,
- source_y, source_width, source_height, 0, 0,
- destination_width, destination_height, NULL,
- IMLIB_OP_COPY,
- ctx->cliprect.x, ctx->cliprect.y,
- ctx->cliprect.w, ctx->cliprect.h);
- }
+ {
+ SET_FLAG(im->flags, F_HAS_ALPHA);
+ __imlib_BlendImageToImage(im_old, im, ctx->anti_alias, 0, 1, source_x,
+ source_y, source_width, source_height, 0, 0,
+ destination_width, destination_height, NULL,
+ IMLIB_OP_COPY,
+ ctx->cliprect.x, ctx->cliprect.y,
+ ctx->cliprect.w, ctx->cliprect.h);
+ }
else
- {
- __imlib_BlendImageToImage(im_old, im, ctx->anti_alias, 0, 0, source_x,
- source_y, source_width, source_height, 0, 0,
- destination_width, destination_height, NULL,
- IMLIB_OP_COPY,
- ctx->cliprect.x, ctx->cliprect.y,
- ctx->cliprect.w, ctx->cliprect.h);
- }
+ {
+ __imlib_BlendImageToImage(im_old, im, ctx->anti_alias, 0, 0, source_x,
+ source_y, source_width, source_height, 0, 0,
+ destination_width, destination_height, NULL,
+ IMLIB_OP_COPY,
+ ctx->cliprect.x, ctx->cliprect.y,
+ ctx->cliprect.w, ctx->cliprect.h);
+ }
return (Imlib_Image) im;
}
Imlib_Updates
imlib_updates_clone(Imlib_Updates updates)
{
- ImlibUpdate *u;
+ ImlibUpdate *u;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
u = (ImlibUpdate *) updates;
return (Imlib_Updates) __imlib_DupUpdates(u);
}
@@ -1643,9 +1738,10 @@ imlib_updates_clone(Imlib_Updates updates)
Imlib_Updates
imlib_update_append_rect(Imlib_Updates updates, int x, int y, int w, int h)
{
- ImlibUpdate *u;
+ ImlibUpdate *u;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
u = (ImlibUpdate *) updates;
return (Imlib_Updates) __imlib_AddUpdate(u, x, y, w, h);
}
@@ -1653,9 +1749,10 @@ imlib_update_append_rect(Imlib_Updates updates, int x, int y, int w, int h)
Imlib_Updates
imlib_updates_merge(Imlib_Updates updates, int w, int h)
{
- ImlibUpdate *u;
+ ImlibUpdate *u;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
u = (ImlibUpdate *) updates;
return (Imlib_Updates) __imlib_MergeUpdate(u, w, h, 0);
}
@@ -1663,9 +1760,10 @@ imlib_updates_merge(Imlib_Updates updates, int w, int h)
Imlib_Updates
imlib_updates_merge_for_rendering(Imlib_Updates updates, int w, int h)
{
- ImlibUpdate *u;
+ ImlibUpdate *u;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
u = (ImlibUpdate *) updates;
return (Imlib_Updates) __imlib_MergeUpdate(u, w, h, 3);
}
@@ -1673,9 +1771,10 @@ imlib_updates_merge_for_rendering(Imlib_Updates updates, int w, int h)
void
imlib_updates_free(Imlib_Updates updates)
{
- ImlibUpdate *u;
+ ImlibUpdate *u;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
u = (ImlibUpdate *) updates;
__imlib_FreeUpdates(u);
}
@@ -1683,9 +1782,10 @@ imlib_updates_free(Imlib_Updates updates)
Imlib_Updates
imlib_updates_get_next(Imlib_Updates updates)
{
- ImlibUpdate *u;
+ ImlibUpdate *u;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
u = (ImlibUpdate *) updates;
return (Imlib_Updates) (u->next);
}
@@ -1695,9 +1795,10 @@ imlib_updates_get_coordinates(Imlib_Updates updates, int *x_return,
int *y_return, int *width_return,
int *height_return)
{
- ImlibUpdate *u;
+ ImlibUpdate *u;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_updates_get_coordinates", "updates", updates);
u = (ImlibUpdate *) updates;
if (x_return)
@@ -1714,9 +1815,10 @@ void
imlib_updates_set_coordinates(Imlib_Updates updates, int x, int y, int width,
int height)
{
- ImlibUpdate *u;
+ ImlibUpdate *u;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_updates_set_coordinates", "updates", updates);
u = (ImlibUpdate *) updates;
u->x = x;
@@ -1729,10 +1831,11 @@ imlib_updates_set_coordinates(Imlib_Updates updates, int x, int y, int width,
void
imlib_render_image_updates_on_drawable(Imlib_Updates updates, int x, int y)
{
- ImlibUpdate *u;
- ImlibImage *im;
+ ImlibUpdate *u;
+ ImlibImage *im;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_render_image_updates_on_drawable", "image",
ctx->image);
CAST_IMAGE(im, ctx->image);
@@ -1745,12 +1848,12 @@ imlib_render_image_updates_on_drawable(Imlib_Updates updates, int x, int y)
return;
__imlib_SetMaxXImageCount(ctx->display, 10);
for (; u; u = u->next)
- {
- __imlib_RenderImage(ctx->display, im, ctx->drawable, 0, ctx->visual,
- ctx->colormap, ctx->depth, u->x, u->y, u->w, u->h,
- x + u->x, y + u->y, u->w, u->h, 0, ctx->dither, 0,
- 0, ctx->color_modifier, OP_COPY);
- }
+ {
+ __imlib_RenderImage(ctx->display, im, ctx->drawable, 0, ctx->visual,
+ ctx->colormap, ctx->depth, u->x, u->y, u->w, u->h,
+ x + u->x, y + u->y, u->w, u->h, 0, ctx->dither, 0,
+ 0, ctx->color_modifier, OP_COPY);
+ }
__imlib_SetMaxXImageCount(ctx->display, 0);
}
#endif
@@ -1758,7 +1861,8 @@ imlib_render_image_updates_on_drawable(Imlib_Updates updates, int x, int y)
Imlib_Updates
imlib_updates_init(void)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
return (Imlib_Updates) NULL;
}
@@ -1766,9 +1870,10 @@ Imlib_Updates
imlib_updates_append_updates(Imlib_Updates updates,
Imlib_Updates appended_updates)
{
- ImlibUpdate *u, *uu;
+ ImlibUpdate *u, *uu;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
u = (ImlibUpdate *) updates;
uu = (ImlibUpdate *) appended_updates;
if (!uu)
@@ -1776,23 +1881,24 @@ imlib_updates_append_updates(Imlib_Updates updates,
if (!u)
return (Imlib_Updates) uu;
while (u)
- {
- if (!(u->next))
- {
- u->next = uu;
- return updates;
- }
- u = u->next;
- }
+ {
+ if (!(u->next))
+ {
+ u->next = uu;
+ return updates;
+ }
+ u = u->next;
+ }
return (Imlib_Updates) u;
}
void
imlib_image_flip_horizontal(void)
{
- ImlibImage *im;
+ ImlibImage *im;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_image_flip_horizontal", "image", ctx->image);
CAST_IMAGE(im, ctx->image);
if ((!(im->data)) && (im->loader) && (im->loader->load))
@@ -1807,9 +1913,10 @@ imlib_image_flip_horizontal(void)
void
imlib_image_flip_vertical(void)
{
- ImlibImage *im;
+ ImlibImage *im;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_image_flip_vertical", "image", ctx->image);
CAST_IMAGE(im, ctx->image);
if ((!(im->data)) && (im->loader) && (im->loader->load))
@@ -1824,9 +1931,10 @@ imlib_image_flip_vertical(void)
void
imlib_image_flip_diagonal(void)
{
- ImlibImage *im;
+ ImlibImage *im;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_image_flip_diagonal", "image", ctx->image);
CAST_IMAGE(im, ctx->image);
if ((!(im->data)) && (im->loader) && (im->loader->load))
@@ -1841,9 +1949,10 @@ imlib_image_flip_diagonal(void)
void
imlib_image_orientate(int orientation)
{
- ImlibImage *im;
+ ImlibImage *im;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_image_orientate", "image", ctx->image);
CAST_IMAGE(im, ctx->image);
if ((!(im->data)) && (im->loader) && (im->loader->load))
@@ -1853,40 +1962,41 @@ imlib_image_orientate(int orientation)
__imlib_DirtyImage(im);
__imlib_DirtyPixmapsForImage(im);
switch (orientation)
- {
- default:
- case 0:
- break;
- case 1:
- __imlib_FlipImageDiagonal(im, 1);
- break;
- case 2:
- __imlib_FlipImageBoth(im);
- break;
- case 3:
- __imlib_FlipImageDiagonal(im, 2);
- break;
- case 4:
- __imlib_FlipImageHoriz(im);
- break;
- case 5:
- __imlib_FlipImageDiagonal(im, 3);
- break;
- case 6:
- __imlib_FlipImageVert(im);
- break;
- case 7:
- __imlib_FlipImageDiagonal(im, 0);
- break;
- }
+ {
+ default:
+ case 0:
+ break;
+ case 1:
+ __imlib_FlipImageDiagonal(im, 1);
+ break;
+ case 2:
+ __imlib_FlipImageBoth(im);
+ break;
+ case 3:
+ __imlib_FlipImageDiagonal(im, 2);
+ break;
+ case 4:
+ __imlib_FlipImageHoriz(im);
+ break;
+ case 5:
+ __imlib_FlipImageDiagonal(im, 3);
+ break;
+ case 6:
+ __imlib_FlipImageVert(im);
+ break;
+ case 7:
+ __imlib_FlipImageDiagonal(im, 0);
+ break;
+ }
}
void
imlib_image_blur(int radius)
{
- ImlibImage *im;
+ ImlibImage *im;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_image_blur", "image", ctx->image);
CAST_IMAGE(im, ctx->image);
if ((!(im->data)) && (im->loader) && (im->loader->load))
@@ -1901,9 +2011,10 @@ imlib_image_blur(int radius)
void
imlib_image_sharpen(int radius)
{
- ImlibImage *im;
+ ImlibImage *im;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CAST_IMAGE(im, ctx->image);
CHECK_PARAM_POINTER("imlib_image_sharpen", "image", ctx->image);
if ((!(im->data)) && (im->loader) && (im->loader->load))
@@ -1918,9 +2029,10 @@ imlib_image_sharpen(int radius)
void
imlib_image_tile_horizontal(void)
{
- ImlibImage *im;
+ ImlibImage *im;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_image_tile_horizontal", "image", ctx->image);
CAST_IMAGE(im, ctx->image);
if ((!(im->data)) && (im->loader) && (im->loader->load))
@@ -1935,9 +2047,10 @@ imlib_image_tile_horizontal(void)
void
imlib_image_tile_vertical(void)
{
- ImlibImage *im;
+ ImlibImage *im;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_image_tile_vertical", "image", ctx->image);
CAST_IMAGE(im, ctx->image);
if ((!(im->data)) && (im->loader) && (im->loader->load))
@@ -1952,9 +2065,10 @@ imlib_image_tile_vertical(void)
void
imlib_image_tile(void)
{
- ImlibImage *im;
+ ImlibImage *im;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_image_tile", "image", ctx->image);
CAST_IMAGE(im, ctx->image);
if ((!(im->data)) && (im->loader) && (im->loader->load))
@@ -1970,158 +2084,25 @@ imlib_image_tile(void)
Imlib_Font
imlib_load_font(const char *font_name)
{
- ImlibFont *fn;
- ImlibXFontSet *xf;
- char *ttfname, *xfontsetname;
- int mode;
-
- if (!ctx) ctx = imlib_context_new();
- if (!font_name || *font_name == '\0')
- return NULL;
-
- /* split fontset name */
- xfontsetname = NULL;
- ttfname = strdup(font_name);
- if (!strchr(font_name, '/') ||
- (strchr(font_name, '/') && strchr(font_name, ',')))
- {
- char *p, *mp;
-
- xfontsetname = malloc((strlen(font_name) + 1) * sizeof(char));
-
- if (!ttfname || !xfontsetname )
- {
- if (ttfname) free(ttfname);
- if (xfontsetname) free(xfontsetname);
- return NULL;
- }
-
- *ttfname = *xfontsetname = '\0';
- p = (char *)font_name;
- while (*p)
- {
- int i;
-
- mp = strchr(p, ',');
- if (!mp)
- mp = p + strlen(p);
-
- for (i=0; p+i < mp && p[i] != '/'; i++ );
- if (p[i] == '/')
- {
- strncpy(ttfname, p, mp - p);
- ttfname[mp - p] = '\0';
- }
- else
- {
- if (*xfontsetname)
- strcat(xfontsetname, ",");
- for (i=strlen(xfontsetname); p < mp ; i++, p++)
- xfontsetname[i] = *p;
- xfontsetname[i] = '\0';
- }
-
- p = mp;
- if ( *p == ',' )
- p++;
- }
- }
-
- /* find a cached font */
- mode = 0;
- if (*ttfname)
- mode |= IMLIB_FONT_TYPE_TTF;
- if (xfontsetname && *xfontsetname)
- mode |= IMLIB_FONT_TYPE_X;
-
- fn = __imlib_find_cached_font(ttfname, xfontsetname, mode);
- if (fn)
- {
- /* reference it up by one and return it */
- fn->hdr.references++;
- if (fn->type == IMLIB_FONT_TYPE_TTF_X)
- fn->xf.ttffont->hdr.references++;
-
- if (ttfname) free(ttfname);
- if (xfontsetname) free(xfontsetname);
-
- return fn;
- }
-
- xf = NULL;
- if (mode & IMLIB_FONT_TYPE_X)
- {
- ImlibFont *tf;
-
- /* try to find X font */
- tf = __imlib_find_cached_font(NULL, xfontsetname, IMLIB_FONT_TYPE_X);
- if (tf)
- xf = (ImlibXFontSet *)__imlib_clone_cached_font(tf);
- else
- {
- xf = (ImlibXFontSet *)__imlib_load_xfontset(ctx->display, xfontsetname);
- /* error */
- if (!xf)
- {
- if (ttfname) free(ttfname);
- if (xfontsetname) free(xfontsetname);
- return NULL;
- }
- }
-
- free(xfontsetname);
-
- /* try to find ttf font */
- if (mode & IMLIB_FONT_TYPE_TTF)
- {
- tf = __imlib_find_cached_font(ttfname, NULL, IMLIB_FONT_TYPE_TTF);
- if (tf)
- {
- xf->type = IMLIB_FONT_TYPE_TTF_X;
- xf->ttffont = tf;
- tf->hdr.references++;
- xf->total_ascent = MAX(xf->max_ascent, tf->ttf.max_ascent/64);
- xf->total_descent = MAX(xf->max_descent, -tf->ttf.max_descent/64);
- }
- }
-
- if (!*ttfname || xf->ttffont)
- {
- free(ttfname);
- return (ImlibFont *)xf;
- }
- }
-
- fn = __imlib_load_font(ttfname);
- free(ttfname);
-
- /* set X fontSet */
- if (fn && xf)
- {
- xf->type = IMLIB_FONT_TYPE_TTF_X;
- xf->ttffont = fn;
- xf->total_ascent = MAX(xf->max_ascent, fn->ttf.max_ascent/64);
- xf->total_descent = MAX(xf->max_descent, -fn->ttf.max_descent/64);
- return (ImlibFont *)xf;
- }
-
- return fn;
+ return imlib_font_load_joined(font_name);
}
void
imlib_free_font(void)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_free_font", "font", ctx->font);
- __imlib_free_font(ctx->font);
+ imlib_font_free(ctx->font);
ctx->font = NULL;
}
void
imlib_text_draw(int x, int y, const char *text)
{
- if (!ctx) ctx = imlib_context_new();
- imlib_text_draw_with_return_metrics( x, y, text, NULL, NULL, NULL, NULL);
+ if (!ctx)
+ ctx = imlib_context_new();
+ imlib_text_draw_with_return_metrics(x, y, text, NULL, NULL, NULL, NULL);
}
void
@@ -2130,13 +2111,14 @@ imlib_text_draw_with_return_metrics(int x, int y, const char *text,
int *horizontal_advance_return,
int *vertical_advance_return)
{
- ImlibImage *im;
- ImlibFont *fn;
- char *tt;
- int tx, ty;
- int dir;
+ ImlibImage *im;
+ ImlibFont *fn;
+ char *tt;
+ int tx, ty;
+ int dir;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_text_draw_with_return_metrics", "font",
ctx->font);
CHECK_PARAM_POINTER("imlib_text_draw_with_return_metrics", "image",
@@ -2152,438 +2134,126 @@ imlib_text_draw_with_return_metrics(int x, int y, const char *text,
__imlib_DirtyPixmapsForImage(im);
dir = ctx->direction;
- if ( ctx->direction == IMLIB_TEXT_TO_ANGLE && ctx->angle == 0.0 )
- dir = IMLIB_TEXT_TO_RIGHT;
-
- switch (fn->type)
- {
- case IMLIB_FONT_TYPE_TTF:
- __imlib_render_str(im, fn, x, y, text, (DATA8)ctx->color.red,
- (DATA8)ctx->color.green, (DATA8)ctx->color.blue,
- (DATA8)ctx->color.alpha, (char)dir,
- ctx->angle, width_return, height_return, 0,
- horizontal_advance_return, vertical_advance_return,
- ctx->operation,
- ctx->cliprect.x, ctx->cliprect.y,
- ctx->cliprect.w, ctx->cliprect.h);
- return;
-
- case IMLIB_FONT_TYPE_X:
- __imlib_xfd_draw_str(ctx->display, ctx->drawable, ctx->visual,
- ctx->depth, ctx->colormap, im, fn,
- x, y, text, (DATA8)ctx->color.red,
- (DATA8)ctx->color.green, (DATA8)ctx->color.blue,
- (DATA8)ctx->color.alpha, (char)dir,
- ctx->angle, ctx->blend, ctx->color_modifier,
- ctx->dither, ctx->dither_mask, ctx->operation,
- width_return, height_return,
- horizontal_advance_return, vertical_advance_return,
- ctx->cliprect.x, ctx->cliprect.y,
- ctx->cliprect.w, ctx->cliprect.h);
- return;
-
- case IMLIB_FONT_TYPE_TTF_X:
- {
- char *tmp;
- int i, j, len, oldlen=0;
- int x1, y1, w1, h1, w2, h2;
- int retw, reth, nextx, nexty;
- int dirsave;
-
- w2 = h2 = 0;
- tmp = malloc((strlen(text) + 1) * sizeof(char));
- dirsave = ctx->direction;
- ctx->direction = IMLIB_TEXT_TO_RIGHT;
- imlib_get_text_size(text, &w1, &h1);
- ctx->direction = dirsave;
-
- for (i=0, j=0; i <= strlen(text); i++)
- {
- len = mblen(text+i, MB_CUR_MAX);
- if (len < 0)
- continue;
-
- if ( len == 1 && !isascii(text[i]))
- len = -1;
-
- if ((j && len != oldlen) || i >= strlen(text))
- {
- int ww, hh;
-
- if (oldlen == 1)
- __imlib_calc_advance(fn, &ww, &hh, tmp);
-
- else if (oldlen > 1 || oldlen == -1)
- {
- XRectangle i_ret, l_ret;
-
- XmbTextExtents(fn->xf.xfontset, tmp, strlen(tmp),
- &i_ret, &l_ret);
- ww = l_ret.width;
- hh = l_ret.height;
- }
-
- switch(dir)
- {
- case IMLIB_TEXT_TO_RIGHT:
- x1 = x + w2;
- y1 = y + fn->xf.total_ascent;
- if (oldlen == 1)
- y1 -= fn->xf.ttffont->ttf.max_ascent/64;
- if (oldlen > 1 || oldlen == -1)
- y1 -= fn->xf.max_ascent;
- break;
- case IMLIB_TEXT_TO_LEFT:
- x1 = x + w1 - w2 - ww;
- y1 = y + fn->xf.total_descent;
- if (oldlen == 1)
- y1 -= -fn->xf.ttffont->ttf.max_descent/64;
- if (oldlen > 1 || oldlen == -1)
- y1 -= fn->xf.max_descent;
- break;
- case IMLIB_TEXT_TO_DOWN:
- x1 = x + fn->xf.total_descent;
- if (oldlen == 1)
- x1 -= -fn->xf.ttffont->ttf.max_descent/64;
- if (oldlen > 1 || oldlen == -1)
- x1 -= fn->xf.max_descent;
- y1 = y + h2;
- break;
- case IMLIB_TEXT_TO_UP:
- x1 = x + fn->xf.total_ascent;
- if (oldlen == 1)
- x1 -= fn->xf.ttffont->ttf.max_ascent/64;
- if (oldlen > 1 || oldlen == -1)
- x1 -= fn->xf.max_ascent;
- y1 = y + w1 - h2 - ww;
- break;
- case IMLIB_TEXT_TO_ANGLE:
- { /* However, I cann't make sure these are correct or not. */
- double sa, ca;
-
- sa = sin(ctx->angle);
- ca = cos(ctx->angle);
- x1 = x + w2 * ca;
- if ( sa > 0 )
- y1 = y + w2 * sa;
- else
- y1 = y + (w1 - w2 - ww) * -sa;
-
- y1 += fn->xf.total_descent;
- if (oldlen == 1)
- y1 -= -fn->xf.ttffont->ttf.max_descent/64 * ca;
- if (oldlen > 1 || oldlen == -1)
- y1 -= fn->xf.max_descent * ca;
- }
- break;
- }
-
- if (oldlen == 1)
- __imlib_render_str(im, fn, x1, y1, tmp,
- (DATA8)ctx->color.red,
- (DATA8)ctx->color.green,
- (DATA8)ctx->color.blue,
- (DATA8)ctx->color.alpha,
- (char)dir,
- ctx->angle, &retw, &reth, 0,
- &nextx, &nexty,
- ctx->operation,
- ctx->cliprect.x, ctx->cliprect.y,
- ctx->cliprect.w, ctx->cliprect.h);
-
- else if (oldlen > 1 || oldlen == -1)
- __imlib_xfd_draw_str(ctx->display, ctx->drawable,
- ctx->visual, ctx->depth, ctx->colormap,
- im, fn, x1, y1, tmp,
- (DATA8)ctx->color.red,
- (DATA8)ctx->color.green,
- (DATA8)ctx->color.blue,
- (DATA8)ctx->color.alpha,
- (char)dir, ctx->angle,
- ctx->blend, ctx->color_modifier,
- ctx->dither, ctx->dither_mask,
- ctx->operation,
- &retw, &reth, &nextx, &nexty,
- ctx->cliprect.x, ctx->cliprect.y,
- ctx->cliprect.w, ctx->cliprect.h);
-
-/* #### DEBUG DEBUG DEBUG ####
- __imlib_draw_box(im, x1, y1, retw, reth,
- (DATA8)ctx->color.red,
- (DATA8)ctx->color.green,
- (DATA8)ctx->color.blue,
- (DATA8)ctx->color.alpha,
- ctx->operation);
-
- __imlib_draw_box(im, x1, y1, nextx, nexty,
- (DATA8)ctx->color.red,
- (DATA8)ctx->color.green,
- (DATA8)ctx->color.blue,
- (DATA8)ctx->color.alpha,
- ctx->operation);
-
- printf( "text=%s, x1=%d, y1=%d, retw=%d, reth=%d, w2=%d, ww=%d\n",
- tmp, x1, y1, retw, reth, w2, ww );
-*/
-
- j = 0;
- switch(dir)
- {
- case IMLIB_TEXT_TO_RIGHT:
- case IMLIB_TEXT_TO_LEFT:
- w2 += nextx;
- h2 = nexty;
- break;
- case IMLIB_TEXT_TO_DOWN:
- case IMLIB_TEXT_TO_UP:
- w2 = nextx;
- h2 += nexty;
- break;
- case IMLIB_TEXT_TO_ANGLE:
- w2 += retw;
- h2 = nexty;
- break;
- }
- }
-
- strncpy(tmp+j, text+i, (len == -1) ? 1 : len);
- j += (len == -1) ? 1 : len;
- tmp[j] = '\0';
- if (len > 1)
- i += len - 1;
- oldlen = len;
- }
-
- switch(dir)
- {
- case IMLIB_TEXT_TO_RIGHT:
- case IMLIB_TEXT_TO_LEFT:
- case IMLIB_TEXT_TO_ANGLE:
- if (width_return)
- *width_return = w1;
- if (height_return)
- *height_return = h1;
- if (horizontal_advance_return)
- *horizontal_advance_return = w2;
- if (vertical_advance_return)
- *vertical_advance_return =
- MAX(fn->xf.max_ascent, fn->xf.ttffont->ttf.max_ascent/64) +
- MAX(fn->xf.max_descent, -fn->xf.ttffont->ttf.max_descent/64);
- break;
- case IMLIB_TEXT_TO_DOWN:
- case IMLIB_TEXT_TO_UP:
- if (width_return)
- *width_return = w1;
- if (height_return)
- *height_return = h1;
- if (horizontal_advance_return)
- *horizontal_advance_return =
- MAX(fn->xf.max_ascent, fn->xf.ttffont->ttf.max_ascent/64) +
- MAX(fn->xf.max_descent, -fn->xf.ttffont->ttf.max_descent/64);
- if (vertical_advance_return)
- *vertical_advance_return = h2;
- break;
- }
-
- free(tmp);
- }
- return;
+ if (ctx->direction == IMLIB_TEXT_TO_ANGLE && ctx->angle == 0.0)
+ dir = IMLIB_TEXT_TO_RIGHT;
- default:
- return;
- }
+ imlib_render_str(im, fn, x, y, text, (DATA8) ctx->color.red,
+ (DATA8) ctx->color.green, (DATA8) ctx->color.blue,
+ (DATA8) ctx->color.alpha, (char)dir,
+ ctx->angle, width_return, height_return, 0,
+ horizontal_advance_return, vertical_advance_return,
+ ctx->operation,
+ ctx->cliprect.x, ctx->cliprect.y,
+ ctx->cliprect.w, ctx->cliprect.h);
}
void
imlib_get_text_size(const char *text, int *width_return, int *height_return)
{
- ImlibFont *fn;
- int w, h;
- int dir;
+ ImlibFont *fn;
+ int w, h;
+ int dir;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_get_text_size", "font", ctx->font);
CHECK_PARAM_POINTER("imlib_get_text_size", "text", text);
fn = (ImlibFont *) ctx->font;
dir = ctx->direction;
- if ( ctx->direction == IMLIB_TEXT_TO_ANGLE && ctx->angle == 0.0 )
- dir = IMLIB_TEXT_TO_RIGHT;
+ if (ctx->direction == IMLIB_TEXT_TO_ANGLE && ctx->angle == 0.0)
+ dir = IMLIB_TEXT_TO_RIGHT;
- switch (fn->type)
+ imlib_font_query_size(fn, text, &w, &h);
+
+ switch (dir)
{
- case IMLIB_FONT_TYPE_TTF:
- __imlib_calc_size(fn, &w, &h, text);
- break;
-
- case IMLIB_FONT_TYPE_X:
- {
- XRectangle i_ret, l_ret;
-
- XmbTextExtents(fn->xf.xfontset, text, strlen(text), &i_ret, &l_ret);
- w = l_ret.width;
- /* h = l_ret.height; */
- h = fn->xf.max_ascent + fn->xf.max_descent;
- }
- break;
-
- case IMLIB_FONT_TYPE_TTF_X:
- {
- char *tmp;
- int i, j, len, oldlen=0;
-
- w = h = 0;
- tmp = malloc((strlen(text) + 1) * sizeof(char));
-
- for (i=0, j=0; i <= strlen(text); i++)
- {
- len = mblen(text+i, MB_CUR_MAX);
- if (len < 0)
- continue;
-
- /* if ( len == 1 && !isascii(text[i]) &&
- fn->xf.ttffont->ttf.properties.num_Glyphs < 128) */
- if ( len == 1 && !isascii(text[i]))
- len = -1;
-
- if ((j && len != oldlen) || i >= strlen(text))
- {
- int ww, hh;
-
- if (oldlen == 1)
- {
- ImlibImage im;
-
- im.w = im.h = 0;
- __imlib_render_str(&im, fn, 1, 1, tmp,
- (DATA8)0, (DATA8)0, (DATA8)0, (DATA8)0,
- (char)0, (double)0, NULL, NULL, 0,
- &ww, &hh, 0,
- ctx->cliprect.x, ctx->cliprect.y,
- ctx->cliprect.w, ctx->cliprect.h);
- }
- else if (oldlen > 1 || oldlen == -1)
- {
- XRectangle i_ret, l_ret;
-
- XmbTextExtents(fn->xf.xfontset, tmp, strlen(tmp),
- &i_ret, &l_ret);
- ww = i_ret.width;
- hh = i_ret.height;
- }
-
- j = 0;
- w += ww;
- /* h = MAX(h, hh); */
- }
-
- strncpy(tmp+j, text+i, (len == -1) ? 1 : len);
- j += (len == -1) ? 1 : len;
- tmp[j] = '\0';
- if (len > 1)
- i += len - 1;
- oldlen = len;
- }
-
- h = MAX(fn->xf.max_ascent, fn->xf.ttffont->ttf.max_ascent/64) +
- MAX(fn->xf.max_descent, -fn->xf.ttffont->ttf.max_descent/64);
-
- free(tmp);
- }
- break;
-
- default:
- w = h = 0;
- break;
+ case IMLIB_TEXT_TO_RIGHT:
+ case IMLIB_TEXT_TO_LEFT:
+ if (width_return)
+ *width_return = w;
+ if (height_return)
+ *height_return = h;
+ break;
+ case IMLIB_TEXT_TO_DOWN:
+ case IMLIB_TEXT_TO_UP:
+ if (width_return)
+ *width_return = h;
+ if (height_return)
+ *height_return = w;
+ break;
+ case IMLIB_TEXT_TO_ANGLE:
+ if (width_return || height_return)
+ {
+ double sa, ca;
+
+ sa = sin(ctx->angle);
+ ca = cos(ctx->angle);
+
+ if (width_return)
+ {
+ double x1, x2, xt;
+
+ x1 = x2 = 0.0;
+ xt = ca * w;
+ if (xt < x1)
+ x1 = xt;
+ if (xt > x2)
+ x2 = xt;
+ xt = -(sa * h);
+ if (xt < x1)
+ x1 = xt;
+ if (xt > x2)
+ x2 = xt;
+ xt = ca * w - sa * h;
+ if (xt < x1)
+ x1 = xt;
+ if (xt > x2)
+ x2 = xt;
+ *width_return = (int)(x2 - x1);
+ }
+ if (height_return)
+ {
+ double y1, y2, yt;
+
+ y1 = y2 = 0.0;
+ yt = sa * w;
+ if (yt < y1)
+ y1 = yt;
+ if (yt > y2)
+ y2 = yt;
+ yt = ca * h;
+ if (yt < y1)
+ y1 = yt;
+ if (yt > y2)
+ y2 = yt;
+ yt = sa * w + ca * h;
+ if (yt < y1)
+ y1 = yt;
+ if (yt > y2)
+ y2 = yt;
+ *height_return = (int)(y2 - y1);
+ }
+ }
+ break;
+ default:
+ break;
}
-
- switch(dir)
- {
- case IMLIB_TEXT_TO_RIGHT:
- case IMLIB_TEXT_TO_LEFT:
- if (width_return)
- *width_return = w;
- if (height_return)
- *height_return = h;
- break;
- case IMLIB_TEXT_TO_DOWN:
- case IMLIB_TEXT_TO_UP:
- if (width_return)
- *width_return = h;
- if (height_return)
- *height_return = w;
- break;
- case IMLIB_TEXT_TO_ANGLE:
- if (width_return || height_return)
- {
- double sa, ca;
-
- sa = sin(ctx->angle);
- ca = cos(ctx->angle);
-
- if (width_return)
- {
- double x1, x2, xt;
-
- x1 = x2 = 0.0;
- xt = ca * w;
- if (xt < x1)
- x1 = xt;
- if (xt > x2)
- x2 = xt;
- xt = -(sa * h);
- if (xt < x1)
- x1 = xt;
- if (xt > x2)
- x2 = xt;
- xt = ca * w - sa * h;
- if (xt < x1)
- x1 = xt;
- if (xt > x2)
- x2 = xt;
- *width_return = (int) (x2 - x1);
- }
- if (height_return)
- {
- double y1, y2, yt;
-
- y1 = y2 = 0.0;
- yt = sa * w;
- if (yt < y1)
- y1 = yt;
- if (yt > y2)
- y2 = yt;
- yt = ca * h;
- if (yt < y1)
- y1 = yt;
- if (yt > y2)
- y2 = yt;
- yt = sa * w + ca * h;
- if (yt < y1)
- y1 = yt;
- if (yt > y2)
- y2 = yt;
- *height_return = (int) (y2 - y1);
- }
- }
- break;
- default:
- break;
- }
}
void
imlib_get_text_advance(const char *text, int *horizontal_advance_return,
int *vertical_advance_return)
{
- ImlibFont *fn;
- int w, h;
+ ImlibFont *fn;
+ int w, h;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_get_text_advance", "font", ctx->font);
CHECK_PARAM_POINTER("imlib_get_text_advance", "text", text);
fn = (ImlibFont *) ctx->font;
- __imlib_calc_advance(fn, &w, &h, text);
+ imlib_font_query_advance(fn, text, &w, &h);
if (horizontal_advance_return)
*horizontal_advance_return = w;
if (vertical_advance_return)
@@ -2593,39 +2263,43 @@ imlib_get_text_advance(const char *text, int *horizontal_advance_return,
int
imlib_get_text_inset(const char *text)
{
- ImlibFont *fn;
+ ImlibFont *fn;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER_RETURN("imlib_get_text_advance", "font", ctx->font, 0);
CHECK_PARAM_POINTER_RETURN("imlib_get_text_advance", "text", text, 0);
fn = (ImlibFont *) ctx->font;
- return __imlib_calc_inset(fn, text);
+ return imlib_font_query_inset(fn, text);
}
void
imlib_add_path_to_font_path(const char *path)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_add_path_to_font_path", "path", path);
- if (!__imlib_font_path_exists(path))
- __imlib_add_font_path(path);
+ if (!imlib_font_path_exists(path))
+ imlib_font_add_font_path(path);
}
void
imlib_remove_path_from_font_path(const char *path)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_remove_path_from_font_path", "path", path);
- __imlib_del_font_path(path);
+ imlib_font_del_font_path(path);
}
-char **
+char **
imlib_list_font_path(int *number_return)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER_RETURN("imlib_list_font_path", "number_return",
number_return, NULL);
- return __imlib_list_font_path(number_return);
+ return imlib_font_list_font_path(number_return);
}
int
@@ -2634,11 +2308,12 @@ imlib_text_get_index_and_location(const char *text, int x, int y,
int *char_width_return,
int *char_height_return)
{
- ImlibFont *fn;
- int w, h, cx, cy, cw, ch, cp, xx, yy;
- int dir;
+ ImlibFont *fn;
+ int w, h, cx, cy, cw, ch, cp, xx, yy;
+ int dir;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER_RETURN("imlib_text_get_index_and_location", "font",
ctx->font, -1);
CHECK_PARAM_POINTER_RETURN("imlib_text_get_index_and_location", "text",
@@ -2646,174 +2321,87 @@ imlib_text_get_index_and_location(const char *text, int x, int y,
fn = (ImlibFont *) ctx->font;
dir = ctx->direction;
- if ( ctx->direction == IMLIB_TEXT_TO_ANGLE && ctx->angle == 0.0 )
- dir = IMLIB_TEXT_TO_RIGHT;
+ if (ctx->direction == IMLIB_TEXT_TO_ANGLE && ctx->angle == 0.0)
+ dir = IMLIB_TEXT_TO_RIGHT;
imlib_get_text_size(text, &w, &h);
- switch(dir)
+ switch (dir)
{
- case IMLIB_TEXT_TO_RIGHT:
- xx = x;
- yy = y;
- break;
- case IMLIB_TEXT_TO_LEFT:
- xx = w - x;
- yy = h - y;
- break;
- case IMLIB_TEXT_TO_DOWN:
- xx = y;
- yy = w - x;
- break;
- case IMLIB_TEXT_TO_UP:
- xx = h - y;
- yy = x;
- break;
- default:
- return -1;
+ case IMLIB_TEXT_TO_RIGHT:
+ xx = x;
+ yy = y;
+ break;
+ case IMLIB_TEXT_TO_LEFT:
+ xx = w - x;
+ yy = h - y;
+ break;
+ case IMLIB_TEXT_TO_DOWN:
+ xx = y;
+ yy = w - x;
+ break;
+ case IMLIB_TEXT_TO_UP:
+ xx = h - y;
+ yy = x;
+ break;
+ default:
+ return -1;
}
- switch (fn->type)
+ cp = imlib_font_query_text_at_pos(fn, text, xx, yy, &cx, &cy, &cw, &ch);
+
+ switch (dir)
{
- case IMLIB_FONT_TYPE_TTF:
- cp = __imlib_char_pos(fn, text, xx, yy, &cx, &cy, &cw, &ch);
- break;
-
- case IMLIB_FONT_TYPE_X:
- cp = __imlib_xfd_char_pos(fn, text, xx, yy, &cx, &cy, &cw, &ch);
- break;
-
- case IMLIB_FONT_TYPE_TTF_X:
- {
- char *tmp;
- int i, j;
- int oldp, oldlen, oldx;
-
- tmp = malloc((strlen(text) + 1) * sizeof(char));
-
- cp = -1;
- if ((x < 0) || (x > w) || (y < 0) || (y > h))
- break;
-
- oldp = oldlen = oldx = 0;
- for (i=0, j=0; i <= strlen(text); i++)
- {
- int len;
-
- len = mblen(text+i, MB_CUR_MAX);
- if (len < 0)
- continue;
-
- if ( len == 1 && !isascii(text[i]))
- len = -1;
-
- if ((j && len != oldlen) || i >= strlen(text))
- {
- int ww, hh;
-
- if (oldlen == 1)
- __imlib_calc_size(fn, &ww, &hh, tmp);
-
- else if (oldlen > 1 || oldlen == -1)
- {
- XRectangle i_ret, l_ret;
-
- XmbTextExtents(fn->xf.xfontset, tmp, strlen(tmp),
- &i_ret, &l_ret);
- ww = i_ret.width;
- hh = i_ret.height;
- }
-
- if (xx >= oldx && xx < oldx + ww)
- {
- if (oldlen == 1)
- {
- yy -= fn->xf.total_ascent -
- fn->xf.ttffont->ttf.max_ascent/64;
- cp = __imlib_char_pos(fn, tmp, xx - oldx, yy,
- &cx, &cy, &cw, &ch);
- }
-
- else if (oldlen > 1 || oldlen == -1)
- {
- yy -= fn->xf.total_ascent - fn->xf.max_ascent;
- cp = __imlib_xfd_char_pos(fn, tmp, xx - oldx, yy,
- &cx, &cy, &cw, &ch);
- }
-
- if (cp >= 0)
- cp += oldp;
- cx += oldx;
- break;
- }
- oldx += ww;
- oldp = i;
- j = 0;
- }
- strncpy(tmp+j, text+i, (len == -1) ? 1 : len);
- j += (len == -1) ? 1 : len;
- tmp[j] = '\0';
- if (len > 1)
- i += len - 1;
- oldlen = len;
- }
- free(tmp);
- }
- break;
+ case IMLIB_TEXT_TO_RIGHT:
+ if (char_x_return)
+ *char_x_return = cx;
+ if (char_y_return)
+ *char_y_return = cy;
+ if (char_width_return)
+ *char_width_return = cw;
+ if (char_height_return)
+ *char_height_return = ch;
+ return cp;
+ break;
+ case IMLIB_TEXT_TO_LEFT:
+ cx = 1 + w - cx - cw;
+ if (char_x_return)
+ *char_x_return = cx;
+ if (char_y_return)
+ *char_y_return = cy;
+ if (char_width_return)
+ *char_width_return = cw;
+ if (char_height_return)
+ *char_height_return = ch;
+ return cp;
+ break;
+ case IMLIB_TEXT_TO_DOWN:
+ if (char_x_return)
+ *char_x_return = cy;
+ if (char_y_return)
+ *char_y_return = cx;
+ if (char_width_return)
+ *char_width_return = ch;
+ if (char_height_return)
+ *char_height_return = cw;
+ return cp;
+ break;
+ case IMLIB_TEXT_TO_UP:
+ cy = 1 + h - cy - ch;
+ if (char_x_return)
+ *char_x_return = cy;
+ if (char_y_return)
+ *char_y_return = cx;
+ if (char_width_return)
+ *char_width_return = ch;
+ if (char_height_return)
+ *char_height_return = cw;
+ return cp;
+ break;
+ default:
+ return -1;
+ break;
}
-
- switch(dir)
- {
- case IMLIB_TEXT_TO_RIGHT:
- if (char_x_return)
- *char_x_return = cx;
- if (char_y_return)
- *char_y_return = cy;
- if (char_width_return)
- *char_width_return = cw;
- if (char_height_return)
- *char_height_return = ch;
- return cp;
- break;
- case IMLIB_TEXT_TO_LEFT:
- cx = 1 + w - cx - cw;
- if (char_x_return)
- *char_x_return = cx;
- if (char_y_return)
- *char_y_return = cy;
- if (char_width_return)
- *char_width_return = cw;
- if (char_height_return)
- *char_height_return = ch;
- return cp;
- break;
- case IMLIB_TEXT_TO_DOWN:
- if (char_x_return)
- *char_x_return = cy;
- if (char_y_return)
- *char_y_return = cx;
- if (char_width_return)
- *char_width_return = ch;
- if (char_height_return)
- *char_height_return = cw;
- return cp;
- break;
- case IMLIB_TEXT_TO_UP:
- cy = 1 + h - cy - ch;
- if (char_x_return)
- *char_x_return = cy;
- if (char_y_return)
- *char_y_return = cx;
- if (char_width_return)
- *char_width_return = ch;
- if (char_height_return)
- *char_height_return = cw;
- return cp;
- break;
- default:
- return -1;
- break;
- }
return -1;
}
@@ -2823,275 +2411,162 @@ imlib_text_get_location_at_index(const char *text, int index,
int *char_width_return,
int *char_height_return)
{
- ImlibFont *fn;
- int cx, cy, cw, ch, w, h;
+ ImlibFont *fn;
+ int cx, cy, cw, ch, w, h;
- if (!ctx) ctx = imlib_context_new();
- CHECK_PARAM_POINTER("imlib_text_get_index_and_location", "font",
- ctx->font);
+ if (!ctx)
+ ctx = imlib_context_new();
+ CHECK_PARAM_POINTER("imlib_text_get_index_and_location", "font", ctx->font);
CHECK_PARAM_POINTER("imlib_text_get_index_and_location", "text", text);
fn = (ImlibFont *) ctx->font;
- switch (fn->type)
- {
- case IMLIB_FONT_TYPE_TTF:
- __imlib_char_geom(fn, text, index, &cx, &cy, &cw, &ch);
- break;
-
- case IMLIB_FONT_TYPE_X:
- __imlib_xfd_char_geom(fn, text, index, &cx, &cy, &cw, &ch);
- break;
-
- case IMLIB_FONT_TYPE_TTF_X:
- {
- char *tmp;
- int i, j;
- int oldp, oldlen, oldx;
-
- tmp = malloc((strlen(text) + 1) * sizeof(char));
-
- oldp = oldlen = oldx = 0;
- for (i=0, j=0; i <= strlen(text); i++)
- {
- int len;
-
- len = mblen(text+i, MB_CUR_MAX);
- if (len < 0)
- continue;
-
- if ( len == 1 && !isascii(text[i]))
- len = -1;
-
- if ((j && len != oldlen) || i >= strlen(text))
- {
- int ww, hh;
-
- if (oldlen == 1)
- __imlib_calc_size(fn, &ww, &hh, tmp);
-
- else if (oldlen > 1 || oldlen == -1)
- {
- XRectangle i_ret, l_ret;
-
- XmbTextExtents(fn->xf.xfontset, tmp, strlen(tmp),
- &i_ret, &l_ret);
- ww = i_ret.width;
- hh = i_ret.height;
- }
-
- if (index >= oldp && index < oldp+strlen(tmp))
- {
- if (oldlen == 1)
- __imlib_char_geom(fn, tmp, index-oldp,
- &cx, &cy, &cw, &ch);
-
- else if (oldlen > 1 || oldlen == -1)
- __imlib_xfd_char_geom(fn, tmp, index-oldp,
- &cx, &cy, &cw, &ch);
-
- cx += oldx;
- break;
- }
- oldx += ww;
- oldp = i;
- j = 0;
- }
- strncpy(tmp+j, text+i, (len == -1) ? 1 : len);
- j += (len == -1) ? 1 : len;
- tmp[j] = '\0';
- if (len > 1)
- i += len - 1;
- oldlen = len;
- }
- free(tmp);
- }
- break;
- }
+ imlib_font_query_char_coords(fn, text, index, &cx, &cy, &cw, &ch);
imlib_get_text_size(text, &w, &h);
switch (ctx->direction)
- {
- case IMLIB_TEXT_TO_RIGHT:
- if (char_x_return)
- *char_x_return = cx;
- if (char_y_return)
- *char_y_return = cy;
- if (char_width_return)
- *char_width_return = cw;
- if (char_height_return)
- *char_height_return = ch;
- return;
- break;
- case IMLIB_TEXT_TO_LEFT:
- cx = 1 + w - cx - cw;
- if (char_x_return)
- *char_x_return = cx;
- if (char_y_return)
- *char_y_return = cy;
- if (char_width_return)
- *char_width_return = cw;
- if (char_height_return)
- *char_height_return = ch;
- return;
- break;
- case IMLIB_TEXT_TO_DOWN:
- if (char_x_return)
- *char_x_return = cy;
- if (char_y_return)
- *char_y_return = cx;
- if (char_width_return)
- *char_width_return = ch;
- if (char_height_return)
- *char_height_return = cw;
- return;
- break;
- case IMLIB_TEXT_TO_UP:
- cy = 1 + h - cy - ch;
- if (char_x_return)
- *char_x_return = cy;
- if (char_y_return)
- *char_y_return = cx;
- if (char_width_return)
- *char_width_return = ch;
- if (char_height_return)
- *char_height_return = cw;
- return;
- break;
- default:
- return;
- break;
- }
+ {
+ case IMLIB_TEXT_TO_RIGHT:
+ if (char_x_return)
+ *char_x_return = cx;
+ if (char_y_return)
+ *char_y_return = cy;
+ if (char_width_return)
+ *char_width_return = cw;
+ if (char_height_return)
+ *char_height_return = ch;
+ return;
+ break;
+ case IMLIB_TEXT_TO_LEFT:
+ cx = 1 + w - cx - cw;
+ if (char_x_return)
+ *char_x_return = cx;
+ if (char_y_return)
+ *char_y_return = cy;
+ if (char_width_return)
+ *char_width_return = cw;
+ if (char_height_return)
+ *char_height_return = ch;
+ return;
+ break;
+ case IMLIB_TEXT_TO_DOWN:
+ if (char_x_return)
+ *char_x_return = cy;
+ if (char_y_return)
+ *char_y_return = cx;
+ if (char_width_return)
+ *char_width_return = ch;
+ if (char_height_return)
+ *char_height_return = cw;
+ return;
+ break;
+ case IMLIB_TEXT_TO_UP:
+ cy = 1 + h - cy - ch;
+ if (char_x_return)
+ *char_x_return = cy;
+ if (char_y_return)
+ *char_y_return = cx;
+ if (char_width_return)
+ *char_width_return = ch;
+ if (char_height_return)
+ *char_height_return = cw;
+ return;
+ break;
+ default:
+ return;
+ break;
+ }
}
-char **
+char **
imlib_list_fonts(int *number_return)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER_RETURN("imlib_list_fonts", "number_return",
number_return, NULL);
- return __imlib_list_fonts(number_return);
+ return imlib_font_list_fonts(number_return);
}
void
imlib_free_font_list(char **font_list, int number)
{
- if (!ctx) ctx = imlib_context_new();
- CHECK_PARAM_POINTER("imlib_free_font_list", "font_list", font_list);
- CHECK_PARAM_POINTER("imlib_free_font_list", "number", number);
- __imlib_free_font_list(font_list, number);
+ __imlib_FileFreeDirList(font_list, number);
}
int
imlib_get_font_cache_size(void)
{
- if (!ctx) ctx = imlib_context_new();
- return __imlib_get_font_cache_size();
+ if (!ctx)
+ ctx = imlib_context_new();
+ return imlib_font_cache_get();
}
void
imlib_set_font_cache_size(int bytes)
{
- if (!ctx) ctx = imlib_context_new();
- __imlib_set_font_cache_size(bytes);
+ if (!ctx)
+ ctx = imlib_context_new();
+ imlib_font_cache_set(bytes);
}
void
imlib_flush_font_cache(void)
{
- if (!ctx) ctx = imlib_context_new();
- __imlib_purge_font_cache();
+ if (!ctx)
+ ctx = imlib_context_new();
+ imlib_font_flush();
}
int
imlib_get_font_ascent(void)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER_RETURN("imlib_get_font_ascent", "font", ctx->font, 0);
- switch (((ImlibFont *)ctx->font)->type)
- {
- case IMLIB_FONT_TYPE_TTF:
- return ((ImlibFont *)ctx->font)->ttf.ascent;
- case IMLIB_FONT_TYPE_X:
- return ((ImlibFont *)ctx->font)->xf.ascent;
- case IMLIB_FONT_TYPE_TTF_X:
- return MAX(((ImlibFont *)ctx->font)->xf.ascent,
- ((ImlibFont *)ctx->font)->xf.ttffont->ttf.ascent);
- default:
- return 0;
- }
+ return imlib_font_ascent_get(ctx->font);
}
int
imlib_get_font_descent(void)
{
- if (!ctx) ctx = imlib_context_new();
- CHECK_PARAM_POINTER_RETURN("imlib_get_font_descent", "font", ctx->font, 0);
- switch (((ImlibFont *)ctx->font)->type)
- {
- case IMLIB_FONT_TYPE_TTF:
- return ((ImlibFont *)ctx->font)->ttf.descent;
- case IMLIB_FONT_TYPE_X:
- return ((ImlibFont *)ctx->font)->xf.descent;
- case IMLIB_FONT_TYPE_TTF_X:
- return MAX(((ImlibFont *)ctx->font)->xf.descent,
- ((ImlibFont *)ctx->font)->xf.ttffont->ttf.descent);
- default:
- return 0;
- }
+ if (!ctx)
+ ctx = imlib_context_new();
+ CHECK_PARAM_POINTER_RETURN("imlib_get_font_ascent", "font", ctx->font, 0);
+ return imlib_font_descent_get(ctx->font);
}
int
imlib_get_maximum_font_ascent(void)
{
- if (!ctx) ctx = imlib_context_new();
- CHECK_PARAM_POINTER_RETURN("imlib_get_maximum_font_ascent", "font",
- ctx->font, 0);
- switch (((ImlibFont *)ctx->font)->type)
- {
- case IMLIB_FONT_TYPE_TTF:
- return ((ImlibFont *)ctx->font)->ttf.max_ascent / 64;
- case IMLIB_FONT_TYPE_X:
- return ((ImlibFont *)ctx->font)->xf.max_ascent;
- case IMLIB_FONT_TYPE_TTF_X:
- return MAX(((ImlibFont *)ctx->font)->xf.max_ascent,
- ((ImlibFont *)ctx->font)->xf.ttffont->ttf.max_ascent / 64);
- default:
- return 0;
- }
+ if (!ctx)
+ ctx = imlib_context_new();
+ CHECK_PARAM_POINTER_RETURN("imlib_get_font_ascent", "font", ctx->font, 0);
+ return imlib_font_max_ascent_get(ctx->font);
}
int
imlib_get_maximum_font_descent(void)
{
- if (!ctx) ctx = imlib_context_new();
- CHECK_PARAM_POINTER_RETURN("imlib_get_maximum_font_descent", "font",
- ctx->font, 0);
- switch (((ImlibFont *)ctx->font)->type)
- {
- case IMLIB_FONT_TYPE_TTF:
- return ((ImlibFont *)ctx->font)->ttf.max_descent / 64;
- case IMLIB_FONT_TYPE_X:
- return -((ImlibFont *)ctx->font)->xf.max_descent;
- case IMLIB_FONT_TYPE_TTF_X:
- return MIN(-((ImlibFont *)ctx->font)->xf.max_descent,
- ((ImlibFont *)ctx->font)->xf.ttffont->ttf.max_descent / 64);
- default:
- return 0;
- }
+ if (!ctx)
+ ctx = imlib_context_new();
+ CHECK_PARAM_POINTER_RETURN("imlib_get_font_ascent", "font", ctx->font, 0);
+ return imlib_font_max_descent_get(ctx->font);
}
Imlib_Color_Modifier
imlib_create_color_modifier(void)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
return (Imlib_Color_Modifier) __imlib_CreateCmod();
}
void
imlib_free_color_modifier(void)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_free_color_modifier", "color_modifier",
ctx->color_modifier);
__imlib_FreeCmod((ImlibColorModifier *) ctx->color_modifier);
@@ -3101,7 +2576,8 @@ imlib_free_color_modifier(void)
void
imlib_modify_color_modifier_gamma(double gamma_value)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_modify_color_modifier_gamma", "color_modifier",
ctx->color_modifier);
__imlib_CmodModGamma((ImlibColorModifier *) ctx->color_modifier,
@@ -3111,7 +2587,8 @@ imlib_modify_color_modifier_gamma(double gamma_value)
void
imlib_modify_color_modifier_brightness(double brightness_value)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_modify_color_modifier_brightness",
"color_modifier", ctx->color_modifier);
__imlib_CmodModBrightness((ImlibColorModifier *) ctx->color_modifier,
@@ -3121,7 +2598,8 @@ imlib_modify_color_modifier_brightness(double brightness_value)
void
imlib_modify_color_modifier_contrast(double contrast_value)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_modify_color_modifier_contrast",
"color_modifier", ctx->color_modifier);
__imlib_CmodModContrast((ImlibColorModifier *) ctx->color_modifier,
@@ -3132,7 +2610,8 @@ void
imlib_set_color_modifier_tables(DATA8 * red_table, DATA8 * green_table,
DATA8 * blue_table, DATA8 * alpha_table)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_set_color_modifier_tables", "color_modifier",
ctx->color_modifier);
__imlib_CmodSetTables((ImlibColorModifier *) ctx->color_modifier,
@@ -3143,7 +2622,8 @@ void
imlib_get_color_modifier_tables(DATA8 * red_table, DATA8 * green_table,
DATA8 * blue_table, DATA8 * alpha_table)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_get_color_modifier_tables", "color_modifier",
ctx->color_modifier);
__imlib_CmodGetTables((ImlibColorModifier *) ctx->color_modifier,
@@ -3153,7 +2633,8 @@ imlib_get_color_modifier_tables(DATA8 * red_table, DATA8 * green_table,
void
imlib_reset_color_modifier(void)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_rset_color_modifier", "color_modifier",
ctx->color_modifier);
__imlib_CmodReset((ImlibColorModifier *) ctx->color_modifier);
@@ -3162,9 +2643,10 @@ imlib_reset_color_modifier(void)
void
imlib_apply_color_modifier(void)
{
- ImlibImage *im;
+ ImlibImage *im;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_apply_color_modifier", "image", ctx->image);
CHECK_PARAM_POINTER("imlib_apply_color_modifier", "color_modifier",
ctx->color_modifier);
@@ -3182,19 +2664,20 @@ imlib_apply_color_modifier(void)
void
imlib_apply_color_modifier_to_rectangle(int x, int y, int width, int height)
{
- ImlibImage *im;
+ ImlibImage *im;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_apply_color_modifier_to_rectangle", "image",
ctx->image);
CHECK_PARAM_POINTER("imlib_apply_color_modifier_to_rectangle",
"color_modifier", ctx->color_modifier);
CAST_IMAGE(im, ctx->image);
if (x < 0)
- {
- width += x;
- x = 0;
- }
+ {
+ width += x;
+ x = 0;
+ }
if (width <= 0)
return;
if ((x + width) > im->w)
@@ -3202,10 +2685,10 @@ imlib_apply_color_modifier_to_rectangle(int x, int y, int width, int height)
if (width <= 0)
return;
if (y < 0)
- {
- height += y;
- y = 0;
- }
+ {
+ height += y;
+ y = 0;
+ }
if (height <= 0)
return;
if ((y + height) > im->h)
@@ -3226,11 +2709,12 @@ imlib_apply_color_modifier_to_rectangle(int x, int y, int width, int height)
Imlib_Updates
imlib_image_draw_pixel(int x, int y, char make_updates)
{
- ImlibImage *im;
+ ImlibImage *im;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER_RETURN("imlib_image_draw_pixel", "image", ctx->image,
- NULL);
+ NULL);
CAST_IMAGE(im, ctx->image);
if ((!(im->data)) && (im->loader) && (im->loader->load))
im->loader->load(im, NULL, 0, 1);
@@ -3239,39 +2723,40 @@ imlib_image_draw_pixel(int x, int y, char make_updates)
__imlib_DirtyImage(im);
__imlib_DirtyPixmapsForImage(im);
if (ctx->cliprect.w == 0)
- {
- __imlib_draw_set_point(im, x, y,
- (DATA8) ctx->color.red,
- (DATA8) ctx->color.green,
- (DATA8) ctx->color.blue,
- (DATA8) ctx->color.alpha,
- ctx->operation);
- }
+ {
+ __imlib_draw_set_point(im, x, y,
+ (DATA8) ctx->color.red,
+ (DATA8) ctx->color.green,
+ (DATA8) ctx->color.blue,
+ (DATA8) ctx->color.alpha, ctx->operation);
+ }
else
- {
- __imlib_draw_set_point_clipped(im, x, y,
- ctx->cliprect.x,
- ctx->cliprect.x +
- ctx->cliprect.w - 1,
- ctx->cliprect.y,
- ctx->cliprect.y +
- ctx->cliprect.h - 1,
- (DATA8) ctx->color.red,
- (DATA8) ctx->color.green,
- (DATA8) ctx->color.blue,
- (DATA8) ctx->color.alpha,
- ctx->operation);
- }
- if (!make_updates) return (Imlib_Updates) NULL;
+ {
+ __imlib_draw_set_point_clipped(im, x, y,
+ ctx->cliprect.x,
+ ctx->cliprect.x +
+ ctx->cliprect.w - 1,
+ ctx->cliprect.y,
+ ctx->cliprect.y +
+ ctx->cliprect.h - 1,
+ (DATA8) ctx->color.red,
+ (DATA8) ctx->color.green,
+ (DATA8) ctx->color.blue,
+ (DATA8) ctx->color.alpha,
+ ctx->operation);
+ }
+ if (!make_updates)
+ return (Imlib_Updates) NULL;
return (Imlib_Updates) __imlib_AddUpdate(NULL, x, y, 1, 1);
}
Imlib_Updates
imlib_image_draw_line(int x1, int y1, int x2, int y2, char make_updates)
{
- ImlibImage *im;
+ ImlibImage *im;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER_RETURN("imlib_image_draw_line", "image", ctx->image,
NULL);
CAST_IMAGE(im, ctx->image);
@@ -3282,41 +2767,42 @@ imlib_image_draw_line(int x1, int y1, int x2, int y2, char make_updates)
__imlib_DirtyImage(im);
__imlib_DirtyPixmapsForImage(im);
if (ctx->cliprect.w)
- {
- return (Imlib_Updates) __imlib_draw_line_clipped(im, x1, y1, x2, y2,
- ctx->cliprect.x,
- ctx->cliprect.x +
- ctx->cliprect.w - 1,
- ctx->cliprect.y,
- ctx->cliprect.y +
- ctx->cliprect.h - 1,
- (DATA8) ctx->color.red,
- (DATA8) ctx->color.
- green,
- (DATA8) ctx->color.
- blue,
- (DATA8) ctx->color.
- alpha, ctx->operation,
- (char) make_updates);
- }
+ {
+ return (Imlib_Updates) __imlib_draw_line_clipped(im, x1, y1, x2, y2,
+ ctx->cliprect.x,
+ ctx->cliprect.x +
+ ctx->cliprect.w - 1,
+ ctx->cliprect.y,
+ ctx->cliprect.y +
+ ctx->cliprect.h - 1,
+ (DATA8) ctx->color.red,
+ (DATA8) ctx->color.
+ green,
+ (DATA8) ctx->color.
+ blue,
+ (DATA8) ctx->color.
+ alpha, ctx->operation,
+ (char)make_updates);
+ }
else
- {
- return (Imlib_Updates) __imlib_draw_line(im, x1, y1, x2, y2,
- (DATA8) ctx->color.red,
- (DATA8) ctx->color.green,
- (DATA8) ctx->color.blue,
- (DATA8) ctx->color.alpha,
- ctx->operation,
- (char) make_updates);
- }
+ {
+ return (Imlib_Updates) __imlib_draw_line(im, x1, y1, x2, y2,
+ (DATA8) ctx->color.red,
+ (DATA8) ctx->color.green,
+ (DATA8) ctx->color.blue,
+ (DATA8) ctx->color.alpha,
+ ctx->operation,
+ (char)make_updates);
+ }
}
void
imlib_image_draw_rectangle(int x, int y, int width, int height)
{
- ImlibImage *im;
+ ImlibImage *im;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_image_draw_rectangle", "image", ctx->image);
CAST_IMAGE(im, ctx->image);
if ((!(im->data)) && (im->loader) && (im->loader->load))
@@ -3326,29 +2812,30 @@ imlib_image_draw_rectangle(int x, int y, int width, int height)
__imlib_DirtyImage(im);
__imlib_DirtyPixmapsForImage(im);
if (ctx->cliprect.w)
- {
- __imlib_draw_box_clipped(im, x, y, width, height, ctx->cliprect.x,
- ctx->cliprect.x + ctx->cliprect.w,
- ctx->cliprect.y,
- ctx->cliprect.y + ctx->cliprect.h,
- ctx->color.red, ctx->color.green,
- ctx->color.blue, ctx->color.alpha,
- ctx->operation);
- }
+ {
+ __imlib_draw_box_clipped(im, x, y, width, height, ctx->cliprect.x,
+ ctx->cliprect.x + ctx->cliprect.w,
+ ctx->cliprect.y,
+ ctx->cliprect.y + ctx->cliprect.h,
+ ctx->color.red, ctx->color.green,
+ ctx->color.blue, ctx->color.alpha,
+ ctx->operation);
+ }
else
- {
- __imlib_draw_box(im, x, y, width, height, ctx->color.red,
- ctx->color.green, ctx->color.blue, ctx->color.alpha,
- ctx->operation);
- }
+ {
+ __imlib_draw_box(im, x, y, width, height, ctx->color.red,
+ ctx->color.green, ctx->color.blue, ctx->color.alpha,
+ ctx->operation);
+ }
}
void
imlib_image_fill_rectangle(int x, int y, int width, int height)
{
- ImlibImage *im;
+ ImlibImage *im;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_image_fill_rectangle", "image", ctx->image);
CAST_IMAGE(im, ctx->image);
if ((!(im->data)) && (im->loader) && (im->loader->load))
@@ -3358,30 +2845,31 @@ imlib_image_fill_rectangle(int x, int y, int width, int height)
__imlib_DirtyImage(im);
__imlib_DirtyPixmapsForImage(im);
if (ctx->cliprect.w)
- {
- __imlib_draw_filled_box_clipped(im, x, y, width, height,
- ctx->cliprect.x,
- ctx->cliprect.x + ctx->cliprect.w,
- ctx->cliprect.y,
- ctx->cliprect.y + ctx->cliprect.h,
- ctx->color.red, ctx->color.green,
- ctx->color.blue, ctx->color.alpha,
- ctx->operation);
- }
+ {
+ __imlib_draw_filled_box_clipped(im, x, y, width, height,
+ ctx->cliprect.x,
+ ctx->cliprect.x + ctx->cliprect.w,
+ ctx->cliprect.y,
+ ctx->cliprect.y + ctx->cliprect.h,
+ ctx->color.red, ctx->color.green,
+ ctx->color.blue, ctx->color.alpha,
+ ctx->operation);
+ }
else
- {
- __imlib_draw_filled_box(im, x, y, width, height, ctx->color.red,
- ctx->color.green, ctx->color.blue,
- ctx->color.alpha, ctx->operation);
- }
+ {
+ __imlib_draw_filled_box(im, x, y, width, height, ctx->color.red,
+ ctx->color.green, ctx->color.blue,
+ ctx->color.alpha, ctx->operation);
+ }
}
void
imlib_image_copy_alpha_to_image(Imlib_Image image_source, int x, int y)
{
- ImlibImage *im, *im2;
+ ImlibImage *im, *im2;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_image_copy_alpha_to_image", "image_source",
image_source);
CHECK_PARAM_POINTER("imlib_image_copy_alpha_to_image", "image_destination",
@@ -3404,12 +2892,12 @@ imlib_image_copy_alpha_to_image(Imlib_Image image_source, int x, int y)
void
imlib_image_copy_alpha_rectangle_to_image(Imlib_Image image_source, int x,
int y, int width, int height,
- int destination_x,
- int destination_y)
+ int destination_x, int destination_y)
{
- ImlibImage *im, *im2;
+ ImlibImage *im, *im2;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_image_copy_alpha_rectangle_to_image",
"image_source", image_source);
CHECK_PARAM_POINTER("imlib_image_copy_alpha_rectangle_to_image",
@@ -3434,10 +2922,11 @@ void
imlib_image_scroll_rect(int x, int y, int width, int height, int delta_x,
int delta_y)
{
- ImlibImage *im;
- int xx, yy, w, h, nx, ny;
+ ImlibImage *im;
+ int xx, yy, w, h, nx, ny;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_image_scroll_rect", "image", ctx->image);
CAST_IMAGE(im, ctx->image);
if ((!(im->data)) && (im->loader) && (im->loader->load))
@@ -3445,41 +2934,41 @@ imlib_image_scroll_rect(int x, int y, int width, int height, int delta_x,
if (!(im->data))
return;
if (delta_x > 0)
- {
- xx = x;
- nx = x + delta_x;
- w = width - delta_x;
- }
+ {
+ xx = x;
+ nx = x + delta_x;
+ w = width - delta_x;
+ }
else
- {
- xx = x - delta_x;
- nx = x;
- w = width + delta_x;
- }
+ {
+ xx = x - delta_x;
+ nx = x;
+ w = width + delta_x;
+ }
if (delta_y > 0)
- {
- yy = y;
- ny = y + delta_y;
- h = height - delta_y;
- }
+ {
+ yy = y;
+ ny = y + delta_y;
+ h = height - delta_y;
+ }
else
- {
- yy = y - delta_y;
- ny = y;
- h = height + delta_y;
- }
+ {
+ yy = y - delta_y;
+ ny = y;
+ h = height + delta_y;
+ }
__imlib_DirtyImage(im);
__imlib_DirtyPixmapsForImage(im);
__imlib_copy_image_data(im, xx, yy, w, h, nx, ny);
}
void
-imlib_image_copy_rect(int x, int y, int width, int height, int new_x,
- int new_y)
+imlib_image_copy_rect(int x, int y, int width, int height, int new_x, int new_y)
{
- ImlibImage *im;
+ ImlibImage *im;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_image_copy_rect", "image", ctx->image);
CAST_IMAGE(im, ctx->image);
if ((!(im->data)) && (im->loader) && (im->loader->load))
@@ -3494,14 +2983,16 @@ imlib_image_copy_rect(int x, int y, int width, int height, int new_x,
Imlib_Color_Range
imlib_create_color_range(void)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
return (Imlib_Color_Range) __imlib_CreateRange();
}
void
imlib_free_color_range(void)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_free_color_range", "color_range",
ctx->color_range);
__imlib_FreeRange((ImlibRange *) ctx->color_range);
@@ -3511,7 +3002,8 @@ imlib_free_color_range(void)
void
imlib_add_color_to_color_range(int distance_away)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_add_color_to_color_range", "color_range",
ctx->color_range);
__imlib_AddRangeColor((ImlibRange *) ctx->color_range, ctx->color.red,
@@ -3523,9 +3015,10 @@ void
imlib_image_fill_color_range_rectangle(int x, int y, int width, int height,
double angle)
{
- ImlibImage *im;
+ ImlibImage *im;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_image_fill_color_range_rectangle", "image",
ctx->image);
CHECK_PARAM_POINTER("imlib_image_fill_color_range_rectangle",
@@ -3540,17 +3033,18 @@ imlib_image_fill_color_range_rectangle(int x, int y, int width, int height,
__imlib_DrawGradient(im, x, y, width, height,
(ImlibRange *) ctx->color_range, angle,
ctx->operation,
- ctx->cliprect.x, ctx->cliprect.y,
- ctx->cliprect.w, ctx->cliprect.h);
+ ctx->cliprect.x, ctx->cliprect.y,
+ ctx->cliprect.w, ctx->cliprect.h);
}
void
imlib_image_fill_hsva_color_range_rectangle(int x, int y, int width, int height,
- double angle)
+ double angle)
{
- ImlibImage *im;
+ ImlibImage *im;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_image_fill_color_range_rectangle", "image",
ctx->image);
CHECK_PARAM_POINTER("imlib_image_fill_color_range_rectangle",
@@ -3565,33 +3059,33 @@ imlib_image_fill_hsva_color_range_rectangle(int x, int y, int width, int height,
__imlib_DrawHsvaGradient(im, x, y, width, height,
(ImlibRange *) ctx->color_range, angle,
ctx->operation,
- ctx->cliprect.x, ctx->cliprect.y,
- ctx->cliprect.w, ctx->cliprect.h);
+ ctx->cliprect.x, ctx->cliprect.y,
+ ctx->cliprect.w, ctx->cliprect.h);
}
void
imlib_image_query_pixel(int x, int y, Imlib_Color * color_return)
{
- ImlibImage *im;
- DATA32 *p;
+ ImlibImage *im;
+ DATA32 *p;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_image_query_pixel", "image", ctx->image);
- CHECK_PARAM_POINTER("imlib_image_query_pixel", "color_return",
- color_return);
+ CHECK_PARAM_POINTER("imlib_image_query_pixel", "color_return", color_return);
CAST_IMAGE(im, ctx->image);
if ((!(im->data)) && (im->loader) && (im->loader->load))
im->loader->load(im, NULL, 0, 1);
if (!(im->data))
return;
if ((x < 0) || (x >= im->w) || (y < 0) || (y >= im->h))
- {
- color_return->red = 0;
- color_return->green = 0;
- color_return->blue = 0;
- color_return->alpha = 0;
- return;
- }
+ {
+ color_return->red = 0;
+ color_return->green = 0;
+ color_return->blue = 0;
+ color_return->alpha = 0;
+ return;
+ }
p = im->data + (im->w * y) + x;
color_return->red = ((*p) >> 16) & 0xff;
color_return->green = ((*p) >> 8) & 0xff;
@@ -3600,14 +3094,16 @@ imlib_image_query_pixel(int x, int y, Imlib_Color * color_return)
}
void
-imlib_image_query_pixel_hsva(int x, int y, float *hue, float *saturation, float *value, int *alpha)
+imlib_image_query_pixel_hsva(int x, int y, float *hue, float *saturation,
+ float *value, int *alpha)
{
- ImlibImage *im;
- DATA32 *p;
- int r,g,b,f;
- float i,j,k,max,min,d;
+ ImlibImage *im;
+ DATA32 *p;
+ int r, g, b, f;
+ float i, j, k, max, min, d;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_image_query_pixel", "image", ctx->image);
CAST_IMAGE(im, ctx->image);
if ((!(im->data)) && (im->loader) && (im->loader->load))
@@ -3615,13 +3111,13 @@ imlib_image_query_pixel_hsva(int x, int y, float *hue, float *saturation, float
if (!(im->data))
return;
if ((x < 0) || (x >= im->w) || (y < 0) || (y >= im->h))
- {
- *hue = 0;
- *saturation = 0;
- *value = 0;
- *alpha = 0;
- return;
- }
+ {
+ *hue = 0;
+ *saturation = 0;
+ *value = 0;
+ *alpha = 0;
+ return;
+ }
p = im->data + (im->w * y) + x;
r = ((*p) >> 16) & 0xff;
g = ((*p) >> 8) & 0xff;
@@ -3632,63 +3128,67 @@ imlib_image_query_pixel_hsva(int x, int y, float *hue, float *saturation, float
}
void
-imlib_image_query_pixel_hlsa(int x, int y, float *hue, float *lightness, float *saturation, int *alpha)
-{
- ImlibImage *im;
- DATA32 *p;
- int r,g,b,f;
- float i,j,k,max,min,d;
-
- if (!ctx) ctx = imlib_context_new();
- CHECK_PARAM_POINTER("imlib_image_query_pixel", "image", ctx->image);
- CAST_IMAGE(im, ctx->image);
- if ((!(im->data)) && (im->loader) && (im->loader->load))
- im->loader->load(im, NULL, 0, 1);
- if (!(im->data))
- return;
- if ((x < 0) || (x >= im->w) || (y < 0) || (y >= im->h))
- {
- *hue = 0;
- *lightness = 0;
- *saturation = 0;
- *alpha = 0;
- return;
- }
- p = im->data + (im->w * y) + x;
- r = ((*p) >> 16) & 0xff;
- g = ((*p) >> 8) & 0xff;
- b = (*p) & 0xff;
- *alpha = ((*p) >> 24) & 0xff;
-
- __imlib_rgb_to_hls(r, g, b, hue, lightness, saturation);
-}
-
-void
-imlib_image_query_pixel_cmya(int x, int y, int *cyan, int *magenta, int *yellow, int *alpha)
-{
- ImlibImage *im;
- DATA32 *p;
-
- if (!ctx) ctx = imlib_context_new();
- CHECK_PARAM_POINTER("imlib_image_query_pixel", "image", ctx->image);
- CAST_IMAGE(im, ctx->image);
- if ((!(im->data)) && (im->loader) && (im->loader->load))
- im->loader->load(im, NULL, 0, 1);
- if (!(im->data))
- return;
- if ((x < 0) || (x >= im->w) || (y < 0) || (y >= im->h))
- {
- *cyan = 0;
- *magenta = 0;
- *yellow = 0;
- *alpha = 0;
- return;
- }
- p = im->data + (im->w * y) + x;
- *cyan = 255 - (((*p) >> 16) & 0xff);
- *magenta = 255 - (((*p) >> 8) & 0xff);
- *yellow = 255 - ((*p) & 0xff);
- *alpha = ((*p) >> 24) & 0xff;
+imlib_image_query_pixel_hlsa(int x, int y, float *hue, float *lightness,
+ float *saturation, int *alpha)
+{
+ ImlibImage *im;
+ DATA32 *p;
+ int r, g, b, f;
+ float i, j, k, max, min, d;
+
+ if (!ctx)
+ ctx = imlib_context_new();
+ CHECK_PARAM_POINTER("imlib_image_query_pixel", "image", ctx->image);
+ CAST_IMAGE(im, ctx->image);
+ if ((!(im->data)) && (im->loader) && (im->loader->load))
+ im->loader->load(im, NULL, 0, 1);
+ if (!(im->data))
+ return;
+ if ((x < 0) || (x >= im->w) || (y < 0) || (y >= im->h))
+ {
+ *hue = 0;
+ *lightness = 0;
+ *saturation = 0;
+ *alpha = 0;
+ return;
+ }
+ p = im->data + (im->w * y) + x;
+ r = ((*p) >> 16) & 0xff;
+ g = ((*p) >> 8) & 0xff;
+ b = (*p) & 0xff;
+ *alpha = ((*p) >> 24) & 0xff;
+
+ __imlib_rgb_to_hls(r, g, b, hue, lightness, saturation);
+}
+
+void
+imlib_image_query_pixel_cmya(int x, int y, int *cyan, int *magenta, int *yellow,
+ int *alpha)
+{
+ ImlibImage *im;
+ DATA32 *p;
+
+ if (!ctx)
+ ctx = imlib_context_new();
+ CHECK_PARAM_POINTER("imlib_image_query_pixel", "image", ctx->image);
+ CAST_IMAGE(im, ctx->image);
+ if ((!(im->data)) && (im->loader) && (im->loader->load))
+ im->loader->load(im, NULL, 0, 1);
+ if (!(im->data))
+ return;
+ if ((x < 0) || (x >= im->w) || (y < 0) || (y >= im->h))
+ {
+ *cyan = 0;
+ *magenta = 0;
+ *yellow = 0;
+ *alpha = 0;
+ return;
+ }
+ p = im->data + (im->w * y) + x;
+ *cyan = 255 - (((*p) >> 16) & 0xff);
+ *magenta = 255 - (((*p) >> 8) & 0xff);
+ *yellow = 255 - ((*p) & 0xff);
+ *alpha = ((*p) >> 24) & 0xff;
}
void
@@ -3696,9 +3196,10 @@ imlib_image_attach_data_value(const char *key, void *data, int value,
Imlib_Internal_Data_Destructor_Function
destructor_function)
{
- ImlibImage *im;
+ ImlibImage *im;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_image_attach_data_value", "image", ctx->image);
CHECK_PARAM_POINTER("imlib_image_attach_data_value", "key", key);
CAST_IMAGE(im, ctx->image);
@@ -3706,13 +3207,14 @@ imlib_image_attach_data_value(const char *key, void *data, int value,
(ImlibDataDestructorFunction) destructor_function);
}
-void *
+void *
imlib_image_get_attached_data(const char *key)
{
- ImlibImageTag *t;
- ImlibImage *im;
+ ImlibImageTag *t;
+ ImlibImage *im;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER_RETURN("imlib_image_get_attached_data", "image",
ctx->image, NULL);
CHECK_PARAM_POINTER_RETURN("imlib_image_get_attached_data", "key", key,
@@ -3727,14 +3229,14 @@ imlib_image_get_attached_data(const char *key)
int
imlib_image_get_attached_value(const char *key)
{
- ImlibImageTag *t;
- ImlibImage *im;
+ ImlibImageTag *t;
+ ImlibImage *im;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER_RETURN("imlib_image_get_attached_value", "image",
ctx->image, 0);
- CHECK_PARAM_POINTER_RETURN("imlib_image_get_attached_value", "key", key,
- 0);
+ CHECK_PARAM_POINTER_RETURN("imlib_image_get_attached_value", "key", key, 0);
CAST_IMAGE(im, ctx->image);
t = __imlib_GetTag(im, key);
if (t)
@@ -3745,9 +3247,10 @@ imlib_image_get_attached_value(const char *key)
void
imlib_image_remove_attached_data_value(const char *key)
{
- ImlibImage *im;
+ ImlibImage *im;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_image_remove_attached_data_value", "image",
ctx->image);
CHECK_PARAM_POINTER("imlib_image_remove_attached_data_value", "key", key);
@@ -3758,10 +3261,11 @@ imlib_image_remove_attached_data_value(const char *key)
void
imlib_image_remove_and_free_attached_data_value(const char *key)
{
- ImlibImageTag *t;
- ImlibImage *im;
+ ImlibImageTag *t;
+ ImlibImage *im;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_image_remove_and_free_attached_data_value",
"image", ctx->image);
CHECK_PARAM_POINTER("imlib_image_remove_and_free_attached_data_value",
@@ -3774,10 +3278,11 @@ imlib_image_remove_and_free_attached_data_value(const char *key)
void
imlib_save_image(const char *filename)
{
- ImlibImage *im;
- Imlib_Image prev_ctxt_image;
+ ImlibImage *im;
+ Imlib_Image prev_ctxt_image;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_save_image", "image", ctx->image);
CHECK_PARAM_POINTER("imlib_save_image", "filename", filename);
CAST_IMAGE(im, ctx->image);
@@ -3795,10 +3300,11 @@ void
imlib_save_image_with_error_return(const char *filename,
Imlib_Load_Error * error_return)
{
- ImlibImage *im;
- Imlib_Image prev_ctxt_image;
+ ImlibImage *im;
+ Imlib_Image prev_ctxt_image;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_save_image_with_error_return", "image",
ctx->image);
CHECK_PARAM_POINTER("imlib_save_image_with_error_return", "filename",
@@ -3819,11 +3325,12 @@ imlib_save_image_with_error_return(const char *filename,
Imlib_Image
imlib_create_rotated_image(double angle)
{
- ImlibImage *im, *im_old;
- int x, y, dx, dy, sz;
- double x1, y1, d;
+ ImlibImage *im, *im_old;
+ int x, y, dx, dy, sz;
+ double x1, y1, d;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER_RETURN("imlib_create_rotated_image", "image",
ctx->image, NULL);
CAST_IMAGE(im_old, ctx->image);
@@ -3832,42 +3339,42 @@ imlib_create_rotated_image(double angle)
if (!(im_old->data))
return NULL;
- d = hypot((double) (im_old->w + 4), (double) (im_old->h + 4)) / sqrt(2.0);
+ d = hypot((double)(im_old->w + 4), (double)(im_old->h + 4)) / sqrt(2.0);
- x1 = (double) (im_old->w) / 2.0 - sin(angle + atan(1.0)) * d;
- y1 = (double) (im_old->h) / 2.0 - cos(angle + atan(1.0)) * d;
+ x1 = (double)(im_old->w) / 2.0 - sin(angle + atan(1.0)) * d;
+ y1 = (double)(im_old->h) / 2.0 - cos(angle + atan(1.0)) * d;
- sz = (int) (d * sqrt(2.0));
- x = (int) (x1 * _ROTATE_PREC_MAX);
- y = (int) (y1 * _ROTATE_PREC_MAX);
- dx = (int) (cos(angle) * _ROTATE_PREC_MAX);
- dy = -(int) (sin(angle) * _ROTATE_PREC_MAX);
+ sz = (int)(d * sqrt(2.0));
+ x = (int)(x1 * _ROTATE_PREC_MAX);
+ y = (int)(y1 * _ROTATE_PREC_MAX);
+ dx = (int)(cos(angle) * _ROTATE_PREC_MAX);
+ dy = -(int)(sin(angle) * _ROTATE_PREC_MAX);
im = __imlib_CreateImage(sz, sz, NULL);
im->data = calloc(sz * sz, sizeof(DATA32));
if (!(im->data))
- {
- __imlib_FreeImage(im);
- return NULL;
- }
+ {
+ __imlib_FreeImage(im);
+ return NULL;
+ }
if (ctx->anti_alias)
- {
+ {
#ifdef DO_MMX_ASM
- if (__imlib_get_cpuid() & CPUID_MMX)
- __imlib_mmx_RotateAA(im_old->data, im->data, im_old->w, im_old->w,
- im_old->h, im->w, sz, sz, x, y, dx, dy, -dy,
- dx);
- else
+ if (__imlib_get_cpuid() & CPUID_MMX)
+ __imlib_mmx_RotateAA(im_old->data, im->data, im_old->w, im_old->w,
+ im_old->h, im->w, sz, sz, x, y, dx, dy, -dy,
+ dx);
+ else
#endif
- __imlib_RotateAA(im_old->data, im->data, im_old->w, im_old->w,
- im_old->h, im->w, sz, sz, x, y, dx, dy, -dy, dx);
- }
+ __imlib_RotateAA(im_old->data, im->data, im_old->w, im_old->w,
+ im_old->h, im->w, sz, sz, x, y, dx, dy, -dy, dx);
+ }
else
- {
- __imlib_RotateSample(im_old->data, im->data, im_old->w, im_old->w,
- im_old->h, im->w, sz, sz, x, y, dx, dy, -dy, dx);
- }
+ {
+ __imlib_RotateSample(im_old->data, im->data, im_old->w, im_old->w,
+ im_old->h, im->w, sz, sz, x, y, dx, dy, -dy, dx);
+ }
SET_FLAG(im->flags, F_HAS_ALPHA);
return (Imlib_Image) im;
@@ -3881,9 +3388,10 @@ imlib_blend_image_onto_image_at_angle(Imlib_Image source_image,
int destination_y, int angle_x,
int angle_y)
{
- ImlibImage *im_src, *im_dst;
+ ImlibImage *im_src, *im_dst;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_blend_image_onto_image_at_angle",
"source_image", source_image);
CHECK_PARAM_POINTER("imlib_blend_image_onto_image_at_angle", "image",
@@ -3906,8 +3414,8 @@ imlib_blend_image_onto_image_at_angle(Imlib_Image source_image,
destination_x, destination_y, angle_x,
angle_y, 0, 0, ctx->color_modifier,
ctx->operation,
- ctx->cliprect.x, ctx->cliprect.y,
- ctx->cliprect.w, ctx->cliprect.h);
+ ctx->cliprect.x, ctx->cliprect.y,
+ ctx->cliprect.w, ctx->cliprect.h);
}
void
@@ -3916,12 +3424,12 @@ imlib_blend_image_onto_image_skewed(Imlib_Image source_image,
int source_y, int source_width,
int source_height, int destination_x,
int destination_y, int h_angle_x,
- int h_angle_y, int v_angle_x,
- int v_angle_y)
+ int h_angle_y, int v_angle_x, int v_angle_y)
{
- ImlibImage *im_src, *im_dst;
+ ImlibImage *im_src, *im_dst;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_blend_image_onto_image_skewed", "source_image",
source_image);
CHECK_PARAM_POINTER("imlib_blend_image_onto_image_skewed", "image",
@@ -3944,8 +3452,8 @@ imlib_blend_image_onto_image_skewed(Imlib_Image source_image,
destination_x, destination_y, h_angle_x,
h_angle_y, v_angle_x, v_angle_y,
ctx->color_modifier, ctx->operation,
- ctx->cliprect.x, ctx->cliprect.y,
- ctx->cliprect.w, ctx->cliprect.h);
+ ctx->cliprect.x, ctx->cliprect.y,
+ ctx->cliprect.w, ctx->cliprect.h);
}
#ifndef X_DISPLAY_MISSING
@@ -3956,9 +3464,10 @@ imlib_render_image_on_drawable_skewed(int source_x, int source_y,
int h_angle_x, int h_angle_y,
int v_angle_x, int v_angle_y)
{
- ImlibImage *im;
+ ImlibImage *im;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_render_image_on_drawable_skewed", "image",
ctx->image);
CAST_IMAGE(im, ctx->image);
@@ -3982,9 +3491,10 @@ imlib_render_image_on_drawable_at_angle(int source_x, int source_y,
int destination_x, int destination_y,
int angle_x, int angle_y)
{
- ImlibImage *im;
+ ImlibImage *im;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_render_image_on_drawable_at_angle", "image",
ctx->image);
CAST_IMAGE(im, ctx->image);
@@ -4006,9 +3516,10 @@ imlib_render_image_on_drawable_at_angle(int source_x, int source_y,
void
imlib_image_filter(void)
{
- ImlibImage *im;
+ ImlibImage *im;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_image_filter", "image", ctx->image);
CHECK_PARAM_POINTER("imlib_image_filter", "filter", ctx->filter);
CAST_IMAGE(im, ctx->image);
@@ -4024,14 +3535,16 @@ imlib_image_filter(void)
Imlib_Filter
imlib_create_filter(int initsize)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
return (Imlib_Filter) __imlib_CreateFilter(initsize);
}
void
imlib_free_filter(void)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_free_filter", "filter", ctx->filter);
__imlib_FreeFilter((ImlibFilter *) ctx->filter);
ctx->filter = NULL;
@@ -4040,23 +3553,26 @@ imlib_free_filter(void)
void
imlib_context_set_filter(Imlib_Filter filter)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
ctx->filter = filter;
}
Imlib_Filter
imlib_context_get_filter(void)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
return ctx->filter;
}
void
imlib_filter_set(int xoff, int yoff, int a, int r, int g, int b)
{
- ImlibFilter *fil;
+ ImlibFilter *fil;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_filter_set", "filter", ctx->filter);
fil = (ImlibFilter *) ctx->filter;
__imlib_FilterSetColor(&fil->alpha, xoff, yoff, a, 0, 0, 0);
@@ -4068,9 +3584,10 @@ imlib_filter_set(int xoff, int yoff, int a, int r, int g, int b)
void
imlib_filter_set_alpha(int xoff, int yoff, int a, int r, int g, int b)
{
- ImlibFilter *fil;
+ ImlibFilter *fil;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_filter_set_alpha", "filter", ctx->filter);
fil = (ImlibFilter *) ctx->filter;
__imlib_FilterSetColor(&fil->alpha, xoff, yoff, a, r, g, b);
@@ -4079,9 +3596,10 @@ imlib_filter_set_alpha(int xoff, int yoff, int a, int r, int g, int b)
void
imlib_filter_set_red(int xoff, int yoff, int a, int r, int g, int b)
{
- ImlibFilter *fil;
+ ImlibFilter *fil;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_filter_set_red", "filter", ctx->filter);
fil = (ImlibFilter *) ctx->filter;
__imlib_FilterSetColor(&fil->red, xoff, yoff, a, r, g, b);
@@ -4090,9 +3608,10 @@ imlib_filter_set_red(int xoff, int yoff, int a, int r, int g, int b)
void
imlib_filter_set_green(int xoff, int yoff, int a, int r, int g, int b)
{
- ImlibFilter *fil;
+ ImlibFilter *fil;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_filter_set_green", "filter", ctx->filter);
fil = (ImlibFilter *) ctx->filter;
__imlib_FilterSetColor(&fil->green, xoff, yoff, a, r, g, b);
@@ -4101,9 +3620,10 @@ imlib_filter_set_green(int xoff, int yoff, int a, int r, int g, int b)
void
imlib_filter_set_blue(int xoff, int yoff, int a, int r, int g, int b)
{
- ImlibFilter *fil;
+ ImlibFilter *fil;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_filter_set_blue", "filter", ctx->filter);
fil = (ImlibFilter *) ctx->filter;
__imlib_FilterSetColor(&fil->blue, xoff, yoff, a, r, g, b);
@@ -4112,7 +3632,8 @@ imlib_filter_set_blue(int xoff, int yoff, int a, int r, int g, int b)
void
imlib_filter_constants(int a, int r, int g, int b)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_filter_constants", "filter", ctx->filter);
__imlib_FilterConstants((ImlibFilter *) ctx->filter, a, r, g, b);
}
@@ -4120,7 +3641,8 @@ imlib_filter_constants(int a, int r, int g, int b)
void
imlib_filter_divisors(int a, int r, int g, int b)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_filter_divisors", "filter", ctx->filter);
__imlib_FilterDivisors((ImlibFilter *) ctx->filter, a, r, g, b);
}
@@ -4128,10 +3650,11 @@ imlib_filter_divisors(int a, int r, int g, int b)
void
imlib_apply_filter(char *script, ...)
{
- va_list param_list;
- ImlibImage *im;
+ va_list param_list;
+ ImlibImage *im;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
__imlib_dynamic_filters_init();
CAST_IMAGE(im, ctx->image);
if ((!(im->data)) && (im->loader) && (im->loader->load))
@@ -4148,14 +3671,16 @@ imlib_apply_filter(char *script, ...)
ImlibPolygon
imlib_polygon_new(void)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
return (ImlibPolygon) __imlib_polygon_new();
}
void
imlib_polygon_add_point(ImlibPolygon poly, int x, int y)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_polygon_add_point", "polygon", poly);
__imlib_polygon_add_point(poly, x, y);
}
@@ -4163,7 +3688,8 @@ imlib_polygon_add_point(ImlibPolygon poly, int x, int y)
void
imlib_polygon_free(ImlibPolygon poly)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_polygon_free", "polygon", poly);
__imlib_polygon_free(poly);
}
@@ -4171,9 +3697,10 @@ imlib_polygon_free(ImlibPolygon poly)
void
imlib_image_draw_polygon(ImlibPolygon poly, unsigned char closed)
{
- ImlibImage *im;
+ ImlibImage *im;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_image_draw_polygon", "image", ctx->image);
CAST_IMAGE(im, ctx->image);
if ((!(im->data)) && (im->loader) && (im->loader->load))
@@ -4183,28 +3710,29 @@ imlib_image_draw_polygon(ImlibPolygon poly, unsigned char closed)
__imlib_DirtyImage(im);
__imlib_DirtyPixmapsForImage(im);
if (ctx->cliprect.w)
- {
- __imlib_draw_polygon_clipped(im, poly, closed, ctx->cliprect.x,
- ctx->cliprect.x + ctx->cliprect.w - 1,
- ctx->cliprect.y,
- ctx->cliprect.y + ctx->cliprect.h - 1,
- ctx->color.red, ctx->color.green,
- ctx->color.blue, ctx->color.alpha,
- ctx->operation);
- }
+ {
+ __imlib_draw_polygon_clipped(im, poly, closed, ctx->cliprect.x,
+ ctx->cliprect.x + ctx->cliprect.w - 1,
+ ctx->cliprect.y,
+ ctx->cliprect.y + ctx->cliprect.h - 1,
+ ctx->color.red, ctx->color.green,
+ ctx->color.blue, ctx->color.alpha,
+ ctx->operation);
+ }
else
- {
- __imlib_draw_polygon(im, poly, closed, ctx->color.red, ctx->color.green,
- ctx->color.blue, ctx->color.alpha, ctx->operation);
- }
+ {
+ __imlib_draw_polygon(im, poly, closed, ctx->color.red, ctx->color.green,
+ ctx->color.blue, ctx->color.alpha, ctx->operation);
+ }
}
void
imlib_image_fill_polygon(ImlibPolygon poly)
{
- ImlibImage *im;
+ ImlibImage *im;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_image_fill_polygon", "image", ctx->image);
CAST_IMAGE(im, ctx->image);
if ((!(im->data)) && (im->loader) && (im->loader->load))
@@ -4222,12 +3750,12 @@ imlib_image_fill_polygon(ImlibPolygon poly)
ctx->operation, ctx->anti_alias);
}
-
void
imlib_polygon_get_bounds(ImlibPolygon poly, int *px1, int *py1, int *px2,
int *py2)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_polygon_get_bounds", "polygon", poly);
__imlib_polygon_get_bounds(poly, px1, py1, px2, py2);
}
@@ -4235,9 +3763,10 @@ imlib_polygon_get_bounds(ImlibPolygon poly, int *px1, int *py1, int *px2,
void
imlib_image_draw_ellipse(int xc, int yc, int a, int b)
{
- ImlibImage *im;
+ ImlibImage *im;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_draw_ellipse", "image", ctx->image);
CAST_IMAGE(im, ctx->image);
if ((!(im->data)) && (im->loader) && (im->loader->load))
@@ -4248,31 +3777,32 @@ imlib_image_draw_ellipse(int xc, int yc, int a, int b)
__imlib_DirtyPixmapsForImage(im);
if (ctx->cliprect.w)
- {
- __imlib_draw_ellipse_clipped(im, xc, yc, a, b, ctx->cliprect.x,
- ctx->cliprect.x + ctx->cliprect.w - 1,
- ctx->cliprect.y,
- ctx->cliprect.y + ctx->cliprect.h - 1,
- ctx->color.red, ctx->color.green,
- ctx->color.blue, ctx->color.alpha,
- ctx->operation);
- }
+ {
+ __imlib_draw_ellipse_clipped(im, xc, yc, a, b, ctx->cliprect.x,
+ ctx->cliprect.x + ctx->cliprect.w - 1,
+ ctx->cliprect.y,
+ ctx->cliprect.y + ctx->cliprect.h - 1,
+ ctx->color.red, ctx->color.green,
+ ctx->color.blue, ctx->color.alpha,
+ ctx->operation);
+ }
else
- {
- __imlib_draw_ellipse_clipped(im, xc, yc, a, b, 0,
- im->w - 1, 0, im->h - 1,
- ctx->color.red, ctx->color.green,
- ctx->color.blue, ctx->color.alpha,
- ctx->operation);
- }
+ {
+ __imlib_draw_ellipse_clipped(im, xc, yc, a, b, 0,
+ im->w - 1, 0, im->h - 1,
+ ctx->color.red, ctx->color.green,
+ ctx->color.blue, ctx->color.alpha,
+ ctx->operation);
+ }
}
void
imlib_image_fill_ellipse(int xc, int yc, int a, int b)
{
- ImlibImage *im;
+ ImlibImage *im;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_fill_ellipse", "image", ctx->image);
CAST_IMAGE(im, ctx->image);
if ((!(im->data)) && (im->loader) && (im->loader->load))
@@ -4283,18 +3813,18 @@ imlib_image_fill_ellipse(int xc, int yc, int a, int b)
__imlib_DirtyPixmapsForImage(im);
__imlib_fill_ellipse(im, xc, yc, a, b, ctx->cliprect.x,
- ctx->cliprect.x + ctx->cliprect.w - 1,
- ctx->cliprect.y,
- ctx->cliprect.y + ctx->cliprect.h - 1, ctx->color.red,
- ctx->color.green, ctx->color.blue, ctx->color.alpha,
- ctx->operation, ctx->anti_alias);
+ ctx->cliprect.x + ctx->cliprect.w - 1,
+ ctx->cliprect.y,
+ ctx->cliprect.y + ctx->cliprect.h - 1, ctx->color.red,
+ ctx->color.green, ctx->color.blue, ctx->color.alpha,
+ ctx->operation, ctx->anti_alias);
}
-
unsigned char
imlib_polygon_contains_point(ImlibPolygon poly, int x, int y)
{
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER_RETURN("imlib_polygon_contains_point", "polygon", poly,
0);
return __imlib_polygon_contains_point(poly, x, y);
@@ -4303,9 +3833,10 @@ imlib_polygon_contains_point(ImlibPolygon poly, int x, int y)
void
imlib_image_clear(void)
{
- ImlibImage *im;
+ ImlibImage *im;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_image_clear", "image", ctx->image);
CAST_IMAGE(im, ctx->image);
if ((!(im->data)) && (im->loader) && (im->loader->load))
@@ -4314,17 +3845,18 @@ imlib_image_clear(void)
return;
__imlib_DirtyImage(im);
__imlib_DirtyPixmapsForImage(im);
- memset(im->data, 0, im->w * im->h * sizeof(DATA32));
+ memset(im->data, 0, im->w * im->h * sizeof(DATA32));
}
void
imlib_image_clear_color(int r, int g, int b, int a)
{
- ImlibImage *im;
- int i, max;
- DATA32 col;
+ ImlibImage *im;
+ int i, max;
+ DATA32 col;
- if (!ctx) ctx = imlib_context_new();
+ if (!ctx)
+ ctx = imlib_context_new();
CHECK_PARAM_POINTER("imlib_image_clear_color", "image", ctx->image);
CAST_IMAGE(im, ctx->image);
if ((!(im->data)) && (im->loader) && (im->loader->load))
@@ -4335,5 +3867,6 @@ imlib_image_clear_color(int r, int g, int b, int a)
__imlib_DirtyPixmapsForImage(im);
max = im->w * im->h;
WRITE_RGBA(&col, r, g, b, a);
- for (i = 0; i < max; i++) im->data[i] = col;
+ for (i = 0; i < max; i++)
+ im->data[i] = col;
}
diff --git a/src/blend.c b/src/blend.c
index 4aae7ab..b1b5bff 100644
--- a/src/blend.c
+++ b/src/blend.c
@@ -48,7 +48,7 @@
#define LOOP_START_3 \
DATA8 aa, na; \
LOOP_START_2
-
+
#define LOOP_END \
} \
p1 += srcw - w; \
@@ -62,119 +62,101 @@
/* COPY OPS */
-int pow_lut_initialized = 0;
-DATA8 pow_lut[256][256];
+int pow_lut_initialized = 0;
+DATA8 pow_lut[256][256];
void
__imlib_build_pow_lut(void)
{
- int i, j;
-
- if (pow_lut_initialized) return;
+ int i, j;
+
+ if (pow_lut_initialized)
+ return;
pow_lut_initialized = 1;
for (i = 0; i < 256; i++)
{
- for (j = 0; j < 256; j++)
+ for (j = 0; j < 256; j++)
/* pow_lut[i][j] = 255 * pow((double)i / 255, (double)j / 255);*/
- {
- int divisor;
-
- divisor = (i + (j * (255 - i)) / 255);
- if (divisor > 0) pow_lut[i][j] = (i * 255) / divisor;
- else pow_lut[i][j] = 0;
- }
+ {
+ int divisor;
+
+ divisor = (i + (j * (255 - i)) / 255);
+ if (divisor > 0)
+ pow_lut[i][j] = (i * 255) / divisor;
+ else
+ pow_lut[i][j] = 0;
+ }
}
}
static void
-__imlib_BlendRGBAToRGB(DATA32 *src, int srcw, DATA32 *dst, int dstw,
- int w, int h, ImlibColorModifier *cm)
+__imlib_BlendRGBAToRGB(DATA32 * src, int srcw, DATA32 * dst, int dstw,
+ int w, int h, ImlibColorModifier * cm)
{
- LOOP_START_2
-
- a = A_VAL(p1);
+ LOOP_START_2 a = A_VAL(p1);
BLEND_COLOR(a, R_VAL(p2), R_VAL(p1), R_VAL(p2));
BLEND_COLOR(a, G_VAL(p2), G_VAL(p1), G_VAL(p2));
BLEND_COLOR(a, B_VAL(p2), B_VAL(p1), B_VAL(p2));
-
- LOOP_END_WITH_INCREMENT
-}
+
+LOOP_END_WITH_INCREMENT}
static void
-__imlib_BlendRGBAToRGBA(DATA32 *src, int srcw, DATA32 *dst, int dstw,
- int w, int h, ImlibColorModifier *cm)
+__imlib_BlendRGBAToRGBA(DATA32 * src, int srcw, DATA32 * dst, int dstw,
+ int w, int h, ImlibColorModifier * cm)
{
- LOOP_START_3
-
- a = pow_lut[A_VAL(p1)][A_VAL(p2)];
-
+ LOOP_START_3 a = pow_lut[A_VAL(p1)][A_VAL(p2)];
+
BLEND_COLOR(a, R_VAL(p2), R_VAL(p1), R_VAL(p2));
BLEND_COLOR(a, G_VAL(p2), G_VAL(p1), G_VAL(p2));
BLEND_COLOR(a, B_VAL(p2), B_VAL(p1), B_VAL(p2));
-
+
A_VAL(p2) = A_VAL(p2) + ((A_VAL(p1) * (255 - A_VAL(p2))) / 255);
- LOOP_END_WITH_INCREMENT
-
-}
+LOOP_END_WITH_INCREMENT}
static void
-__imlib_CopyRGBAToRGB(DATA32 *src, int srcw, DATA32 *dst, int dstw,
- int w, int h, ImlibColorModifier *cm)
+__imlib_CopyRGBAToRGB(DATA32 * src, int srcw, DATA32 * dst, int dstw,
+ int w, int h, ImlibColorModifier * cm)
{
- LOOP_START
-
- *p2 = (*p2 & 0xff000000) | (*p1 & 0x00ffffff);
+ LOOP_START * p2 = (*p2 & 0xff000000) | (*p1 & 0x00ffffff);
- LOOP_END_WITH_INCREMENT
-}
+LOOP_END_WITH_INCREMENT}
static void
-__imlib_CopyRGBToRGBA(DATA32 *src, int srcw, DATA32 *dst, int dstw,
- int w, int h, ImlibColorModifier *cm)
+__imlib_CopyRGBToRGBA(DATA32 * src, int srcw, DATA32 * dst, int dstw,
+ int w, int h, ImlibColorModifier * cm)
{
- LOOP_START
+ LOOP_START * p2 = 0xff000000 | (*p1 & 0x00ffffff);
- *p2 = 0xff000000 | (*p1 & 0x00ffffff);
-
- LOOP_END_WITH_INCREMENT
-}
+LOOP_END_WITH_INCREMENT}
static void
-__imlib_CopyRGBAToRGBA(DATA32 *src, int srcw, DATA32 *dst, int dstw,
- int w, int h, ImlibColorModifier *cm)
+__imlib_CopyRGBAToRGBA(DATA32 * src, int srcw, DATA32 * dst, int dstw,
+ int w, int h, ImlibColorModifier * cm)
{
/* FIXME: This could be a memcpy operation. */
- LOOP_START
+ LOOP_START * p2 = *p1;
- *p2 = *p1;
-
- LOOP_END_WITH_INCREMENT
-}
+LOOP_END_WITH_INCREMENT}
/* ADD OPS */
static void
-__imlib_AddBlendRGBAToRGB(DATA32 *src, int srcw, DATA32 *dst, int dstw,
- int w, int h, ImlibColorModifier *cm)
+__imlib_AddBlendRGBAToRGB(DATA32 * src, int srcw, DATA32 * dst, int dstw,
+ int w, int h, ImlibColorModifier * cm)
{
- LOOP_START_2
-
- a = A_VAL(p1);
+ LOOP_START_2 a = A_VAL(p1);
ADD_COLOR_WITH_ALPHA(a, R_VAL(p2), R_VAL(p1), R_VAL(p2));
ADD_COLOR_WITH_ALPHA(a, G_VAL(p2), G_VAL(p1), G_VAL(p2));
ADD_COLOR_WITH_ALPHA(a, B_VAL(p2), B_VAL(p1), B_VAL(p2));
- LOOP_END_WITH_INCREMENT
-}
+LOOP_END_WITH_INCREMENT}
static void
-__imlib_AddBlendRGBAToRGBA(DATA32 *src, int srcw, DATA32 *dst, int dstw,
- int w, int h, ImlibColorModifier *cm)
+__imlib_AddBlendRGBAToRGBA(DATA32 * src, int srcw, DATA32 * dst, int dstw,
+ int w, int h, ImlibColorModifier * cm)
{
- LOOP_START_3
-
- a = pow_lut[A_VAL(p1)][A_VAL(p2)];
+ LOOP_START_3 a = pow_lut[A_VAL(p1)][A_VAL(p2)];
ADD_COLOR_WITH_ALPHA(a, R_VAL(p2), R_VAL(p1), R_VAL(p2));
ADD_COLOR_WITH_ALPHA(a, G_VAL(p2), G_VAL(p1), G_VAL(p2));
@@ -182,74 +164,59 @@ __imlib_AddBlendRGBAToRGBA(DATA32 *src, int srcw, DATA32 *dst, int dstw,
A_VAL(p2) = A_VAL(p2) + ((A_VAL(p1) * (255 - A_VAL(p2))) / 255);
- LOOP_END_WITH_INCREMENT
-}
+LOOP_END_WITH_INCREMENT}
static void
-__imlib_AddCopyRGBAToRGB(DATA32 *src, int srcw, DATA32 *dst, int dstw,
- int w, int h, ImlibColorModifier *cm)
+__imlib_AddCopyRGBAToRGB(DATA32 * src, int srcw, DATA32 * dst, int dstw,
+ int w, int h, ImlibColorModifier * cm)
{
- LOOP_START_1
-
- ADD_COLOR(R_VAL(p2), R_VAL(p1), R_VAL(p2));
+ LOOP_START_1 ADD_COLOR(R_VAL(p2), R_VAL(p1), R_VAL(p2));
ADD_COLOR(G_VAL(p2), G_VAL(p1), G_VAL(p2));
ADD_COLOR(B_VAL(p2), B_VAL(p1), B_VAL(p2));
- LOOP_END_WITH_INCREMENT
-}
+LOOP_END_WITH_INCREMENT}
static void
-__imlib_AddCopyRGBAToRGBA(DATA32 *src, int srcw, DATA32 *dst, int dstw,
- int w, int h, ImlibColorModifier *cm)
+__imlib_AddCopyRGBAToRGBA(DATA32 * src, int srcw, DATA32 * dst, int dstw,
+ int w, int h, ImlibColorModifier * cm)
{
- LOOP_START_3
-
- ADD_COLOR(R_VAL(p2), R_VAL(p1), R_VAL(p2));
+ LOOP_START_3 ADD_COLOR(R_VAL(p2), R_VAL(p1), R_VAL(p2));
ADD_COLOR(G_VAL(p2), G_VAL(p1), G_VAL(p2));
ADD_COLOR(B_VAL(p2), B_VAL(p1), B_VAL(p2));
SATURATE_UPPER(A_VAL(p2), A_VAL(p1) + A_VAL(p2));
- LOOP_END_WITH_INCREMENT
-}
+LOOP_END_WITH_INCREMENT}
static void
-__imlib_AddCopyRGBToRGBA(DATA32 *src, int srcw, DATA32 *dst, int dstw,
- int w, int h, ImlibColorModifier *cm)
+__imlib_AddCopyRGBToRGBA(DATA32 * src, int srcw, DATA32 * dst, int dstw,
+ int w, int h, ImlibColorModifier * cm)
{
- LOOP_START_3
-
- ADD_COLOR(R_VAL(p2), R_VAL(p1), R_VAL(p2));
+ LOOP_START_3 ADD_COLOR(R_VAL(p2), R_VAL(p1), R_VAL(p2));
ADD_COLOR(G_VAL(p2), G_VAL(p1), G_VAL(p2));
ADD_COLOR(B_VAL(p2), B_VAL(p1), B_VAL(p2));
A_VAL(p2) = 0xff;
- LOOP_END_WITH_INCREMENT
-}
+LOOP_END_WITH_INCREMENT}
/* SUBTRACT OPS */
static void
-__imlib_SubBlendRGBAToRGB(DATA32 *src, int srcw, DATA32 *dst, int dstw,
- int w, int h, ImlibColorModifier *cm)
+__imlib_SubBlendRGBAToRGB(DATA32 * src, int srcw, DATA32 * dst, int dstw,
+ int w, int h, ImlibColorModifier * cm)
{
- LOOP_START_2
-
- SATURATE_UPPER(a, A_VAL(p1) + (255 - A_VAL(p2)));
+ LOOP_START_2 SATURATE_UPPER(a, A_VAL(p1) + (255 - A_VAL(p2)));
SUB_COLOR_WITH_ALPHA(a, R_VAL(p2), R_VAL(p1), R_VAL(p2));
SUB_COLOR_WITH_ALPHA(a, G_VAL(p2), G_VAL(p1), G_VAL(p2));
SUB_COLOR_WITH_ALPHA(a, B_VAL(p2), B_VAL(p1), B_VAL(p2));
SATURATE_UPPER(A_VAL(p2), A_VAL(p1) + A_VAL(p2));
- LOOP_END_WITH_INCREMENT
-}
+LOOP_END_WITH_INCREMENT}
static void
-__imlib_SubBlendRGBAToRGBA(DATA32 *src, int srcw, DATA32 *dst, int dstw,
- int w, int h, ImlibColorModifier *cm)
+__imlib_SubBlendRGBAToRGBA(DATA32 * src, int srcw, DATA32 * dst, int dstw,
+ int w, int h, ImlibColorModifier * cm)
{
- LOOP_START_3
-
- a = pow_lut[A_VAL(p1)][A_VAL(p2)];
+ LOOP_START_3 a = pow_lut[A_VAL(p1)][A_VAL(p2)];
SUB_COLOR_WITH_ALPHA(a, R_VAL(p2), R_VAL(p1), R_VAL(p2));
SUB_COLOR_WITH_ALPHA(a, G_VAL(p2), G_VAL(p1), G_VAL(p2));
@@ -257,75 +224,59 @@ __imlib_SubBlendRGBAToRGBA(DATA32 *src, int srcw, DATA32 *dst, int dstw,
A_VAL(p2) = A_VAL(p2) + ((A_VAL(p1) * (255 - A_VAL(p2))) / 255);
- LOOP_END_WITH_INCREMENT
-}
+LOOP_END_WITH_INCREMENT}
static void
-__imlib_SubCopyRGBAToRGB(DATA32 *src, int srcw, DATA32 *dst, int dstw,
- int w, int h, ImlibColorModifier *cm)
+__imlib_SubCopyRGBAToRGB(DATA32 * src, int srcw, DATA32 * dst, int dstw,
+ int w, int h, ImlibColorModifier * cm)
{
- LOOP_START_1
-
- SUB_COLOR(R_VAL(p2), R_VAL(p1), R_VAL(p2));
+ LOOP_START_1 SUB_COLOR(R_VAL(p2), R_VAL(p1), R_VAL(p2));
SUB_COLOR(G_VAL(p2), G_VAL(p1), G_VAL(p2));
SUB_COLOR(B_VAL(p2), B_VAL(p1), B_VAL(p2));
- LOOP_END_WITH_INCREMENT
-}
+LOOP_END_WITH_INCREMENT}
static void
-__imlib_SubCopyRGBAToRGBA(DATA32 *src, int srcw, DATA32 *dst, int dstw,
- int w, int h, ImlibColorModifier *cm)
+__imlib_SubCopyRGBAToRGBA(DATA32 * src, int srcw, DATA32 * dst, int dstw,
+ int w, int h, ImlibColorModifier * cm)
{
- LOOP_START_3
-
- SUB_COLOR(R_VAL(p2), R_VAL(p1), R_VAL(p2));
+ LOOP_START_3 SUB_COLOR(R_VAL(p2), R_VAL(p1), R_VAL(p2));
SUB_COLOR(G_VAL(p2), G_VAL(p1), G_VAL(p2));
SUB_COLOR(B_VAL(p2), B_VAL(p1), B_VAL(p2));
SATURATE_UPPER(A_VAL(p2), A_VAL(p1) + A_VAL(p2));
- LOOP_END_WITH_INCREMENT
-}
+LOOP_END_WITH_INCREMENT}
static void
-__imlib_SubCopyRGBToRGBA(DATA32 *src, int srcw, DATA32 *dst, int dstw,
- int w, int h, ImlibColorModifier *cm)
+__imlib_SubCopyRGBToRGBA(DATA32 * src, int srcw, DATA32 * dst, int dstw,
+ int w, int h, ImlibColorModifier * cm)
{
- LOOP_START_3
-
- SUB_COLOR(R_VAL(p2), R_VAL(p1), R_VAL(p2));
+ LOOP_START_3 SUB_COLOR(R_VAL(p2), R_VAL(p1), R_VAL(p2));
SUB_COLOR(G_VAL(p2), G_VAL(p1), G_VAL(p2));
SUB_COLOR(B_VAL(p2), B_VAL(p1), B_VAL(p2));
A_VAL(p2) = 0xff;
- LOOP_END_WITH_INCREMENT
-}
-
+LOOP_END_WITH_INCREMENT}
/* RESHADE OPS */
static void
-__imlib_ReBlendRGBAToRGB(DATA32 *src, int srcw, DATA32 *dst, int dstw,
- int w, int h, ImlibColorModifier *cm)
+__imlib_ReBlendRGBAToRGB(DATA32 * src, int srcw, DATA32 * dst, int dstw,
+ int w, int h, ImlibColorModifier * cm)
{
- LOOP_START_2
-
- a = A_VAL(p1);
+ LOOP_START_2 a = A_VAL(p1);
RESHADE_COLOR_WITH_ALPHA(a, R_VAL(p2), R_VAL(p1), R_VAL(p2));
RESHADE_COLOR_WITH_ALPHA(a, G_VAL(p2), G_VAL(p1), G_VAL(p2));
RESHADE_COLOR_WITH_ALPHA(a, B_VAL(p2), B_VAL(p1), B_VAL(p2));
- LOOP_END_WITH_INCREMENT
-}
+LOOP_END_WITH_INCREMENT}
static void
-__imlib_ReBlendRGBAToRGBA(DATA32 *src, int srcw, DATA32 *dst, int dstw,
- int w, int h, ImlibColorModifier *cm)
+__imlib_ReBlendRGBAToRGBA(DATA32 * src, int srcw, DATA32 * dst, int dstw,
+ int w, int h, ImlibColorModifier * cm)
{
- LOOP_START_3
-
- a = pow_lut[A_VAL(p1)][A_VAL(p2)];
+ LOOP_START_3 a = pow_lut[A_VAL(p1)][A_VAL(p2)];
RESHADE_COLOR_WITH_ALPHA(a, R_VAL(p2), R_VAL(p1), R_VAL(p2));
RESHADE_COLOR_WITH_ALPHA(a, G_VAL(p2), G_VAL(p1), G_VAL(p2));
@@ -333,91 +284,63 @@ __imlib_ReBlendRGBAToRGBA(DATA32 *src, int srcw, DATA32 *dst, int dstw,
A_VAL(p2) = A_VAL(p2) + ((A_VAL(p1) * (255 - A_VAL(p2))) / 255);
- LOOP_END_WITH_INCREMENT
-}
+LOOP_END_WITH_INCREMENT}
static void
-__imlib_ReCopyRGBAToRGB(DATA32 *src, int srcw, DATA32 *dst, int dstw,
- int w, int h, ImlibColorModifier *cm)
+__imlib_ReCopyRGBAToRGB(DATA32 * src, int srcw, DATA32 * dst, int dstw,
+ int w, int h, ImlibColorModifier * cm)
{
- LOOP_START_1
-
- RESHADE_COLOR(R_VAL(p2), R_VAL(p1), R_VAL(p2));
+ LOOP_START_1 RESHADE_COLOR(R_VAL(p2), R_VAL(p1), R_VAL(p2));
RESHADE_COLOR(G_VAL(p2), G_VAL(p1), G_VAL(p2));
RESHADE_COLOR(B_VAL(p2), B_VAL(p1), B_VAL(p2));
- LOOP_END_WITH_INCREMENT
-}
+LOOP_END_WITH_INCREMENT}
static void
-__imlib_ReCopyRGBAToRGBA(DATA32 *src, int srcw, DATA32 *dst, int dstw,
- int w, int h, ImlibColorModifier *cm)
+__imlib_ReCopyRGBAToRGBA(DATA32 * src, int srcw, DATA32 * dst, int dstw,
+ int w, int h, ImlibColorModifier * cm)
{
- LOOP_START_3
-
- RESHADE_COLOR(R_VAL(p2), R_VAL(p1), R_VAL(p2));
+ LOOP_START_3 RESHADE_COLOR(R_VAL(p2), R_VAL(p1), R_VAL(p2));
RESHADE_COLOR(G_VAL(p2), G_VAL(p1), G_VAL(p2));
RESHADE_COLOR(B_VAL(p2), B_VAL(p1), B_VAL(p2));
SATURATE_UPPER(A_VAL(p2), A_VAL(p1) + A_VAL(p2));
- LOOP_END_WITH_INCREMENT
-}
+LOOP_END_WITH_INCREMENT}
static void
-__imlib_ReCopyRGBToRGBA(DATA32 *src, int srcw, DATA32 *dst, int dstw,
- int w, int h, ImlibColorModifier *cm)
+__imlib_ReCopyRGBToRGBA(DATA32 * src, int srcw, DATA32 * dst, int dstw,
+ int w, int h, ImlibColorModifier * cm)
{
- LOOP_START_3
-
- RESHADE_COLOR(R_VAL(p2), R_VAL(p1), R_VAL(p2));
+ LOOP_START_3 RESHADE_COLOR(R_VAL(p2), R_VAL(p1), R_VAL(p2));
RESHADE_COLOR(G_VAL(p2), G_VAL(p1), G_VAL(p2));
RESHADE_COLOR(B_VAL(p2), B_VAL(p1), B_VAL(p2));
A_VAL(p2) = 0xff;
- LOOP_END_WITH_INCREMENT
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+LOOP_END_WITH_INCREMENT}
/* WITH COLOMOD */
/* COPY OPS */
static void
-__imlib_BlendRGBAToRGBCmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
- int w, int h, ImlibColorModifier *cm)
+__imlib_BlendRGBAToRGBCmod(DATA32 * src, int srcw, DATA32 * dst, int dstw,
+ int w, int h, ImlibColorModifier * cm)
{
- LOOP_START_2
-
- a = A_CMOD(cm, A_VAL(p1));
+ LOOP_START_2 a = A_CMOD(cm, A_VAL(p1));
BLEND_COLOR(a, R_VAL(p2), R_CMOD(cm, R_VAL(p1)), R_VAL(p2));
BLEND_COLOR(a, G_VAL(p2), G_CMOD(cm, G_VAL(p1)), G_VAL(p2));
BLEND_COLOR(a, B_VAL(p2), B_CMOD(cm, B_VAL(p1)), B_VAL(p2));
- LOOP_END_WITH_INCREMENT
-}
+LOOP_END_WITH_INCREMENT}
static void
-__imlib_BlendRGBAToRGBACmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
- int w, int h, ImlibColorModifier *cm)
+__imlib_BlendRGBAToRGBACmod(DATA32 * src, int srcw, DATA32 * dst, int dstw,
+ int w, int h, ImlibColorModifier * cm)
{
LOOP_START_3
-
- SATURATE_UPPER(a, A_CMOD(cm, A_VAL(p1)) + (((255 - A_VAL(p2)) * (A_CMOD(cm, A_VAL(p1)))) / 255));
+ SATURATE_UPPER(a,
+ A_CMOD(cm,
+ A_VAL(p1)) +
+ (((255 - A_VAL(p2)) * (A_CMOD(cm, A_VAL(p1)))) / 255));
BLEND_COLOR(a, R_VAL(p2), R_CMOD(cm, R_VAL(p1)), R_VAL(p2));
BLEND_COLOR(a, G_VAL(p2), G_CMOD(cm, G_VAL(p1)), G_VAL(p2));
@@ -425,102 +348,85 @@ __imlib_BlendRGBAToRGBACmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
A_VAL(p2) = A_VAL(p2) + ((A_CMOD(cm, A_VAL(p1)) * (255 - A_VAL(p2))) / 255);
- LOOP_END_WITH_INCREMENT
-}
+LOOP_END_WITH_INCREMENT}
static void
-__imlib_BlendRGBToRGBACmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
- int w, int h, ImlibColorModifier *cm)
+__imlib_BlendRGBToRGBACmod(DATA32 * src, int srcw, DATA32 * dst, int dstw,
+ int w, int h, ImlibColorModifier * cm)
{
- LOOP_START_3
-
- SATURATE_UPPER(a, A_CMOD(cm, 0xff) + (255 - A_VAL(p2)));
+ LOOP_START_3 SATURATE_UPPER(a, A_CMOD(cm, 0xff) + (255 - A_VAL(p2)));
BLEND_COLOR(a, R_VAL(p2), R_CMOD(cm, R_VAL(p1)), R_VAL(p2));
BLEND_COLOR(a, G_VAL(p2), G_CMOD(cm, G_VAL(p1)), G_VAL(p2));
BLEND_COLOR(a, B_VAL(p2), B_CMOD(cm, B_VAL(p1)), B_VAL(p2));
SATURATE_UPPER(A_VAL(p2), A_CMOD(cm, 0xff) + A_VAL(p2));
- LOOP_END_WITH_INCREMENT
-}
+LOOP_END_WITH_INCREMENT}
static void
-__imlib_BlendRGBToRGBCmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
- int w, int h, ImlibColorModifier *cm)
+__imlib_BlendRGBToRGBCmod(DATA32 * src, int srcw, DATA32 * dst, int dstw,
+ int w, int h, ImlibColorModifier * cm)
{
- LOOP_START_3
-
- a = A_CMOD(cm, 0xff);
+ LOOP_START_3 a = A_CMOD(cm, 0xff);
BLEND_COLOR(a, R_VAL(p2), R_CMOD(cm, R_VAL(p1)), R_VAL(p2));
BLEND_COLOR(a, G_VAL(p2), G_CMOD(cm, G_VAL(p1)), G_VAL(p2));
BLEND_COLOR(a, B_VAL(p2), B_CMOD(cm, B_VAL(p1)), B_VAL(p2));
- LOOP_END_WITH_INCREMENT
-}
+LOOP_END_WITH_INCREMENT}
static void
-__imlib_CopyRGBAToRGBCmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
- int w, int h, ImlibColorModifier *cm)
+__imlib_CopyRGBAToRGBCmod(DATA32 * src, int srcw, DATA32 * dst, int dstw,
+ int w, int h, ImlibColorModifier * cm)
{
- LOOP_START
-
- R_VAL(p2) = R_CMOD(cm, R_VAL(p1));
+ LOOP_START R_VAL(p2) = R_CMOD(cm, R_VAL(p1));
G_VAL(p2) = G_CMOD(cm, G_VAL(p1));
B_VAL(p2) = B_CMOD(cm, B_VAL(p1));
- LOOP_END_WITH_INCREMENT
-}
+LOOP_END_WITH_INCREMENT}
static void
-__imlib_CopyRGBToRGBACmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
- int w, int h, ImlibColorModifier *cm)
+__imlib_CopyRGBToRGBACmod(DATA32 * src, int srcw, DATA32 * dst, int dstw,
+ int w, int h, ImlibColorModifier * cm)
{
- LOOP_START
-
- R_VAL(p2) = R_CMOD(cm, R_VAL(p1));
+ LOOP_START R_VAL(p2) = R_CMOD(cm, R_VAL(p1));
G_VAL(p2) = G_CMOD(cm, G_VAL(p1));
B_VAL(p2) = B_CMOD(cm, B_VAL(p1));
A_VAL(p2) = A_CMOD(cm, 0xff);
- LOOP_END_WITH_INCREMENT
-}
+LOOP_END_WITH_INCREMENT}
static void
-__imlib_CopyRGBAToRGBACmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
- int w, int h, ImlibColorModifier *cm)
+__imlib_CopyRGBAToRGBACmod(DATA32 * src, int srcw, DATA32 * dst, int dstw,
+ int w, int h, ImlibColorModifier * cm)
{
- LOOP_START
-
- R_VAL(p2) = R_CMOD(cm, R_VAL(p1));
+ LOOP_START R_VAL(p2) = R_CMOD(cm, R_VAL(p1));
G_VAL(p2) = G_CMOD(cm, G_VAL(p1));
B_VAL(p2) = B_CMOD(cm, B_VAL(p1));
A_VAL(p2) = A_CMOD(cm, A_VAL(p1));
- LOOP_END_WITH_INCREMENT
-}
+LOOP_END_WITH_INCREMENT}
/* ADD OPS */
static void
-__imlib_AddBlendRGBAToRGBCmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
- int w, int h, ImlibColorModifier *cm)
+__imlib_AddBlendRGBAToRGBCmod(DATA32 * src, int srcw, DATA32 * dst, int dstw,
+ int w, int h, ImlibColorModifier * cm)
{
- LOOP_START_2
-
- SATURATE_UPPER(a, A_CMOD(cm, A_VAL(p1)) + (255 - A_VAL(p2)));
+ LOOP_START_2 SATURATE_UPPER(a, A_CMOD(cm, A_VAL(p1)) + (255 - A_VAL(p2)));
ADD_COLOR_WITH_ALPHA(a, R_VAL(p2), R_CMOD(cm, R_VAL(p1)), R_VAL(p2));
ADD_COLOR_WITH_ALPHA(a, G_VAL(p2), G_CMOD(cm, G_VAL(p1)), G_VAL(p2));
ADD_COLOR_WITH_ALPHA(a, B_VAL(p2), B_CMOD(cm, B_VAL(p1)), B_VAL(p2));
- LOOP_END_WITH_INCREMENT
-}
+LOOP_END_WITH_INCREMENT}
static void
-__imlib_AddBlendRGBAToRGBACmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
- int w, int h, ImlibColorModifier *cm)
+__imlib_AddBlendRGBAToRGBACmod(DATA32 * src, int srcw, DATA32 * dst, int dstw,
+ int w, int h, ImlibColorModifier * cm)
{
LOOP_START_3
-
- SATURATE_UPPER(a, A_CMOD(cm, A_VAL(p1)) + (((255 - A_VAL(p2)) * (A_CMOD(cm, A_VAL(p1)))) / 255));
+ SATURATE_UPPER(a,
+ A_CMOD(cm,
+ A_VAL(p1)) +
+ (((255 - A_VAL(p2)) * (A_CMOD(cm, A_VAL(p1)))) / 255));
ADD_COLOR_WITH_ALPHA(a, R_VAL(p2), R_CMOD(cm, R_VAL(p1)), R_VAL(p2));
ADD_COLOR_WITH_ALPHA(a, G_VAL(p2), G_CMOD(cm, G_VAL(p1)), G_VAL(p2));
@@ -528,103 +434,86 @@ __imlib_AddBlendRGBAToRGBACmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
A_VAL(p2) = A_VAL(p2) + ((A_CMOD(cm, A_VAL(p1)) * (255 - A_VAL(p2))) / 255);
- LOOP_END_WITH_INCREMENT
-}
+LOOP_END_WITH_INCREMENT}
static void
-__imlib_AddBlendRGBToRGBCmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
- int w, int h, ImlibColorModifier *cm)
+__imlib_AddBlendRGBToRGBCmod(DATA32 * src, int srcw, DATA32 * dst, int dstw,
+ int w, int h, ImlibColorModifier * cm)
{
- LOOP_START_3
-
- a = A_CMOD(cm, 0xff);
+ LOOP_START_3 a = A_CMOD(cm, 0xff);
ADD_COLOR_WITH_ALPHA(a, R_VAL(p2), R_CMOD(cm, R_VAL(p1)), R_VAL(p2));
ADD_COLOR_WITH_ALPHA(a, G_VAL(p2), G_CMOD(cm, G_VAL(p1)), G_VAL(p2));
ADD_COLOR_WITH_ALPHA(a, B_VAL(p2), B_CMOD(cm, B_VAL(p1)), B_VAL(p2));
- LOOP_END_WITH_INCREMENT
-}
+LOOP_END_WITH_INCREMENT}
static void
-__imlib_AddBlendRGBToRGBACmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
- int w, int h, ImlibColorModifier *cm)
+__imlib_AddBlendRGBToRGBACmod(DATA32 * src, int srcw, DATA32 * dst, int dstw,
+ int w, int h, ImlibColorModifier * cm)
{
- LOOP_START_3
-
- SATURATE_UPPER(a, A_CMOD(cm, 0xff) + (255 - A_VAL(p2)));
+ LOOP_START_3 SATURATE_UPPER(a, A_CMOD(cm, 0xff) + (255 - A_VAL(p2)));
ADD_COLOR_WITH_ALPHA(a, R_VAL(p2), R_CMOD(cm, R_VAL(p1)), R_VAL(p2));
ADD_COLOR_WITH_ALPHA(a, G_VAL(p2), G_CMOD(cm, G_VAL(p1)), G_VAL(p2));
ADD_COLOR_WITH_ALPHA(a, B_VAL(p2), B_CMOD(cm, B_VAL(p1)), B_VAL(p2));
SATURATE_UPPER(A_VAL(p2), A_CMOD(cm, A_VAL(p1)) + A_VAL(p2));
- LOOP_END_WITH_INCREMENT
-}
+LOOP_END_WITH_INCREMENT}
static void
-__imlib_AddCopyRGBAToRGBCmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
- int w, int h, ImlibColorModifier *cm)
+__imlib_AddCopyRGBAToRGBCmod(DATA32 * src, int srcw, DATA32 * dst, int dstw,
+ int w, int h, ImlibColorModifier * cm)
{
- LOOP_START_1
-
- ADD_COLOR(R_VAL(p2), R_CMOD(cm, R_VAL(p1)), R_VAL(p2));
+ LOOP_START_1 ADD_COLOR(R_VAL(p2), R_CMOD(cm, R_VAL(p1)), R_VAL(p2));
ADD_COLOR(G_VAL(p2), G_CMOD(cm, G_VAL(p1)), G_VAL(p2));
ADD_COLOR(B_VAL(p2), B_CMOD(cm, B_VAL(p1)), B_VAL(p2));
- LOOP_END_WITH_INCREMENT
-}
+LOOP_END_WITH_INCREMENT}
static void
-__imlib_AddCopyRGBAToRGBACmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
- int w, int h, ImlibColorModifier *cm)
+__imlib_AddCopyRGBAToRGBACmod(DATA32 * src, int srcw, DATA32 * dst, int dstw,
+ int w, int h, ImlibColorModifier * cm)
{
- LOOP_START_3
-
- ADD_COLOR(R_VAL(p2), R_CMOD(cm, R_VAL(p1)), R_VAL(p2));
+ LOOP_START_3 ADD_COLOR(R_VAL(p2), R_CMOD(cm, R_VAL(p1)), R_VAL(p2));
ADD_COLOR(G_VAL(p2), G_CMOD(cm, G_VAL(p1)), G_VAL(p2));
ADD_COLOR(B_VAL(p2), B_CMOD(cm, B_VAL(p1)), B_VAL(p2));
SATURATE_UPPER(A_VAL(p2), A_CMOD(cm, A_VAL(p1)) + A_VAL(p2));
- LOOP_END_WITH_INCREMENT
-}
+LOOP_END_WITH_INCREMENT}
static void
-__imlib_AddCopyRGBToRGBACmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
- int w, int h, ImlibColorModifier *cm)
+__imlib_AddCopyRGBToRGBACmod(DATA32 * src, int srcw, DATA32 * dst, int dstw,
+ int w, int h, ImlibColorModifier * cm)
{
- LOOP_START_3
-
- ADD_COLOR(R_VAL(p2), R_CMOD(cm, R_VAL(p1)), R_VAL(p2));
+ LOOP_START_3 ADD_COLOR(R_VAL(p2), R_CMOD(cm, R_VAL(p1)), R_VAL(p2));
ADD_COLOR(G_VAL(p2), G_CMOD(cm, G_VAL(p1)), G_VAL(p2));
ADD_COLOR(B_VAL(p2), B_CMOD(cm, B_VAL(p1)), B_VAL(p2));
SATURATE_UPPER(A_VAL(p2), A_CMOD(cm, 0xff) + A_VAL(p2));
- LOOP_END_WITH_INCREMENT
-}
+LOOP_END_WITH_INCREMENT}
/* SUBTRACT OPS */
static void
-__imlib_SubBlendRGBAToRGBCmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
- int w, int h, ImlibColorModifier *cm)
+__imlib_SubBlendRGBAToRGBCmod(DATA32 * src, int srcw, DATA32 * dst, int dstw,
+ int w, int h, ImlibColorModifier * cm)
{
- LOOP_START_2
-
- a = A_CMOD(cm, A_VAL(p1));
+ LOOP_START_2 a = A_CMOD(cm, A_VAL(p1));
SUB_COLOR_WITH_ALPHA(a, R_VAL(p2), R_CMOD(cm, R_VAL(p1)), R_VAL(p2));
SUB_COLOR_WITH_ALPHA(a, G_VAL(p2), G_CMOD(cm, G_VAL(p1)), G_VAL(p2));
SUB_COLOR_WITH_ALPHA(a, B_VAL(p2), B_CMOD(cm, B_VAL(p1)), B_VAL(p2));
- LOOP_END_WITH_INCREMENT
-}
+LOOP_END_WITH_INCREMENT}
static void
-__imlib_SubBlendRGBAToRGBACmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
- int w, int h, ImlibColorModifier *cm)
+__imlib_SubBlendRGBAToRGBACmod(DATA32 * src, int srcw, DATA32 * dst, int dstw,
+ int w, int h, ImlibColorModifier * cm)
{
LOOP_START_3
-
- SATURATE_UPPER(a, A_CMOD(cm, A_VAL(p1)) + (((255 - A_VAL(p2)) * (A_CMOD(cm, A_VAL(p1)))) / 255));
+ SATURATE_UPPER(a,
+ A_CMOD(cm,
+ A_VAL(p1)) +
+ (((255 - A_VAL(p2)) * (A_CMOD(cm, A_VAL(p1)))) / 255));
SUB_COLOR_WITH_ALPHA(a, R_VAL(p2), R_CMOD(cm, R_VAL(p1)), R_VAL(p2));
SUB_COLOR_WITH_ALPHA(a, G_VAL(p2), G_CMOD(cm, G_VAL(p1)), G_VAL(p2));
@@ -632,105 +521,87 @@ __imlib_SubBlendRGBAToRGBACmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
A_VAL(p2) = A_VAL(p2) + ((A_CMOD(cm, A_VAL(p1)) * (255 - A_VAL(p2))) / 255);
- LOOP_END_WITH_INCREMENT
-}
+LOOP_END_WITH_INCREMENT}
static void
-__imlib_SubBlendRGBToRGBCmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
- int w, int h, ImlibColorModifier *cm)
+__imlib_SubBlendRGBToRGBCmod(DATA32 * src, int srcw, DATA32 * dst, int dstw,
+ int w, int h, ImlibColorModifier * cm)
{
- LOOP_START_2
-
- a = A_CMOD(cm, 0xff);
+ LOOP_START_2 a = A_CMOD(cm, 0xff);
SUB_COLOR_WITH_ALPHA(a, R_VAL(p2), R_CMOD(cm, R_VAL(p1)), R_VAL(p2));
SUB_COLOR_WITH_ALPHA(a, G_VAL(p2), G_CMOD(cm, G_VAL(p1)), G_VAL(p2));
SUB_COLOR_WITH_ALPHA(a, B_VAL(p2), B_CMOD(cm, B_VAL(p1)), B_VAL(p2));
- LOOP_END_WITH_INCREMENT
-}
+LOOP_END_WITH_INCREMENT}
static void
-__imlib_SubBlendRGBToRGBACmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
- int w, int h, ImlibColorModifier *cm)
+__imlib_SubBlendRGBToRGBACmod(DATA32 * src, int srcw, DATA32 * dst, int dstw,
+ int w, int h, ImlibColorModifier * cm)
{
- LOOP_START_3
-
- SATURATE_UPPER(a, A_CMOD(cm, 0xff) + (255 - A_VAL(p2)));
+ LOOP_START_3 SATURATE_UPPER(a, A_CMOD(cm, 0xff) + (255 - A_VAL(p2)));
SUB_COLOR_WITH_ALPHA(a, R_VAL(p2), R_CMOD(cm, R_VAL(p1)), R_VAL(p2));
SUB_COLOR_WITH_ALPHA(a, G_VAL(p2), G_CMOD(cm, G_VAL(p1)), G_VAL(p2));
SUB_COLOR_WITH_ALPHA(a, B_VAL(p2), B_CMOD(cm, B_VAL(p1)), B_VAL(p2));
SATURATE_UPPER(A_VAL(p2), A_CMOD(cm, 0xff) + A_VAL(p2));
- LOOP_END_WITH_INCREMENT
-}
+LOOP_END_WITH_INCREMENT}
static void
-__imlib_SubCopyRGBAToRGBCmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
- int w, int h, ImlibColorModifier *cm)
+__imlib_SubCopyRGBAToRGBCmod(DATA32 * src, int srcw, DATA32 * dst, int dstw,
+ int w, int h, ImlibColorModifier * cm)
{
- LOOP_START_1
-
- SUB_COLOR(R_VAL(p2), R_CMOD(cm, R_VAL(p1)), R_VAL(p2));
+ LOOP_START_1 SUB_COLOR(R_VAL(p2), R_CMOD(cm, R_VAL(p1)), R_VAL(p2));
SUB_COLOR(G_VAL(p2), G_CMOD(cm, G_VAL(p1)), G_VAL(p2));
SUB_COLOR(B_VAL(p2), B_CMOD(cm, B_VAL(p1)), B_VAL(p2));
- LOOP_END_WITH_INCREMENT
-}
+LOOP_END_WITH_INCREMENT}
static void
-__imlib_SubCopyRGBAToRGBACmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
- int w, int h, ImlibColorModifier *cm)
+__imlib_SubCopyRGBAToRGBACmod(DATA32 * src, int srcw, DATA32 * dst, int dstw,
+ int w, int h, ImlibColorModifier * cm)
{
- LOOP_START_3
-
- SUB_COLOR(R_VAL(p2), R_CMOD(cm, R_VAL(p1)), R_VAL(p2));
+ LOOP_START_3 SUB_COLOR(R_VAL(p2), R_CMOD(cm, R_VAL(p1)), R_VAL(p2));
SUB_COLOR(G_VAL(p2), G_CMOD(cm, G_VAL(p1)), G_VAL(p2));
SUB_COLOR(B_VAL(p2), B_CMOD(cm, B_VAL(p1)), B_VAL(p2));
SATURATE_UPPER(A_VAL(p2), A_CMOD(cm, A_VAL(p1)) + A_VAL(p2));
- LOOP_END_WITH_INCREMENT
-}
+LOOP_END_WITH_INCREMENT}
static void
-__imlib_SubCopyRGBToRGBACmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
- int w, int h, ImlibColorModifier *cm)
+__imlib_SubCopyRGBToRGBACmod(DATA32 * src, int srcw, DATA32 * dst, int dstw,
+ int w, int h, ImlibColorModifier * cm)
{
- LOOP_START_3
-
- SUB_COLOR(R_VAL(p2), R_CMOD(cm, R_VAL(p1)), R_VAL(p2));
+ LOOP_START_3 SUB_COLOR(R_VAL(p2), R_CMOD(cm, R_VAL(p1)), R_VAL(p2));
SUB_COLOR(G_VAL(p2), G_CMOD(cm, G_VAL(p1)), G_VAL(p2));
SUB_COLOR(B_VAL(p2), B_CMOD(cm, B_VAL(p1)), B_VAL(p2));
SATURATE_UPPER(A_VAL(p2), A_CMOD(cm, 0xff) + A_VAL(p2));
- LOOP_END_WITH_INCREMENT
-}
-
+LOOP_END_WITH_INCREMENT}
/* RESHADE OPS */
static void
-__imlib_ReBlendRGBAToRGBCmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
- int w, int h, ImlibColorModifier *cm)
+__imlib_ReBlendRGBAToRGBCmod(DATA32 * src, int srcw, DATA32 * dst, int dstw,
+ int w, int h, ImlibColorModifier * cm)
{
- LOOP_START_2
-
- a = A_CMOD(cm, A_VAL(p1));
+ LOOP_START_2 a = A_CMOD(cm, A_VAL(p1));
RESHADE_COLOR_WITH_ALPHA(a, R_VAL(p2), R_CMOD(cm, R_VAL(p1)), R_VAL(p2));
RESHADE_COLOR_WITH_ALPHA(a, G_VAL(p2), G_CMOD(cm, G_VAL(p1)), G_VAL(p2));
RESHADE_COLOR_WITH_ALPHA(a, B_VAL(p2), B_CMOD(cm, B_VAL(p1)), B_VAL(p2));
- LOOP_END_WITH_INCREMENT
-}
+LOOP_END_WITH_INCREMENT}
static void
-__imlib_ReBlendRGBAToRGBACmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
- int w, int h, ImlibColorModifier *cm)
+__imlib_ReBlendRGBAToRGBACmod(DATA32 * src, int srcw, DATA32 * dst, int dstw,
+ int w, int h, ImlibColorModifier * cm)
{
LOOP_START_3
-
- SATURATE_UPPER(a, A_CMOD(cm, A_VAL(p1)) + (((255 - A_VAL(p2)) * (A_CMOD(cm, A_VAL(p1)))) / 255));
+ SATURATE_UPPER(a,
+ A_CMOD(cm,
+ A_VAL(p1)) +
+ (((255 - A_VAL(p2)) * (A_CMOD(cm, A_VAL(p1)))) / 255));
RESHADE_COLOR_WITH_ALPHA(a, R_VAL(p2), R_CMOD(cm, R_VAL(p1)), R_VAL(p2));
RESHADE_COLOR_WITH_ALPHA(a, G_VAL(p2), G_CMOD(cm, G_VAL(p1)), G_VAL(p2));
@@ -738,83 +609,63 @@ __imlib_ReBlendRGBAToRGBACmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
A_VAL(p2) = A_VAL(p2) + ((A_CMOD(cm, A_VAL(p1)) * (255 - A_VAL(p2))) / 255);
- LOOP_END_WITH_INCREMENT
-}
+LOOP_END_WITH_INCREMENT}
static void
-__imlib_ReBlendRGBToRGBCmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
- int w, int h, ImlibColorModifier *cm)
+__imlib_ReBlendRGBToRGBCmod(DATA32 * src, int srcw, DATA32 * dst, int dstw,
+ int w, int h, ImlibColorModifier * cm)
{
- LOOP_START_2
-
- a = A_CMOD(cm, 0xff);
+ LOOP_START_2 a = A_CMOD(cm, 0xff);
RESHADE_COLOR_WITH_ALPHA(a, R_VAL(p2), R_CMOD(cm, R_VAL(p1)), R_VAL(p2));
RESHADE_COLOR_WITH_ALPHA(a, G_VAL(p2), G_CMOD(cm, G_VAL(p1)), G_VAL(p2));
RESHADE_COLOR_WITH_ALPHA(a, B_VAL(p2), B_CMOD(cm, B_VAL(p1)), B_VAL(p2));
- LOOP_END_WITH_INCREMENT
-}
+LOOP_END_WITH_INCREMENT}
static void
-__imlib_ReBlendRGBToRGBACmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
- int w, int h, ImlibColorModifier *cm)
+__imlib_ReBlendRGBToRGBACmod(DATA32 * src, int srcw, DATA32 * dst, int dstw,
+ int w, int h, ImlibColorModifier * cm)
{
- LOOP_START_3
-
- SATURATE_UPPER(a, A_CMOD(cm, A_VAL(p1)) + (255 - A_VAL(p2)));
+ LOOP_START_3 SATURATE_UPPER(a, A_CMOD(cm, A_VAL(p1)) + (255 - A_VAL(p2)));
RESHADE_COLOR_WITH_ALPHA(a, R_VAL(p2), R_CMOD(cm, R_VAL(p1)), R_VAL(p2));
RESHADE_COLOR_WITH_ALPHA(a, G_VAL(p2), G_CMOD(cm, G_VAL(p1)), G_VAL(p2));
RESHADE_COLOR_WITH_ALPHA(a, B_VAL(p2), B_CMOD(cm, B_VAL(p1)), B_VAL(p2));
SATURATE_UPPER(A_VAL(p2), A_CMOD(cm, 0xff) + A_VAL(p2));
- LOOP_END_WITH_INCREMENT
-}
+LOOP_END_WITH_INCREMENT}
static void
-__imlib_ReCopyRGBAToRGBCmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
- int w, int h, ImlibColorModifier *cm)
+__imlib_ReCopyRGBAToRGBCmod(DATA32 * src, int srcw, DATA32 * dst, int dstw,
+ int w, int h, ImlibColorModifier * cm)
{
- LOOP_START_1
-
- RESHADE_COLOR(R_VAL(p2), R_CMOD(cm, R_VAL(p1)), R_VAL(p2));
+ LOOP_START_1 RESHADE_COLOR(R_VAL(p2), R_CMOD(cm, R_VAL(p1)), R_VAL(p2));
RESHADE_COLOR(G_VAL(p2), G_CMOD(cm, G_VAL(p1)), G_VAL(p2));
RESHADE_COLOR(B_VAL(p2), B_CMOD(cm, B_VAL(p1)), B_VAL(p2));
- LOOP_END_WITH_INCREMENT
-}
+LOOP_END_WITH_INCREMENT}
static void
-__imlib_ReCopyRGBAToRGBACmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
- int w, int h, ImlibColorModifier *cm)
+__imlib_ReCopyRGBAToRGBACmod(DATA32 * src, int srcw, DATA32 * dst, int dstw,
+ int w, int h, ImlibColorModifier * cm)
{
- LOOP_START_3
-
- RESHADE_COLOR(R_VAL(p2), R_CMOD(cm, R_VAL(p1)), R_VAL(p2));
+ LOOP_START_3 RESHADE_COLOR(R_VAL(p2), R_CMOD(cm, R_VAL(p1)), R_VAL(p2));
RESHADE_COLOR(G_VAL(p2), G_CMOD(cm, G_VAL(p1)), G_VAL(p2));
RESHADE_COLOR(B_VAL(p2), B_CMOD(cm, B_VAL(p1)), B_VAL(p2));
SATURATE_UPPER(A_VAL(p2), A_CMOD(cm, A_VAL(p1)) + A_VAL(p2));
- LOOP_END_WITH_INCREMENT
-}
+LOOP_END_WITH_INCREMENT}
static void
-__imlib_ReCopyRGBToRGBACmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
- int w, int h, ImlibColorModifier *cm)
+__imlib_ReCopyRGBToRGBACmod(DATA32 * src, int srcw, DATA32 * dst, int dstw,
+ int w, int h, ImlibColorModifier * cm)
{
- LOOP_START_3
-
- RESHADE_COLOR(R_VAL(p2), R_CMOD(cm, R_VAL(p1)), R_VAL(p2));
+ LOOP_START_3 RESHADE_COLOR(R_VAL(p2), R_CMOD(cm, R_VAL(p1)), R_VAL(p2));
RESHADE_COLOR(G_VAL(p2), G_CMOD(cm, G_VAL(p1)), G_VAL(p2));
RESHADE_COLOR(B_VAL(p2), B_CMOD(cm, B_VAL(p1)), B_VAL(p2));
SATURATE_UPPER(A_VAL(p2), A_CMOD(cm, 0xff) + A_VAL(p2));
- LOOP_END_WITH_INCREMENT
-}
-
-
-
-
+LOOP_END_WITH_INCREMENT}
/*\ Equivalent functions \*/
@@ -858,102 +709,135 @@ __imlib_ReCopyRGBToRGBACmod(DATA32 *src, int srcw, DATA32 *dst, int dstw,
ImlibBlendFunction
__imlib_GetBlendFunction(ImlibOp op, char blend, char merge_alpha, char rgb_src,
- ImlibColorModifier * cm)
+ ImlibColorModifier * cm)
{
- /*\ [ mmx ][ operation ][ cmod ][ merge_alpha ][ rgb_src ][ blend ] \*/
+ /*\ [ mmx ][ operation ][ cmod ][ merge_alpha ][ rgb_src ][ blend ] \ */
static ImlibBlendFunction ibfuncs[][4][2][2][2][2] = {
- /*\ OP_COPY \*/
- {{{{{ __imlib_CopyRGBAToRGB, __imlib_BlendRGBAToRGB },
- { __imlib_CopyRGBToRGB, __imlib_BlendRGBToRGB } },
- {{ __imlib_CopyRGBAToRGBA, __imlib_BlendRGBAToRGBA },
- { __imlib_CopyRGBToRGBA, __imlib_BlendRGBToRGBA } } },
-
- {{{ __imlib_CopyRGBAToRGBCmod, __imlib_BlendRGBAToRGBCmod },
- { __imlib_CopyRGBToRGBCmod, __imlib_BlendRGBToRGBCmod } },
- {{ __imlib_CopyRGBAToRGBACmod, __imlib_BlendRGBAToRGBACmod },
- { __imlib_CopyRGBToRGBACmod, __imlib_BlendRGBToRGBACmod } } } },
- /*\ OP_ADD \*/
- {{{{ __imlib_AddCopyRGBAToRGB, __imlib_AddBlendRGBAToRGB },
- { __imlib_AddCopyRGBToRGB, __imlib_AddBlendRGBToRGB } },
- {{ __imlib_AddCopyRGBAToRGBA, __imlib_AddBlendRGBAToRGBA },
- { __imlib_AddCopyRGBToRGBA, __imlib_AddBlendRGBToRGBA } } },
-
- {{{ __imlib_AddCopyRGBAToRGBCmod, __imlib_AddBlendRGBAToRGBCmod },
- { __imlib_AddCopyRGBToRGBCmod, __imlib_AddBlendRGBToRGBCmod } },
- {{ __imlib_AddCopyRGBAToRGBACmod, __imlib_AddBlendRGBAToRGBACmod },
- { __imlib_AddCopyRGBToRGBACmod, __imlib_AddBlendRGBToRGBACmod } } } },
- /*\ OP_SUBTRACT \*/
- {{{{ __imlib_SubCopyRGBAToRGB, __imlib_SubBlendRGBAToRGB },
- { __imlib_SubCopyRGBToRGB, __imlib_SubBlendRGBToRGB } },
- {{ __imlib_SubCopyRGBAToRGBA, __imlib_SubBlendRGBAToRGBA },
- { __imlib_SubCopyRGBToRGBA, __imlib_SubBlendRGBToRGBA } } },
-
- {{{ __imlib_SubCopyRGBAToRGBCmod, __imlib_SubBlendRGBAToRGBCmod },
- { __imlib_SubCopyRGBToRGBCmod, __imlib_SubBlendRGBToRGBCmod } },
- {{ __imlib_SubCopyRGBAToRGBACmod, __imlib_SubBlendRGBAToRGBACmod },
- { __imlib_SubCopyRGBToRGBACmod, __imlib_SubBlendRGBToRGBACmod } } } },
- /*\ OP_RESHADE \*/
- {{{{ __imlib_ReCopyRGBAToRGB, __imlib_ReBlendRGBAToRGB },
- { __imlib_ReCopyRGBToRGB, __imlib_ReBlendRGBToRGB } },
- {{ __imlib_ReCopyRGBAToRGBA, __imlib_ReBlendRGBAToRGBA },
- { __imlib_ReCopyRGBToRGBA, __imlib_ReBlendRGBToRGBA } } },
-
- {{{ __imlib_ReCopyRGBAToRGBCmod, __imlib_ReBlendRGBAToRGBCmod },
- { __imlib_ReCopyRGBToRGBCmod, __imlib_ReBlendRGBToRGBCmod } },
- {{ __imlib_ReCopyRGBAToRGBACmod, __imlib_ReBlendRGBAToRGBACmod },
- { __imlib_ReCopyRGBToRGBACmod, __imlib_ReBlendRGBToRGBACmod } } } } },
+ /*\ OP_COPY \ */
+ {{{{{__imlib_CopyRGBAToRGB, __imlib_BlendRGBAToRGB},
+ {__imlib_CopyRGBToRGB, __imlib_BlendRGBToRGB}},
+ {{__imlib_CopyRGBAToRGBA, __imlib_BlendRGBAToRGBA},
+ {__imlib_CopyRGBToRGBA, __imlib_BlendRGBToRGBA}}},
+
+ {{{__imlib_CopyRGBAToRGBCmod, __imlib_BlendRGBAToRGBCmod},
+ {__imlib_CopyRGBToRGBCmod, __imlib_BlendRGBToRGBCmod}},
+ {{__imlib_CopyRGBAToRGBACmod, __imlib_BlendRGBAToRGBACmod},
+ {__imlib_CopyRGBToRGBACmod, __imlib_BlendRGBToRGBACmod}}}},
+ /*\ OP_ADD \ */
+ {{{{__imlib_AddCopyRGBAToRGB, __imlib_AddBlendRGBAToRGB},
+ {__imlib_AddCopyRGBToRGB, __imlib_AddBlendRGBToRGB}},
+ {{__imlib_AddCopyRGBAToRGBA, __imlib_AddBlendRGBAToRGBA},
+ {__imlib_AddCopyRGBToRGBA, __imlib_AddBlendRGBToRGBA}}},
+
+ {{{__imlib_AddCopyRGBAToRGBCmod, __imlib_AddBlendRGBAToRGBCmod},
+ {__imlib_AddCopyRGBToRGBCmod, __imlib_AddBlendRGBToRGBCmod}},
+ {{__imlib_AddCopyRGBAToRGBACmod, __imlib_AddBlendRGBAToRGBACmod},
+ {__imlib_AddCopyRGBToRGBACmod, __imlib_AddBlendRGBToRGBACmod}}}},
+ /*\ OP_SUBTRACT \ */
+ {{{{__imlib_SubCopyRGBAToRGB, __imlib_SubBlendRGBAToRGB},
+ {__imlib_SubCopyRGBToRGB, __imlib_SubBlendRGBToRGB}},
+ {{__imlib_SubCopyRGBAToRGBA, __imlib_SubBlendRGBAToRGBA},
+ {__imlib_SubCopyRGBToRGBA, __imlib_SubBlendRGBToRGBA}}},
+
+ {{{__imlib_SubCopyRGBAToRGBCmod, __imlib_SubBlendRGBAToRGBCmod},
+ {__imlib_SubCopyRGBToRGBCmod, __imlib_SubBlendRGBToRGBCmod}},
+ {{__imlib_SubCopyRGBAToRGBACmod, __imlib_SubBlendRGBAToRGBACmod},
+ {__imlib_SubCopyRGBToRGBACmod, __imlib_SubBlendRGBToRGBACmod}}}},
+ /*\ OP_RESHADE \ */
+ {{{{__imlib_ReCopyRGBAToRGB, __imlib_ReBlendRGBAToRGB},
+ {__imlib_ReCopyRGBToRGB, __imlib_ReBlendRGBToRGB}},
+ {{__imlib_ReCopyRGBAToRGBA, __imlib_ReBlendRGBAToRGBA},
+ {__imlib_ReCopyRGBToRGBA, __imlib_ReBlendRGBToRGBA}}},
+
+ {{{__imlib_ReCopyRGBAToRGBCmod, __imlib_ReBlendRGBAToRGBCmod},
+ {__imlib_ReCopyRGBToRGBCmod, __imlib_ReBlendRGBToRGBCmod}},
+ {{__imlib_ReCopyRGBAToRGBACmod, __imlib_ReBlendRGBAToRGBACmod},
+ {__imlib_ReCopyRGBToRGBACmod, __imlib_ReBlendRGBToRGBACmod}}}}},
#ifdef DO_MMX_ASM
- /*\ OP_COPY \*/
- {{{{{ __imlib_mmx_copy_rgba_to_rgb, __imlib_mmx_blend_rgba_to_rgb},
- { __imlib_mmx_copy_rgb_to_rgb, __imlib_mmx_blend_rgb_to_rgb } },
- {{ __imlib_mmx_copy_rgba_to_rgba, __imlib_BlendRGBAToRGBA/*__imlib_mmx_blend_rgba_to_rgba*/ },
- { __imlib_mmx_copy_rgb_to_rgba, __imlib_mmx_blend_rgb_to_rgba } } },
-
- {{{ __imlib_mmx_copy_rgba_to_rgb_cmod, __imlib_mmx_blend_rgba_to_rgb_cmod },
- { __imlib_mmx_copy_rgb_to_rgb_cmod, __imlib_mmx_blend_rgb_to_rgb_cmod } },
- {{ __imlib_mmx_copy_rgba_to_rgba_cmod, __imlib_BlendRGBAToRGBACmod/*__imlib_mmx_blend_rgba_to_rgba_cmod*/ },
- { __imlib_mmx_copy_rgb_to_rgba_cmod, __imlib_mmx_blend_rgb_to_rgba_cmod } } } },
- /*\ OP_ADD \*/
- {{{{ __imlib_mmx_add_copy_rgba_to_rgb, __imlib_mmx_add_blend_rgba_to_rgb },
- { __imlib_mmx_add_copy_rgb_to_rgb, __imlib_mmx_add_blend_rgb_to_rgb } },
- {{ __imlib_mmx_add_copy_rgba_to_rgba, __imlib_AddBlendRGBAToRGBA/*__imlib_mmx_add_blend_rgba_to_rgba*/ },
- { __imlib_mmx_add_copy_rgb_to_rgba, __imlib_mmx_add_blend_rgb_to_rgba } } },
-
- {{{ __imlib_mmx_add_copy_rgba_to_rgb_cmod, __imlib_mmx_add_blend_rgba_to_rgb_cmod },
- { __imlib_mmx_add_copy_rgb_to_rgb_cmod, __imlib_mmx_add_blend_rgb_to_rgb_cmod } },
- {{ __imlib_mmx_add_copy_rgba_to_rgba_cmod, __imlib_AddBlendRGBAToRGBACmod/*__imlib_mmx_add_blend_rgba_to_rgba_cmod*/ },
- { __imlib_mmx_add_copy_rgb_to_rgba_cmod, __imlib_mmx_add_blend_rgb_to_rgba_cmod } } } },
- /*\ OP_SUBTRACT \*/
- {{{{ __imlib_mmx_subtract_copy_rgba_to_rgb, __imlib_mmx_subtract_blend_rgba_to_rgb },
- { __imlib_mmx_subtract_copy_rgb_to_rgb, __imlib_mmx_subtract_blend_rgb_to_rgb } },
- {{ __imlib_mmx_subtract_copy_rgba_to_rgba, __imlib_SubBlendRGBAToRGBA/*__imlib_mmx_subtract_blend_rgba_to_rgba*/ },
- { __imlib_mmx_subtract_copy_rgb_to_rgba, __imlib_mmx_subtract_blend_rgb_to_rgba } } },
-
- {{{ __imlib_mmx_subtract_copy_rgba_to_rgb_cmod, __imlib_mmx_subtract_blend_rgba_to_rgb_cmod },
- { __imlib_mmx_subtract_copy_rgb_to_rgb_cmod, __imlib_mmx_subtract_blend_rgb_to_rgb_cmod } },
- {{ __imlib_mmx_subtract_copy_rgba_to_rgba_cmod, __imlib_SubBlendRGBAToRGBACmod/*__imlib_mmx_subtract_blend_rgba_to_rgba_cmod*/ },
- { __imlib_mmx_subtract_copy_rgb_to_rgba_cmod, __imlib_mmx_subtract_blend_rgb_to_rgba_cmod } } } },
- /*\ OP_RESHADE \*/
- {{{{ __imlib_mmx_reshade_copy_rgba_to_rgb, __imlib_mmx_reshade_blend_rgba_to_rgb },
- { __imlib_mmx_reshade_copy_rgb_to_rgb, __imlib_mmx_reshade_blend_rgb_to_rgb } },
- {{ __imlib_mmx_reshade_copy_rgba_to_rgba, __imlib_ReBlendRGBAToRGBA/*__imlib_mmx_reshade_blend_rgba_to_rgba*/ },
- { __imlib_mmx_reshade_copy_rgb_to_rgba, __imlib_mmx_reshade_blend_rgb_to_rgba } } },
-
- {{{ __imlib_mmx_reshade_copy_rgba_to_rgb_cmod, __imlib_mmx_reshade_blend_rgba_to_rgb_cmod },
- { __imlib_mmx_reshade_copy_rgb_to_rgb_cmod, __imlib_mmx_reshade_blend_rgb_to_rgb_cmod } },
- {{ __imlib_mmx_reshade_copy_rgba_to_rgba_cmod, __imlib_ReBlendRGBAToRGBACmod/*__imlib_mmx_reshade_blend_rgba_to_rgba_cmod*/ },
- { __imlib_mmx_reshade_copy_rgb_to_rgba_cmod, __imlib_mmx_reshade_blend_rgb_to_rgba_cmod } } } } },
+ /*\ OP_COPY \ */
+ {{{{{__imlib_mmx_copy_rgba_to_rgb, __imlib_mmx_blend_rgba_to_rgb},
+ {__imlib_mmx_copy_rgb_to_rgb, __imlib_mmx_blend_rgb_to_rgb}},
+ {{__imlib_mmx_copy_rgba_to_rgba,
+ __imlib_BlendRGBAToRGBA /*__imlib_mmx_blend_rgba_to_rgba*/ },
+ {__imlib_mmx_copy_rgb_to_rgba, __imlib_mmx_blend_rgb_to_rgba}}},
+
+ {{{__imlib_mmx_copy_rgba_to_rgb_cmod,
+ __imlib_mmx_blend_rgba_to_rgb_cmod},
+ {__imlib_mmx_copy_rgb_to_rgb_cmod,
+ __imlib_mmx_blend_rgb_to_rgb_cmod}},
+ {{__imlib_mmx_copy_rgba_to_rgba_cmod,
+ __imlib_BlendRGBAToRGBACmod /*__imlib_mmx_blend_rgba_to_rgba_cmod*/
+ },
+ {__imlib_mmx_copy_rgb_to_rgba_cmod,
+ __imlib_mmx_blend_rgb_to_rgba_cmod}}}},
+ /*\ OP_ADD \ */
+ {{{{__imlib_mmx_add_copy_rgba_to_rgb, __imlib_mmx_add_blend_rgba_to_rgb},
+ {__imlib_mmx_add_copy_rgb_to_rgb, __imlib_mmx_add_blend_rgb_to_rgb}},
+ {{__imlib_mmx_add_copy_rgba_to_rgba,
+ __imlib_AddBlendRGBAToRGBA /*__imlib_mmx_add_blend_rgba_to_rgba*/ },
+ {__imlib_mmx_add_copy_rgb_to_rgba,
+ __imlib_mmx_add_blend_rgb_to_rgba}}},
+
+ {{{__imlib_mmx_add_copy_rgba_to_rgb_cmod,
+ __imlib_mmx_add_blend_rgba_to_rgb_cmod},
+ {__imlib_mmx_add_copy_rgb_to_rgb_cmod,
+ __imlib_mmx_add_blend_rgb_to_rgb_cmod}},
+ {{__imlib_mmx_add_copy_rgba_to_rgba_cmod,
+ __imlib_AddBlendRGBAToRGBACmod
+ /*__imlib_mmx_add_blend_rgba_to_rgba_cmod*/ },
+ {__imlib_mmx_add_copy_rgb_to_rgba_cmod,
+ __imlib_mmx_add_blend_rgb_to_rgba_cmod}}}},
+ /*\ OP_SUBTRACT \ */
+ {{{{__imlib_mmx_subtract_copy_rgba_to_rgb,
+ __imlib_mmx_subtract_blend_rgba_to_rgb},
+ {__imlib_mmx_subtract_copy_rgb_to_rgb,
+ __imlib_mmx_subtract_blend_rgb_to_rgb}},
+ {{__imlib_mmx_subtract_copy_rgba_to_rgba,
+ __imlib_SubBlendRGBAToRGBA
+ /*__imlib_mmx_subtract_blend_rgba_to_rgba*/ },
+ {__imlib_mmx_subtract_copy_rgb_to_rgba,
+ __imlib_mmx_subtract_blend_rgb_to_rgba}}},
+
+ {{{__imlib_mmx_subtract_copy_rgba_to_rgb_cmod,
+ __imlib_mmx_subtract_blend_rgba_to_rgb_cmod},
+ {__imlib_mmx_subtract_copy_rgb_to_rgb_cmod,
+ __imlib_mmx_subtract_blend_rgb_to_rgb_cmod}},
+ {{__imlib_mmx_subtract_copy_rgba_to_rgba_cmod,
+ __imlib_SubBlendRGBAToRGBACmod
+ /*__imlib_mmx_subtract_blend_rgba_to_rgba_cmod*/ },
+ {__imlib_mmx_subtract_copy_rgb_to_rgba_cmod,
+ __imlib_mmx_subtract_blend_rgb_to_rgba_cmod}}}},
+ /*\ OP_RESHADE \ */
+ {{{{__imlib_mmx_reshade_copy_rgba_to_rgb,
+ __imlib_mmx_reshade_blend_rgba_to_rgb},
+ {__imlib_mmx_reshade_copy_rgb_to_rgb,
+ __imlib_mmx_reshade_blend_rgb_to_rgb}},
+ {{__imlib_mmx_reshade_copy_rgba_to_rgba,
+ __imlib_ReBlendRGBAToRGBA /*__imlib_mmx_reshade_blend_rgba_to_rgba*/
+ },
+ {__imlib_mmx_reshade_copy_rgb_to_rgba,
+ __imlib_mmx_reshade_blend_rgb_to_rgba}}},
+
+ {{{__imlib_mmx_reshade_copy_rgba_to_rgb_cmod,
+ __imlib_mmx_reshade_blend_rgba_to_rgb_cmod},
+ {__imlib_mmx_reshade_copy_rgb_to_rgb_cmod,
+ __imlib_mmx_reshade_blend_rgb_to_rgb_cmod}},
+ {{__imlib_mmx_reshade_copy_rgba_to_rgba_cmod,
+ __imlib_ReBlendRGBAToRGBACmod
+ /*__imlib_mmx_reshade_blend_rgba_to_rgba_cmod*/ },
+ {__imlib_mmx_reshade_copy_rgb_to_rgba_cmod,
+ __imlib_mmx_reshade_blend_rgb_to_rgba_cmod}}}}},
#endif
};
- int opi = (op == OP_COPY) ? 0
- : (op == OP_ADD) ? 1
- : (op == OP_SUBTRACT) ? 2
- : (op == OP_RESHADE) ? 3 : -1;
- int do_mmx = 0;
+ int opi = (op == OP_COPY) ? 0
+ : (op == OP_ADD) ? 1
+ : (op == OP_SUBTRACT) ? 2 : (op == OP_RESHADE) ? 3 : -1;
+ int do_mmx = 0;
- if (opi == -1) return NULL;
+ if (opi == -1)
+ return NULL;
#ifdef DO_MMX_ASM
do_mmx = !!(__imlib_get_cpuid() & CPUID_MMX);
@@ -964,36 +848,36 @@ __imlib_GetBlendFunction(ImlibOp op, char blend, char merge_alpha, char rgb_src,
}
void
-__imlib_BlendRGBAToData(DATA32 *src, int src_w, int src_h, DATA32 *dst,
- int dst_w, int dst_h, int sx, int sy, int dx, int dy,
- int w, int h, char blend, char merge_alpha,
- ImlibColorModifier *cm, ImlibOp op, char rgb_src)
+__imlib_BlendRGBAToData(DATA32 * src, int src_w, int src_h, DATA32 * dst,
+ int dst_w, int dst_h, int sx, int sy, int dx, int dy,
+ int w, int h, char blend, char merge_alpha,
+ ImlibColorModifier * cm, ImlibOp op, char rgb_src)
{
- ImlibBlendFunction blender;
+ ImlibBlendFunction blender;
if (sx < 0)
{
- w += sx;
- dx -= sx;
- sx = 0;
+ w += sx;
+ dx -= sx;
+ sx = 0;
}
if (sy < 0)
{
- h += sy;
- dy -= sy;
- sy = 0;
+ h += sy;
+ dy -= sy;
+ sy = 0;
}
if (dx < 0)
{
- w += dx;
- sx -= dx;
- dx = 0;
+ w += dx;
+ sx -= dx;
+ dx = 0;
}
if (dy < 0)
{
- h += dy;
- sy -= dy;
- dy = 0;
+ h += dy;
+ sy -= dy;
+ dy = 0;
}
if ((w <= 0) || (h <= 0))
return;
@@ -1004,29 +888,29 @@ __imlib_BlendRGBAToData(DATA32 *src, int src_w, int src_h, DATA32 *dst,
if ((dx + w) > dst_w)
w = dst_w - dx;
if ((dy + h) > dst_h)
- h = dst_h - dy;
+ h = dst_h - dy;
if ((w <= 0) || (h <= 0))
return;
__imlib_build_pow_lut();
blender = __imlib_GetBlendFunction(op, blend, merge_alpha, rgb_src, cm);
if (blender)
- blender(src + (sy * src_w) + sx, src_w,
- dst + (dy * dst_w) + dx, dst_w, w, h, cm);
+ blender(src + (sy * src_w) + sx, src_w,
+ dst + (dy * dst_w) + dx, dst_w, w, h, cm);
}
#define LINESIZE 16
void
-__imlib_BlendImageToImage(ImlibImage *im_src, ImlibImage *im_dst,
- char aa, char blend, char merge_alpha,
- int ssx, int ssy, int ssw, int ssh,
- int ddx, int ddy, int ddw, int ddh,
- ImlibColorModifier *cm, ImlibOp op,
- int clx, int cly, int clw, int clh)
+__imlib_BlendImageToImage(ImlibImage * im_src, ImlibImage * im_dst,
+ char aa, char blend, char merge_alpha,
+ int ssx, int ssy, int ssw, int ssh,
+ int ddx, int ddy, int ddw, int ddh,
+ ImlibColorModifier * cm, ImlibOp op,
+ int clx, int cly, int clw, int clh)
{
- char rgb_src = 0;
-
+ char rgb_src = 0;
+
if ((!(im_src->data)) && (im_src->loader) && (im_src->loader->load))
im_src->loader->load(im_src, NULL, 0, 1);
if ((!(im_dst->data)) && (im_dst->loader) && (im_src->loader->load))
@@ -1035,172 +919,177 @@ __imlib_BlendImageToImage(ImlibImage *im_src, ImlibImage *im_dst,
return;
if (!im_dst->data)
return;
-
- if ((ssw == ddw) &&
- (ssh == ddh))
+
+ if ((ssw == ddw) && (ssh == ddh))
{
- if (!IMAGE_HAS_ALPHA(im_dst))
- merge_alpha = 0;
- if (!IMAGE_HAS_ALPHA(im_src))
- {
- rgb_src = 1;
- if (merge_alpha)
- blend = 1;
- }
- if (clw)
- {
- int px, py;
-
- px = ddx;
- py = ddy;
- CLIP_TO(ddx, ddy, ddw, ddh, clx, cly, clw, clh);
- px = ddx - px;
- py = ddy - py;
- ssx += px;
- ssy += py;
- if ((ssw < 1) || (ssh < 1)) return;
- if ((ddw < 1) || (ddh < 1)) return;
- }
-
- __imlib_BlendRGBAToData(im_src->data, im_src->w, im_src->h,
- im_dst->data, im_dst->w, im_dst->h,
- ssx, ssy,
- ddx, ddy,
- ddw, ddh, blend, merge_alpha, cm, op, rgb_src);
+ if (!IMAGE_HAS_ALPHA(im_dst))
+ merge_alpha = 0;
+ if (!IMAGE_HAS_ALPHA(im_src))
+ {
+ rgb_src = 1;
+ if (merge_alpha)
+ blend = 1;
+ }
+ if (clw)
+ {
+ int px, py;
+
+ px = ddx;
+ py = ddy;
+ CLIP_TO(ddx, ddy, ddw, ddh, clx, cly, clw, clh);
+ px = ddx - px;
+ py = ddy - py;
+ ssx += px;
+ ssy += py;
+ if ((ssw < 1) || (ssh < 1))
+ return;
+ if ((ddw < 1) || (ddh < 1))
+ return;
+ }
+
+ __imlib_BlendRGBAToData(im_src->data, im_src->w, im_src->h,
+ im_dst->data, im_dst->w, im_dst->h,
+ ssx, ssy,
+ ddx, ddy,
+ ddw, ddh, blend, merge_alpha, cm, op, rgb_src);
}
else
{
- ImlibScaleInfo *scaleinfo = NULL;
- DATA32 *buf = NULL;
- int sx, sy, sw, sh, dx, dy, dw, dh, dxx, dyy, y2, x2;
- int psx, psy, psw, psh;
- int y, h, hh;
- int do_mmx;
- sx = ssx;
- sy = ssy;
- sw = ssw;
- sh = ssh;
- dx = ddx;
- dy = ddy;
- dw = abs(ddw);
- dh = abs(ddh);
- /* don't do anything if we have a 0 width or height image to render */
- /* if the input rect size < 0 don't render either */
- if ((dw <= 0) || (dh <= 0) || (sw <= 0) || (sh <= 0))
- return;
- /* clip the source rect to be within the actual image */
- psx = sx;
- psy = sy;
- psw = sw;
- psh = sh;
- CLIP(sx, sy, sw, sh, 0, 0, im_src->w, im_src->h);
- if (psx != sx)
- dx += ((sx - psx) * abs(ddw)) / ssw;
- if (psy != sy)
- dy += ((sy - psy) * abs(ddh)) / ssh;
- if (psw != sw)
- dw = (dw * sw) / psw;
- if (psh != sh)
- dh = (dh * sh) / psh;
- if ((dw <= 0) || (dh <= 0) || (sw <= 0) || (sh <= 0))
- {
- return;
- }
- /* clip output coords to clipped input coords */
- psx = dx;
- psy = dy;
- psw = dw;
- psh = dh;
- x2 = sx;
- y2 = sy;
- CLIP(dx, dy, dw, dh, 0, 0, im_dst->w, im_dst->h);
- if ((dw <= 0) || (dh <= 0) || (sw <= 0) || (sh <= 0)) return;
- if (clw)
- {
- CLIP_TO(dx, dy, dw, dh, clx, cly, clw, clh);
- if ((dw < 1) || (dh < 1)) return;
- }
- if (psx != dx)
- sx += ((dx - psx) * ssw) / abs(ddw);
- if (psy != dy)
- sy += ((dy - psy) * ssh) / abs(ddh);
- if (psw != dw)
- sw = (sw * dw) / psw;
- if (psh != dh)
- sh = (sh * dh) / psh;
- dxx = dx - psx;
- dyy = dy - psy;
- dxx += (x2 * abs(ddw)) / ssw;
- dyy += (y2 * abs(ddh)) / ssh;
-
- if ((dw > 0) && (sw == 0))
- sw = 1;
- if ((dh > 0) && (sh == 0))
- sh = 1;
- /* do a second check to see if we now have invalid coords */
- /* don't do anything if we have a 0 width or height image to render */
- /* if the input rect size < 0 don't render either */
- if ((dw <= 0) || (dh <= 0) || (sw <= 0) || (sh <= 0))
- {
- return;
- }
- scaleinfo = __imlib_CalcScaleInfo(im_src, ssw, ssh, ddw, ddh, aa);
- if (!scaleinfo) return;
- /* if we are scaling the image at all make a scaling buffer */
- /* allocate a buffer to render scaled RGBA data into */
- buf = malloc(dw * LINESIZE * sizeof(DATA32));
- if (!buf)
- {
- __imlib_FreeScaleInfo(scaleinfo);
- return;
- }
- /* setup h */
- h = dh;
- if (!IMAGE_HAS_ALPHA(im_dst))
- merge_alpha = 0;
- if (!IMAGE_HAS_ALPHA(im_src))
- {
- rgb_src = 1;
- if (merge_alpha)
- blend = 1;
- }
- /* scale in LINESIZE Y chunks and convert to depth*/
+ ImlibScaleInfo *scaleinfo = NULL;
+ DATA32 *buf = NULL;
+ int sx, sy, sw, sh, dx, dy, dw, dh, dxx, dyy, y2, x2;
+ int psx, psy, psw, psh;
+ int y, h, hh;
+ int do_mmx;
+
+ sx = ssx;
+ sy = ssy;
+ sw = ssw;
+ sh = ssh;
+ dx = ddx;
+ dy = ddy;
+ dw = abs(ddw);
+ dh = abs(ddh);
+ /* don't do anything if we have a 0 width or height image to render */
+ /* if the input rect size < 0 don't render either */
+ if ((dw <= 0) || (dh <= 0) || (sw <= 0) || (sh <= 0))
+ return;
+ /* clip the source rect to be within the actual image */
+ psx = sx;
+ psy = sy;
+ psw = sw;
+ psh = sh;
+ CLIP(sx, sy, sw, sh, 0, 0, im_src->w, im_src->h);
+ if (psx != sx)
+ dx += ((sx - psx) * abs(ddw)) / ssw;
+ if (psy != sy)
+ dy += ((sy - psy) * abs(ddh)) / ssh;
+ if (psw != sw)
+ dw = (dw * sw) / psw;
+ if (psh != sh)
+ dh = (dh * sh) / psh;
+ if ((dw <= 0) || (dh <= 0) || (sw <= 0) || (sh <= 0))
+ {
+ return;
+ }
+ /* clip output coords to clipped input coords */
+ psx = dx;
+ psy = dy;
+ psw = dw;
+ psh = dh;
+ x2 = sx;
+ y2 = sy;
+ CLIP(dx, dy, dw, dh, 0, 0, im_dst->w, im_dst->h);
+ if ((dw <= 0) || (dh <= 0) || (sw <= 0) || (sh <= 0))
+ return;
+ if (clw)
+ {
+ CLIP_TO(dx, dy, dw, dh, clx, cly, clw, clh);
+ if ((dw < 1) || (dh < 1))
+ return;
+ }
+ if (psx != dx)
+ sx += ((dx - psx) * ssw) / abs(ddw);
+ if (psy != dy)
+ sy += ((dy - psy) * ssh) / abs(ddh);
+ if (psw != dw)
+ sw = (sw * dw) / psw;
+ if (psh != dh)
+ sh = (sh * dh) / psh;
+ dxx = dx - psx;
+ dyy = dy - psy;
+ dxx += (x2 * abs(ddw)) / ssw;
+ dyy += (y2 * abs(ddh)) / ssh;
+
+ if ((dw > 0) && (sw == 0))
+ sw = 1;
+ if ((dh > 0) && (sh == 0))
+ sh = 1;
+ /* do a second check to see if we now have invalid coords */
+ /* don't do anything if we have a 0 width or height image to render */
+ /* if the input rect size < 0 don't render either */
+ if ((dw <= 0) || (dh <= 0) || (sw <= 0) || (sh <= 0))
+ {
+ return;
+ }
+ scaleinfo = __imlib_CalcScaleInfo(im_src, ssw, ssh, ddw, ddh, aa);
+ if (!scaleinfo)
+ return;
+ /* if we are scaling the image at all make a scaling buffer */
+ /* allocate a buffer to render scaled RGBA data into */
+ buf = malloc(dw * LINESIZE * sizeof(DATA32));
+ if (!buf)
+ {
+ __imlib_FreeScaleInfo(scaleinfo);
+ return;
+ }
+ /* setup h */
+ h = dh;
+ if (!IMAGE_HAS_ALPHA(im_dst))
+ merge_alpha = 0;
+ if (!IMAGE_HAS_ALPHA(im_src))
+ {
+ rgb_src = 1;
+ if (merge_alpha)
+ blend = 1;
+ }
+ /* scale in LINESIZE Y chunks and convert to depth */
#ifdef DO_MMX_ASM
- do_mmx = __imlib_get_cpuid() & CPUID_MMX;
+ do_mmx = __imlib_get_cpuid() & CPUID_MMX;
#endif
- for (y = 0; y < dh; y += LINESIZE)
- {
- hh = LINESIZE;
- if (h < LINESIZE)
- hh = h;
- /* scale the imagedata for this LINESIZE lines chunk of image */
- if (aa)
- {
+ for (y = 0; y < dh; y += LINESIZE)
+ {
+ hh = LINESIZE;
+ if (h < LINESIZE)
+ hh = h;
+ /* scale the imagedata for this LINESIZE lines chunk of image */
+ if (aa)
+ {
#ifdef DO_MMX_ASM
- if (do_mmx)
- __imlib_Scale_mmx_AARGBA(scaleinfo, buf, dxx, dyy + y,
- 0, 0, dw, hh, dw, im_src->w);
- else
+ if (do_mmx)
+ __imlib_Scale_mmx_AARGBA(scaleinfo, buf, dxx, dyy + y,
+ 0, 0, dw, hh, dw, im_src->w);
+ else
#endif
- if (IMAGE_HAS_ALPHA(im_src))
- __imlib_ScaleAARGBA(scaleinfo, buf, dxx, dyy + y,
- 0, 0, dw, hh, dw, im_src->w);
- else
- __imlib_ScaleAARGB(scaleinfo, buf, dxx, dyy + y,
- 0, 0, dw, hh, dw, im_src->w);
- }
- else
- __imlib_ScaleSampleRGBA(scaleinfo, buf, dxx, dyy + y,
- 0, 0, dw, hh, dw);
- __imlib_BlendRGBAToData(buf, dw, hh,
- im_dst->data, im_dst->w,
- im_dst->h,
- 0, 0, dx, dy + y, dw, dh,
- blend, merge_alpha, cm, op, rgb_src);
- h -= LINESIZE;
- }
- /* free up our buffers and point tables */
- free(buf);
- __imlib_FreeScaleInfo(scaleinfo);
+ if (IMAGE_HAS_ALPHA(im_src))
+ __imlib_ScaleAARGBA(scaleinfo, buf, dxx, dyy + y,
+ 0, 0, dw, hh, dw, im_src->w);
+ else
+ __imlib_ScaleAARGB(scaleinfo, buf, dxx, dyy + y,
+ 0, 0, dw, hh, dw, im_src->w);
+ }
+ else
+ __imlib_ScaleSampleRGBA(scaleinfo, buf, dxx, dyy + y,
+ 0, 0, dw, hh, dw);
+ __imlib_BlendRGBAToData(buf, dw, hh,
+ im_dst->data, im_dst->w,
+ im_dst->h,
+ 0, 0, dx, dy + y, dw, dh,
+ blend, merge_alpha, cm, op, rgb_src);
+ h -= LINESIZE;
+ }
+ /* free up our buffers and point tables */
+ free(buf);
+ __imlib_FreeScaleInfo(scaleinfo);
}
}
diff --git a/src/color.c b/src/color.c
index 2208013..e611c55 100644
--- a/src/color.c
+++ b/src/color.c
@@ -3,518 +3,555 @@
#include <X11/Xutil.h>
#include "color.h"
-DATA8 _pal_type = 0;
-DATA16 _max_colors = 256;
+DATA8 _pal_type = 0;
+DATA16 _max_colors = 256;
int
-__imlib_XActualDepth(Display *d, Visual *v)
+__imlib_XActualDepth(Display * d, Visual * v)
{
- XVisualInfo xvi, *xvir;
- int depth = 0, num;
-
+ XVisualInfo xvi, *xvir;
+ int depth = 0, num;
+
xvi.visual = v;
xvi.visualid = XVisualIDFromVisual(v);
xvir = XGetVisualInfo(d, VisualIDMask, &xvi, &num);
if (xvir)
{
- depth = xvir[0].depth;
- if ((depth == 16) &&
- ((xvir->red_mask | xvir->green_mask | xvir->blue_mask) == 0x7fff))
- depth = 15;
- XFree(xvir);
+ depth = xvir[0].depth;
+ if ((depth == 16) &&
+ ((xvir->red_mask | xvir->green_mask | xvir->blue_mask) == 0x7fff))
+ depth = 15;
+ XFree(xvir);
}
return depth;
}
-Visual *
-__imlib_BestVisual(Display *d, int screen, int *depth_return)
+Visual *
+__imlib_BestVisual(Display * d, int screen, int *depth_return)
{
- XVisualInfo xvi, *xvir;
- int j, i, num, maxd = 0;
- Visual *v = NULL;
- const int visprefs[] =
- {PseudoColor, TrueColor, DirectColor, StaticColor, GrayScale, StaticGray};
-
+ XVisualInfo xvi, *xvir;
+ int j, i, num, maxd = 0;
+ Visual *v = NULL;
+ const int visprefs[] =
+ { PseudoColor, TrueColor, DirectColor, StaticColor, GrayScale,
+StaticGray };
+
xvi.screen = screen;
maxd = 0;
for (j = 0; j < 6; j++)
{
- xvi.class = visprefs[j];
- xvir = XGetVisualInfo(d, VisualScreenMask | VisualClassMask,
- &xvi, &num);
- if (xvir)
- {
- for (i = 0; i < num; i++)
- {
- if ((xvir[i].depth > 1) &&
- (xvir[i].depth >= maxd) &&
- (xvi.class == PseudoColor))
- {
- maxd = xvir[i].depth;
- v = xvir[i].visual;
- }
- else if ((xvir[i].depth > maxd) &&
- (xvir[i].depth <= 24))
- {
- maxd = xvir[i].depth;
- v = xvir[i].visual;
- }
- }
- XFree(xvir);
- }
+ xvi.class = visprefs[j];
+ xvir = XGetVisualInfo(d, VisualScreenMask | VisualClassMask,
+ &xvi, &num);
+ if (xvir)
+ {
+ for (i = 0; i < num; i++)
+ {
+ if ((xvir[i].depth > 1) &&
+ (xvir[i].depth >= maxd) && (xvi.class == PseudoColor))
+ {
+ maxd = xvir[i].depth;
+ v = xvir[i].visual;
+ }
+ else if ((xvir[i].depth > maxd) && (xvir[i].depth <= 24))
+ {
+ maxd = xvir[i].depth;
+ v = xvir[i].visual;
+ }
+ }
+ XFree(xvir);
+ }
}
if (depth_return)
*depth_return = maxd;
return v;
}
-DATA8 *
-__imlib_AllocColorTable(Display *d, Colormap cmap, DATA8 *type_return, Visual *v)
+DATA8 *
+__imlib_AllocColorTable(Display * d, Colormap cmap, DATA8 * type_return,
+ Visual * v)
{
- DATA8 *color_lut = NULL;
+ DATA8 *color_lut = NULL;
if (v->bits_per_rgb > 1)
{
- if ((_max_colors >= 256) && (color_lut = __imlib_AllocColors332(d, cmap, v)))
- {
- *type_return = _pal_type;
- return color_lut;
- }
- if ((_max_colors >= 216) && (color_lut = __imlib_AllocColors666(d, cmap, v)))
- {
- *type_return = _pal_type;
- return color_lut;
- }
- if ((_max_colors >= 128) && (color_lut = __imlib_AllocColors232(d, cmap, v)))
- {
- *type_return = _pal_type;
- return color_lut;
- }
- if ((_max_colors >= 64) && (color_lut = __imlib_AllocColors222(d, cmap, v)))
- {
- *type_return = _pal_type;
- return color_lut;
- }
- if ((_max_colors >= 32) && (color_lut = __imlib_AllocColors221(d, cmap, v)))
- {
- *type_return = _pal_type;
- return color_lut;
- }
- if ((_max_colors >= 16) && (color_lut = __imlib_AllocColors121(d, cmap, v)))
- {
- *type_return = _pal_type;
- return color_lut;
- }
+ if ((_max_colors >= 256)
+ && (color_lut = __imlib_AllocColors332(d, cmap, v)))
+ {
+ *type_return = _pal_type;
+ return color_lut;
+ }
+ if ((_max_colors >= 216)
+ && (color_lut = __imlib_AllocColors666(d, cmap, v)))
+ {
+ *type_return = _pal_type;
+ return color_lut;
+ }
+ if ((_max_colors >= 128)
+ && (color_lut = __imlib_AllocColors232(d, cmap, v)))
+ {
+ *type_return = _pal_type;
+ return color_lut;
+ }
+ if ((_max_colors >= 64)
+ && (color_lut = __imlib_AllocColors222(d, cmap, v)))
+ {
+ *type_return = _pal_type;
+ return color_lut;
+ }
+ if ((_max_colors >= 32)
+ && (color_lut = __imlib_AllocColors221(d, cmap, v)))
+ {
+ *type_return = _pal_type;
+ return color_lut;
+ }
+ if ((_max_colors >= 16)
+ && (color_lut = __imlib_AllocColors121(d, cmap, v)))
+ {
+ *type_return = _pal_type;
+ return color_lut;
+ }
}
if ((_max_colors >= 8) && (color_lut = __imlib_AllocColors111(d, cmap, v)))
{
- *type_return = _pal_type;
- return color_lut;
+ *type_return = _pal_type;
+ return color_lut;
}
color_lut = __imlib_AllocColors1(d, cmap, v);
*type_return = _pal_type;
return color_lut;
}
-DATA8 *
-__imlib_AllocColors332(Display *d, Colormap cmap, Visual *v)
+DATA8 *
+__imlib_AllocColors332(Display * d, Colormap cmap, Visual * v)
{
- int r, g, b, i;
- DATA8 *color_lut;
- int sig_mask = 0;
-
- for (i = 0; i < v->bits_per_rgb; i++) sig_mask |= (0x1 << i);
+ int r, g, b, i;
+ DATA8 *color_lut;
+ int sig_mask = 0;
+
+ for (i = 0; i < v->bits_per_rgb; i++)
+ sig_mask |= (0x1 << i);
sig_mask <<= (16 - v->bits_per_rgb);
i = 0;
color_lut = malloc(256 * sizeof(DATA8));
for (r = 0; r < 8; r++)
{
- for (g = 0; g < 8; g++)
- {
- for (b = 0; b < 4; b++)
- {
- XColor xcl;
- XColor xcl_in;
- int val;
- Status ret;
-
- val = (r << 6) | (r << 3) | (r);
- xcl.red = (unsigned short)((val << 7) | (val >> 2));
- val = (g << 6) | (g << 3) | (g);
- xcl.green = (unsigned short)((val << 7) | (val >> 2));
- val = (b << 6) | (b << 4) | (b << 2) | (b);
- xcl.blue = (unsigned short)((val << 8) | (val));
- xcl_in = xcl;
- ret = XAllocColor(d, cmap, &xcl);
- if ((ret == Success) ||
- ((xcl_in.red & sig_mask) != (xcl.red & sig_mask)) ||
- ((xcl_in.green & sig_mask) != (xcl.green & sig_mask)) ||
- ((xcl_in.blue & sig_mask) != (xcl.blue & sig_mask)))
- {
- unsigned long pixels[256];
- int j;
-
- if (i > 0)
- {
- for(j = 0; j < i; j++)
- pixels[j] = (unsigned long) color_lut[j];
- XFreeColors(d, cmap, pixels, i, 0);
- }
- free(color_lut);
- return NULL;
- }
- color_lut[i] = xcl.pixel;
- i++;
- }
- }
+ for (g = 0; g < 8; g++)
+ {
+ for (b = 0; b < 4; b++)
+ {
+ XColor xcl;
+ XColor xcl_in;
+ int val;
+ Status ret;
+
+ val = (r << 6) | (r << 3) | (r);
+ xcl.red = (unsigned short)((val << 7) | (val >> 2));
+ val = (g << 6) | (g << 3) | (g);
+ xcl.green = (unsigned short)((val << 7) | (val >> 2));
+ val = (b << 6) | (b << 4) | (b << 2) | (b);
+ xcl.blue = (unsigned short)((val << 8) | (val));
+ xcl_in = xcl;
+ ret = XAllocColor(d, cmap, &xcl);
+ if ((ret == Success) ||
+ ((xcl_in.red & sig_mask) != (xcl.red & sig_mask)) ||
+ ((xcl_in.green & sig_mask) != (xcl.green & sig_mask)) ||
+ ((xcl_in.blue & sig_mask) != (xcl.blue & sig_mask)))
+ {
+ unsigned long pixels[256];
+ int j;
+
+ if (i > 0)
+ {
+ for (j = 0; j < i; j++)
+ pixels[j] = (unsigned long)color_lut[j];
+ XFreeColors(d, cmap, pixels, i, 0);
+ }
+ free(color_lut);
+ return NULL;
+ }
+ color_lut[i] = xcl.pixel;
+ i++;
+ }
+ }
}
_pal_type = 0;
return color_lut;
}
-DATA8 *
-__imlib_AllocColors666(Display *d, Colormap cmap, Visual *v)
+DATA8 *
+__imlib_AllocColors666(Display * d, Colormap cmap, Visual * v)
{
- int r, g, b, i;
- DATA8 *color_lut;
- int sig_mask = 0;
-
- for (i = 0; i < v->bits_per_rgb; i++) sig_mask |= (0x1 << i);
+ int r, g, b, i;
+ DATA8 *color_lut;
+ int sig_mask = 0;
+
+ for (i = 0; i < v->bits_per_rgb; i++)
+ sig_mask |= (0x1 << i);
sig_mask <<= (16 - v->bits_per_rgb);
i = 0;
color_lut = malloc(256 * sizeof(DATA8));
for (r = 0; r < 6; r++)
{
- for (g = 0; g < 6; g++)
- {
- for (b = 0; b < 6; b++)
- {
- XColor xcl;
- XColor xcl_in;
- int val;
- Status ret;
-
- val = (int)((((double)r) / 5.0) * 65535);
- xcl.red = (unsigned short)(val);
- val = (int)((((double)g) / 5.0) * 65535);
- xcl.green = (unsigned short)(val);
- val = (int)((((double)b) / 5.0) * 65535);
- xcl.blue = (unsigned short)(val);
- xcl_in = xcl;
- ret = XAllocColor(d, cmap, &xcl);
- if ((ret == Success) ||
- ((xcl_in.red & sig_mask) != (xcl.red & sig_mask)) ||
- ((xcl_in.green & sig_mask) != (xcl.green & sig_mask)) ||
- ((xcl_in.blue & sig_mask) != (xcl.blue & sig_mask)))
- {
- unsigned long pixels[256];
- int j;
-
- if (i > 0)
- {
- for(j = 0; j < i; j++)
- pixels[j] = (unsigned long) color_lut[j];
- XFreeColors(d, cmap, pixels, i, 0);
- }
- free(color_lut);
- return NULL;
- }
- color_lut[i] = xcl.pixel;
- i++;
- }
- }
+ for (g = 0; g < 6; g++)
+ {
+ for (b = 0; b < 6; b++)
+ {
+ XColor xcl;
+ XColor xcl_in;
+ int val;
+ Status ret;
+
+ val = (int)((((double)r) / 5.0) * 65535);
+ xcl.red = (unsigned short)(val);
+ val = (int)((((double)g) / 5.0) * 65535);
+ xcl.green = (unsigned short)(val);
+ val = (int)((((double)b) / 5.0) * 65535);
+ xcl.blue = (unsigned short)(val);
+ xcl_in = xcl;
+ ret = XAllocColor(d, cmap, &xcl);
+ if ((ret == Success) ||
+ ((xcl_in.red & sig_mask) != (xcl.red & sig_mask)) ||
+ ((xcl_in.green & sig_mask) != (xcl.green & sig_mask)) ||
+ ((xcl_in.blue & sig_mask) != (xcl.blue & sig_mask)))
+ {
+ unsigned long pixels[256];
+ int j;
+
+ if (i > 0)
+ {
+ for (j = 0; j < i; j++)
+ pixels[j] = (unsigned long)color_lut[j];
+ XFreeColors(d, cmap, pixels, i, 0);
+ }
+ free(color_lut);
+ return NULL;
+ }
+ color_lut[i] = xcl.pixel;
+ i++;
+ }
+ }
}
_pal_type = 7;
return color_lut;
}
-DATA8 *
-__imlib_AllocColors232(Display *d, Colormap cmap, Visual *v)
+DATA8 *
+__imlib_AllocColors232(Display * d, Colormap cmap, Visual * v)
{
- int r, g, b, i;
- DATA8 *color_lut;
- int sig_mask = 0;
-
- for (i = 0; i < v->bits_per_rgb; i++) sig_mask |= (0x1 << i);
+ int r, g, b, i;
+ DATA8 *color_lut;
+ int sig_mask = 0;
+
+ for (i = 0; i < v->bits_per_rgb; i++)
+ sig_mask |= (0x1 << i);
sig_mask <<= (16 - v->bits_per_rgb);
i = 0;
- color_lut = malloc(128 * sizeof(DATA8));
+ color_lut = malloc(128 * sizeof(DATA8));
for (r = 0; r < 4; r++)
{
- for (g = 0; g < 8; g++)
- {
- for (b = 0; b < 4; b++)
- {
- XColor xcl;
- XColor xcl_in;
- int val;
- Status ret;
-
- val = (r << 6) | (r << 4) | (r << 2) | (r);
- xcl.red = (unsigned short)((val << 8) | (val));
- val = (g << 6) | (g << 3) | (g);
- xcl.green = (unsigned short)((val << 7) | (val >> 2));
- val = (b << 6) | (b << 4) | (b << 2) | (b);
- xcl.blue = (unsigned short)((val << 8) | (val));
- xcl_in = xcl;
- ret = XAllocColor(d, cmap, &xcl);
- if ((ret == Success) ||
- ((xcl_in.red & sig_mask) != (xcl.red & sig_mask)) ||
- ((xcl_in.green & sig_mask) != (xcl.green & sig_mask)) ||
- ((xcl_in.blue & sig_mask) != (xcl.blue & sig_mask)))
- {
- unsigned long pixels[256];
- int j;
-
- if (i > 0)
- {
- for(j = 0; j < i; j++)
- pixels[j] = (unsigned long) color_lut[j];
- XFreeColors(d, cmap, pixels, i, 0);
- }
- free(color_lut);
- return NULL;
- }
- color_lut[i] = xcl.pixel;
- i++;
- }
- }
+ for (g = 0; g < 8; g++)
+ {
+ for (b = 0; b < 4; b++)
+ {
+ XColor xcl;
+ XColor xcl_in;
+ int val;
+ Status ret;
+
+ val = (r << 6) | (r << 4) | (r << 2) | (r);
+ xcl.red = (unsigned short)((val << 8) | (val));
+ val = (g << 6) | (g << 3) | (g);
+ xcl.green = (unsigned short)((val << 7) | (val >> 2));
+ val = (b << 6) | (b << 4) | (b << 2) | (b);
+ xcl.blue = (unsigned short)((val << 8) | (val));
+ xcl_in = xcl;
+ ret = XAllocColor(d, cmap, &xcl);
+ if ((ret == Success) ||
+ ((xcl_in.red & sig_mask) != (xcl.red & sig_mask)) ||
+ ((xcl_in.green & sig_mask) != (xcl.green & sig_mask)) ||
+ ((xcl_in.blue & sig_mask) != (xcl.blue & sig_mask)))
+ {
+ unsigned long pixels[256];
+ int j;
+
+ if (i > 0)
+ {
+ for (j = 0; j < i; j++)
+ pixels[j] = (unsigned long)color_lut[j];
+ XFreeColors(d, cmap, pixels, i, 0);
+ }
+ free(color_lut);
+ return NULL;
+ }
+ color_lut[i] = xcl.pixel;
+ i++;
+ }
+ }
}
_pal_type = 1;
return color_lut;
}
-DATA8 *
-__imlib_AllocColors222(Display *d, Colormap cmap, Visual *v)
+DATA8 *
+__imlib_AllocColors222(Display * d, Colormap cmap, Visual * v)
{
- int r, g, b, i;
- DATA8 *color_lut;
- int sig_mask = 0;
-
- for (i = 0; i < v->bits_per_rgb; i++) sig_mask |= (0x1 << i);
+ int r, g, b, i;
+ DATA8 *color_lut;
+ int sig_mask = 0;
+
+ for (i = 0; i < v->bits_per_rgb; i++)
+ sig_mask |= (0x1 << i);
sig_mask <<= (16 - v->bits_per_rgb);
i = 0;
- color_lut = malloc(64 * sizeof(DATA8));
+ color_lut = malloc(64 * sizeof(DATA8));
for (r = 0; r < 4; r++)
{
- for (g = 0; g < 4; g++)
- {
- for (b = 0; b < 4; b++)
- {
- XColor xcl;
- XColor xcl_in;
- int val;
- Status ret;
-
- val = (r << 6) | (r << 4) | (r << 2) | (r);
- xcl.red = (unsigned short)((val << 8) | (val));
- val = (g << 6) | (g << 4) | (g << 2) | (g);
- xcl.green = (unsigned short)((val << 8) | (val));
- val = (b << 6) | (b << 4) | (b << 2) | (b);
- xcl.blue = (unsigned short)((val << 8) | (val));
- xcl_in = xcl;
- ret = XAllocColor(d, cmap, &xcl);
- if ((ret == Success) ||
- ((xcl_in.red & sig_mask) != (xcl.red & sig_mask)) ||
- ((xcl_in.green & sig_mask) != (xcl.green & sig_mask)) ||
- ((xcl_in.blue & sig_mask) != (xcl.blue & sig_mask)))
- {
- unsigned long pixels[256];
- int j;
-
- if (i > 0)
- {
- for(j = 0; j < i; j++)
- pixels[j] = (unsigned long) color_lut[j];
- XFreeColors(d, cmap, pixels, i, 0);
- }
- free(color_lut);
- return NULL;
- }
- color_lut[i] = xcl.pixel;
- i++;
- }
- }
+ for (g = 0; g < 4; g++)
+ {
+ for (b = 0; b < 4; b++)
+ {
+ XColor xcl;
+ XColor xcl_in;
+ int val;
+ Status ret;
+
+ val = (r << 6) | (r << 4) | (r << 2) | (r);
+ xcl.red = (unsigned short)((val << 8) | (val));
+ val = (g << 6) | (g << 4) | (g << 2) | (g);
+ xcl.green = (unsigned short)((val << 8) | (val));
+ val = (b << 6) | (b << 4) | (b << 2) | (b);
+ xcl.blue = (unsigned short)((val << 8) | (val));
+ xcl_in = xcl;
+ ret = XAllocColor(d, cmap, &xcl);
+ if ((ret == Success) ||
+ ((xcl_in.red & sig_mask) != (xcl.red & sig_mask)) ||
+ ((xcl_in.green & sig_mask) != (xcl.green & sig_mask)) ||
+ ((xcl_in.blue & sig_mask) != (xcl.blue & sig_mask)))
+ {
+ unsigned long pixels[256];
+ int j;
+
+ if (i > 0)
+ {
+ for (j = 0; j < i; j++)
+ pixels[j] = (unsigned long)color_lut[j];
+ XFreeColors(d, cmap, pixels, i, 0);
+ }
+ free(color_lut);
+ return NULL;
+ }
+ color_lut[i] = xcl.pixel;
+ i++;
+ }
+ }
}
_pal_type = 2;
return color_lut;
}
-DATA8 *
-__imlib_AllocColors221(Display *d, Colormap cmap, Visual *v)
+DATA8 *
+__imlib_AllocColors221(Display * d, Colormap cmap, Visual * v)
{
- int r, g, b, i;
- DATA8 *color_lut;
- int sig_mask = 0;
-
- for (i = 0; i < v->bits_per_rgb; i++) sig_mask |= (0x1 << i);
+ int r, g, b, i;
+ DATA8 *color_lut;
+ int sig_mask = 0;
+
+ for (i = 0; i < v->bits_per_rgb; i++)
+ sig_mask |= (0x1 << i);
sig_mask <<= (16 - v->bits_per_rgb);
i = 0;
- color_lut = malloc(32 * sizeof(DATA8));
+ color_lut = malloc(32 * sizeof(DATA8));
for (r = 0; r < 4; r++)
{
- for (g = 0; g < 4; g++)
- {
- for (b = 0; b < 2; b++)
- {
- XColor xcl;
- XColor xcl_in;
- int val;
- Status ret;
-
- val = (r << 6) | (r << 4) | (r << 2) | (r);
- xcl.red = (unsigned short)((val << 8) | (val));
- val = (g << 6) | (g << 4) | (g << 2) | (g);
- xcl.green = (unsigned short)((val << 8) | (val));
- val = (b << 7) | (b << 6) | (b << 5) | (b << 4) | (b << 3) | (b << 2) | (b << 1) | (b);
- xcl.blue = (unsigned short)((val << 8) | (val));
- xcl_in = xcl;
- ret = XAllocColor(d, cmap, &xcl);
- if ((ret == Success) ||
- ((xcl_in.red & sig_mask) != (xcl.red & sig_mask)) ||
- ((xcl_in.green & sig_mask) != (xcl.green & sig_mask)) ||
- ((xcl_in.blue & sig_mask) != (xcl.blue & sig_mask)))
- {
- unsigned long pixels[256];
- int j;
-
- if (i > 0)
- {
- for(j = 0; j < i; j++)
- pixels[j] = (unsigned long) color_lut[j];
- XFreeColors(d, cmap, pixels, i, 0);
- }
- free(color_lut);
- return NULL;
- }
- color_lut[i] = xcl.pixel;
- i++;
- }
- }
+ for (g = 0; g < 4; g++)
+ {
+ for (b = 0; b < 2; b++)
+ {
+ XColor xcl;
+ XColor xcl_in;
+ int val;
+ Status ret;
+
+ val = (r << 6) | (r << 4) | (r << 2) | (r);
+ xcl.red = (unsigned short)((val << 8) | (val));
+ val = (g << 6) | (g << 4) | (g << 2) | (g);
+ xcl.green = (unsigned short)((val << 8) | (val));
+ val =
+ (b << 7) | (b << 6) | (b << 5) | (b << 4) | (b << 3) | (b
+ <<
+ 2)
+ | (b << 1) | (b);
+ xcl.blue = (unsigned short)((val << 8) | (val));
+ xcl_in = xcl;
+ ret = XAllocColor(d, cmap, &xcl);
+ if ((ret == Success) ||
+ ((xcl_in.red & sig_mask) != (xcl.red & sig_mask)) ||
+ ((xcl_in.green & sig_mask) != (xcl.green & sig_mask)) ||
+ ((xcl_in.blue & sig_mask) != (xcl.blue & sig_mask)))
+ {
+ unsigned long pixels[256];
+ int j;
+
+ if (i > 0)
+ {
+ for (j = 0; j < i; j++)
+ pixels[j] = (unsigned long)color_lut[j];
+ XFreeColors(d, cmap, pixels, i, 0);
+ }
+ free(color_lut);
+ return NULL;
+ }
+ color_lut[i] = xcl.pixel;
+ i++;
+ }
+ }
}
_pal_type = 3;
return color_lut;
}
-DATA8 *
-__imlib_AllocColors121(Display *d, Colormap cmap, Visual *v)
+DATA8 *
+__imlib_AllocColors121(Display * d, Colormap cmap, Visual * v)
{
- int r, g, b, i;
- DATA8 *color_lut;
- int sig_mask = 0;
-
- for (i = 0; i < v->bits_per_rgb; i++) sig_mask |= (0x1 << i);
+ int r, g, b, i;
+ DATA8 *color_lut;
+ int sig_mask = 0;
+
+ for (i = 0; i < v->bits_per_rgb; i++)
+ sig_mask |= (0x1 << i);
sig_mask <<= (16 - v->bits_per_rgb);
i = 0;
- color_lut = malloc(16 * sizeof(DATA8));
+ color_lut = malloc(16 * sizeof(DATA8));
for (r = 0; r < 2; r++)
{
- for (g = 0; g < 4; g++)
- {
- for (b = 0; b < 2; b++)
- {
- XColor xcl;
- XColor xcl_in;
- int val;
- Status ret;
-
- val = (r << 7) | (r << 6) | (r << 5) | (r << 4) | (r << 3) | (r << 2) | (r << 1) | (r);
- xcl.red = (unsigned short)((val << 8) | (val));
- val = (g << 6) | (g << 4) | (g << 2) | (g);
- xcl.green = (unsigned short)((val << 8) | (val));
- val = (b << 7) | (b << 6) | (b << 5) | (b << 4) | (b << 3) | (b << 2) | (b << 1) | (b);
- xcl.blue = (unsigned short)((val << 8) | (val));
- xcl_in = xcl;
- ret = XAllocColor(d, cmap, &xcl);
- if ((ret == Success) ||
- ((xcl_in.red & sig_mask) != (xcl.red & sig_mask)) ||
- ((xcl_in.green & sig_mask) != (xcl.green & sig_mask)) ||
- ((xcl_in.blue & sig_mask) != (xcl.blue & sig_mask)))
- {
- unsigned long pixels[256];
- int j;
-
- if (i > 0)
- {
- for(j = 0; j < i; j++)
- pixels[j] = (unsigned long) color_lut[j];
- XFreeColors(d, cmap, pixels, i, 0);
- }
- free(color_lut);
- return NULL;
- }
- color_lut[i] = xcl.pixel;
- i++;
- }
- }
+ for (g = 0; g < 4; g++)
+ {
+ for (b = 0; b < 2; b++)
+ {
+ XColor xcl;
+ XColor xcl_in;
+ int val;
+ Status ret;
+
+ val =
+ (r << 7) | (r << 6) | (r << 5) | (r << 4) | (r << 3) | (r
+ <<
+ 2)
+ | (r << 1) | (r);
+ xcl.red = (unsigned short)((val << 8) | (val));
+ val = (g << 6) | (g << 4) | (g << 2) | (g);
+ xcl.green = (unsigned short)((val << 8) | (val));
+ val =
+ (b << 7) | (b << 6) | (b << 5) | (b << 4) | (b << 3) | (b
+ <<
+ 2)
+ | (b << 1) | (b);
+ xcl.blue = (unsigned short)((val << 8) | (val));
+ xcl_in = xcl;
+ ret = XAllocColor(d, cmap, &xcl);
+ if ((ret == Success) ||
+ ((xcl_in.red & sig_mask) != (xcl.red & sig_mask)) ||
+ ((xcl_in.green & sig_mask) != (xcl.green & sig_mask)) ||
+ ((xcl_in.blue & sig_mask) != (xcl.blue & sig_mask)))
+ {
+ unsigned long pixels[256];
+ int j;
+
+ if (i > 0)
+ {
+ for (j = 0; j < i; j++)
+ pixels[j] = (unsigned long)color_lut[j];
+ XFreeColors(d, cmap, pixels, i, 0);
+ }
+ free(color_lut);
+ return NULL;
+ }
+ color_lut[i] = xcl.pixel;
+ i++;
+ }
+ }
}
_pal_type = 4;
return color_lut;
}
-DATA8 *
-__imlib_AllocColors111(Display *d, Colormap cmap, Visual *v)
+DATA8 *
+__imlib_AllocColors111(Display * d, Colormap cmap, Visual * v)
{
- int r, g, b, i ;
- DATA8 *color_lut;
- int sig_mask = 0;
-
- for (i = 0; i < v->bits_per_rgb; i++) sig_mask |= (0x1 << i);
+ int r, g, b, i;
+ DATA8 *color_lut;
+ int sig_mask = 0;
+
+ for (i = 0; i < v->bits_per_rgb; i++)
+ sig_mask |= (0x1 << i);
sig_mask <<= (16 - v->bits_per_rgb);
i = 0;
- color_lut = malloc(8 * sizeof(DATA8));
+ color_lut = malloc(8 * sizeof(DATA8));
for (r = 0; r < 2; r++)
{
- for (g = 0; g < 2; g++)
- {
- for (b = 0; b < 2; b++)
- {
- XColor xcl;
- XColor xcl_in;
- int val;
- Status ret;
-
- val = (r << 7) | (r << 6) | (r << 5) | (r << 4) | (r << 3) | (r << 2) | (r << 1) | (r);
- xcl.red = (unsigned short)((val << 8) | (val));
- val = (g << 7) | (g << 6) | (g << 5) | (g << 4) | (g << 3) | (g << 2) | (g << 1) | (g);
- xcl.green = (unsigned short)((val << 8) | (val));
- val = (b << 7) | (b << 6) | (b << 5) | (b << 4) | (b << 3) | (b << 2) | (b << 1) | (b);
- xcl.blue = (unsigned short)((val << 8) | (val));
- xcl_in = xcl;
- ret = XAllocColor(d, cmap, &xcl);
- if ((ret == Success) ||
- ((xcl_in.red & sig_mask) != (xcl.red & sig_mask)) ||
- ((xcl_in.green & sig_mask) != (xcl.green & sig_mask)) ||
- ((xcl_in.blue & sig_mask) != (xcl.blue & sig_mask)))
- {
- unsigned long pixels[256];
- int j;
-
- if (i > 0)
- {
- for(j = 0; j < i; j++)
- pixels[j] = (unsigned long) color_lut[j];
- XFreeColors(d, cmap, pixels, i, 0);
- }
- free(color_lut);
- return NULL;
- }
- color_lut[i] = xcl.pixel;
- i++;
- }
- }
+ for (g = 0; g < 2; g++)
+ {
+ for (b = 0; b < 2; b++)
+ {
+ XColor xcl;
+ XColor xcl_in;
+ int val;
+ Status ret;
+
+ val =
+ (r << 7) | (r << 6) | (r << 5) | (r << 4) | (r << 3) | (r
+ <<
+ 2)
+ | (r << 1) | (r);
+ xcl.red = (unsigned short)((val << 8) | (val));
+ val =
+ (g << 7) | (g << 6) | (g << 5) | (g << 4) | (g << 3) | (g
+ <<
+ 2)
+ | (g << 1) | (g);
+ xcl.green = (unsigned short)((val << 8) | (val));
+ val =
+ (b << 7) | (b << 6) | (b << 5) | (b << 4) | (b << 3) | (b
+ <<
+ 2)
+ | (b << 1) | (b);
+ xcl.blue = (unsigned short)((val << 8) | (val));
+ xcl_in = xcl;
+ ret = XAllocColor(d, cmap, &xcl);
+ if ((ret == Success) ||
+ ((xcl_in.red & sig_mask) != (xcl.red & sig_mask)) ||
+ ((xcl_in.green & sig_mask) != (xcl.green & sig_mask)) ||
+ ((xcl_in.blue & sig_mask) != (xcl.blue & sig_mask)))
+ {
+ unsigned long pixels[256];
+ int j;
+
+ if (i > 0)
+ {
+ for (j = 0; j < i; j++)
+ pixels[j] = (unsigned long)color_lut[j];
+ XFreeColors(d, cmap, pixels, i, 0);
+ }
+ free(color_lut);
+ return NULL;
+ }
+ color_lut[i] = xcl.pixel;
+ i++;
+ }
+ }
}
_pal_type = 5;
return color_lut;
}
-DATA8 *
-__imlib_AllocColors1(Display *d, Colormap cmap, Visual *v)
+DATA8 *
+__imlib_AllocColors1(Display * d, Colormap cmap, Visual * v)
{
- XColor xcl;
- DATA8 *color_lut;
+ XColor xcl;
+ DATA8 *color_lut;
- color_lut = malloc(2 * sizeof(DATA8));
+ color_lut = malloc(2 * sizeof(DATA8));
xcl.red = (unsigned short)(0x0000);
xcl.green = (unsigned short)(0x0000);
xcl.blue = (unsigned short)(0x0000);
diff --git a/src/color_helpers.c b/src/color_helpers.c
index 0f0dc51..69dc2d5 100644
--- a/src/color_helpers.c
+++ b/src/color_helpers.c
@@ -3,187 +3,233 @@
* Color space conversion helper routines
* Convert between rgb and hsv adn between rgb and hls
*/
-
+
void
-__imlib_rgb_to_hsv(int r, int g, int b, float *hue, float *saturation, float *value)
+__imlib_rgb_to_hsv(int r, int g, int b, float *hue, float *saturation,
+ float *value)
{
- int f;
- float i,j,k,max,min,d;
+ int f;
+ float i, j, k, max, min, d;
- i = ((float)r)/255.0;
- j = ((float)g)/255.0;
- k = ((float)b)/255.0;
+ i = ((float)r) / 255.0;
+ j = ((float)g) / 255.0;
+ k = ((float)b) / 255.0;
f = 0;
max = min = i;
- if (j>max) { max = j; f = 1; } else min = j;
- if (k>max) { max = k; f = 2; } else if (k<min) min = k;
+ if (j > max)
+ {
+ max = j;
+ f = 1;
+ }
+ else
+ min = j;
+ if (k > max)
+ {
+ max = k;
+ f = 2;
+ }
+ else if (k < min)
+ min = k;
d = max - min;
*value = max;
- if (max!=0) *saturation = d/max; else *saturation = 0;
- if (*saturation==0)
+ if (max != 0)
+ *saturation = d / max;
+ else
+ *saturation = 0;
+ if (*saturation == 0)
*hue = 0;
else
- {
- switch (f)
- {
- case 0:
- *hue = (j - k)/d;
- break;
- case 1:
- *hue = 2 + (k - i)/d;
- break;
- case 2:
- *hue = 4 + (i - j)/d;
- break;
- }
- *hue *= 60.0;
- if (*hue<0) *hue += 360.0;
- }
+ {
+ switch (f)
+ {
+ case 0:
+ *hue = (j - k) / d;
+ break;
+ case 1:
+ *hue = 2 + (k - i) / d;
+ break;
+ case 2:
+ *hue = 4 + (i - j) / d;
+ break;
+ }
+ *hue *= 60.0;
+ if (*hue < 0)
+ *hue += 360.0;
+ }
}
void
-__imlib_hsv_to_rgb(float hue, float saturation, float value, int *r, int *g, int *b)
+__imlib_hsv_to_rgb(float hue, float saturation, float value, int *r, int *g,
+ int *b)
{
- int i,p,q,t,h;
- float vs,vsf;
+ int i, p, q, t, h;
+ float vs, vsf;
- i = (int)(value*255.0);
- if (saturation==0)
+ i = (int)(value * 255.0);
+ if (saturation == 0)
*r = *g = *b = i;
else
- {
- if (hue==360) hue = 0;
- hue = hue/60.0;
- h = (int)hue;
- vs = value * saturation;
- vsf = vs * (hue - h);
- p = (int)(255.0 * (value - vs));
- q = (int)(255.0 * (value - vsf));
- t = (int)(255.0 * (value - vs + vsf));
- switch (h)
- {
- case 0:
- *r = i;
- *g = t;
- *b = p;
- break;
- case 1:
- *r = q;
- *g = i;
- *b = p;
- break;
- case 2:
- *r = p;
- *g = i;
- *b = t;
- break;
- case 3:
- *r = p;
- *g = q;
- *b = i;
- break;
- case 4:
- *r = t;
- *g = p;
- *b = i;
- break;
- case 5:
- *r = i;
- *g = p;
- *b = q;
- break;
- }
- }
+ {
+ if (hue == 360)
+ hue = 0;
+ hue = hue / 60.0;
+ h = (int)hue;
+ vs = value * saturation;
+ vsf = vs * (hue - h);
+ p = (int)(255.0 * (value - vs));
+ q = (int)(255.0 * (value - vsf));
+ t = (int)(255.0 * (value - vs + vsf));
+ switch (h)
+ {
+ case 0:
+ *r = i;
+ *g = t;
+ *b = p;
+ break;
+ case 1:
+ *r = q;
+ *g = i;
+ *b = p;
+ break;
+ case 2:
+ *r = p;
+ *g = i;
+ *b = t;
+ break;
+ case 3:
+ *r = p;
+ *g = q;
+ *b = i;
+ break;
+ case 4:
+ *r = t;
+ *g = p;
+ *b = i;
+ break;
+ case 5:
+ *r = i;
+ *g = p;
+ *b = q;
+ break;
+ }
+ }
}
void
-__imlib_rgb_to_hls(int r, int g, int b, float *hue, float *lightness, float *saturation)
+__imlib_rgb_to_hls(int r, int g, int b, float *hue, float *lightness,
+ float *saturation)
{
- int f;
- float i,j,k,max,min,d;
+ int f;
+ float i, j, k, max, min, d;
- i = ((float)r)/255.0;
- j = ((float)g)/255.0;
- k = ((float)b)/255.0;
+ i = ((float)r) / 255.0;
+ j = ((float)g) / 255.0;
+ k = ((float)b) / 255.0;
f = 0;
max = min = i;
- if (j>max) { max = j; f = 1; } else min = j;
- if (k>max) { max = k; f = 2; } else if (k<min) min = k;
+ if (j > max)
+ {
+ max = j;
+ f = 1;
+ }
+ else
+ min = j;
+ if (k > max)
+ {
+ max = k;
+ f = 2;
+ }
+ else if (k < min)
+ min = k;
d = max - min;
- *lightness = (max + min)/2.0;
- if (d==0)
- {
- *saturation = 0;
- *hue = 0;
- }
+ *lightness = (max + min) / 2.0;
+ if (d == 0)
+ {
+ *saturation = 0;
+ *hue = 0;
+ }
else
- {
- if (*lightness < 0.5) *saturation = d/(max + min); else *saturation = d/(2 - max - min);
- switch (f)
- {
- case 0:
- *hue = (j - k)/d;
- break;
- case 1:
- *hue = 2 + (k - i)/d;
- break;
- case 2:
- *hue = 4 + (i - j)/d;
- break;
- }
- *hue *= 60.0;
- if (*hue<0) *hue += 360.0;
- }
+ {
+ if (*lightness < 0.5)
+ *saturation = d / (max + min);
+ else
+ *saturation = d / (2 - max - min);
+ switch (f)
+ {
+ case 0:
+ *hue = (j - k) / d;
+ break;
+ case 1:
+ *hue = 2 + (k - i) / d;
+ break;
+ case 2:
+ *hue = 4 + (i - j) / d;
+ break;
+ }
+ *hue *= 60.0;
+ if (*hue < 0)
+ *hue += 360.0;
+ }
}
void
-__imlib_hls_to_rgb(float hue, float lightness, float saturation, int *r, int *g, int *b)
+__imlib_hls_to_rgb(float hue, float lightness, float saturation, int *r, int *g,
+ int *b)
{
- float m1,m2,m21,h;
+ float m1, m2, m21, h;
- if (saturation==0)
+ if (saturation == 0)
*r = *g = *b = (int)(lightness * 255.0);
else
- {
- if (lightness<=0.5)
- m2 = lightness * (1 + saturation);
- else
- m2 = lightness + saturation + lightness * saturation;
- m1 = 2 * lightness - m2;
- m21 = m2 - m1;
- h = hue + 120;
- if (h>360) h -= 360; else if (h<0) h += 360;
- if (h<60)
- *r = (int)(255.0 * (m1 + m21 * h/60.0));
- else if (h<180)
- *r = (int)(255.0 * m2);
- else if (h<240)
- *r = (int)(255.0 * (m1 + m21 * (240.0 - h)/60.0));
- else
- *r = (int)(255.0 * m1);
- h = hue;
- if (h>360) h -= 360; else if (h<0) h += 360;
- if (h<60)
- *g = (int)(255.0 * (m1 + m21 * h/60.0));
- else if (h<180)
- *g = (int)(255.0 * m2);
- else if (h<240)
- *g = (int)(255.0 * (m1 + m21 * (240.0 - h)/60.0));
- else
- *g = (int)(255.0 * m1);
- h = hue - 120;
- if (h>360) h -= 360; else if (h<0) h += 360;
- if (h<60)
- *b = (int)(255.0 * (m1 + m21 * h/60.0));
- else if (h<180)
- *b = (int)(255.0 * m2);
- else if (h<240)
- *b = (int)(255.0 * (m1 + m21 * (240.0 - h)/60.0));
- else
- *b = (int)(255.0 * m1);
- }
+ {
+ if (lightness <= 0.5)
+ m2 = lightness * (1 + saturation);
+ else
+ m2 = lightness + saturation + lightness * saturation;
+ m1 = 2 * lightness - m2;
+ m21 = m2 - m1;
+ h = hue + 120;
+ if (h > 360)
+ h -= 360;
+ else if (h < 0)
+ h += 360;
+ if (h < 60)
+ *r = (int)(255.0 * (m1 + m21 * h / 60.0));
+ else if (h < 180)
+ *r = (int)(255.0 * m2);
+ else if (h < 240)
+ *r = (int)(255.0 * (m1 + m21 * (240.0 - h) / 60.0));
+ else
+ *r = (int)(255.0 * m1);
+ h = hue;
+ if (h > 360)
+ h -= 360;
+ else if (h < 0)
+ h += 360;
+ if (h < 60)
+ *g = (int)(255.0 * (m1 + m21 * h / 60.0));
+ else if (h < 180)
+ *g = (int)(255.0 * m2);
+ else if (h < 240)
+ *g = (int)(255.0 * (m1 + m21 * (240.0 - h) / 60.0));
+ else
+ *g = (int)(255.0 * m1);
+ h = hue - 120;
+ if (h > 360)
+ h -= 360;
+ else if (h < 0)
+ h += 360;
+ if (h < 60)
+ *b = (int)(255.0 * (m1 + m21 * h / 60.0));
+ else if (h < 180)
+ *b = (int)(255.0 * m2);
+ else if (h < 240)
+ *b = (int)(255.0 * (m1 + m21 * (240.0 - h) / 60.0));
+ else
+ *b = (int)(255.0 * m1);
+ }
}
diff --git a/src/colormod.c b/src/colormod.c
index 117ff6e..aa6fe75 100644
--- a/src/colormod.c
+++ b/src/colormod.c
@@ -6,121 +6,121 @@
#include "image.h"
#include "blend.h"
-static DATABIG mod_count = 0;
+static DATABIG mod_count = 0;
ImlibColorModifier *
__imlib_CreateCmod(void)
{
ImlibColorModifier *cm;
- int i;
-
+ int i;
+
cm = malloc(sizeof(ImlibColorModifier));
cm->modification_count = mod_count;
for (i = 0; i < 256; i++)
{
- cm->red_mapping[i] = (DATA8)i;
- cm->green_mapping[i] = (DATA8)i;
- cm->blue_mapping[i] = (DATA8)i;
- cm->alpha_mapping[i] = (DATA8)i;
+ cm->red_mapping[i] = (DATA8) i;
+ cm->green_mapping[i] = (DATA8) i;
+ cm->blue_mapping[i] = (DATA8) i;
+ cm->alpha_mapping[i] = (DATA8) i;
}
return cm;
}
void
-__imlib_FreeCmod(ImlibColorModifier *cm)
+__imlib_FreeCmod(ImlibColorModifier * cm)
{
free(cm);
}
void
-__imlib_CmodChanged(ImlibColorModifier *cm)
+__imlib_CmodChanged(ImlibColorModifier * cm)
{
mod_count++;
cm->modification_count = mod_count;
}
void
-__imlib_CmodSetTables(ImlibColorModifier *cm,
- DATA8 *r, DATA8 *g, DATA8 *b, DATA8 *a)
+__imlib_CmodSetTables(ImlibColorModifier * cm,
+ DATA8 * r, DATA8 * g, DATA8 * b, DATA8 * a)
{
- int i;
-
+ int i;
+
for (i = 0; i < 256; i++)
{
- if (r)
- cm->red_mapping[i] = r[i];
- if (g)
- cm->green_mapping[i] = g[i];
- if (b)
- cm->blue_mapping[i] = b[i];
- if (a)
- cm->alpha_mapping[i] = a[i];
+ if (r)
+ cm->red_mapping[i] = r[i];
+ if (g)
+ cm->green_mapping[i] = g[i];
+ if (b)
+ cm->blue_mapping[i] = b[i];
+ if (a)
+ cm->alpha_mapping[i] = a[i];
}
__imlib_CmodChanged(cm);
}
void
-__imlib_CmodReset(ImlibColorModifier *cm)
+__imlib_CmodReset(ImlibColorModifier * cm)
{
- int i;
-
+ int i;
+
for (i = 0; i < 256; i++)
{
- cm->red_mapping[i] = (DATA8)i;
- cm->green_mapping[i] = (DATA8)i;
- cm->blue_mapping[i] = (DATA8)i;
- cm->alpha_mapping[i] = (DATA8)i;
+ cm->red_mapping[i] = (DATA8) i;
+ cm->green_mapping[i] = (DATA8) i;
+ cm->blue_mapping[i] = (DATA8) i;
+ cm->alpha_mapping[i] = (DATA8) i;
}
__imlib_CmodChanged(cm);
}
void
-__imlib_DataCmodApply(DATA32 *data, int w, int h, int jump,
- ImlibImageFlags *fl, ImlibColorModifier *cm)
+__imlib_DataCmodApply(DATA32 * data, int w, int h, int jump,
+ ImlibImageFlags * fl, ImlibColorModifier * cm)
{
- int x, y;
- DATA32 *p;
- DATA8 r, g, b, a;
-
+ int x, y;
+ DATA32 *p;
+ DATA8 r, g, b, a;
+
/* We might be adding alpha */
if (fl && !(*fl & F_HAS_ALPHA))
{
- p = data;
- for (y = 0; y < h; y++)
- {
- for (x = 0; x < w; x++)
- {
- R_VAL(p) = R_CMOD(cm, R_VAL(p));
- G_VAL(p) = G_CMOD(cm, G_VAL(p));
- B_VAL(p) = B_CMOD(cm, B_VAL(p));
- A_VAL(p) = A_CMOD(cm, 255);
- p++;
- }
- p += jump;
- }
- if (A_CMOD(cm, 255) != 255)
- *fl |= F_HAS_ALPHA;
- return;
+ p = data;
+ for (y = 0; y < h; y++)
+ {
+ for (x = 0; x < w; x++)
+ {
+ R_VAL(p) = R_CMOD(cm, R_VAL(p));
+ G_VAL(p) = G_CMOD(cm, G_VAL(p));
+ B_VAL(p) = B_CMOD(cm, B_VAL(p));
+ A_VAL(p) = A_CMOD(cm, 255);
+ p++;
+ }
+ p += jump;
+ }
+ if (A_CMOD(cm, 255) != 255)
+ *fl |= F_HAS_ALPHA;
+ return;
}
p = data;
for (y = 0; y < h; y++)
{
- for (x = 0; x < w; x++)
- {
- R_VAL(p) = R_CMOD(cm, R_VAL(p));
- G_VAL(p) = G_CMOD(cm, G_VAL(p));
- B_VAL(p) = B_CMOD(cm, B_VAL(p));
- A_VAL(p) = A_CMOD(cm, A_VAL(p));
- p++;
- }
- p += jump;
+ for (x = 0; x < w; x++)
+ {
+ R_VAL(p) = R_CMOD(cm, R_VAL(p));
+ G_VAL(p) = G_CMOD(cm, G_VAL(p));
+ B_VAL(p) = B_CMOD(cm, B_VAL(p));
+ A_VAL(p) = A_CMOD(cm, A_VAL(p));
+ p++;
+ }
+ p += jump;
}
}
void
-__imlib_CmodGetTables(ImlibColorModifier *cm, DATA8 *r, DATA8 *g,
- DATA8 *b, DATA8 *a)
+__imlib_CmodGetTables(ImlibColorModifier * cm, DATA8 * r, DATA8 * g,
+ DATA8 * b, DATA8 * a)
{
if (r)
memcpy(r, cm->red_mapping, (256 * sizeof(DATA8)));
@@ -133,86 +133,122 @@ __imlib_CmodGetTables(ImlibColorModifier *cm, DATA8 *r, DATA8 *g,
}
void
-__imlib_CmodModBrightness(ImlibColorModifier *cm, double v)
+__imlib_CmodModBrightness(ImlibColorModifier * cm, double v)
{
- int i, val, val2;
-
+ int i, val, val2;
+
val = (int)(v * 255);
for (i = 0; i < 256; i++)
{
- val2 = (int)cm->red_mapping[i] + val;
- if (val2 < 0) val2 = 0; if (val2 > 255) val2 = 255;
- cm->red_mapping[i] = (DATA8)val2;
-
- val2 = (int)cm->green_mapping[i] + val;
- if (val2 < 0) val2 = 0; if (val2 > 255) val2 = 255;
- cm->green_mapping[i] = (DATA8)val2;
-
- val2 = (int)cm->blue_mapping[i] + val;
- if (val2 < 0) val2 = 0; if (val2 > 255) val2 = 255;
- cm->blue_mapping[i] = (DATA8)val2;
-
- val2 = (int)cm->alpha_mapping[i] + val;
- if (val2 < 0) val2 = 0; if (val2 > 255) val2 = 255;
- cm->alpha_mapping[i] = (DATA8)val2;
+ val2 = (int)cm->red_mapping[i] + val;
+ if (val2 < 0)
+ val2 = 0;
+ if (val2 > 255)
+ val2 = 255;
+ cm->red_mapping[i] = (DATA8) val2;
+
+ val2 = (int)cm->green_mapping[i] + val;
+ if (val2 < 0)
+ val2 = 0;
+ if (val2 > 255)
+ val2 = 255;
+ cm->green_mapping[i] = (DATA8) val2;
+
+ val2 = (int)cm->blue_mapping[i] + val;
+ if (val2 < 0)
+ val2 = 0;
+ if (val2 > 255)
+ val2 = 255;
+ cm->blue_mapping[i] = (DATA8) val2;
+
+ val2 = (int)cm->alpha_mapping[i] + val;
+ if (val2 < 0)
+ val2 = 0;
+ if (val2 > 255)
+ val2 = 255;
+ cm->alpha_mapping[i] = (DATA8) val2;
}
}
void
-__imlib_CmodModContrast(ImlibColorModifier *cm, double v)
+__imlib_CmodModContrast(ImlibColorModifier * cm, double v)
{
- int i, val2;
-
+ int i, val2;
+
for (i = 0; i < 256; i++)
{
- val2 = (int)(((double)cm->red_mapping[i] - 127) * v) + 127;
- if (val2 < 0) val2 = 0; if (val2 > 255) val2 = 255;
- cm->red_mapping[i] = (DATA8)val2;
-
- val2 = (int)(((double)cm->green_mapping[i] - 127) * v) + 127;
- if (val2 < 0) val2 = 0; if (val2 > 255) val2 = 255;
- cm->green_mapping[i] = (DATA8)val2;
-
- val2 = (int)(((double)cm->blue_mapping[i] - 127) * v) + 127;
- if (val2 < 0) val2 = 0; if (val2 > 255) val2 = 255;
- cm->blue_mapping[i] = (DATA8)val2;
-
- val2 = (int)(((double)cm->alpha_mapping[i] - 127) * v) + 127;
- if (val2 < 0) val2 = 0; if (val2 > 255) val2 = 255;
- cm->alpha_mapping[i] = (DATA8)val2;
+ val2 = (int)(((double)cm->red_mapping[i] - 127) * v) + 127;
+ if (val2 < 0)
+ val2 = 0;
+ if (val2 > 255)
+ val2 = 255;
+ cm->red_mapping[i] = (DATA8) val2;
+
+ val2 = (int)(((double)cm->green_mapping[i] - 127) * v) + 127;
+ if (val2 < 0)
+ val2 = 0;
+ if (val2 > 255)
+ val2 = 255;
+ cm->green_mapping[i] = (DATA8) val2;
+
+ val2 = (int)(((double)cm->blue_mapping[i] - 127) * v) + 127;
+ if (val2 < 0)
+ val2 = 0;
+ if (val2 > 255)
+ val2 = 255;
+ cm->blue_mapping[i] = (DATA8) val2;
+
+ val2 = (int)(((double)cm->alpha_mapping[i] - 127) * v) + 127;
+ if (val2 < 0)
+ val2 = 0;
+ if (val2 > 255)
+ val2 = 255;
+ cm->alpha_mapping[i] = (DATA8) val2;
}
}
void
-__imlib_CmodModGamma(ImlibColorModifier *cm, double v)
+__imlib_CmodModGamma(ImlibColorModifier * cm, double v)
{
- int i, val2;
+ int i, val2;
if (v < 0.01)
v = 0.01;
for (i = 0; i < 256; i++)
{
- val2 = (int)(pow(((double)cm->red_mapping[i] / 255), (1 / v)) * 255);
- if (val2 < 0) val2 = 0; if (val2 > 255) val2 = 255;
- cm->red_mapping[i] = (DATA8)val2;
-
- val2 = (int)(pow(((double)cm->green_mapping[i] / 255), (1 / v)) * 255);
- if (val2 < 0) val2 = 0; if (val2 > 255) val2 = 255;
- cm->green_mapping[i] = (DATA8)val2;
-
- val2 = (int)(pow(((double)cm->blue_mapping[i] / 255), (1 / v)) * 255);
- if (val2 < 0) val2 = 0; if (val2 > 255) val2 = 255;
- cm->blue_mapping[i] = (DATA8)val2;
-
- val2 = (int)(pow(((double)cm->alpha_mapping[i] / 255), (1 / v)) * 255);
- if (val2 < 0) val2 = 0; if (val2 > 255) val2 = 255;
- cm->alpha_mapping[i] = (DATA8)val2;
+ val2 = (int)(pow(((double)cm->red_mapping[i] / 255), (1 / v)) * 255);
+ if (val2 < 0)
+ val2 = 0;
+ if (val2 > 255)
+ val2 = 255;
+ cm->red_mapping[i] = (DATA8) val2;
+
+ val2 = (int)(pow(((double)cm->green_mapping[i] / 255), (1 / v)) * 255);
+ if (val2 < 0)
+ val2 = 0;
+ if (val2 > 255)
+ val2 = 255;
+ cm->green_mapping[i] = (DATA8) val2;
+
+ val2 = (int)(pow(((double)cm->blue_mapping[i] / 255), (1 / v)) * 255);
+ if (val2 < 0)
+ val2 = 0;
+ if (val2 > 255)
+ val2 = 255;
+ cm->blue_mapping[i] = (DATA8) val2;
+
+ val2 = (int)(pow(((double)cm->alpha_mapping[i] / 255), (1 / v)) * 255);
+ if (val2 < 0)
+ val2 = 0;
+ if (val2 > 255)
+ val2 = 255;
+ cm->alpha_mapping[i] = (DATA8) val2;
}
}
#if 0
void
-__imlib_ImageCmodApply(ImlibImage *im, ImlibColorModifier *cm)
+__imlib_ImageCmodApply(ImlibImage * im, ImlibColorModifier * cm)
{
__imlib_DataCmodApply(im->data, im->w, im->h, 0, cm);
}
diff --git a/src/context.c b/src/context.c
index 7311aa2..567da7c 100644
--- a/src/context.c
+++ b/src/context.c
@@ -5,9 +5,9 @@
#include "color.h"
#include "rgba.h"
-static Context *context = NULL;
-static int max_context_count = 128;
-static int context_counter = 0;
+static Context *context = NULL;
+static int max_context_count = 128;
+static int context_counter = 0;
void
__imlib_SetMaxContexts(int num)
@@ -25,126 +25,126 @@ __imlib_GetMaxContexts(void)
void
__imlib_FlushContexts(void)
{
- Context *ct, *pct, *ctt;
-
+ Context *ct, *pct, *ctt;
+
ct = context;
pct = NULL;
while (ct)
{
- ctt = ct;
- ct = ct->next;
- /* it hasnt been referenced in the last max_context_count refernces */
- /* thus old and getrid of it */
- if (ctt->last_use < (context_counter - max_context_count))
- {
- if (pct)
- context = ctt->next;
- else
- pct->next = ctt->next;
- if (ctt->palette)
- {
- int i, num[] = { 256, 128, 64, 32, 16, 8, 1 };
- unsigned long pixels[256];
-
- for (i = 0; i < num[ctt->palette_type]; i++)
- pixels[i] = (unsigned long)ctt->palette[i];
- XFreeColors(ctt->display, ctt->colormap, pixels,
- num[ctt->palette_type], 0);
-
- free(ctt->palette);
- free(ctt->r_dither);
- free(ctt->g_dither);
- free(ctt->b_dither);
- }
- else if (ctt->r_dither)
- {
- free(ctt->r_dither);
- free(ctt->g_dither);
- free(ctt->b_dither);
- }
- free(ctt);
- }
- else
- pct = ctt;
+ ctt = ct;
+ ct = ct->next;
+ /* it hasnt been referenced in the last max_context_count refernces */
+ /* thus old and getrid of it */
+ if (ctt->last_use < (context_counter - max_context_count))
+ {
+ if (pct)
+ context = ctt->next;
+ else
+ pct->next = ctt->next;
+ if (ctt->palette)
+ {
+ int i, num[] = { 256, 128, 64, 32, 16, 8, 1 };
+ unsigned long pixels[256];
+
+ for (i = 0; i < num[ctt->palette_type]; i++)
+ pixels[i] = (unsigned long)ctt->palette[i];
+ XFreeColors(ctt->display, ctt->colormap, pixels,
+ num[ctt->palette_type], 0);
+
+ free(ctt->palette);
+ free(ctt->r_dither);
+ free(ctt->g_dither);
+ free(ctt->b_dither);
+ }
+ else if (ctt->r_dither)
+ {
+ free(ctt->r_dither);
+ free(ctt->g_dither);
+ free(ctt->b_dither);
+ }
+ free(ctt);
+ }
+ else
+ pct = ctt;
}
}
void
-__imlib_FreeContextForDisplay(Display *d)
+__imlib_FreeContextForDisplay(Display * d)
{
- Context *ct;
-
+ Context *ct;
+
ct = context;
while (ct)
{
- if (ct->display == d)
- ct->last_use = - (max_context_count * 2);
+ if (ct->display == d)
+ ct->last_use = -(max_context_count * 2);
ct = ct->next;
}
__imlib_FlushContexts();
}
void
-__imlib_FreeContextForColormap(Display *d, Colormap cm)
+__imlib_FreeContextForColormap(Display * d, Colormap cm)
{
- Context *ct;
-
+ Context *ct;
+
ct = context;
while (ct)
{
- if ((ct->display == d) && (ct->colormap == cm))
- ct->last_use = - (max_context_count * 2);
+ if ((ct->display == d) && (ct->colormap == cm))
+ ct->last_use = -(max_context_count * 2);
ct = ct->next;
}
__imlib_FlushContexts();
}
void
-__imlib_FreeContextForVisual(Display *d, Visual *v)
+__imlib_FreeContextForVisual(Display * d, Visual * v)
{
- Context *ct;
-
+ Context *ct;
+
ct = context;
while (ct)
{
- if ((ct->display == d) && (ct->visual == v))
- ct->last_use = - (max_context_count * 2);
+ if ((ct->display == d) && (ct->visual == v))
+ ct->last_use = -(max_context_count * 2);
ct = ct->next;
}
__imlib_FlushContexts();
}
-Context *
-__imlib_FindContext(Display *d, Visual *v, Colormap c, int depth)
+Context *
+__imlib_FindContext(Display * d, Visual * v, Colormap c, int depth)
{
- Context *ct, *pct;
+ Context *ct, *pct;
pct = NULL;
ct = context;
while (ct)
{
- if ((ct->display == d) && (ct->visual == v) &&
- (ct->colormap == c) && (ct->depth == depth))
- {
- if (pct)
- {
- pct->next = ct->next;
- ct->next = context;
- context = ct;
- }
- return ct;
- }
- pct = ct;
- ct = ct->next;
+ if ((ct->display == d) && (ct->visual == v) &&
+ (ct->colormap == c) && (ct->depth == depth))
+ {
+ if (pct)
+ {
+ pct->next = ct->next;
+ ct->next = context;
+ context = ct;
+ }
+ return ct;
+ }
+ pct = ct;
+ ct = ct->next;
}
return NULL;
}
-Context *
-__imlib_NewContext(Display *d, Visual *v, Colormap c, int depth)
+Context *
+__imlib_NewContext(Display * d, Visual * v, Colormap c, int depth)
{
- Context *ct;
-
+ Context *ct;
+
context_counter++;
ct = malloc(sizeof(Context));
ct->last_use = context_counter;
@@ -156,47 +156,47 @@ __imlib_NewContext(Display *d, Visual *v, Colormap c, int depth)
if (depth <= 8)
{
- ct->palette = __imlib_AllocColorTable(d, c, &(ct->palette_type), v);
- ct->r_dither = malloc(sizeof(DATA8) * DM_X * DM_Y * 256);
- ct->g_dither = malloc(sizeof(DATA8) * DM_X * DM_Y * 256);
- ct->b_dither = malloc(sizeof(DATA8) * DM_X * DM_Y * 256);
- __imlib_RGBA_init((void *)ct->r_dither, (void *)ct->g_dither,
- (void *)ct->b_dither, depth, ct->palette_type);
+ ct->palette = __imlib_AllocColorTable(d, c, &(ct->palette_type), v);
+ ct->r_dither = malloc(sizeof(DATA8) * DM_X * DM_Y * 256);
+ ct->g_dither = malloc(sizeof(DATA8) * DM_X * DM_Y * 256);
+ ct->b_dither = malloc(sizeof(DATA8) * DM_X * DM_Y * 256);
+ __imlib_RGBA_init((void *)ct->r_dither, (void *)ct->g_dither,
+ (void *)ct->b_dither, depth, ct->palette_type);
}
else
{
- ct->palette = NULL;
- ct->palette_type = 0;
- if ((depth > 8) && (depth <= 16))
- {
- ct->r_dither = malloc(sizeof(DATA16) * 4 * 4 * 256);
- ct->g_dither = malloc(sizeof(DATA16) * 4 * 4 * 256);
- ct->b_dither = malloc(sizeof(DATA16) * 4 * 4 * 256);
- __imlib_RGBA_init((void *)ct->r_dither, (void *)ct->g_dither,
- (void *)ct->b_dither, depth, 0);
- }
- else
- {
- ct->r_dither = NULL;
- ct->g_dither = NULL;
- ct->b_dither = NULL;
+ ct->palette = NULL;
+ ct->palette_type = 0;
+ if ((depth > 8) && (depth <= 16))
+ {
+ ct->r_dither = malloc(sizeof(DATA16) * 4 * 4 * 256);
+ ct->g_dither = malloc(sizeof(DATA16) * 4 * 4 * 256);
+ ct->b_dither = malloc(sizeof(DATA16) * 4 * 4 * 256);
__imlib_RGBA_init((void *)ct->r_dither, (void *)ct->g_dither,
- (void *)ct->b_dither, depth, 0);
- }
+ (void *)ct->b_dither, depth, 0);
+ }
+ else
+ {
+ ct->r_dither = NULL;
+ ct->g_dither = NULL;
+ ct->b_dither = NULL;
+ __imlib_RGBA_init((void *)ct->r_dither, (void *)ct->g_dither,
+ (void *)ct->b_dither, depth, 0);
+ }
}
return ct;
}
-Context *
-__imlib_GetContext(Display *d, Visual *v, Colormap c, int depth)
+Context *
+__imlib_GetContext(Display * d, Visual * v, Colormap c, int depth)
{
- Context *ct;
-
+ Context *ct;
+
ct = __imlib_FindContext(d, v, c, depth);
if (ct)
{
- ct->last_use = context_counter;
- return ct;
+ ct->last_use = context_counter;
+ return ct;
}
ct = __imlib_NewContext(d, v, c, depth);
ct->next = context;
diff --git a/src/draw.c b/src/draw.c
index 26904ae..8dd1d53 100644
--- a/src/draw.c
+++ b/src/draw.c
@@ -8,50 +8,49 @@
#include "draw.h"
char
-__imlib_CreatePixmapsForImage(Display *d, Drawable w, Visual *v, int depth,
- Colormap cm, ImlibImage *im, Pixmap *p, Mask *m,
- int sx, int sy, int sw, int sh,
- int dw, int dh,
- char antialias, char hiq, char dither_mask,
- ImlibColorModifier *cmod)
+__imlib_CreatePixmapsForImage(Display * d, Drawable w, Visual * v, int depth,
+ Colormap cm, ImlibImage * im, Pixmap * p,
+ Mask * m, int sx, int sy, int sw, int sh, int dw,
+ int dh, char antialias, char hiq,
+ char dither_mask, ImlibColorModifier * cmod)
{
- ImlibImagePixmap *ip = NULL;
- Pixmap pmap = 0;
- Pixmap mask = 0;
- long long mod_count = 0;
-
+ ImlibImagePixmap *ip = NULL;
+ Pixmap pmap = 0;
+ Pixmap mask = 0;
+ long long mod_count = 0;
+
if (cmod)
mod_count = cmod->modification_count;
- ip = __imlib_FindCachedImagePixmap(im, dw, dh, d, v, depth, sx, sy,
- sw, sh, cm, antialias, hiq, dither_mask,
- mod_count);
+ ip = __imlib_FindCachedImagePixmap(im, dw, dh, d, v, depth, sx, sy,
+ sw, sh, cm, antialias, hiq, dither_mask,
+ mod_count);
if (ip)
{
- if (p)
- *p = ip->pixmap;
- if (m)
- *m = ip->mask;
+ if (p)
+ *p = ip->pixmap;
+ if (m)
+ *m = ip->mask;
ip->references++;
#ifdef DEBUG_CACHE
- fprintf(stderr, "[Imlib2] Match found in cache. Reference count is %d, pixmap 0x%08x, mask 0x%08x\n",
- ip->references, ip->pixmap, ip->mask);
+ fprintf(stderr,
+ "[Imlib2] Match found in cache. Reference count is %d, pixmap 0x%08x, mask 0x%08x\n",
+ ip->references, ip->pixmap, ip->mask);
#endif
- return 2;
+ return 2;
}
if (p)
{
- pmap = XCreatePixmap(d, w, dw, dh, depth);
- *p = pmap;
+ pmap = XCreatePixmap(d, w, dw, dh, depth);
+ *p = pmap;
}
if (m)
{
- if (IMAGE_HAS_ALPHA(im))
- mask = XCreatePixmap(d, w, dw, dh, 1);
- *m = mask;
+ if (IMAGE_HAS_ALPHA(im))
+ mask = XCreatePixmap(d, w, dw, dh, 1);
+ *m = mask;
}
- __imlib_RenderImage(d, im, pmap, mask, v, cm, depth, sx, sy, sw, sh, 0, 0,
- dw, dh, antialias, hiq, 0, dither_mask, cmod,
- OP_COPY);
+ __imlib_RenderImage(d, im, pmap, mask, v, cm, depth, sx, sy, sw, sh, 0, 0,
+ dw, dh, antialias, hiq, 0, dither_mask, cmod, OP_COPY);
ip = __imlib_ProduceImagePixmap();
ip->visual = v;
ip->depth = depth;
@@ -79,9 +78,9 @@ __imlib_CreatePixmapsForImage(Display *d, Drawable w, Visual *v, int depth,
ip->mask = mask;
__imlib_AddImagePixmapToCache(ip);
#ifdef DEBUG_CACHE
- fprintf(stderr, "[Imlib2] Created pixmap. Reference count is %d, pixmap 0x%08x, mask 0x%08x\n",
- ip->references, ip->pixmap, ip->mask);
+ fprintf(stderr,
+ "[Imlib2] Created pixmap. Reference count is %d, pixmap 0x%08x, mask 0x%08x\n",
+ ip->references, ip->pixmap, ip->mask);
#endif
return 1;
}
-
diff --git a/src/dynamic_filters.c b/src/dynamic_filters.c
index 7ffdb39..6c82862 100644
--- a/src/dynamic_filters.c
+++ b/src/dynamic_filters.c
@@ -16,164 +16,171 @@
#include "script.h"
#include "loaderpath.h"
-
-pImlibExternalFilter filters = NULL;
-int dyn_initialised = 0;
+pImlibExternalFilter filters = NULL;
+int dyn_initialised = 0;
#define MALLOCSHOW
-#define FREESHOW
+#define FREESHOW
/*
#define FDEBUG
*/
-pImlibExternalFilter __imlib_LoadFilter( char *file )
+pImlibExternalFilter
+__imlib_LoadFilter(char *file)
{
ImlibExternalFilter *ptr;
struct imlib_filter_info *info;
/* printf( "Loading filter %s\n", file ); */
MALLOCSHOW;
- ptr = malloc( sizeof( ImlibExternalFilter ) );
+ ptr = malloc(sizeof(ImlibExternalFilter));
ptr->filename = strdup(file);
ptr->handle = lt_dlopenext(file);
- if( !ptr->handle )
- {
- FREESHOW;
- free( ptr->filename );
- FREESHOW;
- free( ptr );
- return NULL;
- }
- ptr->init_filter = lt_dlsym( ptr->handle, "init" );
- ptr->deinit_filter = lt_dlsym( ptr->handle, "deinit" );
- ptr->exec_filter = lt_dlsym( ptr->handle, "exec" );
- if( !ptr->init_filter || !ptr->deinit_filter || !ptr->exec_filter )
- {
- lt_dlclose( ptr->handle );
- FREESHOW;
- free( ptr->filename );
- FREESHOW;
- free( ptr );
- return NULL;
- }
- info = malloc( sizeof( struct imlib_filter_info ) );
- ptr->init_filter( info );
+ if (!ptr->handle)
+ {
+ FREESHOW;
+ free(ptr->filename);
+ FREESHOW;
+ free(ptr);
+ return NULL;
+ }
+ ptr->init_filter = lt_dlsym(ptr->handle, "init");
+ ptr->deinit_filter = lt_dlsym(ptr->handle, "deinit");
+ ptr->exec_filter = lt_dlsym(ptr->handle, "exec");
+ if (!ptr->init_filter || !ptr->deinit_filter || !ptr->exec_filter)
+ {
+ lt_dlclose(ptr->handle);
+ FREESHOW;
+ free(ptr->filename);
+ FREESHOW;
+ free(ptr);
+ return NULL;
+ }
+ info = malloc(sizeof(struct imlib_filter_info));
+ ptr->init_filter(info);
ptr->num_filters = info->num_filters;
ptr->filters = info->filters;
ptr->name = info->name;
ptr->author = info->author;
ptr->description = info->description;
-
- free( info );
-
-#ifdef FDEBUG
- printf( "Filter has %d filters in it.\n", ptr->num_filters );
- for( i = 0; i < ptr->num_filters; i++ )
- printf( " -> \"%s\"\n", ptr->filters[i] );
+
+ free(info);
+
+#ifdef FDEBUG
+ printf("Filter has %d filters in it.\n", ptr->num_filters);
+ for (i = 0; i < ptr->num_filters; i++)
+ printf(" -> \"%s\"\n", ptr->filters[i]);
#endif
-
+
ptr->next = NULL;
return ptr;
}
-void __imlib_dynamic_filters_init()
+void
+__imlib_dynamic_filters_init()
{
- char **list;
- int num_filters, i = 0;
+ char **list;
+ int num_filters, i = 0;
ImlibExternalFilter *ptr, *tptr;
-
- if( ! dyn_initialised )
- {
- MALLOCSHOW;
- filters = malloc( sizeof( ImlibExternalFilter ) );
- filters->filename = "";
- filters->next = NULL;
- ptr = filters;
+
+ if (!dyn_initialised)
+ {
+ MALLOCSHOW;
+ filters = malloc(sizeof(ImlibExternalFilter));
+ filters->filename = "";
+ filters->next = NULL;
+ ptr = filters;
#ifdef FDEBUG
- printf( "DEBUG: Dynamic filters Initisialising\n" );
+ printf("DEBUG: Dynamic filters Initisialising\n");
#endif
- dyn_initialised = 1;
+ dyn_initialised = 1;
#ifdef FDEBUG
- printf( "DEBUG: Loading Filters\n" );
+ printf("DEBUG: Loading Filters\n");
#endif
- list = __imlib_ListFilters( &num_filters );
- for( i = num_filters - 1; i >= 0; i -- )
- {
- tptr = NULL;
- if((tptr = __imlib_LoadFilter( list[i] )) != NULL )
- {
- ptr->next = tptr;
- ptr = ptr->next;
- }
- if( list[i] ){
- FREESHOW;
- free( list[i] );
- }
- }
- FREESHOW;
- if( list )
- free( list );
- }
+ list = __imlib_ListFilters(&num_filters);
+ for (i = num_filters - 1; i >= 0; i--)
+ {
+ tptr = NULL;
+ if ((tptr = __imlib_LoadFilter(list[i])) != NULL)
+ {
+ ptr->next = tptr;
+ ptr = ptr->next;
+ }
+ if (list[i])
+ {
+ FREESHOW;
+ free(list[i]);
+ }
+ }
+ FREESHOW;
+ if (list)
+ free(list);
+ }
}
-void __imlib_dynamic_filters_deinit()
+void
+__imlib_dynamic_filters_deinit()
{
}
-pImlibExternalFilter __imlib_get_dynamic_filter( char *name )
+pImlibExternalFilter
+__imlib_get_dynamic_filter(char *name)
{
pImlibExternalFilter f_ptr;
- int i = 0;
+ int i = 0;
/* scan the filters */
- for( f_ptr = filters->next; f_ptr != NULL; f_ptr = f_ptr->next )
- {
- /* scan the methods provided */
- for( i = 0; i < f_ptr->num_filters; i++ )
- {
- if( strcmp( f_ptr->filters[i], name ) == 0 )
- {
+ for (f_ptr = filters->next; f_ptr != NULL; f_ptr = f_ptr->next)
+ {
+ /* scan the methods provided */
+ for (i = 0; i < f_ptr->num_filters; i++)
+ {
+ if (strcmp(f_ptr->filters[i], name) == 0)
+ {
#ifdef FDEBUG
- printf( "DEBUG: Found filter \"%s\"\n", name );
+ printf("DEBUG: Found filter \"%s\"\n", name);
#endif
- return f_ptr;
- }
- }
- }
+ return f_ptr;
+ }
+ }
+ }
return NULL;
}
/* loader dir */
-char **__imlib_ListFilters(int *num_ret)
+char **
+__imlib_ListFilters(int *num_ret)
{
- char **list = NULL, **l, *s;
- int num, i, pi = 0;
-
+ char **list = NULL, **l, *s;
+ int num, i, pi = 0;
+
*num_ret = 0;
/* same for system loader path */
- s = (char *) malloc(sizeof(SYS_LOADERS_PATH) + 7 + 1);
+ s = (char *)malloc(sizeof(SYS_LOADERS_PATH) + 7 + 1);
sprintf(s, SYS_LOADERS_PATH "/filter");
-#ifndef __EMX__
+#ifndef __EMX__
l = __imlib_FileDir(s, &num);
-#else
+#else
l = __imlib_FileDir(__XOS2RedirRoot(s), &num);
-#endif
+#endif
if (num > 0)
- {
- *num_ret += num;
- list = realloc(list, sizeof(char *) * *num_ret);
- for (i = 0; i < num; i++)
- {
- s = (char *) realloc(s, sizeof(SYS_LOADERS_PATH) + 8 + strlen(l[i]) + 1);
- sprintf(s, SYS_LOADERS_PATH "/filter/%s", l[i]);
-#ifndef __EMX__
- list[pi + i] = strdup(s);
-#else
- list[pi + i] = strdup(__XOS2RedirRoot(s));
-#endif
- }
- __imlib_FileFreeDirList(l, num);
- }
+ {
+ *num_ret += num;
+ list = realloc(list, sizeof(char *) * *num_ret);
+ for (i = 0; i < num; i++)
+ {
+ s = (char *)realloc(s,
+ sizeof(SYS_LOADERS_PATH) + 8 + strlen(l[i]) +
+ 1);
+ sprintf(s, SYS_LOADERS_PATH "/filter/%s", l[i]);
+#ifndef __EMX__
+ list[pi + i] = strdup(s);
+#else
+ list[pi + i] = strdup(__XOS2RedirRoot(s));
+#endif
+ }
+ __imlib_FileFreeDirList(l, num);
+ }
free(s);
/* List currently contains *everything in there* we need to weed out
@@ -181,6 +188,6 @@ char **__imlib_ListFilters(int *num_ret)
* lt_dlopen can take an extension-less name and do the Right Thing
* with it, so that's what we'll give it. */
list = __imlib_TrimLoaderList(list, num_ret);
-
+
return list;
}
diff --git a/src/file.c b/src/file.c
index f9dc71c..d693048 100644
--- a/src/file.c
+++ b/src/file.c
@@ -13,81 +13,85 @@
#include <pwd.h>
#include "file.h"
-static void __imlib_FileFieldWord(char *s, int num, char *wd);
+static void __imlib_FileFieldWord(char *s, int num, char *wd);
-char *
+char *
__imlib_FileKey(const char *file)
{
- char *newfile;
-
+ char *newfile;
+
newfile = malloc(strlen(file) + 1);
- if (!newfile) return NULL;
+ if (!newfile)
+ return NULL;
newfile[0] = 0;
- {
- char *p1, *p2;
- int go;
-
- go = 0;
- p1 = (char *)file;
- p2 = newfile;
- while (p1[0])
- {
- if (go)
- {
- p2[0] = p1[0];
- p2++;
- }
- if ((p1[0] == ':') && (p1[1] != ':'))
- go = 1;
- if ((p1[0] == ':') && (p1[1] == ':'))
- p1++;
- p1++;
- }
- p2[0] = p1[0];
- }
- if (newfile[0]) return newfile;
- else free(newfile);
+ {
+ char *p1, *p2;
+ int go;
+
+ go = 0;
+ p1 = (char *)file;
+ p2 = newfile;
+ while (p1[0])
+ {
+ if (go)
+ {
+ p2[0] = p1[0];
+ p2++;
+ }
+ if ((p1[0] == ':') && (p1[1] != ':'))
+ go = 1;
+ if ((p1[0] == ':') && (p1[1] == ':'))
+ p1++;
+ p1++;
+ }
+ p2[0] = p1[0];
+ }
+ if (newfile[0])
+ return newfile;
+ else
+ free(newfile);
return NULL;
}
-char *
+char *
__imlib_FileRealFile(const char *file)
{
- char *newfile;
-
+ char *newfile;
+
newfile = malloc(strlen(file) + 1);
- if (!newfile) return NULL;
+ if (!newfile)
+ return NULL;
newfile[0] = 0;
- {
- char *p1, *p2;
-
- p1 = (char *)file;
- p2 = newfile;
- while (p1[0])
- {
- if (p1[0] == ':')
- {
- if (p1[1] == ':')
- {
- p2[0] = ':';
- p2++;
- p1++;
- }
- else
- {
- p2[0] = 0;
- return newfile;
- }
- }
- else
- {
- p2[0] = p1[0];
- p2++;
- }
- p1++;
- }
- p2[0] = p1[0];
- }
+ {
+ char *p1, *p2;
+
+ p1 = (char *)file;
+ p2 = newfile;
+ while (p1[0])
+ {
+ if (p1[0] == ':')
+ {
+ if (p1[1] == ':')
+ {
+ p2[0] = ':';
+ p2++;
+ p1++;
+ }
+ else
+ {
+ p2[0] = 0;
+ return newfile;
+ }
+ }
+ else
+ {
+ p2[0] = p1[0];
+ p2++;
+ }
+ p1++;
+ }
+ p2[0] = p1[0];
+ }
return newfile;
}
@@ -96,18 +100,19 @@ __imlib_FileExtension(const char *file)
{
char *p;
char *fl;
-
+
fl = __imlib_FileRealFile(file);
- if (!fl) return strdup("");
+ if (!fl)
+ return strdup("");
p = strrchr(file, '.');
- if (p)
- {
- char *ret;
-
- ret = strdup(p + 1);
- free(fl);
- return ret;
- }
+ if (p)
+ {
+ char *ret;
+
+ ret = strdup(p + 1);
+ free(fl);
+ return ret;
+ }
free(fl);
return strdup("");
}
@@ -117,15 +122,19 @@ __imlib_FileExists(const char *s)
{
struct stat st;
char *fl;
-
- if ((!s) || (!*s)) return 0;
- if (__imlib_IsRealFile(s)) fl = strdup(s);
- else fl = __imlib_FileRealFile(s);
- if (!fl) return 0;
+
+ if ((!s) || (!*s))
+ return 0;
+ if (__imlib_IsRealFile(s))
+ fl = strdup(s);
+ else
+ fl = __imlib_FileRealFile(s);
+ if (!fl)
+ return 0;
if (stat(fl, &st) < 0)
{
- free(fl);
- return 0;
+ free(fl);
+ return 0;
}
free(fl);
return 1;
@@ -136,20 +145,24 @@ __imlib_FileIsFile(const char *s)
{
struct stat st;
char *fl;
-
- if ((!s) || (!*s)) return 0;
- if (__imlib_IsRealFile(s)) fl = strdup(s);
- else fl = __imlib_FileRealFile(s);
- if (!fl) return 0;
+
+ if ((!s) || (!*s))
+ return 0;
+ if (__imlib_IsRealFile(s))
+ fl = strdup(s);
+ else
+ fl = __imlib_FileRealFile(s);
+ if (!fl)
+ return 0;
if (stat(fl, &st) < 0)
{
- free(fl);
- return 0;
+ free(fl);
+ return 0;
}
if (S_ISREG(st.st_mode))
{
- free(fl);
- return 1;
+ free(fl);
+ return 1;
}
free(fl);
return 0;
@@ -160,20 +173,24 @@ __imlib_FileIsDir(const char *s)
{
struct stat st;
char *fl;
-
- if ((!s) || (!*s)) return 0;
- if (__imlib_IsRealFile(s)) fl = strdup(s);
- else fl = __imlib_FileRealFile(s);
- if (!fl) return 0;
+
+ if ((!s) || (!*s))
+ return 0;
+ if (__imlib_IsRealFile(s))
+ fl = strdup(s);
+ else
+ fl = __imlib_FileRealFile(s);
+ if (!fl)
+ return 0;
if (stat(fl, &st) < 0)
{
- free(fl);
- return 0;
+ free(fl);
+ return 0;
}
if (S_ISDIR(st.st_mode))
{
- free(fl);
- return 1;
+ free(fl);
+ return 1;
}
free(fl);
return 0;
@@ -184,35 +201,42 @@ __imlib_FilePermissions(const char *s)
{
struct stat st;
char *fl;
-
- if ((!s) || (!*s)) return 0;
- if (__imlib_IsRealFile(s)) fl = strdup(s);
- else fl = __imlib_FileRealFile(s);
- if (!fl) return 0;
+
+ if ((!s) || (!*s))
+ return 0;
+ if (__imlib_IsRealFile(s))
+ fl = strdup(s);
+ else
+ fl = __imlib_FileRealFile(s);
+ if (!fl)
+ return 0;
if (stat(fl, &st) < 0)
{
- free(fl);
- return 0;
+ free(fl);
+ return 0;
}
free(fl);
return st.st_mode;
}
-int
+int
__imlib_FileCanRead(const char *s)
{
char *fl;
int val;
-
- if (__imlib_IsRealFile(s)) fl = strdup(s);
- else fl = __imlib_FileRealFile(s);
- if (!fl) return 0;
+
+ if (__imlib_IsRealFile(s))
+ fl = strdup(s);
+ else
+ fl = __imlib_FileRealFile(s);
+ if (!fl)
+ return 0;
if (!(__imlib_FilePermissions(fl) & (S_IRUSR | S_IRGRP | S_IROTH)))
{
- free(fl);
- return 0;
+ free(fl);
+ return 0;
}
-
+
val = (1 + access(fl, R_OK));
free(fl);
return val;
@@ -226,63 +250,63 @@ __imlib_FileDir(char *dir, int *num)
DIR *dirp;
char **names;
struct dirent *dp;
-
+
if ((!dir) || (!*dir))
- return(0);
+ return (0);
dirp = opendir(dir);
if (!dirp)
{
- *num = 0;
- return(NULL);
+ *num = 0;
+ return (NULL);
}
/* count # of entries in dir (worst case) */
for (dirlen = 0; (dp = readdir(dirp)) != NULL; dirlen++);
if (!dirlen)
{
- closedir(dirp);
- *num = dirlen;
- return(NULL);
+ closedir(dirp);
+ *num = dirlen;
+ return (NULL);
}
names = (char **)malloc(dirlen * sizeof(char *));
-
+
if (!names)
- return(NULL);
-
+ return (NULL);
+
rewinddir(dirp);
for (i = 0; i < dirlen;)
{
- dp = readdir(dirp);
- if (!dp)
- break;
- if ((strcmp(dp->d_name, ".")) && (strcmp(dp->d_name, "..")))
- {
- names[i] = strdup(dp->d_name);
- i++;
- }
+ dp = readdir(dirp);
+ if (!dp)
+ break;
+ if ((strcmp(dp->d_name, ".")) && (strcmp(dp->d_name, "..")))
+ {
+ names[i] = strdup(dp->d_name);
+ i++;
+ }
}
-
+
if (i < dirlen)
- dirlen = i; /* dir got shorter... */
+ dirlen = i; /* dir got shorter... */
closedir(dirp);
*num = dirlen;
/* do a simple bubble sort here to alphanumberic it */
while (!done)
{
- done = 1;
- for (i = 0; i < dirlen - 1; i++)
- {
- if (strcmp(names[i], names[i + 1]) > 0)
- {
- char *tmp;
-
- tmp = names[i];
- names[i] = names[i + 1];
- names[i + 1] = tmp;
- done = 0;
- }
- }
+ done = 1;
+ for (i = 0; i < dirlen - 1; i++)
+ {
+ if (strcmp(names[i], names[i + 1]) > 0)
+ {
+ char *tmp;
+
+ tmp = names[i];
+ names[i] = names[i + 1];
+ names[i + 1] = tmp;
+ done = 0;
+ }
+ }
}
- return(names);
+ return (names);
}
void
@@ -292,7 +316,7 @@ __imlib_FileFreeDirList(char **l, int num)
return;
while (num--)
if (l[num])
- free(l[num]);
+ free(l[num]);
free(l);
return;
}
@@ -309,7 +333,8 @@ __imlib_FileDel(char *s)
int
__imlib_IsRealFile(const char *s)
{
- struct stat st;
+ struct stat st;
+
return ((stat(s, &st) != -1) && (S_ISREG(st.st_mode)));
}
@@ -318,20 +343,24 @@ __imlib_FileModDate(const char *s)
{
struct stat st;
char *fl;
-
- if ((!s) || (!*s)) return 0;
- if (__imlib_IsRealFile(s)) fl = strdup(s);
- else fl = __imlib_FileRealFile(s);
- if (!fl) return 0;
+
+ if ((!s) || (!*s))
+ return 0;
+ if (__imlib_IsRealFile(s))
+ fl = strdup(s);
+ else
+ fl = __imlib_FileRealFile(s);
+ if (!fl)
+ return 0;
if (stat(fl, &st) < 0)
{
- free(fl);
- return 0;
+ free(fl);
+ return 0;
}
if (st.st_mtime > st.st_ctime)
{
- free(fl);
- return st.st_mtime;
+ free(fl);
+ return st.st_mtime;
}
free(fl);
return st.st_ctime;
@@ -344,6 +373,7 @@ __imlib_FileHomeDir(int uid)
static char *usr_s = NULL;
char *s;
struct passwd *pwd;
+
#ifndef __EMX__
s = getenv("HOME");
if (s)
@@ -352,15 +382,15 @@ __imlib_FileHomeDir(int uid)
usr_uid = getuid();
if ((uid == usr_uid) && (usr_s))
{
- return(strdup(usr_s));
+ return (strdup(usr_s));
}
pwd = getpwuid(uid);
if (pwd)
{
- s = strdup(pwd->pw_dir);
- if (uid == usr_uid)
- usr_s = strdup(s);
- return(s);
+ s = strdup(pwd->pw_dir);
+ if (uid == usr_uid)
+ usr_s = strdup(s);
+ return (s);
}
#else
if ((s = getenv("HOME")) != NULL)
@@ -371,7 +401,6 @@ __imlib_FileHomeDir(int uid)
return NULL;
}
-
/* gets word number [num] in the string [s] and copies it into [wd] */
/* wd is NULL terminated. If word [num] does not exist wd = "" */
/* NB: this function now handles quotes so for a line: */
@@ -386,34 +415,24 @@ char *
__imlib_FileField(char *s, int field)
{
char buf[4096];
-
+
buf[0] = 0;
__imlib_FileFieldWord(s, field + 1, buf);
if (buf[0])
{
- if ((!strcmp(buf, "NULL")) ||
- (!strcmp(buf, "(null)")))
- return(NULL);
- return(strdup(buf));
+ if ((!strcmp(buf, "NULL")) || (!strcmp(buf, "(null)")))
+ return (NULL);
+ return (strdup(buf));
}
- return(NULL);
+ return (NULL);
}
-
-
-
-
-
-
-
-
-
static void
__imlib_FileFieldWord(char *s, int num, char *wd)
{
char *cur, *start, *end;
int count, inword, inquote, len;
-
+
if (!s)
return;
if (!wd)
@@ -429,45 +448,45 @@ __imlib_FileFieldWord(char *s, int num, char *wd)
end = NULL;
while ((*cur) && (count < num))
{
- if (inword)
- {
- if (inquote)
- {
- if (*cur == '"')
- {
- inquote = 0;
- inword = 0;
- end = cur;
- count++;
- }
- }
- else
- {
- if (isspace(*cur))
- {
- end = cur;
- inword = 0;
- count++;
- }
- }
- }
- else
- {
- if (!isspace(*cur))
- {
- if (*cur == '"')
- {
- inquote = 1;
- start = cur + 1;
- }
- else
- start = cur;
- inword = 1;
- }
- }
- if (count == num)
- break;
- cur++;
+ if (inword)
+ {
+ if (inquote)
+ {
+ if (*cur == '"')
+ {
+ inquote = 0;
+ inword = 0;
+ end = cur;
+ count++;
+ }
+ }
+ else
+ {
+ if (isspace(*cur))
+ {
+ end = cur;
+ inword = 0;
+ count++;
+ }
+ }
+ }
+ else
+ {
+ if (!isspace(*cur))
+ {
+ if (*cur == '"')
+ {
+ inquote = 1;
+ start = cur + 1;
+ }
+ else
+ start = cur;
+ inword = 1;
+ }
+ }
+ if (count == num)
+ break;
+ cur++;
}
if (!start)
return;
@@ -480,9 +499,8 @@ __imlib_FileFieldWord(char *s, int num, char *wd)
len = 4000;
if (len > 0)
{
- strncpy(wd, start, len);
- wd[len] = 0;
+ strncpy(wd, start, len);
+ wd[len] = 0;
}
return;
}
-
diff --git a/src/filter.c b/src/filter.c
index 60b11cb..6436dee 100644
--- a/src/filter.c
+++ b/src/filter.c
@@ -5,31 +5,34 @@
#include "filter.h"
/*\ Create and return an empty filter struct \*/
-ImlibFilter *
+ImlibFilter *
__imlib_CreateFilter(int size)
{
- ImlibFilter *fil;
+ ImlibFilter *fil;
fil = malloc(sizeof(ImlibFilter));
- if (size > 0) {
- fil->alpha.pixels = malloc(size * sizeof(ImlibFilterPixel));
- fil->red.pixels = malloc(size * sizeof(ImlibFilterPixel));
- fil->green.pixels = malloc(size * sizeof(ImlibFilterPixel));
- fil->blue.pixels = malloc(size * sizeof(ImlibFilterPixel));
- fil->alpha.size = size;
- fil->red.size = size;
- fil->green.size = size;
- fil->blue.size = size;
- } else {
- fil->alpha.pixels = 0;
- fil->red.pixels = 0;
- fil->green.pixels = 0;
- fil->blue.pixels = 0;
- fil->alpha.size = 0;
- fil->red.size = 0;
- fil->green.size = 0;
- fil->blue.size = 0;
- }
+ if (size > 0)
+ {
+ fil->alpha.pixels = malloc(size * sizeof(ImlibFilterPixel));
+ fil->red.pixels = malloc(size * sizeof(ImlibFilterPixel));
+ fil->green.pixels = malloc(size * sizeof(ImlibFilterPixel));
+ fil->blue.pixels = malloc(size * sizeof(ImlibFilterPixel));
+ fil->alpha.size = size;
+ fil->red.size = size;
+ fil->green.size = size;
+ fil->blue.size = size;
+ }
+ else
+ {
+ fil->alpha.pixels = 0;
+ fil->red.pixels = 0;
+ fil->green.pixels = 0;
+ fil->blue.pixels = 0;
+ fil->alpha.size = 0;
+ fil->red.size = 0;
+ fil->green.size = 0;
+ fil->blue.size = 0;
+ }
fil->alpha.entries = 0;
fil->red.entries = 0;
fil->green.entries = 0;
@@ -47,7 +50,7 @@ __imlib_CreateFilter(int size)
/*\ Free a filter struct \*/
void
-__imlib_FreeFilter(ImlibFilter *fil)
+__imlib_FreeFilter(ImlibFilter * fil)
{
free(fil->alpha.pixels);
free(fil->red.pixels);
@@ -57,36 +60,44 @@ __imlib_FreeFilter(ImlibFilter *fil)
}
void
-__imlib_FilterSetColor(ImlibFilterColor *fil, int x, int y,
- int a, int r, int g, int b)
+__imlib_FilterSetColor(ImlibFilterColor * fil, int x, int y,
+ int a, int r, int g, int b)
{
- int i;
- ImlibFilterPixel *pix = fil->pixels;
-
- /*\ Look for an entry matching (x, y) \*/
- for (i = fil->entries; --i >= 0; ) {
- if ((pix[i].xoff == x) && (pix[i].yoff == y))
- break;
- }
- /*\ If all zero, remove the found entry \*/
- if (!(a | r | g | b)) {
- if (i >= 0) {
- while (i < fil->entries) {
- pix[i] = pix[i + 1];
- }
- fil->entries--;
- }
- return;
- }
- /*\ No match, then make a new entry \*/
- if (i < 0) i = fil->entries;
- if (i >= fil->size) {
- fil->size += 4;
- pix = realloc(pix, (fil->size * sizeof(ImlibFilterPixel)));
- if (!pix) return;
- fil->pixels = pix;
- }
- if (i >= fil->entries) fil->entries = i + 1;
+ int i;
+ ImlibFilterPixel *pix = fil->pixels;
+
+ /*\ Look for an entry matching (x, y) \ */
+ for (i = fil->entries; --i >= 0;)
+ {
+ if ((pix[i].xoff == x) && (pix[i].yoff == y))
+ break;
+ }
+ /*\ If all zero, remove the found entry \ */
+ if (!(a | r | g | b))
+ {
+ if (i >= 0)
+ {
+ while (i < fil->entries)
+ {
+ pix[i] = pix[i + 1];
+ }
+ fil->entries--;
+ }
+ return;
+ }
+ /*\ No match, then make a new entry \ */
+ if (i < 0)
+ i = fil->entries;
+ if (i >= fil->size)
+ {
+ fil->size += 4;
+ pix = realloc(pix, (fil->size * sizeof(ImlibFilterPixel)));
+ if (!pix)
+ return;
+ fil->pixels = pix;
+ }
+ if (i >= fil->entries)
+ fil->entries = i + 1;
pix[i].xoff = x;
pix[i].yoff = y;
pix[i].a = a;
@@ -97,7 +108,7 @@ __imlib_FilterSetColor(ImlibFilterColor *fil, int x, int y,
/*\ Set the divisors manually \*/
void
-__imlib_FilterDivisors(ImlibFilter *fil, int a, int r, int g, int b)
+__imlib_FilterDivisors(ImlibFilter * fil, int a, int r, int g, int b)
{
fil->alpha.div = a;
fil->red.div = r;
@@ -107,7 +118,7 @@ __imlib_FilterDivisors(ImlibFilter *fil, int a, int r, int g, int b)
/*\ Set the constants \*/
void
-__imlib_FilterConstants(ImlibFilter *fil, int a, int r, int g, int b)
+__imlib_FilterConstants(ImlibFilter * fil, int a, int r, int g, int b)
{
fil->alpha.cons = a;
fil->red.cons = r;
@@ -116,44 +127,51 @@ __imlib_FilterConstants(ImlibFilter *fil, int a, int r, int g, int b)
}
static int
-__imlib_FilterCalcDiv(ImlibFilterColor *fil)
+__imlib_FilterCalcDiv(ImlibFilterColor * fil)
{
- int i, ret;
- ImlibFilterPixel *pix;
+ int i, ret;
+ ImlibFilterPixel *pix;
- if (fil->div) return fil->div;
+ if (fil->div)
+ return fil->div;
ret = 0;
pix = fil->pixels;
- for (i = fil->entries; --i >= 0; ) {
- ret += pix->a + pix->r + pix->g + pix->b;
- pix++;
- }
+ for (i = fil->entries; --i >= 0;)
+ {
+ ret += pix->a + pix->r + pix->g + pix->b;
+ pix++;
+ }
return ret;
}
static int
-__imlib_FilterGet(ImlibFilterColor *fil, DATA32 *data,
- int w, int h, int x, int y)
+__imlib_FilterGet(ImlibFilterColor * fil, DATA32 * data,
+ int w, int h, int x, int y)
{
- int i, off, ret;
- ImlibFilterPixel *pix;
- DATA32 *p;
+ int i, off, ret;
+ ImlibFilterPixel *pix;
+ DATA32 *p;
ret = fil->cons;
pix = fil->pixels;
- for (i = fil->entries; --i >= 0; ) {
- off = x + pix->xoff;
- if (off < 0) off = 0;
- if (off >= w) off = w - 1;
- p = data + off;
- off = y + pix->yoff;
- if (off < 0) off = 0;
- if (off >= h) off = h - 1;
- p += off * w;
- ret += A_VAL(p) * pix->a + R_VAL(p) * pix->r +
- G_VAL(p) * pix->g + B_VAL(p) * pix->b;
- pix++;
- }
+ for (i = fil->entries; --i >= 0;)
+ {
+ off = x + pix->xoff;
+ if (off < 0)
+ off = 0;
+ if (off >= w)
+ off = w - 1;
+ p = data + off;
+ off = y + pix->yoff;
+ if (off < 0)
+ off = 0;
+ if (off >= h)
+ off = h - 1;
+ p += off * w;
+ ret += A_VAL(p) * pix->a + R_VAL(p) * pix->r +
+ G_VAL(p) * pix->g + B_VAL(p) * pix->b;
+ pix++;
+ }
return ret;
}
@@ -164,13 +182,14 @@ __imlib_FilterGet(ImlibFilterColor *fil, DATA32 *data,
|*| NB: This is currently not very optimal, and could probably be improved
\*/
void
-__imlib_FilterImage(ImlibImage *im, ImlibFilter *fil)
+__imlib_FilterImage(ImlibImage * im, ImlibFilter * fil)
{
- int x, y, a, r, g, b, ad, rd, gd, bd;
- DATA32 *data, *p1, *p2;
+ int x, y, a, r, g, b, ad, rd, gd, bd;
+ DATA32 *data, *p1, *p2;
data = malloc(im->w * im->h * sizeof(DATA32));
- if (!data) return;
+ if (!data)
+ return;
ad = __imlib_FilterCalcDiv(&fil->alpha);
rd = __imlib_FilterCalcDiv(&fil->red);
@@ -180,33 +199,43 @@ __imlib_FilterImage(ImlibImage *im, ImlibFilter *fil)
p1 = im->data;
p2 = data;
- for (y = 0; y < im->h; y++) {
- for (x = 0; x < im->w; x++) {
- *p2 = *p1;
- if (ad) {
- a = __imlib_FilterGet(&fil->alpha, im->data, im->w, im->h, x, y);
- a /= ad;
- A_VAL(p2) = SATURATE(a);
- }
- if (rd) {
- r = __imlib_FilterGet(&fil->red, im->data, im->w, im->h, x, y);
- r /= rd;
- R_VAL(p2) = SATURATE(r);
- }
- if (gd) {
- g = __imlib_FilterGet(&fil->green, im->data, im->w, im->h, x, y);
- g /= gd;
- G_VAL(p2) = SATURATE(g);
- }
- if (bd) {
- b = __imlib_FilterGet(&fil->blue, im->data, im->w, im->h, x, y);
- b /= bd;
- B_VAL(p2) = SATURATE(b);
- }
- p1++;
- p2++;
- }
- }
+ for (y = 0; y < im->h; y++)
+ {
+ for (x = 0; x < im->w; x++)
+ {
+ *p2 = *p1;
+ if (ad)
+ {
+ a = __imlib_FilterGet(&fil->alpha, im->data, im->w, im->h, x,
+ y);
+ a /= ad;
+ A_VAL(p2) = SATURATE(a);
+ }
+ if (rd)
+ {
+ r = __imlib_FilterGet(&fil->red, im->data, im->w, im->h, x,
+ y);
+ r /= rd;
+ R_VAL(p2) = SATURATE(r);
+ }
+ if (gd)
+ {
+ g = __imlib_FilterGet(&fil->green, im->data, im->w, im->h, x,
+ y);
+ g /= gd;
+ G_VAL(p2) = SATURATE(g);
+ }
+ if (bd)
+ {
+ b = __imlib_FilterGet(&fil->blue, im->data, im->w, im->h, x,
+ y);
+ b /= bd;
+ B_VAL(p2) = SATURATE(b);
+ }
+ p1++;
+ p2++;
+ }
+ }
free(im->data);
im->data = data;
}
diff --git a/src/font.h b/src/font.h
index 54201e7..c92bbaf 100644
--- a/src/font.h
+++ b/src/font.h
@@ -1,229 +1,130 @@
-#ifndef __FONT
-#define __FONT 1
-typedef struct _imlib_font_header ImlibFontHeader;
-typedef struct _imlib_ttffont ImlibTtfFont;
-typedef struct _imlib_xfont ImlibXFontSet;
-typedef union _imlib_font ImlibFont;
-typedef struct _imlib_encoding_map ImlibEncodingMap;
-typedef unsigned short ImlibWideChar;
+#include <ft2build.h>
+#include FT_FREETYPE_H
+#include FT_GLYPH_H
-#define TTF_FONT_CACHE 1
-#define TTF_HASH_SIZE (256*1)
+/* TODO separate fonts and data stuff */
-#ifdef TTF_FONT_CACHE
-typedef struct _imlib_ttf_hash ImlibTTFHash;
-typedef struct _imlib_ttf_hash_elm ImlibTTFHashElm;
+typedef struct _Imlib_Font ImlibFont;
+typedef struct _Imlib_Font_Glyph Imlib_Font_Glyph;
-struct _imlib_ttf_hash_elm
-{
- wchar_t wc;
- TT_Glyph *glyph;
- TT_Raster_Map *glyph_raster;
-};
+typedef struct _Imlib_Object_List Imlib_Object_List;
+typedef struct _Imlib_Hash Imlib_Hash;
+typedef struct _Imlib_Hash_El Imlib_Hash_El;
-struct _imlib_ttf_hash
+struct _Imlib_Object_List
{
- ImlibTTFHash *next;
- char *name;
- int references;
-
- int type;
- int size;
- ImlibTTFHashElm **hash;
- int mem_use;
+ Imlib_Object_List *next, *prev;
+ Imlib_Object_List *last;
};
-#endif
-struct _imlib_font_header
+struct _Imlib_Hash
{
- int type;
-
- ImlibFont *next;
- char *name;
- int references;
+ int population;
+ Imlib_Object_List *buckets[256];
};
-struct _imlib_ttffont
+struct _Imlib_Hash_El
{
- int type;
-
- ImlibFont *next;
- char *name;
- int references;
-
- TT_Engine engine;
- TT_Face face;
- TT_Instance instance;
- TT_Face_Properties properties;
- int num_glyph;
-#ifdef TTF_FONT_CACHE
- ImlibTTFHash *glyph_hash;
- TT_CharMap char_map;
-#else
- TT_Glyph *glyphs;
- TT_Raster_Map **glyphs_cached_right;
-#endif
- int max_descent;
- int max_ascent;
- int descent;
- int ascent;
- int mem_use;
+ Imlib_Object_List _list_data;
+ char *key;
+ void *data;
};
-struct _imlib_encoding_map {
- ImlibWideChar char_map[96];
-};
+struct _Imlib_Font
+{
+ Imlib_Object_List _list_data;
+ char *name;
+ char *file;
+ int size;
-#define XMB_FONT_CACHE level2
-#define XMB_HASH_SIZE (256*1)
-#define XMB_HASH_VAL1 8
-#define XMB_HASH_VAL2 8
-#define XMB_HASH_VAL3 3
+ struct
+ {
+ FT_Face face;
+ }
+ ft;
-#ifdef XMB_FONT_CACHE
-typedef struct _imlib_xfd_hash ImlibXmbHash;
-typedef struct _imlib_xfd_hash_elm ImlibXmbHashElm;
+ Imlib_Hash *glyphs;
-struct _imlib_xfd_hash_elm
-{
- ImlibXmbHashElm *next;
- wchar_t wc;
- int w, h;
- DATA32 *im;
-};
+ int usage;
-struct _imlib_xfd_hash
-{
- ImlibXmbHash *next;
- char *name;
- int references;
-
- int type;
- int size;
- ImlibXmbHashElm **hash;
- int hash_count;
- int collision_count;
- int mem_use;
-};
-#endif
+ int references;
-struct _imlib_xfont
-{
- int type;
-
- ImlibFont *next;
- char *name;
- int references;
-
- XFontSet xfontset;
- int font_count;
- XFontStruct **font_struct;
- char **font_name;
- int ascent;
- int descent;
- int max_ascent;
- int max_descent;
- int max_width;
-
- ImlibFont *ttffont;
- int total_ascent;
- int total_descent;
-
-#ifdef XMB_FONT_CACHE
- ImlibXmbHash *hash;
-#endif
};
-union _imlib_font
+struct _Imlib_Font_Glyph
{
- int type;
- ImlibFontHeader hdr;
- ImlibTtfFont ttf;
- ImlibXFontSet xf;
+ FT_Glyph glyph;
+ FT_BitmapGlyph glyph_out;
};
-/* Imlib font type */
-#define IMLIB_FONT_TYPE_TTF 1 /* find ttf font only */
-#define IMLIB_FONT_TYPE_X (1<<1) /* find x font only */
-#define IMLIB_FONT_TYPE_TTF_X (IMLIB_FONT_TYPE_TTF | IMLIB_FONT_TYPE_X)
-
-/* Imlib encoding */
-#define IMLIB_ENCOING_ISO_8859_1 0
-#define IMLIB_ENCOING_ISO_8859_2 1
-#define IMLIB_ENCOING_ISO_8859_3 2
-#define IMLIB_ENCOING_ISO_8859_4 3
-
-TT_Raster_Map *__imlib_create_font_raster(int width, int height);
-void __imlib_destroy_font_raster(TT_Raster_Map * rmap);
-void __imlib_add_font_path(const char *path);
-void __imlib_del_font_path(const char *path);
-int __imlib_font_path_exists(const char *path);
-char **__imlib_list_font_path(int *num_ret);
-ImlibFont *__imlib_find_cached_font(const char *ttffontname, const char *xfontname, int mode);
-ImlibFont *__imlib_load_font(const char *fontname);
-ImlibFont *__imlib_load_xfontset(Display *display, const char *fontname);
-#ifdef XMB_FONT_CACHE
-ImlibXmbHash *__imlib_create_font_hash_table(const char *xfontsetname, int type);
-#endif
-#ifdef TTF_FONT_CACHE
-ImlibTTFHash *__imlib_create_ttf_font_hash_table(const char *ttfontname, int type, int argsize);
-#endif
-ImlibFont *__imlib_clone_cached_font(ImlibFont *fn);
-void __imlib_free_font(ImlibFont *font);
-void __imlib_calc_size(ImlibFont *f, int *width, int *height,
- const char *text);
-void __imlib_calc_advance(ImlibFont *f, int *adv_w, int *adv_h,
- const char *text);
-int __imlib_calc_inset(ImlibFont *f, const char *text);
-void __imlib_render_str(ImlibImage *im, ImlibFont *fn, int drx,
- int dry, const char *text,
- DATA8 r, DATA8 g, DATA8 b, DATA8 a,
- char dir, double angle, int *retw, int *reth, int blur,
- int *nextx, int *nexty, ImlibOp op,
- int cx, int cy, int cw, int ch);
-void __imlib_xfd_draw_str(Display *display, Drawable drawable,
- Visual *v, int depth, Colormap cm,
- ImlibImage *im, ImlibFont *fn, int x,
- int y, const char *text, DATA8 r, DATA8 g,
- DATA8 b, DATA8 a, char dir, double angle,
- char blend, ImlibColorModifier *cmod,
- char hiq, char dmask, ImlibOp op,
- int *retw, int *reth,
- int *nextx, int *nexty,
- int cx, int cy, int cw, int ch);
-#ifdef XMB_FONT_CACHE
-void __imlib_xfd_build_str_image(Display *display, Drawable drawable,
- Visual *v, ImlibFont *fn, ImlibImage *im,
- const char *text, DATA8 r, DATA8 g, DATA8 b, DATA8 a);
-#endif
-#ifdef TTF_FONT_CACHE
-unsigned short __imlib_find_hash_index(ImlibTtfFont *f, unsigned short argchar);
-#endif
-int __imlib_char_pos(ImlibFont *fn, const char *text, int x, int y,
- int *cx, int *cy, int *cw, int *ch);
-void __imlib_char_geom(ImlibFont *fn, const char *text, int num,
- int *cx, int *cy, int *cw, int *ch);
-int __imlib_xfd_char_pos(ImlibFont *f, const char *text, int x, int y,
- int *cx, int *cy, int *cw, int *ch);
-void __imlib_xfd_char_geom(ImlibFont *fn, const char *text, int num,
- int *cx, int *cy, int *cw, int *ch);
-char **__imlib_list_fonts(int *num_ret);
-void __imlib_free_font_list(char **list, int num);
-int __imlib_get_cached_font_size(void);
-void __imlib_flush_font_cache(void);
-void __imlib_purge_font_cache(void);
-int __imlib_get_font_cache_size(void);
-void __imlib_set_font_cache_size(int size);
-void __imlib_nuke_font(ImlibFont *font);
-void __imlib_set_TTF_encoding(unsigned char enc);
-void __imlib_init_encoding();
-#ifdef XMB_FONT_CACHE
-void __imlib_free_font_hash(ImlibXmbHash *h);
-#endif
-
-#ifdef TTF_FONT_CACHE
-void __imlib_free_ttf_font_hash(ImlibTTFHash *h);
-#endif
-
-#endif
+/* functions */
+
+void imlib_font_init(void);
+int imlib_font_ascent_get(ImlibFont * fn);
+int imlib_font_descent_get(ImlibFont * fn);
+int imlib_font_max_ascent_get(ImlibFont * fn);
+int imlib_font_max_descent_get(ImlibFont * fn);
+int imlib_font_get_line_advance(ImlibFont * fn);
+int imlib_font_utf8_get_next(unsigned char *buf, int *iindex);
+void imlib_font_add_font_path(const char *path);
+void imlib_font_del_font_path(const char *path);
+int imlib_font_path_exists(const char *path);
+char **imlib_font_list_font_path(int *num_ret);
+char **imlib_font_list_fonts(int *num_ret);
+
+ImlibFont *imlib_font_load_joined(const char *name);
+ImlibFont *imlib_font_load(const char *name, int size);
+void imlib_font_free(ImlibFont * fn);
+static int font_modify_cache_cb(Imlib_Hash * hash, const char *key,
+ void *data, void *fdata);
+int imlib_font_cache_get(void);
+void imlib_font_cache_set(int size);
+void imlib_font_flush(void);
+static int font_flush_free_glyph_cb(Imlib_Hash * hash, const char *key,
+ void *data, void *fdata);
+void imlib_font_modify_cache_by(ImlibFont * fn, int dir);
+void imlib_font_modify_cache_by(ImlibFont * fn, int dir);
+void imlib_font_flush_last(void);
+ImlibFont *imlib_font_find(const char *name, int size);
+
+void imlib_font_query_size(ImlibFont * fn, const char *text,
+ int *w, int *h);
+int imlib_font_query_inset(ImlibFont * fn, const char *text);
+void imlib_font_query_advance(ImlibFont * fn, const char *text,
+ int *h_adv, int *v_adv);
+int imlib_font_query_char_coords(ImlibFont * fn,
+ const char *text, int pos,
+ int *cx, int *cy, int *cw,
+ int *ch);
+int imlib_font_query_text_at_pos(ImlibFont * fn,
+ const char *text, int x, int y,
+ int *cx, int *cy, int *cw,
+ int *ch);
+
+Imlib_Font_Glyph *imlib_font_cache_glyph_get(ImlibFont * fn, FT_UInt index);
+void imlib_render_str(ImlibImage * im, ImlibFont * f, int drx,
+ int dry, const char *text, DATA8 r,
+ DATA8 g, DATA8 b, DATA8 a, char dir,
+ double angle, int *retw, int *reth,
+ int blur, int *nextx, int *nexty,
+ ImlibOp op, int clx, int cly, int clw,
+ int clh);
+void imlib_font_draw(ImlibImage * dst, DATA32 col,
+ ImlibFont * fn, int x, int y,
+ const char *text, int *nextx, int *nexty,
+ int clx, int cly, int clw, int clh);
+
+/* data manipulation */
+
+void *imlib_object_list_prepend(void *in_list, void *in_item);
+void *imlib_object_list_remove(void *in_list, void *in_item);
+Imlib_Hash *imlib_hash_add(Imlib_Hash * hash, const char *key,
+ const void *data);
+void *imlib_hash_find(Imlib_Hash * hash, const char *key);
+void imlib_hash_free(Imlib_Hash * hash);
+void imlib_hash_foreach(Imlib_Hash * hash,
+ int (*func) (Imlib_Hash * hash,
+ const char *key, void *data,
+ void *fdata),
+ const void *fdata);
diff --git a/src/grab.c b/src/grab.c
index 6b7518e..86aa337 100644
--- a/src/grab.c
+++ b/src/grab.c
@@ -8,86 +8,96 @@
#include "grab.h"
static char _x_err = 0;
-static DATA8 rtab[256], gtab[256], btab[256];
+static DATA8 rtab[256], gtab[256], btab[256];
static void
Tmp_HandleXError(Display * d, XErrorEvent * ev)
{
- d = NULL;
- ev = NULL;
- _x_err = 1;
+ d = NULL;
+ ev = NULL;
+ _x_err = 1;
}
void
-__imlib_GrabXImageToRGBA(DATA32 *data, int ox, int oy, int ow, int oh,
- Display *d, XImage *xim, XImage *mxim, Visual *v,
- int depth, int x, int y,
- int w, int h, char grab)
+__imlib_GrabXImageToRGBA(DATA32 * data, int ox, int oy, int ow, int oh,
+ Display * d, XImage * xim, XImage * mxim, Visual * v,
+ int depth, int x, int y, int w, int h, char grab)
{
- int inx, iny;
- DATA32 *src, *ptr;
- int pixel, mpixel;
- int origx, origy;
- int bgr = 0;
+ int inx, iny;
+ DATA32 *src, *ptr;
+ int pixel, mpixel;
+ int origx, origy;
+ int bgr = 0;
- if (!data) return;
+ if (!data)
+ return;
- if (grab) XGrabServer(d); /* This may prevent the image to be changed under our feet */
- origx = x;
- origy = y;
+ if (grab)
+ XGrabServer(d); /* This may prevent the image to be changed under our feet */
+ origx = x;
+ origy = y;
+
+ if (v->blue_mask > v->red_mask)
+ bgr = 1;
- if (v->blue_mask > v->red_mask) bgr = 1;
+ if (origx < 0)
+ inx = -origx;
+ else
+ inx = ox;
+ if (origy < 0)
+ iny = -origy;
+ else
+ iny = oy;
+ /* go thru the XImage and convert */
+ if (xim->bits_per_pixel == 32)
+ depth = 32;
+ switch (depth)
+ {
+ case 0:
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ case 5:
+ case 6:
+ case 7:
+ case 8:
+ if (mxim)
+ {
+ for (y = 0; y < h; y++)
+ {
+ ptr = data + ((y + iny) * ow) + inx;
+ for (x = 0; x < w; x++)
+ {
+ pixel = XGetPixel(xim, x, y);
+ mpixel = XGetPixel(mxim, x, y);
+ *ptr++ = (0xff000000 >> (mpixel << 31)) |
+ (btab[pixel & 0xff]) |
+ (gtab[pixel & 0xff] << 8) |
+ (rtab[pixel & 0xff] << 16);
- if (origx < 0)
- inx = -origx;
- else
- inx = ox;
- if (origy < 0)
- iny = -origy;
- else
- iny = oy;
- /* go thru the XImage and convert */
- if (xim->bits_per_pixel == 32) depth = 32;
- switch (depth) {
- case 0:
- case 1:
- case 2:
- case 3:
- case 4:
- case 5:
- case 6:
- case 7:
- case 8:
- if (mxim) {
- for (y = 0; y < h; y++) {
- ptr = data + ((y + iny) * ow) + inx;
- for (x = 0; x < w; x++) {
- pixel = XGetPixel(xim, x, y);
- mpixel = XGetPixel(mxim, x, y);
- *ptr++ = (0xff000000 >> (mpixel << 31)) |
- (btab[pixel & 0xff]) |
- (gtab[pixel & 0xff] << 8) |
- (rtab[pixel & 0xff] << 16);
-
- }
- }
- }
- else {
- for (y = 0; y < h; y++) {
- ptr = data + ((y + iny) * ow) + inx;
- for (x = 0; x < w; x++) {
- pixel = XGetPixel(xim, x, y);
- *ptr++ = 0xff000000 |
- (btab[pixel & 0xff]) |
- (gtab[pixel & 0xff] << 8) |
- (rtab[pixel & 0xff] << 16);
- }
- }
- }
- break;
- case 16:
-#undef MP
-#undef RMSK
+ }
+ }
+ }
+ else
+ {
+ for (y = 0; y < h; y++)
+ {
+ ptr = data + ((y + iny) * ow) + inx;
+ for (x = 0; x < w; x++)
+ {
+ pixel = XGetPixel(xim, x, y);
+ *ptr++ = 0xff000000 |
+ (btab[pixel & 0xff]) |
+ (gtab[pixel & 0xff] << 8) |
+ (rtab[pixel & 0xff] << 16);
+ }
+ }
+ }
+ break;
+ case 16:
+#undef MP
+#undef RMSK
#undef GMSK
#undef BMSK
#undef R1SH
@@ -110,52 +120,60 @@ __imlib_GrabXImageToRGBA(DATA32 *data, int ox, int oy, int ow, int oh,
#define B2SH(p) ((p) >> 13)
#define P1(p) (R1SH(p) & RMSK) | (G1SH(p) & GMSK) | (B1SH(p) & BMSK)
#define P2(p) (R2SH(p) & RMSK) | (G2SH(p) & GMSK) | (B2SH(p) & BMSK)
- if (mxim) {
- for (y = 0; y < h; y++) {
- src = (DATA32 *)(xim->data + (xim->bytes_per_line * y));
- ptr = data + ((y + iny) * ow) + inx;
- for (x = 0; x < (w - 1); x += 2) {
+ if (mxim)
+ {
+ for (y = 0; y < h; y++)
+ {
+ src = (DATA32 *) (xim->data + (xim->bytes_per_line * y));
+ ptr = data + ((y + iny) * ow) + inx;
+ for (x = 0; x < (w - 1); x += 2)
+ {
#ifdef WORDS_BIGENDIAN
- *ptr++ = MP(x + 1, y) | P2(*src);
- *ptr++ = MP(x, y) | P1(*src);
+ *ptr++ = MP(x + 1, y) | P2(*src);
+ *ptr++ = MP(x, y) | P1(*src);
#else
- *ptr++ = MP(x, y) | P1(*src);
- *ptr++ = MP(x + 1, y) | P2(*src);
+ *ptr++ = MP(x, y) | P1(*src);
+ *ptr++ = MP(x + 1, y) | P2(*src);
#endif
- src++;
- }
- if (x == (w - 1)) {
- pixel = XGetPixel(xim, x, y);
- *ptr++ = MP(x, y) | P1(pixel);
- }
- }
- }
-#undef MP
+ src++;
+ }
+ if (x == (w - 1))
+ {
+ pixel = XGetPixel(xim, x, y);
+ *ptr++ = MP(x, y) | P1(pixel);
+ }
+ }
+ }
+#undef MP
#define MP(x, y) (0xff000000)
- else {
- for (y = 0; y < h; y++) {
- src = (DATA32 *)(xim->data + (xim->bytes_per_line * y));
- ptr = data + ((y + iny) * ow) + inx;
- for (x = 0; x < (w - 1); x += 2) {
+ else
+ {
+ for (y = 0; y < h; y++)
+ {
+ src = (DATA32 *) (xim->data + (xim->bytes_per_line * y));
+ ptr = data + ((y + iny) * ow) + inx;
+ for (x = 0; x < (w - 1); x += 2)
+ {
#ifdef WORDS_BIGENDIAN
- *ptr++ = MP(x + 1, y) | P2(*src);
- *ptr++ = MP(x, y) | P1(*src);
+ *ptr++ = MP(x + 1, y) | P2(*src);
+ *ptr++ = MP(x, y) | P1(*src);
#else
- *ptr++ = MP(x, y) | P1(*src);
- *ptr++ = MP(x + 1, y) | P2(*src);
+ *ptr++ = MP(x, y) | P1(*src);
+ *ptr++ = MP(x + 1, y) | P2(*src);
#endif
- src++;
- }
- if (x == (w - 1)) {
- pixel = XGetPixel(xim, x, y);
- *ptr++ = MP(x, y) | P1(pixel);
- }
- }
- }
- break;
- case 15:
-#undef MP
-#undef RMSK
+ src++;
+ }
+ if (x == (w - 1))
+ {
+ pixel = XGetPixel(xim, x, y);
+ *ptr++ = MP(x, y) | P1(pixel);
+ }
+ }
+ }
+ break;
+ case 15:
+#undef MP
+#undef RMSK
#undef GMSK
#undef BMSK
#undef R1SH
@@ -178,172 +196,210 @@ __imlib_GrabXImageToRGBA(DATA32 *data, int ox, int oy, int ow, int oh,
#define B2SH(p) ((p) >> 13)
#define P1(p) (R1SH(p) & RMSK) | (G1SH(p) & GMSK) | (B1SH(p) & BMSK)
#define P2(p) (R2SH(p) & RMSK) | (G2SH(p) & GMSK) | (B2SH(p) & BMSK)
- if (mxim) {
- for (y = 0; y < h; y++) {
- src = (DATA32 *)(xim->data + (xim->bytes_per_line * y));
- ptr = data + ((y + iny) * ow) + inx;
- for (x = 0; x < (w - 1); x += 2) {
+ if (mxim)
+ {
+ for (y = 0; y < h; y++)
+ {
+ src = (DATA32 *) (xim->data + (xim->bytes_per_line * y));
+ ptr = data + ((y + iny) * ow) + inx;
+ for (x = 0; x < (w - 1); x += 2)
+ {
#ifdef WORDS_BIGENDIAN
- *ptr++ = MP(x + 1, y) | P2(*src);
- *ptr++ = MP(x, y) | P1(*src);
+ *ptr++ = MP(x + 1, y) | P2(*src);
+ *ptr++ = MP(x, y) | P1(*src);
#else
- *ptr++ = MP(x, y) | P1(*src);
- *ptr++ = MP(x + 1, y) | P2(*src);
+ *ptr++ = MP(x, y) | P1(*src);
+ *ptr++ = MP(x + 1, y) | P2(*src);
#endif
- src++;
- }
- if (x == (w - 1)) {
- pixel = XGetPixel(xim, x, y);
- *ptr++ = MP(x, y) | P1(pixel);
- }
- }
- }
-#undef MP
+ src++;
+ }
+ if (x == (w - 1))
+ {
+ pixel = XGetPixel(xim, x, y);
+ *ptr++ = MP(x, y) | P1(pixel);
+ }
+ }
+ }
+#undef MP
#define MP(x, y) (0xff000000)
- else {
- for (y = 0; y < h; y++) {
- src = (DATA32 *)(xim->data + (xim->bytes_per_line * y));
- ptr = data + ((y + iny) * ow) + inx;
- for (x = 0; x < (w - 1); x += 2) {
+ else
+ {
+ for (y = 0; y < h; y++)
+ {
+ src = (DATA32 *) (xim->data + (xim->bytes_per_line * y));
+ ptr = data + ((y + iny) * ow) + inx;
+ for (x = 0; x < (w - 1); x += 2)
+ {
#ifdef WORDS_BIGENDIAN
- *ptr++ = MP(x + 1, y) | P2(*src);
- *ptr++ = MP(x, y) | P1(*src);
+ *ptr++ = MP(x + 1, y) | P2(*src);
+ *ptr++ = MP(x, y) | P1(*src);
#else
- *ptr++ = MP(x, y) | P1(*src);
- *ptr++ = MP(x + 1, y) | P2(*src);
+ *ptr++ = MP(x, y) | P1(*src);
+ *ptr++ = MP(x + 1, y) | P2(*src);
#endif
- src++;
- }
- if (x == (w - 1)) {
- pixel = XGetPixel(xim, x, y);
- *ptr++ = MP(x, y) | P1(pixel);
- }
- }
- }
- break;
- case 24:
- if (bgr) {
- if (mxim) {
- for (y = 0; y < h; y++) {
- ptr = data + ((y + iny) * ow) + inx;
- for (x = 0; x < w; x++) {
- pixel = XGetPixel(xim, x, y);
- pixel =
- ((pixel << 16) & 0xff0000) |
- ((pixel) & 0x00ff00) |
- ((pixel >> 16) & 0x0000ff);
- mpixel = XGetPixel(mxim, x, y);
- *ptr++ = (0xff000000 >> (mpixel << 31)) |
- (pixel & 0x00ffffff);
- }
- }
- }
- else {
- for (y = 0; y < h; y++) {
- ptr = data + ((y + iny) * ow) + inx;
- for (x = 0; x < w; x++) {
- pixel = XGetPixel(xim, x, y);
- *ptr++ = 0xff000000 |
- ((pixel << 16) & 0xff0000) |
- ((pixel) & 0x00ff00) |
- ((pixel >> 16) & 0x0000ff);
- }
- }
- }
- }
- else {
- if (mxim) {
- for (y = 0; y < h; y++) {
- ptr = data + ((y + iny) * ow) + inx;
- for (x = 0; x < w; x++) {
- pixel = XGetPixel(xim, x, y);
- mpixel = XGetPixel(mxim, x, y);
- *ptr++ = (0xff000000 >> (mpixel << 31)) |
- (pixel & 0x00ffffff);
- }
- }
- }
- else {
- for (y = 0; y < h; y++) {
- ptr = data + ((y + iny) * ow) + inx;
- for (x = 0; x < w; x++) {
- pixel = XGetPixel(xim, x, y);
- *ptr++ = 0xff000000 |
- (pixel & 0x00ffffff);
- }
- }
- }
- }
- break;
- case 32:
- if (bgr) {
- if (mxim) {
- for (y = 0; y < h; y++) {
- src = (DATA32 *)(xim->data + (xim->bytes_per_line * y));
- ptr = data + ((y + iny) * ow) + inx;
- for (x = 0; x < w; x++) {
- mpixel = XGetPixel(mxim, x, y);
- pixel =
- ((*src << 16) & 0xff0000) |
- ((*src) & 0x00ff00) |
- ((*src >> 16) & 0x0000ff);
- *ptr++ = (0xff000000 >> (mpixel << 31)) |
- ((pixel) & 0x00ffffff);
- src++;
- }
- }
- }
- else {
- for (y = 0; y < h; y++) {
- src = (DATA32 *)(xim->data + (xim->bytes_per_line * y));
- ptr = data + ((y + iny) * ow) + inx;
- for (x = 0; x < w; x++) {
- *ptr++ = 0xff000000 |
- ((*src << 16) & 0xff0000) |
- ((*src) & 0x00ff00) |
- ((*src >> 16) & 0x0000ff);
- src++;
- }
- }
- }
- }
- else {
- if (mxim) {
- for (y = 0; y < h; y++) {
- src = (DATA32 *)(xim->data + (xim->bytes_per_line * y));
- ptr = data + ((y + iny) * ow) + inx;
- for (x = 0; x < w; x++) {
- mpixel = XGetPixel(mxim, x, y);
- *ptr++ = (0xff000000 >> (mpixel << 31)) |
- ((*src) & 0x00ffffff);
- src++;
- }
- }
- }
- else {
- for (y = 0; y < h; y++) {
- src = (DATA32 *)(xim->data + (xim->bytes_per_line * y));
- ptr = data + ((y + iny) * ow) + inx;
- for (x = 0; x < w; x++) {
- *ptr++ = 0xff000000 |
- ((*src) & 0x00ffffff);
- src++;
- }
- }
- }
- }
- break;
- default:
- break;
- }
- XUngrabServer(d);
+ src++;
+ }
+ if (x == (w - 1))
+ {
+ pixel = XGetPixel(xim, x, y);
+ *ptr++ = MP(x, y) | P1(pixel);
+ }
+ }
+ }
+ break;
+ case 24:
+ if (bgr)
+ {
+ if (mxim)
+ {
+ for (y = 0; y < h; y++)
+ {
+ ptr = data + ((y + iny) * ow) + inx;
+ for (x = 0; x < w; x++)
+ {
+ pixel = XGetPixel(xim, x, y);
+ pixel =
+ ((pixel << 16) & 0xff0000) |
+ ((pixel) & 0x00ff00) |
+ ((pixel >> 16) & 0x0000ff);
+ mpixel = XGetPixel(mxim, x, y);
+ *ptr++ = (0xff000000 >> (mpixel << 31)) |
+ (pixel & 0x00ffffff);
+ }
+ }
+ }
+ else
+ {
+ for (y = 0; y < h; y++)
+ {
+ ptr = data + ((y + iny) * ow) + inx;
+ for (x = 0; x < w; x++)
+ {
+ pixel = XGetPixel(xim, x, y);
+ *ptr++ = 0xff000000 |
+ ((pixel << 16) & 0xff0000) |
+ ((pixel) & 0x00ff00) |
+ ((pixel >> 16) & 0x0000ff);
+ }
+ }
+ }
+ }
+ else
+ {
+ if (mxim)
+ {
+ for (y = 0; y < h; y++)
+ {
+ ptr = data + ((y + iny) * ow) + inx;
+ for (x = 0; x < w; x++)
+ {
+ pixel = XGetPixel(xim, x, y);
+ mpixel = XGetPixel(mxim, x, y);
+ *ptr++ = (0xff000000 >> (mpixel << 31)) |
+ (pixel & 0x00ffffff);
+ }
+ }
+ }
+ else
+ {
+ for (y = 0; y < h; y++)
+ {
+ ptr = data + ((y + iny) * ow) + inx;
+ for (x = 0; x < w; x++)
+ {
+ pixel = XGetPixel(xim, x, y);
+ *ptr++ = 0xff000000 | (pixel & 0x00ffffff);
+ }
+ }
+ }
+ }
+ break;
+ case 32:
+ if (bgr)
+ {
+ if (mxim)
+ {
+ for (y = 0; y < h; y++)
+ {
+ src =
+ (DATA32 *) (xim->data + (xim->bytes_per_line * y));
+ ptr = data + ((y + iny) * ow) + inx;
+ for (x = 0; x < w; x++)
+ {
+ mpixel = XGetPixel(mxim, x, y);
+ pixel =
+ ((*src << 16) & 0xff0000) |
+ ((*src) & 0x00ff00) |
+ ((*src >> 16) & 0x0000ff);
+ *ptr++ = (0xff000000 >> (mpixel << 31)) |
+ ((pixel) & 0x00ffffff);
+ src++;
+ }
+ }
+ }
+ else
+ {
+ for (y = 0; y < h; y++)
+ {
+ src =
+ (DATA32 *) (xim->data + (xim->bytes_per_line * y));
+ ptr = data + ((y + iny) * ow) + inx;
+ for (x = 0; x < w; x++)
+ {
+ *ptr++ = 0xff000000 |
+ ((*src << 16) & 0xff0000) |
+ ((*src) & 0x00ff00) |
+ ((*src >> 16) & 0x0000ff);
+ src++;
+ }
+ }
+ }
+ }
+ else
+ {
+ if (mxim)
+ {
+ for (y = 0; y < h; y++)
+ {
+ src =
+ (DATA32 *) (xim->data + (xim->bytes_per_line * y));
+ ptr = data + ((y + iny) * ow) + inx;
+ for (x = 0; x < w; x++)
+ {
+ mpixel = XGetPixel(mxim, x, y);
+ *ptr++ = (0xff000000 >> (mpixel << 31)) |
+ ((*src) & 0x00ffffff);
+ src++;
+ }
+ }
+ }
+ else
+ {
+ for (y = 0; y < h; y++)
+ {
+ src =
+ (DATA32 *) (xim->data + (xim->bytes_per_line * y));
+ ptr = data + ((y + iny) * ow) + inx;
+ for (x = 0; x < w; x++)
+ {
+ *ptr++ = 0xff000000 | ((*src) & 0x00ffffff);
+ src++;
+ }
+ }
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ XUngrabServer(d);
}
char
-__imlib_GrabDrawableToRGBA(DATA32 *data, int ox, int oy, int ow, int oh,
- Display *d, Drawable p, Pixmap m, Visual *v,
- Colormap cm, int depth, int x, int y,
- int w, int h, char domask, char grab)
+__imlib_GrabDrawableToRGBA(DATA32 * data, int ox, int oy, int ow, int oh,
+ Display * d, Drawable p, Pixmap m, Visual * v,
+ Colormap cm, int depth, int x, int y,
+ int w, int h, char domask, char grab)
{
XErrorHandler prev_erh = NULL;
XWindowAttributes xatt, ratt;
@@ -370,322 +426,311 @@ __imlib_GrabDrawableToRGBA(DATA32 *data, int ox, int oy, int ow, int oh,
if (_x_err)
is_pixmap = 1;
/* reset our error handler */
- XSetErrorHandler((XErrorHandler) prev_erh);
+ XSetErrorHandler((XErrorHandler) prev_erh);
if (is_pixmap)
{
- Window dw;
-
- XGetGeometry(d, p, &dw, &src_x, &src_y,
- (unsigned int *)&src_w, (unsigned int *)&src_h,
- (unsigned int *)&src_x, (unsigned int *)&xatt.depth);
- src_x = 0;
- src_y = 0;
+ Window dw;
+
+ XGetGeometry(d, p, &dw, &src_x, &src_y,
+ (unsigned int *)&src_w, (unsigned int *)&src_h,
+ (unsigned int *)&src_x, (unsigned int *)&xatt.depth);
+ src_x = 0;
+ src_y = 0;
}
else
{
- Window dw;
- XGetWindowAttributes(d, xatt.root, &ratt);
- XTranslateCoordinates(d, p, xatt.root, 0, 0, &src_x, &src_y, &dw);
- src_w = xatt.width;
- src_h = xatt.height;
- if ((xatt.map_state != IsViewable) &&
- (xatt.backing_store == NotUseful))
- {
- if (grab)
- XUngrabServer(d);
- return 0;
- }
+ Window dw;
+
+ XGetWindowAttributes(d, xatt.root, &ratt);
+ XTranslateCoordinates(d, p, xatt.root, 0, 0, &src_x, &src_y, &dw);
+ src_w = xatt.width;
+ src_h = xatt.height;
+ if ((xatt.map_state != IsViewable) && (xatt.backing_store == NotUseful))
+ {
+ if (grab)
+ XUngrabServer(d);
+ return 0;
+ }
}
-
+
/* clip to the drawable tree and screen */
clipx = 0;
- clipy = 0;
+ clipy = 0;
width = src_w - x;
height = src_h - y;
if (width > w)
width = w;
if (height > h)
height = h;
-
+
if (!is_pixmap)
{
- if ((src_x + x + width) > ratt.width)
- width = ratt.width - (src_x + x);
- if ((src_y + y + height) > ratt.height)
- height = ratt.height - (src_y + y);
+ if ((src_x + x + width) > ratt.width)
+ width = ratt.width - (src_x + x);
+ if ((src_y + y + height) > ratt.height)
+ height = ratt.height - (src_y + y);
}
if (x < 0)
{
- clipx = -x;
- width += x;
- x = 0;
+ clipx = -x;
+ width += x;
+ x = 0;
}
if (y < 0)
{
- clipy = -y;
- height += y;
- y = 0;
+ clipy = -y;
+ height += y;
+ y = 0;
}
if (!is_pixmap)
{
- if ((src_x + x) < 0)
- {
- clipx -= (src_x + x);
- width += (src_x + x);
- x = -src_x;
- }
- if ((src_y + y) < 0)
- {
- clipy -= (src_y + y);
- height += (src_y + y);
- y = -src_y;
- }
+ if ((src_x + x) < 0)
+ {
+ clipx -= (src_x + x);
+ width += (src_x + x);
+ x = -src_x;
+ }
+ if ((src_y + y) < 0)
+ {
+ clipy -= (src_y + y);
+ height += (src_y + y);
+ y = -src_y;
+ }
}
if ((width <= 0) || (height <= 0))
{
- if (grab)
- XUngrabServer(d);
- return 0;
+ if (grab)
+ XUngrabServer(d);
+ return 0;
}
w = width;
h = height;
if ((!is_pixmap) && (domask) && (!m))
{
- int ord, rect_no = 0;
- XRectangle *r = NULL;
-
- r = XShapeGetRectangles(d, p, ShapeBounding, &rect_no, &ord);
- if (r)
- {
- if (!((rect_no == 1) &&
- (r[0].x == 0) && (r[0].y == 0) &&
- (r[0].width == xatt.width) && (r[0].height == xatt.height)))
- {
- XGCValues gcv;
- GC gc;
-
- created_mask = 1;
- m = XCreatePixmap(d, p, w, h, 1);
- gcv.foreground = 0;
- gc = XCreateGC(d, m, GCForeground, &gcv);
- XFillRectangle(d, m, gc, 0, 0, w, h);
- XSetForeground(d, gc, 1);
- for (i = 0; i < rect_no; i++)
- XFillRectangle(d, m, gc,
- r[i].x - x, r[i].y - y,
- r[i].width, r[i].height);
- XFreeGC(d, gc);
- }
- XFree(r);
- }
+ int ord, rect_no = 0;
+ XRectangle *r = NULL;
+
+ r = XShapeGetRectangles(d, p, ShapeBounding, &rect_no, &ord);
+ if (r)
+ {
+ if (!((rect_no == 1) &&
+ (r[0].x == 0) && (r[0].y == 0) &&
+ (r[0].width == xatt.width) && (r[0].height == xatt.height)))
+ {
+ XGCValues gcv;
+ GC gc;
+
+ created_mask = 1;
+ m = XCreatePixmap(d, p, w, h, 1);
+ gcv.foreground = 0;
+ gc = XCreateGC(d, m, GCForeground, &gcv);
+ XFillRectangle(d, m, gc, 0, 0, w, h);
+ XSetForeground(d, gc, 1);
+ for (i = 0; i < rect_no; i++)
+ XFillRectangle(d, m, gc,
+ r[i].x - x, r[i].y - y,
+ r[i].width, r[i].height);
+ XFreeGC(d, gc);
+ }
+ XFree(r);
+ }
}
/* Create an Ximage (shared or not) */
if (x_does_shm < 0)
{
- if (XShmQueryExtension(d))
- x_does_shm = 1;
- else
- x_does_shm = 0;
+ if (XShmQueryExtension(d))
+ x_does_shm = 1;
+ else
+ x_does_shm = 0;
}
prev_erh = XSetErrorHandler((XErrorHandler) Tmp_HandleXError);
_x_err = 0;
if (x_does_shm)
{
- xim = XShmCreateImage(d, v, xatt.depth, ZPixmap, NULL,
- &shminfo, w, h);
- if (!xim)
- xim = XGetImage(d, p, x, y, w, h,
- 0xffffffff, ZPixmap);
- else
- {
- XSync(d, False);
- if (_x_err)
- {
- XDestroyImage(xim);
- xim = XGetImage(d, p, x, y, w, h,
- 0xffffffff, ZPixmap);
- _x_err = 0;
- }
- else
- {
- shminfo.shmid = shmget(IPC_PRIVATE, xim->bytes_per_line *
- xim->height, IPC_CREAT | 0666);
- if (shminfo.shmid < 0)
- {
- XDestroyImage(xim);
- xim = XGetImage(d, p, x, y, w, h,
- 0xffffffff, ZPixmap);
- }
- else
- {
- shminfo.shmaddr = xim->data = shmat(shminfo.shmid, 0, 0);
- if (xim->data != (char *)-1)
- {
- shminfo.readOnly = False;
- XShmAttach(d, &shminfo);
- is_shm = 1;
- }
- else
- {
- shmctl(shminfo.shmid, IPC_RMID, 0);
- XDestroyImage(xim);
- xim = XGetImage(d, p, x, y, w, h,
- 0xffffffff, ZPixmap);
- }
- }
- }
- }
+ xim = XShmCreateImage(d, v, xatt.depth, ZPixmap, NULL, &shminfo, w, h);
+ if (!xim)
+ xim = XGetImage(d, p, x, y, w, h, 0xffffffff, ZPixmap);
+ else
+ {
+ XSync(d, False);
+ if (_x_err)
+ {
+ XDestroyImage(xim);
+ xim = XGetImage(d, p, x, y, w, h, 0xffffffff, ZPixmap);
+ _x_err = 0;
+ }
+ else
+ {
+ shminfo.shmid = shmget(IPC_PRIVATE, xim->bytes_per_line *
+ xim->height, IPC_CREAT | 0666);
+ if (shminfo.shmid < 0)
+ {
+ XDestroyImage(xim);
+ xim = XGetImage(d, p, x, y, w, h, 0xffffffff, ZPixmap);
+ }
+ else
+ {
+ shminfo.shmaddr = xim->data = shmat(shminfo.shmid, 0, 0);
+ if (xim->data != (char *)-1)
+ {
+ shminfo.readOnly = False;
+ XShmAttach(d, &shminfo);
+ is_shm = 1;
+ }
+ else
+ {
+ shmctl(shminfo.shmid, IPC_RMID, 0);
+ XDestroyImage(xim);
+ xim = XGetImage(d, p, x, y, w, h,
+ 0xffffffff, ZPixmap);
+ }
+ }
+ }
+ }
}
else
xim = XGetImage(d, p, x, y, w, h, 0xffffffff, ZPixmap);
if (is_shm)
{
- XShmGetImage(d, p, xim, x, y, 0xffffffff);
- XSync(d, False);
- if (_x_err)
- {
- shmdt(shminfo.shmaddr);
- shmctl(shminfo.shmid, IPC_RMID, 0);
- XDestroyImage(xim);
- xim = XGetImage(d, p, x, y, w, h,
- 0xffffffff, ZPixmap);
- is_shm = 0;
- }
+ XShmGetImage(d, p, xim, x, y, 0xffffffff);
+ XSync(d, False);
+ if (_x_err)
+ {
+ shmdt(shminfo.shmaddr);
+ shmctl(shminfo.shmid, IPC_RMID, 0);
+ XDestroyImage(xim);
+ xim = XGetImage(d, p, x, y, w, h, 0xffffffff, ZPixmap);
+ is_shm = 0;
+ }
}
XSetErrorHandler((XErrorHandler) prev_erh);
if ((m) && (domask))
{
- prev_erh = XSetErrorHandler((XErrorHandler) Tmp_HandleXError);
- _x_err = 0;
- if (x_does_shm)
- {
- mxim = XShmCreateImage(d, v, 1, ZPixmap, NULL,
- &mshminfo, w, h);
- if (!mxim)
- mxim = XGetImage(d, p, 0, 0, w, h,
- 0xffffffff, ZPixmap);
- else
- {
- XSync(d, False);
- if (_x_err)
- {
- XDestroyImage(mxim);
- xim = XGetImage(d, p, 0, 0, w, h,
- 0xffffffff, ZPixmap);
- _x_err = 0;
- }
- else
- {
- mshminfo.shmid = shmget(IPC_PRIVATE,
- mxim->bytes_per_line *
- mxim->height, IPC_CREAT | 0666);
- if (mshminfo.shmid < 0)
- {
- XDestroyImage(mxim);
- mxim = XGetImage(d, p, 0, 0, w, h,
- 0xffffffff, ZPixmap);
- }
- else
- {
- mshminfo.shmaddr = xim->data =
- shmat(mshminfo.shmid, 0, 0);
- if (mxim->data != (char *)-1)
- {
- mshminfo.readOnly = False;
- XShmAttach(d, &mshminfo);
- is_mshm = 1;
- }
- else
- {
- shmctl(mshminfo.shmid, IPC_RMID, 0);
- XDestroyImage(mxim);
- mxim = XGetImage(d, p, x, y, w, h,
- 0xffffffff, ZPixmap);
- }
- }
- }
- }
- }
- else
- mxim = XGetImage(d, m, 0, 0, w, h, 0xffffffff, ZPixmap);
- if (is_mshm)
- {
- XShmGetImage(d, p, mxim, 0, 0, 0xffffffff);
- XSync(d, False);
- if (_x_err)
- {
- shmdt(mshminfo.shmaddr);
- shmctl(mshminfo.shmid, IPC_RMID, 0);
- XDestroyImage(mxim);
- mxim = XGetImage(d, p, 0, 0, w, h,
- 0xffffffff, ZPixmap);
- is_mshm = 0;
- }
- XSetErrorHandler((XErrorHandler) prev_erh);
- }
+ prev_erh = XSetErrorHandler((XErrorHandler) Tmp_HandleXError);
+ _x_err = 0;
+ if (x_does_shm)
+ {
+ mxim = XShmCreateImage(d, v, 1, ZPixmap, NULL, &mshminfo, w, h);
+ if (!mxim)
+ mxim = XGetImage(d, p, 0, 0, w, h, 0xffffffff, ZPixmap);
+ else
+ {
+ XSync(d, False);
+ if (_x_err)
+ {
+ XDestroyImage(mxim);
+ xim = XGetImage(d, p, 0, 0, w, h, 0xffffffff, ZPixmap);
+ _x_err = 0;
+ }
+ else
+ {
+ mshminfo.shmid = shmget(IPC_PRIVATE,
+ mxim->bytes_per_line *
+ mxim->height, IPC_CREAT | 0666);
+ if (mshminfo.shmid < 0)
+ {
+ XDestroyImage(mxim);
+ mxim = XGetImage(d, p, 0, 0, w, h,
+ 0xffffffff, ZPixmap);
+ }
+ else
+ {
+ mshminfo.shmaddr = xim->data =
+ shmat(mshminfo.shmid, 0, 0);
+ if (mxim->data != (char *)-1)
+ {
+ mshminfo.readOnly = False;
+ XShmAttach(d, &mshminfo);
+ is_mshm = 1;
+ }
+ else
+ {
+ shmctl(mshminfo.shmid, IPC_RMID, 0);
+ XDestroyImage(mxim);
+ mxim = XGetImage(d, p, x, y, w, h,
+ 0xffffffff, ZPixmap);
+ }
+ }
+ }
+ }
+ }
+ else
+ mxim = XGetImage(d, m, 0, 0, w, h, 0xffffffff, ZPixmap);
+ if (is_mshm)
+ {
+ XShmGetImage(d, p, mxim, 0, 0, 0xffffffff);
+ XSync(d, False);
+ if (_x_err)
+ {
+ shmdt(mshminfo.shmaddr);
+ shmctl(mshminfo.shmid, IPC_RMID, 0);
+ XDestroyImage(mxim);
+ mxim = XGetImage(d, p, 0, 0, w, h, 0xffffffff, ZPixmap);
+ is_mshm = 0;
+ }
+ XSetErrorHandler((XErrorHandler) prev_erh);
+ }
}
if ((is_shm) || (is_mshm))
{
- XSync(d, False);
- if (grab)
- XUngrabServer(d);
- XSync(d, False);
+ XSync(d, False);
+ if (grab)
+ XUngrabServer(d);
+ XSync(d, False);
}
else if (grab)
XUngrabServer(d);
-
+
if ((xatt.depth == 1) && (!cm) && (is_pixmap))
{
- rtab[0] = 0;
- gtab[0] = 0;
- btab[0] = 0;
- rtab[1] = 255;
- gtab[1] = 255;
- btab[1] = 255;
+ rtab[0] = 0;
+ gtab[0] = 0;
+ btab[0] = 0;
+ rtab[1] = 255;
+ gtab[1] = 255;
+ btab[1] = 255;
}
else if (xatt.depth <= 8)
{
- if ((!is_pixmap) && (!cm))
- {
- cm = xatt.colormap;
- if (cm == None)
- cm = ratt.colormap;
- }
- else
- cm = ratt.colormap;
-
- for (i = 0; i < (1 << xatt.depth); i++)
- {
- cols[i].pixel = i;
- cols[i].flags = DoRed | DoGreen | DoBlue;
- }
- XQueryColors(d, cm, cols, 1 << xatt.depth);
- for (i = 0; i < (1 << xatt.depth); i++)
- {
- rtab[i] = cols[i].red >> 8;
- gtab[i] = cols[i].green >> 8;
- btab[i] = cols[i].blue >> 8;
- }
+ if ((!is_pixmap) && (!cm))
+ {
+ cm = xatt.colormap;
+ if (cm == None)
+ cm = ratt.colormap;
+ }
+ else
+ cm = ratt.colormap;
+
+ for (i = 0; i < (1 << xatt.depth); i++)
+ {
+ cols[i].pixel = i;
+ cols[i].flags = DoRed | DoGreen | DoBlue;
+ }
+ XQueryColors(d, cm, cols, 1 << xatt.depth);
+ for (i = 0; i < (1 << xatt.depth); i++)
+ {
+ rtab[i] = cols[i].red >> 8;
+ gtab[i] = cols[i].green >> 8;
+ btab[i] = cols[i].blue >> 8;
+ }
}
__imlib_GrabXImageToRGBA(data, ox, oy, ow, oh,
- d, xim, mxim, v,
- depth, x, y,
- w, h, 0);
+ d, xim, mxim, v, depth, x, y, w, h, 0);
/* destroy the Ximage */
if (is_shm)
{
- XSync(d, False);
- XShmDetach(d, &shminfo);
- shmdt(shminfo.shmaddr);
- shmctl(shminfo.shmid, IPC_RMID, 0);
+ XSync(d, False);
+ XShmDetach(d, &shminfo);
+ shmdt(shminfo.shmaddr);
+ shmctl(shminfo.shmid, IPC_RMID, 0);
}
if ((is_mshm) && (mxim))
{
- XShmDetach(d, &mshminfo);
- shmdt(mshminfo.shmaddr);
- shmctl(mshminfo.shmid, IPC_RMID, 0);
+ XShmDetach(d, &mshminfo);
+ shmdt(mshminfo.shmaddr);
+ shmctl(mshminfo.shmid, IPC_RMID, 0);
}
XDestroyImage(xim);
if (created_mask)
diff --git a/src/grad.c b/src/grad.c
index 188ef4f..9f53d10 100644
--- a/src/grad.c
+++ b/src/grad.c
@@ -8,42 +8,42 @@
#include "grad.h"
#include "color_helpers.h"
-ImlibRange *
+ImlibRange *
__imlib_CreateRange(void)
{
- ImlibRange *rg = NULL;
-
+ ImlibRange *rg = NULL;
+
rg = malloc(sizeof(ImlibRange));
rg->color = NULL;
return rg;
}
void
-__imlib_FreeRange(ImlibRange *rg)
+__imlib_FreeRange(ImlibRange * rg)
{
- ImlibRangeColor *p, *pp;
-
+ ImlibRangeColor *p, *pp;
+
p = rg->color;
- while(p)
+ while (p)
{
pp = p;
- p = p->next;
- free(pp);
+ p = p->next;
+ free(pp);
}
free(rg);
}
void
-__imlib_AddRangeColor(ImlibRange *rg, DATA8 r, DATA8 g, DATA8 b, DATA8 a,
- int dist)
+__imlib_AddRangeColor(ImlibRange * rg, DATA8 r, DATA8 g, DATA8 b, DATA8 a,
+ int dist)
{
- ImlibRangeColor *p, *rc;
+ ImlibRangeColor *p, *rc;
if (dist < 1)
dist = 1;
if (!rg->color)
dist = 0;
-
+
rc = malloc(sizeof(ImlibRangeColor));
rc->red = r;
rc->green = g;
@@ -51,33 +51,33 @@ __imlib_AddRangeColor(ImlibRange *rg, DATA8 r, DATA8 g, DATA8 b, DATA8 a,
rc->alpha = a;
rc->distance = 0;
rc->next = NULL;
-
+
p = rg->color;
if (p)
{
- while (p)
- {
- if (!p->next)
- {
- p->distance = dist;
- p->next = rc;
- p = NULL;
- }
- else
- p = p->next;
- }
+ while (p)
+ {
+ if (!p->next)
+ {
+ p->distance = dist;
+ p->next = rc;
+ p = NULL;
+ }
+ else
+ p = p->next;
+ }
}
else
rg->color = rc;
}
-DATA32 *
-__imlib_MapRange(ImlibRange *rg, int len)
+DATA32 *
+__imlib_MapRange(ImlibRange * rg, int len)
{
- ImlibRangeColor *p;
- DATA32 *map, *pmap, v, vv;
- int r, g, b, a, rr, gg, bb, aa, i, l, ll, v1, v2, inc, j;
-
+ ImlibRangeColor *p;
+ DATA32 *map, *pmap, v, vv;
+ int r, g, b, a, rr, gg, bb, aa, i, l, ll, v1, v2, inc, j;
+
if (!rg->color)
return NULL;
if (!rg->color->next)
@@ -85,161 +85,166 @@ __imlib_MapRange(ImlibRange *rg, int len)
ll = 1;
for (p = rg->color; p; p = p->next)
ll += p->distance;
- map = malloc(len * sizeof(DATA32));
- pmap = malloc(ll * sizeof(DATA32));
+ map = malloc(len * sizeof(DATA32));
+ pmap = malloc(ll * sizeof(DATA32));
i = 0;
for (p = rg->color; p; p = p->next)
{
- if (p->next)
- {
- for (j = 0; j < p->distance; j++)
- {
- v1 = (j << 16) / p->distance;
- v2 = 65536 - v1;
- r = ((p->red * v2) + (p->next->red * v1)) >> 16;
- g = ((p->green * v2) + (p->next->green * v1)) >> 16;
- b = ((p->blue * v2) + (p->next->blue * v1)) >> 16;
- a = ((p->alpha * v2) + (p->next->alpha * v1)) >> 16;
- pmap[i++] = (a << 24) | (r << 16) | (g << 8) | b;
- }
- }
- else
- {
- r = p->red;
- g = p->green;
- b = p->blue;
- a = p->alpha;
- pmap[i++] = (a << 24) | (r << 16) | (g << 8) | b;
- }
+ if (p->next)
+ {
+ for (j = 0; j < p->distance; j++)
+ {
+ v1 = (j << 16) / p->distance;
+ v2 = 65536 - v1;
+ r = ((p->red * v2) + (p->next->red * v1)) >> 16;
+ g = ((p->green * v2) + (p->next->green * v1)) >> 16;
+ b = ((p->blue * v2) + (p->next->blue * v1)) >> 16;
+ a = ((p->alpha * v2) + (p->next->alpha * v1)) >> 16;
+ pmap[i++] = (a << 24) | (r << 16) | (g << 8) | b;
+ }
+ }
+ else
+ {
+ r = p->red;
+ g = p->green;
+ b = p->blue;
+ a = p->alpha;
+ pmap[i++] = (a << 24) | (r << 16) | (g << 8) | b;
+ }
}
inc = ((ll - 1) << 16) / (len);
l = 0;
for (i = 0; i < len; i++)
{
- v = pmap[l >> 16];
- if ((l >> 16) < ll)
- vv = pmap[(l >> 16) + 1];
- else
- vv = pmap[(l >> 16)];
- v1 = l - ((l >> 16) << 16);
- v2 = 65536 - v1;
- b = ((v) ) & 0xff;
- g = ((v) >> 8 ) & 0xff;
- r = ((v) >> 16) & 0xff;
- a = ((v) >> 24) & 0xff;
- bb = ((vv) ) & 0xff;
- gg = ((vv) >> 8 ) & 0xff;
- rr = ((vv) >> 16) & 0xff;
- aa = ((vv) >> 24) & 0xff;
- r = ((r * v2) + (rr * v1)) >> 16;
- g = ((g * v2) + (gg * v1)) >> 16;
- b = ((b * v2) + (bb * v1)) >> 16;
- a = ((a * v2) + (aa * v1)) >> 16;
- map[i] = (a << 24) | (r << 16) | (g << 8) | b;
- l += inc;
+ v = pmap[l >> 16];
+ if ((l >> 16) < ll)
+ vv = pmap[(l >> 16) + 1];
+ else
+ vv = pmap[(l >> 16)];
+ v1 = l - ((l >> 16) << 16);
+ v2 = 65536 - v1;
+ b = ((v)) & 0xff;
+ g = ((v) >> 8) & 0xff;
+ r = ((v) >> 16) & 0xff;
+ a = ((v) >> 24) & 0xff;
+ bb = ((vv)) & 0xff;
+ gg = ((vv) >> 8) & 0xff;
+ rr = ((vv) >> 16) & 0xff;
+ aa = ((vv) >> 24) & 0xff;
+ r = ((r * v2) + (rr * v1)) >> 16;
+ g = ((g * v2) + (gg * v1)) >> 16;
+ b = ((b * v2) + (bb * v1)) >> 16;
+ a = ((a * v2) + (aa * v1)) >> 16;
+ map[i] = (a << 24) | (r << 16) | (g << 8) | b;
+ l += inc;
}
free(pmap);
return map;
}
-DATA32 *
-__imlib_MapHsvaRange(ImlibRange *rg, int len)
+DATA32 *
+__imlib_MapHsvaRange(ImlibRange * rg, int len)
{
- ImlibRangeColor *p;
- DATA32 *map, *pmap, k, kk;
- int r, g, b, a, rr, gg, bb, aa, i, l, ll, inc, j;
- float h1, s1, v1, h2, s2, v2, h, s, v, k1, k2;
-
- if (!rg->color)
- return NULL;
- if (!rg->color->next)
- return NULL;
- ll = 1;
- for (p = rg->color; p; p = p->next)
- ll += p->distance;
- map = malloc(len * sizeof(DATA32));
- pmap = malloc(ll * sizeof(DATA32));
- i = 0;
- for (p = rg->color; p; p = p->next)
- {
- if (p->next)
- {
- for (j = 0; j < p->distance; j++)
- {
- k1 = (j << 16) / (float)p->distance;
- k2 = 65536 - k1;
- r = p->red; rr = p->next->red;
- g = p->green; gg = p->next->green;
- b = p->blue; bb = p->next->blue;
- __imlib_rgb_to_hsv(r, g, b, &h1, &s1, &v1);
- __imlib_rgb_to_hsv(rr, gg, bb, &h2, &s2, &v2);
- h = ((h1 * k2) + (h2 * k1)) / 65536.0;
- s = ((s1 * k2) + (s2 * k1)) / 65536.0;
- v = ((v1 * k2) + (v2 * k1)) / 65536.0;
- __imlib_hsv_to_rgb(h, s, v, &r, &g, &b);
- a = (unsigned long int)((p->alpha * k2) + (p->next->alpha * k1)) >> 16;
- pmap[i++] = (a << 24) | (r << 16) | (g << 8) | b;
- }
- }
- else
- {
- r = p->red;
- g = p->green;
- b = p->blue;
- a = p->alpha;
- pmap[i++] = (a << 24) | (r << 16) | (g << 8) | b;
- }
- }
- inc = ((ll - 1) << 16) / (len);
- l = 0;
- for (i = 0; i < len; i++)
- {
- k = pmap[l >> 16];
- if ((l >> 16) < ll)
- kk = pmap[(l >> 16) + 1];
- else
- kk = pmap[(l >> 16)];
- k1 = l - (float)((l >> 16) << 16);
- k2 = 65536 - k1;
- b = ((k) ) & 0xff;
- g = ((k) >> 8 ) & 0xff;
- r = ((k) >> 16) & 0xff;
- a = ((k) >> 24) & 0xff;
- bb = ((kk) ) & 0xff;
- gg = ((kk) >> 8 ) & 0xff;
- rr = ((kk) >> 16) & 0xff;
- aa = ((kk) >> 24) & 0xff;
- __imlib_rgb_to_hsv(r, g, b, &h1, &s1, &v1);
- __imlib_rgb_to_hsv(rr, gg, bb, &h2, &s2, &v2);
- h = ((h1 * k2) + (h2 * k1)) / 65536.0;
- s = ((s1 * k2) + (s2 * k1)) / 65536.0;
- v = ((v1 * k2) + (v2 * k1)) / 65536.0;
- __imlib_hsv_to_rgb(h, s, v, &r, &g, &b);
- a = (unsigned long int)((a * k2) + (aa * k1)) >> 16;
- map[i] = (a << 24) | (r << 16) | (g << 8) | b;
- l += inc;
- }
- free(pmap);
- return map;
+ ImlibRangeColor *p;
+ DATA32 *map, *pmap, k, kk;
+ int r, g, b, a, rr, gg, bb, aa, i, l, ll, inc, j;
+ float h1, s1, v1, h2, s2, v2, h, s, v, k1, k2;
+
+ if (!rg->color)
+ return NULL;
+ if (!rg->color->next)
+ return NULL;
+ ll = 1;
+ for (p = rg->color; p; p = p->next)
+ ll += p->distance;
+ map = malloc(len * sizeof(DATA32));
+ pmap = malloc(ll * sizeof(DATA32));
+ i = 0;
+ for (p = rg->color; p; p = p->next)
+ {
+ if (p->next)
+ {
+ for (j = 0; j < p->distance; j++)
+ {
+ k1 = (j << 16) / (float)p->distance;
+ k2 = 65536 - k1;
+ r = p->red;
+ rr = p->next->red;
+ g = p->green;
+ gg = p->next->green;
+ b = p->blue;
+ bb = p->next->blue;
+ __imlib_rgb_to_hsv(r, g, b, &h1, &s1, &v1);
+ __imlib_rgb_to_hsv(rr, gg, bb, &h2, &s2, &v2);
+ h = ((h1 * k2) + (h2 * k1)) / 65536.0;
+ s = ((s1 * k2) + (s2 * k1)) / 65536.0;
+ v = ((v1 * k2) + (v2 * k1)) / 65536.0;
+ __imlib_hsv_to_rgb(h, s, v, &r, &g, &b);
+ a = (unsigned long int)((p->alpha * k2) +
+ (p->next->alpha * k1)) >> 16;
+ pmap[i++] = (a << 24) | (r << 16) | (g << 8) | b;
+ }
+ }
+ else
+ {
+ r = p->red;
+ g = p->green;
+ b = p->blue;
+ a = p->alpha;
+ pmap[i++] = (a << 24) | (r << 16) | (g << 8) | b;
+ }
+ }
+ inc = ((ll - 1) << 16) / (len);
+ l = 0;
+ for (i = 0; i < len; i++)
+ {
+ k = pmap[l >> 16];
+ if ((l >> 16) < ll)
+ kk = pmap[(l >> 16) + 1];
+ else
+ kk = pmap[(l >> 16)];
+ k1 = l - (float)((l >> 16) << 16);
+ k2 = 65536 - k1;
+ b = ((k)) & 0xff;
+ g = ((k) >> 8) & 0xff;
+ r = ((k) >> 16) & 0xff;
+ a = ((k) >> 24) & 0xff;
+ bb = ((kk)) & 0xff;
+ gg = ((kk) >> 8) & 0xff;
+ rr = ((kk) >> 16) & 0xff;
+ aa = ((kk) >> 24) & 0xff;
+ __imlib_rgb_to_hsv(r, g, b, &h1, &s1, &v1);
+ __imlib_rgb_to_hsv(rr, gg, bb, &h2, &s2, &v2);
+ h = ((h1 * k2) + (h2 * k1)) / 65536.0;
+ s = ((s1 * k2) + (s2 * k1)) / 65536.0;
+ v = ((v1 * k2) + (v2 * k1)) / 65536.0;
+ __imlib_hsv_to_rgb(h, s, v, &r, &g, &b);
+ a = (unsigned long int)((a * k2) + (aa * k1)) >> 16;
+ map[i] = (a << 24) | (r << 16) | (g << 8) | b;
+ l += inc;
+ }
+ free(pmap);
+ return map;
}
void
-__imlib_DrawGradient(ImlibImage *im, int x, int y, int w, int h,
- ImlibRange *rg, double angle, ImlibOp op,
- int clx, int cly, int clw, int clh)
+__imlib_DrawGradient(ImlibImage * im, int x, int y, int w, int h,
+ ImlibRange * rg, double angle, ImlibOp op,
+ int clx, int cly, int clw, int clh)
{
- DATA32 *map, *p, v;
- int *hlut, *vlut, len = 0, xx, yy, xoff = 0, yoff = 0, ww, hh, jump;
- int tmp, i, divw, divh;
- DATA8 rr, gg, bb, aa, r, g, b, a, nr, ng, nb, na;
-
+ DATA32 *map, *p, v;
+ int *hlut, *vlut, len = 0, xx, yy, xoff = 0, yoff =
+ 0, ww, hh, jump;
+ int tmp, i, divw, divh;
+ DATA8 rr, gg, bb, aa, r, g, b, a, nr, ng, nb, na;
+
ww = w;
hh = h;
if (x < 0)
{
- w += x;
- xoff = -x;
- x = 0;
+ w += x;
+ xoff = -x;
+ x = 0;
}
if (w <= 0)
return;
@@ -249,9 +254,9 @@ __imlib_DrawGradient(ImlibImage *im, int x, int y, int w, int h,
return;
if (y < 0)
{
- h += y;
- yoff = -y;
- y = 0;
+ h += y;
+ yoff = -y;
+ y = 0;
}
if (h <= 0)
return;
@@ -261,17 +266,18 @@ __imlib_DrawGradient(ImlibImage *im, int x, int y, int w, int h,
return;
if (clw)
{
- int px, py;
-
- CLIP_TO(clx, cly, clw, clh, 0, 0, im->w, im->h);
- px = x;
- py = y;
- CLIP_TO(x, y, w, h, clx, cly, clw, clh);
- if ((w < 1) || (h < 1)) return;
- xoff += (x - px);
- yoff += (y - py);
+ int px, py;
+
+ CLIP_TO(clx, cly, clw, clh, 0, 0, im->w, im->h);
+ px = x;
+ py = y;
+ CLIP_TO(x, y, w, h, clx, cly, clw, clh);
+ if ((w < 1) || (h < 1))
+ return;
+ xoff += (x - px);
+ yoff += (y - py);
}
-
+
hlut = malloc(sizeof(int) * ww);
vlut = malloc(sizeof(int) * hh);
if (ww > hh)
@@ -279,155 +285,159 @@ __imlib_DrawGradient(ImlibImage *im, int x, int y, int w, int h,
else
len = hh * 16;
map = __imlib_MapRange(rg, len);
- if (!map) return;
-
+ if (!map)
+ return;
+
xx = (int)(32 * sin(((angle + 180) * 2 * 3.141592654) / 360));
yy = -(int)(32 * cos(((angle + 180) * 2 * 3.141592654) / 360));
divw = ((ww - 1) << 5);
divh = ((hh - 1) << 5);
- if (divw < 1) divw = 1;
- if (divh < 1) divh = 1;
+ if (divw < 1)
+ divw = 1;
+ if (divh < 1)
+ divh = 1;
if (xx < 0)
{
- for (i = 0; i < ww; i++)
- hlut[i] = (-xx * (ww - 1 - i) * len) / divw;
+ for (i = 0; i < ww; i++)
+ hlut[i] = (-xx * (ww - 1 - i) * len) / divw;
}
else
{
- for (i = 0; i < ww; i++)
- hlut[i] = (xx * i * len) / divw;
+ for (i = 0; i < ww; i++)
+ hlut[i] = (xx * i * len) / divw;
}
if (yy < 0)
{
- for (i = 0; i < hh; i++)
- vlut[i] = (-yy * (hh - 1 - i) * len) / divh;
+ for (i = 0; i < hh; i++)
+ vlut[i] = (-yy * (hh - 1 - i) * len) / divh;
}
else
{
- for (i = 0; i < hh; i++)
- vlut[i] = (yy * i * len) / divh;
+ for (i = 0; i < hh; i++)
+ vlut[i] = (yy * i * len) / divh;
}
jump = im->w - w;
-
+
p = im->data + (y * im->w) + x;
switch (op)
{
- case OP_COPY:
- if (IMAGE_HAS_ALPHA(im))
- {
- __imlib_build_pow_lut();
- for (yy = 0; yy < h; yy++)
- {
- for (xx = 0; xx < w; xx++)
- {
- i = vlut[yoff + yy] + hlut[xoff + xx];
- if (i < 0)
- i = 0;
- else if (i >= len)
- i = len - 1;
- READ_RGBA(&(map[i]), r, g, b, a);
- BLEND_DST_ALPHA(r, g, b, a, p);
- p++;
- }
- p += jump;
- }
- }
- else
- {
- for (yy = 0; yy < h; yy++)
- {
- for (xx = 0; xx < w; xx++)
- {
- i = vlut[yoff + yy] + hlut[xoff + xx];
- if (i < 0)
- i = 0;
- else if (i >= len)
- i = len - 1;
- READ_RGBA(&(map[i]), r, g, b, a);
- BLEND(r, g, b, a, p);
- p++;
- }
- p += jump;
- }
- }
- break;
- case OP_ADD:
- for (yy = 0; yy < h; yy++)
- {
- for (xx = 0; xx < w; xx++)
- {
- i = vlut[yoff + yy] + hlut[xoff + xx];
- if (i < 0)
- i = 0;
- else if (i >= len)
- i = len - 1;
- READ_RGBA(&(map[i]), r, g, b, a);
- BLEND_SUB(r, g, b, a, p);
- p++;
- }
- p += jump;
- }
- break;
- case OP_SUBTRACT:
- for (yy = 0; yy < h; yy++)
- {
- for (xx = 0; xx < w; xx++)
- {
- i = vlut[yoff + yy] + hlut[xoff + xx];
- if (i < 0)
- i = 0;
- else if (i >= len)
- i = len - 1;
- READ_RGBA(&(map[i]), r, g, b, a);
- BLEND_SUB(r, g, b, a, p);
- p++;
- }
- p += jump;
- }
- break;
- case OP_RESHADE:
- for (yy = 0; yy < h; yy++)
- {
- for (xx = 0; xx < w; xx++)
- {
- i = vlut[yoff + yy] + hlut[xoff + xx];
- if (i < 0)
- i = 0;
- else if (i >= len)
- i = len - 1;
- READ_RGBA(&(map[i]), r, g, b, a);
- BLEND_RE(r, g, b, a, p);
- p++;
- }
- p += jump;
- }
- break;
- default:
- break;
+ case OP_COPY:
+ if (IMAGE_HAS_ALPHA(im))
+ {
+ __imlib_build_pow_lut();
+ for (yy = 0; yy < h; yy++)
+ {
+ for (xx = 0; xx < w; xx++)
+ {
+ i = vlut[yoff + yy] + hlut[xoff + xx];
+ if (i < 0)
+ i = 0;
+ else if (i >= len)
+ i = len - 1;
+ READ_RGBA(&(map[i]), r, g, b, a);
+ BLEND_DST_ALPHA(r, g, b, a, p);
+ p++;
+ }
+ p += jump;
+ }
+ }
+ else
+ {
+ for (yy = 0; yy < h; yy++)
+ {
+ for (xx = 0; xx < w; xx++)
+ {
+ i = vlut[yoff + yy] + hlut[xoff + xx];
+ if (i < 0)
+ i = 0;
+ else if (i >= len)
+ i = len - 1;
+ READ_RGBA(&(map[i]), r, g, b, a);
+ BLEND(r, g, b, a, p);
+ p++;
+ }
+ p += jump;
+ }
+ }
+ break;
+ case OP_ADD:
+ for (yy = 0; yy < h; yy++)
+ {
+ for (xx = 0; xx < w; xx++)
+ {
+ i = vlut[yoff + yy] + hlut[xoff + xx];
+ if (i < 0)
+ i = 0;
+ else if (i >= len)
+ i = len - 1;
+ READ_RGBA(&(map[i]), r, g, b, a);
+ BLEND_SUB(r, g, b, a, p);
+ p++;
+ }
+ p += jump;
+ }
+ break;
+ case OP_SUBTRACT:
+ for (yy = 0; yy < h; yy++)
+ {
+ for (xx = 0; xx < w; xx++)
+ {
+ i = vlut[yoff + yy] + hlut[xoff + xx];
+ if (i < 0)
+ i = 0;
+ else if (i >= len)
+ i = len - 1;
+ READ_RGBA(&(map[i]), r, g, b, a);
+ BLEND_SUB(r, g, b, a, p);
+ p++;
+ }
+ p += jump;
+ }
+ break;
+ case OP_RESHADE:
+ for (yy = 0; yy < h; yy++)
+ {
+ for (xx = 0; xx < w; xx++)
+ {
+ i = vlut[yoff + yy] + hlut[xoff + xx];
+ if (i < 0)
+ i = 0;
+ else if (i >= len)
+ i = len - 1;
+ READ_RGBA(&(map[i]), r, g, b, a);
+ BLEND_RE(r, g, b, a, p);
+ p++;
+ }
+ p += jump;
+ }
+ break;
+ default:
+ break;
}
-
+
free(vlut);
free(hlut);
free(map);
}
void
-__imlib_DrawHsvaGradient(ImlibImage *im, int x, int y, int w, int h,
- ImlibRange *rg, double angle, ImlibOp op,
- int clx, int cly, int clw, int clh)
+__imlib_DrawHsvaGradient(ImlibImage * im, int x, int y, int w, int h,
+ ImlibRange * rg, double angle, ImlibOp op,
+ int clx, int cly, int clw, int clh)
{
- DATA32 *map, *p, v;
- int *hlut, *vlut, len = 0, xx, yy, xoff = 0, yoff = 0, ww, hh, jump;
- int tmp, i, divw, divh;
- DATA8 rr, gg, bb, aa, r, g, b, a, nr, ng, nb, na;
-
+ DATA32 *map, *p, v;
+ int *hlut, *vlut, len = 0, xx, yy, xoff = 0, yoff =
+ 0, ww, hh, jump;
+ int tmp, i, divw, divh;
+ DATA8 rr, gg, bb, aa, r, g, b, a, nr, ng, nb, na;
+
ww = w;
hh = h;
if (x < 0)
{
- w += x;
- xoff = -x;
- x = 0;
+ w += x;
+ xoff = -x;
+ x = 0;
}
if (w <= 0)
return;
@@ -437,9 +447,9 @@ __imlib_DrawHsvaGradient(ImlibImage *im, int x, int y, int w, int h,
return;
if (y < 0)
{
- h += y;
- yoff = -y;
- y = 0;
+ h += y;
+ yoff = -y;
+ y = 0;
}
if (h <= 0)
return;
@@ -449,17 +459,18 @@ __imlib_DrawHsvaGradient(ImlibImage *im, int x, int y, int w, int h,
return;
if (clw)
{
- int px, py;
-
- CLIP_TO(clx, cly, clw, clh, 0, 0, im->w, im->h);
- px = x;
- py = y;
- CLIP_TO(x, y, w, h, clx, cly, clw, clh);
- if ((w < 1) || (h < 1)) return;
- xoff += (x - px);
- yoff += (y - py);
+ int px, py;
+
+ CLIP_TO(clx, cly, clw, clh, 0, 0, im->w, im->h);
+ px = x;
+ py = y;
+ CLIP_TO(x, y, w, h, clx, cly, clw, clh);
+ if ((w < 1) || (h < 1))
+ return;
+ xoff += (x - px);
+ yoff += (y - py);
}
-
+
hlut = malloc(sizeof(int) * ww);
vlut = malloc(sizeof(int) * hh);
if (ww > hh)
@@ -467,135 +478,137 @@ __imlib_DrawHsvaGradient(ImlibImage *im, int x, int y, int w, int h,
else
len = hh * 16;
map = __imlib_MapHsvaRange(rg, len);
- if (!map) return;
-
+ if (!map)
+ return;
+
xx = (int)(32 * sin(((angle + 180) * 2 * 3.141592654) / 360));
yy = -(int)(32 * cos(((angle + 180) * 2 * 3.141592654) / 360));
divw = ((ww - 1) << 5);
divh = ((hh - 1) << 5);
- if (divw < 1) divw = 1;
- if (divh < 1) divh = 1;
+ if (divw < 1)
+ divw = 1;
+ if (divh < 1)
+ divh = 1;
if (xx < 0)
{
- for (i = 0; i < ww; i++)
- hlut[i] = (-xx * (ww - 1 - i) * len) / divw;
+ for (i = 0; i < ww; i++)
+ hlut[i] = (-xx * (ww - 1 - i) * len) / divw;
}
else
{
- for (i = 0; i < ww; i++)
- hlut[i] = (xx * i * len) / divw;
+ for (i = 0; i < ww; i++)
+ hlut[i] = (xx * i * len) / divw;
}
if (yy < 0)
{
- for (i = 0; i < hh; i++)
- vlut[i] = (-yy * (hh - 1 - i) * len) / divh;
+ for (i = 0; i < hh; i++)
+ vlut[i] = (-yy * (hh - 1 - i) * len) / divh;
}
else
{
- for (i = 0; i < hh; i++)
- vlut[i] = (yy * i * len) / divh;
+ for (i = 0; i < hh; i++)
+ vlut[i] = (yy * i * len) / divh;
}
jump = im->w - w;
-
+
p = im->data + (y * im->w) + x;
switch (op)
{
- case OP_COPY:
- if (IMAGE_HAS_ALPHA(im))
- {
- __imlib_build_pow_lut();
- for (yy = 0; yy < h; yy++)
- {
- for (xx = 0; xx < w; xx++)
- {
- i = vlut[yoff + yy] + hlut[xoff + xx];
- if (i < 0)
- i = 0;
- else if (i >= len)
- i = len - 1;
- READ_RGBA(&(map[i]), r, g, b, a);
- BLEND_DST_ALPHA(r, g, b, a, p);
- p++;
- }
- p += jump;
- }
- }
- else
- {
- for (yy = 0; yy < h; yy++)
- {
- for (xx = 0; xx < w; xx++)
- {
- i = vlut[yoff + yy] + hlut[xoff + xx];
- if (i < 0)
- i = 0;
- else if (i >= len)
- i = len - 1;
- READ_RGBA(&(map[i]), r, g, b, a);
- BLEND(r, g, b, a, p);
- p++;
- }
- p += jump;
- }
- }
- break;
- case OP_ADD:
- for (yy = 0; yy < h; yy++)
- {
- for (xx = 0; xx < w; xx++)
- {
- i = vlut[yoff + yy] + hlut[xoff + xx];
- if (i < 0)
- i = 0;
- else if (i >= len)
- i = len - 1;
- READ_RGBA(&(map[i]), r, g, b, a);
- BLEND_SUB(r, g, b, a, p);
- p++;
- }
- p += jump;
- }
- break;
- case OP_SUBTRACT:
- for (yy = 0; yy < h; yy++)
- {
- for (xx = 0; xx < w; xx++)
- {
- i = vlut[yoff + yy] + hlut[xoff + xx];
- if (i < 0)
- i = 0;
- else if (i >= len)
- i = len - 1;
- READ_RGBA(&(map[i]), r, g, b, a);
- BLEND_SUB(r, g, b, a, p);
- p++;
- }
- p += jump;
- }
- break;
- case OP_RESHADE:
- for (yy = 0; yy < h; yy++)
- {
- for (xx = 0; xx < w; xx++)
- {
- i = vlut[yoff + yy] + hlut[xoff + xx];
- if (i < 0)
- i = 0;
- else if (i >= len)
- i = len - 1;
- READ_RGBA(&(map[i]), r, g, b, a);
- BLEND_RE(r, g, b, a, p);
- p++;
- }
- p += jump;
- }
- break;
- default:
- break;
+ case OP_COPY:
+ if (IMAGE_HAS_ALPHA(im))
+ {
+ __imlib_build_pow_lut();
+ for (yy = 0; yy < h; yy++)
+ {
+ for (xx = 0; xx < w; xx++)
+ {
+ i = vlut[yoff + yy] + hlut[xoff + xx];
+ if (i < 0)
+ i = 0;
+ else if (i >= len)
+ i = len - 1;
+ READ_RGBA(&(map[i]), r, g, b, a);
+ BLEND_DST_ALPHA(r, g, b, a, p);
+ p++;
+ }
+ p += jump;
+ }
+ }
+ else
+ {
+ for (yy = 0; yy < h; yy++)
+ {
+ for (xx = 0; xx < w; xx++)
+ {
+ i = vlut[yoff + yy] + hlut[xoff + xx];
+ if (i < 0)
+ i = 0;
+ else if (i >= len)
+ i = len - 1;
+ READ_RGBA(&(map[i]), r, g, b, a);
+ BLEND(r, g, b, a, p);
+ p++;
+ }
+ p += jump;
+ }
+ }
+ break;
+ case OP_ADD:
+ for (yy = 0; yy < h; yy++)
+ {
+ for (xx = 0; xx < w; xx++)
+ {
+ i = vlut[yoff + yy] + hlut[xoff + xx];
+ if (i < 0)
+ i = 0;
+ else if (i >= len)
+ i = len - 1;
+ READ_RGBA(&(map[i]), r, g, b, a);
+ BLEND_SUB(r, g, b, a, p);
+ p++;
+ }
+ p += jump;
+ }
+ break;
+ case OP_SUBTRACT:
+ for (yy = 0; yy < h; yy++)
+ {
+ for (xx = 0; xx < w; xx++)
+ {
+ i = vlut[yoff + yy] + hlut[xoff + xx];
+ if (i < 0)
+ i = 0;
+ else if (i >= len)
+ i = len - 1;
+ READ_RGBA(&(map[i]), r, g, b, a);
+ BLEND_SUB(r, g, b, a, p);
+ p++;
+ }
+ p += jump;
+ }
+ break;
+ case OP_RESHADE:
+ for (yy = 0; yy < h; yy++)
+ {
+ for (xx = 0; xx < w; xx++)
+ {
+ i = vlut[yoff + yy] + hlut[xoff + xx];
+ if (i < 0)
+ i = 0;
+ else if (i >= len)
+ i = len - 1;
+ READ_RGBA(&(map[i]), r, g, b, a);
+ BLEND_RE(r, g, b, a, p);
+ p++;
+ }
+ p += jump;
+ }
+ break;
+ default:
+ break;
}
-
+
free(vlut);
free(hlut);
free(map);
}
-
diff --git a/src/image.c b/src/image.c
index e27bbd6..cf533bb 100644
--- a/src/image.c
+++ b/src/image.c
@@ -13,12 +13,13 @@
#include "file.h"
#include "loaderpath.h"
-static ImlibImage *images = NULL;
+static ImlibImage *images = NULL;
+
#ifndef X_DISPLAY_MISSING
static ImlibImagePixmap *pixmaps = NULL;
#endif
static ImlibLoader *loaders = NULL;
-static int cache_size = 4096 * 1024;
+static int cache_size = 4096 * 1024;
/* attach a string key'd data and/or int value to an image that cna be */
/* looked up later by its string key */
@@ -26,7 +27,7 @@ void
__imlib_AttachTag(ImlibImage * im, const char *key, int val, void *data,
ImlibDataDestructorFunction destructor)
{
- ImlibImageTag *t;
+ ImlibImageTag *t;
/* no string key? abort */
if (!key)
@@ -48,44 +49,44 @@ __imlib_AttachTag(ImlibImage * im, const char *key, int val, void *data,
}
/* look up a tage by its key on the image it was attached to */
-ImlibImageTag *
+ImlibImageTag *
__imlib_GetTag(ImlibImage * im, const char *key)
{
- ImlibImageTag *t;
+ ImlibImageTag *t;
t = im->tags;
while (t)
- {
- if (!strcmp(t->key, key))
- return t;
- t = t->next;
- }
+ {
+ if (!strcmp(t->key, key))
+ return t;
+ t = t->next;
+ }
/* no tag found - return NULL */
return NULL;
}
/* remove a tag by looking it up by its key and removing it from */
/* the list of keys */
-ImlibImageTag *
+ImlibImageTag *
__imlib_RemoveTag(ImlibImage * im, const char *key)
{
- ImlibImageTag *t, *tt;
+ ImlibImageTag *t, *tt;
tt = NULL;
t = im->tags;
while (t)
- {
- if (!strcmp(t->key, key))
- {
- if (tt)
- tt->next = t->next;
- else
- im->tags = t->next;
- return t;
- }
- tt = t;
- t = t->next;
- }
+ {
+ if (!strcmp(t->key, key))
+ {
+ if (tt)
+ tt->next = t->next;
+ else
+ im->tags = t->next;
+ return t;
+ }
+ tt = t;
+ t = t->next;
+ }
/* no tag found - NULL */
return NULL;
}
@@ -105,15 +106,15 @@ __imlib_FreeTag(ImlibImage * im, ImlibImageTag * t)
void
__imlib_FreeAllTags(ImlibImage * im)
{
- ImlibImageTag *t, *tt;
+ ImlibImageTag *t, *tt;
t = im->tags;
while (t)
- {
- tt = t;
- t = t->next;
- __imlib_FreeTag(im, tt);
- }
+ {
+ tt = t;
+ t = t->next;
+ __imlib_FreeTag(im, tt);
+ }
}
/* set the cache size */
@@ -135,10 +136,10 @@ __imlib_GetCacheSize(void)
}
/* create an image data struct and fill it in */
-ImlibImage *
+ImlibImage *
__imlib_ProduceImage(void)
{
- ImlibImage *im;
+ ImlibImage *im;
im = malloc(sizeof(ImlibImage));
memset(im, 0, sizeof(ImlibImage));
@@ -158,9 +159,9 @@ void
__imlib_ConsumeImage(ImlibImage * im)
{
#ifndef X_DISPLAY_MISSING
-ImlibImagePixmap *ip;
+ ImlibImagePixmap *ip;
#endif
-
+
__imlib_FreeAllTags(im);
if (im->file)
free(im->file);
@@ -177,42 +178,42 @@ ImlibImagePixmap *ip;
ip = pixmaps;
while (ip)
{
- if (ip->image == im)
- {
- ip->image = NULL;
- ip->dirty = 1;
- }
- ip = ip->next;
+ if (ip->image == im)
+ {
+ ip->image = NULL;
+ ip->dirty = 1;
+ }
+ ip = ip->next;
}
#endif
}
-ImlibImage *
+ImlibImage *
__imlib_FindCachedImage(const char *file)
{
- ImlibImage *im, *previous_im;
+ ImlibImage *im, *previous_im;
im = images;
previous_im = NULL;
/* go through the images list */
while (im)
- {
- /* if the filenames match and it's valid */
- if ((!strcmp(file, im->file)) && (IMAGE_IS_VALID(im)))
- {
- /* move the image to the head of the pixmap list */
- if (previous_im)
- {
- previous_im->next = im->next;
- im->next = images;
- images = im;
- }
- /* return it */
- return im;
- }
- previous_im = im;
- im = im->next;
- }
+ {
+ /* if the filenames match and it's valid */
+ if ((!strcmp(file, im->file)) && (IMAGE_IS_VALID(im)))
+ {
+ /* move the image to the head of the pixmap list */
+ if (previous_im)
+ {
+ previous_im->next = im->next;
+ im->next = images;
+ images = im;
+ }
+ /* return it */
+ return im;
+ }
+ previous_im = im;
+ im = im->next;
+ }
return NULL;
}
@@ -228,23 +229,23 @@ __imlib_AddImageToCache(ImlibImage * im)
void
__imlib_RemoveImageFromCache(ImlibImage * im)
{
- ImlibImage *current_im, *previous_im;
+ ImlibImage *current_im, *previous_im;
current_im = images;
previous_im = NULL;
while (current_im)
- {
- if (im == current_im)
- {
- if (previous_im)
- previous_im->next = im->next;
- else
- images = im->next;
- return;
- }
- previous_im = current_im;
- current_im = current_im->next;
- }
+ {
+ if (im == current_im)
+ {
+ if (previous_im)
+ previous_im->next = im->next;
+ else
+ images = im->next;
+ return;
+ }
+ previous_im = current_im;
+ current_im = current_im->next;
+ }
}
/* work out how much we have floaitng aroudn in our speculative cache */
@@ -252,88 +253,88 @@ __imlib_RemoveImageFromCache(ImlibImage * im)
int
__imlib_CurrentCacheSize(void)
{
- ImlibImage *im;
+ ImlibImage *im;
+
#ifndef X_DISPLAY_MISSING
- ImlibImagePixmap *ip;
+ ImlibImagePixmap *ip;
#endif
- int current_cache = 0;
+ int current_cache = 0;
/* go through the image cache */
im = images;
while (im)
- {
- /* mayaswell clean out stuff thats invalid that we dont need anymore */
- if (im->references == 0)
- {
- if (!(IMAGE_IS_VALID(im)))
- {
- ImlibImage *tmp_im;
-
- tmp_im = im;
- im = im->next;
- __imlib_RemoveImageFromCache(tmp_im);
- __imlib_ConsumeImage(tmp_im);
+ {
+ /* mayaswell clean out stuff thats invalid that we dont need anymore */
+ if (im->references == 0)
+ {
+ if (!(IMAGE_IS_VALID(im)))
+ {
+ ImlibImage *tmp_im;
+
+ tmp_im = im;
+ im = im->next;
+ __imlib_RemoveImageFromCache(tmp_im);
+ __imlib_ConsumeImage(tmp_im);
#ifndef X_DISPLAY_MISSING
- ip = pixmaps;
- while (ip)
- {
- if (ip->image == tmp_im)
- {
- ip->image = NULL;
- ip->dirty = 1;
- }
- ip = ip->next;
- }
+ ip = pixmaps;
+ while (ip)
+ {
+ if (ip->image == tmp_im)
+ {
+ ip->image = NULL;
+ ip->dirty = 1;
+ }
+ ip = ip->next;
+ }
#endif
- continue;
- }
- /* it's valid but has 0 ref's - append to cache size count */
- else
- current_cache += im->w * im->h * sizeof(DATA32);
- }
- im = im->next;
- }
+ continue;
+ }
+ /* it's valid but has 0 ref's - append to cache size count */
+ else
+ current_cache += im->w * im->h * sizeof(DATA32);
+ }
+ im = im->next;
+ }
#ifndef X_DISPLAY_MISSING
/* go through the pixmaps */
ip = pixmaps;
while (ip)
- {
- /* if the pixmap has 0 references */
- if (ip->references == 0)
- {
- /* if the image is invalid */
- if ((ip->dirty) ||
- ((ip->image) && (!(IMAGE_IS_VALID(ip->image)))))
- {
- ImlibImagePixmap *tmp_ip;
-
- tmp_ip = ip;
- ip = ip->next;
- __imlib_RemoveImagePixmapFromCache(tmp_ip);
- __imlib_ConsumeImagePixmap(tmp_ip);
- continue;
- }
- else
- {
- /* add the pixmap data size to the cache size */
- if (ip->pixmap)
- {
- if (ip->depth < 8)
- current_cache += ip->w * ip->h * (ip->depth / 8);
- else if (ip->depth == 8)
- current_cache += ip->w * ip->h;
- else if (ip->depth <= 16)
- current_cache += ip->w * ip->h * 2;
- else if (ip->depth <= 32)
- current_cache += ip->w * ip->h * 4;
- }
- /* if theres a mask add it too */
- if (ip->mask)
- current_cache += ip->w * ip->h / 8;
- }
- }
- ip = ip->next;
- }
+ {
+ /* if the pixmap has 0 references */
+ if (ip->references == 0)
+ {
+ /* if the image is invalid */
+ if ((ip->dirty) || ((ip->image) && (!(IMAGE_IS_VALID(ip->image)))))
+ {
+ ImlibImagePixmap *tmp_ip;
+
+ tmp_ip = ip;
+ ip = ip->next;
+ __imlib_RemoveImagePixmapFromCache(tmp_ip);
+ __imlib_ConsumeImagePixmap(tmp_ip);
+ continue;
+ }
+ else
+ {
+ /* add the pixmap data size to the cache size */
+ if (ip->pixmap)
+ {
+ if (ip->depth < 8)
+ current_cache += ip->w * ip->h * (ip->depth / 8);
+ else if (ip->depth == 8)
+ current_cache += ip->w * ip->h;
+ else if (ip->depth <= 16)
+ current_cache += ip->w * ip->h * 2;
+ else if (ip->depth <= 32)
+ current_cache += ip->w * ip->h * 4;
+ }
+ /* if theres a mask add it too */
+ if (ip->mask)
+ current_cache += ip->w * ip->h / 8;
+ }
+ }
+ ip = ip->next;
+ }
#endif
return current_cache;
}
@@ -342,54 +343,54 @@ __imlib_CurrentCacheSize(void)
void
__imlib_CleanupImageCache(void)
{
- ImlibImage *im, *im_last;
- int current_cache;
- char operation = 1;
+ ImlibImage *im, *im_last;
+ int current_cache;
+ char operation = 1;
current_cache = __imlib_CurrentCacheSize();
im_last = NULL;
im = images;
/* remove 0 ref count invalid (dirty) images */
while (im)
- {
- im_last = im;
- im = im->next;
- if ((im_last->references <= 0) && (!(IMAGE_IS_VALID(im_last))))
- {
- __imlib_RemoveImageFromCache(im_last);
- __imlib_ConsumeImage(im_last);
- }
- }
+ {
+ im_last = im;
+ im = im->next;
+ if ((im_last->references <= 0) && (!(IMAGE_IS_VALID(im_last))))
+ {
+ __imlib_RemoveImageFromCache(im_last);
+ __imlib_ConsumeImage(im_last);
+ }
+ }
/* while the cache size of 0 ref coutn data is bigger than the set value */
/* clean out the oldest members of the imaeg cache */
while ((current_cache > cache_size) && (operation))
- {
- im_last = NULL;
- operation = 0;
- im = images;
- while (im)
- {
- if (im->references <= 0)
- im_last = im;
- im = im->next;
- }
- if (im_last)
- {
- __imlib_RemoveImageFromCache(im_last);
- __imlib_ConsumeImage(im_last);
- operation = 1;
- }
- if (operation)
- current_cache = __imlib_CurrentCacheSize();
- }
+ {
+ im_last = NULL;
+ operation = 0;
+ im = images;
+ while (im)
+ {
+ if (im->references <= 0)
+ im_last = im;
+ im = im->next;
+ }
+ if (im_last)
+ {
+ __imlib_RemoveImageFromCache(im_last);
+ __imlib_ConsumeImage(im_last);
+ operation = 1;
+ }
+ if (operation)
+ current_cache = __imlib_CurrentCacheSize();
+ }
}
#ifndef X_DISPLAY_MISSING
/* create a pixmap cache data struct */
-ImlibImagePixmap *
+ImlibImagePixmap *
__imlib_ProduceImagePixmap(void)
{
- ImlibImagePixmap *ip;
+ ImlibImagePixmap *ip;
ip = malloc(sizeof(ImlibImagePixmap));
memset(ip, 0, sizeof(ImlibImagePixmap));
@@ -414,69 +415,69 @@ __imlib_ConsumeImagePixmap(ImlibImagePixmap * ip)
XFreePixmap(ip->display, ip->pixmap);
if (ip->mask)
XFreePixmap(ip->display, ip->mask);
- if (ip->file) free(ip->file);
+ if (ip->file)
+ free(ip->file);
free(ip);
}
-ImlibImagePixmap *
+ImlibImagePixmap *
__imlib_FindCachedImagePixmap(ImlibImage * im, int w, int h, Display * d,
Visual * v, int depth, int sx, int sy, int sw,
int sh, Colormap cm, char aa, char hiq,
char dmask, DATABIG modification_count)
{
- ImlibImagePixmap *ip, *previous_ip;
+ ImlibImagePixmap *ip, *previous_ip;
ip = pixmaps;
previous_ip = NULL;
/* go through the pixmap list */
while (ip)
- {
- /* if all the pixmap attributes match */
- if ((ip->w == w) && (ip->h == h) && (ip->depth == depth) && (!ip->dirty)
- && (ip->visual == v) && (ip->display == d)
- && (ip->source_x == sx) && (ip->source_x == sy)
- && (ip->source_w == sw) && (ip->source_h == sh)
- && (ip->colormap == cm) && (ip->antialias == aa)
- && (ip->modification_count == modification_count)
- && (ip->dither_mask == dmask)
- && (ip->border.left == im->border.left)
- && (ip->border.right == im->border.right)
- && (ip->border.top == im->border.top)
- && (ip->border.bottom == im->border.bottom) &&
- (((im->file) && (ip->file) && !strcmp(im->file, ip->file)) ||
- ((!im->file) && (!ip->file) && (im == ip->image)))
- )
- {
- /* move the pixmap to the head of the pixmap list */
- if (previous_ip)
- {
- previous_ip->next = ip->next;
- ip->next = pixmaps;
- pixmaps = ip;
- }
- /* return it */
- return ip;
- }
- previous_ip = ip;
- ip = ip->next;
- }
+ {
+ /* if all the pixmap attributes match */
+ if ((ip->w == w) && (ip->h == h) && (ip->depth == depth) && (!ip->dirty)
+ && (ip->visual == v) && (ip->display == d)
+ && (ip->source_x == sx) && (ip->source_x == sy)
+ && (ip->source_w == sw) && (ip->source_h == sh)
+ && (ip->colormap == cm) && (ip->antialias == aa)
+ && (ip->modification_count == modification_count)
+ && (ip->dither_mask == dmask)
+ && (ip->border.left == im->border.left)
+ && (ip->border.right == im->border.right)
+ && (ip->border.top == im->border.top)
+ && (ip->border.bottom == im->border.bottom) &&
+ (((im->file) && (ip->file) && !strcmp(im->file, ip->file)) ||
+ ((!im->file) && (!ip->file) && (im == ip->image))))
+ {
+ /* move the pixmap to the head of the pixmap list */
+ if (previous_ip)
+ {
+ previous_ip->next = ip->next;
+ ip->next = pixmaps;
+ pixmaps = ip;
+ }
+ /* return it */
+ return ip;
+ }
+ previous_ip = ip;
+ ip = ip->next;
+ }
return NULL;
}
-ImlibImagePixmap *
+ImlibImagePixmap *
__imlib_FindCachedImagePixmapByID(Display * d, Pixmap p)
{
- ImlibImagePixmap *ip;
+ ImlibImagePixmap *ip;
ip = pixmaps;
/* go through the pixmap list */
while (ip)
- {
- /* if all the pixmap attributes match */
- if ((ip->pixmap == p) && (ip->display == d))
- return ip;
- ip = ip->next;
- }
+ {
+ /* if all the pixmap attributes match */
+ if ((ip->pixmap == p) && (ip->display == d))
+ return ip;
+ ip = ip->next;
+ }
return NULL;
}
@@ -492,72 +493,72 @@ __imlib_AddImagePixmapToCache(ImlibImagePixmap * ip)
void
__imlib_RemoveImagePixmapFromCache(ImlibImagePixmap * ip)
{
- ImlibImagePixmap *current_ip, *previous_ip;
+ ImlibImagePixmap *current_ip, *previous_ip;
current_ip = pixmaps;
previous_ip = NULL;
while (current_ip)
- {
- if (ip == current_ip)
- {
- if (previous_ip)
- previous_ip->next = ip->next;
- else
- pixmaps = ip->next;
- return;
- }
- previous_ip = current_ip;
- current_ip = current_ip->next;
- }
+ {
+ if (ip == current_ip)
+ {
+ if (previous_ip)
+ previous_ip->next = ip->next;
+ else
+ pixmaps = ip->next;
+ return;
+ }
+ previous_ip = current_ip;
+ current_ip = current_ip->next;
+ }
}
/* clean out 0 reference count & dirty pixmaps from the cache */
void
__imlib_CleanupImagePixmapCache(void)
{
- ImlibImagePixmap *ip, *ip_last;
- int current_cache;
- char operation = 0;
+ ImlibImagePixmap *ip, *ip_last;
+ int current_cache;
+ char operation = 0;
current_cache = __imlib_CurrentCacheSize();
ip_last = NULL;
ip = pixmaps;
while (ip)
- {
- ip_last = ip;
- ip = ip->next;
- if ((ip_last->references <= 0) && (ip_last->dirty))
- {
- __imlib_RemoveImagePixmapFromCache(ip_last);
- __imlib_ConsumeImagePixmap(ip_last);
- }
- }
+ {
+ ip_last = ip;
+ ip = ip->next;
+ if ((ip_last->references <= 0) && (ip_last->dirty))
+ {
+ __imlib_RemoveImagePixmapFromCache(ip_last);
+ __imlib_ConsumeImagePixmap(ip_last);
+ }
+ }
while ((current_cache > cache_size) && (operation))
- {
- ip_last = NULL;
- operation = 0;
- ip = pixmaps;
- while (ip)
- {
- if (ip->references <= 0)
- ip_last = ip;
- ip = ip->next;
- }
- if (ip_last)
- {
- __imlib_RemoveImagePixmapFromCache(ip_last);
- __imlib_ConsumeImagePixmap(ip_last);
- operation = 1;
- }
- if (operation)
- current_cache = __imlib_CurrentCacheSize();
- }
+ {
+ ip_last = NULL;
+ operation = 0;
+ ip = pixmaps;
+ while (ip)
+ {
+ if (ip->references <= 0)
+ ip_last = ip;
+ ip = ip->next;
+ }
+ if (ip_last)
+ {
+ __imlib_RemoveImagePixmapFromCache(ip_last);
+ __imlib_ConsumeImagePixmap(ip_last);
+ operation = 1;
+ }
+ if (operation)
+ current_cache = __imlib_CurrentCacheSize();
+ }
}
#endif
#define LOADERS_UNINITIALISED -4444
-static int errors = LOADERS_UNINITIALISED;
+static int errors = LOADERS_UNINITIALISED;
static void
LTDL_Init(void)
@@ -565,22 +566,22 @@ LTDL_Init(void)
/* Do this only once! */
if ((errors == LOADERS_UNINITIALISED))
- {
- errors = lt_dlinit();
+ {
+ errors = lt_dlinit();
- /* Initialise libltdl's memory management. */
- lt_dlmalloc = malloc;
- lt_dlfree = free;
- }
+ /* Initialise libltdl's memory management. */
+ lt_dlmalloc = malloc;
+ lt_dlfree = free;
+ }
/* Failing ltdl initialisation makes continuing somewhat futile... */
if (errors != 0)
- {
- const char *dlerror = lt_dlerror();
+ {
+ const char *dlerror = lt_dlerror();
- fprintf(stderr, "ERROR: failed to initialise ltdl: %s\n", dlerror);
- exit(1);
- }
+ fprintf(stderr, "ERROR: failed to initialise ltdl: %s\n", dlerror);
+ exit(1);
+ }
}
void
@@ -592,11 +593,11 @@ LTDL_Exit(void)
/* try dlopen()ing the file if we succeed finish filling out the malloced */
/* loader struct and return it */
-ImlibLoader *
+ImlibLoader *
__imlib_ProduceLoader(char *file)
{
- ImlibLoader *l;
- void (*l_formats) (ImlibLoader * l);
+ ImlibLoader *l;
+ void (*l_formats) (ImlibLoader * l);
LTDL_Init();
@@ -605,19 +606,19 @@ __imlib_ProduceLoader(char *file)
l->formats = NULL;
l->handle = lt_dlopenext(file);
if (!l->handle)
- {
- free(l);
- return NULL;
- }
+ {
+ free(l);
+ return NULL;
+ }
l->load = lt_dlsym(l->handle, "load");
l->save = lt_dlsym(l->handle, "save");
l_formats = lt_dlsym(l->handle, "formats");
if ((!(l->load)) || (!(l->save)) || (!(l_formats)))
- {
- lt_dlclose(l->handle);
- free(l);
- return NULL;
- }
+ {
+ lt_dlclose(l->handle);
+ free(l);
+ return NULL;
+ }
l_formats(l);
l->file = strdup(file);
l->next = NULL;
@@ -626,38 +627,40 @@ __imlib_ProduceLoader(char *file)
/* list all the filenames of loaders int he system loaders dir and the user */
/* loader dir */
-char **
+char **
__imlib_ListLoaders(int *num_ret)
{
- char **list = NULL, **l, *s;
- int num, i, pi = 0;
+ char **list = NULL, **l, *s;
+ int num, i, pi = 0;
*num_ret = 0;
/* same for system loader path */
- s = (char *) malloc(sizeof(SYS_LOADERS_PATH) + 6 + 1);
+ s = (char *)malloc(sizeof(SYS_LOADERS_PATH) + 6 + 1);
sprintf(s, SYS_LOADERS_PATH "/image");
-#ifndef __EMX__
+#ifndef __EMX__
l = __imlib_FileDir(s, &num);
-#else
+#else
l = __imlib_FileDir(__XOS2RedirRoot(s), &num);
-#endif
+#endif
if (num > 0)
- {
- *num_ret += num;
- list = realloc(list, sizeof(char *) * *num_ret);
-
- for (i = 0; i < num; i++)
- {
- s = (char *) realloc(s, sizeof(SYS_LOADERS_PATH) + 7 + strlen(l[i]) + 1);
- sprintf(s, SYS_LOADERS_PATH "/image/%s", l[i]);
+ {
+ *num_ret += num;
+ list = realloc(list, sizeof(char *) * *num_ret);
+
+ for (i = 0; i < num; i++)
+ {
+ s = (char *)realloc(s,
+ sizeof(SYS_LOADERS_PATH) + 7 + strlen(l[i]) +
+ 1);
+ sprintf(s, SYS_LOADERS_PATH "/image/%s", l[i]);
#ifndef __EMX__
- list[pi + i] = strdup(s);
+ list[pi + i] = strdup(s);
#else
- list[pi + i] = strdup(__XOS2RedirRoot(s));
+ list[pi + i] = strdup(__XOS2RedirRoot(s));
#endif
- }
- __imlib_FileFreeDirList(l, num);
- }
+ }
+ __imlib_FileFreeDirList(l, num);
+ }
free(s);
/* List currently contains *everything in there* we need to weed out
@@ -669,12 +672,12 @@ __imlib_ListLoaders(int *num_ret)
return list;
}
-char **
+char **
__imlib_TrimLoaderList(char **list, int *num)
{
- int i, n, size = 0;
+ int i, n, size = 0;
- char **ret = NULL;
+ char **ret = NULL;
if (!list)
return NULL;
@@ -684,26 +687,26 @@ __imlib_TrimLoaderList(char **list, int *num)
n = *num;
for (i = 0; i < n; i++)
- {
- char *ext;
-
- if (!list[i])
- continue;
- ext = strrchr(list[i], '.');
- if (ext)
- {
- *ext = '\0';
- /* Don't add the same loader multiple times... */
- if (!__imlib_ItemInList(ret, size, list[i]))
- {
- ret = realloc(ret, sizeof(char *) * (size + 1));
-
- ret[size++] = strdup(list[i]);
- }
- }
- if (list[i])
- free(list[i]);
- }
+ {
+ char *ext;
+
+ if (!list[i])
+ continue;
+ ext = strrchr(list[i], '.');
+ if (ext)
+ {
+ *ext = '\0';
+ /* Don't add the same loader multiple times... */
+ if (!__imlib_ItemInList(ret, size, list[i]))
+ {
+ ret = realloc(ret, sizeof(char *) * (size + 1));
+
+ ret[size++] = strdup(list[i]);
+ }
+ }
+ if (list[i])
+ free(list[i]);
+ }
if (list)
free(list);
*num = size;
@@ -713,7 +716,7 @@ __imlib_TrimLoaderList(char **list, int *num)
int
__imlib_ItemInList(char **list, int size, char *item)
{
- int i;
+ int i;
if (!size)
return 0;
@@ -723,10 +726,10 @@ __imlib_ItemInList(char **list, int size, char *item)
return 0;
for (i = 0; i < size; i++)
- {
- if (!strcmp(list[i], item))
- return 1;
- }
+ {
+ if (!strcmp(list[i], item))
+ return 1;
+ }
return 0;
}
@@ -739,25 +742,25 @@ __imlib_ConsumeLoader(ImlibLoader * l)
if (l->handle)
lt_dlclose(l->handle);
if (l->formats)
- {
- int i;
+ {
+ int i;
- for (i = 0; i < l->num_formats; i++)
- free(l->formats[i]);
- free(l->formats);
- }
+ for (i = 0; i < l->num_formats; i++)
+ free(l->formats[i]);
+ free(l->formats);
+ }
free(l);
}
void
__imlib_RescanLoaders(void)
{
- static time_t last_scan_time = 0;
- static time_t last_modified_home_time = 0;
- static time_t last_modified_system_time = 0;
- time_t current_time;
- char *s, *home;
- char do_reload = 0;
+ static time_t last_scan_time = 0;
+ static time_t last_modified_home_time = 0;
+ static time_t last_modified_system_time = 0;
+ time_t current_time;
+ char *s, *home;
+ char do_reload = 0;
/* dont stat the dir and rescan if we checked in the last 5 seconds */
current_time = time(NULL);
@@ -770,20 +773,20 @@ __imlib_RescanLoaders(void)
#else
if (__imlib_FileIsDir(__XOS2RedirRoot(SYS_LOADERS_PATH "/image/")))
#endif
- {
+ {
#ifndef __EMX__
- current_time = __imlib_FileModDate(SYS_LOADERS_PATH "/image/");
+ current_time = __imlib_FileModDate(SYS_LOADERS_PATH "/image/");
#else
- current_time =
- __imlib_FileModDate(__XOS2RedirRoot(SYS_LOADERS_PATH "/image/"));
+ current_time =
+ __imlib_FileModDate(__XOS2RedirRoot(SYS_LOADERS_PATH "/image/"));
#endif
- if (current_time > last_modified_system_time)
- {
- /* yup - set the "do_reload" flag */
- do_reload = 1;
- last_modified_system_time = current_time;
- }
- }
+ if (current_time > last_modified_system_time)
+ {
+ /* yup - set the "do_reload" flag */
+ do_reload = 1;
+ last_modified_system_time = current_time;
+ }
+ }
/* if we dont ned to reload the loaders - get out now */
if (!do_reload)
return;
@@ -795,15 +798,15 @@ __imlib_RescanLoaders(void)
void
__imlib_RemoveAllLoaders(void)
{
- ImlibLoader *l, *il;
+ ImlibLoader *l, *il;
l = loaders;
while (l)
- {
- il = l;
- l = l->next;
- __imlib_ConsumeLoader(il);
- }
+ {
+ il = l;
+ l = l->next;
+ __imlib_ConsumeLoader(il);
+ }
loaders = NULL;
}
@@ -812,8 +815,8 @@ __imlib_RemoveAllLoaders(void)
void
__imlib_LoadAllLoaders(void)
{
- int i, num;
- char **list;
+ int i, num;
+ char **list;
/* list all the loaders imlib can find */
list = __imlib_ListLoaders(&num);
@@ -824,30 +827,30 @@ __imlib_LoadAllLoaders(void)
/* go through the list of filenames for loader .so's and load them */
/* (or try) and if it succeeds, append to our loader list */
for (i = num - 1; i >= 0; i--)
- {
- ImlibLoader *l;
-
- l = __imlib_ProduceLoader(list[i]);
- if (l)
- {
- l->next = loaders;
- loaders = l;
- }
- if (list[i])
- free(list[i]);
- }
+ {
+ ImlibLoader *l;
+
+ l = __imlib_ProduceLoader(list[i]);
+ if (l)
+ {
+ l->next = loaders;
+ loaders = l;
+ }
+ if (list[i])
+ free(list[i]);
+ }
free(list);
}
-ImlibLoader *
+ImlibLoader *
__imlib_FindBestLoaderForFile(const char *file)
{
- char *extension, *lower, *rfile;
- ImlibLoader *l = NULL;
+ char *extension, *lower, *rfile;
+ ImlibLoader *l = NULL;
/* use the file extension for a "best guess" as to what loader to try */
/* first at any rate */
-
+
rfile = __imlib_FileRealFile(file);
extension = __imlib_FileExtension(rfile);
free(rfile);
@@ -856,10 +859,10 @@ __imlib_FindBestLoaderForFile(const char *file)
/* extensions that file format could have */
lower = extension;
while (*lower)
- {
- *lower = tolower(*lower);
- lower++;
- }
+ {
+ *lower = tolower(*lower);
+ lower++;
+ }
if (!extension)
return NULL;
/* go through the loaders - first loader that claims to handle that */
@@ -876,77 +879,77 @@ __imlib_FindBestLoaderForFile(const char *file)
/* of the same format */
l = loaders;
while (l)
- {
- int i;
-
- /* go through all the formats that loader supports */
- for (i = 0; i < l->num_formats; i++)
- {
- /* does it match ? */
- if (!strcmp(l->formats[i], extension))
- {
- /* free the memory allocated for the extension */
- free(extension);
- /* return the loader */
- return l;
- }
- }
- l = l->next;
- }
+ {
+ int i;
+
+ /* go through all the formats that loader supports */
+ for (i = 0; i < l->num_formats; i++)
+ {
+ /* does it match ? */
+ if (!strcmp(l->formats[i], extension))
+ {
+ /* free the memory allocated for the extension */
+ free(extension);
+ /* return the loader */
+ return l;
+ }
+ }
+ l = l->next;
+ }
/* free the memory allocated for the extension */
free(extension);
/* return the loader */
return l;
}
-ImlibLoader *
+ImlibLoader *
__imlib_FindBestLoaderForFileFormat(const char *file, char *format)
{
- char *extension, *lower;
- ImlibLoader *l = NULL;
+ char *extension, *lower;
+ ImlibLoader *l = NULL;
/* if the format is provided ("png" "jpg" etc.) use that */
if (format)
extension = strdup(format);
/* otherwise us the extension */
else
- {
- extension = __imlib_FileExtension(file);
- /* change the extension to all lower case as all "types" are listed as */
- /* lower case strings fromt he loader that represent all the possible */
- /* extensions that file format could have */
- if (extension)
- {
- lower = extension;
- while (*lower)
- {
- *lower = tolower(*lower);
- lower++;
- }
- }
- }
+ {
+ extension = __imlib_FileExtension(file);
+ /* change the extension to all lower case as all "types" are listed as */
+ /* lower case strings fromt he loader that represent all the possible */
+ /* extensions that file format could have */
+ if (extension)
+ {
+ lower = extension;
+ while (*lower)
+ {
+ *lower = tolower(*lower);
+ lower++;
+ }
+ }
+ }
if (!extension)
return NULL;
/* look through the loaders one by one to see if one matches that format */
l = loaders;
while (l)
- {
- int i;
-
- /* go through all the formats that loader supports */
- for (i = 0; i < l->num_formats; i++)
- {
- /* does it match ? */
- if (!strcmp(l->formats[i], extension))
- {
- /* free the memory allocated for the extension */
- free(extension);
- /* return the loader */
- return l;
- }
- }
- l = l->next;
- }
+ {
+ int i;
+
+ /* go through all the formats that loader supports */
+ for (i = 0; i < l->num_formats; i++)
+ {
+ /* does it match ? */
+ if (!strcmp(l->formats[i], extension))
+ {
+ /* free the memory allocated for the extension */
+ free(extension);
+ /* return the loader */
+ return l;
+ }
+ }
+ l = l->next;
+ }
/* free the memory allocated for the extension */
free(extension);
/* return the loader */
@@ -965,10 +968,10 @@ __imlib_SetImageAlphaFlag(ImlibImage * im, char alpha)
/* create a new image struct from data passed that is wize w x h then return */
/* a pointer to that image sturct */
-ImlibImage *
+ImlibImage *
__imlib_CreateImage(int w, int h, DATA32 * data)
{
- ImlibImage *im;
+ ImlibImage *im;
im = __imlib_ProduceImage();
im->w = w;
@@ -979,62 +982,64 @@ __imlib_CreateImage(int w, int h, DATA32 * data)
return im;
}
-ImlibImage *
+ImlibImage *
__imlib_LoadImage(const char *file, ImlibProgressFunction progress,
char progress_granularity, char immediate_load,
char dont_cache, ImlibLoadError * er)
{
- ImlibImage *im;
- ImlibLoader *best_loader;
- char loader_ret = 0;
+ ImlibImage *im;
+ ImlibLoader *best_loader;
+ char loader_ret = 0;
- if (!file) return NULL;
- if (file[0] == 0) return NULL;
+ if (!file)
+ return NULL;
+ if (file[0] == 0)
+ return NULL;
/* see if we alreayd have the image cached */
im = __imlib_FindCachedImage(file);
/* if we found a cached image and we shoudl always check that it is */
/* accurate to the disk conents if they changed since we last loaded */
/* and that it is still a valid image */
if ((im) && (IMAGE_IS_VALID(im)))
- {
- if (IMAGE_ALWAYS_CHECK_DISK(im))
- {
- time_t current_modified_time;
-
- current_modified_time = __imlib_FileModDate(file);
- /* if the file on disk is newer than the cached one */
- if (current_modified_time > im->moddate)
- {
- /* invalidate image */
- SET_FLAG(im->flags, F_INVALID);
- }
- else
- {
- /* image is ok to re-use - program is just being stupid loading */
- /* the same data twice */
- im->references++;
- return im;
- }
- }
- else
- {
- im->references++;
- return im;
- }
- }
+ {
+ if (IMAGE_ALWAYS_CHECK_DISK(im))
+ {
+ time_t current_modified_time;
+
+ current_modified_time = __imlib_FileModDate(file);
+ /* if the file on disk is newer than the cached one */
+ if (current_modified_time > im->moddate)
+ {
+ /* invalidate image */
+ SET_FLAG(im->flags, F_INVALID);
+ }
+ else
+ {
+ /* image is ok to re-use - program is just being stupid loading */
+ /* the same data twice */
+ im->references++;
+ return im;
+ }
+ }
+ else
+ {
+ im->references++;
+ return im;
+ }
+ }
/* either image in cache is invalid or we dont even have it in cache */
/* so produce a new one and load an image into that */
im = __imlib_ProduceImage();
im->file = strdup(file);
- if(__imlib_IsRealFile(file))
+ if (__imlib_IsRealFile(file))
{
- im->real_file = strdup(im->file);
- im->key = NULL;
+ im->real_file = strdup(im->file);
+ im->key = NULL;
}
else
{
- im->real_file = __imlib_FileRealFile(file);
- im->key = __imlib_FileKey(file);
+ im->real_file = __imlib_FileRealFile(file);
+ im->key = __imlib_FileKey(file);
}
im->moddate = __imlib_FileModDate(file);
/* ok - just check all our loaders are up to date */
@@ -1044,92 +1049,92 @@ __imlib_LoadImage(const char *file, ImlibProgressFunction progress,
errno = 0;
if (best_loader)
loader_ret =
- best_loader->load(im, progress, progress_granularity,
- immediate_load);
+ best_loader->load(im, progress, progress_granularity, immediate_load);
/* width is still 0 - the loader didnt manage to do anything */
if (im->w == 0)
- {
- ImlibLoader *l, *previous_l = NULL;
-
- errno = 0;
- l = loaders;
- /* run through all loaders and try load until one succeeds */
- while ((l) && (im->w == 0))
- {
- /* if its not the best loader that alreayd failed - try load */
- if (l != best_loader)
- loader_ret =
- l->load(im, progress, progress_granularity, immediate_load);
- /* if it failed - advance */
- if (im->w == 0)
- {
- previous_l = l;
- l = l->next;
- }
- }
- /* if we have a loader then its the loader that succeeded */
- /* move the successful loader to the head of the list */
- /* as long as it's not alreayd at the head of the list */
- if ((l) && (previous_l))
- {
- im->loader = l;
- previous_l->next = l->next;
- l->next = loaders;
- loaders = l;
- }
- if (im->w > 0) im->loader = l;
- }
+ {
+ ImlibLoader *l, *previous_l = NULL;
+
+ errno = 0;
+ l = loaders;
+ /* run through all loaders and try load until one succeeds */
+ while ((l) && (im->w == 0))
+ {
+ /* if its not the best loader that alreayd failed - try load */
+ if (l != best_loader)
+ loader_ret =
+ l->load(im, progress, progress_granularity, immediate_load);
+ /* if it failed - advance */
+ if (im->w == 0)
+ {
+ previous_l = l;
+ l = l->next;
+ }
+ }
+ /* if we have a loader then its the loader that succeeded */
+ /* move the successful loader to the head of the list */
+ /* as long as it's not alreayd at the head of the list */
+ if ((l) && (previous_l))
+ {
+ im->loader = l;
+ previous_l->next = l->next;
+ l->next = loaders;
+ loaders = l;
+ }
+ if (im->w > 0)
+ im->loader = l;
+ }
else
im->loader = best_loader;
/* all loaders have been tried and they all failed. free the skeleton */
/* image struct we had and return NULL */
if (im->w == 0)
- {
- /* if the caller wants an error return */
- if (er)
- {
- /* set to a default fo no error */
- *er = LOAD_ERROR_NONE;
- /* if the errno is set */
- if (errno != 0)
- {
- /* default to unknown error */
- *er = LOAD_ERROR_UNKNOWN;
- /* standrad fopen() type errors translated */
- if (errno == EEXIST)
- *er = LOAD_ERROR_FILE_DOES_NOT_EXIST;
- else if (errno == EISDIR)
- *er = LOAD_ERROR_FILE_IS_DIRECTORY;
- else if (errno == EISDIR)
- *er = LOAD_ERROR_FILE_IS_DIRECTORY;
- else if (errno == EACCES)
- *er = LOAD_ERROR_PERMISSION_DENIED_TO_READ;
- else if (errno == ENAMETOOLONG)
- *er = LOAD_ERROR_PATH_TOO_LONG;
- else if (errno == ENOENT)
- *er = LOAD_ERROR_PATH_COMPONENT_NON_EXISTANT;
- else if (errno == ENOTDIR)
- *er = LOAD_ERROR_PATH_COMPONENT_NOT_DIRECTORY;
- else if (errno == EFAULT)
- *er = LOAD_ERROR_PATH_POINTS_OUTSIDE_ADDRESS_SPACE;
- else if (errno == ELOOP)
- *er = LOAD_ERROR_TOO_MANY_SYMBOLIC_LINKS;
- else if (errno == ENOMEM)
- *er = LOAD_ERROR_OUT_OF_MEMORY;
- else if (errno == EMFILE)
- *er = LOAD_ERROR_OUT_OF_FILE_DESCRIPTORS;
- if (*er != LOAD_ERROR_UNKNOWN)
- {
- /* free the stuct we created */
- __imlib_ConsumeImage(im);
- return NULL;
- }
- }
- errno = 0;
- }
- __imlib_ConsumeImage(im);
- return NULL;
- }
+ {
+ /* if the caller wants an error return */
+ if (er)
+ {
+ /* set to a default fo no error */
+ *er = LOAD_ERROR_NONE;
+ /* if the errno is set */
+ if (errno != 0)
+ {
+ /* default to unknown error */
+ *er = LOAD_ERROR_UNKNOWN;
+ /* standrad fopen() type errors translated */
+ if (errno == EEXIST)
+ *er = LOAD_ERROR_FILE_DOES_NOT_EXIST;
+ else if (errno == EISDIR)
+ *er = LOAD_ERROR_FILE_IS_DIRECTORY;
+ else if (errno == EISDIR)
+ *er = LOAD_ERROR_FILE_IS_DIRECTORY;
+ else if (errno == EACCES)
+ *er = LOAD_ERROR_PERMISSION_DENIED_TO_READ;
+ else if (errno == ENAMETOOLONG)
+ *er = LOAD_ERROR_PATH_TOO_LONG;
+ else if (errno == ENOENT)
+ *er = LOAD_ERROR_PATH_COMPONENT_NON_EXISTANT;
+ else if (errno == ENOTDIR)
+ *er = LOAD_ERROR_PATH_COMPONENT_NOT_DIRECTORY;
+ else if (errno == EFAULT)
+ *er = LOAD_ERROR_PATH_POINTS_OUTSIDE_ADDRESS_SPACE;
+ else if (errno == ELOOP)
+ *er = LOAD_ERROR_TOO_MANY_SYMBOLIC_LINKS;
+ else if (errno == ENOMEM)
+ *er = LOAD_ERROR_OUT_OF_MEMORY;
+ else if (errno == EMFILE)
+ *er = LOAD_ERROR_OUT_OF_FILE_DESCRIPTORS;
+ if (*er != LOAD_ERROR_UNKNOWN)
+ {
+ /* free the stuct we created */
+ __imlib_ConsumeImage(im);
+ return NULL;
+ }
+ }
+ errno = 0;
+ }
+ __imlib_ConsumeImage(im);
+ return NULL;
+ }
/* the load succeeded - make sure the image is referenced then add */
/* it to our cache if dont_cache isn't set */
@@ -1145,27 +1150,27 @@ __imlib_LoadImage(const char *file, ImlibProgressFunction progress,
#ifndef X_DISPLAY_MISSING
/* find an imagepixmap cache entry by the display and pixmap id */
-ImlibImagePixmap *
+ImlibImagePixmap *
__imlib_FindImlibImagePixmapByID(Display * d, Pixmap p)
{
- ImlibImagePixmap *ip;
+ ImlibImagePixmap *ip;
ip = pixmaps;
/* go through the pixmap list */
while (ip)
- {
- /* if all the pixmap ID & Display match */
- if ((ip->pixmap == p) && (ip->display == d))
- {
+ {
+ /* if all the pixmap ID & Display match */
+ if ((ip->pixmap == p) && (ip->display == d))
+ {
#ifdef DEBUG_CACHE
- fprintf(stderr,
- "[Imlib2] Match found. Reference count is %d, pixmap 0x%08x, mask 0x%08x\n",
- ip->references, ip->pixmap, ip->mask);
+ fprintf(stderr,
+ "[Imlib2] Match found. Reference count is %d, pixmap 0x%08x, mask 0x%08x\n",
+ ip->references, ip->pixmap, ip->mask);
#endif
- return ip;
- }
- ip = ip->next;
- }
+ return ip;
+ }
+ ip = ip->next;
+ }
return NULL;
}
#endif
@@ -1176,56 +1181,55 @@ __imlib_FreeImage(ImlibImage * im)
{
/* if the refcount is positive */
if (im->references >= 0)
- {
- /* reduce a reference from the count */
- im->references--;
- /* if its uncachchable ... */
- if (IMAGE_IS_UNCACHEABLE(im))
- {
- /* and we're down to no references for the image then free it */
- if (im->references == 0)
- __imlib_ConsumeImage(im);
- }
- /* otherwise clean up our cache if the image becoem 0 ref count */
- else if (im->references == 0)
- __imlib_CleanupImageCache();
- }
+ {
+ /* reduce a reference from the count */
+ im->references--;
+ /* if its uncachchable ... */
+ if (IMAGE_IS_UNCACHEABLE(im))
+ {
+ /* and we're down to no references for the image then free it */
+ if (im->references == 0)
+ __imlib_ConsumeImage(im);
+ }
+ /* otherwise clean up our cache if the image becoem 0 ref count */
+ else if (im->references == 0)
+ __imlib_CleanupImageCache();
+ }
}
-
#ifndef X_DISPLAY_MISSING
/* free a cached pixmap */
void
__imlib_FreePixmap(Display * d, Pixmap p)
{
- ImlibImagePixmap *ip;
+ ImlibImagePixmap *ip;
/* find the pixmap in the cache by display and id */
ip = __imlib_FindImlibImagePixmapByID(d, p);
if (ip)
- {
- /* if tis positive reference count */
- if (ip->references > 0)
- {
- /* dereference it by one */
- ip->references--;
+ {
+ /* if tis positive reference count */
+ if (ip->references > 0)
+ {
+ /* dereference it by one */
+ ip->references--;
#ifdef DEBUG_CACHE
- fprintf(stderr,
- "[Imlib2] Reference count is now %d for pixmap 0x%08x\n",
- ip->references, ip->pixmap);
+ fprintf(stderr,
+ "[Imlib2] Reference count is now %d for pixmap 0x%08x\n",
+ ip->references, ip->pixmap);
#endif
- /* if it becaume 0 reference count - clean the cache up */
- if (ip->references == 0)
- __imlib_CleanupImagePixmapCache();
- }
- }
+ /* if it becaume 0 reference count - clean the cache up */
+ if (ip->references == 0)
+ __imlib_CleanupImagePixmapCache();
+ }
+ }
else
- {
+ {
#ifdef DEBUG_CACHE
- fprintf(stderr, "[Imlib2] Pixmap 0x%08x not found. Freeing.\n", p);
+ fprintf(stderr, "[Imlib2] Pixmap 0x%08x not found. Freeing.\n", p);
#endif
- XFreePixmap(d, p);
- }
+ XFreePixmap(d, p);
+ }
}
/* mark all pixmaps generated from this image as dirty so the cache code */
@@ -1234,17 +1238,17 @@ __imlib_FreePixmap(Display * d, Pixmap p)
void
__imlib_DirtyPixmapsForImage(ImlibImage * im)
{
- ImlibImagePixmap *ip;
+ ImlibImagePixmap *ip;
ip = pixmaps;
/* go through the pixmap list */
while (ip)
- {
- /* if image matches */
- if (ip->image == im)
- ip->dirty = 1;
- ip = ip->next;
- }
+ {
+ /* if image matches */
+ if (ip->image == im)
+ ip->dirty = 1;
+ ip = ip->next;
+ }
__imlib_CleanupImagePixmapCache();
}
#endif
@@ -1263,15 +1267,15 @@ __imlib_SaveImage(ImlibImage * im, const char *file,
ImlibProgressFunction progress, char progress_granularity,
ImlibLoadError * er)
{
- ImlibLoader *l;
- char e, *pfile;
+ ImlibLoader *l;
+ char e, *pfile;
if (!file)
- {
- if (er)
- *er = LOAD_ERROR_FILE_DOES_NOT_EXIST;
- return;
- }
+ {
+ if (er)
+ *er = LOAD_ERROR_FILE_DOES_NOT_EXIST;
+ return;
+ }
/* ok - just check all our loaders are up to date */
__imlib_RescanLoaders();
/* set the filename to the saved one */
@@ -1283,24 +1287,24 @@ __imlib_SaveImage(ImlibImage * im, const char *file,
l = __imlib_FindBestLoaderForFileFormat(im->real_file, im->format);
/* no loader - abort */
if (!l)
- {
- if (er)
- *er = LOAD_ERROR_NO_LOADER_FOR_FILE_FORMAT;
- /* set the filename back to the laoder image filename */
- free(im->file);
- im->file = pfile;
- return;
- }
+ {
+ if (er)
+ *er = LOAD_ERROR_NO_LOADER_FOR_FILE_FORMAT;
+ /* set the filename back to the laoder image filename */
+ free(im->file);
+ im->file = pfile;
+ return;
+ }
/* no saver function in loader - abort */
if (!l->save)
- {
- if (er)
- *er = LOAD_ERROR_NO_LOADER_FOR_FILE_FORMAT;
- /* set the filename back to the laoder image filename */
- free(im->file);
- im->file = pfile;
- return;
- }
+ {
+ if (er)
+ *er = LOAD_ERROR_NO_LOADER_FOR_FILE_FORMAT;
+ /* set the filename back to the laoder image filename */
+ free(im->file);
+ im->file = pfile;
+ return;
+ }
/* if they want an error returned - assume none by default */
if (er)
*er = LOAD_ERROR_NONE;
@@ -1313,33 +1317,33 @@ __imlib_SaveImage(ImlibImage * im, const char *file,
/* if there's an error return and the save faile (e = 0) figure it out */
if ((er) && (e == 0))
- {
- *er = LOAD_ERROR_UNKNOWN;
- if (errno == EEXIST)
- *er = LOAD_ERROR_FILE_DOES_NOT_EXIST;
- else if (errno == EISDIR)
- *er = LOAD_ERROR_FILE_IS_DIRECTORY;
- else if (errno == EISDIR)
- *er = LOAD_ERROR_FILE_IS_DIRECTORY;
- else if (errno == EACCES)
- *er = LOAD_ERROR_PERMISSION_DENIED_TO_WRITE;
- else if (errno == ENAMETOOLONG)
- *er = LOAD_ERROR_PATH_TOO_LONG;
- else if (errno == ENOENT)
- *er = LOAD_ERROR_PATH_COMPONENT_NON_EXISTANT;
- else if (errno == ENOTDIR)
- *er = LOAD_ERROR_PATH_COMPONENT_NOT_DIRECTORY;
- else if (errno == EFAULT)
- *er = LOAD_ERROR_PATH_POINTS_OUTSIDE_ADDRESS_SPACE;
- else if (errno == ELOOP)
- *er = LOAD_ERROR_TOO_MANY_SYMBOLIC_LINKS;
- else if (errno == ENOMEM)
- *er = LOAD_ERROR_OUT_OF_MEMORY;
- else if (errno == EMFILE)
- *er = LOAD_ERROR_OUT_OF_FILE_DESCRIPTORS;
- else if (errno == ENOSPC)
- *er = LOAD_ERROR_OUT_OF_DISK_SPACE;
- else if (errno == EROFS)
- *er = LOAD_ERROR_PERMISSION_DENIED_TO_WRITE;
- }
+ {
+ *er = LOAD_ERROR_UNKNOWN;
+ if (errno == EEXIST)
+ *er = LOAD_ERROR_FILE_DOES_NOT_EXIST;
+ else if (errno == EISDIR)
+ *er = LOAD_ERROR_FILE_IS_DIRECTORY;
+ else if (errno == EISDIR)
+ *er = LOAD_ERROR_FILE_IS_DIRECTORY;
+ else if (errno == EACCES)
+ *er = LOAD_ERROR_PERMISSION_DENIED_TO_WRITE;
+ else if (errno == ENAMETOOLONG)
+ *er = LOAD_ERROR_PATH_TOO_LONG;
+ else if (errno == ENOENT)
+ *er = LOAD_ERROR_PATH_COMPONENT_NON_EXISTANT;
+ else if (errno == ENOTDIR)
+ *er = LOAD_ERROR_PATH_COMPONENT_NOT_DIRECTORY;
+ else if (errno == EFAULT)
+ *er = LOAD_ERROR_PATH_POINTS_OUTSIDE_ADDRESS_SPACE;
+ else if (errno == ELOOP)
+ *er = LOAD_ERROR_TOO_MANY_SYMBOLIC_LINKS;
+ else if (errno == ENOMEM)
+ *er = LOAD_ERROR_OUT_OF_MEMORY;
+ else if (errno == EMFILE)
+ *er = LOAD_ERROR_OUT_OF_FILE_DESCRIPTORS;
+ else if (errno == ENOSPC)
+ *er = LOAD_ERROR_OUT_OF_DISK_SPACE;
+ else if (errno == EROFS)
+ *er = LOAD_ERROR_PERMISSION_DENIED_TO_WRITE;
+ }
}
diff --git a/src/rend.c b/src/rend.c
index d089293..accb874 100644
--- a/src/rend.c
+++ b/src/rend.c
@@ -18,166 +18,166 @@
#define LINESIZE 16
DATA32
-__imlib_RenderGetPixel(Display *d, Drawable w, Visual *v, Colormap cm, int depth, DATA8 r, DATA8 g, DATA8 b)
+__imlib_RenderGetPixel(Display * d, Drawable w, Visual * v, Colormap cm,
+ int depth, DATA8 r, DATA8 g, DATA8 b)
{
- Context *ct;
- int actual_depth;
-
+ Context *ct;
+ int actual_depth;
+
ct = __imlib_GetContext(d, v, cm, depth);
actual_depth = depth;
- if (depth == 16) actual_depth = __imlib_XActualDepth(d, v);
-
+ if (depth == 16)
+ actual_depth = __imlib_XActualDepth(d, v);
+
if (ct->palette)
{
- switch (ct->palette_type)
- {
- case 0: /* 332 */
- return ct->palette[((r >> 0) & 0xe0) |
- ((g >> 3) & 0x1b) |
- ((b >> 6) & 0x02)];
- break;
- case 1: /* 232 */
- return ct->palette[((r >> 0) & 0xe0) |
- ((g >> 3) & 0x1b) |
- ((b >> 6) & 0x02)];
- break;
- case 2: /* 222 */
- return ct->palette[((r >> 0) & 0xe0) |
- ((g >> 3) & 0x1b) |
- ((b >> 6) & 0x02)];
- break;
- case 3: /* 221 */
- return ct->palette[((r >> 0) & 0xe0) |
- ((g >> 3) & 0x1b) |
- ((b >> 6) & 0x02)];
- break;
- case 4: /* 121 */
- return ct->palette[((r >> 0) & 0xe0) |
- ((g >> 3) & 0x1b) |
- ((b >> 6) & 0x02)];
- break;
- case 5: /* 111 */
- return ct->palette[((r >> 0) & 0xe0) |
- ((g >> 3) & 0x1b) |
- ((b >> 6) & 0x02)];
- break;
- case 6: /* 1 */
- return ct->palette[((r >> 0) & 0xe0) |
- ((g >> 3) & 0x1b) |
- ((b >> 6) & 0x02)];
- break;
- case 7: /* 666 */
- return ct->palette[((int)(((double)r / 255) * 5.0) * 36) +
- ((int)(((double)g / 255) * 5.0) * 6 ) +
- ((int)(((double)b / 255) * 5.0) )];
- break;
- default:
- return 0;
- }
+ switch (ct->palette_type)
+ {
+ case 0: /* 332 */
+ return ct->palette[((r >> 0) & 0xe0) |
+ ((g >> 3) & 0x1b) | ((b >> 6) & 0x02)];
+ break;
+ case 1: /* 232 */
+ return ct->palette[((r >> 0) & 0xe0) |
+ ((g >> 3) & 0x1b) | ((b >> 6) & 0x02)];
+ break;
+ case 2: /* 222 */
+ return ct->palette[((r >> 0) & 0xe0) |
+ ((g >> 3) & 0x1b) | ((b >> 6) & 0x02)];
+ break;
+ case 3: /* 221 */
+ return ct->palette[((r >> 0) & 0xe0) |
+ ((g >> 3) & 0x1b) | ((b >> 6) & 0x02)];
+ break;
+ case 4: /* 121 */
+ return ct->palette[((r >> 0) & 0xe0) |
+ ((g >> 3) & 0x1b) | ((b >> 6) & 0x02)];
+ break;
+ case 5: /* 111 */
+ return ct->palette[((r >> 0) & 0xe0) |
+ ((g >> 3) & 0x1b) | ((b >> 6) & 0x02)];
+ break;
+ case 6: /* 1 */
+ return ct->palette[((r >> 0) & 0xe0) |
+ ((g >> 3) & 0x1b) | ((b >> 6) & 0x02)];
+ break;
+ case 7: /* 666 */
+ return ct->palette[((int)(((double)r / 255) * 5.0) * 36) +
+ ((int)(((double)g / 255) * 5.0) * 6) +
+ ((int)(((double)b / 255) * 5.0))];
+ break;
+ default:
+ return 0;
+ }
}
else
{
- unsigned int rm, gm, bm;
- int i, rshift, gshift, bshift;
- DATA32 val;
-
- rm = v->red_mask;
- gm = v->green_mask;
- bm = v->blue_mask;
- if ((rm == 0xf800) && (gm == 0x7e0) && (bm == 0x1f)) /* 565 */
- {
- return (((r << 8) & 0xf800) |
- ((g << 3) & 0x07e0) |
- ((b >> 3) & 0x001f));
- }
- if ((rm == 0xff0000) && (gm == 0xff00) && (bm == 0xff)) /* 888 */
- {
- return (((r << 16) & 0xff0000) |
- ((g << 8 ) & 0x00ff00) |
- ((r ) & 0x0000ff));
- }
- if ((rm == 0x7c00) && (gm == 0x3e0) && (bm == 0x1f)) /* 555 */
- {
- return (((r << 7) & 0x7c00) |
- ((g << 2) & 0x03e0) |
- ((b >> 3) & 0x001f));
- }
- for (i = 31; i >= 0; i--)
- {
- if (rm >= (1 << i))
- {
- rshift = i - 7;
- break;
- }
- }
- for (i = 31; i >= 0; i--)
- {
- if (gm >= (1 << i))
- {
- gshift = i - 7;
- break;
- }
- }
- for (i = 31; i >= 0; i--)
- {
- if (bm >= (1 << i))
- {
- bshift = i - 7;
- break;
- }
- }
- if (rshift >= 0) val = ((r << rshift) & rm);
- else val = ((r >> (-rshift)) & rm);
- if (gshift >= 0) val |= ((g << gshift) & gm);
- else val |= ((g >> (-gshift)) & gm);
- if (bshift >= 0) val |= ((b << bshift) & bm);
- else val |= ((b >> (-bshift)) & bm);
- return val;
+ unsigned int rm, gm, bm;
+ int i, rshift, gshift, bshift;
+ DATA32 val;
+
+ rm = v->red_mask;
+ gm = v->green_mask;
+ bm = v->blue_mask;
+ if ((rm == 0xf800) && (gm == 0x7e0) && (bm == 0x1f)) /* 565 */
+ {
+ return (((r << 8) & 0xf800) |
+ ((g << 3) & 0x07e0) | ((b >> 3) & 0x001f));
+ }
+ if ((rm == 0xff0000) && (gm == 0xff00) && (bm == 0xff)) /* 888 */
+ {
+ return (((r << 16) & 0xff0000) |
+ ((g << 8) & 0x00ff00) | ((r) & 0x0000ff));
+ }
+ if ((rm == 0x7c00) && (gm == 0x3e0) && (bm == 0x1f)) /* 555 */
+ {
+ return (((r << 7) & 0x7c00) |
+ ((g << 2) & 0x03e0) | ((b >> 3) & 0x001f));
+ }
+ for (i = 31; i >= 0; i--)
+ {
+ if (rm >= (1 << i))
+ {
+ rshift = i - 7;
+ break;
+ }
+ }
+ for (i = 31; i >= 0; i--)
+ {
+ if (gm >= (1 << i))
+ {
+ gshift = i - 7;
+ break;
+ }
+ }
+ for (i = 31; i >= 0; i--)
+ {
+ if (bm >= (1 << i))
+ {
+ bshift = i - 7;
+ break;
+ }
+ }
+ if (rshift >= 0)
+ val = ((r << rshift) & rm);
+ else
+ val = ((r >> (-rshift)) & rm);
+ if (gshift >= 0)
+ val |= ((g << gshift) & gm);
+ else
+ val |= ((g >> (-gshift)) & gm);
+ if (bshift >= 0)
+ val |= ((b << bshift) & bm);
+ else
+ val |= ((b >> (-bshift)) & bm);
+ return val;
}
return 0;
}
void
-__imlib_generic_render(DATA32 *src, int jump, int w, int h, int dx, int dy,
- XImage *xim, Visual *v, Context *ct);
+ __imlib_generic_render(DATA32 * src, int jump, int w, int h, int dx, int dy,
+ XImage * xim, Visual * v,
+ Context * ct);
void
-__imlib_generic_render(DATA32 *src, int jump, int w, int h, int dx, int dy,
- XImage *xim, Visual *v, Context *ct)
+__imlib_generic_render(DATA32 * src, int jump, int w, int h, int dx, int dy,
+ XImage * xim, Visual * v, Context * ct)
{
- unsigned int x, y, r, g, b, val, hh;
- unsigned int rmask, gmask, bmask;
- int i, rshift, gshift, bshift;
- const DATA8 _dither_88[8][8] =
- {
- { 0, 32, 8, 40, 2, 34, 10, 42 },
- { 48, 16, 56, 24, 50, 18, 58, 26 },
- { 12, 44, 4, 36, 14, 46, 6, 38 },
- { 60, 28, 52, 20, 62, 30, 54, 22 },
- { 3, 35, 11, 43, 1, 33, 9, 41 },
- { 51, 19, 59, 27, 49, 17, 57, 25 },
- { 15, 47, 7, 39, 13, 45, 5, 37 },
- { 63, 31, 55, 23, 61, 29, 53, 21 }
- };
+ unsigned int x, y, r, g, b, val, hh;
+ unsigned int rmask, gmask, bmask;
+ int i, rshift, gshift, bshift;
+ const DATA8 _dither_88[8][8] = {
+ {0, 32, 8, 40, 2, 34, 10, 42},
+ {48, 16, 56, 24, 50, 18, 58, 26},
+ {12, 44, 4, 36, 14, 46, 6, 38},
+ {60, 28, 52, 20, 62, 30, 54, 22},
+ {3, 35, 11, 43, 1, 33, 9, 41},
+ {51, 19, 59, 27, 49, 17, 57, 25},
+ {15, 47, 7, 39, 13, 45, 5, 37},
+ {63, 31, 55, 23, 61, 29, 53, 21}
+ };
if (xim->depth == 1)
{
- hh = dy + h;
- for (y = dy; y < hh; y++)
- {
- for (x = dx; x < w; x++)
- {
- r = R_VAL(src);
- g = G_VAL(src);
- b = B_VAL(src);
- val = (R_VAL(src) + G_VAL(src) + B_VAL(src)) / 12;
- if (val > _dither_88[x & 0x3][y & 0x3]) val = ct->palette[1];
- else val = ct->palette[0];
- XPutPixel(xim, x, y, val);
- src++;
- }
- }
- return;
+ hh = dy + h;
+ for (y = dy; y < hh; y++)
+ {
+ for (x = dx; x < w; x++)
+ {
+ r = R_VAL(src);
+ g = G_VAL(src);
+ b = B_VAL(src);
+ val = (R_VAL(src) + G_VAL(src) + B_VAL(src)) / 12;
+ if (val > _dither_88[x & 0x3][y & 0x3])
+ val = ct->palette[1];
+ else
+ val = ct->palette[0];
+ XPutPixel(xim, x, y, val);
+ src++;
+ }
+ }
+ return;
}
rmask = xim->red_mask;
gmask = xim->green_mask;
@@ -187,82 +187,82 @@ __imlib_generic_render(DATA32 *src, int jump, int w, int h, int dx, int dy,
bshift = 0;
for (i = 31; i >= 0; i--)
{
- if (rmask >= (1 << i))
- {
- rshift = i - 7;
- break;
- }
+ if (rmask >= (1 << i))
+ {
+ rshift = i - 7;
+ break;
+ }
}
for (i = 31; i >= 0; i--)
{
- if (gmask >= (1 << i))
- {
- gshift = i - 7;
- break;
- }
+ if (gmask >= (1 << i))
+ {
+ gshift = i - 7;
+ break;
+ }
}
for (i = 31; i >= 0; i--)
{
- if (bmask >= (1 << i))
- {
- bshift = i - 7;
- break;
- }
+ if (bmask >= (1 << i))
+ {
+ bshift = i - 7;
+ break;
+ }
}
hh = dy + h;
for (y = dy; y < hh; y++)
{
- for (x = dx; x < w; x++)
- {
- r = R_VAL(src);
- if (rshift >= 0)
- val = ((r << rshift) & rmask);
- else
- val = ((r >> (-rshift)) & rmask);
- g = G_VAL(src);
- if (gshift >= 0)
- val |= ((g << gshift) & gmask);
- else
- val |= ((g >> (-gshift)) & gmask);
- b = B_VAL(src);
- if (bshift >= 0)
- val |= ((b << bshift) & bmask);
- else
- val |= ((b >> (-bshift)) & bmask);
- XPutPixel(xim, x, y, val);
- src++;
- }
+ for (x = dx; x < w; x++)
+ {
+ r = R_VAL(src);
+ if (rshift >= 0)
+ val = ((r << rshift) & rmask);
+ else
+ val = ((r >> (-rshift)) & rmask);
+ g = G_VAL(src);
+ if (gshift >= 0)
+ val |= ((g << gshift) & gmask);
+ else
+ val |= ((g >> (-gshift)) & gmask);
+ b = B_VAL(src);
+ if (bshift >= 0)
+ val |= ((b << bshift) & bmask);
+ else
+ val |= ((b >> (-bshift)) & bmask);
+ XPutPixel(xim, x, y, val);
+ src++;
+ }
}
}
void
-__imlib_RenderImage(Display *d, ImlibImage *im,
- Drawable w, Drawable m,
- Visual *v, Colormap cm, int depth,
- int sx, int sy, int sw, int sh,
- int dx, int dy, int dw, int dh,
- char antialias, char hiq, char blend, char dither_mask,
- ImlibColorModifier *cmod, ImlibOp op)
+__imlib_RenderImage(Display * d, ImlibImage * im,
+ Drawable w, Drawable m,
+ Visual * v, Colormap cm, int depth,
+ int sx, int sy, int sw, int sh,
+ int dx, int dy, int dw, int dh,
+ char antialias, char hiq, char blend, char dither_mask,
+ ImlibColorModifier * cmod, ImlibOp op)
{
- XImage *xim = NULL, *mxim = NULL;
- Context *ct;
- DATA32 *buf = NULL, *pointer = NULL, *back = NULL;
- int y, h, hh, jump;
- static Display *disp = NULL;
- static GC gc = 0;
- static GC gcm = 0;
- XGCValues gcv;
- ImlibScaleInfo *scaleinfo = NULL;
- int psx, psy, psw, psh;
- int actual_depth = 0;
- char shm = 0;
- ImlibRGBAFunction rgbaer, masker = NULL;
- ImlibBlendFunction blender = NULL;
- int do_mmx;
+ XImage *xim = NULL, *mxim = NULL;
+ Context *ct;
+ DATA32 *buf = NULL, *pointer = NULL, *back = NULL;
+ int y, h, hh, jump;
+ static Display *disp = NULL;
+ static GC gc = 0;
+ static GC gcm = 0;
+ XGCValues gcv;
+ ImlibScaleInfo *scaleinfo = NULL;
+ int psx, psy, psw, psh;
+ int actual_depth = 0;
+ char shm = 0;
+ ImlibRGBAFunction rgbaer, masker = NULL;
+ ImlibBlendFunction blender = NULL;
+ int do_mmx;
blender = __imlib_GetBlendFunction(op, 1, 0,
- (!(im->flags & F_HAS_ALPHA)), NULL);
-
+ (!(im->flags & F_HAS_ALPHA)), NULL);
+
/* dont do anything if we have a 0 widht or height image to render */
if ((dw == 0) || (dh == 0))
return;
@@ -300,191 +300,203 @@ __imlib_RenderImage(Display *d, ImlibImage *im,
/* if we are scaling the image at all make a scaling buffer */
if (!((sw == dw) && (sh == dh)))
{
- scaleinfo = __imlib_CalcScaleInfo(im, sw, sh, dw, dh, antialias);
- if (!scaleinfo) return;
+ scaleinfo = __imlib_CalcScaleInfo(im, sw, sh, dw, dh, antialias);
+ if (!scaleinfo)
+ return;
}
/* Sign not needed anymore */
- dw = abs(dw); dh = abs(dh);
+ dw = abs(dw);
+ dh = abs(dh);
ct = __imlib_GetContext(d, v, cm, depth);
actual_depth = depth;
if (depth == 16)
actual_depth = __imlib_XActualDepth(d, v);
- __imlib_RGBASetupContext(ct);
+ __imlib_RGBASetupContext(ct);
if ((blend) && (IMAGE_HAS_ALPHA(im)))
{
- back = malloc(dw *dh *sizeof(DATA32));
- if (!__imlib_GrabDrawableToRGBA(back, 0, 0, dw, dh, d, w, 0, v, cm, depth, dx, dy, dw, dh, 0, 1))
- {
- free(back);
- back = NULL;
- }
+ back = malloc(dw * dh * sizeof(DATA32));
+ if (!__imlib_GrabDrawableToRGBA
+ (back, 0, 0, dw, dh, d, w, 0, v, cm, depth, dx, dy, dw, dh, 0, 1))
+ {
+ free(back);
+ back = NULL;
+ }
}
/* get a new XImage - or get one from the cached list */
xim = __imlib_ProduceXImage(d, v, depth, dw, dh, &shm);
if (!xim)
{
- __imlib_FreeScaleInfo(scaleinfo);
- if (back) free(back);
- return;
+ __imlib_FreeScaleInfo(scaleinfo);
+ if (back)
+ free(back);
+ return;
}
/* do a double check in 24/32bpp */
if ((xim->bits_per_pixel == 32) && (depth == 24))
actual_depth = 32;
if (m)
{
- mxim = __imlib_ProduceXImage(d, v, 1, dw, dh, &shm);
- if (!mxim)
- {
- __imlib_ConsumeXImage(d, xim);
- __imlib_FreeScaleInfo(scaleinfo);
- if (back) free(back);
- return;
- }
- memset(mxim->data, 0, mxim->bytes_per_line * mxim->height);
+ mxim = __imlib_ProduceXImage(d, v, 1, dw, dh, &shm);
+ if (!mxim)
+ {
+ __imlib_ConsumeXImage(d, xim);
+ __imlib_FreeScaleInfo(scaleinfo);
+ if (back)
+ free(back);
+ return;
+ }
+ memset(mxim->data, 0, mxim->bytes_per_line * mxim->height);
}
/* if we are scaling the image at all make a scaling buffer */
if (scaleinfo)
{
- /* allocate a buffer to render scaled RGBA data into */
- buf = malloc(dw * LINESIZE * sizeof(DATA32));
- if (!buf)
- {
- __imlib_ConsumeXImage(d, xim);
- if (m)
- __imlib_ConsumeXImage(d, mxim);
- __imlib_FreeScaleInfo(scaleinfo);
- if (back) free(back);
- return;
- }
+ /* allocate a buffer to render scaled RGBA data into */
+ buf = malloc(dw * LINESIZE * sizeof(DATA32));
+ if (!buf)
+ {
+ __imlib_ConsumeXImage(d, xim);
+ if (m)
+ __imlib_ConsumeXImage(d, mxim);
+ __imlib_FreeScaleInfo(scaleinfo);
+ if (back)
+ free(back);
+ return;
+ }
}
/* setup h */
h = dh;
- /* scale in LINESIZE Y chunks and convert to depth*/
+ /* scale in LINESIZE Y chunks and convert to depth */
/* Get rgba and mask functions for XImage rendering */
- rgbaer = __imlib_GetRGBAFunction(xim->bits_per_pixel,
- v->red_mask, v->green_mask, v->blue_mask,
- hiq, ct->palette_type);
- if (m) masker = __imlib_GetMaskFunction(dither_mask);
+ rgbaer = __imlib_GetRGBAFunction(xim->bits_per_pixel,
+ v->red_mask, v->green_mask, v->blue_mask,
+ hiq, ct->palette_type);
+ if (m)
+ masker = __imlib_GetMaskFunction(dither_mask);
#ifdef DO_MMX_ASM
do_mmx = __imlib_get_cpuid() & CPUID_MMX;
#endif
for (y = 0; y < dh; y += LINESIZE)
{
- hh = LINESIZE;
- if (h < LINESIZE)
- hh = h;
- /* if we're scaling it */
- if (scaleinfo)
- {
- /* scale the imagedata for this LINESIZE lines chunk of image data */
- if (antialias)
- {
+ hh = LINESIZE;
+ if (h < LINESIZE)
+ hh = h;
+ /* if we're scaling it */
+ if (scaleinfo)
+ {
+ /* scale the imagedata for this LINESIZE lines chunk of image data */
+ if (antialias)
+ {
#ifdef DO_MMX_ASM
- if (do_mmx)
- __imlib_Scale_mmx_AARGBA(scaleinfo, buf,
- ((sx * dw) / sw),
- ((sy * dh) / sh) + y,
- 0, 0, dw, hh, dw, im->w);
- else
+ if (do_mmx)
+ __imlib_Scale_mmx_AARGBA(scaleinfo, buf,
+ ((sx * dw) / sw),
+ ((sy * dh) / sh) + y,
+ 0, 0, dw, hh, dw, im->w);
+ else
#endif
- if (IMAGE_HAS_ALPHA(im))
- __imlib_ScaleAARGBA(scaleinfo, buf, ((sx * dw) / sw),
- ((sy * dh) / sh) + y,
- 0, 0, dw, hh, dw, im->w);
- else
- __imlib_ScaleAARGB(scaleinfo, buf, ((sx * dw) / sw),
- ((sy * dh) / sh) + y,
- 0, 0, dw, hh, dw, im->w);
- }
- else
- __imlib_ScaleSampleRGBA(scaleinfo, buf, ((sx * dw) / sw),
- ((sy * dh) / sh) + y,
- 0, 0, dw, hh, dw);
- jump = 0;
- pointer = buf;
- if (cmod)
- __imlib_DataCmodApply(buf, dw, hh, 0, NULL, cmod);
- }
- else
- {
- if (cmod)
- {
- if (!buf)
- buf = malloc(im->w * LINESIZE * sizeof(DATA32));
- if (!buf)
- {
- __imlib_ConsumeXImage(d, xim);
- if (m)
- __imlib_ConsumeXImage(d, mxim);
- __imlib_FreeScaleInfo(scaleinfo);
- if (back) free(back);
- return;
- }
- memcpy(buf, im->data + ((y + sy) * im->w) + sx,
- im->w * hh * sizeof(DATA32));
- __imlib_DataCmodApply(buf, dw, hh, im->w - dw, NULL, cmod);
- pointer = buf;
- jump = 0;
- }
- else
- {
- jump = im->w - sw;
- pointer = im->data + ((y + sy) * im->w) + sx;
- }
- }
- /* if we have a back buffer - we're blending to the bg */
- if (back)
- {
- blender(pointer, jump + dw, back + (y * dw), dw, dw, hh, NULL);
- pointer = back + (y * dw);
- jump = 0;
- }
- /* once scaled... convert chunk to bit depth into XImage bufer */
- if (rgbaer)
- rgbaer(pointer, jump,
- ((DATA8 *)xim->data) + (y * (xim->bytes_per_line)),
- xim->bytes_per_line, dw, hh, dx, dy + y);
- else
- __imlib_generic_render(pointer, jump, dw, hh, 0, y, xim, v, ct);
- if (m)
- masker(pointer, jump,
- ((DATA8 *)mxim->data) + (y * (mxim->bytes_per_line)),
- mxim->bytes_per_line, dw, hh, dx, dy + y);
- h -= LINESIZE;
+ if (IMAGE_HAS_ALPHA(im))
+ __imlib_ScaleAARGBA(scaleinfo, buf, ((sx * dw) / sw),
+ ((sy * dh) / sh) + y,
+ 0, 0, dw, hh, dw, im->w);
+ else
+ __imlib_ScaleAARGB(scaleinfo, buf, ((sx * dw) / sw),
+ ((sy * dh) / sh) + y,
+ 0, 0, dw, hh, dw, im->w);
+ }
+ else
+ __imlib_ScaleSampleRGBA(scaleinfo, buf, ((sx * dw) / sw),
+ ((sy * dh) / sh) + y, 0, 0, dw, hh, dw);
+ jump = 0;
+ pointer = buf;
+ if (cmod)
+ __imlib_DataCmodApply(buf, dw, hh, 0, NULL, cmod);
+ }
+ else
+ {
+ if (cmod)
+ {
+ if (!buf)
+ buf = malloc(im->w * LINESIZE * sizeof(DATA32));
+ if (!buf)
+ {
+ __imlib_ConsumeXImage(d, xim);
+ if (m)
+ __imlib_ConsumeXImage(d, mxim);
+ __imlib_FreeScaleInfo(scaleinfo);
+ if (back)
+ free(back);
+ return;
+ }
+ memcpy(buf, im->data + ((y + sy) * im->w) + sx,
+ im->w * hh * sizeof(DATA32));
+ __imlib_DataCmodApply(buf, dw, hh, im->w - dw, NULL, cmod);
+ pointer = buf;
+ jump = 0;
+ }
+ else
+ {
+ jump = im->w - sw;
+ pointer = im->data + ((y + sy) * im->w) + sx;
+ }
+ }
+ /* if we have a back buffer - we're blending to the bg */
+ if (back)
+ {
+ blender(pointer, jump + dw, back + (y * dw), dw, dw, hh, NULL);
+ pointer = back + (y * dw);
+ jump = 0;
+ }
+ /* once scaled... convert chunk to bit depth into XImage bufer */
+ if (rgbaer)
+ rgbaer(pointer, jump,
+ ((DATA8 *) xim->data) + (y * (xim->bytes_per_line)),
+ xim->bytes_per_line, dw, hh, dx, dy + y);
+ else
+ __imlib_generic_render(pointer, jump, dw, hh, 0, y, xim, v, ct);
+ if (m)
+ masker(pointer, jump,
+ ((DATA8 *) mxim->data) + (y * (mxim->bytes_per_line)),
+ mxim->bytes_per_line, dw, hh, dx, dy + y);
+ h -= LINESIZE;
}
/* free up our buffers and poit tables */
- if (buf) free(buf);
- if (scaleinfo) __imlib_FreeScaleInfo(scaleinfo);
- if (back) free(back);
+ if (buf)
+ free(buf);
+ if (scaleinfo)
+ __imlib_FreeScaleInfo(scaleinfo);
+ if (back)
+ free(back);
/* if we changed diplays since last time... free old gc's */
if (disp != d)
{
- if (gc) XFreeGC(disp, gc);
- if (gcm) XFreeGC(disp, gcm);
- gc = 0;
- gcm = 0;
+ if (gc)
+ XFreeGC(disp, gc);
+ if (gcm)
+ XFreeGC(disp, gcm);
+ gc = 0;
+ gcm = 0;
}
/* if we didnt have a gc... create it */
if (!gc)
{
- disp = d;
- gcv.graphics_exposures = False;
- gc = XCreateGC(d, w, GCGraphicsExposures, &gcv);
+ disp = d;
+ gcv.graphics_exposures = False;
+ gc = XCreateGC(d, w, GCGraphicsExposures, &gcv);
}
if (m)
{
- if (!gcm)
- {
- gcv.graphics_exposures = False;
- gcm = XCreateGC(d, m, GCGraphicsExposures, &gcv);
- }
- /* write the mask */
- if (shm)
- /* write shm XImage */
- XShmPutImage(d, m, gcm, mxim, 0, 0, dx, dy, dw, dh, False);
- /* write regular XImage */
- else
- XPutImage(d, m, gcm, mxim, 0, 0, dx, dy, dw, dh);
+ if (!gcm)
+ {
+ gcv.graphics_exposures = False;
+ gcm = XCreateGC(d, m, GCGraphicsExposures, &gcv);
+ }
+ /* write the mask */
+ if (shm)
+ /* write shm XImage */
+ XShmPutImage(d, m, gcm, mxim, 0, 0, dx, dy, dw, dh, False);
+ /* write regular XImage */
+ else
+ XPutImage(d, m, gcm, mxim, 0, 0, dx, dy, dw, dh);
}
/* write the image */
if (shm)
@@ -499,54 +511,68 @@ __imlib_RenderImage(Display *d, ImlibImage *im,
XSync(d, False);
__imlib_ConsumeXImage(d, xim);
if (m)
- __imlib_ConsumeXImage(d, mxim);
+ __imlib_ConsumeXImage(d, mxim);
}
void
-__imlib_RenderImageSkewed(Display *d, ImlibImage *im, Drawable w, Drawable m,
- Visual *v, Colormap cm, int depth,
- int sx, int sy, int sw, int sh, int dx, int dy,
- int hsx, int hsy, int vsx, int vsy,
- char antialias, char hiq, char blend,
- char dither_mask, ImlibColorModifier *cmod,
- ImlibOp op)
+__imlib_RenderImageSkewed(Display * d, ImlibImage * im, Drawable w, Drawable m,
+ Visual * v, Colormap cm, int depth,
+ int sx, int sy, int sw, int sh, int dx, int dy,
+ int hsx, int hsy, int vsx, int vsy,
+ char antialias, char hiq, char blend,
+ char dither_mask, ImlibColorModifier * cmod,
+ ImlibOp op)
{
- Context *ct;
- int dx1, dy1, dx2, dy2, dw, dh, tsx, tsy;
- ImlibImage *back;
+ Context *ct;
+ int dx1, dy1, dx2, dy2, dw, dh, tsx, tsy;
+ ImlibImage *back;
dx1 = dx2 = dx;
dy1 = dy2 = dy;
- if (hsx < 0) dx1 += hsx;
- else dx2 += hsx;
- if (hsy < 0) dy1 += hsy;
- else dy2 += hsy;
- tsx = vsx; tsy = vsy;
- if (!tsx && !tsy) {
- tsy = (hsx * im->h) / im->w;
- tsx = -(hsy * im->h) / im->w;
- }
- if (tsx < 0) dx1 += tsx;
- else dx2 += tsx;
- if (tsy < 0) dy1 += tsy;
- else dy2 += tsy;
+ if (hsx < 0)
+ dx1 += hsx;
+ else
+ dx2 += hsx;
+ if (hsy < 0)
+ dy1 += hsy;
+ else
+ dy2 += hsy;
+ tsx = vsx;
+ tsy = vsy;
+ if (!tsx && !tsy)
+ {
+ tsy = (hsx * im->h) / im->w;
+ tsx = -(hsy * im->h) / im->w;
+ }
+ if (tsx < 0)
+ dx1 += tsx;
+ else
+ dx2 += tsx;
+ if (tsy < 0)
+ dy1 += tsy;
+ else
+ dy2 += tsy;
- if ((dx2 < 0) || (dy2 < 0)) return;
+ if ((dx2 < 0) || (dy2 < 0))
+ return;
dw = dx2 - dx1;
dh = dy2 - dy1;
- if ((dw <= 0) || (dh <= 0)) return;
+ if ((dw <= 0) || (dh <= 0))
+ return;
- if (dx1 < 0) {
- dw += dx1;
- dx1 = 0;
- }
- if (dy1 < 0) {
- dh += dy1;
- dy1 = 0;
- }
+ if (dx1 < 0)
+ {
+ dw += dx1;
+ dx1 = 0;
+ }
+ if (dy1 < 0)
+ {
+ dh += dy1;
+ dy1 = 0;
+ }
ct = __imlib_GetContext(d, v, cm, depth);
@@ -554,13 +580,13 @@ __imlib_RenderImageSkewed(Display *d, ImlibImage *im, Drawable w, Drawable m,
back->data = malloc(dw * dh * sizeof(DATA32));
memset(back->data, 0, dw * dh * sizeof(DATA32));
__imlib_GrabDrawableToRGBA(back->data, 0, 0, dw, dh, d, w, 0, v, cm,
- depth, dx1, dy1, dw, dh, 0, 1);
+ depth, dx1, dy1, dw, dh, 0, 1);
__imlib_BlendImageToImageSkewed(im, back, antialias, 1, 0, sx, sy, sw, sh,
- dx - dx1, dy - dy1, hsx, hsy, vsx, vsy,
- cmod, op, 0, 0, 0, 0);
+ dx - dx1, dy - dy1, hsx, hsy, vsx, vsy,
+ cmod, op, 0, 0, 0, 0);
__imlib_RenderImage(d, back, w, m, v, cm, depth, 0, 0, dw, dh,
- dx1, dy1, dw, dh, 0, hiq, 0, dither_mask, 0, OP_COPY);
+ dx1, dy1, dw, dh, 0, hiq, 0, dither_mask, 0, OP_COPY);
__imlib_FreeImage(back);
}
diff --git a/src/rgba.c b/src/rgba.c
index 194a871..7fb651b 100644
--- a/src/rgba.c
+++ b/src/rgba.c
@@ -25,177 +25,943 @@
/* x86: RGBA in byte order = ABGR when read as an int (in register/int) */
/* lookup table to see what color index to use */
-static DATA8 *_dither_color_lut;
-static DATA8 _pal_type;
+static DATA8 *_dither_color_lut;
+static DATA8 _pal_type;
/* using DATA32 - major speedup for aligned memory reads */
/* these data structs global rather than context-based for speed */
-static DATA16 *_dither_r16;
-static DATA16 *_dither_g16;
-static DATA16 *_dither_b16;
-static DATA8 *_dither_r8;
-static DATA8 *_dither_g8;
-static DATA8 *_dither_b8;
-static DATA8 *_dither_666r;
-static DATA8 *_dither_666g;
-static DATA8 *_dither_666b;
-static int dither_a_init = 0;
-static DATA8 _dither_a1[8 * 8 * 256];
+static DATA16 *_dither_r16;
+static DATA16 *_dither_g16;
+static DATA16 *_dither_b16;
+static DATA8 *_dither_r8;
+static DATA8 *_dither_g8;
+static DATA8 *_dither_b8;
+static DATA8 *_dither_666r;
+static DATA8 *_dither_666g;
+static DATA8 *_dither_666b;
+static int dither_a_init = 0;
+static DATA8 _dither_a1[8 * 8 * 256];
/* the famous dither matrix */
-const DATA8 _dither_44[4][4] =
-{
- {0, 4, 1, 5},
- {6, 2, 7, 3},
- {1, 5, 0, 4},
- {7, 3, 6, 2}
+const DATA8 _dither_44[4][4] = {
+ {0, 4, 1, 5},
+ {6, 2, 7, 3},
+ {1, 5, 0, 4},
+ {7, 3, 6, 2}
};
-const DATA8 _dither_88[8][8] =
-{
- { 0, 32, 8, 40, 2, 34, 10, 42 },
- { 48, 16, 56, 24, 50, 18, 58, 26 },
- { 12, 44, 4, 36, 14, 46, 6, 38 },
- { 60, 28, 52, 20, 62, 30, 54, 22 },
- { 3, 35, 11, 43, 1, 33, 9, 41 },
- { 51, 19, 59, 27, 49, 17, 57, 25 },
- { 15, 47, 7, 39, 13, 45, 5, 37 },
- { 63, 31, 55, 23, 61, 29, 53, 21 }
+const DATA8 _dither_88[8][8] = {
+ {0, 32, 8, 40, 2, 34, 10, 42},
+ {48, 16, 56, 24, 50, 18, 58, 26},
+ {12, 44, 4, 36, 14, 46, 6, 38},
+ {60, 28, 52, 20, 62, 30, 54, 22},
+ {3, 35, 11, 43, 1, 33, 9, 41},
+ {51, 19, 59, 27, 49, 17, 57, 25},
+ {15, 47, 7, 39, 13, 45, 5, 37},
+ {63, 31, 55, 23, 61, 29, 53, 21}
};
+
/* This dither table was generated by Raph Levien using patented
* technology (US Patent 5,276,535). The dither table itself is in the
* public domain. */
-const DATA8 _dither_128128[128][128] =
-{
- { 0, 41, 23, 5, 17, 39, 7, 15, 62, 23, 40, 51, 31, 47, 9, 32, 52, 27, 57, 25, 6, 61, 27, 52, 37, 7, 40, 63, 18, 36, 10, 42, 25, 62, 45, 34, 20, 42, 37, 14, 35, 29, 50, 10, 61, 2, 40, 8, 37, 12, 58, 22, 5, 41, 10, 39, 0, 60, 11, 46, 2, 55, 38, 17, 36, 59, 13, 54, 37, 56, 8, 29, 16, 13, 63, 22, 41, 55, 7, 20, 49, 14, 23, 55, 37, 23, 19, 36, 15, 49, 23, 63, 30, 14, 38, 27, 53, 13, 22, 41, 19, 31, 7, 19, 50, 30, 49, 16, 3, 32, 56, 40, 29, 34, 8, 48, 19, 45, 4, 51, 12, 46, 35, 49, 16, 42, 12, 62 },
- { 30, 57, 36, 54, 47, 34, 52, 27, 43, 4, 28, 7, 17, 36, 62, 13, 44, 7, 18, 48, 33, 21, 44, 14, 30, 47, 12, 33, 5, 55, 31, 58, 13, 30, 4, 17, 52, 10, 60, 26, 46, 0, 39, 27, 42, 22, 47, 25, 60, 32, 9, 38, 48, 17, 59, 30, 49, 18, 34, 25, 51, 19, 5, 48, 21, 8, 28, 46, 1, 32, 41, 19, 54, 47, 37, 18, 28, 11, 44, 30, 39, 56, 2, 33, 8, 42, 61, 28, 58, 8, 46, 9, 41, 4, 58, 7, 21, 48, 59, 10, 52, 14, 42, 57, 12, 25, 7, 53, 42, 24, 11, 50, 17, 59, 42, 2, 36, 60, 32, 17, 63, 29, 21, 7, 59, 32, 24, 39 },
- { 22, 8, 16, 32, 3, 25, 13, 57, 18, 45, 58, 39, 55, 20, 5, 42, 23, 34, 63, 1, 51, 10, 58, 4, 60, 23, 53, 27, 44, 21, 3, 48, 8, 50, 43, 54, 27, 32, 5, 55, 21, 58, 12, 53, 6, 36, 14, 50, 17, 29, 53, 15, 24, 52, 7, 36, 13, 42, 4, 53, 9, 35, 61, 26, 56, 32, 49, 15, 62, 23, 6, 60, 2, 31, 4, 48, 58, 38, 15, 61, 5, 25, 47, 28, 50, 15, 7, 40, 3, 32, 33, 52, 25, 50, 35, 42, 61, 3, 28, 36, 23, 63, 4, 33, 46, 62, 36, 23, 60, 6, 54, 28, 4, 37, 23, 55, 25, 8, 42, 54, 14, 6, 56, 38, 19, 52, 4, 46 },
- { 48, 53, 43, 12, 45, 63, 30, 37, 9, 34, 21, 1, 25, 47, 29, 58, 3, 54, 15, 39, 29, 17, 38, 35, 20, 43, 1, 49, 15, 59, 29, 39, 22, 35, 16, 23, 1, 47, 39, 18, 8, 44, 25, 31, 57, 19, 63, 4, 45, 3, 42, 61, 1, 31, 45, 20, 57, 29, 62, 21, 32, 41, 14, 44, 3, 39, 5, 34, 10, 43, 51, 35, 23, 52, 40, 10, 21, 1, 53, 18, 51, 43, 12, 62, 18, 54, 26, 51, 20, 57, 14, 1, 62, 16, 11, 18, 32, 39, 17, 44, 1, 48, 26, 37, 18, 2, 51, 14, 28, 45, 35, 18, 57, 13, 47, 11, 51, 20, 2, 39, 31, 47, 25, 1, 50, 11, 60, 7 },
- { 18, 28, 1, 56, 21, 10, 51, 2, 46, 54, 14, 61, 11, 50, 13, 38, 19, 31, 45, 9, 55, 24, 47, 5, 54, 9, 62, 11, 35, 8, 51, 14, 57, 6, 63, 40, 58, 14, 51, 28, 62, 34, 15, 48, 1, 41, 30, 35, 55, 21, 34, 11, 49, 37, 8, 52, 4, 23, 15, 43, 1, 58, 11, 23, 53, 16, 55, 26, 58, 18, 27, 12, 45, 14, 25, 63, 42, 33, 27, 35, 9, 31, 21, 38, 1, 44, 34, 12, 48, 38, 21, 44, 29, 47, 26, 53, 1, 46, 54, 8, 59, 29, 11, 55, 22, 41, 33, 20, 39, 1, 48, 9, 44, 32, 5, 62, 29, 44, 57, 23, 10, 58, 34, 43, 15, 37, 26, 33 },
- { 51, 38, 59, 24, 35, 42, 19, 60, 5, 32, 41, 26, 43, 33, 7, 53, 48, 11, 59, 23, 42, 2, 61, 30, 16, 40, 32, 24, 56, 41, 19, 33, 37, 26, 47, 9, 31, 22, 2, 45, 9, 54, 4, 37, 21, 52, 11, 23, 7, 57, 16, 25, 55, 18, 63, 27, 46, 39, 56, 10, 50, 37, 29, 47, 19, 63, 24, 9, 46, 2, 39, 60, 9, 57, 30, 7, 49, 11, 59, 3, 45, 57, 5, 60, 29, 22, 5, 60, 30, 9, 59, 18, 40, 6, 57, 36, 30, 12, 24, 34, 15, 40, 52, 6, 49, 9, 58, 4, 63, 12, 26, 61, 22, 53, 38, 16, 35, 14, 28, 50, 42, 17, 5, 28, 62, 20, 54, 12 },
- { 26, 6, 31, 15, 49, 6, 38, 27, 22, 49, 16, 56, 2, 62, 30, 21, 0, 36, 28, 6, 49, 32, 13, 52, 26, 50, 19, 46, 3, 26, 62, 0, 53, 12, 29, 3, 53, 41, 60, 24, 38, 13, 58, 16, 43, 9, 59, 39, 46, 28, 44, 40, 2, 33, 13, 41, 16, 6, 47, 31, 26, 17, 57, 6, 38, 0, 42, 36, 29, 52, 20, 31, 48, 0, 34, 56, 20, 36, 23, 54, 14, 41, 24, 37, 10, 55, 46, 25, 16, 45, 36, 4, 55, 23, 15, 8, 50, 62, 5, 56, 44, 20, 13, 28, 59, 31, 24, 47, 31, 52, 37, 17, 40, 0, 26, 49, 3, 60, 7, 33, 0, 61, 53, 40, 8, 45, 2, 41 },
- { 16, 63, 43, 4, 61, 24, 56, 13, 53, 8, 36, 12, 24, 41, 16, 46, 60, 26, 52, 39, 14, 57, 21, 37, 0, 45, 7, 59, 38, 17, 43, 10, 45, 20, 61, 43, 19, 11, 33, 17, 50, 32, 23, 61, 28, 49, 26, 0, 18, 51, 5, 60, 22, 58, 29, 0, 59, 34, 19, 62, 3, 52, 7, 44, 30, 59, 13, 50, 15, 62, 7, 17, 38, 22, 44, 15, 40, 4, 47, 28, 33, 17, 49, 16, 51, 40, 10, 56, 0, 53, 13, 49, 28, 38, 60, 21, 43, 19, 37, 27, 3, 51, 34, 39, 0, 45, 15, 43, 10, 21, 3, 55, 8, 33, 59, 10, 41, 18, 52, 24, 46, 20, 30, 13, 58, 22, 36, 57 },
- { 50, 34, 11, 47, 29, 17, 44, 0, 33, 63, 28, 46, 52, 5, 57, 10, 42, 18, 4, 63, 20, 8, 44, 10, 56, 34, 14, 29, 5, 54, 23, 59, 32, 49, 7, 34, 49, 27, 56, 0, 42, 7, 46, 3, 40, 6, 54, 32, 62, 13, 36, 10, 47, 8, 35, 49, 24, 51, 12, 40, 22, 35, 60, 12, 22, 51, 33, 4, 40, 25, 43, 55, 5, 54, 12, 61, 26, 51, 8, 62, 0, 53, 7, 63, 2, 32, 19, 34, 42, 24, 31, 63, 2, 10, 45, 33, 0, 48, 9, 61, 22, 47, 8, 62, 18, 56, 7, 54, 27, 57, 46, 30, 50, 19, 45, 30, 56, 36, 22, 47, 11, 38, 3, 51, 32, 48, 18, 9 },
- { 0, 21, 40, 19, 52, 9, 37, 48, 20, 40, 3, 18, 27, 38, 35, 22, 31, 56, 13, 35, 46, 28, 60, 40, 27, 18, 61, 50, 41, 30, 7, 36, 2, 25, 16, 57, 5, 15, 47, 29, 55, 19, 30, 52, 15, 34, 20, 12, 43, 30, 20, 54, 25, 44, 53, 12, 38, 5, 55, 27, 48, 15, 33, 27, 45, 8, 19, 28, 56, 11, 33, 49, 18, 36, 29, 2, 45, 16, 39, 19, 31, 43, 27, 35, 20, 52, 26, 6, 61, 11, 41, 17, 29, 51, 20, 56, 25, 32, 41, 17, 53, 31, 25, 14, 42, 23, 35, 16, 38, 6, 34, 12, 15, 62, 6, 21, 13, 1, 63, 9, 55, 27, 43, 25, 14, 4, 31, 55 },
- { 44, 29, 61, 2, 35, 58, 26, 15, 60, 10, 51, 59, 14, 55, 8, 50, 2, 44, 25, 51, 1, 33, 16, 4, 48, 36, 2, 21, 12, 57, 48, 13, 51, 55, 40, 28, 37, 62, 8, 39, 12, 63, 36, 10, 59, 24, 56, 47, 9, 50, 41, 1, 32, 17, 6, 21, 61, 30, 9, 43, 1, 54, 41, 2, 54, 37, 48, 61, 1, 46, 21, 3, 58, 24, 50, 32, 60, 10, 57, 25, 46, 12, 59, 4, 45, 13, 57, 47, 27, 39, 5, 58, 47, 14, 35, 4, 52, 13, 60, 6, 36, 10, 45, 55, 4, 50, 29, 2, 61, 50, 25, 58, 44, 24, 36, 42, 54, 28, 40, 32, 16, 56, 6, 62, 46, 39, 60, 23 },
- { 7, 48, 14, 54, 23, 40, 4, 45, 30, 22, 42, 32, 1, 44, 20, 29, 58, 8, 37, 19, 41, 54, 24, 58, 9, 53, 25, 46, 34, 16, 23, 38, 27, 11, 18, 1, 52, 21, 35, 22, 48, 5, 25, 45, 18, 38, 2, 27, 35, 4, 57, 15, 62, 39, 57, 28, 42, 16, 36, 60, 24, 18, 10, 63, 20, 5, 16, 23, 37, 14, 59, 27, 41, 8, 13, 42, 21, 35, 6, 50, 3, 38, 15, 48, 30, 39, 17, 3, 49, 14, 53, 33, 24, 7, 61, 44, 11, 39, 23, 49, 19, 58, 1, 32, 36, 12, 60, 41, 20, 13, 41, 4, 39, 1, 48, 8, 18, 51, 14, 44, 5, 37, 21, 34, 1, 26, 10, 37 },
- { 53, 36, 27, 9, 50, 12, 32, 55, 2, 57, 7, 17, 48, 34, 63, 15, 40, 26, 62, 11, 49, 6, 31, 39, 22, 42, 6, 63, 1, 39, 60, 4, 42, 61, 32, 45, 24, 44, 2, 60, 16, 41, 53, 1, 33, 61, 49, 17, 63, 23, 45, 26, 33, 3, 23, 46, 2, 50, 20, 4, 45, 34, 49, 30, 39, 58, 44, 31, 53, 34, 6, 52, 30, 47, 63, 1, 53, 22, 42, 31, 58, 23, 54, 22, 61, 8, 36, 59, 22, 35, 21, 1, 55, 40, 27, 16, 30, 54, 2, 29, 43, 16, 39, 63, 21, 46, 26, 10, 48, 32, 19, 53, 30, 56, 26, 60, 33, 4, 61, 23, 49, 59, 15, 53, 19, 58, 42, 16 },
- { 20, 5, 59, 46, 25, 62, 7, 19, 43, 25, 37, 61, 11, 24, 4, 54, 12, 52, 3, 32, 17, 61, 12, 47, 15, 55, 18, 31, 53, 28, 9, 50, 21, 6, 55, 9, 58, 14, 54, 26, 33, 7, 31, 58, 13, 21, 8, 42, 29, 6, 37, 11, 48, 52, 14, 60, 11, 39, 56, 32, 14, 58, 7, 26, 17, 4, 42, 8, 11, 47, 19, 38, 10, 17, 26, 37, 9, 55, 28, 13, 18, 40, 6, 33, 1, 43, 25, 11, 51, 7, 62, 43, 18, 37, 3, 57, 45, 9, 38, 58, 5, 52, 27, 7, 17, 53, 5, 57, 37, 2, 63, 9, 22, 15, 11, 38, 25, 45, 35, 0, 28, 10, 41, 30, 50, 8, 31, 57 },
- { 49, 33, 16, 38, 1, 42, 51, 34, 53, 14, 28, 49, 30, 56, 36, 23, 43, 20, 38, 56, 22, 45, 28, 0, 62, 35, 26, 44, 11, 19, 52, 35, 44, 15, 30, 38, 10, 31, 40, 4, 46, 50, 20, 40, 27, 44, 51, 14, 56, 53, 19, 59, 7, 29, 41, 19, 35, 25, 8, 52, 22, 44, 13, 53, 50, 32, 61, 24, 56, 25, 63, 0, 45, 57, 33, 59, 16, 46, 4, 62, 50, 11, 60, 37, 52, 19, 55, 29, 37, 46, 13, 26, 48, 10, 50, 34, 21, 63, 26, 13, 42, 33, 22, 55, 35, 28, 43, 15, 24, 51, 27, 34, 46, 49, 58, 3, 52, 9, 57, 19, 48, 55, 3, 35, 12, 45, 24, 3 },
- { 41, 11, 56, 28, 18, 31, 22, 10, 37, 6, 47, 13, 3, 41, 9, 46, 0, 48, 29, 6, 34, 10, 55, 37, 20, 8, 49, 3, 41, 59, 14, 25, 0, 63, 19, 47, 27, 51, 17, 57, 23, 10, 61, 6, 54, 3, 38, 31, 0, 22, 34, 43, 20, 55, 31, 0, 49, 63, 29, 38, 3, 62, 28, 40, 0, 22, 14, 35, 2, 48, 15, 43, 23, 14, 3, 29, 49, 20, 39, 34, 0, 44, 29, 9, 15, 47, 5, 42, 0, 31, 58, 5, 31, 61, 23, 15, 0, 47, 19, 50, 24, 3, 59, 11, 44, 0, 31, 59, 6, 42, 17, 60, 0, 39, 20, 31, 43, 17, 29, 40, 12, 25, 60, 22, 52, 15, 63, 29 },
- { 20, 52, 8, 44, 62, 4, 59, 49, 17, 63, 21, 39, 60, 18, 52, 27, 33, 59, 14, 51, 59, 43, 24, 5, 51, 30, 57, 17, 32, 5, 37, 56, 48, 34, 42, 3, 60, 5, 36, 13, 43, 37, 18, 34, 25, 12, 59, 24, 47, 36, 11, 50, 3, 38, 9, 58, 16, 5, 43, 18, 47, 10, 37, 18, 59, 46, 29, 52, 40, 12, 34, 28, 56, 36, 53, 7, 43, 8, 24, 52, 26, 17, 56, 43, 24, 32, 63, 20, 57, 16, 22, 52, 36, 8, 41, 56, 29, 32, 54, 7, 35, 57, 14, 48, 20, 62, 13, 39, 53, 29, 8, 45, 13, 29, 7, 61, 14, 54, 6, 63, 38, 32, 18, 43, 2, 39, 6, 47 },
- { 0, 58, 23, 35, 13, 46, 12, 39, 0, 31, 55, 24, 5, 35, 15, 61, 17, 5, 39, 25, 18, 2, 50, 33, 41, 13, 39, 23, 62, 46, 29, 12, 22, 8, 56, 25, 20, 49, 32, 62, 0, 56, 11, 46, 63, 42, 9, 16, 55, 5, 60, 15, 62, 26, 45, 21, 36, 51, 13, 57, 31, 24, 55, 6, 35, 9, 57, 5, 20, 60, 7, 51, 5, 19, 40, 25, 61, 32, 56, 12, 36, 48, 21, 2, 58, 12, 39, 28, 9, 50, 40, 12, 44, 18, 25, 49, 6, 38, 11, 62, 18, 46, 30, 9, 40, 25, 49, 19, 10, 36, 55, 22, 33, 52, 41, 18, 37, 27, 49, 21, 2, 46, 7, 53, 33, 61, 27, 35 },
- { 41, 31, 5, 39, 51, 26, 33, 57, 27, 41, 9, 44, 54, 29, 48, 7, 44, 36, 57, 10, 31, 63, 16, 45, 11, 60, 1, 47, 7, 20, 43, 3, 58, 36, 13, 52, 39, 7, 15, 28, 22, 48, 30, 21, 1, 29, 49, 44, 27, 17, 40, 30, 24, 42, 12, 53, 33, 7, 47, 20, 1, 42, 11, 49, 25, 43, 17, 32, 45, 27, 41, 21, 31, 62, 11, 49, 2, 15, 42, 5, 63, 7, 41, 27, 49, 6, 54, 23, 46, 34, 2, 28, 54, 3, 59, 12, 46, 17, 42, 28, 40, 1, 37, 51, 5, 55, 2, 34, 47, 16, 3, 62, 47, 5, 23, 56, 1, 44, 12, 34, 51, 16, 57, 11, 25, 17, 54, 13 },
- { 60, 26, 55, 18, 3, 60, 20, 6, 52, 15, 50, 19, 32, 11, 23, 53, 26, 21, 1, 47, 42, 27, 8, 58, 21, 27, 53, 36, 26, 54, 31, 50, 17, 30, 45, 1, 29, 59, 44, 53, 41, 4, 35, 58, 51, 19, 32, 4, 52, 34, 48, 8, 51, 5, 56, 2, 25, 61, 27, 38, 54, 27, 62, 21, 51, 1, 39, 62, 10, 50, 1, 58, 13, 47, 38, 18, 35, 54, 22, 51, 30, 19, 59, 34, 14, 32, 44, 4, 60, 15, 52, 62, 20, 43, 30, 35, 21, 60, 4, 52, 12, 24, 61, 18, 30, 42, 23, 61, 25, 50, 27, 38, 11, 59, 12, 35, 50, 30, 59, 24, 8, 42, 28, 37, 48, 9, 44, 21 },
- { 10, 47, 15, 50, 30, 43, 8, 45, 29, 2, 36, 59, 1, 58, 41, 3, 63, 31, 54, 20, 13, 55, 35, 38, 4, 44, 15, 9, 61, 2, 14, 38, 61, 10, 23, 54, 18, 12, 24, 2, 14, 55, 16, 8, 38, 14, 41, 60, 10, 23, 1, 58, 32, 17, 28, 37, 41, 15, 3, 60, 15, 33, 4, 36, 16, 59, 28, 14, 23, 55, 37, 18, 44, 28, 2, 57, 30, 10, 27, 46, 14, 38, 3, 53, 21, 61, 17, 35, 10, 41, 26, 7, 33, 9, 57, 1, 53, 37, 26, 20, 56, 48, 9, 33, 58, 16, 37, 7, 45, 1, 57, 15, 32, 26, 42, 23, 7, 20, 4, 54, 31, 62, 22, 1, 59, 30, 4, 51 },
- { 36, 2, 38, 11, 24, 36, 54, 22, 62, 47, 25, 8, 28, 45, 16, 38, 12, 43, 9, 37, 49, 3, 23, 52, 18, 30, 50, 33, 19, 42, 49, 26, 6, 40, 47, 35, 63, 38, 50, 33, 60, 26, 36, 47, 24, 57, 6, 26, 39, 63, 19, 44, 14, 46, 61, 9, 50, 30, 45, 23, 10, 50, 44, 8, 31, 54, 6, 46, 36, 4, 30, 54, 8, 52, 22, 41, 4, 60, 40, 0, 58, 24, 45, 10, 37, 1, 48, 30, 56, 17, 38, 48, 24, 47, 19, 39, 14, 8, 45, 32, 2, 34, 27, 44, 4, 52, 11, 56, 31, 21, 40, 19, 44, 51, 2, 63, 46, 58, 36, 43, 14, 5, 50, 38, 14, 56, 40, 23 },
- { 61, 46, 32, 63, 54, 1, 14, 34, 12, 40, 18, 49, 37, 10, 61, 30, 51, 24, 60, 7, 29, 40, 62, 11, 46, 58, 6, 56, 24, 10, 34, 52, 21, 59, 16, 3, 27, 5, 20, 46, 9, 40, 7, 62, 2, 30, 53, 15, 48, 10, 28, 35, 54, 6, 21, 34, 18, 55, 7, 40, 57, 19, 26, 60, 41, 13, 24, 51, 19, 61, 9, 25, 34, 15, 63, 11, 45, 17, 20, 47, 33, 8, 31, 62, 43, 26, 53, 7, 24, 59, 0, 13, 55, 4, 62, 27, 51, 31, 63, 15, 58, 7, 54, 14, 46, 22, 28, 43, 12, 63, 8, 54, 5, 17, 39, 33, 15, 10, 27, 17, 47, 34, 19, 45, 27, 12, 33, 17 },
- { 5, 28, 21, 7, 17, 48, 42, 58, 23, 4, 63, 14, 55, 21, 34, 5, 19, 0, 45, 17, 52, 15, 25, 32, 0, 22, 40, 13, 45, 62, 18, 0, 43, 11, 33, 55, 30, 42, 57, 19, 51, 31, 22, 43, 18, 45, 34, 0, 43, 31, 56, 3, 23, 40, 59, 0, 44, 13, 48, 35, 2, 32, 46, 0, 21, 48, 35, 3, 40, 32, 43, 59, 0, 48, 33, 26, 53, 36, 55, 12, 51, 16, 55, 5, 18, 29, 11, 39, 51, 19, 45, 31, 42, 21, 35, 6, 22, 47, 10, 38, 23, 50, 20, 36, 0, 60, 38, 4, 50, 35, 48, 34, 24, 57, 9, 53, 28, 48, 61, 0, 56, 24, 53, 3, 63, 6, 42, 57 },
- { 13, 53, 45, 40, 58, 27, 6, 16, 38, 51, 33, 30, 43, 2, 47, 56, 40, 50, 33, 57, 27, 5, 47, 42, 60, 36, 16, 54, 28, 4, 37, 57, 28, 51, 22, 8, 45, 14, 6, 39, 0, 54, 11, 59, 28, 12, 50, 21, 61, 13, 19, 38, 49, 11, 25, 37, 58, 29, 22, 63, 14, 56, 12, 53, 30, 63, 9, 57, 26, 12, 47, 16, 23, 39, 50, 6, 31, 2, 25, 6, 28, 41, 36, 22, 50, 57, 42, 3, 34, 8, 28, 61, 11, 50, 16, 54, 41, 0, 55, 43, 5, 29, 41, 63, 25, 16, 53, 18, 26, 10, 21, 0, 61, 30, 41, 22, 3, 38, 20, 39, 29, 8, 41, 16, 36, 52, 22, 19 },
- { 55, 34, 0, 25, 10, 32, 56, 44, 28, 0, 57, 7, 26, 53, 23, 8, 13, 35, 22, 12, 36, 60, 20, 8, 14, 29, 48, 2, 41, 49, 23, 13, 39, 7, 48, 58, 25, 53, 34, 62, 28, 16, 48, 4, 37, 56, 27, 5, 36, 52, 46, 7, 62, 33, 52, 11, 17, 53, 5, 28, 41, 24, 38, 17, 5, 39, 20, 45, 15, 56, 5, 38, 60, 8, 14, 57, 21, 48, 62, 39, 59, 13, 1, 60, 9, 32, 16, 63, 44, 25, 52, 15, 36, 2, 60, 29, 12, 33, 25, 17, 59, 45, 13, 8, 49, 32, 6, 40, 59, 29, 45, 37, 13, 47, 6, 55, 30, 45, 9, 52, 13, 59, 25, 47, 32, 1, 49, 30 },
- { 9, 39, 14, 61, 49, 37, 3, 20, 50, 13, 41, 19, 46, 17, 38, 59, 28, 62, 4, 44, 54, 1, 34, 51, 55, 7, 63, 32, 21, 8, 56, 31, 62, 19, 36, 1, 41, 17, 24, 12, 42, 35, 25, 52, 20, 8, 44, 59, 25, 2, 22, 42, 16, 29, 4, 46, 20, 36, 43, 9, 51, 8, 49, 26, 58, 33, 54, 1, 37, 29, 52, 20, 27, 45, 19, 35, 42, 16, 10, 32, 20, 49, 46, 27, 40, 4, 47, 22, 13, 55, 4, 47, 26, 44, 23, 40, 58, 19, 48, 13, 31, 2, 57, 34, 42, 19, 61, 32, 14, 55, 5, 51, 26, 19, 58, 16, 49, 14, 62, 5, 33, 44, 21, 7, 60, 26, 11, 41 },
- { 62, 24, 47, 29, 8, 19, 53, 11, 60, 24, 32, 61, 4, 55, 31, 2, 49, 16, 39, 9, 31, 24, 43, 17, 26, 38, 11, 25, 58, 43, 12, 35, 3, 46, 15, 32, 63, 4, 49, 56, 2, 60, 10, 32, 63, 17, 39, 12, 55, 30, 57, 9, 48, 55, 39, 24, 60, 2, 58, 31, 19, 61, 34, 3, 42, 11, 22, 46, 7, 61, 10, 42, 3, 55, 32, 1, 58, 28, 44, 54, 4, 34, 23, 15, 56, 20, 37, 58, 6, 30, 38, 18, 63, 9, 32, 5, 51, 3, 62, 37, 52, 18, 39, 23, 3, 51, 9, 47, 1, 23, 43, 15, 60, 35, 11, 40, 1, 36, 31, 26, 57, 2, 37, 54, 18, 44, 58, 16 },
- { 5, 51, 3, 33, 43, 62, 21, 42, 35, 9, 48, 15, 36, 10, 22, 42, 20, 46, 26, 56, 50, 12, 59, 3, 48, 19, 45, 53, 1, 27, 47, 17, 52, 24, 56, 11, 51, 21, 37, 30, 20, 46, 14, 41, 1, 47, 33, 7, 41, 17, 35, 27, 20, 1, 14, 54, 26, 33, 18, 47, 1, 44, 14, 59, 16, 52, 28, 18, 49, 31, 25, 34, 63, 13, 51, 24, 9, 50, 3, 23, 38, 63, 7, 52, 29, 46, 11, 33, 50, 22, 57, 36, 1, 57, 49, 17, 39, 28, 9, 35, 6, 27, 53, 15, 55, 30, 24, 58, 36, 41, 11, 52, 32, 3, 44, 25, 62, 23, 51, 15, 42, 22, 50, 10, 39, 4, 31, 35 },
- { 46, 22, 57, 17, 12, 39, 26, 5, 31, 59, 1, 45, 27, 62, 52, 7, 58, 33, 6, 18, 39, 22, 33, 41, 57, 5, 35, 18, 40, 16, 60, 5, 29, 42, 7, 39, 27, 44, 9, 47, 8, 26, 54, 22, 51, 29, 24, 49, 15, 61, 4, 51, 31, 63, 43, 6, 50, 8, 39, 12, 53, 37, 23, 30, 40, 6, 62, 43, 14, 53, 2, 49, 7, 36, 17, 41, 61, 37, 18, 56, 11, 18, 44, 35, 2, 19, 61, 0, 41, 14, 8, 30, 43, 12, 24, 46, 14, 54, 42, 21, 44, 61, 10, 46, 37, 11, 44, 7, 18, 63, 20, 29, 7, 49, 28, 54, 8, 43, 4, 48, 18, 63, 12, 29, 48, 24, 59, 20 },
- { 13, 36, 28, 54, 35, 2, 56, 46, 16, 49, 22, 40, 11, 34, 14, 43, 29, 12, 63, 48, 2, 61, 7, 15, 28, 30, 50, 9, 61, 33, 38, 23, 54, 13, 61, 33, 3, 59, 16, 35, 58, 40, 5, 38, 13, 57, 3, 58, 37, 21, 45, 12, 39, 7, 35, 30, 13, 56, 22, 62, 27, 6, 55, 10, 48, 21, 33, 2, 38, 23, 40, 20, 44, 29, 59, 4, 26, 12, 33, 47, 28, 53, 31, 13, 59, 41, 27, 49, 26, 54, 45, 16, 53, 21, 35, 7, 59, 26, 11, 56, 1, 24, 33, 4, 28, 62, 21, 49, 31, 2, 56, 39, 24, 58, 13, 17, 37, 21, 56, 10, 38, 0, 34, 55, 15, 43, 1, 52 },
- { 42, 9, 50, 6, 25, 60, 14, 38, 10, 29, 53, 18, 57, 3, 25, 51, 0, 53, 25, 17, 29, 37, 52, 46, 0, 62, 14, 37, 4, 50, 10, 44, 0, 46, 20, 25, 50, 19, 55, 0, 23, 31, 62, 34, 11, 45, 19, 32, 0, 53, 10, 59, 23, 47, 18, 60, 42, 28, 37, 3, 50, 15, 35, 44, 0, 51, 27, 60, 9, 57, 16, 58, 11, 22, 46, 15, 53, 48, 7, 42, 0, 60, 5, 49, 24, 54, 9, 17, 39, 5, 34, 62, 3, 40, 60, 31, 0, 47, 29, 16, 49, 39, 59, 17, 50, 0, 40, 13, 53, 38, 16, 46, 0, 42, 34, 60, 2, 53, 29, 31, 58, 46, 27, 6, 61, 8, 37, 28 },
- { 0, 63, 21, 40, 45, 18, 51, 23, 63, 34, 6, 43, 28, 38, 55, 19, 40, 35, 8, 41, 54, 10, 21, 32, 39, 23, 53, 26, 55, 28, 22, 63, 30, 34, 9, 48, 6, 38, 29, 43, 49, 6, 18, 52, 27, 61, 9, 43, 28, 42, 33, 26, 56, 3, 51, 23, 0, 48, 16, 45, 32, 25, 63, 20, 57, 17, 42, 12, 35, 47, 5, 31, 39, 56, 6, 30, 34, 21, 61, 25, 14, 40, 22, 38, 15, 6, 36, 56, 20, 60, 25, 12, 51, 27, 10, 56, 42, 20, 36, 63, 32, 6, 21, 41, 12, 34, 60, 26, 5, 48, 27, 10, 62, 19, 6, 47, 39, 14, 45, 7, 24, 17, 41, 32, 23, 51, 19, 56 },
- { 45, 31, 15, 59, 4, 33, 7, 47, 0, 41, 13, 61, 4, 47, 9, 23, 60, 14, 57, 31, 4, 45, 59, 6, 58, 10, 44, 20, 8, 42, 15, 6, 55, 17, 58, 31, 53, 12, 61, 10, 15, 57, 43, 2, 23, 35, 48, 14, 54, 6, 18, 49, 15, 38, 11, 34, 62, 9, 21, 58, 11, 41, 4, 31, 38, 8, 29, 55, 19, 36, 27, 52, 0, 25, 50, 43, 1, 39, 8, 55, 35, 51, 10, 30, 45, 62, 29, 2, 46, 10, 32, 48, 18, 38, 5, 22, 33, 8, 51, 3, 14, 44, 54, 25, 57, 30, 18, 52, 33, 22, 59, 28, 36, 52, 32, 21, 26, 50, 5, 55, 35, 60, 14, 54, 4, 40, 16, 33 },
- { 27, 3, 49, 10, 30, 40, 55, 27, 57, 24, 52, 21, 32, 17, 60, 30, 5, 44, 27, 49, 19, 34, 13, 24, 43, 36, 3, 49, 31, 59, 37, 48, 26, 41, 2, 41, 14, 36, 21, 32, 40, 26, 13, 49, 55, 5, 16, 40, 25, 60, 36, 1, 63, 29, 17, 44, 25, 40, 52, 5, 29, 47, 54, 13, 46, 24, 60, 4, 51, 22, 63, 14, 45, 18, 12, 62, 17, 57, 19, 42, 3, 26, 58, 48, 1, 21, 40, 52, 23, 37, 44, 1, 29, 58, 43, 50, 15, 61, 19, 45, 58, 28, 7, 48, 2, 46, 8, 42, 3, 55, 8, 50, 12, 4, 55, 10, 63, 33, 20, 40, 11, 3, 46, 20, 48, 26, 61, 11 },
- { 44, 56, 24, 36, 53, 19, 12, 37, 16, 44, 7, 36, 49, 54, 11, 37, 48, 21, 15, 1, 62, 25, 47, 56, 16, 18, 51, 12, 40, 1, 24, 11, 52, 16, 23, 59, 28, 1, 45, 53, 4, 60, 37, 21, 39, 30, 63, 20, 52, 10, 30, 45, 8, 41, 54, 4, 57, 7, 34, 55, 36, 18, 23, 59, 2, 48, 11, 32, 44, 1, 41, 8, 33, 54, 38, 23, 30, 46, 6, 29, 62, 18, 32, 16, 55, 34, 14, 11, 61, 7, 55, 16, 53, 13, 23, 2, 55, 37, 26, 10, 33, 23, 36, 16, 38, 22, 56, 15, 24, 43, 35, 17, 44, 40, 25, 46, 16, 1, 57, 25, 49, 36, 28, 62, 9, 35, 7, 53 },
- { 17, 38, 8, 61, 1, 50, 26, 62, 3, 31, 56, 15, 1, 26, 40, 2, 34, 51, 56, 36, 42, 9, 38, 2, 29, 60, 32, 57, 19, 62, 34, 47, 4, 57, 39, 7, 44, 63, 24, 18, 46, 28, 8, 54, 1, 34, 7, 46, 3, 37, 50, 23, 57, 21, 13, 46, 31, 20, 43, 15, 1, 61, 8, 33, 37, 17, 56, 26, 15, 49, 24, 59, 28, 3, 56, 9, 52, 32, 13, 49, 10, 43, 5, 45, 8, 25, 59, 42, 28, 33, 19, 40, 8, 63, 35, 47, 25, 4, 40, 52, 1, 60, 12, 53, 63, 9, 29, 60, 37, 19, 1, 62, 31, 20, 58, 12, 41, 30, 43, 9, 18, 52, 22, 1, 39, 30, 58, 21 },
- { 13, 47, 29, 18, 43, 34, 5, 48, 20, 42, 10, 45, 30, 58, 20, 63, 24, 11, 6, 28, 54, 14, 22, 52, 41, 7, 26, 5, 45, 15, 53, 13, 35, 27, 18, 50, 12, 33, 5, 56, 10, 17, 45, 24, 59, 15, 50, 26, 56, 13, 19, 5, 32, 52, 27, 36, 2, 61, 12, 26, 49, 40, 27, 52, 13, 50, 6, 39, 61, 34, 10, 37, 48, 20, 41, 27, 2, 36, 59, 24, 54, 33, 63, 20, 38, 50, 3, 17, 52, 4, 58, 27, 45, 21, 32, 11, 48, 17, 57, 20, 46, 38, 25, 43, 4, 34, 51, 6, 13, 45, 57, 26, 6, 48, 2, 35, 53, 23, 61, 34, 59, 6, 42, 56, 13, 51, 2, 41 },
- { 32, 5, 55, 23, 58, 14, 22, 52, 29, 15, 61, 25, 51, 8, 43, 13, 53, 41, 46, 20, 3, 33, 63, 11, 48, 21, 54, 38, 28, 3, 30, 43, 21, 62, 9, 31, 55, 22, 51, 29, 37, 62, 32, 12, 42, 29, 41, 9, 33, 44, 62, 28, 43, 1, 59, 19, 48, 30, 51, 39, 24, 4, 58, 19, 42, 29, 22, 43, 3, 18, 53, 5, 13, 50, 16, 60, 45, 21, 7, 40, 15, 0, 26, 53, 13, 31, 43, 24, 47, 31, 15, 49, 2, 41, 6, 59, 29, 42, 9, 30, 14, 7, 49, 18, 31, 47, 20, 39, 49, 32, 11, 41, 54, 15, 61, 18, 7, 38, 4, 13, 44, 28, 15, 32, 45, 19, 27, 49 },
- { 63, 34, 11, 39, 2, 45, 37, 8, 59, 39, 33, 4, 36, 17, 48, 5, 29, 18, 32, 61, 39, 50, 5, 27, 35, 0, 46, 12, 22, 49, 60, 6, 54, 0, 38, 49, 2, 42, 15, 40, 0, 47, 20, 51, 3, 57, 18, 61, 22, 0, 39, 16, 55, 12, 35, 8, 41, 22, 6, 59, 16, 45, 10, 36, 0, 62, 9, 54, 30, 58, 21, 43, 63, 31, 7, 35, 12, 48, 58, 28, 47, 37, 41, 9, 57, 20, 61, 0, 36, 11, 57, 35, 23, 52, 37, 18, 0, 62, 22, 55, 35, 62, 27, 54, 0, 15, 61, 28, 2, 59, 22, 9, 37, 27, 33, 51, 29, 48, 19, 50, 25, 37, 10, 57, 5, 37, 60, 8 },
- { 20, 25, 46, 52, 31, 60, 12, 55, 0, 19, 11, 46, 62, 35, 23, 38, 57, 0, 55, 10, 16, 30, 58, 44, 17, 59, 29, 63, 42, 8, 36, 20, 33, 46, 16, 61, 25, 35, 8, 54, 26, 7, 58, 22, 34, 6, 47, 14, 53, 31, 48, 9, 37, 25, 49, 63, 16, 55, 45, 14, 34, 63, 21, 53, 25, 33, 46, 16, 35, 7, 46, 29, 0, 39, 25, 55, 22, 34, 18, 4, 56, 11, 23, 51, 28, 6, 39, 14, 62, 44, 19, 8, 60, 12, 56, 28, 50, 34, 39, 5, 51, 3, 41, 12, 57, 35, 10, 53, 25, 17, 52, 30, 47, 0, 43, 14, 5, 57, 31, 55, 0, 63, 47, 23, 54, 24, 14, 43 },
- { 0, 57, 16, 6, 26, 19, 35, 28, 49, 42, 54, 26, 21, 1, 59, 27, 9, 47, 26, 44, 50, 22, 13, 40, 8, 37, 10, 34, 17, 56, 25, 58, 13, 27, 44, 9, 20, 58, 31, 17, 60, 36, 10, 41, 53, 25, 36, 39, 4, 24, 58, 17, 60, 4, 22, 38, 10, 32, 0, 50, 31, 7, 28, 47, 12, 57, 5, 26, 52, 23, 14, 40, 57, 17, 47, 5, 53, 1, 44, 31, 19, 60, 46, 2, 35, 48, 30, 54, 22, 5, 51, 39, 25, 31, 4, 43, 14, 9, 45, 16, 24, 44, 19, 29, 40, 23, 44, 7, 38, 42, 4, 63, 12, 54, 23, 59, 22, 42, 8, 15, 40, 21, 8, 34, 3, 41, 30, 50 },
- { 39, 10, 48, 33, 41, 54, 5, 47, 23, 13, 32, 7, 52, 44, 14, 39, 58, 18, 35, 6, 37, 2, 60, 24, 55, 19, 53, 2, 51, 32, 1, 41, 51, 4, 40, 29, 47, 3, 52, 44, 13, 49, 28, 16, 1, 62, 11, 27, 52, 35, 5, 42, 29, 47, 14, 56, 28, 53, 26, 38, 9, 56, 40, 3, 38, 15, 41, 60, 1, 37, 50, 25, 11, 28, 61, 19, 42, 62, 10, 52, 39, 6, 32, 14, 58, 17, 7, 26, 42, 34, 27, 10, 54, 40, 20, 63, 26, 53, 21, 61, 32, 7, 59, 48, 3, 56, 18, 31, 58, 14, 49, 21, 36, 16, 45, 9, 36, 24, 62, 45, 27, 31, 53, 17, 49, 12, 62, 18 },
- { 28, 59, 21, 58, 2, 16, 38, 9, 62, 3, 56, 41, 10, 31, 50, 4, 32, 52, 12, 63, 23, 46, 33, 31, 4, 48, 25, 43, 14, 23, 47, 11, 22, 55, 14, 60, 23, 37, 11, 39, 23, 2, 45, 56, 31, 43, 19, 55, 16, 46, 21, 51, 11, 33, 44, 2, 41, 18, 5, 52, 23, 44, 17, 60, 27, 49, 11, 32, 44, 10, 54, 2, 56, 33, 8, 38, 13, 29, 36, 16, 24, 63, 27, 51, 21, 43, 56, 12, 49, 3, 59, 48, 1, 15, 46, 7, 36, 2, 47, 11, 50, 27, 37, 13, 33, 8, 51, 46, 1, 34, 28, 40, 3, 33, 60, 29, 47, 1, 35, 11, 59, 42, 2, 60, 26, 46, 6, 35 },
- { 4, 43, 9, 29, 36, 63, 24, 44, 20, 50, 30, 17, 60, 22, 16, 43, 25, 3, 42, 19, 51, 15, 8, 54, 42, 15, 61, 5, 39, 57, 18, 61, 31, 48, 34, 2, 50, 19, 57, 5, 63, 33, 19, 38, 13, 27, 48, 7, 32, 61, 2, 26, 58, 6, 24, 50, 13, 61, 42, 20, 62, 2, 35, 20, 51, 4, 62, 18, 23, 58, 20, 31, 43, 15, 51, 45, 26, 50, 4, 55, 45, 3, 35, 9, 38, 1, 32, 61, 20, 45, 17, 33, 24, 57, 29, 51, 22, 58, 38, 30, 15, 1, 54, 21, 63, 43, 26, 12, 24, 56, 8, 60, 50, 19, 5, 52, 13, 54, 17, 50, 4, 16, 36, 12, 32, 56, 22, 54 },
- { 51, 25, 40, 53, 12, 49, 15, 57, 34, 7, 38, 47, 2, 36, 55, 8, 61, 30, 56, 7, 28, 59, 48, 11, 27, 35, 21, 45, 28, 36, 9, 38, 6, 16, 24, 63, 10, 32, 28, 43, 21, 53, 5, 60, 8, 57, 3, 45, 11, 37, 15, 54, 40, 20, 62, 36, 27, 34, 11, 48, 30, 15, 54, 8, 30, 42, 22, 34, 48, 13, 35, 63, 4, 37, 22, 2, 59, 9, 41, 23, 13, 41, 49, 18, 59, 24, 40, 5, 37, 30, 9, 61, 44, 6, 37, 11, 33, 17, 5, 55, 41, 60, 23, 39, 17, 5, 30, 62, 41, 16, 46, 25, 11, 56, 39, 26, 20, 38, 29, 39, 22, 52, 44, 20, 48, 1, 38, 14 },
- { 15, 33, 2, 18, 44, 6, 27, 0, 32, 61, 25, 12, 58, 28, 40, 20, 47, 13, 34, 43, 38, 1, 23, 62, 40, 0, 51, 10, 63, 3, 52, 26, 44, 30, 45, 6, 41, 54, 0, 51, 12, 30, 46, 24, 49, 22, 40, 33, 63, 23, 43, 30, 9, 47, 0, 17, 54, 7, 57, 3, 37, 47, 24, 46, 13, 55, 7, 52, 2, 42, 6, 26, 49, 18, 60, 34, 16, 57, 33, 20, 61, 30, 8, 54, 14, 46, 12, 53, 16, 55, 38, 13, 22, 53, 18, 59, 46, 27, 43, 19, 32, 10, 45, 6, 49, 36, 52, 2, 20, 55, 6, 39, 32, 15, 44, 3, 58, 10, 63, 6, 56, 30, 7, 58, 9, 40, 19, 63 },
- { 10, 47, 61, 23, 55, 31, 52, 42, 17, 45, 4, 51, 27, 6, 15, 53, 0, 49, 26, 10, 56, 18, 36, 6, 20, 58, 32, 30, 13, 49, 19, 56, 0, 59, 12, 53, 27, 17, 38, 25, 48, 9, 15, 36, 14, 30, 59, 17, 0, 50, 8, 58, 18, 56, 31, 45, 21, 41, 29, 19, 60, 6, 32, 59, 0, 36, 29, 39, 19, 59, 46, 12, 55, 30, 10, 47, 24, 3, 28, 48, 0, 55, 44, 27, 33, 4, 63, 29, 49, 0, 26, 50, 34, 2, 42, 14, 0, 62, 9, 56, 3, 52, 28, 34, 58, 9, 20, 48, 37, 32, 22, 53, 0, 62, 27, 49, 34, 46, 21, 33, 41, 14, 25, 37, 53, 29, 31, 45 },
- { 56, 28, 7, 37, 11, 36, 20, 9, 54, 14, 39, 19, 34, 63, 45, 37, 24, 17, 60, 31, 21, 45, 53, 29, 47, 15, 7, 55, 40, 23, 34, 14, 42, 20, 37, 35, 15, 59, 7, 62, 34, 40, 59, 1, 51, 42, 10, 28, 54, 21, 35, 5, 38, 13, 36, 4, 59, 12, 39, 53, 15, 43, 9, 21, 39, 62, 16, 56, 25, 9, 32, 38, 0, 41, 14, 51, 40, 53, 43, 11, 37, 17, 5, 22, 57, 39, 19, 7, 42, 21, 60, 10, 31, 63, 25, 52, 30, 49, 36, 25, 48, 17, 61, 14, 22, 42, 29, 13, 60, 11, 47, 18, 35, 41, 7, 23, 4, 16, 51, 11, 0, 48, 61, 3, 17, 50, 5, 24 },
- { 0, 42, 21, 49, 60, 3, 57, 40, 29, 48, 23, 56, 42, 11, 22, 5, 59, 39, 4, 50, 3, 41, 12, 57, 25, 50, 44, 18, 4, 46, 7, 62, 33, 50, 4, 56, 21, 32, 43, 18, 3, 23, 55, 34, 20, 4, 53, 38, 12, 46, 29, 52, 25, 61, 23, 51, 26, 46, 1, 34, 25, 57, 28, 51, 26, 11, 50, 3, 44, 28, 53, 21, 57, 27, 62, 6, 31, 19, 8, 63, 26, 59, 36, 47, 15, 29, 50, 25, 35, 47, 18, 41, 4, 48, 8, 40, 12, 23, 6, 44, 13, 40, 1, 31, 55, 0, 61, 43, 4, 50, 26, 58, 9, 53, 24, 61, 42, 55, 31, 43, 57, 20, 34, 27, 43, 8, 59, 39 },
- { 18, 51, 30, 13, 26, 16, 46, 22, 2, 59, 8, 30, 1, 48, 33, 51, 29, 9, 46, 16, 62, 14, 33, 2, 38, 9, 27, 60, 37, 26, 53, 17, 28, 10, 24, 46, 2, 49, 8, 57, 29, 45, 6, 26, 62, 44, 18, 25, 61, 3, 42, 14, 49, 10, 43, 6, 17, 32, 63, 10, 49, 4, 40, 14, 45, 33, 22, 37, 12, 61, 5, 17, 43, 7, 23, 37, 15, 58, 49, 13, 39, 21, 10, 52, 1, 62, 9, 56, 12, 2, 58, 28, 36, 16, 56, 28, 56, 35, 20, 63, 24, 37, 51, 8, 45, 25, 16, 33, 27, 38, 2, 44, 13, 30, 17, 36, 12, 26, 5, 18, 28, 47, 13, 60, 23, 45, 13, 33 },
- { 55, 4, 62, 34, 52, 38, 7, 63, 32, 37, 13, 53, 25, 62, 18, 12, 55, 41, 27, 35, 24, 49, 31, 52, 17, 63, 34, 1, 56, 12, 41, 2, 48, 58, 39, 16, 61, 27, 41, 52, 13, 19, 50, 39, 11, 31, 57, 6, 32, 40, 20, 55, 1, 28, 33, 57, 48, 8, 37, 22, 44, 18, 53, 1, 61, 5, 54, 16, 47, 36, 50, 24, 55, 34, 48, 45, 1, 30, 33, 46, 2, 50, 32, 42, 25, 34, 43, 21, 38, 52, 23, 45, 14, 54, 21, 4, 44, 16, 53, 29, 10, 47, 19, 57, 12, 54, 39, 10, 51, 15, 63, 21, 57, 40, 51, 1, 48, 57, 37, 62, 2, 38, 9, 52, 1, 35, 58, 22 },
- { 36, 46, 10, 42, 1, 27, 43, 15, 50, 21, 45, 16, 41, 3, 35, 44, 20, 1, 57, 11, 55, 7, 43, 8, 22, 42, 13, 46, 21, 39, 31, 60, 22, 5, 29, 44, 11, 35, 20, 4, 36, 58, 32, 15, 47, 2, 36, 48, 16, 60, 8, 35, 44, 63, 16, 2, 40, 26, 55, 14, 58, 35, 24, 31, 19, 42, 31, 58, 1, 29, 10, 40, 2, 19, 12, 54, 22, 61, 7, 24, 56, 5, 28, 16, 54, 3, 15, 58, 6, 30, 8, 62, 1, 43, 31, 47, 7, 59, 1, 38, 58, 4, 34, 27, 38, 5, 31, 59, 7, 46, 30, 3, 34, 6, 28, 59, 20, 8, 32, 15, 53, 24, 55, 31, 19, 49, 11, 26 },
- { 2, 24, 16, 58, 19, 55, 5, 35, 10, 61, 4, 28, 57, 24, 58, 7, 31, 47, 22, 38, 19, 28, 61, 36, 54, 5, 59, 29, 6, 52, 15, 11, 43, 36, 8, 54, 52, 1, 62, 25, 47, 9, 1, 60, 28, 53, 24, 14, 46, 27, 51, 22, 12, 24, 38, 53, 20, 11, 51, 3, 29, 7, 48, 63, 8, 49, 9, 21, 52, 14, 63, 32, 46, 60, 35, 4, 41, 16, 52, 35, 18, 42, 59, 7, 36, 61, 45, 27, 33, 51, 19, 39, 34, 11, 61, 18, 33, 41, 28, 15, 54, 22, 42, 3, 49, 21, 47, 18, 36, 23, 55, 19, 48, 24, 45, 10, 33, 44, 50, 40, 7, 35, 15, 41, 63, 6, 40, 54 },
- { 62, 41, 32, 8, 47, 28, 60, 24, 44, 30, 38, 49, 9, 33, 14, 40, 50, 14, 60, 2, 54, 40, 0, 20, 25, 39, 16, 49, 24, 35, 57, 47, 19, 61, 33, 18, 23, 37, 13, 55, 31, 43, 22, 41, 17, 8, 42, 58, 0, 37, 5, 56, 31, 54, 7, 30, 60, 33, 42, 17, 59, 39, 12, 27, 38, 17, 35, 41, 27, 45, 20, 7, 25, 15, 29, 58, 27, 47, 11, 40, 14, 54, 23, 46, 19, 31, 11, 40, 13, 49, 5, 58, 24, 51, 26, 6, 50, 20, 49, 9, 32, 46, 17, 60, 14, 63, 24, 1, 57, 41, 9, 43, 14, 62, 16, 52, 3, 27, 14, 22, 61, 45, 4, 28, 9, 47, 29, 17 },
- { 5, 50, 12, 53, 38, 18, 11, 51, 0, 55, 17, 6, 47, 54, 19, 63, 5, 26, 34, 45, 13, 30, 47, 58, 10, 48, 32, 3, 62, 9, 26, 0, 25, 14, 50, 3, 47, 30, 42, 16, 6, 63, 12, 49, 33, 55, 21, 10, 34, 63, 18, 41, 3, 47, 19, 43, 0, 49, 8, 28, 46, 20, 52, 0, 56, 24, 60, 3, 59, 5, 39, 57, 48, 52, 9, 38, 3, 21, 26, 60, 0, 32, 12, 38, 4, 48, 53, 0, 60, 15, 29, 44, 18, 10, 38, 57, 13, 60, 2, 26, 62, 7, 50, 29, 35, 8, 40, 53, 28, 12, 60, 33, 38, 5, 37, 29, 60, 39, 56, 0, 30, 18, 50, 34, 59, 25, 14, 44 },
- { 20, 31, 60, 22, 3, 49, 33, 25, 40, 13, 34, 59, 22, 36, 0, 28, 37, 56, 8, 18, 51, 16, 4, 45, 27, 12, 53, 42, 18, 44, 51, 31, 55, 40, 28, 58, 7, 60, 10, 51, 27, 37, 24, 56, 5, 26, 44, 29, 50, 23, 45, 11, 34, 15, 59, 27, 13, 23, 62, 37, 4, 57, 15, 32, 42, 6, 47, 11, 30, 43, 23, 13, 0, 36, 18, 44, 63, 51, 37, 29, 49, 20, 57, 27, 62, 9, 24, 35, 23, 53, 37, 3, 42, 55, 0, 36, 23, 39, 31, 43, 17, 37, 24, 11, 52, 43, 19, 32, 5, 50, 26, 0, 56, 21, 54, 11, 19, 6, 47, 25, 59, 42, 12, 54, 21, 3, 38, 57 },
- { 48, 0, 35, 27, 44, 14, 59, 7, 57, 46, 26, 2, 42, 12, 52, 43, 10, 27, 53, 42, 32, 62, 37, 21, 34, 61, 7, 23, 36, 4, 38, 12, 41, 5, 17, 45, 22, 27, 39, 21, 59, 0, 45, 18, 39, 62, 3, 38, 14, 7, 54, 26, 61, 39, 9, 52, 45, 36, 18, 50, 10, 34, 44, 22, 50, 14, 36, 55, 17, 34, 53, 62, 33, 26, 56, 6, 31, 12, 6, 53, 9, 44, 2, 50, 20, 40, 55, 17, 47, 7, 26, 63, 22, 32, 48, 16, 46, 8, 52, 12, 57, 41, 0, 56, 25, 3, 61, 14, 45, 35, 18, 44, 12, 46, 23, 42, 32, 51, 35, 10, 17, 36, 23, 1, 45, 52, 32, 10 },
- { 37, 15, 43, 8, 63, 39, 21, 31, 16, 37, 19, 62, 30, 46, 17, 60, 21, 48, 1, 23, 6, 25, 11, 56, 1, 40, 30, 58, 15, 54, 21, 59, 9, 63, 35, 56, 11, 51, 2, 46, 34, 14, 53, 7, 30, 11, 51, 19, 60, 40, 30, 1, 24, 50, 20, 32, 3, 56, 5, 25, 31, 13, 61, 2, 29, 60, 25, 20, 51, 2, 27, 8, 18, 42, 10, 45, 21, 34, 43, 17, 62, 29, 41, 14, 34, 6, 30, 43, 2, 57, 33, 13, 45, 12, 27, 62, 4, 55, 21, 35, 5, 27, 45, 33, 16, 47, 30, 54, 22, 10, 51, 27, 63, 7, 49, 1, 58, 22, 15, 43, 53, 7, 57, 39, 27, 12, 61, 24 },
- { 56, 51, 26, 56, 19, 2, 41, 54, 5, 52, 9, 48, 6, 23, 39, 4, 32, 15, 63, 35, 59, 49, 43, 15, 52, 19, 50, 9, 46, 33, 1, 29, 48, 20, 32, 1, 38, 33, 19, 54, 9, 32, 24, 48, 58, 35, 16, 48, 4, 52, 13, 57, 33, 5, 45, 59, 15, 29, 41, 55, 47, 39, 23, 53, 9, 40, 4, 57, 10, 44, 48, 40, 50, 14, 61, 24, 55, 1, 59, 22, 33, 8, 51, 25, 58, 46, 11, 59, 20, 41, 17, 51, 6, 56, 35, 25, 42, 30, 15, 58, 48, 18, 61, 9, 58, 39, 13, 2, 37, 59, 40, 2, 31, 16, 34, 41, 8, 30, 62, 3, 29, 48, 33, 5, 63, 16, 41, 7 },
- { 22, 4, 46, 11, 33, 51, 29, 10, 62, 24, 43, 27, 15, 58, 50, 25, 54, 44, 9, 38, 18, 3, 29, 57, 32, 5, 26, 43, 17, 61, 24, 52, 8, 42, 23, 53, 15, 61, 7, 28, 57, 43, 4, 40, 20, 2, 43, 25, 32, 35, 21, 43, 17, 48, 10, 22, 38, 54, 11, 21, 1, 58, 16, 30, 48, 18, 46, 32, 38, 13, 22, 4, 59, 35, 2, 51, 30, 39, 15, 47, 4, 56, 13, 37, 1, 28, 16, 52, 32, 9, 61, 29, 38, 19, 3, 52, 10, 48, 1, 32, 11, 40, 20, 36, 6, 22, 49, 29, 55, 6, 20, 56, 36, 52, 19, 60, 26, 46, 18, 54, 40, 13, 20, 46, 35, 19, 49, 29 },
- { 61, 17, 34, 53, 23, 6, 48, 35, 20, 40, 1, 56, 36, 29, 11, 34, 7, 41, 14, 30, 55, 20, 46, 8, 24, 38, 63, 2, 37, 10, 45, 14, 34, 49, 6, 13, 44, 25, 49, 41, 21, 12, 61, 15, 54, 29, 63, 12, 56, 8, 49, 2, 62, 36, 28, 61, 0, 25, 41, 63, 35, 8, 44, 6, 37, 62, 7, 21, 63, 28, 55, 31, 16, 24, 41, 19, 9, 57, 27, 36, 18, 42, 31, 62, 22, 55, 38, 4, 27, 47, 1, 40, 14, 54, 43, 20, 60, 23, 38, 63, 25, 51, 2, 53, 26, 63, 10, 42, 17, 34, 47, 25, 13, 5, 44, 11, 55, 2, 38, 27, 6, 60, 52, 25, 9, 55, 1, 40 },
- { 8, 30, 58, 3, 42, 61, 17, 38, 13, 59, 32, 10, 54, 3, 51, 20, 61, 26, 57, 2, 46, 33, 12, 60, 41, 13, 48, 29, 55, 20, 39, 27, 57, 18, 62, 29, 55, 2, 31, 16, 37, 50, 26, 36, 6, 46, 9, 41, 27, 57, 23, 39, 26, 6, 51, 12, 31, 46, 7, 16, 27, 52, 19, 56, 26, 12, 33, 53, 1, 41, 8, 57, 46, 7, 54, 32, 47, 5, 49, 11, 60, 23, 5, 48, 10, 43, 19, 63, 35, 24, 49, 21, 59, 5, 31, 37, 14, 44, 7, 42, 6, 30, 46, 13, 44, 32, 19, 50, 4, 58, 8, 30, 62, 38, 28, 53, 21, 36, 13, 50, 21, 33, 15, 2, 44, 31, 14, 47 },
- { 37, 13, 39, 16, 28, 9, 57, 0, 25, 49, 21, 45, 18, 47, 12, 42, 0, 49, 22, 39, 16, 53, 25, 36, 0, 52, 22, 16, 6, 60, 4, 51, 0, 26, 37, 47, 10, 36, 63, 5, 57, 0, 18, 59, 23, 33, 51, 19, 0, 44, 15, 11, 54, 17, 42, 35, 53, 18, 58, 33, 49, 4, 34, 42, 0, 50, 43, 25, 16, 49, 34, 20, 37, 28, 12, 63, 16, 38, 25, 44, 0, 40, 52, 17, 35, 3, 50, 14, 8, 53, 11, 36, 25, 45, 9, 62, 0, 54, 28, 17, 50, 55, 15, 24, 57, 0, 53, 34, 23, 41, 15, 45, 0, 49, 16, 4, 48, 9, 63, 45, 0, 42, 58, 37, 61, 22, 54, 26 },
- { 0, 50, 21, 47, 54, 36, 27, 45, 52, 4, 34, 15, 63, 29, 37, 59, 17, 31, 6, 61, 28, 5, 48, 18, 59, 27, 34, 56, 44, 31, 35, 12, 41, 59, 16, 3, 40, 20, 50, 22, 30, 40, 52, 10, 45, 3, 59, 22, 37, 61, 29, 46, 31, 58, 2, 22, 9, 43, 3, 39, 14, 61, 24, 54, 15, 29, 11, 60, 39, 17, 5, 61, 0, 44, 50, 3, 31, 14, 58, 21, 54, 28, 15, 45, 60, 26, 33, 58, 44, 22, 60, 2, 57, 34, 49, 27, 18, 34, 21, 59, 29, 4, 36, 41, 8, 39, 28, 11, 62, 26, 53, 20, 35, 24, 59, 32, 29, 39, 24, 31, 57, 23, 11, 28, 5, 36, 11, 59 },
- { 44, 32, 63, 5, 20, 12, 41, 7, 30, 61, 42, 8, 39, 5, 33, 8, 24, 53, 45, 11, 37, 58, 7, 44, 10, 50, 3, 40, 8, 22, 53, 19, 46, 9, 33, 52, 24, 58, 8, 44, 13, 47, 8, 34, 38, 30, 14, 47, 7, 34, 4, 55, 9, 19, 40, 49, 56, 26, 60, 21, 30, 45, 10, 19, 40, 58, 23, 36, 3, 52, 45, 23, 54, 13, 22, 42, 53, 45, 7, 33, 10, 36, 57, 6, 29, 12, 41, 0, 30, 15, 41, 30, 17, 7, 16, 53, 40, 56, 2, 39, 12, 61, 10, 52, 31, 60, 16, 45, 1, 37, 7, 61, 40, 10, 43, 17, 58, 7, 54, 14, 4, 51, 39, 49, 18, 56, 42, 20 },
- { 14, 6, 24, 36, 56, 49, 22, 60, 18, 14, 23, 51, 26, 57, 21, 52, 41, 14, 35, 50, 19, 31, 40, 23, 33, 14, 63, 17, 32, 47, 7, 62, 23, 30, 56, 11, 42, 27, 14, 60, 35, 19, 28, 61, 17, 55, 25, 39, 53, 17, 42, 21, 38, 63, 25, 5, 14, 36, 12, 50, 1, 37, 59, 32, 2, 51, 6, 56, 27, 32, 11, 30, 38, 26, 60, 8, 26, 19, 62, 39, 50, 2, 21, 39, 53, 23, 56, 19, 49, 39, 5, 46, 55, 23, 42, 4, 31, 11, 47, 26, 45, 22, 48, 18, 21, 5, 48, 25, 57, 14, 47, 30, 3, 56, 12, 50, 1, 42, 19, 47, 35, 17, 8, 30, 45, 25, 4, 51 },
- { 28, 58, 43, 1, 31, 8, 33, 2, 44, 55, 32, 1, 60, 12, 46, 27, 4, 62, 23, 1, 56, 13, 62, 2, 54, 36, 25, 51, 1, 57, 26, 42, 3, 49, 17, 38, 1, 48, 31, 4, 54, 3, 50, 24, 1, 49, 5, 63, 13, 27, 52, 1, 48, 13, 45, 33, 52, 30, 46, 20, 55, 28, 6, 48, 24, 38, 20, 47, 14, 62, 48, 9, 58, 4, 36, 30, 56, 1, 34, 12, 18, 63, 25, 48, 4, 16, 37, 7, 62, 10, 52, 28, 13, 50, 36, 63, 24, 51, 15, 58, 8, 33, 1, 38, 56, 35, 42, 9, 33, 51, 22, 18, 48, 32, 27, 37, 23, 61, 33, 11, 59, 29, 62, 1, 53, 10, 60, 33 },
- { 12, 39, 17, 52, 26, 46, 53, 38, 25, 11, 48, 36, 16, 43, 2, 35, 55, 17, 39, 29, 43, 9, 28, 45, 20, 5, 46, 12, 42, 28, 13, 52, 36, 6, 60, 22, 54, 17, 62, 39, 25, 42, 15, 55, 44, 20, 31, 10, 35, 57, 24, 32, 29, 6, 59, 18, 7, 62, 3, 41, 10, 44, 16, 54, 13, 62, 31, 9, 41, 1, 21, 43, 18, 47, 15, 40, 11, 49, 28, 55, 46, 30, 8, 43, 32, 61, 28, 47, 25, 34, 21, 61, 32, 1, 20, 9, 46, 6, 35, 19, 41, 54, 27, 63, 14, 3, 51, 20, 62, 2, 38, 55, 8, 21, 63, 6, 46, 9, 26, 51, 3, 24, 43, 34, 16, 41, 18, 48 },
- { 62, 23, 55, 9, 15, 62, 19, 13, 58, 40, 6, 30, 54, 19, 50, 31, 10, 44, 6, 59, 21, 47, 51, 15, 60, 39, 30, 54, 21, 61, 19, 33, 14, 29, 43, 11, 34, 45, 7, 21, 10, 56, 36, 6, 38, 11, 58, 42, 2, 47, 11, 60, 50, 16, 41, 28, 38, 23, 47, 17, 35, 63, 22, 33, 42, 5, 45, 17, 53, 35, 25, 56, 33, 6, 51, 19, 60, 23, 43, 15, 5, 40, 58, 13, 51, 1, 45, 11, 54, 3, 43, 8, 37, 48, 59, 29, 39, 21, 61, 43, 3, 31, 10, 44, 24, 29, 60, 12, 28, 40, 11, 25, 43, 52, 14, 41, 16, 57, 44, 20, 40, 55, 12, 21, 57, 27, 35, 2 },
- { 37, 6, 31, 42, 40, 4, 29, 50, 0, 20, 63, 28, 9, 58, 14, 24, 63, 26, 48, 16, 34, 4, 32, 38, 23, 11, 58, 4, 37, 9, 45, 5, 63, 48, 26, 57, 2, 28, 32, 51, 46, 29, 13, 62, 27, 46, 28, 18, 50, 15, 40, 4, 19, 34, 54, 0, 53, 9, 26, 58, 28, 5, 49, 0, 57, 27, 19, 60, 29, 8, 59, 12, 37, 63, 24, 46, 3, 37, 6, 52, 26, 32, 20, 36, 9, 22, 59, 18, 35, 51, 14, 57, 17, 24, 12, 44, 56, 0, 30, 13, 59, 20, 49, 17, 54, 43, 6, 34, 46, 17, 58, 36, 0, 34, 29, 54, 25, 2, 36, 15, 60, 6, 37, 46, 4, 50, 9, 45 },
- { 19, 59, 48, 3, 24, 60, 44, 22, 34, 51, 15, 45, 41, 5, 33, 47, 0, 37, 12, 55, 25, 54, 8, 57, 0, 47, 18, 34, 49, 15, 55, 24, 40, 20, 8, 35, 53, 13, 41, 18, 0, 59, 22, 33, 4, 52, 8, 60, 24, 36, 31, 56, 45, 26, 10, 43, 15, 56, 36, 4, 51, 14, 39, 30, 12, 55, 36, 2, 39, 49, 4, 44, 17, 0, 32, 13, 53, 35, 59, 17, 62, 0, 55, 24, 52, 38, 31, 6, 42, 19, 29, 40, 4, 54, 33, 5, 16, 27, 52, 37, 23, 55, 7, 37, 0, 39, 23, 49, 4, 53, 31, 15, 59, 10, 50, 4, 60, 34, 48, 7, 31, 49, 27, 14, 62, 22, 53, 29 },
- { 46, 21, 14, 51, 36, 17, 7, 57, 10, 32, 3, 37, 22, 60, 39, 18, 56, 20, 42, 3, 36, 10, 44, 26, 41, 29, 53, 27, 2, 39, 30, 52, 0, 59, 15, 48, 23, 61, 6, 58, 37, 12, 40, 49, 16, 39, 20, 44, 0, 62, 8, 21, 3, 59, 23, 32, 49, 31, 12, 44, 22, 59, 18, 50, 24, 7, 43, 52, 15, 23, 41, 26, 51, 28, 55, 39, 21, 27, 10, 42, 12, 45, 27, 47, 3, 15, 63, 26, 55, 0, 60, 26, 45, 18, 62, 38, 58, 49, 8, 47, 4, 33, 46, 29, 57, 13, 56, 16, 59, 21, 5, 47, 23, 39, 18, 44, 13, 22, 28, 53, 19, 0, 58, 32, 41, 7, 26, 13 },
- { 0, 56, 34, 28, 11, 55, 31, 47, 26, 41, 56, 13, 53, 28, 11, 49, 7, 52, 32, 61, 50, 22, 63, 17, 13, 56, 7, 19, 43, 62, 10, 21, 37, 32, 43, 4, 38, 19, 44, 25, 31, 54, 5, 23, 61, 30, 53, 12, 35, 22, 43, 53, 37, 48, 7, 62, 20, 2, 61, 41, 8, 34, 47, 9, 63, 34, 28, 10, 55, 33, 14, 57, 7, 47, 9, 61, 4, 49, 31, 50, 21, 38, 8, 16, 57, 44, 33, 5, 49, 36, 12, 50, 7, 34, 10, 25, 2, 22, 36, 15, 26, 61, 18, 9, 22, 46, 32, 8, 27, 37, 44, 30, 55, 3, 62, 24, 38, 56, 5, 45, 38, 24, 43, 10, 19, 54, 39, 61 },
- { 41, 30, 8, 63, 43, 23, 38, 3, 62, 19, 8, 49, 25, 1, 58, 30, 23, 40, 9, 28, 18, 40, 6, 38, 49, 22, 35, 59, 8, 27, 50, 5, 56, 17, 11, 50, 30, 9, 55, 2, 51, 19, 34, 47, 9, 41, 6, 26, 48, 57, 14, 28, 17, 12, 39, 13, 37, 46, 25, 19, 54, 27, 1, 37, 16, 45, 20, 60, 1, 48, 20, 38, 31, 22, 42, 15, 19, 44, 1, 61, 6, 34, 56, 40, 29, 10, 20, 46, 13, 22, 41, 23, 59, 42, 30, 51, 45, 13, 63, 53, 42, 12, 51, 38, 62, 2, 26, 41, 50, 1, 61, 10, 19, 42, 31, 8, 49, 32, 12, 63, 9, 52, 16, 56, 36, 2, 31, 16 },
- { 52, 5, 47, 20, 1, 53, 12, 50, 16, 35, 43, 21, 33, 43, 16, 44, 3, 59, 14, 46, 1, 30, 60, 33, 2, 45, 12, 42, 31, 47, 14, 33, 46, 25, 55, 27, 60, 36, 16, 42, 14, 46, 26, 1, 55, 15, 63, 32, 2, 38, 5, 47, 33, 61, 30, 52, 4, 57, 6, 38, 11, 43, 61, 24, 52, 3, 31, 22, 42, 10, 62, 3, 59, 11, 35, 57, 33, 54, 24, 14, 29, 48, 18, 2, 60, 41, 53, 24, 32, 62, 3, 53, 15, 1, 55, 17, 32, 40, 6, 31, 1, 40, 28, 5, 35, 52, 19, 63, 13, 33, 17, 41, 52, 26, 15, 57, 1, 20, 42, 17, 35, 27, 48, 5, 25, 50, 44, 11 },
- { 35, 25, 38, 57, 33, 17, 40, 6, 59, 27, 54, 5, 61, 10, 52, 26, 36, 19, 51, 35, 57, 48, 11, 20, 54, 25, 61, 16, 1, 58, 24, 61, 3, 39, 7, 47, 1, 22, 49, 28, 63, 10, 58, 32, 17, 36, 45, 19, 51, 29, 59, 10, 50, 1, 23, 42, 18, 29, 51, 21, 56, 32, 14, 5, 40, 58, 47, 13, 54, 35, 29, 45, 18, 52, 26, 2, 38, 8, 46, 36, 58, 11, 52, 35, 17, 28, 1, 58, 9, 39, 17, 28, 37, 48, 20, 9, 57, 24, 50, 19, 58, 16, 48, 25, 43, 11, 35, 6, 45, 24, 56, 4, 36, 7, 47, 35, 52, 28, 59, 30, 2, 61, 21, 33, 63, 12, 18, 59 },
- { 3, 49, 15, 10, 27, 61, 25, 45, 30, 0, 14, 47, 31, 38, 17, 62, 7, 55, 27, 4, 15, 24, 42, 52, 10, 34, 5, 51, 36, 18, 41, 11, 35, 21, 62, 13, 33, 57, 8, 35, 5, 40, 21, 43, 52, 3, 24, 56, 11, 16, 33, 25, 41, 20, 55, 8, 60, 35, 15, 48, 2, 57, 30, 49, 18, 25, 6, 39, 17, 57, 7, 25, 43, 5, 49, 16, 62, 22, 55, 4, 25, 43, 23, 7, 50, 11, 37, 48, 14, 51, 33, 57, 7, 27, 39, 46, 4, 29, 11, 43, 34, 56, 7, 60, 20, 54, 30, 57, 22, 49, 9, 33, 54, 14, 63, 23, 6, 43, 10, 40, 50, 13, 44, 8, 38, 33, 46, 23 },
- { 55, 39, 22, 50, 44, 4, 36, 9, 52, 23, 37, 59, 21, 2, 46, 13, 31, 41, 11, 45, 62, 29, 6, 37, 19, 48, 30, 23, 44, 7, 53, 28, 54, 16, 41, 29, 44, 18, 52, 24, 60, 15, 48, 7, 27, 59, 9, 34, 42, 54, 7, 63, 4, 46, 31, 27, 45, 0, 40, 26, 34, 17, 37, 10, 53, 29, 36, 50, 2, 27, 51, 11, 61, 37, 23, 41, 30, 7, 18, 50, 39, 14, 63, 32, 45, 61, 19, 30, 25, 44, 2, 47, 23, 63, 11, 34, 59, 37, 60, 3, 22, 14, 44, 30, 15, 0, 47, 15, 3, 38, 61, 20, 27, 45, 11, 39, 51, 16, 55, 3, 22, 54, 29, 58, 1, 57, 6, 29 },
- { 9, 17, 60, 2, 34, 56, 20, 62, 39, 12, 49, 6, 29, 56, 34, 48, 0, 58, 22, 38, 18, 43, 56, 0, 63, 14, 55, 3, 59, 31, 15, 45, 0, 49, 6, 58, 3, 38, 12, 45, 0, 37, 29, 57, 13, 39, 30, 49, 0, 23, 44, 36, 16, 57, 13, 54, 11, 24, 63, 9, 53, 7, 62, 42, 0, 59, 15, 23, 63, 34, 40, 16, 32, 0, 53, 12, 48, 28, 59, 33, 0, 53, 9, 27, 3, 22, 54, 5, 56, 9, 61, 13, 42, 14, 52, 19, 0, 21, 47, 27, 53, 36, 3, 50, 39, 58, 25, 40, 53, 28, 12, 50, 0, 59, 32, 2, 21, 34, 26, 46, 37, 7, 18, 47, 24, 14, 53, 42 },
- { 61, 32, 13, 54, 29, 7, 46, 13, 28, 57, 18, 41, 53, 15, 9, 39, 24, 49, 33, 3, 53, 9, 26, 32, 40, 28, 46, 39, 25, 9, 56, 21, 63, 37, 26, 22, 51, 27, 17, 56, 31, 53, 4, 43, 22, 46, 12, 18, 60, 40, 20, 26, 50, 21, 39, 5, 49, 33, 16, 44, 22, 46, 20, 32, 24, 45, 8, 43, 12, 46, 4, 48, 56, 20, 29, 58, 3, 40, 10, 42, 31, 21, 47, 41, 56, 38, 15, 42, 36, 27, 20, 33, 55, 3, 26, 44, 31, 54, 12, 35, 9, 63, 28, 10, 21, 32, 9, 60, 17, 8, 43, 29, 40, 16, 36, 48, 60, 7, 57, 14, 62, 31, 42, 15, 36, 40, 20, 26 },
- { 0, 37, 47, 23, 41, 18, 32, 48, 1, 35, 8, 25, 4, 26, 63, 20, 54, 8, 16, 61, 35, 23, 51, 15, 58, 7, 12, 20, 50, 34, 42, 4, 38, 10, 32, 47, 8, 60, 41, 20, 9, 25, 50, 19, 62, 1, 37, 56, 28, 8, 53, 11, 3, 58, 34, 43, 19, 60, 38, 4, 58, 31, 3, 51, 11, 55, 38, 30, 21, 58, 19, 26, 9, 44, 36, 13, 46, 20, 62, 24, 13, 60, 5, 28, 12, 34, 7, 59, 0, 53, 45, 6, 38, 30, 50, 7, 62, 16, 41, 5, 46, 18, 55, 42, 51, 5, 45, 23, 34, 48, 19, 58, 5, 25, 54, 19, 13, 41, 28, 21, 0, 49, 10, 60, 4, 51, 9, 45 },
- { 19, 28, 6, 58, 10, 51, 4, 22, 55, 42, 60, 45, 34, 51, 42, 5, 30, 45, 27, 40, 13, 47, 4, 49, 21, 38, 60, 29, 2, 57, 17, 27, 52, 19, 61, 14, 30, 34, 2, 44, 63, 33, 11, 35, 16, 51, 25, 6, 14, 47, 31, 61, 37, 29, 18, 8, 52, 2, 28, 54, 13, 41, 15, 62, 35, 18, 2, 60, 6, 33, 41, 61, 31, 6, 56, 17, 34, 50, 6, 52, 44, 35, 16, 51, 59, 24, 48, 18, 31, 40, 16, 49, 21, 60, 17, 39, 10, 49, 32, 57, 24, 39, 1, 25, 18, 62, 37, 12, 56, 1, 37, 11, 52, 44, 9, 30, 47, 4, 51, 40, 55, 25, 34, 27, 56, 30, 32, 54 },
- { 63, 40, 49, 15, 43, 26, 63, 38, 16, 20, 30, 12, 57, 14, 19, 60, 36, 12, 59, 2, 57, 17, 42, 31, 1, 44, 16, 35, 47, 11, 32, 48, 13, 43, 1, 39, 51, 12, 57, 23, 6, 40, 53, 3, 55, 31, 39, 60, 35, 44, 5, 15, 45, 1, 62, 41, 26, 14, 47, 22, 36, 27, 50, 9, 26, 47, 52, 28, 54, 16, 1, 13, 51, 39, 23, 63, 1, 30, 15, 26, 2, 57, 19, 37, 1, 44, 21, 50, 13, 63, 8, 24, 56, 1, 35, 25, 58, 20, 2, 28, 14, 51, 33, 59, 13, 30, 4, 49, 31, 24, 63, 26, 33, 3, 58, 38, 62, 24, 32, 8, 17, 45, 5, 48, 18, 3, 43, 11 },
- { 21, 4, 24, 34, 59, 1, 37, 11, 53, 5, 47, 2, 22, 40, 32, 1, 24, 50, 21, 29, 38, 25, 63, 8, 55, 24, 53, 6, 62, 23, 59, 3, 54, 20, 58, 24, 5, 46, 15, 38, 48, 14, 27, 42, 23, 7, 46, 10, 17, 58, 25, 52, 23, 32, 49, 12, 55, 30, 40, 7, 59, 1, 56, 21, 39, 4, 23, 15, 37, 46, 55, 42, 21, 4, 48, 8, 45, 54, 37, 55, 32, 8, 46, 10, 30, 54, 4, 41, 25, 29, 36, 48, 11, 43, 14, 47, 5, 43, 53, 36, 61, 10, 45, 6, 41, 54, 27, 43, 16, 55, 6, 46, 18, 42, 23, 15, 1, 45, 12, 60, 37, 22, 62, 12, 39, 59, 16, 52 },
- { 47, 35, 56, 7, 19, 46, 31, 50, 33, 24, 61, 35, 50, 7, 53, 44, 55, 6, 46, 10, 52, 5, 21, 43, 36, 10, 18, 41, 26, 37, 8, 29, 40, 36, 9, 49, 34, 26, 61, 21, 7, 59, 18, 62, 29, 54, 20, 32, 51, 0, 40, 10, 55, 6, 20, 36, 9, 61, 5, 51, 44, 19, 33, 43, 13, 57, 40, 63, 8, 24, 29, 10, 60, 34, 27, 40, 25, 18, 10, 42, 21, 49, 26, 62, 38, 12, 33, 61, 5, 57, 2, 19, 54, 28, 62, 22, 38, 31, 16, 7, 22, 47, 29, 17, 35, 8, 20, 51, 2, 40, 22, 50, 13, 61, 28, 53, 35, 20, 56, 30, 2, 53, 14, 41, 23, 34, 8, 31 },
- { 12, 2, 42, 29, 52, 13, 21, 8, 55, 14, 41, 17, 28, 58, 23, 11, 17, 36, 31, 62, 17, 34, 50, 14, 28, 61, 33, 52, 2, 51, 17, 45, 7, 25, 62, 30, 18, 55, 0, 42, 30, 35, 45, 1, 12, 48, 3, 63, 21, 36, 30, 48, 19, 59, 43, 27, 46, 17, 34, 25, 12, 29, 53, 6, 48, 31, 11, 34, 49, 3, 36, 50, 19, 47, 14, 61, 11, 36, 58, 4, 60, 14, 39, 22, 6, 52, 15, 35, 17, 46, 31, 42, 9, 34, 3, 52, 12, 60, 26, 56, 40, 2, 53, 23, 57, 38, 62, 14, 36, 59, 10, 31, 39, 6, 49, 9, 41, 26, 5, 48, 43, 27, 33, 58, 1, 50, 25, 57 },
- { 61, 37, 15, 61, 3, 39, 58, 43, 26, 0, 44, 10, 47, 3, 37, 63, 28, 43, 13, 39, 3, 57, 30, 59, 0, 48, 5, 43, 13, 22, 60, 33, 55, 15, 42, 4, 52, 10, 45, 13, 54, 4, 24, 49, 37, 26, 41, 14, 42, 9, 61, 13, 38, 23, 3, 53, 0, 58, 21, 42, 63, 10, 17, 61, 25, 0, 58, 28, 17, 44, 57, 12, 27, 0, 55, 5, 52, 28, 23, 47, 29, 0, 43, 17, 58, 28, 47, 23, 55, 10, 58, 23, 51, 40, 18, 33, 45, 0, 49, 8, 32, 61, 19, 48, 0, 26, 7, 47, 29, 18, 44, 0, 56, 34, 20, 59, 15, 51, 37, 18, 10, 52, 7, 20, 46, 9, 38, 17 },
- { 6, 27, 48, 23, 45, 29, 5, 18, 38, 62, 27, 56, 20, 32, 15, 9, 48, 0, 54, 22, 45, 20, 7, 41, 23, 39, 19, 27, 58, 31, 44, 0, 12, 50, 23, 56, 20, 39, 32, 59, 16, 52, 33, 9, 57, 22, 6, 58, 28, 50, 24, 2, 56, 35, 16, 45, 32, 38, 15, 54, 2, 38, 46, 22, 35, 45, 20, 5, 52, 25, 7, 35, 59, 32, 22, 43, 38, 3, 51, 16, 34, 53, 32, 50, 3, 40, 8, 43, 0, 39, 27, 4, 14, 61, 8, 55, 15, 41, 20, 44, 27, 13, 39, 11, 46, 42, 54, 33, 4, 52, 23, 61, 14, 25, 43, 2, 33, 11, 63, 29, 61, 17, 40, 55, 22, 62, 28, 44 },
- { 20, 54, 8, 56, 35, 10, 63, 31, 52, 12, 48, 6, 59, 41, 52, 33, 19, 58, 25, 49, 11, 37, 47, 12, 54, 15, 56, 35, 7, 47, 16, 53, 28, 34, 5, 37, 28, 8, 48, 3, 28, 38, 18, 61, 16, 43, 53, 32, 4, 17, 47, 27, 44, 8, 63, 10, 25, 49, 6, 37, 24, 52, 32, 3, 50, 12, 41, 56, 38, 14, 62, 20, 40, 16, 53, 31, 18, 63, 41, 9, 59, 7, 13, 25, 57, 20, 63, 26, 53, 18, 48, 62, 30, 46, 21, 25, 58, 29, 36, 4, 55, 34, 6, 60, 31, 16, 21, 12, 58, 38, 9, 29, 47, 7, 52, 30, 57, 44, 22, 0, 35, 45, 3, 31, 14, 36, 0, 51 },
- { 42, 14, 33, 24, 16, 49, 40, 2, 22, 33, 16, 36, 25, 1, 21, 61, 38, 8, 33, 4, 62, 26, 29, 60, 6, 46, 30, 11, 63, 4, 36, 40, 19, 57, 46, 11, 41, 63, 22, 25, 58, 10, 46, 2, 34, 27, 11, 38, 56, 34, 12, 53, 18, 33, 41, 51, 13, 28, 60, 20, 47, 14, 29, 59, 16, 62, 8, 22, 32, 47, 9, 49, 2, 44, 7, 12, 45, 6, 20, 27, 45, 24, 62, 42, 36, 11, 33, 15, 37, 7, 32, 10, 37, 1, 35, 50, 6, 11, 63, 24, 52, 15, 50, 24, 3, 37, 56, 27, 34, 22, 49, 16, 36, 62, 17, 39, 4, 15, 54, 24, 50, 8, 58, 26, 49, 54, 11, 30 },
- { 4, 59, 41, 1, 53, 12, 25, 45, 59, 7, 51, 39, 54, 14, 46, 4, 27, 53, 16, 44, 18, 51, 1, 32, 25, 2, 50, 40, 20, 54, 24, 9, 62, 2, 27, 60, 1, 17, 36, 50, 6, 40, 30, 55, 41, 19, 49, 1, 21, 60, 40, 5, 62, 1, 22, 30, 57, 4, 43, 31, 1, 55, 40, 7, 27, 37, 30, 54, 1, 19, 42, 30, 56, 26, 62, 49, 24, 57, 37, 56, 2, 39, 16, 5, 30, 55, 3, 49, 60, 23, 56, 44, 17, 52, 13, 42, 28, 48, 18, 45, 9, 37, 21, 41, 58, 10, 48, 1, 63, 5, 41, 57, 2, 24, 12, 48, 27, 42, 32, 46, 13, 38, 19, 34, 5, 41, 25, 60 },
- { 39, 28, 21, 46, 32, 57, 36, 9, 19, 42, 4, 29, 11, 43, 30, 49, 13, 42, 35, 56, 9, 39, 15, 52, 36, 61, 18, 26, 45, 14, 31, 48, 21, 43, 14, 33, 49, 54, 14, 44, 21, 62, 13, 23, 8, 62, 15, 51, 44, 7, 30, 37, 20, 42, 56, 7, 39, 18, 50, 11, 61, 9, 19, 43, 57, 2, 48, 11, 39, 60, 28, 4, 37, 17, 35, 1, 33, 11, 31, 14, 48, 19, 35, 51, 46, 21, 44, 29, 12, 41, 2, 22, 58, 26, 54, 4, 59, 38, 2, 33, 57, 1, 63, 13, 28, 51, 15, 40, 18, 45, 8, 30, 43, 37, 54, 19, 8, 59, 21, 6, 60, 29, 55, 10, 63, 15, 47, 17 },
- { 3, 50, 10, 62, 18, 5, 27, 49, 60, 23, 55, 18, 62, 24, 56, 10, 59, 28, 2, 23, 34, 59, 43, 20, 10, 42, 8, 49, 1, 37, 57, 6, 51, 29, 53, 7, 23, 31, 5, 32, 51, 0, 35, 54, 45, 31, 5, 26, 36, 24, 55, 15, 48, 29, 14, 48, 26, 60, 21, 41, 36, 26, 50, 33, 14, 44, 17, 24, 52, 15, 46, 23, 54, 6, 47, 21, 60, 50, 4, 53, 29, 61, 8, 23, 1, 60, 19, 6, 53, 16, 47, 34, 6, 39, 16, 31, 12, 20, 53, 22, 30, 43, 25, 46, 35, 6, 44, 32, 53, 26, 55, 19, 11, 59, 5, 33, 51, 1, 35, 53, 25, 3, 42, 23, 44, 32, 7, 53 },
- { 22, 44, 37, 6, 26, 51, 38, 0, 34, 13, 31, 46, 3, 37, 6, 19, 40, 21, 47, 63, 12, 5, 29, 55, 22, 58, 34, 28, 60, 22, 11, 41, 17, 38, 9, 44, 59, 39, 56, 19, 11, 47, 25, 15, 3, 39, 57, 17, 61, 11, 46, 3, 58, 9, 54, 35, 2, 34, 8, 45, 15, 56, 5, 23, 53, 33, 63, 35, 4, 59, 10, 51, 13, 61, 29, 41, 15, 25, 43, 19, 40, 10, 54, 33, 41, 12, 38, 51, 31, 26, 61, 9, 30, 45, 24, 62, 49, 40, 10, 61, 14, 49, 5, 17, 54, 20, 60, 23, 3, 13, 35, 50, 32, 23, 46, 27, 38, 63, 16, 12, 39, 48, 18, 51, 1, 27, 56, 35 },
- { 63, 15, 30, 55, 43, 14, 57, 17, 53, 44, 7, 48, 26, 50, 32, 60, 0, 53, 14, 31, 50, 24, 46, 0, 38, 13, 4, 52, 16, 45, 30, 59, 0, 25, 55, 35, 16, 10, 26, 42, 58, 29, 60, 38, 50, 22, 28, 47, 0, 50, 28, 19, 33, 39, 11, 44, 16, 52, 24, 59, 3, 38, 27, 51, 0, 21, 7, 42, 26, 34, 21, 40, 33, 18, 39, 3, 54, 38, 8, 59, 0, 44, 27, 15, 58, 28, 57, 9, 43, 0, 36, 50, 20, 59, 8, 34, 0, 27, 47, 7, 36, 19, 56, 32, 0, 38, 11, 29, 62, 47, 6, 61, 0, 41, 14, 56, 10, 23, 45, 31, 57, 8, 36, 13, 58, 38, 11, 19 },
- { 0, 34, 12, 47, 21, 2, 40, 30, 11, 25, 61, 20, 40, 15, 35, 22, 45, 36, 7, 41, 17, 57, 9, 48, 32, 62, 44, 24, 35, 3, 54, 13, 33, 63, 19, 4, 48, 22, 62, 2, 37, 8, 33, 6, 20, 52, 9, 32, 43, 13, 39, 63, 25, 4, 49, 23, 62, 32, 9, 30, 48, 18, 63, 12, 46, 29, 58, 13, 48, 8, 57, 31, 0, 51, 9, 58, 12, 22, 47, 29, 35, 22, 49, 5, 46, 4, 34, 20, 63, 24, 56, 11, 41, 3, 51, 19, 56, 35, 17, 58, 28, 42, 9, 45, 59, 26, 51, 42, 17, 36, 25, 15, 53, 21, 44, 3, 30, 55, 5, 50, 21, 28, 61, 32, 6, 49, 28, 46 },
- { 58, 42, 60, 4, 31, 59, 22, 63, 35, 38, 9, 54, 1, 57, 8, 51, 16, 58, 27, 53, 3, 38, 30, 15, 27, 6, 19, 56, 10, 50, 21, 36, 47, 5, 43, 28, 51, 32, 13, 46, 18, 54, 16, 43, 63, 12, 36, 59, 22, 34, 5, 52, 17, 59, 27, 41, 0, 19, 55, 37, 13, 43, 6, 34, 41, 10, 36, 55, 19, 44, 3, 16, 58, 27, 49, 25, 32, 62, 17, 55, 13, 63, 18, 52, 25, 37, 17, 48, 13, 32, 5, 46, 28, 37, 14, 43, 25, 5, 51, 39, 3, 52, 33, 22, 8, 40, 12, 4, 57, 9, 46, 39, 28, 58, 13, 62, 17, 42, 19, 36, 0, 47, 16, 43, 24, 21, 54, 13 },
- { 25, 9, 23, 50, 36, 8, 45, 14, 3, 51, 16, 28, 44, 12, 42, 29, 4, 26, 10, 47, 22, 61, 18, 54, 51, 39, 46, 13, 41, 26, 58, 7, 18, 39, 12, 57, 15, 1, 52, 27, 41, 23, 48, 1, 27, 45, 18, 2, 57, 26, 55, 8, 43, 31, 6, 58, 14, 51, 40, 5, 61, 31, 24, 54, 17, 60, 22, 1, 39, 30, 53, 45, 36, 13, 43, 5, 45, 2, 37, 6, 34, 42, 2, 39, 10, 62, 7, 54, 40, 18, 60, 15, 52, 21, 63, 8, 55, 46, 15, 30, 23, 13, 62, 16, 50, 24, 58, 31, 48, 21, 34, 2, 49, 7, 31, 37, 26, 48, 9, 61, 40, 11, 52, 2, 60, 40, 4, 37 },
- { 52, 28, 39, 16, 54, 19, 29, 55, 42, 20, 58, 33, 24, 63, 18, 55, 39, 62, 43, 34, 12, 40, 6, 35, 2, 25, 8, 62, 34, 1, 31, 42, 61, 27, 53, 24, 40, 61, 34, 8, 59, 4, 30, 56, 40, 6, 53, 42, 10, 48, 16, 37, 12, 46, 21, 36, 47, 11, 28, 45, 22, 10, 57, 2, 49, 31, 14, 44, 61, 11, 25, 6, 23, 63, 18, 36, 28, 56, 20, 51, 11, 48, 27, 56, 32, 22, 45, 30, 2, 42, 27, 39, 1, 44, 23, 31, 38, 22, 11, 61, 43, 54, 4, 47, 35, 2, 44, 16, 28, 54, 12, 62, 18, 43, 10, 52, 1, 58, 33, 15, 29, 56, 20, 34, 9, 30, 48, 17 },
- { 46, 2, 56, 11, 41, 1, 49, 6, 27, 47, 2, 48, 5, 32, 37, 3, 13, 19, 32, 1, 55, 28, 60, 17, 43, 59, 32, 20, 49, 16, 55, 23, 14, 46, 2, 36, 6, 30, 20, 49, 12, 47, 35, 14, 21, 60, 29, 14, 35, 24, 46, 1, 56, 29, 53, 8, 33, 23, 56, 1, 35, 46, 20, 39, 26, 4, 53, 28, 17, 38, 60, 34, 48, 9, 55, 15, 46, 7, 41, 31, 60, 24, 16, 36, 1, 59, 19, 52, 35, 6, 55, 11, 59, 33, 7, 57, 4, 29, 48, 1, 19, 26, 37, 30, 18, 63, 37, 6, 59, 1, 40, 24, 56, 33, 46, 22, 35, 7, 24, 53, 39, 5, 26, 45, 55, 18, 62, 7 },
- { 20, 60, 29, 34, 20, 62, 33, 52, 10, 36, 13, 60, 41, 21, 50, 27, 56, 49, 8, 51, 21, 45, 11, 48, 8, 23, 53, 3, 29, 44, 5, 52, 9, 32, 50, 17, 43, 56, 3, 38, 24, 10, 62, 25, 51, 9, 33, 49, 61, 7, 30, 62, 22, 19, 2, 42, 63, 5, 49, 18, 60, 15, 52, 7, 43, 56, 23, 50, 5, 50, 2, 20, 41, 30, 1, 52, 22, 61, 14, 26, 3, 43, 53, 7, 47, 28, 11, 14, 23, 58, 33, 25, 47, 13, 50, 17, 40, 54, 34, 60, 41, 6, 59, 14, 50, 7, 25, 55, 20, 42, 51, 8, 27, 4, 16, 60, 28, 50, 44, 3, 22, 49, 63, 12, 33, 1, 43, 31 },
- { 36, 5, 46, 8, 44, 24, 13, 39, 25, 57, 31, 18, 8, 52, 10, 45, 6, 30, 36, 24, 63, 4, 33, 26, 57, 40, 15, 56, 37, 12, 40, 25, 37, 58, 11, 63, 21, 45, 16, 60, 31, 53, 18, 33, 3, 45, 23, 0, 20, 54, 40, 15, 50, 38, 60, 16, 25, 42, 29, 38, 7, 41, 25, 62, 18, 33, 8, 35, 42, 16, 32, 56, 12, 39, 59, 19, 34, 9, 49, 38, 57, 12, 21, 50, 14, 40, 61, 44, 50, 9, 49, 19, 3, 29, 35, 62, 12, 24, 7, 18, 52, 32, 10, 46, 21, 41, 32, 11, 36, 29, 14, 34, 60, 38, 54, 11, 41, 14, 19, 57, 32, 16, 7, 41, 51, 25, 14, 57 },
- { 53, 18, 26, 50, 15, 58, 4, 63, 17, 43, 7, 40, 61, 35, 15, 41, 23, 60, 16, 38, 14, 42, 19, 50, 0, 31, 10, 46, 27, 63, 18, 60, 0, 20, 29, 39, 8, 26, 37, 5, 42, 0, 44, 39, 57, 17, 58, 41, 28, 37, 4, 32, 9, 44, 12, 31, 54, 10, 59, 14, 27, 53, 12, 36, 0, 47, 13, 63, 21, 58, 10, 24, 50, 27, 4, 26, 44, 53, 31, 0, 18, 42, 29, 33, 57, 4, 32, 26, 0, 38, 16, 61, 41, 53, 20, 0, 42, 44, 49, 27, 10, 56, 39, 0, 57, 15, 53, 49, 3, 61, 22, 47, 17, 5, 49, 26, 2, 63, 39, 10, 47, 27, 37, 23, 4, 59, 38, 10 },
- { 23, 39, 61, 3, 37, 28, 48, 31, 0, 34, 51, 23, 2, 26, 58, 0, 53, 11, 46, 1, 57, 29, 52, 14, 37, 61, 21, 35, 2, 49, 7, 34, 47, 55, 4, 33, 54, 13, 58, 52, 19, 50, 22, 7, 13, 29, 36, 11, 51, 17, 60, 25, 55, 4, 34, 51, 0, 35, 20, 48, 32, 3, 51, 30, 59, 28, 40, 3, 46, 29, 54, 43, 7, 62, 47, 11, 39, 4, 23, 46, 55, 8, 63, 5, 25, 37, 18, 46, 21, 56, 31, 5, 36, 8, 45, 58, 26, 15, 2, 36, 47, 21, 29, 44, 25, 34, 3, 27, 43, 10, 52, 0, 45, 30, 24, 36, 43, 18, 34, 59, 0, 52, 61, 15, 44, 19, 30, 49 },
- { 0, 27, 12, 43, 54, 9, 22, 53, 21, 46, 15, 55, 29, 47, 20, 33, 39, 28, 59, 35, 9, 44, 5, 24, 47, 7, 52, 17, 56, 22, 30, 42, 14, 26, 45, 18, 49, 1, 24, 34, 11, 27, 55, 32, 61, 47, 2, 56, 6, 44, 13, 47, 36, 27, 58, 22, 16, 47, 40, 4, 57, 38, 21, 45, 16, 9, 56, 26, 11, 38, 0, 22, 36, 17, 33, 57, 16, 30, 62, 15, 35, 40, 20, 45, 59, 10, 54, 8, 63, 13, 52, 27, 22, 57, 28, 12, 32, 51, 55, 22, 63, 4, 16, 54, 12, 62, 45, 19, 58, 13, 32, 40, 20, 56, 7, 57, 9, 54, 6, 29, 42, 21, 8, 55, 35, 47, 6, 41 },
- { 56, 33, 58, 32, 19, 35, 42, 6, 59, 11, 38, 5, 49, 12, 62, 7, 52, 17, 5, 25, 54, 20, 61, 31, 54, 27, 41, 11, 44, 5, 59, 12, 36, 51, 10, 61, 28, 41, 48, 9, 43, 63, 5, 40, 20, 8, 49, 26, 34, 21, 58, 1, 18, 45, 7, 39, 61, 26, 8, 50, 23, 10, 63, 5, 55, 37, 19, 49, 52, 15, 59, 47, 13, 54, 1, 25, 42, 58, 10, 48, 3, 27, 50, 1, 17, 48, 34, 41, 16, 40, 2, 45, 10, 39, 17, 61, 5, 38, 19, 9, 41, 31, 60, 38, 5, 23, 36, 8, 30, 55, 24, 63, 12, 48, 14, 51, 31, 20, 45, 25, 12, 50, 32, 2, 28, 11, 62, 14 },
- { 44, 16, 7, 48, 1, 62, 16, 50, 27, 33, 61, 25, 17, 44, 31, 14, 22, 43, 32, 48, 18, 40, 8, 36, 3, 16, 33, 62, 23, 38, 25, 53, 2, 21, 41, 6, 22, 15, 59, 29, 16, 37, 26, 15, 52, 42, 23, 15, 54, 39, 10, 30, 53, 11, 49, 24, 2, 43, 55, 17, 34, 44, 15, 31, 24, 44, 2, 32, 7, 35, 25, 5, 40, 45, 29, 51, 6, 21, 37, 52, 24, 60, 13, 31, 53, 23, 2, 28, 49, 24, 31, 60, 20, 51, 1, 34, 48, 14, 59, 33, 50, 1, 18, 33, 48, 60, 17, 51, 39, 6, 38, 2, 35, 29, 40, 23, 1, 62, 15, 53, 37, 17, 46, 57, 40, 51, 24, 22 },
- { 5, 37, 52, 24, 45, 13, 40, 3, 45, 9, 19, 42, 56, 4, 37, 46, 56, 2, 63, 11, 51, 1, 49, 13, 59, 45, 39, 1, 48, 15, 58, 9, 46, 31, 54, 35, 57, 38, 3, 46, 56, 4, 47, 57, 1, 30, 38, 63, 3, 46, 28, 63, 41, 14, 33, 62, 19, 32, 13, 28, 61, 1, 53, 42, 11, 60, 22, 62, 27, 42, 61, 31, 19, 8, 61, 12, 32, 55, 2, 18, 33, 12, 43, 36, 9, 62, 30, 55, 6, 58, 35, 7, 43, 29, 54, 23, 43, 30, 3, 25, 11, 45, 52, 28, 7, 14, 42, 1, 22, 50, 16, 53, 19, 59, 4, 46, 33, 41, 4, 35, 58, 5, 26, 13, 20, 2, 34, 54 },
- { 30, 63, 21, 10, 26, 55, 29, 59, 23, 39, 53, 1, 36, 24, 59, 27, 10, 34, 23, 38, 30, 60, 22, 42, 28, 19, 9, 57, 30, 19, 43, 33, 13, 63, 3, 19, 11, 50, 31, 20, 14, 34, 10, 35, 17, 59, 7, 31, 19, 25, 50, 5, 20, 57, 29, 6, 52, 41, 4, 46, 20, 37, 26, 17, 49, 6, 39, 18, 53, 14, 3, 49, 57, 23, 34, 48, 14, 41, 28, 38, 56, 6, 58, 25, 39, 19, 43, 15, 37, 11, 47, 18, 53, 4, 37, 9, 62, 21, 53, 40, 57, 24, 13, 40, 56, 26, 47, 31, 59, 25, 45, 27, 10, 43, 21, 61, 13, 27, 48, 9, 23, 43, 31, 62, 38, 59, 9, 47 },
- { 25, 4, 40, 60, 34, 6, 18, 36, 8, 57, 12, 30, 49, 14, 6, 54, 41, 16, 50, 6, 43, 15, 34, 4, 53, 24, 50, 35, 4, 51, 7, 55, 28, 24, 39, 44, 60, 7, 25, 62, 42, 53, 24, 61, 28, 45, 52, 12, 48, 37, 9, 35, 43, 3, 37, 48, 12, 58, 30, 52, 9, 59, 6, 57, 33, 29, 48, 4, 37, 45, 20, 34, 10, 39, 0, 60, 22, 45, 8, 63, 21, 42, 14, 49, 3, 56, 11, 46, 21, 61, 0, 42, 25, 13, 63, 17, 36, 8, 46, 16, 6, 35, 63, 0, 21, 37, 4, 57, 9, 34, 5, 61, 48, 32, 8, 37, 54, 17, 56, 30, 60, 0, 50, 16, 7, 29, 42, 17 },
- { 32, 50, 15, 48, 2, 43, 52, 25, 47, 16, 32, 63, 21, 52, 40, 19, 0, 61, 29, 58, 20, 56, 26, 46, 12, 55, 6, 22, 62, 32, 17, 40, 0, 49, 34, 8, 27, 32, 48, 0, 21, 39, 5, 44, 12, 6, 22, 40, 0, 57, 16, 60, 23, 17, 54, 22, 36, 15, 24, 39, 19, 34, 47, 23, 0, 54, 13, 51, 24, 9, 55, 16, 52, 27, 44, 20, 4, 54, 26, 49, 0, 30, 46, 16, 29, 51, 34, 4, 52, 28, 33, 15, 57, 39, 26, 49, 0, 56, 27, 31, 48, 20, 43, 29, 53, 11, 46, 19, 41, 13, 55, 18, 0, 57, 26, 51, 2, 44, 6, 38, 14, 40, 22, 45, 36, 53, 3, 57 },
- { 44, 12, 37, 28, 22, 57, 11, 38, 0, 51, 9, 41, 4, 29, 11, 47, 33, 45, 12, 26, 3, 36, 9, 63, 31, 16, 38, 44, 14, 47, 25, 61, 20, 58, 15, 47, 17, 57, 13, 36, 9, 51, 18, 29, 50, 36, 54, 20, 61, 27, 32, 13, 53, 44, 9, 27, 0, 63, 45, 2, 56, 10, 14, 43, 41, 28, 58, 11, 35, 60, 30, 41, 6, 63, 11, 51, 37, 32, 15, 10, 35, 53, 5, 61, 22, 7, 26, 59, 23, 9, 44, 48, 21, 3, 51, 32, 24, 41, 12, 61, 2, 55, 9, 15, 35, 58, 28, 15, 62, 30, 37, 23, 42, 29, 11, 17, 35, 24, 63, 20, 52, 28, 8, 55, 11, 23, 47, 19 },
- { 0, 56, 8, 53, 14, 31, 61, 20, 55, 28, 62, 18, 35, 60, 25, 57, 7, 23, 39, 54, 47, 17, 43, 0, 40, 59, 29, 2, 56, 10, 37, 5, 43, 11, 29, 52, 1, 23, 54, 41, 59, 30, 55, 1, 62, 15, 33, 4, 43, 10, 47, 39, 1, 31, 40, 60, 49, 33, 7, 55, 26, 50, 31, 61, 8, 18, 21, 32, 44, 1, 25, 47, 18, 36, 30, 23, 59, 7, 40, 59, 27, 19, 38, 32, 44, 54, 40, 17, 38, 60, 27, 6, 35, 55, 10, 14, 44, 5, 50, 17, 38, 26, 42, 50, 18, 3, 44, 52, 2, 49, 7, 52, 15, 46, 62, 39, 55, 10, 31, 48, 3, 58, 33, 18, 61, 34, 13, 59 },
- { 39, 27, 63, 20, 35, 41, 4, 45, 26, 5, 38, 13, 44, 2, 50, 17, 37, 52, 2, 13, 28, 58, 24, 51, 21, 8, 34, 48, 27, 42, 18, 51, 31, 56, 5, 36, 38, 44, 4, 17, 26, 11, 38, 23, 42, 8, 56, 39, 24, 51, 5, 56, 21, 59, 14, 6, 18, 42, 22, 35, 16, 37, 3, 25, 39, 46, 63, 5, 50, 17, 58, 8, 55, 3, 50, 12, 43, 17, 47, 2, 51, 9, 62, 12, 1, 35, 13, 50, 1, 37, 12, 51, 19, 29, 46, 59, 22, 58, 33, 45, 22, 60, 10, 32, 61, 39, 8, 33, 25, 36, 20, 60, 38, 4, 21, 5, 28, 45, 12, 18, 42, 11, 49, 1, 27, 40, 6, 30 },
- { 24, 16, 42, 1, 50, 10, 48, 17, 33, 43, 24, 48, 21, 55, 31, 42, 10, 21, 63, 35, 49, 6, 33, 13, 41, 53, 10, 20, 60, 6, 53, 26, 12, 41, 22, 60, 14, 28, 63, 33, 49, 3, 45, 16, 48, 26, 14, 46, 18, 30, 35, 26, 8, 50, 29, 51, 25, 57, 12, 47, 53, 9, 62, 20, 54, 2, 36, 15, 40, 28, 33, 13, 38, 24, 46, 1, 29, 56, 33, 20, 44, 24, 41, 26, 57, 20, 63, 8, 30, 55, 5, 41, 62, 8, 34, 2, 37, 10, 19, 6, 37, 1, 53, 23, 5, 27, 58, 22, 43, 12, 50, 26, 9, 34, 54, 32, 49, 1, 59, 37, 22, 46, 25, 36, 51, 15, 54, 46 },
- { 52, 7, 45, 33, 26, 58, 14, 60, 7, 54, 3, 58, 8, 34, 14, 5, 59, 30, 18, 44, 8, 22, 48, 62, 3, 26, 55, 38, 23, 16, 39, 1, 62, 24, 49, 9, 53, 19, 46, 7, 19, 60, 31, 58, 2, 34, 53, 7, 59, 2, 62, 42, 46, 19, 36, 11, 44, 4, 38, 28, 1, 43, 32, 51, 12, 29, 56, 22, 52, 2, 62, 49, 22, 60, 14, 35, 63, 5, 25, 57, 14, 53, 4, 46, 18, 31, 42, 22, 47, 20, 58, 31, 16, 43, 23, 54, 30, 42, 52, 57, 29, 49, 30, 13, 45, 48, 16, 55, 6, 63, 1, 44, 14, 58, 19, 47, 15, 24, 51, 34, 6, 55, 5, 63, 20, 41, 21, 9 },
- { 30, 62, 18, 55, 5, 23, 39, 29, 49, 30, 15, 36, 28, 46, 60, 25, 39, 46, 4, 32, 61, 40, 15, 30, 36, 45, 14, 2, 49, 33, 57, 45, 18, 32, 3, 45, 30, 2, 35, 52, 40, 27, 13, 21, 38, 63, 20, 28, 37, 23, 16, 10, 13, 55, 2, 62, 21, 32, 60, 17, 58, 23, 5, 40, 16, 48, 7, 45, 10, 26, 43, 19, 6, 31, 52, 21, 39, 16, 48, 9, 37, 28, 36, 55, 7, 48, 3, 59, 15, 45, 25, 1, 53, 13, 47, 7, 62, 15, 4, 25, 12, 41, 18, 60, 38, 11, 34, 19, 39, 31, 29, 56, 23, 42, 3, 27, 60, 41, 8, 16, 61, 29, 43, 9, 32, 2, 60, 34 },
- { 3, 38, 13, 37, 52, 44, 2, 19, 12, 42, 63, 19, 40, 1, 20, 50, 12, 55, 15, 56, 27, 1, 54, 11, 57, 18, 32, 63, 44, 4, 29, 13, 37, 61, 35, 16, 42, 57, 12, 22, 6, 55, 43, 10, 50, 5, 44, 11, 48, 52, 34, 58, 28, 41, 38, 30, 7, 52, 11, 49, 30, 14, 45, 27, 59, 34, 21, 38, 32, 58, 11, 36, 56, 42, 9, 41, 3, 54, 31, 42, 0, 60, 16, 11, 39, 24, 52, 33, 6, 36, 10, 40, 32, 60, 26, 20, 39, 28, 47, 34, 63, 8, 54, 3, 24, 56, 0, 51, 13, 47, 16, 40, 7, 35, 52, 11, 36, 4, 57, 30, 39, 13, 18, 50, 58, 28, 12, 48 },
- { 57, 24, 49, 21, 10, 31, 61, 36, 56, 0, 22, 53, 11, 56, 32, 7, 36, 27, 41, 9, 46, 19, 34, 42, 25, 7, 50, 9, 28, 21, 54, 8, 50, 7, 27, 59, 10, 25, 48, 62, 37, 0, 33, 58, 25, 18, 32, 61, 0, 15, 45, 5, 50, 3, 23, 55, 47, 17, 40, 6, 60, 34, 53, 8, 41, 0, 61, 13, 54, 4, 46, 28, 0, 17, 48, 27, 58, 13, 23, 61, 33, 21, 50, 30, 62, 8, 14, 29, 56, 27, 61, 49, 17, 2, 44, 11, 51, 0, 59, 17, 40, 20, 32, 47, 36, 21, 42, 28, 60, 4, 54, 10, 59, 17, 30, 62, 21, 43, 26, 48, 0, 56, 36, 25, 8, 44, 39, 17 },
- { 10, 42, 4, 59, 27, 47, 8, 23, 51, 32, 45, 6, 37, 26, 48, 43, 62, 0, 21, 53, 38, 12, 51, 5, 60, 47, 24, 37, 59, 15, 35, 47, 22, 55, 0, 50, 21, 40, 6, 29, 15, 52, 24, 8, 41, 55, 13, 29, 40, 56, 24, 31, 19, 33, 61, 15, 0, 35, 24, 42, 21, 2, 19, 57, 24, 15, 30, 50, 20, 25, 40, 16, 57, 34, 61, 8, 29, 45, 6, 49, 11, 47, 2, 44, 19, 57, 38, 50, 12, 42, 21, 4, 35, 52, 28, 56, 23, 36, 13, 45, 4, 52, 27, 14, 6, 62, 9, 45, 21, 37, 25, 46, 33, 49, 0, 44, 7, 53, 13, 19, 53, 31, 3, 47, 15, 56, 22, 51 },
- { 35, 28, 53, 32, 1, 16, 54, 40, 9, 17, 25, 58, 14, 59, 3, 22, 16, 51, 31, 5, 23, 58, 28, 17, 35, 20, 0, 42, 11, 52, 3, 31, 41, 17, 43, 13, 32, 54, 18, 60, 32, 45, 17, 49, 2, 36, 51, 22, 7, 36, 9, 63, 48, 12, 46, 26, 43, 28, 63, 13, 48, 37, 51, 33, 5, 47, 55, 9, 42, 63, 7, 51, 24, 12, 37, 19, 55, 34, 18, 38, 15, 28, 54, 34, 5, 43, 22, 0, 48, 14, 54, 24, 58, 9, 38, 5, 32, 55, 21, 30, 49, 9, 59, 43, 30, 51, 35, 26, 7, 53, 2, 22, 14, 27, 57, 18, 38, 24, 33, 45, 10, 41, 20, 60, 37, 5, 32, 0 },
- { 63, 19, 15, 40, 62, 35, 14, 28, 46, 61, 4, 49, 35, 10, 29, 54, 33, 8, 45, 62, 37, 1, 43, 55, 10, 52, 61, 30, 19, 40, 25, 62, 11, 38, 27, 58, 36, 3, 46, 8, 39, 4, 62, 28, 47, 20, 4, 54, 47, 27, 43, 1, 21, 38, 8, 58, 10, 54, 4, 56, 9, 26, 12, 39, 60, 27, 18, 37, 1, 31, 35, 5, 45, 50, 2, 43, 26, 1, 59, 23, 56, 40, 7, 26, 58, 17, 32, 63, 25, 39, 7, 31, 45, 19, 63, 15, 48, 8, 37, 61, 16, 34, 1, 56, 18, 3, 15, 58, 49, 32, 63, 41, 55, 5, 40, 22, 50, 6, 59, 2, 63, 23, 52, 11, 26, 61, 44, 23 },
- { 11, 56, 46, 6, 22, 43, 58, 3, 34, 21, 38, 30, 18, 44, 52, 13, 41, 57, 17, 28, 14, 49, 25, 7, 33, 39, 26, 6, 56, 48, 1, 20, 56, 5, 46, 9, 19, 51, 30, 25, 56, 21, 35, 14, 57, 42, 16, 33, 10, 57, 17, 59, 41, 25, 53, 37, 20, 40, 30, 18, 31, 62, 44, 22, 3, 44, 11, 48, 23, 53, 18, 60, 29, 22, 62, 15, 53, 47, 10, 41, 3, 19, 52, 36, 13, 46, 10, 35, 3, 61, 41, 16, 1, 50, 26, 42, 18, 46, 2, 25, 54, 20, 39, 23, 47, 31, 41, 12, 38, 17, 8, 19, 31, 48, 12, 61, 9, 54, 29, 35, 15, 38, 6, 43, 34, 14, 7, 47 },
- { 39, 2, 33, 26, 53, 8, 18, 50, 41, 12, 53, 1, 63, 24, 19, 39, 2, 24, 47, 10, 60, 38, 19, 63, 48, 4, 15, 45, 32, 14, 60, 36, 29, 53, 23, 63, 34, 12, 61, 1, 43, 11, 53, 30, 1, 26, 60, 45, 23, 39, 3, 29, 12, 50, 4, 16, 51, 3, 45, 36, 50, 1, 16, 54, 35, 14, 57, 30, 58, 9, 46, 14, 41, 10, 32, 38, 4, 30, 21, 51, 32, 63, 25, 1, 60, 27, 53, 18, 51, 22, 28, 55, 34, 12, 40, 3, 60, 29, 57, 41, 6, 44, 11, 53, 8, 61, 24, 57, 1, 28, 44, 59, 36, 3, 34, 25, 41, 31, 16, 44, 22, 47, 28, 58, 1, 49, 54, 29 },
- { 58, 25, 50, 13, 38, 30, 60, 24, 6, 57, 27, 42, 9, 45, 6, 61, 30, 50, 4, 34, 29, 3, 46, 13, 22, 42, 58, 28, 9, 39, 23, 44, 7, 15, 44, 2, 40, 15, 47, 41, 23, 37, 7, 59, 38, 11, 34, 6, 62, 14, 52, 35, 55, 19, 32, 61, 33, 24, 57, 6, 22, 59, 29, 7, 49, 25, 40, 3, 17, 39, 27, 52, 0, 55, 16, 57, 24, 61, 36, 6, 29, 12, 48, 39, 20, 44, 6, 40, 33, 5, 48, 10, 57, 36, 22, 51, 33, 9, 24, 12, 62, 29, 50, 35, 14, 43, 5, 33, 47, 52, 13, 23, 10, 51, 56, 16, 46, 1, 49, 4, 61, 9, 52, 18, 31, 21, 36, 17 },
- { 19, 42, 9, 48, 2, 44, 11, 37, 48, 20, 33, 16, 55, 35, 49, 15, 37, 20, 59, 16, 53, 22, 56, 31, 50, 11, 34, 54, 16, 51, 4, 49, 33, 53, 21, 28, 56, 24, 31, 9, 52, 16, 48, 24, 44, 13, 51, 20, 31, 49, 18, 6, 34, 2, 44, 14, 47, 8, 15, 43, 13, 41, 33, 52, 20, 61, 7, 51, 34, 62, 4, 20, 36, 33, 43, 8, 46, 13, 53, 17, 45, 42, 9, 31, 52, 11, 30, 56, 13, 59, 17, 44, 27, 6, 62, 11, 43, 17, 49, 38, 26, 2, 16, 27, 58, 21, 54, 18, 26, 5, 35, 61, 43, 27, 7, 39, 14, 58, 37, 55, 20, 33, 13, 40, 62, 10, 55, 5 },
- { 51, 14, 61, 29, 59, 20, 55, 31, 0, 49, 11, 60, 3, 26, 22, 56, 0, 40, 12, 43, 41, 8, 36, 0, 17, 57, 24, 2, 46, 26, 61, 18, 0, 38, 12, 59, 6, 49, 3, 57, 19, 63, 5, 33, 18, 54, 28, 56, 0, 43, 26, 46, 63, 27, 56, 22, 27, 54, 38, 28, 63, 24, 10, 45, 0, 31, 42, 21, 12, 25, 44, 49, 59, 6, 26, 50, 3, 34, 27, 59, 0, 35, 62, 16, 4, 58, 47, 0, 43, 24, 37, 2, 54, 20, 46, 31, 0, 56, 34, 5, 55, 45, 60, 37, 0, 40, 10, 38, 63, 46, 15, 20, 0, 53, 21, 62, 30, 11, 24, 27, 40, 0, 57, 26, 3, 45, 27, 35 }
+const DATA8 _dither_128128[128][128] = {
+ {0, 41, 23, 5, 17, 39, 7, 15, 62, 23, 40, 51, 31, 47, 9, 32, 52, 27, 57, 25,
+ 6, 61, 27, 52, 37, 7, 40, 63, 18, 36, 10, 42, 25, 62, 45, 34, 20, 42, 37,
+ 14, 35, 29, 50, 10, 61, 2, 40, 8, 37, 12, 58, 22, 5, 41, 10, 39, 0, 60, 11,
+ 46, 2, 55, 38, 17, 36, 59, 13, 54, 37, 56, 8, 29, 16, 13, 63, 22, 41, 55, 7,
+ 20, 49, 14, 23, 55, 37, 23, 19, 36, 15, 49, 23, 63, 30, 14, 38, 27, 53, 13,
+ 22, 41, 19, 31, 7, 19, 50, 30, 49, 16, 3, 32, 56, 40, 29, 34, 8, 48, 19, 45,
+ 4, 51, 12, 46, 35, 49, 16, 42, 12, 62},
+ {30, 57, 36, 54, 47, 34, 52, 27, 43, 4, 28, 7, 17, 36, 62, 13, 44, 7, 18, 48,
+ 33, 21, 44, 14, 30, 47, 12, 33, 5, 55, 31, 58, 13, 30, 4, 17, 52, 10, 60,
+ 26, 46, 0, 39, 27, 42, 22, 47, 25, 60, 32, 9, 38, 48, 17, 59, 30, 49, 18,
+ 34, 25, 51, 19, 5, 48, 21, 8, 28, 46, 1, 32, 41, 19, 54, 47, 37, 18, 28, 11,
+ 44, 30, 39, 56, 2, 33, 8, 42, 61, 28, 58, 8, 46, 9, 41, 4, 58, 7, 21, 48,
+ 59, 10, 52, 14, 42, 57, 12, 25, 7, 53, 42, 24, 11, 50, 17, 59, 42, 2, 36,
+ 60, 32, 17, 63, 29, 21, 7, 59, 32, 24, 39},
+ {22, 8, 16, 32, 3, 25, 13, 57, 18, 45, 58, 39, 55, 20, 5, 42, 23, 34, 63, 1,
+ 51, 10, 58, 4, 60, 23, 53, 27, 44, 21, 3, 48, 8, 50, 43, 54, 27, 32, 5, 55,
+ 21, 58, 12, 53, 6, 36, 14, 50, 17, 29, 53, 15, 24, 52, 7, 36, 13, 42, 4, 53,
+ 9, 35, 61, 26, 56, 32, 49, 15, 62, 23, 6, 60, 2, 31, 4, 48, 58, 38, 15, 61,
+ 5, 25, 47, 28, 50, 15, 7, 40, 3, 32, 33, 52, 25, 50, 35, 42, 61, 3, 28, 36,
+ 23, 63, 4, 33, 46, 62, 36, 23, 60, 6, 54, 28, 4, 37, 23, 55, 25, 8, 42, 54,
+ 14, 6, 56, 38, 19, 52, 4, 46},
+ {48, 53, 43, 12, 45, 63, 30, 37, 9, 34, 21, 1, 25, 47, 29, 58, 3, 54, 15, 39,
+ 29, 17, 38, 35, 20, 43, 1, 49, 15, 59, 29, 39, 22, 35, 16, 23, 1, 47, 39,
+ 18, 8, 44, 25, 31, 57, 19, 63, 4, 45, 3, 42, 61, 1, 31, 45, 20, 57, 29, 62,
+ 21, 32, 41, 14, 44, 3, 39, 5, 34, 10, 43, 51, 35, 23, 52, 40, 10, 21, 1, 53,
+ 18, 51, 43, 12, 62, 18, 54, 26, 51, 20, 57, 14, 1, 62, 16, 11, 18, 32, 39,
+ 17, 44, 1, 48, 26, 37, 18, 2, 51, 14, 28, 45, 35, 18, 57, 13, 47, 11, 51,
+ 20, 2, 39, 31, 47, 25, 1, 50, 11, 60, 7},
+ {18, 28, 1, 56, 21, 10, 51, 2, 46, 54, 14, 61, 11, 50, 13, 38, 19, 31, 45, 9,
+ 55, 24, 47, 5, 54, 9, 62, 11, 35, 8, 51, 14, 57, 6, 63, 40, 58, 14, 51, 28,
+ 62, 34, 15, 48, 1, 41, 30, 35, 55, 21, 34, 11, 49, 37, 8, 52, 4, 23, 15, 43,
+ 1, 58, 11, 23, 53, 16, 55, 26, 58, 18, 27, 12, 45, 14, 25, 63, 42, 33, 27,
+ 35, 9, 31, 21, 38, 1, 44, 34, 12, 48, 38, 21, 44, 29, 47, 26, 53, 1, 46, 54,
+ 8, 59, 29, 11, 55, 22, 41, 33, 20, 39, 1, 48, 9, 44, 32, 5, 62, 29, 44, 57,
+ 23, 10, 58, 34, 43, 15, 37, 26, 33},
+ {51, 38, 59, 24, 35, 42, 19, 60, 5, 32, 41, 26, 43, 33, 7, 53, 48, 11, 59,
+ 23, 42, 2, 61, 30, 16, 40, 32, 24, 56, 41, 19, 33, 37, 26, 47, 9, 31, 22, 2,
+ 45, 9, 54, 4, 37, 21, 52, 11, 23, 7, 57, 16, 25, 55, 18, 63, 27, 46, 39, 56,
+ 10, 50, 37, 29, 47, 19, 63, 24, 9, 46, 2, 39, 60, 9, 57, 30, 7, 49, 11, 59,
+ 3, 45, 57, 5, 60, 29, 22, 5, 60, 30, 9, 59, 18, 40, 6, 57, 36, 30, 12, 24,
+ 34, 15, 40, 52, 6, 49, 9, 58, 4, 63, 12, 26, 61, 22, 53, 38, 16, 35, 14, 28,
+ 50, 42, 17, 5, 28, 62, 20, 54, 12},
+ {26, 6, 31, 15, 49, 6, 38, 27, 22, 49, 16, 56, 2, 62, 30, 21, 0, 36, 28, 6,
+ 49, 32, 13, 52, 26, 50, 19, 46, 3, 26, 62, 0, 53, 12, 29, 3, 53, 41, 60, 24,
+ 38, 13, 58, 16, 43, 9, 59, 39, 46, 28, 44, 40, 2, 33, 13, 41, 16, 6, 47, 31,
+ 26, 17, 57, 6, 38, 0, 42, 36, 29, 52, 20, 31, 48, 0, 34, 56, 20, 36, 23, 54,
+ 14, 41, 24, 37, 10, 55, 46, 25, 16, 45, 36, 4, 55, 23, 15, 8, 50, 62, 5, 56,
+ 44, 20, 13, 28, 59, 31, 24, 47, 31, 52, 37, 17, 40, 0, 26, 49, 3, 60, 7, 33,
+ 0, 61, 53, 40, 8, 45, 2, 41},
+ {16, 63, 43, 4, 61, 24, 56, 13, 53, 8, 36, 12, 24, 41, 16, 46, 60, 26, 52,
+ 39, 14, 57, 21, 37, 0, 45, 7, 59, 38, 17, 43, 10, 45, 20, 61, 43, 19, 11,
+ 33, 17, 50, 32, 23, 61, 28, 49, 26, 0, 18, 51, 5, 60, 22, 58, 29, 0, 59, 34,
+ 19, 62, 3, 52, 7, 44, 30, 59, 13, 50, 15, 62, 7, 17, 38, 22, 44, 15, 40, 4,
+ 47, 28, 33, 17, 49, 16, 51, 40, 10, 56, 0, 53, 13, 49, 28, 38, 60, 21, 43,
+ 19, 37, 27, 3, 51, 34, 39, 0, 45, 15, 43, 10, 21, 3, 55, 8, 33, 59, 10, 41,
+ 18, 52, 24, 46, 20, 30, 13, 58, 22, 36, 57},
+ {50, 34, 11, 47, 29, 17, 44, 0, 33, 63, 28, 46, 52, 5, 57, 10, 42, 18, 4, 63,
+ 20, 8, 44, 10, 56, 34, 14, 29, 5, 54, 23, 59, 32, 49, 7, 34, 49, 27, 56, 0,
+ 42, 7, 46, 3, 40, 6, 54, 32, 62, 13, 36, 10, 47, 8, 35, 49, 24, 51, 12, 40,
+ 22, 35, 60, 12, 22, 51, 33, 4, 40, 25, 43, 55, 5, 54, 12, 61, 26, 51, 8, 62,
+ 0, 53, 7, 63, 2, 32, 19, 34, 42, 24, 31, 63, 2, 10, 45, 33, 0, 48, 9, 61,
+ 22, 47, 8, 62, 18, 56, 7, 54, 27, 57, 46, 30, 50, 19, 45, 30, 56, 36, 22,
+ 47, 11, 38, 3, 51, 32, 48, 18, 9},
+ {0, 21, 40, 19, 52, 9, 37, 48, 20, 40, 3, 18, 27, 38, 35, 22, 31, 56, 13, 35,
+ 46, 28, 60, 40, 27, 18, 61, 50, 41, 30, 7, 36, 2, 25, 16, 57, 5, 15, 47, 29,
+ 55, 19, 30, 52, 15, 34, 20, 12, 43, 30, 20, 54, 25, 44, 53, 12, 38, 5, 55,
+ 27, 48, 15, 33, 27, 45, 8, 19, 28, 56, 11, 33, 49, 18, 36, 29, 2, 45, 16,
+ 39, 19, 31, 43, 27, 35, 20, 52, 26, 6, 61, 11, 41, 17, 29, 51, 20, 56, 25,
+ 32, 41, 17, 53, 31, 25, 14, 42, 23, 35, 16, 38, 6, 34, 12, 15, 62, 6, 21,
+ 13, 1, 63, 9, 55, 27, 43, 25, 14, 4, 31, 55},
+ {44, 29, 61, 2, 35, 58, 26, 15, 60, 10, 51, 59, 14, 55, 8, 50, 2, 44, 25, 51,
+ 1, 33, 16, 4, 48, 36, 2, 21, 12, 57, 48, 13, 51, 55, 40, 28, 37, 62, 8, 39,
+ 12, 63, 36, 10, 59, 24, 56, 47, 9, 50, 41, 1, 32, 17, 6, 21, 61, 30, 9, 43,
+ 1, 54, 41, 2, 54, 37, 48, 61, 1, 46, 21, 3, 58, 24, 50, 32, 60, 10, 57, 25,
+ 46, 12, 59, 4, 45, 13, 57, 47, 27, 39, 5, 58, 47, 14, 35, 4, 52, 13, 60, 6,
+ 36, 10, 45, 55, 4, 50, 29, 2, 61, 50, 25, 58, 44, 24, 36, 42, 54, 28, 40,
+ 32, 16, 56, 6, 62, 46, 39, 60, 23},
+ {7, 48, 14, 54, 23, 40, 4, 45, 30, 22, 42, 32, 1, 44, 20, 29, 58, 8, 37, 19,
+ 41, 54, 24, 58, 9, 53, 25, 46, 34, 16, 23, 38, 27, 11, 18, 1, 52, 21, 35,
+ 22, 48, 5, 25, 45, 18, 38, 2, 27, 35, 4, 57, 15, 62, 39, 57, 28, 42, 16, 36,
+ 60, 24, 18, 10, 63, 20, 5, 16, 23, 37, 14, 59, 27, 41, 8, 13, 42, 21, 35, 6,
+ 50, 3, 38, 15, 48, 30, 39, 17, 3, 49, 14, 53, 33, 24, 7, 61, 44, 11, 39, 23,
+ 49, 19, 58, 1, 32, 36, 12, 60, 41, 20, 13, 41, 4, 39, 1, 48, 8, 18, 51, 14,
+ 44, 5, 37, 21, 34, 1, 26, 10, 37},
+ {53, 36, 27, 9, 50, 12, 32, 55, 2, 57, 7, 17, 48, 34, 63, 15, 40, 26, 62, 11,
+ 49, 6, 31, 39, 22, 42, 6, 63, 1, 39, 60, 4, 42, 61, 32, 45, 24, 44, 2, 60,
+ 16, 41, 53, 1, 33, 61, 49, 17, 63, 23, 45, 26, 33, 3, 23, 46, 2, 50, 20, 4,
+ 45, 34, 49, 30, 39, 58, 44, 31, 53, 34, 6, 52, 30, 47, 63, 1, 53, 22, 42,
+ 31, 58, 23, 54, 22, 61, 8, 36, 59, 22, 35, 21, 1, 55, 40, 27, 16, 30, 54, 2,
+ 29, 43, 16, 39, 63, 21, 46, 26, 10, 48, 32, 19, 53, 30, 56, 26, 60, 33, 4,
+ 61, 23, 49, 59, 15, 53, 19, 58, 42, 16},
+ {20, 5, 59, 46, 25, 62, 7, 19, 43, 25, 37, 61, 11, 24, 4, 54, 12, 52, 3, 32,
+ 17, 61, 12, 47, 15, 55, 18, 31, 53, 28, 9, 50, 21, 6, 55, 9, 58, 14, 54, 26,
+ 33, 7, 31, 58, 13, 21, 8, 42, 29, 6, 37, 11, 48, 52, 14, 60, 11, 39, 56, 32,
+ 14, 58, 7, 26, 17, 4, 42, 8, 11, 47, 19, 38, 10, 17, 26, 37, 9, 55, 28, 13,
+ 18, 40, 6, 33, 1, 43, 25, 11, 51, 7, 62, 43, 18, 37, 3, 57, 45, 9, 38, 58,
+ 5, 52, 27, 7, 17, 53, 5, 57, 37, 2, 63, 9, 22, 15, 11, 38, 25, 45, 35, 0,
+ 28, 10, 41, 30, 50, 8, 31, 57},
+ {49, 33, 16, 38, 1, 42, 51, 34, 53, 14, 28, 49, 30, 56, 36, 23, 43, 20, 38,
+ 56, 22, 45, 28, 0, 62, 35, 26, 44, 11, 19, 52, 35, 44, 15, 30, 38, 10, 31,
+ 40, 4, 46, 50, 20, 40, 27, 44, 51, 14, 56, 53, 19, 59, 7, 29, 41, 19, 35,
+ 25, 8, 52, 22, 44, 13, 53, 50, 32, 61, 24, 56, 25, 63, 0, 45, 57, 33, 59,
+ 16, 46, 4, 62, 50, 11, 60, 37, 52, 19, 55, 29, 37, 46, 13, 26, 48, 10, 50,
+ 34, 21, 63, 26, 13, 42, 33, 22, 55, 35, 28, 43, 15, 24, 51, 27, 34, 46, 49,
+ 58, 3, 52, 9, 57, 19, 48, 55, 3, 35, 12, 45, 24, 3},
+ {41, 11, 56, 28, 18, 31, 22, 10, 37, 6, 47, 13, 3, 41, 9, 46, 0, 48, 29, 6,
+ 34, 10, 55, 37, 20, 8, 49, 3, 41, 59, 14, 25, 0, 63, 19, 47, 27, 51, 17, 57,
+ 23, 10, 61, 6, 54, 3, 38, 31, 0, 22, 34, 43, 20, 55, 31, 0, 49, 63, 29, 38,
+ 3, 62, 28, 40, 0, 22, 14, 35, 2, 48, 15, 43, 23, 14, 3, 29, 49, 20, 39, 34,
+ 0, 44, 29, 9, 15, 47, 5, 42, 0, 31, 58, 5, 31, 61, 23, 15, 0, 47, 19, 50,
+ 24, 3, 59, 11, 44, 0, 31, 59, 6, 42, 17, 60, 0, 39, 20, 31, 43, 17, 29, 40,
+ 12, 25, 60, 22, 52, 15, 63, 29},
+ {20, 52, 8, 44, 62, 4, 59, 49, 17, 63, 21, 39, 60, 18, 52, 27, 33, 59, 14,
+ 51, 59, 43, 24, 5, 51, 30, 57, 17, 32, 5, 37, 56, 48, 34, 42, 3, 60, 5, 36,
+ 13, 43, 37, 18, 34, 25, 12, 59, 24, 47, 36, 11, 50, 3, 38, 9, 58, 16, 5, 43,
+ 18, 47, 10, 37, 18, 59, 46, 29, 52, 40, 12, 34, 28, 56, 36, 53, 7, 43, 8,
+ 24, 52, 26, 17, 56, 43, 24, 32, 63, 20, 57, 16, 22, 52, 36, 8, 41, 56, 29,
+ 32, 54, 7, 35, 57, 14, 48, 20, 62, 13, 39, 53, 29, 8, 45, 13, 29, 7, 61, 14,
+ 54, 6, 63, 38, 32, 18, 43, 2, 39, 6, 47},
+ {0, 58, 23, 35, 13, 46, 12, 39, 0, 31, 55, 24, 5, 35, 15, 61, 17, 5, 39, 25,
+ 18, 2, 50, 33, 41, 13, 39, 23, 62, 46, 29, 12, 22, 8, 56, 25, 20, 49, 32,
+ 62, 0, 56, 11, 46, 63, 42, 9, 16, 55, 5, 60, 15, 62, 26, 45, 21, 36, 51, 13,
+ 57, 31, 24, 55, 6, 35, 9, 57, 5, 20, 60, 7, 51, 5, 19, 40, 25, 61, 32, 56,
+ 12, 36, 48, 21, 2, 58, 12, 39, 28, 9, 50, 40, 12, 44, 18, 25, 49, 6, 38, 11,
+ 62, 18, 46, 30, 9, 40, 25, 49, 19, 10, 36, 55, 22, 33, 52, 41, 18, 37, 27,
+ 49, 21, 2, 46, 7, 53, 33, 61, 27, 35},
+ {41, 31, 5, 39, 51, 26, 33, 57, 27, 41, 9, 44, 54, 29, 48, 7, 44, 36, 57, 10,
+ 31, 63, 16, 45, 11, 60, 1, 47, 7, 20, 43, 3, 58, 36, 13, 52, 39, 7, 15, 28,
+ 22, 48, 30, 21, 1, 29, 49, 44, 27, 17, 40, 30, 24, 42, 12, 53, 33, 7, 47,
+ 20, 1, 42, 11, 49, 25, 43, 17, 32, 45, 27, 41, 21, 31, 62, 11, 49, 2, 15,
+ 42, 5, 63, 7, 41, 27, 49, 6, 54, 23, 46, 34, 2, 28, 54, 3, 59, 12, 46, 17,
+ 42, 28, 40, 1, 37, 51, 5, 55, 2, 34, 47, 16, 3, 62, 47, 5, 23, 56, 1, 44,
+ 12, 34, 51, 16, 57, 11, 25, 17, 54, 13},
+ {60, 26, 55, 18, 3, 60, 20, 6, 52, 15, 50, 19, 32, 11, 23, 53, 26, 21, 1, 47,
+ 42, 27, 8, 58, 21, 27, 53, 36, 26, 54, 31, 50, 17, 30, 45, 1, 29, 59, 44,
+ 53, 41, 4, 35, 58, 51, 19, 32, 4, 52, 34, 48, 8, 51, 5, 56, 2, 25, 61, 27,
+ 38, 54, 27, 62, 21, 51, 1, 39, 62, 10, 50, 1, 58, 13, 47, 38, 18, 35, 54,
+ 22, 51, 30, 19, 59, 34, 14, 32, 44, 4, 60, 15, 52, 62, 20, 43, 30, 35, 21,
+ 60, 4, 52, 12, 24, 61, 18, 30, 42, 23, 61, 25, 50, 27, 38, 11, 59, 12, 35,
+ 50, 30, 59, 24, 8, 42, 28, 37, 48, 9, 44, 21},
+ {10, 47, 15, 50, 30, 43, 8, 45, 29, 2, 36, 59, 1, 58, 41, 3, 63, 31, 54, 20,
+ 13, 55, 35, 38, 4, 44, 15, 9, 61, 2, 14, 38, 61, 10, 23, 54, 18, 12, 24, 2,
+ 14, 55, 16, 8, 38, 14, 41, 60, 10, 23, 1, 58, 32, 17, 28, 37, 41, 15, 3, 60,
+ 15, 33, 4, 36, 16, 59, 28, 14, 23, 55, 37, 18, 44, 28, 2, 57, 30, 10, 27,
+ 46, 14, 38, 3, 53, 21, 61, 17, 35, 10, 41, 26, 7, 33, 9, 57, 1, 53, 37, 26,
+ 20, 56, 48, 9, 33, 58, 16, 37, 7, 45, 1, 57, 15, 32, 26, 42, 23, 7, 20, 4,
+ 54, 31, 62, 22, 1, 59, 30, 4, 51},
+ {36, 2, 38, 11, 24, 36, 54, 22, 62, 47, 25, 8, 28, 45, 16, 38, 12, 43, 9, 37,
+ 49, 3, 23, 52, 18, 30, 50, 33, 19, 42, 49, 26, 6, 40, 47, 35, 63, 38, 50,
+ 33, 60, 26, 36, 47, 24, 57, 6, 26, 39, 63, 19, 44, 14, 46, 61, 9, 50, 30,
+ 45, 23, 10, 50, 44, 8, 31, 54, 6, 46, 36, 4, 30, 54, 8, 52, 22, 41, 4, 60,
+ 40, 0, 58, 24, 45, 10, 37, 1, 48, 30, 56, 17, 38, 48, 24, 47, 19, 39, 14, 8,
+ 45, 32, 2, 34, 27, 44, 4, 52, 11, 56, 31, 21, 40, 19, 44, 51, 2, 63, 46, 58,
+ 36, 43, 14, 5, 50, 38, 14, 56, 40, 23},
+ {61, 46, 32, 63, 54, 1, 14, 34, 12, 40, 18, 49, 37, 10, 61, 30, 51, 24, 60,
+ 7, 29, 40, 62, 11, 46, 58, 6, 56, 24, 10, 34, 52, 21, 59, 16, 3, 27, 5, 20,
+ 46, 9, 40, 7, 62, 2, 30, 53, 15, 48, 10, 28, 35, 54, 6, 21, 34, 18, 55, 7,
+ 40, 57, 19, 26, 60, 41, 13, 24, 51, 19, 61, 9, 25, 34, 15, 63, 11, 45, 17,
+ 20, 47, 33, 8, 31, 62, 43, 26, 53, 7, 24, 59, 0, 13, 55, 4, 62, 27, 51, 31,
+ 63, 15, 58, 7, 54, 14, 46, 22, 28, 43, 12, 63, 8, 54, 5, 17, 39, 33, 15, 10,
+ 27, 17, 47, 34, 19, 45, 27, 12, 33, 17},
+ {5, 28, 21, 7, 17, 48, 42, 58, 23, 4, 63, 14, 55, 21, 34, 5, 19, 0, 45, 17,
+ 52, 15, 25, 32, 0, 22, 40, 13, 45, 62, 18, 0, 43, 11, 33, 55, 30, 42, 57,
+ 19, 51, 31, 22, 43, 18, 45, 34, 0, 43, 31, 56, 3, 23, 40, 59, 0, 44, 13, 48,
+ 35, 2, 32, 46, 0, 21, 48, 35, 3, 40, 32, 43, 59, 0, 48, 33, 26, 53, 36, 55,
+ 12, 51, 16, 55, 5, 18, 29, 11, 39, 51, 19, 45, 31, 42, 21, 35, 6, 22, 47,
+ 10, 38, 23, 50, 20, 36, 0, 60, 38, 4, 50, 35, 48, 34, 24, 57, 9, 53, 28, 48,
+ 61, 0, 56, 24, 53, 3, 63, 6, 42, 57},
+ {13, 53, 45, 40, 58, 27, 6, 16, 38, 51, 33, 30, 43, 2, 47, 56, 40, 50, 33,
+ 57, 27, 5, 47, 42, 60, 36, 16, 54, 28, 4, 37, 57, 28, 51, 22, 8, 45, 14, 6,
+ 39, 0, 54, 11, 59, 28, 12, 50, 21, 61, 13, 19, 38, 49, 11, 25, 37, 58, 29,
+ 22, 63, 14, 56, 12, 53, 30, 63, 9, 57, 26, 12, 47, 16, 23, 39, 50, 6, 31, 2,
+ 25, 6, 28, 41, 36, 22, 50, 57, 42, 3, 34, 8, 28, 61, 11, 50, 16, 54, 41, 0,
+ 55, 43, 5, 29, 41, 63, 25, 16, 53, 18, 26, 10, 21, 0, 61, 30, 41, 22, 3, 38,
+ 20, 39, 29, 8, 41, 16, 36, 52, 22, 19},
+ {55, 34, 0, 25, 10, 32, 56, 44, 28, 0, 57, 7, 26, 53, 23, 8, 13, 35, 22, 12,
+ 36, 60, 20, 8, 14, 29, 48, 2, 41, 49, 23, 13, 39, 7, 48, 58, 25, 53, 34, 62,
+ 28, 16, 48, 4, 37, 56, 27, 5, 36, 52, 46, 7, 62, 33, 52, 11, 17, 53, 5, 28,
+ 41, 24, 38, 17, 5, 39, 20, 45, 15, 56, 5, 38, 60, 8, 14, 57, 21, 48, 62, 39,
+ 59, 13, 1, 60, 9, 32, 16, 63, 44, 25, 52, 15, 36, 2, 60, 29, 12, 33, 25, 17,
+ 59, 45, 13, 8, 49, 32, 6, 40, 59, 29, 45, 37, 13, 47, 6, 55, 30, 45, 9, 52,
+ 13, 59, 25, 47, 32, 1, 49, 30},
+ {9, 39, 14, 61, 49, 37, 3, 20, 50, 13, 41, 19, 46, 17, 38, 59, 28, 62, 4, 44,
+ 54, 1, 34, 51, 55, 7, 63, 32, 21, 8, 56, 31, 62, 19, 36, 1, 41, 17, 24, 12,
+ 42, 35, 25, 52, 20, 8, 44, 59, 25, 2, 22, 42, 16, 29, 4, 46, 20, 36, 43, 9,
+ 51, 8, 49, 26, 58, 33, 54, 1, 37, 29, 52, 20, 27, 45, 19, 35, 42, 16, 10,
+ 32, 20, 49, 46, 27, 40, 4, 47, 22, 13, 55, 4, 47, 26, 44, 23, 40, 58, 19,
+ 48, 13, 31, 2, 57, 34, 42, 19, 61, 32, 14, 55, 5, 51, 26, 19, 58, 16, 49,
+ 14, 62, 5, 33, 44, 21, 7, 60, 26, 11, 41},
+ {62, 24, 47, 29, 8, 19, 53, 11, 60, 24, 32, 61, 4, 55, 31, 2, 49, 16, 39, 9,
+ 31, 24, 43, 17, 26, 38, 11, 25, 58, 43, 12, 35, 3, 46, 15, 32, 63, 4, 49,
+ 56, 2, 60, 10, 32, 63, 17, 39, 12, 55, 30, 57, 9, 48, 55, 39, 24, 60, 2, 58,
+ 31, 19, 61, 34, 3, 42, 11, 22, 46, 7, 61, 10, 42, 3, 55, 32, 1, 58, 28, 44,
+ 54, 4, 34, 23, 15, 56, 20, 37, 58, 6, 30, 38, 18, 63, 9, 32, 5, 51, 3, 62,
+ 37, 52, 18, 39, 23, 3, 51, 9, 47, 1, 23, 43, 15, 60, 35, 11, 40, 1, 36, 31,
+ 26, 57, 2, 37, 54, 18, 44, 58, 16},
+ {5, 51, 3, 33, 43, 62, 21, 42, 35, 9, 48, 15, 36, 10, 22, 42, 20, 46, 26, 56,
+ 50, 12, 59, 3, 48, 19, 45, 53, 1, 27, 47, 17, 52, 24, 56, 11, 51, 21, 37,
+ 30, 20, 46, 14, 41, 1, 47, 33, 7, 41, 17, 35, 27, 20, 1, 14, 54, 26, 33, 18,
+ 47, 1, 44, 14, 59, 16, 52, 28, 18, 49, 31, 25, 34, 63, 13, 51, 24, 9, 50, 3,
+ 23, 38, 63, 7, 52, 29, 46, 11, 33, 50, 22, 57, 36, 1, 57, 49, 17, 39, 28, 9,
+ 35, 6, 27, 53, 15, 55, 30, 24, 58, 36, 41, 11, 52, 32, 3, 44, 25, 62, 23,
+ 51, 15, 42, 22, 50, 10, 39, 4, 31, 35},
+ {46, 22, 57, 17, 12, 39, 26, 5, 31, 59, 1, 45, 27, 62, 52, 7, 58, 33, 6, 18,
+ 39, 22, 33, 41, 57, 5, 35, 18, 40, 16, 60, 5, 29, 42, 7, 39, 27, 44, 9, 47,
+ 8, 26, 54, 22, 51, 29, 24, 49, 15, 61, 4, 51, 31, 63, 43, 6, 50, 8, 39, 12,
+ 53, 37, 23, 30, 40, 6, 62, 43, 14, 53, 2, 49, 7, 36, 17, 41, 61, 37, 18, 56,
+ 11, 18, 44, 35, 2, 19, 61, 0, 41, 14, 8, 30, 43, 12, 24, 46, 14, 54, 42, 21,
+ 44, 61, 10, 46, 37, 11, 44, 7, 18, 63, 20, 29, 7, 49, 28, 54, 8, 43, 4, 48,
+ 18, 63, 12, 29, 48, 24, 59, 20},
+ {13, 36, 28, 54, 35, 2, 56, 46, 16, 49, 22, 40, 11, 34, 14, 43, 29, 12, 63,
+ 48, 2, 61, 7, 15, 28, 30, 50, 9, 61, 33, 38, 23, 54, 13, 61, 33, 3, 59, 16,
+ 35, 58, 40, 5, 38, 13, 57, 3, 58, 37, 21, 45, 12, 39, 7, 35, 30, 13, 56, 22,
+ 62, 27, 6, 55, 10, 48, 21, 33, 2, 38, 23, 40, 20, 44, 29, 59, 4, 26, 12, 33,
+ 47, 28, 53, 31, 13, 59, 41, 27, 49, 26, 54, 45, 16, 53, 21, 35, 7, 59, 26,
+ 11, 56, 1, 24, 33, 4, 28, 62, 21, 49, 31, 2, 56, 39, 24, 58, 13, 17, 37, 21,
+ 56, 10, 38, 0, 34, 55, 15, 43, 1, 52},
+ {42, 9, 50, 6, 25, 60, 14, 38, 10, 29, 53, 18, 57, 3, 25, 51, 0, 53, 25, 17,
+ 29, 37, 52, 46, 0, 62, 14, 37, 4, 50, 10, 44, 0, 46, 20, 25, 50, 19, 55, 0,
+ 23, 31, 62, 34, 11, 45, 19, 32, 0, 53, 10, 59, 23, 47, 18, 60, 42, 28, 37,
+ 3, 50, 15, 35, 44, 0, 51, 27, 60, 9, 57, 16, 58, 11, 22, 46, 15, 53, 48, 7,
+ 42, 0, 60, 5, 49, 24, 54, 9, 17, 39, 5, 34, 62, 3, 40, 60, 31, 0, 47, 29,
+ 16, 49, 39, 59, 17, 50, 0, 40, 13, 53, 38, 16, 46, 0, 42, 34, 60, 2, 53, 29,
+ 31, 58, 46, 27, 6, 61, 8, 37, 28},
+ {0, 63, 21, 40, 45, 18, 51, 23, 63, 34, 6, 43, 28, 38, 55, 19, 40, 35, 8, 41,
+ 54, 10, 21, 32, 39, 23, 53, 26, 55, 28, 22, 63, 30, 34, 9, 48, 6, 38, 29,
+ 43, 49, 6, 18, 52, 27, 61, 9, 43, 28, 42, 33, 26, 56, 3, 51, 23, 0, 48, 16,
+ 45, 32, 25, 63, 20, 57, 17, 42, 12, 35, 47, 5, 31, 39, 56, 6, 30, 34, 21,
+ 61, 25, 14, 40, 22, 38, 15, 6, 36, 56, 20, 60, 25, 12, 51, 27, 10, 56, 42,
+ 20, 36, 63, 32, 6, 21, 41, 12, 34, 60, 26, 5, 48, 27, 10, 62, 19, 6, 47, 39,
+ 14, 45, 7, 24, 17, 41, 32, 23, 51, 19, 56},
+ {45, 31, 15, 59, 4, 33, 7, 47, 0, 41, 13, 61, 4, 47, 9, 23, 60, 14, 57, 31,
+ 4, 45, 59, 6, 58, 10, 44, 20, 8, 42, 15, 6, 55, 17, 58, 31, 53, 12, 61, 10,
+ 15, 57, 43, 2, 23, 35, 48, 14, 54, 6, 18, 49, 15, 38, 11, 34, 62, 9, 21, 58,
+ 11, 41, 4, 31, 38, 8, 29, 55, 19, 36, 27, 52, 0, 25, 50, 43, 1, 39, 8, 55,
+ 35, 51, 10, 30, 45, 62, 29, 2, 46, 10, 32, 48, 18, 38, 5, 22, 33, 8, 51, 3,
+ 14, 44, 54, 25, 57, 30, 18, 52, 33, 22, 59, 28, 36, 52, 32, 21, 26, 50, 5,
+ 55, 35, 60, 14, 54, 4, 40, 16, 33},
+ {27, 3, 49, 10, 30, 40, 55, 27, 57, 24, 52, 21, 32, 17, 60, 30, 5, 44, 27,
+ 49, 19, 34, 13, 24, 43, 36, 3, 49, 31, 59, 37, 48, 26, 41, 2, 41, 14, 36,
+ 21, 32, 40, 26, 13, 49, 55, 5, 16, 40, 25, 60, 36, 1, 63, 29, 17, 44, 25,
+ 40, 52, 5, 29, 47, 54, 13, 46, 24, 60, 4, 51, 22, 63, 14, 45, 18, 12, 62,
+ 17, 57, 19, 42, 3, 26, 58, 48, 1, 21, 40, 52, 23, 37, 44, 1, 29, 58, 43, 50,
+ 15, 61, 19, 45, 58, 28, 7, 48, 2, 46, 8, 42, 3, 55, 8, 50, 12, 4, 55, 10,
+ 63, 33, 20, 40, 11, 3, 46, 20, 48, 26, 61, 11},
+ {44, 56, 24, 36, 53, 19, 12, 37, 16, 44, 7, 36, 49, 54, 11, 37, 48, 21, 15,
+ 1, 62, 25, 47, 56, 16, 18, 51, 12, 40, 1, 24, 11, 52, 16, 23, 59, 28, 1, 45,
+ 53, 4, 60, 37, 21, 39, 30, 63, 20, 52, 10, 30, 45, 8, 41, 54, 4, 57, 7, 34,
+ 55, 36, 18, 23, 59, 2, 48, 11, 32, 44, 1, 41, 8, 33, 54, 38, 23, 30, 46, 6,
+ 29, 62, 18, 32, 16, 55, 34, 14, 11, 61, 7, 55, 16, 53, 13, 23, 2, 55, 37,
+ 26, 10, 33, 23, 36, 16, 38, 22, 56, 15, 24, 43, 35, 17, 44, 40, 25, 46, 16,
+ 1, 57, 25, 49, 36, 28, 62, 9, 35, 7, 53},
+ {17, 38, 8, 61, 1, 50, 26, 62, 3, 31, 56, 15, 1, 26, 40, 2, 34, 51, 56, 36,
+ 42, 9, 38, 2, 29, 60, 32, 57, 19, 62, 34, 47, 4, 57, 39, 7, 44, 63, 24, 18,
+ 46, 28, 8, 54, 1, 34, 7, 46, 3, 37, 50, 23, 57, 21, 13, 46, 31, 20, 43, 15,
+ 1, 61, 8, 33, 37, 17, 56, 26, 15, 49, 24, 59, 28, 3, 56, 9, 52, 32, 13, 49,
+ 10, 43, 5, 45, 8, 25, 59, 42, 28, 33, 19, 40, 8, 63, 35, 47, 25, 4, 40, 52,
+ 1, 60, 12, 53, 63, 9, 29, 60, 37, 19, 1, 62, 31, 20, 58, 12, 41, 30, 43, 9,
+ 18, 52, 22, 1, 39, 30, 58, 21},
+ {13, 47, 29, 18, 43, 34, 5, 48, 20, 42, 10, 45, 30, 58, 20, 63, 24, 11, 6,
+ 28, 54, 14, 22, 52, 41, 7, 26, 5, 45, 15, 53, 13, 35, 27, 18, 50, 12, 33, 5,
+ 56, 10, 17, 45, 24, 59, 15, 50, 26, 56, 13, 19, 5, 32, 52, 27, 36, 2, 61,
+ 12, 26, 49, 40, 27, 52, 13, 50, 6, 39, 61, 34, 10, 37, 48, 20, 41, 27, 2,
+ 36, 59, 24, 54, 33, 63, 20, 38, 50, 3, 17, 52, 4, 58, 27, 45, 21, 32, 11,
+ 48, 17, 57, 20, 46, 38, 25, 43, 4, 34, 51, 6, 13, 45, 57, 26, 6, 48, 2, 35,
+ 53, 23, 61, 34, 59, 6, 42, 56, 13, 51, 2, 41},
+ {32, 5, 55, 23, 58, 14, 22, 52, 29, 15, 61, 25, 51, 8, 43, 13, 53, 41, 46,
+ 20, 3, 33, 63, 11, 48, 21, 54, 38, 28, 3, 30, 43, 21, 62, 9, 31, 55, 22, 51,
+ 29, 37, 62, 32, 12, 42, 29, 41, 9, 33, 44, 62, 28, 43, 1, 59, 19, 48, 30,
+ 51, 39, 24, 4, 58, 19, 42, 29, 22, 43, 3, 18, 53, 5, 13, 50, 16, 60, 45, 21,
+ 7, 40, 15, 0, 26, 53, 13, 31, 43, 24, 47, 31, 15, 49, 2, 41, 6, 59, 29, 42,
+ 9, 30, 14, 7, 49, 18, 31, 47, 20, 39, 49, 32, 11, 41, 54, 15, 61, 18, 7, 38,
+ 4, 13, 44, 28, 15, 32, 45, 19, 27, 49},
+ {63, 34, 11, 39, 2, 45, 37, 8, 59, 39, 33, 4, 36, 17, 48, 5, 29, 18, 32, 61,
+ 39, 50, 5, 27, 35, 0, 46, 12, 22, 49, 60, 6, 54, 0, 38, 49, 2, 42, 15, 40,
+ 0, 47, 20, 51, 3, 57, 18, 61, 22, 0, 39, 16, 55, 12, 35, 8, 41, 22, 6, 59,
+ 16, 45, 10, 36, 0, 62, 9, 54, 30, 58, 21, 43, 63, 31, 7, 35, 12, 48, 58, 28,
+ 47, 37, 41, 9, 57, 20, 61, 0, 36, 11, 57, 35, 23, 52, 37, 18, 0, 62, 22, 55,
+ 35, 62, 27, 54, 0, 15, 61, 28, 2, 59, 22, 9, 37, 27, 33, 51, 29, 48, 19, 50,
+ 25, 37, 10, 57, 5, 37, 60, 8},
+ {20, 25, 46, 52, 31, 60, 12, 55, 0, 19, 11, 46, 62, 35, 23, 38, 57, 0, 55,
+ 10, 16, 30, 58, 44, 17, 59, 29, 63, 42, 8, 36, 20, 33, 46, 16, 61, 25, 35,
+ 8, 54, 26, 7, 58, 22, 34, 6, 47, 14, 53, 31, 48, 9, 37, 25, 49, 63, 16, 55,
+ 45, 14, 34, 63, 21, 53, 25, 33, 46, 16, 35, 7, 46, 29, 0, 39, 25, 55, 22,
+ 34, 18, 4, 56, 11, 23, 51, 28, 6, 39, 14, 62, 44, 19, 8, 60, 12, 56, 28, 50,
+ 34, 39, 5, 51, 3, 41, 12, 57, 35, 10, 53, 25, 17, 52, 30, 47, 0, 43, 14, 5,
+ 57, 31, 55, 0, 63, 47, 23, 54, 24, 14, 43},
+ {0, 57, 16, 6, 26, 19, 35, 28, 49, 42, 54, 26, 21, 1, 59, 27, 9, 47, 26, 44,
+ 50, 22, 13, 40, 8, 37, 10, 34, 17, 56, 25, 58, 13, 27, 44, 9, 20, 58, 31,
+ 17, 60, 36, 10, 41, 53, 25, 36, 39, 4, 24, 58, 17, 60, 4, 22, 38, 10, 32, 0,
+ 50, 31, 7, 28, 47, 12, 57, 5, 26, 52, 23, 14, 40, 57, 17, 47, 5, 53, 1, 44,
+ 31, 19, 60, 46, 2, 35, 48, 30, 54, 22, 5, 51, 39, 25, 31, 4, 43, 14, 9, 45,
+ 16, 24, 44, 19, 29, 40, 23, 44, 7, 38, 42, 4, 63, 12, 54, 23, 59, 22, 42, 8,
+ 15, 40, 21, 8, 34, 3, 41, 30, 50},
+ {39, 10, 48, 33, 41, 54, 5, 47, 23, 13, 32, 7, 52, 44, 14, 39, 58, 18, 35, 6,
+ 37, 2, 60, 24, 55, 19, 53, 2, 51, 32, 1, 41, 51, 4, 40, 29, 47, 3, 52, 44,
+ 13, 49, 28, 16, 1, 62, 11, 27, 52, 35, 5, 42, 29, 47, 14, 56, 28, 53, 26,
+ 38, 9, 56, 40, 3, 38, 15, 41, 60, 1, 37, 50, 25, 11, 28, 61, 19, 42, 62, 10,
+ 52, 39, 6, 32, 14, 58, 17, 7, 26, 42, 34, 27, 10, 54, 40, 20, 63, 26, 53,
+ 21, 61, 32, 7, 59, 48, 3, 56, 18, 31, 58, 14, 49, 21, 36, 16, 45, 9, 36, 24,
+ 62, 45, 27, 31, 53, 17, 49, 12, 62, 18},
+ {28, 59, 21, 58, 2, 16, 38, 9, 62, 3, 56, 41, 10, 31, 50, 4, 32, 52, 12, 63,
+ 23, 46, 33, 31, 4, 48, 25, 43, 14, 23, 47, 11, 22, 55, 14, 60, 23, 37, 11,
+ 39, 23, 2, 45, 56, 31, 43, 19, 55, 16, 46, 21, 51, 11, 33, 44, 2, 41, 18, 5,
+ 52, 23, 44, 17, 60, 27, 49, 11, 32, 44, 10, 54, 2, 56, 33, 8, 38, 13, 29,
+ 36, 16, 24, 63, 27, 51, 21, 43, 56, 12, 49, 3, 59, 48, 1, 15, 46, 7, 36, 2,
+ 47, 11, 50, 27, 37, 13, 33, 8, 51, 46, 1, 34, 28, 40, 3, 33, 60, 29, 47, 1,
+ 35, 11, 59, 42, 2, 60, 26, 46, 6, 35},
+ {4, 43, 9, 29, 36, 63, 24, 44, 20, 50, 30, 17, 60, 22, 16, 43, 25, 3, 42, 19,
+ 51, 15, 8, 54, 42, 15, 61, 5, 39, 57, 18, 61, 31, 48, 34, 2, 50, 19, 57, 5,
+ 63, 33, 19, 38, 13, 27, 48, 7, 32, 61, 2, 26, 58, 6, 24, 50, 13, 61, 42, 20,
+ 62, 2, 35, 20, 51, 4, 62, 18, 23, 58, 20, 31, 43, 15, 51, 45, 26, 50, 4, 55,
+ 45, 3, 35, 9, 38, 1, 32, 61, 20, 45, 17, 33, 24, 57, 29, 51, 22, 58, 38, 30,
+ 15, 1, 54, 21, 63, 43, 26, 12, 24, 56, 8, 60, 50, 19, 5, 52, 13, 54, 17, 50,
+ 4, 16, 36, 12, 32, 56, 22, 54},
+ {51, 25, 40, 53, 12, 49, 15, 57, 34, 7, 38, 47, 2, 36, 55, 8, 61, 30, 56, 7,
+ 28, 59, 48, 11, 27, 35, 21, 45, 28, 36, 9, 38, 6, 16, 24, 63, 10, 32, 28,
+ 43, 21, 53, 5, 60, 8, 57, 3, 45, 11, 37, 15, 54, 40, 20, 62, 36, 27, 34, 11,
+ 48, 30, 15, 54, 8, 30, 42, 22, 34, 48, 13, 35, 63, 4, 37, 22, 2, 59, 9, 41,
+ 23, 13, 41, 49, 18, 59, 24, 40, 5, 37, 30, 9, 61, 44, 6, 37, 11, 33, 17, 5,
+ 55, 41, 60, 23, 39, 17, 5, 30, 62, 41, 16, 46, 25, 11, 56, 39, 26, 20, 38,
+ 29, 39, 22, 52, 44, 20, 48, 1, 38, 14},
+ {15, 33, 2, 18, 44, 6, 27, 0, 32, 61, 25, 12, 58, 28, 40, 20, 47, 13, 34, 43,
+ 38, 1, 23, 62, 40, 0, 51, 10, 63, 3, 52, 26, 44, 30, 45, 6, 41, 54, 0, 51,
+ 12, 30, 46, 24, 49, 22, 40, 33, 63, 23, 43, 30, 9, 47, 0, 17, 54, 7, 57, 3,
+ 37, 47, 24, 46, 13, 55, 7, 52, 2, 42, 6, 26, 49, 18, 60, 34, 16, 57, 33, 20,
+ 61, 30, 8, 54, 14, 46, 12, 53, 16, 55, 38, 13, 22, 53, 18, 59, 46, 27, 43,
+ 19, 32, 10, 45, 6, 49, 36, 52, 2, 20, 55, 6, 39, 32, 15, 44, 3, 58, 10, 63,
+ 6, 56, 30, 7, 58, 9, 40, 19, 63},
+ {10, 47, 61, 23, 55, 31, 52, 42, 17, 45, 4, 51, 27, 6, 15, 53, 0, 49, 26, 10,
+ 56, 18, 36, 6, 20, 58, 32, 30, 13, 49, 19, 56, 0, 59, 12, 53, 27, 17, 38,
+ 25, 48, 9, 15, 36, 14, 30, 59, 17, 0, 50, 8, 58, 18, 56, 31, 45, 21, 41, 29,
+ 19, 60, 6, 32, 59, 0, 36, 29, 39, 19, 59, 46, 12, 55, 30, 10, 47, 24, 3, 28,
+ 48, 0, 55, 44, 27, 33, 4, 63, 29, 49, 0, 26, 50, 34, 2, 42, 14, 0, 62, 9,
+ 56, 3, 52, 28, 34, 58, 9, 20, 48, 37, 32, 22, 53, 0, 62, 27, 49, 34, 46, 21,
+ 33, 41, 14, 25, 37, 53, 29, 31, 45},
+ {56, 28, 7, 37, 11, 36, 20, 9, 54, 14, 39, 19, 34, 63, 45, 37, 24, 17, 60,
+ 31, 21, 45, 53, 29, 47, 15, 7, 55, 40, 23, 34, 14, 42, 20, 37, 35, 15, 59,
+ 7, 62, 34, 40, 59, 1, 51, 42, 10, 28, 54, 21, 35, 5, 38, 13, 36, 4, 59, 12,
+ 39, 53, 15, 43, 9, 21, 39, 62, 16, 56, 25, 9, 32, 38, 0, 41, 14, 51, 40, 53,
+ 43, 11, 37, 17, 5, 22, 57, 39, 19, 7, 42, 21, 60, 10, 31, 63, 25, 52, 30,
+ 49, 36, 25, 48, 17, 61, 14, 22, 42, 29, 13, 60, 11, 47, 18, 35, 41, 7, 23,
+ 4, 16, 51, 11, 0, 48, 61, 3, 17, 50, 5, 24},
+ {0, 42, 21, 49, 60, 3, 57, 40, 29, 48, 23, 56, 42, 11, 22, 5, 59, 39, 4, 50,
+ 3, 41, 12, 57, 25, 50, 44, 18, 4, 46, 7, 62, 33, 50, 4, 56, 21, 32, 43, 18,
+ 3, 23, 55, 34, 20, 4, 53, 38, 12, 46, 29, 52, 25, 61, 23, 51, 26, 46, 1, 34,
+ 25, 57, 28, 51, 26, 11, 50, 3, 44, 28, 53, 21, 57, 27, 62, 6, 31, 19, 8, 63,
+ 26, 59, 36, 47, 15, 29, 50, 25, 35, 47, 18, 41, 4, 48, 8, 40, 12, 23, 6, 44,
+ 13, 40, 1, 31, 55, 0, 61, 43, 4, 50, 26, 58, 9, 53, 24, 61, 42, 55, 31, 43,
+ 57, 20, 34, 27, 43, 8, 59, 39},
+ {18, 51, 30, 13, 26, 16, 46, 22, 2, 59, 8, 30, 1, 48, 33, 51, 29, 9, 46, 16,
+ 62, 14, 33, 2, 38, 9, 27, 60, 37, 26, 53, 17, 28, 10, 24, 46, 2, 49, 8, 57,
+ 29, 45, 6, 26, 62, 44, 18, 25, 61, 3, 42, 14, 49, 10, 43, 6, 17, 32, 63, 10,
+ 49, 4, 40, 14, 45, 33, 22, 37, 12, 61, 5, 17, 43, 7, 23, 37, 15, 58, 49, 13,
+ 39, 21, 10, 52, 1, 62, 9, 56, 12, 2, 58, 28, 36, 16, 56, 28, 56, 35, 20, 63,
+ 24, 37, 51, 8, 45, 25, 16, 33, 27, 38, 2, 44, 13, 30, 17, 36, 12, 26, 5, 18,
+ 28, 47, 13, 60, 23, 45, 13, 33},
+ {55, 4, 62, 34, 52, 38, 7, 63, 32, 37, 13, 53, 25, 62, 18, 12, 55, 41, 27,
+ 35, 24, 49, 31, 52, 17, 63, 34, 1, 56, 12, 41, 2, 48, 58, 39, 16, 61, 27,
+ 41, 52, 13, 19, 50, 39, 11, 31, 57, 6, 32, 40, 20, 55, 1, 28, 33, 57, 48, 8,
+ 37, 22, 44, 18, 53, 1, 61, 5, 54, 16, 47, 36, 50, 24, 55, 34, 48, 45, 1, 30,
+ 33, 46, 2, 50, 32, 42, 25, 34, 43, 21, 38, 52, 23, 45, 14, 54, 21, 4, 44,
+ 16, 53, 29, 10, 47, 19, 57, 12, 54, 39, 10, 51, 15, 63, 21, 57, 40, 51, 1,
+ 48, 57, 37, 62, 2, 38, 9, 52, 1, 35, 58, 22},
+ {36, 46, 10, 42, 1, 27, 43, 15, 50, 21, 45, 16, 41, 3, 35, 44, 20, 1, 57, 11,
+ 55, 7, 43, 8, 22, 42, 13, 46, 21, 39, 31, 60, 22, 5, 29, 44, 11, 35, 20, 4,
+ 36, 58, 32, 15, 47, 2, 36, 48, 16, 60, 8, 35, 44, 63, 16, 2, 40, 26, 55, 14,
+ 58, 35, 24, 31, 19, 42, 31, 58, 1, 29, 10, 40, 2, 19, 12, 54, 22, 61, 7, 24,
+ 56, 5, 28, 16, 54, 3, 15, 58, 6, 30, 8, 62, 1, 43, 31, 47, 7, 59, 1, 38, 58,
+ 4, 34, 27, 38, 5, 31, 59, 7, 46, 30, 3, 34, 6, 28, 59, 20, 8, 32, 15, 53,
+ 24, 55, 31, 19, 49, 11, 26},
+ {2, 24, 16, 58, 19, 55, 5, 35, 10, 61, 4, 28, 57, 24, 58, 7, 31, 47, 22, 38,
+ 19, 28, 61, 36, 54, 5, 59, 29, 6, 52, 15, 11, 43, 36, 8, 54, 52, 1, 62, 25,
+ 47, 9, 1, 60, 28, 53, 24, 14, 46, 27, 51, 22, 12, 24, 38, 53, 20, 11, 51, 3,
+ 29, 7, 48, 63, 8, 49, 9, 21, 52, 14, 63, 32, 46, 60, 35, 4, 41, 16, 52, 35,
+ 18, 42, 59, 7, 36, 61, 45, 27, 33, 51, 19, 39, 34, 11, 61, 18, 33, 41, 28,
+ 15, 54, 22, 42, 3, 49, 21, 47, 18, 36, 23, 55, 19, 48, 24, 45, 10, 33, 44,
+ 50, 40, 7, 35, 15, 41, 63, 6, 40, 54},
+ {62, 41, 32, 8, 47, 28, 60, 24, 44, 30, 38, 49, 9, 33, 14, 40, 50, 14, 60, 2,
+ 54, 40, 0, 20, 25, 39, 16, 49, 24, 35, 57, 47, 19, 61, 33, 18, 23, 37, 13,
+ 55, 31, 43, 22, 41, 17, 8, 42, 58, 0, 37, 5, 56, 31, 54, 7, 30, 60, 33, 42,
+ 17, 59, 39, 12, 27, 38, 17, 35, 41, 27, 45, 20, 7, 25, 15, 29, 58, 27, 47,
+ 11, 40, 14, 54, 23, 46, 19, 31, 11, 40, 13, 49, 5, 58, 24, 51, 26, 6, 50,
+ 20, 49, 9, 32, 46, 17, 60, 14, 63, 24, 1, 57, 41, 9, 43, 14, 62, 16, 52, 3,
+ 27, 14, 22, 61, 45, 4, 28, 9, 47, 29, 17},
+ {5, 50, 12, 53, 38, 18, 11, 51, 0, 55, 17, 6, 47, 54, 19, 63, 5, 26, 34, 45,
+ 13, 30, 47, 58, 10, 48, 32, 3, 62, 9, 26, 0, 25, 14, 50, 3, 47, 30, 42, 16,
+ 6, 63, 12, 49, 33, 55, 21, 10, 34, 63, 18, 41, 3, 47, 19, 43, 0, 49, 8, 28,
+ 46, 20, 52, 0, 56, 24, 60, 3, 59, 5, 39, 57, 48, 52, 9, 38, 3, 21, 26, 60,
+ 0, 32, 12, 38, 4, 48, 53, 0, 60, 15, 29, 44, 18, 10, 38, 57, 13, 60, 2, 26,
+ 62, 7, 50, 29, 35, 8, 40, 53, 28, 12, 60, 33, 38, 5, 37, 29, 60, 39, 56, 0,
+ 30, 18, 50, 34, 59, 25, 14, 44},
+ {20, 31, 60, 22, 3, 49, 33, 25, 40, 13, 34, 59, 22, 36, 0, 28, 37, 56, 8, 18,
+ 51, 16, 4, 45, 27, 12, 53, 42, 18, 44, 51, 31, 55, 40, 28, 58, 7, 60, 10,
+ 51, 27, 37, 24, 56, 5, 26, 44, 29, 50, 23, 45, 11, 34, 15, 59, 27, 13, 23,
+ 62, 37, 4, 57, 15, 32, 42, 6, 47, 11, 30, 43, 23, 13, 0, 36, 18, 44, 63, 51,
+ 37, 29, 49, 20, 57, 27, 62, 9, 24, 35, 23, 53, 37, 3, 42, 55, 0, 36, 23, 39,
+ 31, 43, 17, 37, 24, 11, 52, 43, 19, 32, 5, 50, 26, 0, 56, 21, 54, 11, 19, 6,
+ 47, 25, 59, 42, 12, 54, 21, 3, 38, 57},
+ {48, 0, 35, 27, 44, 14, 59, 7, 57, 46, 26, 2, 42, 12, 52, 43, 10, 27, 53, 42,
+ 32, 62, 37, 21, 34, 61, 7, 23, 36, 4, 38, 12, 41, 5, 17, 45, 22, 27, 39, 21,
+ 59, 0, 45, 18, 39, 62, 3, 38, 14, 7, 54, 26, 61, 39, 9, 52, 45, 36, 18, 50,
+ 10, 34, 44, 22, 50, 14, 36, 55, 17, 34, 53, 62, 33, 26, 56, 6, 31, 12, 6,
+ 53, 9, 44, 2, 50, 20, 40, 55, 17, 47, 7, 26, 63, 22, 32, 48, 16, 46, 8, 52,
+ 12, 57, 41, 0, 56, 25, 3, 61, 14, 45, 35, 18, 44, 12, 46, 23, 42, 32, 51,
+ 35, 10, 17, 36, 23, 1, 45, 52, 32, 10},
+ {37, 15, 43, 8, 63, 39, 21, 31, 16, 37, 19, 62, 30, 46, 17, 60, 21, 48, 1,
+ 23, 6, 25, 11, 56, 1, 40, 30, 58, 15, 54, 21, 59, 9, 63, 35, 56, 11, 51, 2,
+ 46, 34, 14, 53, 7, 30, 11, 51, 19, 60, 40, 30, 1, 24, 50, 20, 32, 3, 56, 5,
+ 25, 31, 13, 61, 2, 29, 60, 25, 20, 51, 2, 27, 8, 18, 42, 10, 45, 21, 34, 43,
+ 17, 62, 29, 41, 14, 34, 6, 30, 43, 2, 57, 33, 13, 45, 12, 27, 62, 4, 55, 21,
+ 35, 5, 27, 45, 33, 16, 47, 30, 54, 22, 10, 51, 27, 63, 7, 49, 1, 58, 22, 15,
+ 43, 53, 7, 57, 39, 27, 12, 61, 24},
+ {56, 51, 26, 56, 19, 2, 41, 54, 5, 52, 9, 48, 6, 23, 39, 4, 32, 15, 63, 35,
+ 59, 49, 43, 15, 52, 19, 50, 9, 46, 33, 1, 29, 48, 20, 32, 1, 38, 33, 19, 54,
+ 9, 32, 24, 48, 58, 35, 16, 48, 4, 52, 13, 57, 33, 5, 45, 59, 15, 29, 41, 55,
+ 47, 39, 23, 53, 9, 40, 4, 57, 10, 44, 48, 40, 50, 14, 61, 24, 55, 1, 59, 22,
+ 33, 8, 51, 25, 58, 46, 11, 59, 20, 41, 17, 51, 6, 56, 35, 25, 42, 30, 15,
+ 58, 48, 18, 61, 9, 58, 39, 13, 2, 37, 59, 40, 2, 31, 16, 34, 41, 8, 30, 62,
+ 3, 29, 48, 33, 5, 63, 16, 41, 7},
+ {22, 4, 46, 11, 33, 51, 29, 10, 62, 24, 43, 27, 15, 58, 50, 25, 54, 44, 9,
+ 38, 18, 3, 29, 57, 32, 5, 26, 43, 17, 61, 24, 52, 8, 42, 23, 53, 15, 61, 7,
+ 28, 57, 43, 4, 40, 20, 2, 43, 25, 32, 35, 21, 43, 17, 48, 10, 22, 38, 54,
+ 11, 21, 1, 58, 16, 30, 48, 18, 46, 32, 38, 13, 22, 4, 59, 35, 2, 51, 30, 39,
+ 15, 47, 4, 56, 13, 37, 1, 28, 16, 52, 32, 9, 61, 29, 38, 19, 3, 52, 10, 48,
+ 1, 32, 11, 40, 20, 36, 6, 22, 49, 29, 55, 6, 20, 56, 36, 52, 19, 60, 26, 46,
+ 18, 54, 40, 13, 20, 46, 35, 19, 49, 29},
+ {61, 17, 34, 53, 23, 6, 48, 35, 20, 40, 1, 56, 36, 29, 11, 34, 7, 41, 14, 30,
+ 55, 20, 46, 8, 24, 38, 63, 2, 37, 10, 45, 14, 34, 49, 6, 13, 44, 25, 49, 41,
+ 21, 12, 61, 15, 54, 29, 63, 12, 56, 8, 49, 2, 62, 36, 28, 61, 0, 25, 41, 63,
+ 35, 8, 44, 6, 37, 62, 7, 21, 63, 28, 55, 31, 16, 24, 41, 19, 9, 57, 27, 36,
+ 18, 42, 31, 62, 22, 55, 38, 4, 27, 47, 1, 40, 14, 54, 43, 20, 60, 23, 38,
+ 63, 25, 51, 2, 53, 26, 63, 10, 42, 17, 34, 47, 25, 13, 5, 44, 11, 55, 2, 38,
+ 27, 6, 60, 52, 25, 9, 55, 1, 40},
+ {8, 30, 58, 3, 42, 61, 17, 38, 13, 59, 32, 10, 54, 3, 51, 20, 61, 26, 57, 2,
+ 46, 33, 12, 60, 41, 13, 48, 29, 55, 20, 39, 27, 57, 18, 62, 29, 55, 2, 31,
+ 16, 37, 50, 26, 36, 6, 46, 9, 41, 27, 57, 23, 39, 26, 6, 51, 12, 31, 46, 7,
+ 16, 27, 52, 19, 56, 26, 12, 33, 53, 1, 41, 8, 57, 46, 7, 54, 32, 47, 5, 49,
+ 11, 60, 23, 5, 48, 10, 43, 19, 63, 35, 24, 49, 21, 59, 5, 31, 37, 14, 44, 7,
+ 42, 6, 30, 46, 13, 44, 32, 19, 50, 4, 58, 8, 30, 62, 38, 28, 53, 21, 36, 13,
+ 50, 21, 33, 15, 2, 44, 31, 14, 47},
+ {37, 13, 39, 16, 28, 9, 57, 0, 25, 49, 21, 45, 18, 47, 12, 42, 0, 49, 22, 39,
+ 16, 53, 25, 36, 0, 52, 22, 16, 6, 60, 4, 51, 0, 26, 37, 47, 10, 36, 63, 5,
+ 57, 0, 18, 59, 23, 33, 51, 19, 0, 44, 15, 11, 54, 17, 42, 35, 53, 18, 58,
+ 33, 49, 4, 34, 42, 0, 50, 43, 25, 16, 49, 34, 20, 37, 28, 12, 63, 16, 38,
+ 25, 44, 0, 40, 52, 17, 35, 3, 50, 14, 8, 53, 11, 36, 25, 45, 9, 62, 0, 54,
+ 28, 17, 50, 55, 15, 24, 57, 0, 53, 34, 23, 41, 15, 45, 0, 49, 16, 4, 48, 9,
+ 63, 45, 0, 42, 58, 37, 61, 22, 54, 26},
+ {0, 50, 21, 47, 54, 36, 27, 45, 52, 4, 34, 15, 63, 29, 37, 59, 17, 31, 6, 61,
+ 28, 5, 48, 18, 59, 27, 34, 56, 44, 31, 35, 12, 41, 59, 16, 3, 40, 20, 50,
+ 22, 30, 40, 52, 10, 45, 3, 59, 22, 37, 61, 29, 46, 31, 58, 2, 22, 9, 43, 3,
+ 39, 14, 61, 24, 54, 15, 29, 11, 60, 39, 17, 5, 61, 0, 44, 50, 3, 31, 14, 58,
+ 21, 54, 28, 15, 45, 60, 26, 33, 58, 44, 22, 60, 2, 57, 34, 49, 27, 18, 34,
+ 21, 59, 29, 4, 36, 41, 8, 39, 28, 11, 62, 26, 53, 20, 35, 24, 59, 32, 29,
+ 39, 24, 31, 57, 23, 11, 28, 5, 36, 11, 59},
+ {44, 32, 63, 5, 20, 12, 41, 7, 30, 61, 42, 8, 39, 5, 33, 8, 24, 53, 45, 11,
+ 37, 58, 7, 44, 10, 50, 3, 40, 8, 22, 53, 19, 46, 9, 33, 52, 24, 58, 8, 44,
+ 13, 47, 8, 34, 38, 30, 14, 47, 7, 34, 4, 55, 9, 19, 40, 49, 56, 26, 60, 21,
+ 30, 45, 10, 19, 40, 58, 23, 36, 3, 52, 45, 23, 54, 13, 22, 42, 53, 45, 7,
+ 33, 10, 36, 57, 6, 29, 12, 41, 0, 30, 15, 41, 30, 17, 7, 16, 53, 40, 56, 2,
+ 39, 12, 61, 10, 52, 31, 60, 16, 45, 1, 37, 7, 61, 40, 10, 43, 17, 58, 7, 54,
+ 14, 4, 51, 39, 49, 18, 56, 42, 20},
+ {14, 6, 24, 36, 56, 49, 22, 60, 18, 14, 23, 51, 26, 57, 21, 52, 41, 14, 35,
+ 50, 19, 31, 40, 23, 33, 14, 63, 17, 32, 47, 7, 62, 23, 30, 56, 11, 42, 27,
+ 14, 60, 35, 19, 28, 61, 17, 55, 25, 39, 53, 17, 42, 21, 38, 63, 25, 5, 14,
+ 36, 12, 50, 1, 37, 59, 32, 2, 51, 6, 56, 27, 32, 11, 30, 38, 26, 60, 8, 26,
+ 19, 62, 39, 50, 2, 21, 39, 53, 23, 56, 19, 49, 39, 5, 46, 55, 23, 42, 4, 31,
+ 11, 47, 26, 45, 22, 48, 18, 21, 5, 48, 25, 57, 14, 47, 30, 3, 56, 12, 50, 1,
+ 42, 19, 47, 35, 17, 8, 30, 45, 25, 4, 51},
+ {28, 58, 43, 1, 31, 8, 33, 2, 44, 55, 32, 1, 60, 12, 46, 27, 4, 62, 23, 1,
+ 56, 13, 62, 2, 54, 36, 25, 51, 1, 57, 26, 42, 3, 49, 17, 38, 1, 48, 31, 4,
+ 54, 3, 50, 24, 1, 49, 5, 63, 13, 27, 52, 1, 48, 13, 45, 33, 52, 30, 46, 20,
+ 55, 28, 6, 48, 24, 38, 20, 47, 14, 62, 48, 9, 58, 4, 36, 30, 56, 1, 34, 12,
+ 18, 63, 25, 48, 4, 16, 37, 7, 62, 10, 52, 28, 13, 50, 36, 63, 24, 51, 15,
+ 58, 8, 33, 1, 38, 56, 35, 42, 9, 33, 51, 22, 18, 48, 32, 27, 37, 23, 61, 33,
+ 11, 59, 29, 62, 1, 53, 10, 60, 33},
+ {12, 39, 17, 52, 26, 46, 53, 38, 25, 11, 48, 36, 16, 43, 2, 35, 55, 17, 39,
+ 29, 43, 9, 28, 45, 20, 5, 46, 12, 42, 28, 13, 52, 36, 6, 60, 22, 54, 17, 62,
+ 39, 25, 42, 15, 55, 44, 20, 31, 10, 35, 57, 24, 32, 29, 6, 59, 18, 7, 62, 3,
+ 41, 10, 44, 16, 54, 13, 62, 31, 9, 41, 1, 21, 43, 18, 47, 15, 40, 11, 49,
+ 28, 55, 46, 30, 8, 43, 32, 61, 28, 47, 25, 34, 21, 61, 32, 1, 20, 9, 46, 6,
+ 35, 19, 41, 54, 27, 63, 14, 3, 51, 20, 62, 2, 38, 55, 8, 21, 63, 6, 46, 9,
+ 26, 51, 3, 24, 43, 34, 16, 41, 18, 48},
+ {62, 23, 55, 9, 15, 62, 19, 13, 58, 40, 6, 30, 54, 19, 50, 31, 10, 44, 6, 59,
+ 21, 47, 51, 15, 60, 39, 30, 54, 21, 61, 19, 33, 14, 29, 43, 11, 34, 45, 7,
+ 21, 10, 56, 36, 6, 38, 11, 58, 42, 2, 47, 11, 60, 50, 16, 41, 28, 38, 23,
+ 47, 17, 35, 63, 22, 33, 42, 5, 45, 17, 53, 35, 25, 56, 33, 6, 51, 19, 60,
+ 23, 43, 15, 5, 40, 58, 13, 51, 1, 45, 11, 54, 3, 43, 8, 37, 48, 59, 29, 39,
+ 21, 61, 43, 3, 31, 10, 44, 24, 29, 60, 12, 28, 40, 11, 25, 43, 52, 14, 41,
+ 16, 57, 44, 20, 40, 55, 12, 21, 57, 27, 35, 2},
+ {37, 6, 31, 42, 40, 4, 29, 50, 0, 20, 63, 28, 9, 58, 14, 24, 63, 26, 48, 16,
+ 34, 4, 32, 38, 23, 11, 58, 4, 37, 9, 45, 5, 63, 48, 26, 57, 2, 28, 32, 51,
+ 46, 29, 13, 62, 27, 46, 28, 18, 50, 15, 40, 4, 19, 34, 54, 0, 53, 9, 26, 58,
+ 28, 5, 49, 0, 57, 27, 19, 60, 29, 8, 59, 12, 37, 63, 24, 46, 3, 37, 6, 52,
+ 26, 32, 20, 36, 9, 22, 59, 18, 35, 51, 14, 57, 17, 24, 12, 44, 56, 0, 30,
+ 13, 59, 20, 49, 17, 54, 43, 6, 34, 46, 17, 58, 36, 0, 34, 29, 54, 25, 2, 36,
+ 15, 60, 6, 37, 46, 4, 50, 9, 45},
+ {19, 59, 48, 3, 24, 60, 44, 22, 34, 51, 15, 45, 41, 5, 33, 47, 0, 37, 12, 55,
+ 25, 54, 8, 57, 0, 47, 18, 34, 49, 15, 55, 24, 40, 20, 8, 35, 53, 13, 41, 18,
+ 0, 59, 22, 33, 4, 52, 8, 60, 24, 36, 31, 56, 45, 26, 10, 43, 15, 56, 36, 4,
+ 51, 14, 39, 30, 12, 55, 36, 2, 39, 49, 4, 44, 17, 0, 32, 13, 53, 35, 59, 17,
+ 62, 0, 55, 24, 52, 38, 31, 6, 42, 19, 29, 40, 4, 54, 33, 5, 16, 27, 52, 37,
+ 23, 55, 7, 37, 0, 39, 23, 49, 4, 53, 31, 15, 59, 10, 50, 4, 60, 34, 48, 7,
+ 31, 49, 27, 14, 62, 22, 53, 29},
+ {46, 21, 14, 51, 36, 17, 7, 57, 10, 32, 3, 37, 22, 60, 39, 18, 56, 20, 42, 3,
+ 36, 10, 44, 26, 41, 29, 53, 27, 2, 39, 30, 52, 0, 59, 15, 48, 23, 61, 6, 58,
+ 37, 12, 40, 49, 16, 39, 20, 44, 0, 62, 8, 21, 3, 59, 23, 32, 49, 31, 12, 44,
+ 22, 59, 18, 50, 24, 7, 43, 52, 15, 23, 41, 26, 51, 28, 55, 39, 21, 27, 10,
+ 42, 12, 45, 27, 47, 3, 15, 63, 26, 55, 0, 60, 26, 45, 18, 62, 38, 58, 49, 8,
+ 47, 4, 33, 46, 29, 57, 13, 56, 16, 59, 21, 5, 47, 23, 39, 18, 44, 13, 22,
+ 28, 53, 19, 0, 58, 32, 41, 7, 26, 13},
+ {0, 56, 34, 28, 11, 55, 31, 47, 26, 41, 56, 13, 53, 28, 11, 49, 7, 52, 32,
+ 61, 50, 22, 63, 17, 13, 56, 7, 19, 43, 62, 10, 21, 37, 32, 43, 4, 38, 19,
+ 44, 25, 31, 54, 5, 23, 61, 30, 53, 12, 35, 22, 43, 53, 37, 48, 7, 62, 20, 2,
+ 61, 41, 8, 34, 47, 9, 63, 34, 28, 10, 55, 33, 14, 57, 7, 47, 9, 61, 4, 49,
+ 31, 50, 21, 38, 8, 16, 57, 44, 33, 5, 49, 36, 12, 50, 7, 34, 10, 25, 2, 22,
+ 36, 15, 26, 61, 18, 9, 22, 46, 32, 8, 27, 37, 44, 30, 55, 3, 62, 24, 38, 56,
+ 5, 45, 38, 24, 43, 10, 19, 54, 39, 61},
+ {41, 30, 8, 63, 43, 23, 38, 3, 62, 19, 8, 49, 25, 1, 58, 30, 23, 40, 9, 28,
+ 18, 40, 6, 38, 49, 22, 35, 59, 8, 27, 50, 5, 56, 17, 11, 50, 30, 9, 55, 2,
+ 51, 19, 34, 47, 9, 41, 6, 26, 48, 57, 14, 28, 17, 12, 39, 13, 37, 46, 25,
+ 19, 54, 27, 1, 37, 16, 45, 20, 60, 1, 48, 20, 38, 31, 22, 42, 15, 19, 44, 1,
+ 61, 6, 34, 56, 40, 29, 10, 20, 46, 13, 22, 41, 23, 59, 42, 30, 51, 45, 13,
+ 63, 53, 42, 12, 51, 38, 62, 2, 26, 41, 50, 1, 61, 10, 19, 42, 31, 8, 49, 32,
+ 12, 63, 9, 52, 16, 56, 36, 2, 31, 16},
+ {52, 5, 47, 20, 1, 53, 12, 50, 16, 35, 43, 21, 33, 43, 16, 44, 3, 59, 14, 46,
+ 1, 30, 60, 33, 2, 45, 12, 42, 31, 47, 14, 33, 46, 25, 55, 27, 60, 36, 16,
+ 42, 14, 46, 26, 1, 55, 15, 63, 32, 2, 38, 5, 47, 33, 61, 30, 52, 4, 57, 6,
+ 38, 11, 43, 61, 24, 52, 3, 31, 22, 42, 10, 62, 3, 59, 11, 35, 57, 33, 54,
+ 24, 14, 29, 48, 18, 2, 60, 41, 53, 24, 32, 62, 3, 53, 15, 1, 55, 17, 32, 40,
+ 6, 31, 1, 40, 28, 5, 35, 52, 19, 63, 13, 33, 17, 41, 52, 26, 15, 57, 1, 20,
+ 42, 17, 35, 27, 48, 5, 25, 50, 44, 11},
+ {35, 25, 38, 57, 33, 17, 40, 6, 59, 27, 54, 5, 61, 10, 52, 26, 36, 19, 51,
+ 35, 57, 48, 11, 20, 54, 25, 61, 16, 1, 58, 24, 61, 3, 39, 7, 47, 1, 22, 49,
+ 28, 63, 10, 58, 32, 17, 36, 45, 19, 51, 29, 59, 10, 50, 1, 23, 42, 18, 29,
+ 51, 21, 56, 32, 14, 5, 40, 58, 47, 13, 54, 35, 29, 45, 18, 52, 26, 2, 38, 8,
+ 46, 36, 58, 11, 52, 35, 17, 28, 1, 58, 9, 39, 17, 28, 37, 48, 20, 9, 57, 24,
+ 50, 19, 58, 16, 48, 25, 43, 11, 35, 6, 45, 24, 56, 4, 36, 7, 47, 35, 52, 28,
+ 59, 30, 2, 61, 21, 33, 63, 12, 18, 59},
+ {3, 49, 15, 10, 27, 61, 25, 45, 30, 0, 14, 47, 31, 38, 17, 62, 7, 55, 27, 4,
+ 15, 24, 42, 52, 10, 34, 5, 51, 36, 18, 41, 11, 35, 21, 62, 13, 33, 57, 8,
+ 35, 5, 40, 21, 43, 52, 3, 24, 56, 11, 16, 33, 25, 41, 20, 55, 8, 60, 35, 15,
+ 48, 2, 57, 30, 49, 18, 25, 6, 39, 17, 57, 7, 25, 43, 5, 49, 16, 62, 22, 55,
+ 4, 25, 43, 23, 7, 50, 11, 37, 48, 14, 51, 33, 57, 7, 27, 39, 46, 4, 29, 11,
+ 43, 34, 56, 7, 60, 20, 54, 30, 57, 22, 49, 9, 33, 54, 14, 63, 23, 6, 43, 10,
+ 40, 50, 13, 44, 8, 38, 33, 46, 23},
+ {55, 39, 22, 50, 44, 4, 36, 9, 52, 23, 37, 59, 21, 2, 46, 13, 31, 41, 11, 45,
+ 62, 29, 6, 37, 19, 48, 30, 23, 44, 7, 53, 28, 54, 16, 41, 29, 44, 18, 52,
+ 24, 60, 15, 48, 7, 27, 59, 9, 34, 42, 54, 7, 63, 4, 46, 31, 27, 45, 0, 40,
+ 26, 34, 17, 37, 10, 53, 29, 36, 50, 2, 27, 51, 11, 61, 37, 23, 41, 30, 7,
+ 18, 50, 39, 14, 63, 32, 45, 61, 19, 30, 25, 44, 2, 47, 23, 63, 11, 34, 59,
+ 37, 60, 3, 22, 14, 44, 30, 15, 0, 47, 15, 3, 38, 61, 20, 27, 45, 11, 39, 51,
+ 16, 55, 3, 22, 54, 29, 58, 1, 57, 6, 29},
+ {9, 17, 60, 2, 34, 56, 20, 62, 39, 12, 49, 6, 29, 56, 34, 48, 0, 58, 22, 38,
+ 18, 43, 56, 0, 63, 14, 55, 3, 59, 31, 15, 45, 0, 49, 6, 58, 3, 38, 12, 45,
+ 0, 37, 29, 57, 13, 39, 30, 49, 0, 23, 44, 36, 16, 57, 13, 54, 11, 24, 63, 9,
+ 53, 7, 62, 42, 0, 59, 15, 23, 63, 34, 40, 16, 32, 0, 53, 12, 48, 28, 59, 33,
+ 0, 53, 9, 27, 3, 22, 54, 5, 56, 9, 61, 13, 42, 14, 52, 19, 0, 21, 47, 27,
+ 53, 36, 3, 50, 39, 58, 25, 40, 53, 28, 12, 50, 0, 59, 32, 2, 21, 34, 26, 46,
+ 37, 7, 18, 47, 24, 14, 53, 42},
+ {61, 32, 13, 54, 29, 7, 46, 13, 28, 57, 18, 41, 53, 15, 9, 39, 24, 49, 33, 3,
+ 53, 9, 26, 32, 40, 28, 46, 39, 25, 9, 56, 21, 63, 37, 26, 22, 51, 27, 17,
+ 56, 31, 53, 4, 43, 22, 46, 12, 18, 60, 40, 20, 26, 50, 21, 39, 5, 49, 33,
+ 16, 44, 22, 46, 20, 32, 24, 45, 8, 43, 12, 46, 4, 48, 56, 20, 29, 58, 3, 40,
+ 10, 42, 31, 21, 47, 41, 56, 38, 15, 42, 36, 27, 20, 33, 55, 3, 26, 44, 31,
+ 54, 12, 35, 9, 63, 28, 10, 21, 32, 9, 60, 17, 8, 43, 29, 40, 16, 36, 48, 60,
+ 7, 57, 14, 62, 31, 42, 15, 36, 40, 20, 26},
+ {0, 37, 47, 23, 41, 18, 32, 48, 1, 35, 8, 25, 4, 26, 63, 20, 54, 8, 16, 61,
+ 35, 23, 51, 15, 58, 7, 12, 20, 50, 34, 42, 4, 38, 10, 32, 47, 8, 60, 41, 20,
+ 9, 25, 50, 19, 62, 1, 37, 56, 28, 8, 53, 11, 3, 58, 34, 43, 19, 60, 38, 4,
+ 58, 31, 3, 51, 11, 55, 38, 30, 21, 58, 19, 26, 9, 44, 36, 13, 46, 20, 62,
+ 24, 13, 60, 5, 28, 12, 34, 7, 59, 0, 53, 45, 6, 38, 30, 50, 7, 62, 16, 41,
+ 5, 46, 18, 55, 42, 51, 5, 45, 23, 34, 48, 19, 58, 5, 25, 54, 19, 13, 41, 28,
+ 21, 0, 49, 10, 60, 4, 51, 9, 45},
+ {19, 28, 6, 58, 10, 51, 4, 22, 55, 42, 60, 45, 34, 51, 42, 5, 30, 45, 27, 40,
+ 13, 47, 4, 49, 21, 38, 60, 29, 2, 57, 17, 27, 52, 19, 61, 14, 30, 34, 2, 44,
+ 63, 33, 11, 35, 16, 51, 25, 6, 14, 47, 31, 61, 37, 29, 18, 8, 52, 2, 28, 54,
+ 13, 41, 15, 62, 35, 18, 2, 60, 6, 33, 41, 61, 31, 6, 56, 17, 34, 50, 6, 52,
+ 44, 35, 16, 51, 59, 24, 48, 18, 31, 40, 16, 49, 21, 60, 17, 39, 10, 49, 32,
+ 57, 24, 39, 1, 25, 18, 62, 37, 12, 56, 1, 37, 11, 52, 44, 9, 30, 47, 4, 51,
+ 40, 55, 25, 34, 27, 56, 30, 32, 54},
+ {63, 40, 49, 15, 43, 26, 63, 38, 16, 20, 30, 12, 57, 14, 19, 60, 36, 12, 59,
+ 2, 57, 17, 42, 31, 1, 44, 16, 35, 47, 11, 32, 48, 13, 43, 1, 39, 51, 12, 57,
+ 23, 6, 40, 53, 3, 55, 31, 39, 60, 35, 44, 5, 15, 45, 1, 62, 41, 26, 14, 47,
+ 22, 36, 27, 50, 9, 26, 47, 52, 28, 54, 16, 1, 13, 51, 39, 23, 63, 1, 30, 15,
+ 26, 2, 57, 19, 37, 1, 44, 21, 50, 13, 63, 8, 24, 56, 1, 35, 25, 58, 20, 2,
+ 28, 14, 51, 33, 59, 13, 30, 4, 49, 31, 24, 63, 26, 33, 3, 58, 38, 62, 24,
+ 32, 8, 17, 45, 5, 48, 18, 3, 43, 11},
+ {21, 4, 24, 34, 59, 1, 37, 11, 53, 5, 47, 2, 22, 40, 32, 1, 24, 50, 21, 29,
+ 38, 25, 63, 8, 55, 24, 53, 6, 62, 23, 59, 3, 54, 20, 58, 24, 5, 46, 15, 38,
+ 48, 14, 27, 42, 23, 7, 46, 10, 17, 58, 25, 52, 23, 32, 49, 12, 55, 30, 40,
+ 7, 59, 1, 56, 21, 39, 4, 23, 15, 37, 46, 55, 42, 21, 4, 48, 8, 45, 54, 37,
+ 55, 32, 8, 46, 10, 30, 54, 4, 41, 25, 29, 36, 48, 11, 43, 14, 47, 5, 43, 53,
+ 36, 61, 10, 45, 6, 41, 54, 27, 43, 16, 55, 6, 46, 18, 42, 23, 15, 1, 45, 12,
+ 60, 37, 22, 62, 12, 39, 59, 16, 52},
+ {47, 35, 56, 7, 19, 46, 31, 50, 33, 24, 61, 35, 50, 7, 53, 44, 55, 6, 46, 10,
+ 52, 5, 21, 43, 36, 10, 18, 41, 26, 37, 8, 29, 40, 36, 9, 49, 34, 26, 61, 21,
+ 7, 59, 18, 62, 29, 54, 20, 32, 51, 0, 40, 10, 55, 6, 20, 36, 9, 61, 5, 51,
+ 44, 19, 33, 43, 13, 57, 40, 63, 8, 24, 29, 10, 60, 34, 27, 40, 25, 18, 10,
+ 42, 21, 49, 26, 62, 38, 12, 33, 61, 5, 57, 2, 19, 54, 28, 62, 22, 38, 31,
+ 16, 7, 22, 47, 29, 17, 35, 8, 20, 51, 2, 40, 22, 50, 13, 61, 28, 53, 35, 20,
+ 56, 30, 2, 53, 14, 41, 23, 34, 8, 31},
+ {12, 2, 42, 29, 52, 13, 21, 8, 55, 14, 41, 17, 28, 58, 23, 11, 17, 36, 31,
+ 62, 17, 34, 50, 14, 28, 61, 33, 52, 2, 51, 17, 45, 7, 25, 62, 30, 18, 55, 0,
+ 42, 30, 35, 45, 1, 12, 48, 3, 63, 21, 36, 30, 48, 19, 59, 43, 27, 46, 17,
+ 34, 25, 12, 29, 53, 6, 48, 31, 11, 34, 49, 3, 36, 50, 19, 47, 14, 61, 11,
+ 36, 58, 4, 60, 14, 39, 22, 6, 52, 15, 35, 17, 46, 31, 42, 9, 34, 3, 52, 12,
+ 60, 26, 56, 40, 2, 53, 23, 57, 38, 62, 14, 36, 59, 10, 31, 39, 6, 49, 9, 41,
+ 26, 5, 48, 43, 27, 33, 58, 1, 50, 25, 57},
+ {61, 37, 15, 61, 3, 39, 58, 43, 26, 0, 44, 10, 47, 3, 37, 63, 28, 43, 13, 39,
+ 3, 57, 30, 59, 0, 48, 5, 43, 13, 22, 60, 33, 55, 15, 42, 4, 52, 10, 45, 13,
+ 54, 4, 24, 49, 37, 26, 41, 14, 42, 9, 61, 13, 38, 23, 3, 53, 0, 58, 21, 42,
+ 63, 10, 17, 61, 25, 0, 58, 28, 17, 44, 57, 12, 27, 0, 55, 5, 52, 28, 23, 47,
+ 29, 0, 43, 17, 58, 28, 47, 23, 55, 10, 58, 23, 51, 40, 18, 33, 45, 0, 49, 8,
+ 32, 61, 19, 48, 0, 26, 7, 47, 29, 18, 44, 0, 56, 34, 20, 59, 15, 51, 37, 18,
+ 10, 52, 7, 20, 46, 9, 38, 17},
+ {6, 27, 48, 23, 45, 29, 5, 18, 38, 62, 27, 56, 20, 32, 15, 9, 48, 0, 54, 22,
+ 45, 20, 7, 41, 23, 39, 19, 27, 58, 31, 44, 0, 12, 50, 23, 56, 20, 39, 32,
+ 59, 16, 52, 33, 9, 57, 22, 6, 58, 28, 50, 24, 2, 56, 35, 16, 45, 32, 38, 15,
+ 54, 2, 38, 46, 22, 35, 45, 20, 5, 52, 25, 7, 35, 59, 32, 22, 43, 38, 3, 51,
+ 16, 34, 53, 32, 50, 3, 40, 8, 43, 0, 39, 27, 4, 14, 61, 8, 55, 15, 41, 20,
+ 44, 27, 13, 39, 11, 46, 42, 54, 33, 4, 52, 23, 61, 14, 25, 43, 2, 33, 11,
+ 63, 29, 61, 17, 40, 55, 22, 62, 28, 44},
+ {20, 54, 8, 56, 35, 10, 63, 31, 52, 12, 48, 6, 59, 41, 52, 33, 19, 58, 25,
+ 49, 11, 37, 47, 12, 54, 15, 56, 35, 7, 47, 16, 53, 28, 34, 5, 37, 28, 8, 48,
+ 3, 28, 38, 18, 61, 16, 43, 53, 32, 4, 17, 47, 27, 44, 8, 63, 10, 25, 49, 6,
+ 37, 24, 52, 32, 3, 50, 12, 41, 56, 38, 14, 62, 20, 40, 16, 53, 31, 18, 63,
+ 41, 9, 59, 7, 13, 25, 57, 20, 63, 26, 53, 18, 48, 62, 30, 46, 21, 25, 58,
+ 29, 36, 4, 55, 34, 6, 60, 31, 16, 21, 12, 58, 38, 9, 29, 47, 7, 52, 30, 57,
+ 44, 22, 0, 35, 45, 3, 31, 14, 36, 0, 51},
+ {42, 14, 33, 24, 16, 49, 40, 2, 22, 33, 16, 36, 25, 1, 21, 61, 38, 8, 33, 4,
+ 62, 26, 29, 60, 6, 46, 30, 11, 63, 4, 36, 40, 19, 57, 46, 11, 41, 63, 22,
+ 25, 58, 10, 46, 2, 34, 27, 11, 38, 56, 34, 12, 53, 18, 33, 41, 51, 13, 28,
+ 60, 20, 47, 14, 29, 59, 16, 62, 8, 22, 32, 47, 9, 49, 2, 44, 7, 12, 45, 6,
+ 20, 27, 45, 24, 62, 42, 36, 11, 33, 15, 37, 7, 32, 10, 37, 1, 35, 50, 6, 11,
+ 63, 24, 52, 15, 50, 24, 3, 37, 56, 27, 34, 22, 49, 16, 36, 62, 17, 39, 4,
+ 15, 54, 24, 50, 8, 58, 26, 49, 54, 11, 30},
+ {4, 59, 41, 1, 53, 12, 25, 45, 59, 7, 51, 39, 54, 14, 46, 4, 27, 53, 16, 44,
+ 18, 51, 1, 32, 25, 2, 50, 40, 20, 54, 24, 9, 62, 2, 27, 60, 1, 17, 36, 50,
+ 6, 40, 30, 55, 41, 19, 49, 1, 21, 60, 40, 5, 62, 1, 22, 30, 57, 4, 43, 31,
+ 1, 55, 40, 7, 27, 37, 30, 54, 1, 19, 42, 30, 56, 26, 62, 49, 24, 57, 37, 56,
+ 2, 39, 16, 5, 30, 55, 3, 49, 60, 23, 56, 44, 17, 52, 13, 42, 28, 48, 18, 45,
+ 9, 37, 21, 41, 58, 10, 48, 1, 63, 5, 41, 57, 2, 24, 12, 48, 27, 42, 32, 46,
+ 13, 38, 19, 34, 5, 41, 25, 60},
+ {39, 28, 21, 46, 32, 57, 36, 9, 19, 42, 4, 29, 11, 43, 30, 49, 13, 42, 35,
+ 56, 9, 39, 15, 52, 36, 61, 18, 26, 45, 14, 31, 48, 21, 43, 14, 33, 49, 54,
+ 14, 44, 21, 62, 13, 23, 8, 62, 15, 51, 44, 7, 30, 37, 20, 42, 56, 7, 39, 18,
+ 50, 11, 61, 9, 19, 43, 57, 2, 48, 11, 39, 60, 28, 4, 37, 17, 35, 1, 33, 11,
+ 31, 14, 48, 19, 35, 51, 46, 21, 44, 29, 12, 41, 2, 22, 58, 26, 54, 4, 59,
+ 38, 2, 33, 57, 1, 63, 13, 28, 51, 15, 40, 18, 45, 8, 30, 43, 37, 54, 19, 8,
+ 59, 21, 6, 60, 29, 55, 10, 63, 15, 47, 17},
+ {3, 50, 10, 62, 18, 5, 27, 49, 60, 23, 55, 18, 62, 24, 56, 10, 59, 28, 2, 23,
+ 34, 59, 43, 20, 10, 42, 8, 49, 1, 37, 57, 6, 51, 29, 53, 7, 23, 31, 5, 32,
+ 51, 0, 35, 54, 45, 31, 5, 26, 36, 24, 55, 15, 48, 29, 14, 48, 26, 60, 21,
+ 41, 36, 26, 50, 33, 14, 44, 17, 24, 52, 15, 46, 23, 54, 6, 47, 21, 60, 50,
+ 4, 53, 29, 61, 8, 23, 1, 60, 19, 6, 53, 16, 47, 34, 6, 39, 16, 31, 12, 20,
+ 53, 22, 30, 43, 25, 46, 35, 6, 44, 32, 53, 26, 55, 19, 11, 59, 5, 33, 51, 1,
+ 35, 53, 25, 3, 42, 23, 44, 32, 7, 53},
+ {22, 44, 37, 6, 26, 51, 38, 0, 34, 13, 31, 46, 3, 37, 6, 19, 40, 21, 47, 63,
+ 12, 5, 29, 55, 22, 58, 34, 28, 60, 22, 11, 41, 17, 38, 9, 44, 59, 39, 56,
+ 19, 11, 47, 25, 15, 3, 39, 57, 17, 61, 11, 46, 3, 58, 9, 54, 35, 2, 34, 8,
+ 45, 15, 56, 5, 23, 53, 33, 63, 35, 4, 59, 10, 51, 13, 61, 29, 41, 15, 25,
+ 43, 19, 40, 10, 54, 33, 41, 12, 38, 51, 31, 26, 61, 9, 30, 45, 24, 62, 49,
+ 40, 10, 61, 14, 49, 5, 17, 54, 20, 60, 23, 3, 13, 35, 50, 32, 23, 46, 27,
+ 38, 63, 16, 12, 39, 48, 18, 51, 1, 27, 56, 35},
+ {63, 15, 30, 55, 43, 14, 57, 17, 53, 44, 7, 48, 26, 50, 32, 60, 0, 53, 14,
+ 31, 50, 24, 46, 0, 38, 13, 4, 52, 16, 45, 30, 59, 0, 25, 55, 35, 16, 10, 26,
+ 42, 58, 29, 60, 38, 50, 22, 28, 47, 0, 50, 28, 19, 33, 39, 11, 44, 16, 52,
+ 24, 59, 3, 38, 27, 51, 0, 21, 7, 42, 26, 34, 21, 40, 33, 18, 39, 3, 54, 38,
+ 8, 59, 0, 44, 27, 15, 58, 28, 57, 9, 43, 0, 36, 50, 20, 59, 8, 34, 0, 27,
+ 47, 7, 36, 19, 56, 32, 0, 38, 11, 29, 62, 47, 6, 61, 0, 41, 14, 56, 10, 23,
+ 45, 31, 57, 8, 36, 13, 58, 38, 11, 19},
+ {0, 34, 12, 47, 21, 2, 40, 30, 11, 25, 61, 20, 40, 15, 35, 22, 45, 36, 7, 41,
+ 17, 57, 9, 48, 32, 62, 44, 24, 35, 3, 54, 13, 33, 63, 19, 4, 48, 22, 62, 2,
+ 37, 8, 33, 6, 20, 52, 9, 32, 43, 13, 39, 63, 25, 4, 49, 23, 62, 32, 9, 30,
+ 48, 18, 63, 12, 46, 29, 58, 13, 48, 8, 57, 31, 0, 51, 9, 58, 12, 22, 47, 29,
+ 35, 22, 49, 5, 46, 4, 34, 20, 63, 24, 56, 11, 41, 3, 51, 19, 56, 35, 17, 58,
+ 28, 42, 9, 45, 59, 26, 51, 42, 17, 36, 25, 15, 53, 21, 44, 3, 30, 55, 5, 50,
+ 21, 28, 61, 32, 6, 49, 28, 46},
+ {58, 42, 60, 4, 31, 59, 22, 63, 35, 38, 9, 54, 1, 57, 8, 51, 16, 58, 27, 53,
+ 3, 38, 30, 15, 27, 6, 19, 56, 10, 50, 21, 36, 47, 5, 43, 28, 51, 32, 13, 46,
+ 18, 54, 16, 43, 63, 12, 36, 59, 22, 34, 5, 52, 17, 59, 27, 41, 0, 19, 55,
+ 37, 13, 43, 6, 34, 41, 10, 36, 55, 19, 44, 3, 16, 58, 27, 49, 25, 32, 62,
+ 17, 55, 13, 63, 18, 52, 25, 37, 17, 48, 13, 32, 5, 46, 28, 37, 14, 43, 25,
+ 5, 51, 39, 3, 52, 33, 22, 8, 40, 12, 4, 57, 9, 46, 39, 28, 58, 13, 62, 17,
+ 42, 19, 36, 0, 47, 16, 43, 24, 21, 54, 13},
+ {25, 9, 23, 50, 36, 8, 45, 14, 3, 51, 16, 28, 44, 12, 42, 29, 4, 26, 10, 47,
+ 22, 61, 18, 54, 51, 39, 46, 13, 41, 26, 58, 7, 18, 39, 12, 57, 15, 1, 52,
+ 27, 41, 23, 48, 1, 27, 45, 18, 2, 57, 26, 55, 8, 43, 31, 6, 58, 14, 51, 40,
+ 5, 61, 31, 24, 54, 17, 60, 22, 1, 39, 30, 53, 45, 36, 13, 43, 5, 45, 2, 37,
+ 6, 34, 42, 2, 39, 10, 62, 7, 54, 40, 18, 60, 15, 52, 21, 63, 8, 55, 46, 15,
+ 30, 23, 13, 62, 16, 50, 24, 58, 31, 48, 21, 34, 2, 49, 7, 31, 37, 26, 48, 9,
+ 61, 40, 11, 52, 2, 60, 40, 4, 37},
+ {52, 28, 39, 16, 54, 19, 29, 55, 42, 20, 58, 33, 24, 63, 18, 55, 39, 62, 43,
+ 34, 12, 40, 6, 35, 2, 25, 8, 62, 34, 1, 31, 42, 61, 27, 53, 24, 40, 61, 34,
+ 8, 59, 4, 30, 56, 40, 6, 53, 42, 10, 48, 16, 37, 12, 46, 21, 36, 47, 11, 28,
+ 45, 22, 10, 57, 2, 49, 31, 14, 44, 61, 11, 25, 6, 23, 63, 18, 36, 28, 56,
+ 20, 51, 11, 48, 27, 56, 32, 22, 45, 30, 2, 42, 27, 39, 1, 44, 23, 31, 38,
+ 22, 11, 61, 43, 54, 4, 47, 35, 2, 44, 16, 28, 54, 12, 62, 18, 43, 10, 52, 1,
+ 58, 33, 15, 29, 56, 20, 34, 9, 30, 48, 17},
+ {46, 2, 56, 11, 41, 1, 49, 6, 27, 47, 2, 48, 5, 32, 37, 3, 13, 19, 32, 1, 55,
+ 28, 60, 17, 43, 59, 32, 20, 49, 16, 55, 23, 14, 46, 2, 36, 6, 30, 20, 49,
+ 12, 47, 35, 14, 21, 60, 29, 14, 35, 24, 46, 1, 56, 29, 53, 8, 33, 23, 56, 1,
+ 35, 46, 20, 39, 26, 4, 53, 28, 17, 38, 60, 34, 48, 9, 55, 15, 46, 7, 41, 31,
+ 60, 24, 16, 36, 1, 59, 19, 52, 35, 6, 55, 11, 59, 33, 7, 57, 4, 29, 48, 1,
+ 19, 26, 37, 30, 18, 63, 37, 6, 59, 1, 40, 24, 56, 33, 46, 22, 35, 7, 24, 53,
+ 39, 5, 26, 45, 55, 18, 62, 7},
+ {20, 60, 29, 34, 20, 62, 33, 52, 10, 36, 13, 60, 41, 21, 50, 27, 56, 49, 8,
+ 51, 21, 45, 11, 48, 8, 23, 53, 3, 29, 44, 5, 52, 9, 32, 50, 17, 43, 56, 3,
+ 38, 24, 10, 62, 25, 51, 9, 33, 49, 61, 7, 30, 62, 22, 19, 2, 42, 63, 5, 49,
+ 18, 60, 15, 52, 7, 43, 56, 23, 50, 5, 50, 2, 20, 41, 30, 1, 52, 22, 61, 14,
+ 26, 3, 43, 53, 7, 47, 28, 11, 14, 23, 58, 33, 25, 47, 13, 50, 17, 40, 54,
+ 34, 60, 41, 6, 59, 14, 50, 7, 25, 55, 20, 42, 51, 8, 27, 4, 16, 60, 28, 50,
+ 44, 3, 22, 49, 63, 12, 33, 1, 43, 31},
+ {36, 5, 46, 8, 44, 24, 13, 39, 25, 57, 31, 18, 8, 52, 10, 45, 6, 30, 36, 24,
+ 63, 4, 33, 26, 57, 40, 15, 56, 37, 12, 40, 25, 37, 58, 11, 63, 21, 45, 16,
+ 60, 31, 53, 18, 33, 3, 45, 23, 0, 20, 54, 40, 15, 50, 38, 60, 16, 25, 42,
+ 29, 38, 7, 41, 25, 62, 18, 33, 8, 35, 42, 16, 32, 56, 12, 39, 59, 19, 34, 9,
+ 49, 38, 57, 12, 21, 50, 14, 40, 61, 44, 50, 9, 49, 19, 3, 29, 35, 62, 12,
+ 24, 7, 18, 52, 32, 10, 46, 21, 41, 32, 11, 36, 29, 14, 34, 60, 38, 54, 11,
+ 41, 14, 19, 57, 32, 16, 7, 41, 51, 25, 14, 57},
+ {53, 18, 26, 50, 15, 58, 4, 63, 17, 43, 7, 40, 61, 35, 15, 41, 23, 60, 16,
+ 38, 14, 42, 19, 50, 0, 31, 10, 46, 27, 63, 18, 60, 0, 20, 29, 39, 8, 26, 37,
+ 5, 42, 0, 44, 39, 57, 17, 58, 41, 28, 37, 4, 32, 9, 44, 12, 31, 54, 10, 59,
+ 14, 27, 53, 12, 36, 0, 47, 13, 63, 21, 58, 10, 24, 50, 27, 4, 26, 44, 53,
+ 31, 0, 18, 42, 29, 33, 57, 4, 32, 26, 0, 38, 16, 61, 41, 53, 20, 0, 42, 44,
+ 49, 27, 10, 56, 39, 0, 57, 15, 53, 49, 3, 61, 22, 47, 17, 5, 49, 26, 2, 63,
+ 39, 10, 47, 27, 37, 23, 4, 59, 38, 10},
+ {23, 39, 61, 3, 37, 28, 48, 31, 0, 34, 51, 23, 2, 26, 58, 0, 53, 11, 46, 1,
+ 57, 29, 52, 14, 37, 61, 21, 35, 2, 49, 7, 34, 47, 55, 4, 33, 54, 13, 58, 52,
+ 19, 50, 22, 7, 13, 29, 36, 11, 51, 17, 60, 25, 55, 4, 34, 51, 0, 35, 20, 48,
+ 32, 3, 51, 30, 59, 28, 40, 3, 46, 29, 54, 43, 7, 62, 47, 11, 39, 4, 23, 46,
+ 55, 8, 63, 5, 25, 37, 18, 46, 21, 56, 31, 5, 36, 8, 45, 58, 26, 15, 2, 36,
+ 47, 21, 29, 44, 25, 34, 3, 27, 43, 10, 52, 0, 45, 30, 24, 36, 43, 18, 34,
+ 59, 0, 52, 61, 15, 44, 19, 30, 49},
+ {0, 27, 12, 43, 54, 9, 22, 53, 21, 46, 15, 55, 29, 47, 20, 33, 39, 28, 59,
+ 35, 9, 44, 5, 24, 47, 7, 52, 17, 56, 22, 30, 42, 14, 26, 45, 18, 49, 1, 24,
+ 34, 11, 27, 55, 32, 61, 47, 2, 56, 6, 44, 13, 47, 36, 27, 58, 22, 16, 47,
+ 40, 4, 57, 38, 21, 45, 16, 9, 56, 26, 11, 38, 0, 22, 36, 17, 33, 57, 16, 30,
+ 62, 15, 35, 40, 20, 45, 59, 10, 54, 8, 63, 13, 52, 27, 22, 57, 28, 12, 32,
+ 51, 55, 22, 63, 4, 16, 54, 12, 62, 45, 19, 58, 13, 32, 40, 20, 56, 7, 57, 9,
+ 54, 6, 29, 42, 21, 8, 55, 35, 47, 6, 41},
+ {56, 33, 58, 32, 19, 35, 42, 6, 59, 11, 38, 5, 49, 12, 62, 7, 52, 17, 5, 25,
+ 54, 20, 61, 31, 54, 27, 41, 11, 44, 5, 59, 12, 36, 51, 10, 61, 28, 41, 48,
+ 9, 43, 63, 5, 40, 20, 8, 49, 26, 34, 21, 58, 1, 18, 45, 7, 39, 61, 26, 8,
+ 50, 23, 10, 63, 5, 55, 37, 19, 49, 52, 15, 59, 47, 13, 54, 1, 25, 42, 58,
+ 10, 48, 3, 27, 50, 1, 17, 48, 34, 41, 16, 40, 2, 45, 10, 39, 17, 61, 5, 38,
+ 19, 9, 41, 31, 60, 38, 5, 23, 36, 8, 30, 55, 24, 63, 12, 48, 14, 51, 31, 20,
+ 45, 25, 12, 50, 32, 2, 28, 11, 62, 14},
+ {44, 16, 7, 48, 1, 62, 16, 50, 27, 33, 61, 25, 17, 44, 31, 14, 22, 43, 32,
+ 48, 18, 40, 8, 36, 3, 16, 33, 62, 23, 38, 25, 53, 2, 21, 41, 6, 22, 15, 59,
+ 29, 16, 37, 26, 15, 52, 42, 23, 15, 54, 39, 10, 30, 53, 11, 49, 24, 2, 43,
+ 55, 17, 34, 44, 15, 31, 24, 44, 2, 32, 7, 35, 25, 5, 40, 45, 29, 51, 6, 21,
+ 37, 52, 24, 60, 13, 31, 53, 23, 2, 28, 49, 24, 31, 60, 20, 51, 1, 34, 48,
+ 14, 59, 33, 50, 1, 18, 33, 48, 60, 17, 51, 39, 6, 38, 2, 35, 29, 40, 23, 1,
+ 62, 15, 53, 37, 17, 46, 57, 40, 51, 24, 22},
+ {5, 37, 52, 24, 45, 13, 40, 3, 45, 9, 19, 42, 56, 4, 37, 46, 56, 2, 63, 11,
+ 51, 1, 49, 13, 59, 45, 39, 1, 48, 15, 58, 9, 46, 31, 54, 35, 57, 38, 3, 46,
+ 56, 4, 47, 57, 1, 30, 38, 63, 3, 46, 28, 63, 41, 14, 33, 62, 19, 32, 13, 28,
+ 61, 1, 53, 42, 11, 60, 22, 62, 27, 42, 61, 31, 19, 8, 61, 12, 32, 55, 2, 18,
+ 33, 12, 43, 36, 9, 62, 30, 55, 6, 58, 35, 7, 43, 29, 54, 23, 43, 30, 3, 25,
+ 11, 45, 52, 28, 7, 14, 42, 1, 22, 50, 16, 53, 19, 59, 4, 46, 33, 41, 4, 35,
+ 58, 5, 26, 13, 20, 2, 34, 54},
+ {30, 63, 21, 10, 26, 55, 29, 59, 23, 39, 53, 1, 36, 24, 59, 27, 10, 34, 23,
+ 38, 30, 60, 22, 42, 28, 19, 9, 57, 30, 19, 43, 33, 13, 63, 3, 19, 11, 50,
+ 31, 20, 14, 34, 10, 35, 17, 59, 7, 31, 19, 25, 50, 5, 20, 57, 29, 6, 52, 41,
+ 4, 46, 20, 37, 26, 17, 49, 6, 39, 18, 53, 14, 3, 49, 57, 23, 34, 48, 14, 41,
+ 28, 38, 56, 6, 58, 25, 39, 19, 43, 15, 37, 11, 47, 18, 53, 4, 37, 9, 62, 21,
+ 53, 40, 57, 24, 13, 40, 56, 26, 47, 31, 59, 25, 45, 27, 10, 43, 21, 61, 13,
+ 27, 48, 9, 23, 43, 31, 62, 38, 59, 9, 47},
+ {25, 4, 40, 60, 34, 6, 18, 36, 8, 57, 12, 30, 49, 14, 6, 54, 41, 16, 50, 6,
+ 43, 15, 34, 4, 53, 24, 50, 35, 4, 51, 7, 55, 28, 24, 39, 44, 60, 7, 25, 62,
+ 42, 53, 24, 61, 28, 45, 52, 12, 48, 37, 9, 35, 43, 3, 37, 48, 12, 58, 30,
+ 52, 9, 59, 6, 57, 33, 29, 48, 4, 37, 45, 20, 34, 10, 39, 0, 60, 22, 45, 8,
+ 63, 21, 42, 14, 49, 3, 56, 11, 46, 21, 61, 0, 42, 25, 13, 63, 17, 36, 8, 46,
+ 16, 6, 35, 63, 0, 21, 37, 4, 57, 9, 34, 5, 61, 48, 32, 8, 37, 54, 17, 56,
+ 30, 60, 0, 50, 16, 7, 29, 42, 17},
+ {32, 50, 15, 48, 2, 43, 52, 25, 47, 16, 32, 63, 21, 52, 40, 19, 0, 61, 29,
+ 58, 20, 56, 26, 46, 12, 55, 6, 22, 62, 32, 17, 40, 0, 49, 34, 8, 27, 32, 48,
+ 0, 21, 39, 5, 44, 12, 6, 22, 40, 0, 57, 16, 60, 23, 17, 54, 22, 36, 15, 24,
+ 39, 19, 34, 47, 23, 0, 54, 13, 51, 24, 9, 55, 16, 52, 27, 44, 20, 4, 54, 26,
+ 49, 0, 30, 46, 16, 29, 51, 34, 4, 52, 28, 33, 15, 57, 39, 26, 49, 0, 56, 27,
+ 31, 48, 20, 43, 29, 53, 11, 46, 19, 41, 13, 55, 18, 0, 57, 26, 51, 2, 44, 6,
+ 38, 14, 40, 22, 45, 36, 53, 3, 57},
+ {44, 12, 37, 28, 22, 57, 11, 38, 0, 51, 9, 41, 4, 29, 11, 47, 33, 45, 12, 26,
+ 3, 36, 9, 63, 31, 16, 38, 44, 14, 47, 25, 61, 20, 58, 15, 47, 17, 57, 13,
+ 36, 9, 51, 18, 29, 50, 36, 54, 20, 61, 27, 32, 13, 53, 44, 9, 27, 0, 63, 45,
+ 2, 56, 10, 14, 43, 41, 28, 58, 11, 35, 60, 30, 41, 6, 63, 11, 51, 37, 32,
+ 15, 10, 35, 53, 5, 61, 22, 7, 26, 59, 23, 9, 44, 48, 21, 3, 51, 32, 24, 41,
+ 12, 61, 2, 55, 9, 15, 35, 58, 28, 15, 62, 30, 37, 23, 42, 29, 11, 17, 35,
+ 24, 63, 20, 52, 28, 8, 55, 11, 23, 47, 19},
+ {0, 56, 8, 53, 14, 31, 61, 20, 55, 28, 62, 18, 35, 60, 25, 57, 7, 23, 39, 54,
+ 47, 17, 43, 0, 40, 59, 29, 2, 56, 10, 37, 5, 43, 11, 29, 52, 1, 23, 54, 41,
+ 59, 30, 55, 1, 62, 15, 33, 4, 43, 10, 47, 39, 1, 31, 40, 60, 49, 33, 7, 55,
+ 26, 50, 31, 61, 8, 18, 21, 32, 44, 1, 25, 47, 18, 36, 30, 23, 59, 7, 40, 59,
+ 27, 19, 38, 32, 44, 54, 40, 17, 38, 60, 27, 6, 35, 55, 10, 14, 44, 5, 50,
+ 17, 38, 26, 42, 50, 18, 3, 44, 52, 2, 49, 7, 52, 15, 46, 62, 39, 55, 10, 31,
+ 48, 3, 58, 33, 18, 61, 34, 13, 59},
+ {39, 27, 63, 20, 35, 41, 4, 45, 26, 5, 38, 13, 44, 2, 50, 17, 37, 52, 2, 13,
+ 28, 58, 24, 51, 21, 8, 34, 48, 27, 42, 18, 51, 31, 56, 5, 36, 38, 44, 4, 17,
+ 26, 11, 38, 23, 42, 8, 56, 39, 24, 51, 5, 56, 21, 59, 14, 6, 18, 42, 22, 35,
+ 16, 37, 3, 25, 39, 46, 63, 5, 50, 17, 58, 8, 55, 3, 50, 12, 43, 17, 47, 2,
+ 51, 9, 62, 12, 1, 35, 13, 50, 1, 37, 12, 51, 19, 29, 46, 59, 22, 58, 33, 45,
+ 22, 60, 10, 32, 61, 39, 8, 33, 25, 36, 20, 60, 38, 4, 21, 5, 28, 45, 12, 18,
+ 42, 11, 49, 1, 27, 40, 6, 30},
+ {24, 16, 42, 1, 50, 10, 48, 17, 33, 43, 24, 48, 21, 55, 31, 42, 10, 21, 63,
+ 35, 49, 6, 33, 13, 41, 53, 10, 20, 60, 6, 53, 26, 12, 41, 22, 60, 14, 28,
+ 63, 33, 49, 3, 45, 16, 48, 26, 14, 46, 18, 30, 35, 26, 8, 50, 29, 51, 25,
+ 57, 12, 47, 53, 9, 62, 20, 54, 2, 36, 15, 40, 28, 33, 13, 38, 24, 46, 1, 29,
+ 56, 33, 20, 44, 24, 41, 26, 57, 20, 63, 8, 30, 55, 5, 41, 62, 8, 34, 2, 37,
+ 10, 19, 6, 37, 1, 53, 23, 5, 27, 58, 22, 43, 12, 50, 26, 9, 34, 54, 32, 49,
+ 1, 59, 37, 22, 46, 25, 36, 51, 15, 54, 46},
+ {52, 7, 45, 33, 26, 58, 14, 60, 7, 54, 3, 58, 8, 34, 14, 5, 59, 30, 18, 44,
+ 8, 22, 48, 62, 3, 26, 55, 38, 23, 16, 39, 1, 62, 24, 49, 9, 53, 19, 46, 7,
+ 19, 60, 31, 58, 2, 34, 53, 7, 59, 2, 62, 42, 46, 19, 36, 11, 44, 4, 38, 28,
+ 1, 43, 32, 51, 12, 29, 56, 22, 52, 2, 62, 49, 22, 60, 14, 35, 63, 5, 25, 57,
+ 14, 53, 4, 46, 18, 31, 42, 22, 47, 20, 58, 31, 16, 43, 23, 54, 30, 42, 52,
+ 57, 29, 49, 30, 13, 45, 48, 16, 55, 6, 63, 1, 44, 14, 58, 19, 47, 15, 24,
+ 51, 34, 6, 55, 5, 63, 20, 41, 21, 9},
+ {30, 62, 18, 55, 5, 23, 39, 29, 49, 30, 15, 36, 28, 46, 60, 25, 39, 46, 4,
+ 32, 61, 40, 15, 30, 36, 45, 14, 2, 49, 33, 57, 45, 18, 32, 3, 45, 30, 2, 35,
+ 52, 40, 27, 13, 21, 38, 63, 20, 28, 37, 23, 16, 10, 13, 55, 2, 62, 21, 32,
+ 60, 17, 58, 23, 5, 40, 16, 48, 7, 45, 10, 26, 43, 19, 6, 31, 52, 21, 39, 16,
+ 48, 9, 37, 28, 36, 55, 7, 48, 3, 59, 15, 45, 25, 1, 53, 13, 47, 7, 62, 15,
+ 4, 25, 12, 41, 18, 60, 38, 11, 34, 19, 39, 31, 29, 56, 23, 42, 3, 27, 60,
+ 41, 8, 16, 61, 29, 43, 9, 32, 2, 60, 34},
+ {3, 38, 13, 37, 52, 44, 2, 19, 12, 42, 63, 19, 40, 1, 20, 50, 12, 55, 15, 56,
+ 27, 1, 54, 11, 57, 18, 32, 63, 44, 4, 29, 13, 37, 61, 35, 16, 42, 57, 12,
+ 22, 6, 55, 43, 10, 50, 5, 44, 11, 48, 52, 34, 58, 28, 41, 38, 30, 7, 52, 11,
+ 49, 30, 14, 45, 27, 59, 34, 21, 38, 32, 58, 11, 36, 56, 42, 9, 41, 3, 54,
+ 31, 42, 0, 60, 16, 11, 39, 24, 52, 33, 6, 36, 10, 40, 32, 60, 26, 20, 39,
+ 28, 47, 34, 63, 8, 54, 3, 24, 56, 0, 51, 13, 47, 16, 40, 7, 35, 52, 11, 36,
+ 4, 57, 30, 39, 13, 18, 50, 58, 28, 12, 48},
+ {57, 24, 49, 21, 10, 31, 61, 36, 56, 0, 22, 53, 11, 56, 32, 7, 36, 27, 41, 9,
+ 46, 19, 34, 42, 25, 7, 50, 9, 28, 21, 54, 8, 50, 7, 27, 59, 10, 25, 48, 62,
+ 37, 0, 33, 58, 25, 18, 32, 61, 0, 15, 45, 5, 50, 3, 23, 55, 47, 17, 40, 6,
+ 60, 34, 53, 8, 41, 0, 61, 13, 54, 4, 46, 28, 0, 17, 48, 27, 58, 13, 23, 61,
+ 33, 21, 50, 30, 62, 8, 14, 29, 56, 27, 61, 49, 17, 2, 44, 11, 51, 0, 59, 17,
+ 40, 20, 32, 47, 36, 21, 42, 28, 60, 4, 54, 10, 59, 17, 30, 62, 21, 43, 26,
+ 48, 0, 56, 36, 25, 8, 44, 39, 17},
+ {10, 42, 4, 59, 27, 47, 8, 23, 51, 32, 45, 6, 37, 26, 48, 43, 62, 0, 21, 53,
+ 38, 12, 51, 5, 60, 47, 24, 37, 59, 15, 35, 47, 22, 55, 0, 50, 21, 40, 6, 29,
+ 15, 52, 24, 8, 41, 55, 13, 29, 40, 56, 24, 31, 19, 33, 61, 15, 0, 35, 24,
+ 42, 21, 2, 19, 57, 24, 15, 30, 50, 20, 25, 40, 16, 57, 34, 61, 8, 29, 45, 6,
+ 49, 11, 47, 2, 44, 19, 57, 38, 50, 12, 42, 21, 4, 35, 52, 28, 56, 23, 36,
+ 13, 45, 4, 52, 27, 14, 6, 62, 9, 45, 21, 37, 25, 46, 33, 49, 0, 44, 7, 53,
+ 13, 19, 53, 31, 3, 47, 15, 56, 22, 51},
+ {35, 28, 53, 32, 1, 16, 54, 40, 9, 17, 25, 58, 14, 59, 3, 22, 16, 51, 31, 5,
+ 23, 58, 28, 17, 35, 20, 0, 42, 11, 52, 3, 31, 41, 17, 43, 13, 32, 54, 18,
+ 60, 32, 45, 17, 49, 2, 36, 51, 22, 7, 36, 9, 63, 48, 12, 46, 26, 43, 28, 63,
+ 13, 48, 37, 51, 33, 5, 47, 55, 9, 42, 63, 7, 51, 24, 12, 37, 19, 55, 34, 18,
+ 38, 15, 28, 54, 34, 5, 43, 22, 0, 48, 14, 54, 24, 58, 9, 38, 5, 32, 55, 21,
+ 30, 49, 9, 59, 43, 30, 51, 35, 26, 7, 53, 2, 22, 14, 27, 57, 18, 38, 24, 33,
+ 45, 10, 41, 20, 60, 37, 5, 32, 0},
+ {63, 19, 15, 40, 62, 35, 14, 28, 46, 61, 4, 49, 35, 10, 29, 54, 33, 8, 45,
+ 62, 37, 1, 43, 55, 10, 52, 61, 30, 19, 40, 25, 62, 11, 38, 27, 58, 36, 3,
+ 46, 8, 39, 4, 62, 28, 47, 20, 4, 54, 47, 27, 43, 1, 21, 38, 8, 58, 10, 54,
+ 4, 56, 9, 26, 12, 39, 60, 27, 18, 37, 1, 31, 35, 5, 45, 50, 2, 43, 26, 1,
+ 59, 23, 56, 40, 7, 26, 58, 17, 32, 63, 25, 39, 7, 31, 45, 19, 63, 15, 48, 8,
+ 37, 61, 16, 34, 1, 56, 18, 3, 15, 58, 49, 32, 63, 41, 55, 5, 40, 22, 50, 6,
+ 59, 2, 63, 23, 52, 11, 26, 61, 44, 23},
+ {11, 56, 46, 6, 22, 43, 58, 3, 34, 21, 38, 30, 18, 44, 52, 13, 41, 57, 17,
+ 28, 14, 49, 25, 7, 33, 39, 26, 6, 56, 48, 1, 20, 56, 5, 46, 9, 19, 51, 30,
+ 25, 56, 21, 35, 14, 57, 42, 16, 33, 10, 57, 17, 59, 41, 25, 53, 37, 20, 40,
+ 30, 18, 31, 62, 44, 22, 3, 44, 11, 48, 23, 53, 18, 60, 29, 22, 62, 15, 53,
+ 47, 10, 41, 3, 19, 52, 36, 13, 46, 10, 35, 3, 61, 41, 16, 1, 50, 26, 42, 18,
+ 46, 2, 25, 54, 20, 39, 23, 47, 31, 41, 12, 38, 17, 8, 19, 31, 48, 12, 61, 9,
+ 54, 29, 35, 15, 38, 6, 43, 34, 14, 7, 47},
+ {39, 2, 33, 26, 53, 8, 18, 50, 41, 12, 53, 1, 63, 24, 19, 39, 2, 24, 47, 10,
+ 60, 38, 19, 63, 48, 4, 15, 45, 32, 14, 60, 36, 29, 53, 23, 63, 34, 12, 61,
+ 1, 43, 11, 53, 30, 1, 26, 60, 45, 23, 39, 3, 29, 12, 50, 4, 16, 51, 3, 45,
+ 36, 50, 1, 16, 54, 35, 14, 57, 30, 58, 9, 46, 14, 41, 10, 32, 38, 4, 30, 21,
+ 51, 32, 63, 25, 1, 60, 27, 53, 18, 51, 22, 28, 55, 34, 12, 40, 3, 60, 29,
+ 57, 41, 6, 44, 11, 53, 8, 61, 24, 57, 1, 28, 44, 59, 36, 3, 34, 25, 41, 31,
+ 16, 44, 22, 47, 28, 58, 1, 49, 54, 29},
+ {58, 25, 50, 13, 38, 30, 60, 24, 6, 57, 27, 42, 9, 45, 6, 61, 30, 50, 4, 34,
+ 29, 3, 46, 13, 22, 42, 58, 28, 9, 39, 23, 44, 7, 15, 44, 2, 40, 15, 47, 41,
+ 23, 37, 7, 59, 38, 11, 34, 6, 62, 14, 52, 35, 55, 19, 32, 61, 33, 24, 57, 6,
+ 22, 59, 29, 7, 49, 25, 40, 3, 17, 39, 27, 52, 0, 55, 16, 57, 24, 61, 36, 6,
+ 29, 12, 48, 39, 20, 44, 6, 40, 33, 5, 48, 10, 57, 36, 22, 51, 33, 9, 24, 12,
+ 62, 29, 50, 35, 14, 43, 5, 33, 47, 52, 13, 23, 10, 51, 56, 16, 46, 1, 49, 4,
+ 61, 9, 52, 18, 31, 21, 36, 17},
+ {19, 42, 9, 48, 2, 44, 11, 37, 48, 20, 33, 16, 55, 35, 49, 15, 37, 20, 59,
+ 16, 53, 22, 56, 31, 50, 11, 34, 54, 16, 51, 4, 49, 33, 53, 21, 28, 56, 24,
+ 31, 9, 52, 16, 48, 24, 44, 13, 51, 20, 31, 49, 18, 6, 34, 2, 44, 14, 47, 8,
+ 15, 43, 13, 41, 33, 52, 20, 61, 7, 51, 34, 62, 4, 20, 36, 33, 43, 8, 46, 13,
+ 53, 17, 45, 42, 9, 31, 52, 11, 30, 56, 13, 59, 17, 44, 27, 6, 62, 11, 43,
+ 17, 49, 38, 26, 2, 16, 27, 58, 21, 54, 18, 26, 5, 35, 61, 43, 27, 7, 39, 14,
+ 58, 37, 55, 20, 33, 13, 40, 62, 10, 55, 5},
+ {51, 14, 61, 29, 59, 20, 55, 31, 0, 49, 11, 60, 3, 26, 22, 56, 0, 40, 12, 43,
+ 41, 8, 36, 0, 17, 57, 24, 2, 46, 26, 61, 18, 0, 38, 12, 59, 6, 49, 3, 57,
+ 19, 63, 5, 33, 18, 54, 28, 56, 0, 43, 26, 46, 63, 27, 56, 22, 27, 54, 38,
+ 28, 63, 24, 10, 45, 0, 31, 42, 21, 12, 25, 44, 49, 59, 6, 26, 50, 3, 34, 27,
+ 59, 0, 35, 62, 16, 4, 58, 47, 0, 43, 24, 37, 2, 54, 20, 46, 31, 0, 56, 34,
+ 5, 55, 45, 60, 37, 0, 40, 10, 38, 63, 46, 15, 20, 0, 53, 21, 62, 30, 11, 24,
+ 27, 40, 0, 57, 26, 3, 45, 27, 35}
};
/*****************************************************************************/
@@ -606,7 +1372,6 @@ const DATA8 _dither_128128[128][128] =
}
#endif
-
/*****************************************************************************/
/* Actual rendering routines */
/* RGBA -> RGB666 */
@@ -745,7 +1510,7 @@ _b[1] = ((((src[1] ) & 0xff) * 5) + _dith) >> 8; \
dest += 2; src += 2; \
}
#else
-#if 0 /* OOOOOOLD code for 666 - the 666 dithering uses the 128x128 dither mask :) */
+#if 0 /* OOOOOOLD code for 666 - the 666 dithering uses the 128x128 dither mask :) */
#define WRITE4_RGBA_RGB666_DITHER(src, dest) \
{ \
*((DATA32 *)dest) = (_dither_color_lut[((DITHER_RGBA_666_LUT_R(0))) + \
@@ -1623,1294 +2388,1376 @@ src++;
*dest = ((*src >> 0) & 0xff); dest++; src++;
void
-__imlib_RGBASetupContext(Context *ct)
+__imlib_RGBASetupContext(Context * ct)
{
_dither_color_lut = ct->palette;
_pal_type = ct->palette_type;
if ((ct->depth == 16) || (ct->depth == 15))
{
- _dither_r16 = (DATA16 *)ct->r_dither;
- _dither_g16 = (DATA16 *)ct->g_dither;
- _dither_b16 = (DATA16 *)ct->b_dither;
+ _dither_r16 = (DATA16 *) ct->r_dither;
+ _dither_g16 = (DATA16 *) ct->g_dither;
+ _dither_b16 = (DATA16 *) ct->b_dither;
}
else if (ct->depth <= 8)
{
- switch (_pal_type)
- {
- case 0:
- case 1:
- case 2:
- case 3:
- case 4:
- case 5:
- case 7:
- _dither_r8 = (DATA8 *)ct->r_dither;
- _dither_g8 = (DATA8 *)ct->g_dither;
- _dither_b8 = (DATA8 *)ct->b_dither;
- break;
- case 6:
- _dither_r8 = (DATA8 *)ct->r_dither;
- break;
- default:
- break;
- }
+ switch (_pal_type)
+ {
+ case 0:
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ case 5:
+ case 7:
+ _dither_r8 = (DATA8 *) ct->r_dither;
+ _dither_g8 = (DATA8 *) ct->g_dither;
+ _dither_b8 = (DATA8 *) ct->b_dither;
+ break;
+ case 6:
+ _dither_r8 = (DATA8 *) ct->r_dither;
+ break;
+ default:
+ break;
+ }
}
- _dither_r8 = (DATA8 *)ct->r_dither;
+ _dither_r8 = (DATA8 *) ct->r_dither;
}
-
+
/* Palette mode stuff */
void
__imlib_RGBA_init(void *rd, void *gd, void *bd, int depth, DATA8 palette_type)
{
- DATA16 *rd16, *gd16, *bd16;
- DATA8 *rd8, *gd8, *bd8;
- int i, x, y;
-
+ DATA16 *rd16, *gd16, *bd16;
+ DATA8 *rd8, *gd8, *bd8;
+ int i, x, y;
+
if (!dither_a_init)
{
- for (y = 0; y < 8; y++)
- {
- for (x = 0; x < 8; x++)
- {
- for (i = 0; i < 256; i++)
- {
- int pi;
-
- pi = (i * (256 - 128)) / 255;
- if ((_dither_88[x][y] < ((pi & 0x7f) >> 1)) && (pi < (256 - 128)))
- _dither_a1[(x << DM_BS1) | (y << DM_BS2) | i] = (((pi + 128) >> 7) & 0x01);
- else
- _dither_a1[(x << DM_BS1) | (y << DM_BS2) | i] = ((pi >> 7) & 0x01);
- }
- }
- }
- dither_a_init = 1;
+ for (y = 0; y < 8; y++)
+ {
+ for (x = 0; x < 8; x++)
+ {
+ for (i = 0; i < 256; i++)
+ {
+ int pi;
+
+ pi = (i * (256 - 128)) / 255;
+ if ((_dither_88[x][y] < ((pi & 0x7f) >> 1))
+ && (pi < (256 - 128)))
+ _dither_a1[(x << DM_BS1) | (y << DM_BS2) | i] =
+ (((pi + 128) >> 7) & 0x01);
+ else
+ _dither_a1[(x << DM_BS1) | (y << DM_BS2) | i] =
+ ((pi >> 7) & 0x01);
+ }
+ }
+ }
+ dither_a_init = 1;
}
- if(!rd || !gd || !bd)
+ if (!rd || !gd || !bd)
return;
switch (depth)
{
- case 16:
- rd16 = (DATA16 *)rd;
- gd16 = (DATA16 *)gd;
- bd16 = (DATA16 *)bd;
- for (y = 0; y < 4; y++)
- {
- for (x = 0; x < 4; x++)
- {
- for (i = 0; i < 256; i++)
- {
- if ((_dither_44[x][y] < (i & 0x7)) && (i < (256 - 8)))
- rd16[(x << 10) | (y << 8) | i] = ((i + 8) & 0xf8) << 8;
- else
- rd16[(x << 10) | (y << 8) | i] = (i & 0xf8) << 8;
-
- if ((_dither_44[x][y] < ((i & 0x3) << 1)) && (i < (256 - 4)))
- gd16[(x << 10) | (y << 8) | i] = (((i + 4) & 0xfc) << 8) >> 5;
- else
- gd16[(x << 10) | (y << 8) | i] = ((i & 0xfc) << 8) >> 5;
-
- if ((_dither_44[x][y] < (i & 0x7)) && (i < (256 - 8)))
- bd16[(x << 10) | (y << 8) | i] = (((i + 8) & 0xf8) << 16) >> 19;
- else
- bd16[(x << 10) | (y << 8) | i] = ((i & 0xf8) << 16) >> 19;
- }
- }
- }
- break;
- case 15:
- rd16 = (DATA16 *)rd;
- gd16 = (DATA16 *)gd;
- bd16 = (DATA16 *)bd;
- for (y = 0; y < 4; y++)
- {
- for (x = 0; x < 4; x++)
- {
- for (i = 0; i < 256; i++)
- {
- if ((_dither_44[x][y] < (i & 0x7)) && (i < (256 - 8)))
- rd16[(x << 10) | (y << 8) | i] = (((i + 8) & 0xf8) << 8) >> 1;
- else
- rd16[(x << 10) | (y << 8) | i] = ((i & 0xf8) << 8) >> 1;
-
- if ((_dither_44[x][y] < (i & 0x7)) && (i < (256 - 8)))
- gd16[(x << 10) | (y << 8) | i] = (((i + 8) & 0xf8) << 8) >> 6;
- else
- gd16[(x << 10) | (y << 8) | i] = ((i & 0xf8) << 8) >> 6;
-
- if ((_dither_44[x][y] < (i & 0x7)) && (i < (256 - 8)))
- bd16[(x << 10) | (y << 8) | i] = (((i + 8) & 0xf8) << 16) >> 19;
- else
- bd16[(x << 10) | (y << 8) | i] = ((i & 0xf8) << 16) >> 19;
- }
- }
- }
- break;
- default:
- rd8 = (DATA8 *)rd;
- gd8 = (DATA8 *)gd;
- bd8 = (DATA8 *)bd;
- switch (palette_type)
- {
- case 0:
- for (y = 0; y < DM_Y; y++)
- {
- for (x = 0; x < DM_X; x++)
- {
- for (i = 0; i < 256; i++)
- {
- int pi;
-
- pi = (i * (256 - 32)) / 255;
- if ((_dither_88[x][y] < ((pi & 0x1f) << 1)) && (pi < (256 - 32)))
- rd8[(x << DM_BS1) | (y << DM_BS2) | i] = ((pi + 32) & 0xe0);
- else
- rd8[(x << DM_BS1) | (y << DM_BS2) | i] = (pi & 0xe0);
-
- pi = (i * (256 - 32)) / 255;
- if ((_dither_88[x][y] < ((pi & 0x1f) << 1)) && (pi < (256 - 32)))
- gd8[(x << DM_BS1) | (y << DM_BS2) | i] = (((pi + 32) >> 3)& 0x1c);
- else
- gd8[(x << DM_BS1) | (y << DM_BS2) | i] = ((pi >> 3) & 0x1c);
-
- pi = (i * (256 - 64)) / 255;
- if ((_dither_88[x][y] < (pi & 0x3f)) && (pi < (256 - 64)))
- bd8[(x << DM_BS1) | (y << DM_BS2) | i] = (((pi + 64) >> 6)& 0x03);
- else
- bd8[(x << DM_BS1) | (y << DM_BS2) | i] = ((pi >> 6) & 0x03);
- }
- }
- }
- break;
- case 7: /* 666 8 bit 216 color rgb cube */
- if (!_dither_666r)
- {
- _dither_666r = malloc(256 * sizeof(DATA8));
- _dither_666g = malloc(256 * sizeof(DATA8));
- _dither_666b = malloc(256 * sizeof(DATA8));
- }
- for (y = 0; y < 256; y++)
- {
- _dither_666r[y] = (DATA8)(((y * 6) >> 8) * 6 * 6);
- _dither_666g[y] = (DATA8)(((y * 6) >> 8) * 6);
- _dither_666b[y] = (DATA8)(((y * 6) >> 8));
- }
- for (y = 0; y < DM_Y; y++)
- {
- for (x = 0; x < DM_X; x++)
- {
- for (i = 0; i < 256; i++)
- {
- double pi;
-
- pi = 64.0 * (((double)i - (_dither_666b[i] * (256.0 / 6.0))) / (256.0 / 6.0));
- if ((_dither_88[x][y] < (DATA8)pi) && ((double)i < (256 - (256.0 / 6.0))))
- {
- rd8[(x << DM_BS1) | (y << DM_BS2) | i] = (_dither_666b[i] + 1) * 6 * 6;
- gd8[(x << DM_BS1) | (y << DM_BS2) | i] = (_dither_666b[i] + 1) * 6;
- bd8[(x << DM_BS1) | (y << DM_BS2) | i] = (_dither_666b[i] + 1);
- }
- else
- {
- rd8[(x << DM_BS1) | (y << DM_BS2) | i] = (_dither_666b[i]) * 6 * 6;
- gd8[(x << DM_BS1) | (y << DM_BS2) | i] = (_dither_666b[i]) * 6;
- bd8[(x << DM_BS1) | (y << DM_BS2) | i] = (_dither_666b[i]);
- }
- }
- }
- }
- break;
- case 1:
- for (y = 0; y < DM_Y; y++)
- {
- for (x = 0; x < DM_X; x++)
- {
- for (i = 0; i < 256; i++)
- {
- int pi;
-
- pi = (i * (256 - 64)) / 255;
- if ((_dither_88[x][y] < (pi & 0x3f)) && (pi < (256 - 64)))
- rd8[(x << DM_BS1) | (y << DM_BS2) | i] = (((pi + 64) >> 1) & 0x60);
- else
- rd8[(x << DM_BS1) | (y << DM_BS2) | i] = ((pi >> 1) & 0x60);
-
- pi = (i * (256 - 32)) / 255;
- if ((_dither_88[x][y] < ((pi & 0x1f) << 1)) && (pi < (256 - 32)))
- gd8[(x << DM_BS1) | (y << DM_BS2) | i] = (((pi + 32) >> 3)& 0x1c);
- else
- gd8[(x << DM_BS1) | (y << DM_BS2) | i] = ((pi >> 3) & 0x1c);
-
- pi = (i * (256 - 64)) / 255;
- if ((_dither_88[x][y] < (pi & 0x3f)) && (pi < (256 - 64)))
- bd8[(x << DM_BS1) | (y << DM_BS2) | i] = (((pi + 64) >> 6)& 0x03);
- else
- bd8[(x << DM_BS1) | (y << DM_BS2) | i] = ((pi >> 6) & 0x03);
- }
- }
- }
- break;
- case 2:
- for (y = 0; y < DM_Y; y++)
- {
- for (x = 0; x < DM_X; x++)
- {
- for (i = 0; i < 256; i++)
- {
- int pi;
-
- pi = (i * (256 - 64)) / 255;
- if ((_dither_88[x][y] < (pi & 0x3f)) && (pi < (256 - 64)))
- rd8[(x << DM_BS1) | (y << DM_BS2) | i] = (((pi + 64) >> 2) & 0x30);
- else
- rd8[(x << DM_BS1) | (y << DM_BS2) | i] = ((pi >> 2) & 0x30);
-
- pi = (i * (256 - 64)) / 255;
- if ((_dither_88[x][y] < (pi & 0x3f)) && (pi < (256 - 64)))
- gd8[(x << DM_BS1) | (y << DM_BS2) | i] = (((pi + 64) >> 4)& 0x0c);
- else
- gd8[(x << DM_BS1) | (y << DM_BS2) | i] = ((pi >> 4) & 0x0c);
-
- pi = (i * (256 - 64)) / 255;
- if ((_dither_88[x][y] < (pi & 0x3f)) && (pi < (256 - 64)))
- bd8[(x << DM_BS1) | (y << DM_BS2) | i] = (((pi + 64) >> 6)& 0x03);
- else
- bd8[(x << DM_BS1) | (y << DM_BS2) | i] = ((pi >> 6) & 0x03);
- }
- }
- }
- break;
- case 3:
- for (y = 0; y < DM_Y; y++)
- {
- for (x = 0; x < DM_X; x++)
- {
- for (i = 0; i < 256; i++)
- {
- int pi;
-
- pi = (i * (256 - 64)) / 255;
- if ((_dither_88[x][y] < (pi & 0x3f)) && (pi < (256 - 64)))
- rd8[(x << DM_BS1) | (y << DM_BS2) | i] = (((pi + 64) >> 3) & 0x18);
- else
- rd8[(x << DM_BS1) | (y << DM_BS2) | i] = ((pi >> 3) & 0x18);
-
- pi = (i * (256 - 64)) / 255;
- if ((_dither_88[x][y] < (pi & 0x3f)) && (pi < (256 - 64)))
- gd8[(x << DM_BS1) | (y << DM_BS2) | i] = (((pi + 64) >> 5) & 0x06);
- else
- gd8[(x << DM_BS1) | (y << DM_BS2) | i] = ((pi >> 5) & 0x06);
-
- pi = (i * (256 - 128)) / 255;
- if ((_dither_88[x][y] < ((pi & 0x7f) >> 1)) && (pi < (256 - 128)))
- bd8[(x << DM_BS1) | (y << DM_BS2) | i] = (((pi + 128) >> 7) & 0x01);
- else
- bd8[(x << DM_BS1) | (y << DM_BS2) | i] = ((pi >> 7) & 0x01);
- }
- }
- }
- break;
- case 4:
- for (y = 0; y < DM_Y; y++)
- {
- for (x = 0; x < DM_X; x++)
- {
- for (i = 0; i < 256; i++)
- {
- int pi;
-
- pi = (i * (256 - 128)) / 255;
- if ((_dither_88[x][y] < ((pi & 0x7f) >> 1)) && (pi < (256 - 128)))
- rd8[(x << DM_BS1) | (y << DM_BS2) | i] = (((pi + 128) >> 4) & 0x08);
- else
- rd8[(x << DM_BS1) | (y << DM_BS2) | i] = ((pi >> 4) & 0x08);
-
- pi = (i * (256 - 64)) / 255;
- if ((_dither_88[x][y] < (pi & 0x3f)) && (pi < (256 - 64)))
- gd8[(x << DM_BS1) | (y << DM_BS2) | i] = (((pi + 64) >> 5) & 0x06);
- else
- gd8[(x << DM_BS1) | (y << DM_BS2) | i] = ((pi >> 5) & 0x06);
-
- pi = (i * (256 - 128)) / 255;
- if ((_dither_88[x][y] < ((pi & 0x7f) >> 1)) && (pi < (256 - 128)))
- bd8[(x << DM_BS1) | (y << DM_BS2) | i] = (((pi + 128) >> 7) & 0x01);
- else
- bd8[(x << DM_BS1) | (y << DM_BS2) | i] = ((pi >> 7) & 0x01);
- }
- }
- }
- break;
- case 5:
- for (y = 0; y < DM_Y; y++)
- {
- for (x = 0; x < DM_X; x++)
- {
- for (i = 0; i < 256; i++)
- {
- int pi;
-
- pi = (i * (256 - 128)) / 255;
- if ((_dither_88[x][y] < ((pi & 0x7f) >> 1)) && (pi < (256 - 128)))
- rd8[(x << DM_BS1) | (y << DM_BS2) | i] = (((pi + 128) >> 5) & 0x04);
- else
- rd8[(x << DM_BS1) | (y << DM_BS2) | i] = ((pi >> 5) & 0x04);
-
- pi = (i * (256 - 128)) / 255;
- if ((_dither_88[x][y] < ((pi & 0x7f) >> 1)) && (pi < (256 - 128)))
- gd8[(x << DM_BS1) | (y << DM_BS2) | i] = (((pi + 128) >> 6) & 0x02);
- else
- gd8[(x << DM_BS1) | (y << DM_BS2) | i] = ((pi >> 6) & 0x02);
-
- pi = (i * (256 - 128)) / 255;
- if ((_dither_88[x][y] < ((pi & 0x7f) >> 1)) && (pi < (256 - 128)))
- bd8[(x << DM_BS1) | (y << DM_BS2) | i] = (((pi + 128) >> 7) & 0x01);
- else
- bd8[(x << DM_BS1) | (y << DM_BS2) | i] = ((pi >> 7) & 0x01);
- }
- }
- }
- break;
- case 6:
- for (y = 0; y < DM_Y; y++)
- {
- for (x = 0; x < DM_X; x++)
- {
- for (i = 0; i < 256; i++)
- {
- int pi;
-
- pi = (i * (256 - 128)) / 255;
- if ((_dither_88[x][y] < ((pi & 0x7f) >> 1)) && (pi < (256 - 128)))
- rd8[(x << DM_BS1) | (y << DM_BS2) | i] = (((pi + 128) >> 7) & 0x01);
- else
- rd8[(x << DM_BS1) | (y << DM_BS2) | i] = ((pi >> 7) & 0x01);
- }
- }
- }
- break;
- default:
- break;
- }
- break;
+ case 16:
+ rd16 = (DATA16 *) rd;
+ gd16 = (DATA16 *) gd;
+ bd16 = (DATA16 *) bd;
+ for (y = 0; y < 4; y++)
+ {
+ for (x = 0; x < 4; x++)
+ {
+ for (i = 0; i < 256; i++)
+ {
+ if ((_dither_44[x][y] < (i & 0x7)) && (i < (256 - 8)))
+ rd16[(x << 10) | (y << 8) | i] =
+ ((i + 8) & 0xf8) << 8;
+ else
+ rd16[(x << 10) | (y << 8) | i] = (i & 0xf8) << 8;
+
+ if ((_dither_44[x][y] < ((i & 0x3) << 1))
+ && (i < (256 - 4)))
+ gd16[(x << 10) | (y << 8) | i] =
+ (((i + 4) & 0xfc) << 8) >> 5;
+ else
+ gd16[(x << 10) | (y << 8) | i] =
+ ((i & 0xfc) << 8) >> 5;
+
+ if ((_dither_44[x][y] < (i & 0x7)) && (i < (256 - 8)))
+ bd16[(x << 10) | (y << 8) | i] =
+ (((i + 8) & 0xf8) << 16) >> 19;
+ else
+ bd16[(x << 10) | (y << 8) | i] =
+ ((i & 0xf8) << 16) >> 19;
+ }
+ }
+ }
+ break;
+ case 15:
+ rd16 = (DATA16 *) rd;
+ gd16 = (DATA16 *) gd;
+ bd16 = (DATA16 *) bd;
+ for (y = 0; y < 4; y++)
+ {
+ for (x = 0; x < 4; x++)
+ {
+ for (i = 0; i < 256; i++)
+ {
+ if ((_dither_44[x][y] < (i & 0x7)) && (i < (256 - 8)))
+ rd16[(x << 10) | (y << 8) | i] =
+ (((i + 8) & 0xf8) << 8) >> 1;
+ else
+ rd16[(x << 10) | (y << 8) | i] =
+ ((i & 0xf8) << 8) >> 1;
+
+ if ((_dither_44[x][y] < (i & 0x7)) && (i < (256 - 8)))
+ gd16[(x << 10) | (y << 8) | i] =
+ (((i + 8) & 0xf8) << 8) >> 6;
+ else
+ gd16[(x << 10) | (y << 8) | i] =
+ ((i & 0xf8) << 8) >> 6;
+
+ if ((_dither_44[x][y] < (i & 0x7)) && (i < (256 - 8)))
+ bd16[(x << 10) | (y << 8) | i] =
+ (((i + 8) & 0xf8) << 16) >> 19;
+ else
+ bd16[(x << 10) | (y << 8) | i] =
+ ((i & 0xf8) << 16) >> 19;
+ }
+ }
+ }
+ break;
+ default:
+ rd8 = (DATA8 *) rd;
+ gd8 = (DATA8 *) gd;
+ bd8 = (DATA8 *) bd;
+ switch (palette_type)
+ {
+ case 0:
+ for (y = 0; y < DM_Y; y++)
+ {
+ for (x = 0; x < DM_X; x++)
+ {
+ for (i = 0; i < 256; i++)
+ {
+ int pi;
+
+ pi = (i * (256 - 32)) / 255;
+ if ((_dither_88[x][y] < ((pi & 0x1f) << 1))
+ && (pi < (256 - 32)))
+ rd8[(x << DM_BS1) | (y << DM_BS2) | i] =
+ ((pi + 32) & 0xe0);
+ else
+ rd8[(x << DM_BS1) | (y << DM_BS2) | i] =
+ (pi & 0xe0);
+
+ pi = (i * (256 - 32)) / 255;
+ if ((_dither_88[x][y] < ((pi & 0x1f) << 1))
+ && (pi < (256 - 32)))
+ gd8[(x << DM_BS1) | (y << DM_BS2) | i] =
+ (((pi + 32) >> 3) & 0x1c);
+ else
+ gd8[(x << DM_BS1) | (y << DM_BS2) | i] =
+ ((pi >> 3) & 0x1c);
+
+ pi = (i * (256 - 64)) / 255;
+ if ((_dither_88[x][y] < (pi & 0x3f))
+ && (pi < (256 - 64)))
+ bd8[(x << DM_BS1) | (y << DM_BS2) | i] =
+ (((pi + 64) >> 6) & 0x03);
+ else
+ bd8[(x << DM_BS1) | (y << DM_BS2) | i] =
+ ((pi >> 6) & 0x03);
+ }
+ }
+ }
+ break;
+ case 7: /* 666 8 bit 216 color rgb cube */
+ if (!_dither_666r)
+ {
+ _dither_666r = malloc(256 * sizeof(DATA8));
+ _dither_666g = malloc(256 * sizeof(DATA8));
+ _dither_666b = malloc(256 * sizeof(DATA8));
+ }
+ for (y = 0; y < 256; y++)
+ {
+ _dither_666r[y] = (DATA8) (((y * 6) >> 8) * 6 * 6);
+ _dither_666g[y] = (DATA8) (((y * 6) >> 8) * 6);
+ _dither_666b[y] = (DATA8) (((y * 6) >> 8));
+ }
+ for (y = 0; y < DM_Y; y++)
+ {
+ for (x = 0; x < DM_X; x++)
+ {
+ for (i = 0; i < 256; i++)
+ {
+ double pi;
+
+ pi = 64.0 *
+ (((double)i -
+ (_dither_666b[i] * (256.0 / 6.0))) /
+ (256.0 / 6.0));
+ if ((_dither_88[x][y] < (DATA8) pi)
+ && ((double)i < (256 - (256.0 / 6.0))))
+ {
+ rd8[(x << DM_BS1) | (y << DM_BS2) | i] =
+ (_dither_666b[i] + 1) * 6 * 6;
+ gd8[(x << DM_BS1) | (y << DM_BS2) | i] =
+ (_dither_666b[i] + 1) * 6;
+ bd8[(x << DM_BS1) | (y << DM_BS2) | i] =
+ (_dither_666b[i] + 1);
+ }
+ else
+ {
+ rd8[(x << DM_BS1) | (y << DM_BS2) | i] =
+ (_dither_666b[i]) * 6 * 6;
+ gd8[(x << DM_BS1) | (y << DM_BS2) | i] =
+ (_dither_666b[i]) * 6;
+ bd8[(x << DM_BS1) | (y << DM_BS2) | i] =
+ (_dither_666b[i]);
+ }
+ }
+ }
+ }
+ break;
+ case 1:
+ for (y = 0; y < DM_Y; y++)
+ {
+ for (x = 0; x < DM_X; x++)
+ {
+ for (i = 0; i < 256; i++)
+ {
+ int pi;
+
+ pi = (i * (256 - 64)) / 255;
+ if ((_dither_88[x][y] < (pi & 0x3f))
+ && (pi < (256 - 64)))
+ rd8[(x << DM_BS1) | (y << DM_BS2) | i] =
+ (((pi + 64) >> 1) & 0x60);
+ else
+ rd8[(x << DM_BS1) | (y << DM_BS2) | i] =
+ ((pi >> 1) & 0x60);
+
+ pi = (i * (256 - 32)) / 255;
+ if ((_dither_88[x][y] < ((pi & 0x1f) << 1))
+ && (pi < (256 - 32)))
+ gd8[(x << DM_BS1) | (y << DM_BS2) | i] =
+ (((pi + 32) >> 3) & 0x1c);
+ else
+ gd8[(x << DM_BS1) | (y << DM_BS2) | i] =
+ ((pi >> 3) & 0x1c);
+
+ pi = (i * (256 - 64)) / 255;
+ if ((_dither_88[x][y] < (pi & 0x3f))
+ && (pi < (256 - 64)))
+ bd8[(x << DM_BS1) | (y << DM_BS2) | i] =
+ (((pi + 64) >> 6) & 0x03);
+ else
+ bd8[(x << DM_BS1) | (y << DM_BS2) | i] =
+ ((pi >> 6) & 0x03);
+ }
+ }
+ }
+ break;
+ case 2:
+ for (y = 0; y < DM_Y; y++)
+ {
+ for (x = 0; x < DM_X; x++)
+ {
+ for (i = 0; i < 256; i++)
+ {
+ int pi;
+
+ pi = (i * (256 - 64)) / 255;
+ if ((_dither_88[x][y] < (pi & 0x3f))
+ && (pi < (256 - 64)))
+ rd8[(x << DM_BS1) | (y << DM_BS2) | i] =
+ (((pi + 64) >> 2) & 0x30);
+ else
+ rd8[(x << DM_BS1) | (y << DM_BS2) | i] =
+ ((pi >> 2) & 0x30);
+
+ pi = (i * (256 - 64)) / 255;
+ if ((_dither_88[x][y] < (pi & 0x3f))
+ && (pi < (256 - 64)))
+ gd8[(x << DM_BS1) | (y << DM_BS2) | i] =
+ (((pi + 64) >> 4) & 0x0c);
+ else
+ gd8[(x << DM_BS1) | (y << DM_BS2) | i] =
+ ((pi >> 4) & 0x0c);
+
+ pi = (i * (256 - 64)) / 255;
+ if ((_dither_88[x][y] < (pi & 0x3f))
+ && (pi < (256 - 64)))
+ bd8[(x << DM_BS1) | (y << DM_BS2) | i] =
+ (((pi + 64) >> 6) & 0x03);
+ else
+ bd8[(x << DM_BS1) | (y << DM_BS2) | i] =
+ ((pi >> 6) & 0x03);
+ }
+ }
+ }
+ break;
+ case 3:
+ for (y = 0; y < DM_Y; y++)
+ {
+ for (x = 0; x < DM_X; x++)
+ {
+ for (i = 0; i < 256; i++)
+ {
+ int pi;
+
+ pi = (i * (256 - 64)) / 255;
+ if ((_dither_88[x][y] < (pi & 0x3f))
+ && (pi < (256 - 64)))
+ rd8[(x << DM_BS1) | (y << DM_BS2) | i] =
+ (((pi + 64) >> 3) & 0x18);
+ else
+ rd8[(x << DM_BS1) | (y << DM_BS2) | i] =
+ ((pi >> 3) & 0x18);
+
+ pi = (i * (256 - 64)) / 255;
+ if ((_dither_88[x][y] < (pi & 0x3f))
+ && (pi < (256 - 64)))
+ gd8[(x << DM_BS1) | (y << DM_BS2) | i] =
+ (((pi + 64) >> 5) & 0x06);
+ else
+ gd8[(x << DM_BS1) | (y << DM_BS2) | i] =
+ ((pi >> 5) & 0x06);
+
+ pi = (i * (256 - 128)) / 255;
+ if ((_dither_88[x][y] < ((pi & 0x7f) >> 1))
+ && (pi < (256 - 128)))
+ bd8[(x << DM_BS1) | (y << DM_BS2) | i] =
+ (((pi + 128) >> 7) & 0x01);
+ else
+ bd8[(x << DM_BS1) | (y << DM_BS2) | i] =
+ ((pi >> 7) & 0x01);
+ }
+ }
+ }
+ break;
+ case 4:
+ for (y = 0; y < DM_Y; y++)
+ {
+ for (x = 0; x < DM_X; x++)
+ {
+ for (i = 0; i < 256; i++)
+ {
+ int pi;
+
+ pi = (i * (256 - 128)) / 255;
+ if ((_dither_88[x][y] < ((pi & 0x7f) >> 1))
+ && (pi < (256 - 128)))
+ rd8[(x << DM_BS1) | (y << DM_BS2) | i] =
+ (((pi + 128) >> 4) & 0x08);
+ else
+ rd8[(x << DM_BS1) | (y << DM_BS2) | i] =
+ ((pi >> 4) & 0x08);
+
+ pi = (i * (256 - 64)) / 255;
+ if ((_dither_88[x][y] < (pi & 0x3f))
+ && (pi < (256 - 64)))
+ gd8[(x << DM_BS1) | (y << DM_BS2) | i] =
+ (((pi + 64) >> 5) & 0x06);
+ else
+ gd8[(x << DM_BS1) | (y << DM_BS2) | i] =
+ ((pi >> 5) & 0x06);
+
+ pi = (i * (256 - 128)) / 255;
+ if ((_dither_88[x][y] < ((pi & 0x7f) >> 1))
+ && (pi < (256 - 128)))
+ bd8[(x << DM_BS1) | (y << DM_BS2) | i] =
+ (((pi + 128) >> 7) & 0x01);
+ else
+ bd8[(x << DM_BS1) | (y << DM_BS2) | i] =
+ ((pi >> 7) & 0x01);
+ }
+ }
+ }
+ break;
+ case 5:
+ for (y = 0; y < DM_Y; y++)
+ {
+ for (x = 0; x < DM_X; x++)
+ {
+ for (i = 0; i < 256; i++)
+ {
+ int pi;
+
+ pi = (i * (256 - 128)) / 255;
+ if ((_dither_88[x][y] < ((pi & 0x7f) >> 1))
+ && (pi < (256 - 128)))
+ rd8[(x << DM_BS1) | (y << DM_BS2) | i] =
+ (((pi + 128) >> 5) & 0x04);
+ else
+ rd8[(x << DM_BS1) | (y << DM_BS2) | i] =
+ ((pi >> 5) & 0x04);
+
+ pi = (i * (256 - 128)) / 255;
+ if ((_dither_88[x][y] < ((pi & 0x7f) >> 1))
+ && (pi < (256 - 128)))
+ gd8[(x << DM_BS1) | (y << DM_BS2) | i] =
+ (((pi + 128) >> 6) & 0x02);
+ else
+ gd8[(x << DM_BS1) | (y << DM_BS2) | i] =
+ ((pi >> 6) & 0x02);
+
+ pi = (i * (256 - 128)) / 255;
+ if ((_dither_88[x][y] < ((pi & 0x7f) >> 1))
+ && (pi < (256 - 128)))
+ bd8[(x << DM_BS1) | (y << DM_BS2) | i] =
+ (((pi + 128) >> 7) & 0x01);
+ else
+ bd8[(x << DM_BS1) | (y << DM_BS2) | i] =
+ ((pi >> 7) & 0x01);
+ }
+ }
+ }
+ break;
+ case 6:
+ for (y = 0; y < DM_Y; y++)
+ {
+ for (x = 0; x < DM_X; x++)
+ {
+ for (i = 0; i < 256; i++)
+ {
+ int pi;
+
+ pi = (i * (256 - 128)) / 255;
+ if ((_dither_88[x][y] < ((pi & 0x7f) >> 1))
+ && (pi < (256 - 128)))
+ rd8[(x << DM_BS1) | (y << DM_BS2) | i] =
+ (((pi + 128) >> 7) & 0x01);
+ else
+ rd8[(x << DM_BS1) | (y << DM_BS2) | i] =
+ ((pi >> 7) & 0x01);
+ }
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ break;
}
}
-
+
static void
-__imlib_RGBA_to_RGB565_fast(DATA32 *src , int src_jump,
- DATA8 *dst, int dow,
- int width, int height, int dx, int dy)
+__imlib_RGBA_to_RGB565_fast(DATA32 * src, int src_jump,
+ DATA8 * dst, int dow,
+ int width, int height, int dx, int dy)
{
- int x, y, w, h;
- DATA16 *dest = (DATA16 *)dst;
- int dest_jump = (dow / sizeof(DATA16)) - width;
-
- w = width;
- h = height;
-
- if (IS_ALIGNED_32((int)dest))
- {
- if (IS_MULTIPLE_2(width))
- {
- for (y = 0; y < h; y++)
- {
- for (x = 0; x < w; x+=2)
- WRITE2_RGBA_RGB565(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- else
- {
- w--;
- for (y = 0; y < h; y++)
- {
- for (x = 0; x < w; x+=2)
- WRITE2_RGBA_RGB565(src, dest);
- WRITE1_RGBA_RGB565(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- }
- else
- {
- if (IS_MULTIPLE_2(width))
- {
- w-=2;
- for (y = 0; y < h; y++)
- {
- WRITE1_RGBA_RGB565(src, dest);
- for (x = 0; x < w; x+=2)
- WRITE2_RGBA_RGB565(src, dest);
- WRITE1_RGBA_RGB565(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- else
- {
- w--;
- for (y = 0; y < h; y++)
- {
- WRITE1_RGBA_RGB565(src, dest);
- for (x = 0; x < w; x+=2)
- WRITE2_RGBA_RGB565(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- }
- return;
- dx = 0;
- dy = 0;
+ int x, y, w, h;
+ DATA16 *dest = (DATA16 *) dst;
+ int dest_jump = (dow / sizeof(DATA16)) - width;
+
+ w = width;
+ h = height;
+
+ if (IS_ALIGNED_32((int)dest))
+ {
+ if (IS_MULTIPLE_2(width))
+ {
+ for (y = 0; y < h; y++)
+ {
+ for (x = 0; x < w; x += 2)
+ WRITE2_RGBA_RGB565(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ else
+ {
+ w--;
+ for (y = 0; y < h; y++)
+ {
+ for (x = 0; x < w; x += 2)
+ WRITE2_RGBA_RGB565(src, dest);
+ WRITE1_RGBA_RGB565(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ }
+ else
+ {
+ if (IS_MULTIPLE_2(width))
+ {
+ w -= 2;
+ for (y = 0; y < h; y++)
+ {
+ WRITE1_RGBA_RGB565(src, dest);
+ for (x = 0; x < w; x += 2)
+ WRITE2_RGBA_RGB565(src, dest);
+ WRITE1_RGBA_RGB565(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ else
+ {
+ w--;
+ for (y = 0; y < h; y++)
+ {
+ WRITE1_RGBA_RGB565(src, dest);
+ for (x = 0; x < w; x += 2)
+ WRITE2_RGBA_RGB565(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ }
+ return;
+ dx = 0;
+ dy = 0;
}
static void
-__imlib_RGBA_to_RGB565_dither(DATA32 *src , int src_jump,
- DATA8 *dst, int dow,
- int width, int height, int dx, int dy)
+__imlib_RGBA_to_RGB565_dither(DATA32 * src, int src_jump,
+ DATA8 * dst, int dow,
+ int width, int height, int dx, int dy)
{
- int x, y, w, h;
- DATA16 *dest = (DATA16 *)dst;
- int dest_jump = (dow / sizeof(DATA16)) - width;
-
- w = width + dx;
- h = height + dy;
-
- if (IS_ALIGNED_32((int)dest))
- {
- if (IS_MULTIPLE_2(width))
- {
- for (y = dy; y < h; y++)
- {
- for (x = dx; x < w; x+=2)
- WRITE2_RGBA_RGB565_DITHER(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- else
- {
- w--;
- for (y = dy; y < h; y++)
- {
- for (x = dx; x < w; x+=2)
- WRITE2_RGBA_RGB565_DITHER(src, dest);
- WRITE1_RGBA_RGB565_DITHER(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- }
- else
- {
- if (IS_MULTIPLE_2(width))
- {
- w-=2;
- for (y = dy; y < h; y++)
- {
- x = dx - 1;
- WRITE1_RGBA_RGB565_DITHER(src, dest);
- for (x = dx; x < w; x+=2)
- WRITE2_RGBA_RGB565_DITHER(src, dest);
- WRITE1_RGBA_RGB565_DITHER(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- else
- {
- w--;
- for (y = 0; y < h; y++)
- {
- x = dx - 1;
- WRITE1_RGBA_RGB565_DITHER(src, dest);
- for (x = dx; x < w; x+=2)
- WRITE2_RGBA_RGB565_DITHER(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- }
- return;
- dx = 0;
- dy = 0;
+ int x, y, w, h;
+ DATA16 *dest = (DATA16 *) dst;
+ int dest_jump = (dow / sizeof(DATA16)) - width;
+
+ w = width + dx;
+ h = height + dy;
+
+ if (IS_ALIGNED_32((int)dest))
+ {
+ if (IS_MULTIPLE_2(width))
+ {
+ for (y = dy; y < h; y++)
+ {
+ for (x = dx; x < w; x += 2)
+ WRITE2_RGBA_RGB565_DITHER(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ else
+ {
+ w--;
+ for (y = dy; y < h; y++)
+ {
+ for (x = dx; x < w; x += 2)
+ WRITE2_RGBA_RGB565_DITHER(src, dest);
+ WRITE1_RGBA_RGB565_DITHER(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ }
+ else
+ {
+ if (IS_MULTIPLE_2(width))
+ {
+ w -= 2;
+ for (y = dy; y < h; y++)
+ {
+ x = dx - 1;
+ WRITE1_RGBA_RGB565_DITHER(src, dest);
+ for (x = dx; x < w; x += 2)
+ WRITE2_RGBA_RGB565_DITHER(src, dest);
+ WRITE1_RGBA_RGB565_DITHER(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ else
+ {
+ w--;
+ for (y = 0; y < h; y++)
+ {
+ x = dx - 1;
+ WRITE1_RGBA_RGB565_DITHER(src, dest);
+ for (x = dx; x < w; x += 2)
+ WRITE2_RGBA_RGB565_DITHER(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ }
+ return;
+ dx = 0;
+ dy = 0;
}
static void
-__imlib_RGBA_to_BGR565_fast(DATA32 *src , int src_jump,
- DATA8 *dst, int dow,
- int width, int height, int dx, int dy)
+__imlib_RGBA_to_BGR565_fast(DATA32 * src, int src_jump,
+ DATA8 * dst, int dow,
+ int width, int height, int dx, int dy)
{
- int x, y, w, h;
- DATA16 *dest = (DATA16 *)dst;
- int dest_jump = (dow / sizeof(DATA16)) - width;
-
- w = width;
- h = height;
-
- if (IS_ALIGNED_32((int)dest))
- {
- if (IS_MULTIPLE_2(width))
- {
- for (y = 0; y < h; y++)
- {
- for (x = 0; x < w; x+=2)
- WRITE2_RGBA_BGR565(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- else
- {
- w--;
- for (y = 0; y < h; y++)
- {
- for (x = 0; x < w; x+=2)
- WRITE2_RGBA_BGR565(src, dest);
- WRITE1_RGBA_BGR565(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- }
- else
- {
- if (IS_MULTIPLE_2(width))
- {
- w-=2;
- for (y = 0; y < h; y++)
- {
- WRITE1_RGBA_BGR565(src, dest);
- for (x = 0; x < w; x+=2)
- WRITE2_RGBA_BGR565(src, dest);
- WRITE1_RGBA_BGR565(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- else
- {
- w--;
- for (y = 0; y < h; y++)
- {
- WRITE1_RGBA_BGR565(src, dest);
- for (x = 0; x < w; x+=2)
- WRITE2_RGBA_BGR565(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- }
- return;
- dx = 0;
- dy = 0;
+ int x, y, w, h;
+ DATA16 *dest = (DATA16 *) dst;
+ int dest_jump = (dow / sizeof(DATA16)) - width;
+
+ w = width;
+ h = height;
+
+ if (IS_ALIGNED_32((int)dest))
+ {
+ if (IS_MULTIPLE_2(width))
+ {
+ for (y = 0; y < h; y++)
+ {
+ for (x = 0; x < w; x += 2)
+ WRITE2_RGBA_BGR565(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ else
+ {
+ w--;
+ for (y = 0; y < h; y++)
+ {
+ for (x = 0; x < w; x += 2)
+ WRITE2_RGBA_BGR565(src, dest);
+ WRITE1_RGBA_BGR565(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ }
+ else
+ {
+ if (IS_MULTIPLE_2(width))
+ {
+ w -= 2;
+ for (y = 0; y < h; y++)
+ {
+ WRITE1_RGBA_BGR565(src, dest);
+ for (x = 0; x < w; x += 2)
+ WRITE2_RGBA_BGR565(src, dest);
+ WRITE1_RGBA_BGR565(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ else
+ {
+ w--;
+ for (y = 0; y < h; y++)
+ {
+ WRITE1_RGBA_BGR565(src, dest);
+ for (x = 0; x < w; x += 2)
+ WRITE2_RGBA_BGR565(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ }
+ return;
+ dx = 0;
+ dy = 0;
}
static void
-__imlib_RGBA_to_BGR565_dither(DATA32 *src , int src_jump,
- DATA8 *dst, int dow,
- int width, int height, int dx, int dy)
+__imlib_RGBA_to_BGR565_dither(DATA32 * src, int src_jump,
+ DATA8 * dst, int dow,
+ int width, int height, int dx, int dy)
{
- int x, y, w, h;
- DATA16 *dest = (DATA16 *)dst;
- int dest_jump = (dow / sizeof(DATA16)) - width;
-
- w = width + dx;
- h = height + dy;
-
- if (IS_ALIGNED_32((int)dest))
- {
- if (IS_MULTIPLE_2(width))
- {
- for (y = dy; y < h; y++)
- {
- for (x = dx; x < w; x+=2)
- WRITE2_RGBA_BGR565_DITHER(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- else
- {
- w--;
- for (y = dy; y < h; y++)
- {
- for (x = dx; x < w; x+=2)
- WRITE2_RGBA_BGR565_DITHER(src, dest);
- WRITE1_RGBA_BGR565_DITHER(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- }
- else
- {
- if (IS_MULTIPLE_2(width))
- {
- w-=2;
- for (y = dy; y < h; y++)
- {
- x = dx - 1;
- WRITE1_RGBA_BGR565_DITHER(src, dest);
- for (x = dx; x < w; x+=2)
- WRITE2_RGBA_BGR565_DITHER(src, dest);
- WRITE1_RGBA_BGR565_DITHER(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- else
- {
- w--;
- for (y = 0; y < h; y++)
- {
- x = dx - 1;
- WRITE1_RGBA_BGR565_DITHER(src, dest);
- for (x = dx; x < w; x+=2)
- WRITE2_RGBA_BGR565_DITHER(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- }
- return;
- dx = 0;
- dy = 0;
+ int x, y, w, h;
+ DATA16 *dest = (DATA16 *) dst;
+ int dest_jump = (dow / sizeof(DATA16)) - width;
+
+ w = width + dx;
+ h = height + dy;
+
+ if (IS_ALIGNED_32((int)dest))
+ {
+ if (IS_MULTIPLE_2(width))
+ {
+ for (y = dy; y < h; y++)
+ {
+ for (x = dx; x < w; x += 2)
+ WRITE2_RGBA_BGR565_DITHER(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ else
+ {
+ w--;
+ for (y = dy; y < h; y++)
+ {
+ for (x = dx; x < w; x += 2)
+ WRITE2_RGBA_BGR565_DITHER(src, dest);
+ WRITE1_RGBA_BGR565_DITHER(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ }
+ else
+ {
+ if (IS_MULTIPLE_2(width))
+ {
+ w -= 2;
+ for (y = dy; y < h; y++)
+ {
+ x = dx - 1;
+ WRITE1_RGBA_BGR565_DITHER(src, dest);
+ for (x = dx; x < w; x += 2)
+ WRITE2_RGBA_BGR565_DITHER(src, dest);
+ WRITE1_RGBA_BGR565_DITHER(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ else
+ {
+ w--;
+ for (y = 0; y < h; y++)
+ {
+ x = dx - 1;
+ WRITE1_RGBA_BGR565_DITHER(src, dest);
+ for (x = dx; x < w; x += 2)
+ WRITE2_RGBA_BGR565_DITHER(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ }
+ return;
+ dx = 0;
+ dy = 0;
}
static void
-__imlib_RGBA_to_RGB555_fast(DATA32 *src , int src_jump,
- DATA8 *dst, int dow,
- int width, int height, int dx, int dy)
+__imlib_RGBA_to_RGB555_fast(DATA32 * src, int src_jump,
+ DATA8 * dst, int dow,
+ int width, int height, int dx, int dy)
{
- int x, y, w, h;
- DATA16 *dest = (DATA16 *)dst;
- int dest_jump = (dow / sizeof(DATA16)) - width;
-
- w = width;
- h = height;
-
- if (IS_ALIGNED_32((int)dest))
- {
- if (IS_MULTIPLE_2(width))
- {
- for (y = 0; y < h; y++)
- {
- for (x = 0; x < w; x+=2)
- WRITE2_RGBA_RGB555(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- else
- {
- w--;
- for (y = 0; y < h; y++)
- {
- for (x = 0; x < w; x+=2)
- WRITE2_RGBA_RGB555(src, dest);
- WRITE1_RGBA_RGB555(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- }
- else
- {
- if (IS_MULTIPLE_2(width))
- {
- w-=2;
- for (y = 0; y < h; y++)
- {
- WRITE1_RGBA_RGB555(src, dest);
- for (x = 0; x < w; x+=2)
- WRITE2_RGBA_RGB555(src, dest);
- WRITE1_RGBA_RGB555(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- else
- {
- w--;
- for (y = 0; y < h; y++)
- {
- WRITE1_RGBA_RGB555(src, dest);
- for (x = 0; x < w; x+=2)
- WRITE2_RGBA_RGB555(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- }
- return;
- dx = 0;
- dy = 0;
+ int x, y, w, h;
+ DATA16 *dest = (DATA16 *) dst;
+ int dest_jump = (dow / sizeof(DATA16)) - width;
+
+ w = width;
+ h = height;
+
+ if (IS_ALIGNED_32((int)dest))
+ {
+ if (IS_MULTIPLE_2(width))
+ {
+ for (y = 0; y < h; y++)
+ {
+ for (x = 0; x < w; x += 2)
+ WRITE2_RGBA_RGB555(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ else
+ {
+ w--;
+ for (y = 0; y < h; y++)
+ {
+ for (x = 0; x < w; x += 2)
+ WRITE2_RGBA_RGB555(src, dest);
+ WRITE1_RGBA_RGB555(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ }
+ else
+ {
+ if (IS_MULTIPLE_2(width))
+ {
+ w -= 2;
+ for (y = 0; y < h; y++)
+ {
+ WRITE1_RGBA_RGB555(src, dest);
+ for (x = 0; x < w; x += 2)
+ WRITE2_RGBA_RGB555(src, dest);
+ WRITE1_RGBA_RGB555(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ else
+ {
+ w--;
+ for (y = 0; y < h; y++)
+ {
+ WRITE1_RGBA_RGB555(src, dest);
+ for (x = 0; x < w; x += 2)
+ WRITE2_RGBA_RGB555(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ }
+ return;
+ dx = 0;
+ dy = 0;
}
static void
-__imlib_RGBA_to_RGB555_dither(DATA32 *src , int src_jump,
- DATA8 *dst, int dow,
- int width, int height, int dx, int dy)
+__imlib_RGBA_to_RGB555_dither(DATA32 * src, int src_jump,
+ DATA8 * dst, int dow,
+ int width, int height, int dx, int dy)
{
- int x, y, w, h;
- DATA16 *dest = (DATA16 *)dst;
- int dest_jump = (dow / sizeof(DATA16)) - width;
-
- w = width + dx;
- h = height + dy;
-
- if (IS_ALIGNED_32((int)dest))
- {
- if (IS_MULTIPLE_2(width))
- {
- for (y = dy; y < h; y++)
- {
- for (x = dx; x < w; x+=2)
- WRITE2_RGBA_RGB555_DITHER(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- else
- {
- w--;
- for (y = dy; y < h; y++)
- {
- for (x = dx; x < w; x+=2)
- WRITE2_RGBA_RGB555_DITHER(src, dest);
- WRITE1_RGBA_RGB555_DITHER(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- }
- else
- {
- if (IS_MULTIPLE_2(width))
- {
- w-=2;
- for (y = dy; y < h; y++)
- {
- x = dx - 1;
- WRITE1_RGBA_RGB555_DITHER(src, dest);
- for (x = dx; x < w; x+=2)
- WRITE2_RGBA_RGB555_DITHER(src, dest);
- WRITE1_RGBA_RGB555_DITHER(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- else
- {
- w--;
- for (y = dy; y < h; y++)
- {
- x = dx - 1;
- WRITE1_RGBA_RGB555_DITHER(src, dest);
- for (x = dx; x < w; x+=2)
- WRITE2_RGBA_RGB555_DITHER(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- }
- return;
- dx = 0;
- dy = 0;
+ int x, y, w, h;
+ DATA16 *dest = (DATA16 *) dst;
+ int dest_jump = (dow / sizeof(DATA16)) - width;
+
+ w = width + dx;
+ h = height + dy;
+
+ if (IS_ALIGNED_32((int)dest))
+ {
+ if (IS_MULTIPLE_2(width))
+ {
+ for (y = dy; y < h; y++)
+ {
+ for (x = dx; x < w; x += 2)
+ WRITE2_RGBA_RGB555_DITHER(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ else
+ {
+ w--;
+ for (y = dy; y < h; y++)
+ {
+ for (x = dx; x < w; x += 2)
+ WRITE2_RGBA_RGB555_DITHER(src, dest);
+ WRITE1_RGBA_RGB555_DITHER(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ }
+ else
+ {
+ if (IS_MULTIPLE_2(width))
+ {
+ w -= 2;
+ for (y = dy; y < h; y++)
+ {
+ x = dx - 1;
+ WRITE1_RGBA_RGB555_DITHER(src, dest);
+ for (x = dx; x < w; x += 2)
+ WRITE2_RGBA_RGB555_DITHER(src, dest);
+ WRITE1_RGBA_RGB555_DITHER(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ else
+ {
+ w--;
+ for (y = dy; y < h; y++)
+ {
+ x = dx - 1;
+ WRITE1_RGBA_RGB555_DITHER(src, dest);
+ for (x = dx; x < w; x += 2)
+ WRITE2_RGBA_RGB555_DITHER(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ }
+ return;
+ dx = 0;
+ dy = 0;
}
static void
-__imlib_RGBA_to_BGR555_fast(DATA32 *src , int src_jump,
- DATA8 *dst, int dow,
- int width, int height, int dx, int dy)
+__imlib_RGBA_to_BGR555_fast(DATA32 * src, int src_jump,
+ DATA8 * dst, int dow,
+ int width, int height, int dx, int dy)
{
- int x, y, w, h;
- DATA16 *dest = (DATA16 *)dst;
- int dest_jump = (dow / sizeof(DATA16)) - width;
-
- w = width;
- h = height;
-
- if (IS_ALIGNED_32((int)dest))
- {
- if (IS_MULTIPLE_2(width))
- {
- for (y = 0; y < h; y++)
- {
- for (x = 0; x < w; x+=2)
- WRITE2_RGBA_BGR555(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- else
- {
- w--;
- for (y = 0; y < h; y++)
- {
- for (x = 0; x < w; x+=2)
- WRITE2_RGBA_BGR555(src, dest);
- WRITE1_RGBA_BGR555(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- }
- else
- {
- if (IS_MULTIPLE_2(width))
- {
- w-=2;
- for (y = 0; y < h; y++)
- {
- WRITE1_RGBA_BGR555(src, dest);
- for (x = 0; x < w; x+=2)
- WRITE2_RGBA_BGR555(src, dest);
- WRITE1_RGBA_BGR555(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- else
- {
- w--;
- for (y = 0; y < h; y++)
- {
- WRITE1_RGBA_BGR555(src, dest);
- for (x = 0; x < w; x+=2)
- WRITE2_RGBA_BGR555(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- }
- return;
- dx = 0;
- dy = 0;
+ int x, y, w, h;
+ DATA16 *dest = (DATA16 *) dst;
+ int dest_jump = (dow / sizeof(DATA16)) - width;
+
+ w = width;
+ h = height;
+
+ if (IS_ALIGNED_32((int)dest))
+ {
+ if (IS_MULTIPLE_2(width))
+ {
+ for (y = 0; y < h; y++)
+ {
+ for (x = 0; x < w; x += 2)
+ WRITE2_RGBA_BGR555(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ else
+ {
+ w--;
+ for (y = 0; y < h; y++)
+ {
+ for (x = 0; x < w; x += 2)
+ WRITE2_RGBA_BGR555(src, dest);
+ WRITE1_RGBA_BGR555(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ }
+ else
+ {
+ if (IS_MULTIPLE_2(width))
+ {
+ w -= 2;
+ for (y = 0; y < h; y++)
+ {
+ WRITE1_RGBA_BGR555(src, dest);
+ for (x = 0; x < w; x += 2)
+ WRITE2_RGBA_BGR555(src, dest);
+ WRITE1_RGBA_BGR555(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ else
+ {
+ w--;
+ for (y = 0; y < h; y++)
+ {
+ WRITE1_RGBA_BGR555(src, dest);
+ for (x = 0; x < w; x += 2)
+ WRITE2_RGBA_BGR555(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ }
+ return;
+ dx = 0;
+ dy = 0;
}
static void
-__imlib_RGBA_to_BGR555_dither(DATA32 *src , int src_jump,
- DATA8 *dst, int dow,
- int width, int height, int dx, int dy)
+__imlib_RGBA_to_BGR555_dither(DATA32 * src, int src_jump,
+ DATA8 * dst, int dow,
+ int width, int height, int dx, int dy)
{
- int x, y, w, h;
- DATA16 *dest = (DATA16 *)dst;
- int dest_jump = (dow / sizeof(DATA16)) - width;
-
- w = width + dx;
- h = height + dy;
-
- if (IS_ALIGNED_32((int)dest))
- {
- if (IS_MULTIPLE_2(width))
- {
- for (y = dy; y < h; y++)
- {
- for (x = dx; x < w; x+=2)
- WRITE2_RGBA_BGR555_DITHER(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- else
- {
- w--;
- for (y = dy; y < h; y++)
- {
- for (x = dx; x < w; x+=2)
- WRITE2_RGBA_BGR555_DITHER(src, dest);
- WRITE1_RGBA_BGR555_DITHER(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- }
- else
- {
- if (IS_MULTIPLE_2(width))
- {
- w-=2;
- for (y = dy; y < h; y++)
- {
- x = dx - 1;
- WRITE1_RGBA_BGR555_DITHER(src, dest);
- for (x = dx; x < w; x+=2)
- WRITE2_RGBA_BGR555_DITHER(src, dest);
- WRITE1_RGBA_BGR555_DITHER(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- else
- {
- w--;
- for (y = dy; y < h; y++)
- {
- x = dx - 1;
- WRITE1_RGBA_BGR555_DITHER(src, dest);
- for (x = dx; x < w; x+=2)
- WRITE2_RGBA_BGR555_DITHER(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- }
- return;
- dx = 0;
- dy = 0;
+ int x, y, w, h;
+ DATA16 *dest = (DATA16 *) dst;
+ int dest_jump = (dow / sizeof(DATA16)) - width;
+
+ w = width + dx;
+ h = height + dy;
+
+ if (IS_ALIGNED_32((int)dest))
+ {
+ if (IS_MULTIPLE_2(width))
+ {
+ for (y = dy; y < h; y++)
+ {
+ for (x = dx; x < w; x += 2)
+ WRITE2_RGBA_BGR555_DITHER(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ else
+ {
+ w--;
+ for (y = dy; y < h; y++)
+ {
+ for (x = dx; x < w; x += 2)
+ WRITE2_RGBA_BGR555_DITHER(src, dest);
+ WRITE1_RGBA_BGR555_DITHER(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ }
+ else
+ {
+ if (IS_MULTIPLE_2(width))
+ {
+ w -= 2;
+ for (y = dy; y < h; y++)
+ {
+ x = dx - 1;
+ WRITE1_RGBA_BGR555_DITHER(src, dest);
+ for (x = dx; x < w; x += 2)
+ WRITE2_RGBA_BGR555_DITHER(src, dest);
+ WRITE1_RGBA_BGR555_DITHER(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ else
+ {
+ w--;
+ for (y = dy; y < h; y++)
+ {
+ x = dx - 1;
+ WRITE1_RGBA_BGR555_DITHER(src, dest);
+ for (x = dx; x < w; x += 2)
+ WRITE2_RGBA_BGR555_DITHER(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ }
+ return;
+ dx = 0;
+ dy = 0;
}
static void
-__imlib_RGBA_to_RGB332_fast(DATA32 *src , int src_jump,
- DATA8 *dest, int dow,
- int width, int height, int dx, int dy)
+__imlib_RGBA_to_RGB332_fast(DATA32 * src, int src_jump,
+ DATA8 * dest, int dow,
+ int width, int height, int dx, int dy)
{
- int x, y, w, h;
- int dest_jump = dow - width;
-
- w = width;
- h = height;
-
- if (IS_ALIGNED_32((int)dest))
- {
- if (IS_MULTIPLE_4(width))
- {
- for (y = 0; y < h; y++)
- {
- for (x = 0; x < w; x+=4)
- WRITE4_RGBA_RGB332(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- else if (IS_MULTIPLE_2(width))
- {
- w-=2;
- for (y = 0; y < h; y++)
- {
- for (x = 0; x < w; x+=4)
- WRITE4_RGBA_RGB332(src, dest);
- WRITE2_RGBA_RGB332(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- else
- {
- w-=3;
- for (y = 0; y < h; y++)
- {
- for (x = 0; x < w; x+=4)
- WRITE4_RGBA_RGB332(src, dest);
- for (; x < width; x++)
- {
- WRITE1_RGBA_RGB332(src, dest);
- }
- src += src_jump;
- dest += dest_jump;
- }
- }
- }
- else
- {
- for (y = 0; y < h; y++)
- {
- for (x = 0; ((x < w) && (!(IS_ALIGNED_32((int)dest)))); x++)
- {
- WRITE1_RGBA_RGB332(src, dest);
- }
- if (x < w)
- {
- if (IS_MULTIPLE_4((width - x)))
- {
- for (; x < w; x+=4)
- WRITE4_RGBA_RGB332(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- else if (IS_MULTIPLE_2((width - x)))
- {
- w = width - 2 - x;
- for (; x < w; x+=4)
- WRITE4_RGBA_RGB332(src, dest);
- WRITE2_RGBA_RGB332(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- else
- {
- w = width - 3 - x;
- for (; x < w; x+=4)
- WRITE4_RGBA_RGB332(src, dest);
- for (; x < width; x++)
- {
- WRITE1_RGBA_RGB332(src, dest);
- }
- src += src_jump;
- dest += dest_jump;
- }
- }
- }
- }
- return;
- dx = 0;
- dy = 0;
+ int x, y, w, h;
+ int dest_jump = dow - width;
+
+ w = width;
+ h = height;
+
+ if (IS_ALIGNED_32((int)dest))
+ {
+ if (IS_MULTIPLE_4(width))
+ {
+ for (y = 0; y < h; y++)
+ {
+ for (x = 0; x < w; x += 4)
+ WRITE4_RGBA_RGB332(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ else if (IS_MULTIPLE_2(width))
+ {
+ w -= 2;
+ for (y = 0; y < h; y++)
+ {
+ for (x = 0; x < w; x += 4)
+ WRITE4_RGBA_RGB332(src, dest);
+ WRITE2_RGBA_RGB332(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ else
+ {
+ w -= 3;
+ for (y = 0; y < h; y++)
+ {
+ for (x = 0; x < w; x += 4)
+ WRITE4_RGBA_RGB332(src, dest);
+ for (; x < width; x++)
+ {
+ WRITE1_RGBA_RGB332(src, dest);
+ }
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ }
+ else
+ {
+ for (y = 0; y < h; y++)
+ {
+ for (x = 0; ((x < w) && (!(IS_ALIGNED_32((int)dest)))); x++)
+ {
+ WRITE1_RGBA_RGB332(src, dest);
+ }
+ if (x < w)
+ {
+ if (IS_MULTIPLE_4((width - x)))
+ {
+ for (; x < w; x += 4)
+ WRITE4_RGBA_RGB332(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ else if (IS_MULTIPLE_2((width - x)))
+ {
+ w = width - 2 - x;
+ for (; x < w; x += 4)
+ WRITE4_RGBA_RGB332(src, dest);
+ WRITE2_RGBA_RGB332(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ else
+ {
+ w = width - 3 - x;
+ for (; x < w; x += 4)
+ WRITE4_RGBA_RGB332(src, dest);
+ for (; x < width; x++)
+ {
+ WRITE1_RGBA_RGB332(src, dest);
+ }
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ }
+ }
+ return;
+ dx = 0;
+ dy = 0;
}
static void
-__imlib_RGBA_to_RGB332_dither(DATA32 *src , int src_jump,
- DATA8 *dest, int dow,
- int width, int height, int dx, int dy)
+__imlib_RGBA_to_RGB332_dither(DATA32 * src, int src_jump,
+ DATA8 * dest, int dow,
+ int width, int height, int dx, int dy)
{
- int x, y, w, h;
- int dest_jump = dow - width;
-
- w = width + dx;
- h = height + dy;
-
- if (IS_ALIGNED_32((int)dest))
- {
- if (IS_MULTIPLE_4(width))
- {
- for (y = dy; y < h; y++)
- {
- for (x = dx; x < w; x+=4)
- WRITE4_RGBA_RGB332_DITHER(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- else if (IS_MULTIPLE_2(width))
- {
- w-=2;
- for (y = dy; y < h; y++)
- {
- for (x = dx; x < w; x+=4)
- WRITE4_RGBA_RGB332_DITHER(src, dest);
- WRITE2_RGBA_RGB332_DITHER(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- else
- {
- w-=3;
- for (y = dy; y < h; y++)
- {
- for (x = dx; x < w; x+=4)
- WRITE4_RGBA_RGB332_DITHER(src, dest);
- for (; x < (width + dx); x++)
- {
- WRITE1_RGBA_RGB332_DITHER(src, dest);
- }
- src += src_jump;
- dest += dest_jump;
- }
- }
- }
- else
- {
- for (y = dy; y < h; y++)
- {
- w = width + dx;
- for (x = dx; ((x < w) && (!(IS_ALIGNED_32((int)dest)))); x++)
- {
- WRITE1_RGBA_RGB332_DITHER(src, dest);
- }
- if (x < w)
- {
- w = (width + dx) - (3 + x);
- for (; x < w; x+=4)
- WRITE4_RGBA_RGB332_DITHER(src, dest);
- for (; x < (width + dx); x++)
- {
- WRITE1_RGBA_RGB332_DITHER(src, dest);
- }
- src += src_jump;
- dest += dest_jump;
- }
- }
- }
- return;
- dx = 0;
- dy = 0;
+ int x, y, w, h;
+ int dest_jump = dow - width;
+
+ w = width + dx;
+ h = height + dy;
+
+ if (IS_ALIGNED_32((int)dest))
+ {
+ if (IS_MULTIPLE_4(width))
+ {
+ for (y = dy; y < h; y++)
+ {
+ for (x = dx; x < w; x += 4)
+ WRITE4_RGBA_RGB332_DITHER(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ else if (IS_MULTIPLE_2(width))
+ {
+ w -= 2;
+ for (y = dy; y < h; y++)
+ {
+ for (x = dx; x < w; x += 4)
+ WRITE4_RGBA_RGB332_DITHER(src, dest);
+ WRITE2_RGBA_RGB332_DITHER(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ else
+ {
+ w -= 3;
+ for (y = dy; y < h; y++)
+ {
+ for (x = dx; x < w; x += 4)
+ WRITE4_RGBA_RGB332_DITHER(src, dest);
+ for (; x < (width + dx); x++)
+ {
+ WRITE1_RGBA_RGB332_DITHER(src, dest);
+ }
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ }
+ else
+ {
+ for (y = dy; y < h; y++)
+ {
+ w = width + dx;
+ for (x = dx; ((x < w) && (!(IS_ALIGNED_32((int)dest)))); x++)
+ {
+ WRITE1_RGBA_RGB332_DITHER(src, dest);
+ }
+ if (x < w)
+ {
+ w = (width + dx) - (3 + x);
+ for (; x < w; x += 4)
+ WRITE4_RGBA_RGB332_DITHER(src, dest);
+ for (; x < (width + dx); x++)
+ {
+ WRITE1_RGBA_RGB332_DITHER(src, dest);
+ }
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ }
+ return;
+ dx = 0;
+ dy = 0;
}
static void
-__imlib_RGBA_to_RGB666_fast(DATA32 *src , int src_jump,
- DATA8 *dest, int dow,
- int width, int height, int dx, int dy)
+__imlib_RGBA_to_RGB666_fast(DATA32 * src, int src_jump,
+ DATA8 * dest, int dow,
+ int width, int height, int dx, int dy)
{
- int x, y, w, h;
- int dest_jump = dow - width;
-
- w = width;
- h = height;
-
- if (IS_ALIGNED_32((int)dest))
- {
- if (IS_MULTIPLE_4(width))
- {
- for (y = 0; y < h; y++)
- {
- for (x = 0; x < w; x+=4)
- WRITE4_RGBA_RGB666(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- else if (IS_MULTIPLE_2(width))
- {
- w-=2;
- for (y = 0; y < h; y++)
- {
- for (x = 0; x < w; x+=4)
- WRITE4_RGBA_RGB666(src, dest);
- WRITE2_RGBA_RGB666(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- else
- {
- w-=3;
- for (y = 0; y < h; y++)
- {
- for (x = 0; x < w; x+=4)
- WRITE4_RGBA_RGB666(src, dest);
- for (; x < width; x++)
- {
- WRITE1_RGBA_RGB666(src, dest);
- }
- src += src_jump;
- dest += dest_jump;
- }
- }
- }
- else
- {
- for (y = 0; y < h; y++)
- {
- for (x = 0; ((x < w) && (!(IS_ALIGNED_32((int)dest)))); x++)
- {
- WRITE1_RGBA_RGB666(src, dest);
- }
- if (x < w)
- {
- if (IS_MULTIPLE_4((width - x)))
- {
- for (; x < w; x+=4)
- WRITE4_RGBA_RGB666(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- else if (IS_MULTIPLE_2((width - x)))
- {
- w = width - 2 - x;
- for (; x < w; x+=4)
- WRITE4_RGBA_RGB666(src, dest);
- WRITE2_RGBA_RGB666(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- else
- {
- w = width - 3 - x;
- for (; x < w; x+=4)
- WRITE4_RGBA_RGB666(src, dest);
- for (; x < width; x++)
- {
- WRITE1_RGBA_RGB666(src, dest);
- }
- src += src_jump;
- dest += dest_jump;
- }
- }
- }
- }
- return;
- dx = 0;
- dy = 0;
+ int x, y, w, h;
+ int dest_jump = dow - width;
+
+ w = width;
+ h = height;
+
+ if (IS_ALIGNED_32((int)dest))
+ {
+ if (IS_MULTIPLE_4(width))
+ {
+ for (y = 0; y < h; y++)
+ {
+ for (x = 0; x < w; x += 4)
+ WRITE4_RGBA_RGB666(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ else if (IS_MULTIPLE_2(width))
+ {
+ w -= 2;
+ for (y = 0; y < h; y++)
+ {
+ for (x = 0; x < w; x += 4)
+ WRITE4_RGBA_RGB666(src, dest);
+ WRITE2_RGBA_RGB666(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ else
+ {
+ w -= 3;
+ for (y = 0; y < h; y++)
+ {
+ for (x = 0; x < w; x += 4)
+ WRITE4_RGBA_RGB666(src, dest);
+ for (; x < width; x++)
+ {
+ WRITE1_RGBA_RGB666(src, dest);
+ }
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ }
+ else
+ {
+ for (y = 0; y < h; y++)
+ {
+ for (x = 0; ((x < w) && (!(IS_ALIGNED_32((int)dest)))); x++)
+ {
+ WRITE1_RGBA_RGB666(src, dest);
+ }
+ if (x < w)
+ {
+ if (IS_MULTIPLE_4((width - x)))
+ {
+ for (; x < w; x += 4)
+ WRITE4_RGBA_RGB666(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ else if (IS_MULTIPLE_2((width - x)))
+ {
+ w = width - 2 - x;
+ for (; x < w; x += 4)
+ WRITE4_RGBA_RGB666(src, dest);
+ WRITE2_RGBA_RGB666(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ else
+ {
+ w = width - 3 - x;
+ for (; x < w; x += 4)
+ WRITE4_RGBA_RGB666(src, dest);
+ for (; x < width; x++)
+ {
+ WRITE1_RGBA_RGB666(src, dest);
+ }
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ }
+ }
+ return;
+ dx = 0;
+ dy = 0;
}
static void
-__imlib_RGBA_to_RGB666_dither(DATA32 *src , int src_jump,
- DATA8 *dest, int dow,
- int width, int height, int dx, int dy)
+__imlib_RGBA_to_RGB666_dither(DATA32 * src, int src_jump,
+ DATA8 * dest, int dow,
+ int width, int height, int dx, int dy)
{
- int x, y, w, h;
- int dest_jump = dow - width;
-
+ int x, y, w, h;
+ int dest_jump = dow - width;
+
w = width + dx;
h = height + dy;
-
+
if (IS_ALIGNED_32((int)dest))
{
- if (IS_MULTIPLE_4(width))
- {
- for (y = dy; y < h; y++)
- {
- for (x = dx; x < w; x+=4)
- WRITE4_RGBA_RGB666_DITHER(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- else if (IS_MULTIPLE_2(width))
- {
- w-=2;
- for (y = dy; y < h; y++)
- {
- for (x = dx; x < w; x+=4)
- WRITE4_RGBA_RGB666_DITHER(src, dest);
- WRITE2_RGBA_RGB666_DITHER(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- else
- {
- w-=3;
- for (y = dy; y < h; y++)
- {
- for (x = dx; x < w; x+=4)
- WRITE4_RGBA_RGB666_DITHER(src, dest);
- for (; x < (width + dx); x++)
- {
- WRITE1_RGBA_RGB666_DITHER(src, dest);
- }
- src += src_jump;
- dest += dest_jump;
- }
- }
+ if (IS_MULTIPLE_4(width))
+ {
+ for (y = dy; y < h; y++)
+ {
+ for (x = dx; x < w; x += 4)
+ WRITE4_RGBA_RGB666_DITHER(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ else if (IS_MULTIPLE_2(width))
+ {
+ w -= 2;
+ for (y = dy; y < h; y++)
+ {
+ for (x = dx; x < w; x += 4)
+ WRITE4_RGBA_RGB666_DITHER(src, dest);
+ WRITE2_RGBA_RGB666_DITHER(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ else
+ {
+ w -= 3;
+ for (y = dy; y < h; y++)
+ {
+ for (x = dx; x < w; x += 4)
+ WRITE4_RGBA_RGB666_DITHER(src, dest);
+ for (; x < (width + dx); x++)
+ {
+ WRITE1_RGBA_RGB666_DITHER(src, dest);
+ }
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
}
- else
+ else
{
- for (y = dy; y < h; y++)
- {
- w = width + dx;
- for (x = dx; ((x < w) && (!(IS_ALIGNED_32((int)dest)))); x++)
- {
- WRITE1_RGBA_RGB666_DITHER(src, dest);
- }
- if (x < w)
- {
- w = (width + dx) - (3 + x);
- for (; x < w; x+=4)
- WRITE4_RGBA_RGB666_DITHER(src, dest);
- for (; x < (width + dx); x++)
- {
- WRITE1_RGBA_RGB666_DITHER(src, dest);
- }
- src += src_jump;
- dest += dest_jump;
- }
- }
+ for (y = dy; y < h; y++)
+ {
+ w = width + dx;
+ for (x = dx; ((x < w) && (!(IS_ALIGNED_32((int)dest)))); x++)
+ {
+ WRITE1_RGBA_RGB666_DITHER(src, dest);
+ }
+ if (x < w)
+ {
+ w = (width + dx) - (3 + x);
+ for (; x < w; x += 4)
+ WRITE4_RGBA_RGB666_DITHER(src, dest);
+ for (; x < (width + dx); x++)
+ {
+ WRITE1_RGBA_RGB666_DITHER(src, dest);
+ }
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
}
return;
dx = 0;
@@ -2918,954 +3765,954 @@ __imlib_RGBA_to_RGB666_dither(DATA32 *src , int src_jump,
}
static void
-__imlib_RGBA_to_RGB232_fast(DATA32 *src , int src_jump,
- DATA8 *dest, int dow,
- int width, int height, int dx, int dy)
+__imlib_RGBA_to_RGB232_fast(DATA32 * src, int src_jump,
+ DATA8 * dest, int dow,
+ int width, int height, int dx, int dy)
{
- int x, y, w, h;
- int dest_jump = dow - width;
-
- w = width;
- h = height;
-
- if (IS_ALIGNED_32((int)dest))
- {
- if (IS_MULTIPLE_4(width))
- {
- for (y = 0; y < h; y++)
- {
- for (x = 0; x < w; x+=4)
- WRITE4_RGBA_RGB232(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- else if (IS_MULTIPLE_2(width))
- {
- w-=2;
- for (y = 0; y < h; y++)
- {
- for (x = 0; x < w; x+=4)
- WRITE4_RGBA_RGB232(src, dest);
- WRITE2_RGBA_RGB232(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- else
- {
- w-=3;
- for (y = 0; y < h; y++)
- {
- for (x = 0; x < w; x+=4)
- WRITE4_RGBA_RGB232(src, dest);
- for (; x < width; x++)
- {
- WRITE1_RGBA_RGB232(src, dest);
- }
- src += src_jump;
- dest += dest_jump;
- }
- }
- }
- else
- {
- for (y = 0; y < h; y++)
- {
- for (x = 0; ((x < w) && (!(IS_ALIGNED_32((int)dest)))); x++)
- {
- WRITE1_RGBA_RGB232(src, dest);
- }
- if (x < w)
- {
- if (IS_MULTIPLE_4((width - x)))
- {
- for (; x < w; x+=4)
- WRITE4_RGBA_RGB232(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- else if (IS_MULTIPLE_2((width - x)))
- {
- w = width - 2 - x;
- for (; x < w; x+=4)
- WRITE4_RGBA_RGB232(src, dest);
- WRITE2_RGBA_RGB232(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- else
- {
- w = width - 3 - x;
- for (; x < w; x+=4)
- WRITE4_RGBA_RGB232(src, dest);
- for (; x < width; x++)
- {
- WRITE1_RGBA_RGB232(src, dest);
- }
- src += src_jump;
- dest += dest_jump;
- }
- }
- }
- }
- return;
- dx = 0;
- dy = 0;
+ int x, y, w, h;
+ int dest_jump = dow - width;
+
+ w = width;
+ h = height;
+
+ if (IS_ALIGNED_32((int)dest))
+ {
+ if (IS_MULTIPLE_4(width))
+ {
+ for (y = 0; y < h; y++)
+ {
+ for (x = 0; x < w; x += 4)
+ WRITE4_RGBA_RGB232(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ else if (IS_MULTIPLE_2(width))
+ {
+ w -= 2;
+ for (y = 0; y < h; y++)
+ {
+ for (x = 0; x < w; x += 4)
+ WRITE4_RGBA_RGB232(src, dest);
+ WRITE2_RGBA_RGB232(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ else
+ {
+ w -= 3;
+ for (y = 0; y < h; y++)
+ {
+ for (x = 0; x < w; x += 4)
+ WRITE4_RGBA_RGB232(src, dest);
+ for (; x < width; x++)
+ {
+ WRITE1_RGBA_RGB232(src, dest);
+ }
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ }
+ else
+ {
+ for (y = 0; y < h; y++)
+ {
+ for (x = 0; ((x < w) && (!(IS_ALIGNED_32((int)dest)))); x++)
+ {
+ WRITE1_RGBA_RGB232(src, dest);
+ }
+ if (x < w)
+ {
+ if (IS_MULTIPLE_4((width - x)))
+ {
+ for (; x < w; x += 4)
+ WRITE4_RGBA_RGB232(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ else if (IS_MULTIPLE_2((width - x)))
+ {
+ w = width - 2 - x;
+ for (; x < w; x += 4)
+ WRITE4_RGBA_RGB232(src, dest);
+ WRITE2_RGBA_RGB232(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ else
+ {
+ w = width - 3 - x;
+ for (; x < w; x += 4)
+ WRITE4_RGBA_RGB232(src, dest);
+ for (; x < width; x++)
+ {
+ WRITE1_RGBA_RGB232(src, dest);
+ }
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ }
+ }
+ return;
+ dx = 0;
+ dy = 0;
}
static void
-__imlib_RGBA_to_RGB232_dither(DATA32 *src , int src_jump,
- DATA8 *dest, int dow,
- int width, int height, int dx, int dy)
+__imlib_RGBA_to_RGB232_dither(DATA32 * src, int src_jump,
+ DATA8 * dest, int dow,
+ int width, int height, int dx, int dy)
{
- int x, y, w, h;
- int dest_jump = dow - width;
-
- w = width + dx;
- h = height + dy;
-
- if (IS_ALIGNED_32((int)dest))
- {
- if (IS_MULTIPLE_4(width))
- {
- for (y = dy; y < h; y++)
- {
- for (x = dx; x < w; x+=4)
- WRITE4_RGBA_RGB232_DITHER(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- else if (IS_MULTIPLE_2(width))
- {
- w-=2;
- for (y = dy; y < h; y++)
- {
- for (x = dx; x < w; x+=4)
- WRITE4_RGBA_RGB232_DITHER(src, dest);
- WRITE2_RGBA_RGB232_DITHER(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- else
- {
- w-=3;
- for (y = dy; y < h; y++)
- {
- for (x = dx; x < w; x+=4)
- WRITE4_RGBA_RGB232_DITHER(src, dest);
- for (; x < (width + dx); x++)
- {
- WRITE1_RGBA_RGB232_DITHER(src, dest);
- }
- src += src_jump;
- dest += dest_jump;
- }
- }
- }
- else
- {
- for (y = dy; y < h; y++)
- {
- w = width + dx;
- for (x = dx; ((x < w) && (!(IS_ALIGNED_32((int)dest)))); x++)
- {
- WRITE1_RGBA_RGB232_DITHER(src, dest);
- }
- if (x < w)
- {
- w = (width + dx) - (3 + x);
- for (; x < w; x+=4)
- WRITE4_RGBA_RGB232_DITHER(src, dest);
- for (; x < (width + dx); x++)
- {
- WRITE1_RGBA_RGB232_DITHER(src, dest);
- }
- src += src_jump;
- dest += dest_jump;
- }
- }
- }
- return;
- dx = 0;
- dy = 0;
+ int x, y, w, h;
+ int dest_jump = dow - width;
+
+ w = width + dx;
+ h = height + dy;
+
+ if (IS_ALIGNED_32((int)dest))
+ {
+ if (IS_MULTIPLE_4(width))
+ {
+ for (y = dy; y < h; y++)
+ {
+ for (x = dx; x < w; x += 4)
+ WRITE4_RGBA_RGB232_DITHER(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ else if (IS_MULTIPLE_2(width))
+ {
+ w -= 2;
+ for (y = dy; y < h; y++)
+ {
+ for (x = dx; x < w; x += 4)
+ WRITE4_RGBA_RGB232_DITHER(src, dest);
+ WRITE2_RGBA_RGB232_DITHER(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ else
+ {
+ w -= 3;
+ for (y = dy; y < h; y++)
+ {
+ for (x = dx; x < w; x += 4)
+ WRITE4_RGBA_RGB232_DITHER(src, dest);
+ for (; x < (width + dx); x++)
+ {
+ WRITE1_RGBA_RGB232_DITHER(src, dest);
+ }
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ }
+ else
+ {
+ for (y = dy; y < h; y++)
+ {
+ w = width + dx;
+ for (x = dx; ((x < w) && (!(IS_ALIGNED_32((int)dest)))); x++)
+ {
+ WRITE1_RGBA_RGB232_DITHER(src, dest);
+ }
+ if (x < w)
+ {
+ w = (width + dx) - (3 + x);
+ for (; x < w; x += 4)
+ WRITE4_RGBA_RGB232_DITHER(src, dest);
+ for (; x < (width + dx); x++)
+ {
+ WRITE1_RGBA_RGB232_DITHER(src, dest);
+ }
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ }
+ return;
+ dx = 0;
+ dy = 0;
}
static void
-__imlib_RGBA_to_RGB222_fast(DATA32 *src , int src_jump,
- DATA8 *dest, int dow,
- int width, int height, int dx, int dy)
+__imlib_RGBA_to_RGB222_fast(DATA32 * src, int src_jump,
+ DATA8 * dest, int dow,
+ int width, int height, int dx, int dy)
{
- int x, y, w, h;
- int dest_jump = dow - width;
-
- w = width;
- h = height;
-
- if (IS_ALIGNED_32((int)dest))
- {
- if (IS_MULTIPLE_4(width))
- {
- for (y = 0; y < h; y++)
- {
- for (x = 0; x < w; x+=4)
- WRITE4_RGBA_RGB222(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- else if (IS_MULTIPLE_2(width))
- {
- w-=2;
- for (y = 0; y < h; y++)
- {
- for (x = 0; x < w; x+=4)
- WRITE4_RGBA_RGB222(src, dest);
- WRITE2_RGBA_RGB222(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- else
- {
- w-=3;
- for (y = 0; y < h; y++)
- {
- for (x = 0; x < w; x+=4)
- WRITE4_RGBA_RGB222(src, dest);
- for (; x < width; x++)
- {
- WRITE1_RGBA_RGB222(src, dest);
- }
- src += src_jump;
- dest += dest_jump;
- }
- }
- }
- else
- {
- for (y = 0; y < h; y++)
- {
- for (x = 0; ((x < w) && (!(IS_ALIGNED_32((int)dest)))); x++)
- {
- WRITE1_RGBA_RGB222(src, dest);
- }
- if (x < w)
- {
- if (IS_MULTIPLE_4((width - x)))
- {
- for (; x < w; x+=4)
- WRITE4_RGBA_RGB222(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- else if (IS_MULTIPLE_2((width - x)))
- {
- w = width - 2 - x;
- for (; x < w; x+=4)
- WRITE4_RGBA_RGB222(src, dest);
- WRITE2_RGBA_RGB222(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- else
- {
- w = width - 3 - x;
- for (; x < w; x+=4)
- WRITE4_RGBA_RGB222(src, dest);
- for (; x < width; x++)
- {
- WRITE1_RGBA_RGB222(src, dest);
- }
- src += src_jump;
- dest += dest_jump;
- }
- }
- }
- }
- return;
- dx = 0;
- dy = 0;
+ int x, y, w, h;
+ int dest_jump = dow - width;
+
+ w = width;
+ h = height;
+
+ if (IS_ALIGNED_32((int)dest))
+ {
+ if (IS_MULTIPLE_4(width))
+ {
+ for (y = 0; y < h; y++)
+ {
+ for (x = 0; x < w; x += 4)
+ WRITE4_RGBA_RGB222(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ else if (IS_MULTIPLE_2(width))
+ {
+ w -= 2;
+ for (y = 0; y < h; y++)
+ {
+ for (x = 0; x < w; x += 4)
+ WRITE4_RGBA_RGB222(src, dest);
+ WRITE2_RGBA_RGB222(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ else
+ {
+ w -= 3;
+ for (y = 0; y < h; y++)
+ {
+ for (x = 0; x < w; x += 4)
+ WRITE4_RGBA_RGB222(src, dest);
+ for (; x < width; x++)
+ {
+ WRITE1_RGBA_RGB222(src, dest);
+ }
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ }
+ else
+ {
+ for (y = 0; y < h; y++)
+ {
+ for (x = 0; ((x < w) && (!(IS_ALIGNED_32((int)dest)))); x++)
+ {
+ WRITE1_RGBA_RGB222(src, dest);
+ }
+ if (x < w)
+ {
+ if (IS_MULTIPLE_4((width - x)))
+ {
+ for (; x < w; x += 4)
+ WRITE4_RGBA_RGB222(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ else if (IS_MULTIPLE_2((width - x)))
+ {
+ w = width - 2 - x;
+ for (; x < w; x += 4)
+ WRITE4_RGBA_RGB222(src, dest);
+ WRITE2_RGBA_RGB222(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ else
+ {
+ w = width - 3 - x;
+ for (; x < w; x += 4)
+ WRITE4_RGBA_RGB222(src, dest);
+ for (; x < width; x++)
+ {
+ WRITE1_RGBA_RGB222(src, dest);
+ }
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ }
+ }
+ return;
+ dx = 0;
+ dy = 0;
}
static void
-__imlib_RGBA_to_RGB222_dither(DATA32 *src , int src_jump,
- DATA8 *dest, int dow,
- int width, int height, int dx, int dy)
+__imlib_RGBA_to_RGB222_dither(DATA32 * src, int src_jump,
+ DATA8 * dest, int dow,
+ int width, int height, int dx, int dy)
{
- int x, y, w, h;
- int dest_jump = dow - width;
-
- w = width + dx;
- h = height + dy;
-
- if (IS_ALIGNED_32((int)dest))
- {
- if (IS_MULTIPLE_4(width))
- {
- for (y = dy; y < h; y++)
- {
- for (x = dx; x < w; x+=4)
- WRITE4_RGBA_RGB222_DITHER(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- else if (IS_MULTIPLE_2(width))
- {
- w-=2;
- for (y = dy; y < h; y++)
- {
- for (x = dx; x < w; x+=4)
- WRITE4_RGBA_RGB222_DITHER(src, dest);
- WRITE2_RGBA_RGB222_DITHER(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- else
- {
- w-=3;
- for (y = dy; y < h; y++)
- {
- for (x = dx; x < w; x+=4)
- WRITE4_RGBA_RGB222_DITHER(src, dest);
- for (; x < (width + dx); x++)
- {
- WRITE1_RGBA_RGB222_DITHER(src, dest);
- }
- src += src_jump;
- dest += dest_jump;
- }
- }
- }
- else
- {
- for (y = dy; y < h; y++)
- {
- w = width + dx;
- for (x = dx; ((x < w) && (!(IS_ALIGNED_32((int)dest)))); x++)
- {
- WRITE1_RGBA_RGB222_DITHER(src, dest);
- }
- if (x < w)
- {
- w = (width + dx) - (3 + x);
- for (; x < w; x+=4)
- WRITE4_RGBA_RGB222_DITHER(src, dest);
- for (; x < (width + dx); x++)
- {
- WRITE1_RGBA_RGB222_DITHER(src, dest);
- }
- src += src_jump;
- dest += dest_jump;
- }
- }
- }
- return;
- dx = 0;
- dy = 0;
+ int x, y, w, h;
+ int dest_jump = dow - width;
+
+ w = width + dx;
+ h = height + dy;
+
+ if (IS_ALIGNED_32((int)dest))
+ {
+ if (IS_MULTIPLE_4(width))
+ {
+ for (y = dy; y < h; y++)
+ {
+ for (x = dx; x < w; x += 4)
+ WRITE4_RGBA_RGB222_DITHER(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ else if (IS_MULTIPLE_2(width))
+ {
+ w -= 2;
+ for (y = dy; y < h; y++)
+ {
+ for (x = dx; x < w; x += 4)
+ WRITE4_RGBA_RGB222_DITHER(src, dest);
+ WRITE2_RGBA_RGB222_DITHER(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ else
+ {
+ w -= 3;
+ for (y = dy; y < h; y++)
+ {
+ for (x = dx; x < w; x += 4)
+ WRITE4_RGBA_RGB222_DITHER(src, dest);
+ for (; x < (width + dx); x++)
+ {
+ WRITE1_RGBA_RGB222_DITHER(src, dest);
+ }
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ }
+ else
+ {
+ for (y = dy; y < h; y++)
+ {
+ w = width + dx;
+ for (x = dx; ((x < w) && (!(IS_ALIGNED_32((int)dest)))); x++)
+ {
+ WRITE1_RGBA_RGB222_DITHER(src, dest);
+ }
+ if (x < w)
+ {
+ w = (width + dx) - (3 + x);
+ for (; x < w; x += 4)
+ WRITE4_RGBA_RGB222_DITHER(src, dest);
+ for (; x < (width + dx); x++)
+ {
+ WRITE1_RGBA_RGB222_DITHER(src, dest);
+ }
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ }
+ return;
+ dx = 0;
+ dy = 0;
}
static void
-__imlib_RGBA_to_RGB221_fast(DATA32 *src , int src_jump,
- DATA8 *dest, int dow,
- int width, int height, int dx, int dy)
+__imlib_RGBA_to_RGB221_fast(DATA32 * src, int src_jump,
+ DATA8 * dest, int dow,
+ int width, int height, int dx, int dy)
{
- int x, y, w, h;
- int dest_jump = dow - width;
-
- w = width;
- h = height;
-
- if (IS_ALIGNED_32((int)dest))
- {
- if (IS_MULTIPLE_4(width))
- {
- for (y = 0; y < h; y++)
- {
- for (x = 0; x < w; x+=4)
- WRITE4_RGBA_RGB221(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- else if (IS_MULTIPLE_2(width))
- {
- w-=2;
- for (y = 0; y < h; y++)
- {
- for (x = 0; x < w; x+=4)
- WRITE4_RGBA_RGB221(src, dest);
- WRITE2_RGBA_RGB221(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- else
- {
- w-=3;
- for (y = 0; y < h; y++)
- {
- for (x = 0; x < w; x+=4)
- WRITE4_RGBA_RGB221(src, dest);
- for (; x < width; x++)
- {
- WRITE1_RGBA_RGB221(src, dest);
- }
- src += src_jump;
- dest += dest_jump;
- }
- }
- }
- else
- {
- for (y = 0; y < h; y++)
- {
- for (x = 0; ((x < w) && (!(IS_ALIGNED_32((int)dest)))); x++)
- {
- WRITE1_RGBA_RGB221(src, dest);
- }
- if (x < w)
- {
- if (IS_MULTIPLE_4((width - x)))
- {
- for (; x < w; x+=4)
- WRITE4_RGBA_RGB221(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- else if (IS_MULTIPLE_2((width - x)))
- {
- w = width - 2 - x;
- for (; x < w; x+=4)
- WRITE4_RGBA_RGB221(src, dest);
- WRITE2_RGBA_RGB221(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- else
- {
- w = width - 3 - x;
- for (; x < w; x+=4)
- WRITE4_RGBA_RGB221(src, dest);
- for (; x < width; x++)
- {
- WRITE1_RGBA_RGB221(src, dest);
- }
- src += src_jump;
- dest += dest_jump;
- }
- }
- }
- }
- return;
- dx = 0;
- dy = 0;
+ int x, y, w, h;
+ int dest_jump = dow - width;
+
+ w = width;
+ h = height;
+
+ if (IS_ALIGNED_32((int)dest))
+ {
+ if (IS_MULTIPLE_4(width))
+ {
+ for (y = 0; y < h; y++)
+ {
+ for (x = 0; x < w; x += 4)
+ WRITE4_RGBA_RGB221(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ else if (IS_MULTIPLE_2(width))
+ {
+ w -= 2;
+ for (y = 0; y < h; y++)
+ {
+ for (x = 0; x < w; x += 4)
+ WRITE4_RGBA_RGB221(src, dest);
+ WRITE2_RGBA_RGB221(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ else
+ {
+ w -= 3;
+ for (y = 0; y < h; y++)
+ {
+ for (x = 0; x < w; x += 4)
+ WRITE4_RGBA_RGB221(src, dest);
+ for (; x < width; x++)
+ {
+ WRITE1_RGBA_RGB221(src, dest);
+ }
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ }
+ else
+ {
+ for (y = 0; y < h; y++)
+ {
+ for (x = 0; ((x < w) && (!(IS_ALIGNED_32((int)dest)))); x++)
+ {
+ WRITE1_RGBA_RGB221(src, dest);
+ }
+ if (x < w)
+ {
+ if (IS_MULTIPLE_4((width - x)))
+ {
+ for (; x < w; x += 4)
+ WRITE4_RGBA_RGB221(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ else if (IS_MULTIPLE_2((width - x)))
+ {
+ w = width - 2 - x;
+ for (; x < w; x += 4)
+ WRITE4_RGBA_RGB221(src, dest);
+ WRITE2_RGBA_RGB221(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ else
+ {
+ w = width - 3 - x;
+ for (; x < w; x += 4)
+ WRITE4_RGBA_RGB221(src, dest);
+ for (; x < width; x++)
+ {
+ WRITE1_RGBA_RGB221(src, dest);
+ }
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ }
+ }
+ return;
+ dx = 0;
+ dy = 0;
}
static void
-__imlib_RGBA_to_RGB221_dither(DATA32 *src , int src_jump,
- DATA8 *dest, int dow,
- int width, int height, int dx, int dy)
+__imlib_RGBA_to_RGB221_dither(DATA32 * src, int src_jump,
+ DATA8 * dest, int dow,
+ int width, int height, int dx, int dy)
{
- int x, y, w, h;
- int dest_jump = dow - width;
-
- w = width + dx;
- h = height + dy;
-
- if (IS_ALIGNED_32((int)dest))
- {
- if (IS_MULTIPLE_4(width))
- {
- for (y = dy; y < h; y++)
- {
- for (x = dx; x < w; x+=4)
- WRITE4_RGBA_RGB221_DITHER(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- else if (IS_MULTIPLE_2(width))
- {
- w-=2;
- for (y = dy; y < h; y++)
- {
- for (x = dx; x < w; x+=4)
- WRITE4_RGBA_RGB221_DITHER(src, dest);
- WRITE2_RGBA_RGB221_DITHER(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- else
- {
- w-=3;
- for (y = dy; y < h; y++)
- {
- for (x = dx; x < w; x+=4)
- WRITE4_RGBA_RGB221_DITHER(src, dest);
- for (; x < (width + dx); x++)
- {
- WRITE1_RGBA_RGB221_DITHER(src, dest);
- }
- src += src_jump;
- dest += dest_jump;
- }
- }
- }
- else
- {
- for (y = dy; y < h; y++)
- {
- w = width + dx;
- for (x = dx; ((x < w) && (!(IS_ALIGNED_32((int)dest)))); x++)
- {
- WRITE1_RGBA_RGB221_DITHER(src, dest);
- }
- if (x < w)
- {
- w = (width + dx) - (3 + x);
- for (; x < w; x+=4)
- WRITE4_RGBA_RGB221_DITHER(src, dest);
- for (; x < (width + dx); x++)
- {
- WRITE1_RGBA_RGB221_DITHER(src, dest);
- }
- src += src_jump;
- dest += dest_jump;
- }
- }
- }
- return;
- dx = 0;
- dy = 0;
+ int x, y, w, h;
+ int dest_jump = dow - width;
+
+ w = width + dx;
+ h = height + dy;
+
+ if (IS_ALIGNED_32((int)dest))
+ {
+ if (IS_MULTIPLE_4(width))
+ {
+ for (y = dy; y < h; y++)
+ {
+ for (x = dx; x < w; x += 4)
+ WRITE4_RGBA_RGB221_DITHER(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ else if (IS_MULTIPLE_2(width))
+ {
+ w -= 2;
+ for (y = dy; y < h; y++)
+ {
+ for (x = dx; x < w; x += 4)
+ WRITE4_RGBA_RGB221_DITHER(src, dest);
+ WRITE2_RGBA_RGB221_DITHER(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ else
+ {
+ w -= 3;
+ for (y = dy; y < h; y++)
+ {
+ for (x = dx; x < w; x += 4)
+ WRITE4_RGBA_RGB221_DITHER(src, dest);
+ for (; x < (width + dx); x++)
+ {
+ WRITE1_RGBA_RGB221_DITHER(src, dest);
+ }
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ }
+ else
+ {
+ for (y = dy; y < h; y++)
+ {
+ w = width + dx;
+ for (x = dx; ((x < w) && (!(IS_ALIGNED_32((int)dest)))); x++)
+ {
+ WRITE1_RGBA_RGB221_DITHER(src, dest);
+ }
+ if (x < w)
+ {
+ w = (width + dx) - (3 + x);
+ for (; x < w; x += 4)
+ WRITE4_RGBA_RGB221_DITHER(src, dest);
+ for (; x < (width + dx); x++)
+ {
+ WRITE1_RGBA_RGB221_DITHER(src, dest);
+ }
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ }
+ return;
+ dx = 0;
+ dy = 0;
}
-
+
static void
-__imlib_RGBA_to_RGB121_fast(DATA32 *src , int src_jump,
- DATA8 *dest, int dow,
- int width, int height, int dx, int dy)
+__imlib_RGBA_to_RGB121_fast(DATA32 * src, int src_jump,
+ DATA8 * dest, int dow,
+ int width, int height, int dx, int dy)
{
- int x, y, w, h;
- int dest_jump = dow - width;
-
- w = width;
- h = height;
-
- if (IS_ALIGNED_32((int)dest))
- {
- if (IS_MULTIPLE_4(width))
- {
- for (y = 0; y < h; y++)
- {
- for (x = 0; x < w; x+=4)
- WRITE4_RGBA_RGB121(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- else if (IS_MULTIPLE_2(width))
- {
- w-=2;
- for (y = 0; y < h; y++)
- {
- for (x = 0; x < w; x+=4)
- WRITE4_RGBA_RGB121(src, dest);
- WRITE2_RGBA_RGB121(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- else
- {
- w-=3;
- for (y = 0; y < h; y++)
- {
- for (x = 0; x < w; x+=4)
- WRITE4_RGBA_RGB121(src, dest);
- for (; x < width; x++)
- {
- WRITE1_RGBA_RGB121(src, dest);
- }
- src += src_jump;
- dest += dest_jump;
- }
- }
- }
- else
- {
- for (y = 0; y < h; y++)
- {
- for (x = 0; ((x < w) && (!(IS_ALIGNED_32((int)dest)))); x++)
- {
- WRITE1_RGBA_RGB121(src, dest);
- }
- if (x < w)
- {
- if (IS_MULTIPLE_4((width - x)))
- {
- for (; x < w; x+=4)
- WRITE4_RGBA_RGB121(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- else if (IS_MULTIPLE_2((width - x)))
- {
- w = width - 2 - x;
- for (; x < w; x+=4)
- WRITE4_RGBA_RGB121(src, dest);
- WRITE2_RGBA_RGB121(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- else
- {
- w = width - 3 - x;
- for (; x < w; x+=4)
- WRITE4_RGBA_RGB121(src, dest);
- for (; x < width; x++)
- {
- WRITE1_RGBA_RGB121(src, dest);
- }
- src += src_jump;
- dest += dest_jump;
- }
- }
- }
- }
- return;
- dx = 0;
- dy = 0;
+ int x, y, w, h;
+ int dest_jump = dow - width;
+
+ w = width;
+ h = height;
+
+ if (IS_ALIGNED_32((int)dest))
+ {
+ if (IS_MULTIPLE_4(width))
+ {
+ for (y = 0; y < h; y++)
+ {
+ for (x = 0; x < w; x += 4)
+ WRITE4_RGBA_RGB121(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ else if (IS_MULTIPLE_2(width))
+ {
+ w -= 2;
+ for (y = 0; y < h; y++)
+ {
+ for (x = 0; x < w; x += 4)
+ WRITE4_RGBA_RGB121(src, dest);
+ WRITE2_RGBA_RGB121(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ else
+ {
+ w -= 3;
+ for (y = 0; y < h; y++)
+ {
+ for (x = 0; x < w; x += 4)
+ WRITE4_RGBA_RGB121(src, dest);
+ for (; x < width; x++)
+ {
+ WRITE1_RGBA_RGB121(src, dest);
+ }
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ }
+ else
+ {
+ for (y = 0; y < h; y++)
+ {
+ for (x = 0; ((x < w) && (!(IS_ALIGNED_32((int)dest)))); x++)
+ {
+ WRITE1_RGBA_RGB121(src, dest);
+ }
+ if (x < w)
+ {
+ if (IS_MULTIPLE_4((width - x)))
+ {
+ for (; x < w; x += 4)
+ WRITE4_RGBA_RGB121(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ else if (IS_MULTIPLE_2((width - x)))
+ {
+ w = width - 2 - x;
+ for (; x < w; x += 4)
+ WRITE4_RGBA_RGB121(src, dest);
+ WRITE2_RGBA_RGB121(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ else
+ {
+ w = width - 3 - x;
+ for (; x < w; x += 4)
+ WRITE4_RGBA_RGB121(src, dest);
+ for (; x < width; x++)
+ {
+ WRITE1_RGBA_RGB121(src, dest);
+ }
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ }
+ }
+ return;
+ dx = 0;
+ dy = 0;
}
static void
-__imlib_RGBA_to_RGB121_dither(DATA32 *src , int src_jump,
- DATA8 *dest, int dow,
- int width, int height, int dx, int dy)
+__imlib_RGBA_to_RGB121_dither(DATA32 * src, int src_jump,
+ DATA8 * dest, int dow,
+ int width, int height, int dx, int dy)
{
- int x, y, w, h;
- int dest_jump = dow - width;
-
- w = width + dx;
- h = height + dy;
-
- if (IS_ALIGNED_32((int)dest))
- {
- if (IS_MULTIPLE_4(width))
- {
- for (y = dy; y < h; y++)
- {
- for (x = dx; x < w; x+=4)
- WRITE4_RGBA_RGB121_DITHER(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- else if (IS_MULTIPLE_2(width))
- {
- w-=2;
- for (y = dy; y < h; y++)
- {
- for (x = dx; x < w; x+=4)
- WRITE4_RGBA_RGB121_DITHER(src, dest);
- WRITE2_RGBA_RGB121_DITHER(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- else
- {
- w-=3;
- for (y = dy; y < h; y++)
- {
- for (x = dx; x < w; x+=4)
- WRITE4_RGBA_RGB121_DITHER(src, dest);
- for (; x < (width + dx); x++)
- {
- WRITE1_RGBA_RGB121_DITHER(src, dest);
- }
- src += src_jump;
- dest += dest_jump;
- }
- }
- }
- else
- {
- for (y = dy; y < h; y++)
- {
- w = width + dx;
- for (x = dx; ((x < w) && (!(IS_ALIGNED_32((int)dest)))); x++)
- {
- WRITE1_RGBA_RGB121_DITHER(src, dest);
- }
- if (x < w)
- {
- w = (width + dx) - (3 + x);
- for (; x < w; x+=4)
- WRITE4_RGBA_RGB121_DITHER(src, dest);
- for (; x < (width + dx); x++)
- {
- WRITE1_RGBA_RGB121_DITHER(src, dest);
- }
- src += src_jump;
- dest += dest_jump;
- }
- }
- }
- return;
- dx = 0;
- dy = 0;
+ int x, y, w, h;
+ int dest_jump = dow - width;
+
+ w = width + dx;
+ h = height + dy;
+
+ if (IS_ALIGNED_32((int)dest))
+ {
+ if (IS_MULTIPLE_4(width))
+ {
+ for (y = dy; y < h; y++)
+ {
+ for (x = dx; x < w; x += 4)
+ WRITE4_RGBA_RGB121_DITHER(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ else if (IS_MULTIPLE_2(width))
+ {
+ w -= 2;
+ for (y = dy; y < h; y++)
+ {
+ for (x = dx; x < w; x += 4)
+ WRITE4_RGBA_RGB121_DITHER(src, dest);
+ WRITE2_RGBA_RGB121_DITHER(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ else
+ {
+ w -= 3;
+ for (y = dy; y < h; y++)
+ {
+ for (x = dx; x < w; x += 4)
+ WRITE4_RGBA_RGB121_DITHER(src, dest);
+ for (; x < (width + dx); x++)
+ {
+ WRITE1_RGBA_RGB121_DITHER(src, dest);
+ }
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ }
+ else
+ {
+ for (y = dy; y < h; y++)
+ {
+ w = width + dx;
+ for (x = dx; ((x < w) && (!(IS_ALIGNED_32((int)dest)))); x++)
+ {
+ WRITE1_RGBA_RGB121_DITHER(src, dest);
+ }
+ if (x < w)
+ {
+ w = (width + dx) - (3 + x);
+ for (; x < w; x += 4)
+ WRITE4_RGBA_RGB121_DITHER(src, dest);
+ for (; x < (width + dx); x++)
+ {
+ WRITE1_RGBA_RGB121_DITHER(src, dest);
+ }
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ }
+ return;
+ dx = 0;
+ dy = 0;
}
-
+
static void
-__imlib_RGBA_to_RGB111_fast(DATA32 *src , int src_jump,
- DATA8 *dest, int dow,
- int width, int height, int dx, int dy)
+__imlib_RGBA_to_RGB111_fast(DATA32 * src, int src_jump,
+ DATA8 * dest, int dow,
+ int width, int height, int dx, int dy)
{
- int x, y, w, h;
- int dest_jump = dow - width;
-
- w = width;
- h = height;
-
- if (IS_ALIGNED_32((int)dest))
- {
- if (IS_MULTIPLE_4(width))
- {
- for (y = 0; y < h; y++)
- {
- for (x = 0; x < w; x+=4)
- WRITE4_RGBA_RGB111(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- else if (IS_MULTIPLE_2(width))
- {
- w-=2;
- for (y = 0; y < h; y++)
- {
- for (x = 0; x < w; x+=4)
- WRITE4_RGBA_RGB111(src, dest);
- WRITE2_RGBA_RGB111(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- else
- {
- w-=3;
- for (y = 0; y < h; y++)
- {
- for (x = 0; x < w; x+=4)
- WRITE4_RGBA_RGB111(src, dest);
- for (; x < width; x++)
- {
- WRITE1_RGBA_RGB111(src, dest);
- }
- src += src_jump;
- dest += dest_jump;
- }
- }
- }
- else
- {
- for (y = 0; y < h; y++)
- {
- for (x = 0; ((x < w) && (!(IS_ALIGNED_32((int)dest)))); x++)
- {
- WRITE1_RGBA_RGB111(src, dest);
- }
- if (x < w)
- {
- if (IS_MULTIPLE_4((width - x)))
- {
- for (; x < w; x+=4)
- WRITE4_RGBA_RGB111(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- else if (IS_MULTIPLE_2((width - x)))
- {
- w = width - 2 - x;
- for (; x < w; x+=4)
- WRITE4_RGBA_RGB111(src, dest);
- WRITE2_RGBA_RGB111(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- else
- {
- w = width - 3 - x;
- for (; x < w; x+=4)
- WRITE4_RGBA_RGB111(src, dest);
- for (; x < width; x++)
- {
- WRITE1_RGBA_RGB111(src, dest);
- }
- src += src_jump;
- dest += dest_jump;
- }
- }
- }
- }
- return;
- dx = 0;
- dy = 0;
+ int x, y, w, h;
+ int dest_jump = dow - width;
+
+ w = width;
+ h = height;
+
+ if (IS_ALIGNED_32((int)dest))
+ {
+ if (IS_MULTIPLE_4(width))
+ {
+ for (y = 0; y < h; y++)
+ {
+ for (x = 0; x < w; x += 4)
+ WRITE4_RGBA_RGB111(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ else if (IS_MULTIPLE_2(width))
+ {
+ w -= 2;
+ for (y = 0; y < h; y++)
+ {
+ for (x = 0; x < w; x += 4)
+ WRITE4_RGBA_RGB111(src, dest);
+ WRITE2_RGBA_RGB111(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ else
+ {
+ w -= 3;
+ for (y = 0; y < h; y++)
+ {
+ for (x = 0; x < w; x += 4)
+ WRITE4_RGBA_RGB111(src, dest);
+ for (; x < width; x++)
+ {
+ WRITE1_RGBA_RGB111(src, dest);
+ }
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ }
+ else
+ {
+ for (y = 0; y < h; y++)
+ {
+ for (x = 0; ((x < w) && (!(IS_ALIGNED_32((int)dest)))); x++)
+ {
+ WRITE1_RGBA_RGB111(src, dest);
+ }
+ if (x < w)
+ {
+ if (IS_MULTIPLE_4((width - x)))
+ {
+ for (; x < w; x += 4)
+ WRITE4_RGBA_RGB111(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ else if (IS_MULTIPLE_2((width - x)))
+ {
+ w = width - 2 - x;
+ for (; x < w; x += 4)
+ WRITE4_RGBA_RGB111(src, dest);
+ WRITE2_RGBA_RGB111(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ else
+ {
+ w = width - 3 - x;
+ for (; x < w; x += 4)
+ WRITE4_RGBA_RGB111(src, dest);
+ for (; x < width; x++)
+ {
+ WRITE1_RGBA_RGB111(src, dest);
+ }
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ }
+ }
+ return;
+ dx = 0;
+ dy = 0;
}
static void
-__imlib_RGBA_to_RGB111_dither(DATA32 *src , int src_jump,
- DATA8 *dest, int dow,
- int width, int height, int dx, int dy)
+__imlib_RGBA_to_RGB111_dither(DATA32 * src, int src_jump,
+ DATA8 * dest, int dow,
+ int width, int height, int dx, int dy)
{
- int x, y, w, h;
- int dest_jump = dow - width;
-
- w = width + dx;
- h = height + dy;
-
- if (IS_ALIGNED_32((int)dest))
- {
- if (IS_MULTIPLE_4(width))
- {
- for (y = dy; y < h; y++)
- {
- for (x = dx; x < w; x+=4)
- WRITE4_RGBA_RGB111_DITHER(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- else if (IS_MULTIPLE_2(width))
- {
- w-=2;
- for (y = dy; y < h; y++)
- {
- for (x = dx; x < w; x+=4)
- WRITE4_RGBA_RGB111_DITHER(src, dest);
- WRITE2_RGBA_RGB111_DITHER(src, dest);
- src += src_jump;
- dest += dest_jump;
- }
- }
- else
- {
- w-=3;
- for (y = dy; y < h; y++)
- {
- for (x = dx; x < w; x+=4)
- WRITE4_RGBA_RGB111_DITHER(src, dest);
- for (; x < (width + dx); x++)
- {
- WRITE1_RGBA_RGB111_DITHER(src, dest);
- }
- src += src_jump;
- dest += dest_jump;
- }
- }
- }
- else
- {
- for (y = dy; y < h; y++)
- {
- w = width + dx;
- for (x = dx; ((x < w) && (!(IS_ALIGNED_32((int)dest)))); x++)
- {
- WRITE1_RGBA_RGB111_DITHER(src, dest);
- }
- if (x < w)
- {
- w = (width + dx) - (3 + x);
- for (; x < w; x+=4)
- WRITE4_RGBA_RGB111_DITHER(src, dest);
- for (; x < (width + dx); x++)
- {
- WRITE1_RGBA_RGB111_DITHER(src, dest);
- }
- src += src_jump;
- dest += dest_jump;
- }
- }
- }
- return;
- dx = 0;
- dy = 0;
+ int x, y, w, h;
+ int dest_jump = dow - width;
+
+ w = width + dx;
+ h = height + dy;
+
+ if (IS_ALIGNED_32((int)dest))
+ {
+ if (IS_MULTIPLE_4(width))
+ {
+ for (y = dy; y < h; y++)
+ {
+ for (x = dx; x < w; x += 4)
+ WRITE4_RGBA_RGB111_DITHER(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ else if (IS_MULTIPLE_2(width))
+ {
+ w -= 2;
+ for (y = dy; y < h; y++)
+ {
+ for (x = dx; x < w; x += 4)
+ WRITE4_RGBA_RGB111_DITHER(src, dest);
+ WRITE2_RGBA_RGB111_DITHER(src, dest);
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ else
+ {
+ w -= 3;
+ for (y = dy; y < h; y++)
+ {
+ for (x = dx; x < w; x += 4)
+ WRITE4_RGBA_RGB111_DITHER(src, dest);
+ for (; x < (width + dx); x++)
+ {
+ WRITE1_RGBA_RGB111_DITHER(src, dest);
+ }
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ }
+ else
+ {
+ for (y = dy; y < h; y++)
+ {
+ w = width + dx;
+ for (x = dx; ((x < w) && (!(IS_ALIGNED_32((int)dest)))); x++)
+ {
+ WRITE1_RGBA_RGB111_DITHER(src, dest);
+ }
+ if (x < w)
+ {
+ w = (width + dx) - (3 + x);
+ for (; x < w; x += 4)
+ WRITE4_RGBA_RGB111_DITHER(src, dest);
+ for (; x < (width + dx); x++)
+ {
+ WRITE1_RGBA_RGB111_DITHER(src, dest);
+ }
+ src += src_jump;
+ dest += dest_jump;
+ }
+ }
+ }
+ return;
+ dx = 0;
+ dy = 0;
}
-
+
static void
-__imlib_RGBA_to_RGB1_fast(DATA32 *src , int src_jump,
- DATA8 *dest, int dow,
- int width, int height, int dx, int dy)
+__imlib_RGBA_to_RGB1_fast(DATA32 * src, int src_jump,
+ DATA8 * dest, int dow,
+ int width, int height, int dx, int dy)
{
- int x, y, w, h;
- int dest_jump = dow - width;
-
- w = width;
- h = height;
-
- for (y = 0; y < h; y++)
- {
- for (x = 0; x < w; x++)
- {
- WRITE1_RGBA_RGB1(src, dest);
- }
- src += src_jump;
- dest += dest_jump;
- }
- return;
- dx = 0;
- dy = 0;
+ int x, y, w, h;
+ int dest_jump = dow - width;
+
+ w = width;
+ h = height;
+
+ for (y = 0; y < h; y++)
+ {
+ for (x = 0; x < w; x++)
+ {
+ WRITE1_RGBA_RGB1(src, dest);
+ }
+ src += src_jump;
+ dest += dest_jump;
+ }
+ return;
+ dx = 0;
+ dy = 0;
}
static void
-__imlib_RGBA_to_RGB1_dither(DATA32 *src , int src_jump,
- DATA8 *dest, int dow,
- int width, int height, int dx, int dy)
+__imlib_RGBA_to_RGB1_dither(DATA32 * src, int src_jump,
+ DATA8 * dest, int dow,
+ int width, int height, int dx, int dy)
{
- int x, y, w, h;
- int dest_jump = dow - width;
-
- w = width + dx;
- h = height + dy;
-
- for (y = dy; y < h; y++)
- {
- for (x = dx; x < w; x++)
- {
- WRITE1_RGBA_RGB1_DITHER(src, dest);
- }
- src += src_jump;
- dest += dest_jump;
- }
- return;
- dx = 0;
- dy = 0;
+ int x, y, w, h;
+ int dest_jump = dow - width;
+
+ w = width + dx;
+ h = height + dy;
+
+ for (y = dy; y < h; y++)
+ {
+ for (x = dx; x < w; x++)
+ {
+ WRITE1_RGBA_RGB1_DITHER(src, dest);
+ }
+ src += src_jump;
+ dest += dest_jump;
+ }
+ return;
+ dx = 0;
+ dy = 0;
}
static void
-__imlib_RGBA_to_A1_fast(DATA32 *src , int src_jump,
- DATA8 *dest, int dow,
- int width, int height, int dx, int dy)
+__imlib_RGBA_to_A1_fast(DATA32 * src, int src_jump,
+ DATA8 * dest, int dow,
+ int width, int height, int dx, int dy)
{
- int x, y, w, h;
- int dest_jump = dow - (width >> 3);
-
+ int x, y, w, h;
+ int dest_jump = dow - (width >> 3);
+
w = width;
h = height;
for (y = 0; y < h; y++)
{
- for (x = 0; x < w; x++)
- {
- WRITE1_RGBA_A1(src, dest);
- }
- src += src_jump;
- dest += dest_jump;
+ for (x = 0; x < w; x++)
+ {
+ WRITE1_RGBA_A1(src, dest);
+ }
+ src += src_jump;
+ dest += dest_jump;
}
return;
dx = 0;
@@ -3873,50 +4720,50 @@ __imlib_RGBA_to_A1_fast(DATA32 *src , int src_jump,
}
static void
-__imlib_RGBA_to_A1_dither(DATA32 *src , int src_jump,
- DATA8 *dest, int dow,
- int width, int height, int dx, int dy)
+__imlib_RGBA_to_A1_dither(DATA32 * src, int src_jump,
+ DATA8 * dest, int dow,
+ int width, int height, int dx, int dy)
{
- int x, y, w, h;
- int dest_jump = dow - (width >> 3);
-
+ int x, y, w, h;
+ int dest_jump = dow - (width >> 3);
+
w = width + dx;
h = height + dy;
for (y = dy; y < h; y++)
{
- for (x = dx; x < w; x++)
- {
- WRITE1_RGBA_A1_DITHER(src, dest);
- }
- src += src_jump;
- dest += dest_jump;
+ for (x = dx; x < w; x++)
+ {
+ WRITE1_RGBA_A1_DITHER(src, dest);
+ }
+ src += src_jump;
+ dest += dest_jump;
}
return;
dx = 0;
dy = 0;
}
-
+
static void
-__imlib_RGBA_to_RGB8888_fast(DATA32 *src , int src_jump,
- DATA8 *dst, int dow,
- int width, int height, int dx, int dy)
+__imlib_RGBA_to_RGB8888_fast(DATA32 * src, int src_jump,
+ DATA8 * dst, int dow,
+ int width, int height, int dx, int dy)
{
- int y, w, h;
- DATA32 *dest = (DATA32 *)dst;
- int dest_jump = (dow / sizeof(DATA32)) - width;
-
+ int y, w, h;
+ DATA32 *dest = (DATA32 *) dst;
+ int dest_jump = (dow / sizeof(DATA32)) - width;
+
w = width;
h = height;
if ((src_jump > 0) || (dest_jump > 0))
{
- for (y = h; y > 0; y--)
- {
- memcpy(dest, src, w * sizeof(DATA32));
- src += src_jump + w;
- dest += dest_jump + w;
- }
+ for (y = h; y > 0; y--)
+ {
+ memcpy(dest, src, w * sizeof(DATA32));
+ src += src_jump + w;
+ dest += dest_jump + w;
+ }
}
else
memcpy(dest, src, h * w * sizeof(DATA32));
@@ -3926,25 +4773,25 @@ __imlib_RGBA_to_RGB8888_fast(DATA32 *src , int src_jump,
}
static void
-__imlib_RGBA_to_BGR8888_fast(DATA32 *src , int src_jump,
- DATA8 *dst, int dow,
- int width, int height, int dx, int dy)
+__imlib_RGBA_to_BGR8888_fast(DATA32 * src, int src_jump,
+ DATA8 * dst, int dow,
+ int width, int height, int dx, int dy)
{
- int x, y, w, h;
- DATA32 *dest = (DATA32 *)dst;
- int dest_jump = (dow / sizeof(DATA32)) - width;
-
+ int x, y, w, h;
+ DATA32 *dest = (DATA32 *) dst;
+ int dest_jump = (dow / sizeof(DATA32)) - width;
+
w = width;
h = height;
for (y = 0; y < h; y++)
{
- for (x = 0; x < w; x++)
- {
- WRITE1_RGBA_BGR8888(src, dest);
- }
- src += src_jump;
- dest += dest_jump;
+ for (x = 0; x < w; x++)
+ {
+ WRITE1_RGBA_BGR8888(src, dest);
+ }
+ src += src_jump;
+ dest += dest_jump;
}
return;
dx = 0;
@@ -3952,162 +4799,162 @@ __imlib_RGBA_to_BGR8888_fast(DATA32 *src , int src_jump,
}
static void
-__imlib_RGBA_to_RGB888_fast(DATA32 *src , int src_jump,
- DATA8 *dest, int dow,
- int width, int height, int dx, int dy)
+__imlib_RGBA_to_RGB888_fast(DATA32 * src, int src_jump,
+ DATA8 * dest, int dow,
+ int width, int height, int dx, int dy)
{
- int x, y, w, h;
- int dest_jump = dow - (width * 3);
-
- w = width;
- h = height;
-
- for (y = 0; y < h; y++)
- {
- for (x = 0; x < w; x++)
- {
- WRITE1_RGBA_RGB888(src, dest);
- }
- src += src_jump;
- dest += dest_jump;
- }
- return;
- dx = 0;
- dy = 0;
+ int x, y, w, h;
+ int dest_jump = dow - (width * 3);
+
+ w = width;
+ h = height;
+
+ for (y = 0; y < h; y++)
+ {
+ for (x = 0; x < w; x++)
+ {
+ WRITE1_RGBA_RGB888(src, dest);
+ }
+ src += src_jump;
+ dest += dest_jump;
+ }
+ return;
+ dx = 0;
+ dy = 0;
}
static void
-__imlib_RGBA_to_BGR888_fast(DATA32 *src , int src_jump,
- DATA8 *dest, int dow,
- int width, int height, int dx, int dy)
+__imlib_RGBA_to_BGR888_fast(DATA32 * src, int src_jump,
+ DATA8 * dest, int dow,
+ int width, int height, int dx, int dy)
{
- int x, y, w, h;
- int dest_jump = dow - (width * 3);
-
- w = width;
- h = height;
-
- for (y = 0; y < h; y++)
- {
- for (x = 0; x < w; x++)
- {
- WRITE1_RGBA_BGR888(src, dest);
- }
- src += src_jump;
- dest += dest_jump;
- }
- return;
- dx = 0;
- dy = 0;
+ int x, y, w, h;
+ int dest_jump = dow - (width * 3);
+
+ w = width;
+ h = height;
+
+ for (y = 0; y < h; y++)
+ {
+ for (x = 0; x < w; x++)
+ {
+ WRITE1_RGBA_BGR888(src, dest);
+ }
+ src += src_jump;
+ dest += dest_jump;
+ }
+ return;
+ dx = 0;
+ dy = 0;
}
static void
-__imlib_RGBA_to_Nothing(DATA32 *src , int src_jump,
- DATA8 *dest, int dow,
- int width, int height, int dx, int dy)
+__imlib_RGBA_to_Nothing(DATA32 * src, int src_jump,
+ DATA8 * dest, int dow,
+ int width, int height, int dx, int dy)
{
- /*\ Nothing: Dummy function \*/
+ /*\ Nothing: Dummy function \ */
}
ImlibRGBAFunction
-__imlib_GetRGBAFunction(int depth,
- unsigned long rm, unsigned long gm, unsigned long bm,
- char hiq, DATA8 palette_type)
+__imlib_GetRGBAFunction(int depth,
+ unsigned long rm, unsigned long gm, unsigned long bm,
+ char hiq, DATA8 palette_type)
{
if (depth == 16)
{
- if (hiq)
- {
- if ((rm == 0xf800) && (gm == 0x7e0) && (bm == 0x1f))
- return __imlib_RGBA_to_RGB565_dither;
- if ((rm == 0x7c00) && (gm == 0x3e0) && (bm == 0x1f))
- return __imlib_RGBA_to_RGB555_dither;
- if ((bm == 0xf800) && (gm == 0x7e0) && (rm == 0x1f))
- return __imlib_RGBA_to_BGR565_dither;
- if ((bm == 0x7c00) && (gm == 0x3e0) && (rm == 0x1f))
- return __imlib_RGBA_to_BGR555_dither;
- }
- else
- {
+ if (hiq)
+ {
+ if ((rm == 0xf800) && (gm == 0x7e0) && (bm == 0x1f))
+ return __imlib_RGBA_to_RGB565_dither;
+ if ((rm == 0x7c00) && (gm == 0x3e0) && (bm == 0x1f))
+ return __imlib_RGBA_to_RGB555_dither;
+ if ((bm == 0xf800) && (gm == 0x7e0) && (rm == 0x1f))
+ return __imlib_RGBA_to_BGR565_dither;
+ if ((bm == 0x7c00) && (gm == 0x3e0) && (rm == 0x1f))
+ return __imlib_RGBA_to_BGR555_dither;
+ }
+ else
+ {
#ifdef DO_MMX_ASM
- if (__imlib_get_cpuid() && CPUID_MMX)
- {
- if ((rm == 0xf800) && (gm == 0x7e0) && (bm == 0x1f))
- return __imlib_mmx_rgb565_fast;
- if ((rm == 0x7c00) && (gm == 0x3e0) && (bm == 0x1f))
- return __imlib_mmx_rgb555_fast;
- if ((bm == 0xf800) && (gm == 0x7e0) && (rm == 0x1f))
- return __imlib_mmx_bgr565_fast;
- if ((bm == 0x7c00) && (gm == 0x3e0) && (rm == 0x1f))
- return __imlib_mmx_bgr555_fast;
- }
- else
+ if (__imlib_get_cpuid() && CPUID_MMX)
+ {
+ if ((rm == 0xf800) && (gm == 0x7e0) && (bm == 0x1f))
+ return __imlib_mmx_rgb565_fast;
+ if ((rm == 0x7c00) && (gm == 0x3e0) && (bm == 0x1f))
+ return __imlib_mmx_rgb555_fast;
+ if ((bm == 0xf800) && (gm == 0x7e0) && (rm == 0x1f))
+ return __imlib_mmx_bgr565_fast;
+ if ((bm == 0x7c00) && (gm == 0x3e0) && (rm == 0x1f))
+ return __imlib_mmx_bgr555_fast;
+ }
+ else
#endif
- {
- if ((rm == 0xf800) && (gm == 0x7e0) && (bm == 0x1f))
- return __imlib_RGBA_to_RGB565_fast;
- if ((rm == 0x7c00) && (gm == 0x3e0) && (bm == 0x1f))
- return __imlib_RGBA_to_RGB555_fast;
- if ((bm == 0xf800) && (gm == 0x7e0) && (rm == 0x1f))
- return __imlib_RGBA_to_BGR565_fast;
- if ((bm == 0x7c00) && (gm == 0x3e0) && (rm == 0x1f))
- return __imlib_RGBA_to_BGR555_fast;
- }
- }
- return NULL;
+ {
+ if ((rm == 0xf800) && (gm == 0x7e0) && (bm == 0x1f))
+ return __imlib_RGBA_to_RGB565_fast;
+ if ((rm == 0x7c00) && (gm == 0x3e0) && (bm == 0x1f))
+ return __imlib_RGBA_to_RGB555_fast;
+ if ((bm == 0xf800) && (gm == 0x7e0) && (rm == 0x1f))
+ return __imlib_RGBA_to_BGR565_fast;
+ if ((bm == 0x7c00) && (gm == 0x3e0) && (rm == 0x1f))
+ return __imlib_RGBA_to_BGR555_fast;
+ }
+ }
+ return NULL;
}
else if (depth == 32)
{
- if ((rm == 0xff0000) && (gm == 0xff00) && (bm == 0xff))
- return __imlib_RGBA_to_RGB8888_fast;
- return NULL;
+ if ((rm == 0xff0000) && (gm == 0xff00) && (bm == 0xff))
+ return __imlib_RGBA_to_RGB8888_fast;
+ return NULL;
}
else if (depth == 24)
{
- if ((rm == 0xff0000) && (gm == 0xff00) && (bm == 0xff))
- return __imlib_RGBA_to_RGB888_fast;
- return NULL;
+ if ((rm == 0xff0000) && (gm == 0xff00) && (bm == 0xff))
+ return __imlib_RGBA_to_RGB888_fast;
+ return NULL;
}
else if (depth == 8)
{
- if (hiq)
- {
- if (palette_type == 0)
- return __imlib_RGBA_to_RGB332_dither;
- if (palette_type == 1)
- return __imlib_RGBA_to_RGB232_dither;
- if (palette_type == 2)
- return __imlib_RGBA_to_RGB222_dither;
- if (palette_type == 3)
- return __imlib_RGBA_to_RGB221_dither;
- if (palette_type == 4)
- return __imlib_RGBA_to_RGB121_dither;
- if (palette_type == 5)
- return __imlib_RGBA_to_RGB111_dither;
- if (palette_type == 6)
- return __imlib_RGBA_to_RGB1_dither;
- if (palette_type == 7)
- return __imlib_RGBA_to_RGB666_dither;
- }
- else
- {
- if (palette_type == 0)
- return __imlib_RGBA_to_RGB332_fast;
- if (palette_type == 1)
- return __imlib_RGBA_to_RGB232_fast;
- if (palette_type == 2)
- return __imlib_RGBA_to_RGB222_fast;
- if (palette_type == 3)
- return __imlib_RGBA_to_RGB221_fast;
- if (palette_type == 4)
- return __imlib_RGBA_to_RGB121_fast;
- if (palette_type == 5)
- return __imlib_RGBA_to_RGB111_fast;
- if (palette_type == 6)
- return __imlib_RGBA_to_RGB1_fast;
- if (palette_type == 7)
- return __imlib_RGBA_to_RGB666_fast;
- }
+ if (hiq)
+ {
+ if (palette_type == 0)
+ return __imlib_RGBA_to_RGB332_dither;
+ if (palette_type == 1)
+ return __imlib_RGBA_to_RGB232_dither;
+ if (palette_type == 2)
+ return __imlib_RGBA_to_RGB222_dither;
+ if (palette_type == 3)
+ return __imlib_RGBA_to_RGB221_dither;
+ if (palette_type == 4)
+ return __imlib_RGBA_to_RGB121_dither;
+ if (palette_type == 5)
+ return __imlib_RGBA_to_RGB111_dither;
+ if (palette_type == 6)
+ return __imlib_RGBA_to_RGB1_dither;
+ if (palette_type == 7)
+ return __imlib_RGBA_to_RGB666_dither;
+ }
+ else
+ {
+ if (palette_type == 0)
+ return __imlib_RGBA_to_RGB332_fast;
+ if (palette_type == 1)
+ return __imlib_RGBA_to_RGB232_fast;
+ if (palette_type == 2)
+ return __imlib_RGBA_to_RGB222_fast;
+ if (palette_type == 3)
+ return __imlib_RGBA_to_RGB221_fast;
+ if (palette_type == 4)
+ return __imlib_RGBA_to_RGB121_fast;
+ if (palette_type == 5)
+ return __imlib_RGBA_to_RGB111_fast;
+ if (palette_type == 6)
+ return __imlib_RGBA_to_RGB1_fast;
+ if (palette_type == 7)
+ return __imlib_RGBA_to_RGB666_fast;
+ }
}
return NULL;
}
@@ -4117,4 +4964,3 @@ __imlib_GetMaskFunction(char hiq)
{
return hiq ? &__imlib_RGBA_to_A1_dither : &__imlib_RGBA_to_A1_fast;
}
-
diff --git a/src/rgbadraw.c b/src/rgbadraw.c
index 39114f1..26d58b2 100644
--- a/src/rgbadraw.c
+++ b/src/rgbadraw.c
@@ -9,28 +9,28 @@
#define round(a) floor(a+0.5)
-static void span(ImlibImage * im, int y, int x1, int y1,
- DATA8 r, DATA8 g, DATA8 b, DATA8 a, ImlibOp op);
+static void span(ImlibImage * im, int y, int x1, int y1,
+ DATA8 r, DATA8 g, DATA8 b, DATA8 a, ImlibOp op);
void
__imlib_FlipImageHoriz(ImlibImage * im)
{
- DATA32 *p1, *p2, tmp;
- int x, y;
+ DATA32 *p1, *p2, tmp;
+ int x, y;
for (y = 0; y < im->h; y++)
- {
- p1 = im->data + (y * im->w);
- p2 = im->data + ((y + 1) * im->w) - 1;
- for (x = 0; x < (im->w >> 1); x++)
- {
- tmp = *p1;
- *p1 = *p2;
- *p2 = tmp;
- p1++;
- p2--;
- }
- }
+ {
+ p1 = im->data + (y * im->w);
+ p2 = im->data + ((y + 1) * im->w) - 1;
+ for (x = 0; x < (im->w >> 1); x++)
+ {
+ tmp = *p1;
+ *p1 = *p2;
+ *p2 = tmp;
+ p1++;
+ p2--;
+ }
+ }
x = im->border.left;
im->border.left = im->border.right;
im->border.right = x;
@@ -39,22 +39,22 @@ __imlib_FlipImageHoriz(ImlibImage * im)
void
__imlib_FlipImageVert(ImlibImage * im)
{
- DATA32 *p1, *p2, tmp;
- int x, y;
+ DATA32 *p1, *p2, tmp;
+ int x, y;
for (y = 0; y < (im->h >> 1); y++)
- {
- p1 = im->data + (y * im->w);
- p2 = im->data + ((im->h - 1 - y) * im->w);
- for (x = 0; x < im->w; x++)
- {
- tmp = *p1;
- *p1 = *p2;
- *p2 = tmp;
- p1++;
- p2++;
- }
- }
+ {
+ p1 = im->data + (y * im->w);
+ p2 = im->data + ((im->h - 1 - y) * im->w);
+ for (x = 0; x < im->w; x++)
+ {
+ tmp = *p1;
+ *p1 = *p2;
+ *p2 = tmp;
+ p1++;
+ p2++;
+ }
+ }
x = im->border.top;
im->border.top = im->border.bottom;
im->border.bottom = x;
@@ -63,19 +63,19 @@ __imlib_FlipImageVert(ImlibImage * im)
void
__imlib_FlipImageBoth(ImlibImage * im)
{
- DATA32 *p1, *p2, tmp;
- int x;
+ DATA32 *p1, *p2, tmp;
+ int x;
p1 = im->data;
p2 = im->data + (im->h * im->w) - 1;
for (x = (im->w * im->h) / 2; --x >= 0;)
- {
- tmp = *p1;
- *p1 = *p2;
- *p2 = tmp;
- p1++;
- p2--;
- }
+ {
+ tmp = *p1;
+ *p1 = *p2;
+ *p2 = tmp;
+ p1++;
+ p2--;
+ }
x = im->border.top;
im->border.top = im->border.bottom;
im->border.bottom = x;
@@ -93,8 +93,8 @@ __imlib_FlipImageBoth(ImlibImage * im)
void
__imlib_FlipImageDiagonal(ImlibImage * im, int direction)
{
- DATA32 *data, *to, *from;
- int x, y, w, hw, tmp;
+ DATA32 *data, *to, *from;
+ int x, y, w, hw, tmp;
data = malloc(im->w * im->h * sizeof(DATA32));
from = im->data;
@@ -103,60 +103,60 @@ __imlib_FlipImageDiagonal(ImlibImage * im, int direction)
im->w = w;
hw = w * im->h;
switch (direction)
- {
- default:
- case 0: /*\ DOWN_RIGHT \ */
- tmp = im->border.top;
- im->border.top = im->border.left;
- im->border.left = tmp;
- tmp = im->border.bottom;
- im->border.bottom = im->border.right;
- im->border.right = tmp;
- to = data;
- hw = -hw + 1;
- break;
- case 1: /*\ DOWN_LEFT \ */
- tmp = im->border.top;
- im->border.top = im->border.left;
- im->border.left = im->border.bottom;
- im->border.bottom = im->border.right;
- im->border.right = tmp;
- to = data + w - 1;
- hw = -hw - 1;
- break;
- case 2: /*\ UP_RIGHT \ */
- tmp = im->border.top;
- im->border.top = im->border.right;
- im->border.right = im->border.bottom;
- im->border.bottom = im->border.left;
- im->border.left = tmp;
- to = data + hw - w;
- w = -w;
- hw = hw + 1;
- break;
- case 3: /*\ UP_LEFT \ */
- tmp = im->border.top;
- im->border.top = im->border.right;
- im->border.right = tmp;
- tmp = im->border.bottom;
- im->border.bottom = im->border.left;
- im->border.left = tmp;
- to = data + hw - 1;
- w = -w;
- hw = hw - 1;
- break;
- }
+ {
+ default:
+ case 0: /*\ DOWN_RIGHT \ */
+ tmp = im->border.top;
+ im->border.top = im->border.left;
+ im->border.left = tmp;
+ tmp = im->border.bottom;
+ im->border.bottom = im->border.right;
+ im->border.right = tmp;
+ to = data;
+ hw = -hw + 1;
+ break;
+ case 1: /*\ DOWN_LEFT \ */
+ tmp = im->border.top;
+ im->border.top = im->border.left;
+ im->border.left = im->border.bottom;
+ im->border.bottom = im->border.right;
+ im->border.right = tmp;
+ to = data + w - 1;
+ hw = -hw - 1;
+ break;
+ case 2: /*\ UP_RIGHT \ */
+ tmp = im->border.top;
+ im->border.top = im->border.right;
+ im->border.right = im->border.bottom;
+ im->border.bottom = im->border.left;
+ im->border.left = tmp;
+ to = data + hw - w;
+ w = -w;
+ hw = hw + 1;
+ break;
+ case 3: /*\ UP_LEFT \ */
+ tmp = im->border.top;
+ im->border.top = im->border.right;
+ im->border.right = tmp;
+ tmp = im->border.bottom;
+ im->border.bottom = im->border.left;
+ im->border.left = tmp;
+ to = data + hw - 1;
+ w = -w;
+ hw = hw - 1;
+ break;
+ }
from = im->data;
for (x = im->w; --x >= 0;)
- {
- for (y = im->h; --y >= 0;)
- {
- *to = *from;
- from++;
- to += w;
- }
- to += hw;
- }
+ {
+ for (y = im->h; --y >= 0;)
+ {
+ *to = *from;
+ from++;
+ to += w;
+ }
+ to += hw;
+ }
free(im->data);
im->data = data;
}
@@ -164,10 +164,10 @@ __imlib_FlipImageDiagonal(ImlibImage * im, int direction)
void
__imlib_BlurImage(ImlibImage * im, int rad)
{
- DATA32 *p1, *p2, *data;
- int x, y, mx, my, mw, mh, mt, xx, yy;
- int a, r, g, b;
- int *as, *rs, *gs, *bs;
+ DATA32 *p1, *p2, *data;
+ int x, y, mx, my, mw, mh, mt, xx, yy;
+ int a, r, g, b;
+ int *as, *rs, *gs, *bs;
if (rad < 1)
return;
@@ -178,72 +178,72 @@ __imlib_BlurImage(ImlibImage * im, int rad)
bs = malloc(sizeof(int) * im->w);
for (y = 0; y < im->h; y++)
- {
- my = y - rad;
- mh = (rad << 1) + 1;
- if (my < 0)
- {
- mh += my;
- my = 0;
- }
- if ((my + mh) > im->h)
- mh = im->h - my;
-
- p1 = data + (y * im->w);
- memset(as, 0, im->w * sizeof(int));
- memset(rs, 0, im->w * sizeof(int));
- memset(gs, 0, im->w * sizeof(int));
- memset(bs, 0, im->w * sizeof(int));
-
- for (yy = 0; yy < mh; yy++)
- {
- p2 = im->data + ((yy + my) * im->w);
- for (x = 0; x < im->w; x++)
- {
- as[x] += (*p2 >> 24) & 0xff;
- rs[x] += (*p2 >> 16) & 0xff;
- gs[x] += (*p2 >> 8) & 0xff;
- bs[x] += *p2 & 0xff;
- p2++;
- }
- }
- if (im->w > ((rad << 1) + 1))
- {
- for (x = 0; x < im->w; x++)
- {
- a = 0;
- r = 0;
- g = 0;
- b = 0;
- mx = x - rad;
- mw = (rad << 1) + 1;
- if (mx < 0)
- {
- mw += mx;
- mx = 0;
- }
- if ((mx + mw) > im->w)
- mw = im->w - mx;
- mt = mw * mh;
- for (xx = mx; xx < (mw + mx); xx++)
- {
- a += as[xx];
- r += rs[xx];
- g += gs[xx];
- b += bs[xx];
- }
- a = a / mt;
- r = r / mt;
- g = g / mt;
- b = b / mt;
- *p1 = (a << 24) | (r << 16) | (g << 8) | b;
- p1++;
- }
- }
- else
- {
- }
- }
+ {
+ my = y - rad;
+ mh = (rad << 1) + 1;
+ if (my < 0)
+ {
+ mh += my;
+ my = 0;
+ }
+ if ((my + mh) > im->h)
+ mh = im->h - my;
+
+ p1 = data + (y * im->w);
+ memset(as, 0, im->w * sizeof(int));
+ memset(rs, 0, im->w * sizeof(int));
+ memset(gs, 0, im->w * sizeof(int));
+ memset(bs, 0, im->w * sizeof(int));
+
+ for (yy = 0; yy < mh; yy++)
+ {
+ p2 = im->data + ((yy + my) * im->w);
+ for (x = 0; x < im->w; x++)
+ {
+ as[x] += (*p2 >> 24) & 0xff;
+ rs[x] += (*p2 >> 16) & 0xff;
+ gs[x] += (*p2 >> 8) & 0xff;
+ bs[x] += *p2 & 0xff;
+ p2++;
+ }
+ }
+ if (im->w > ((rad << 1) + 1))
+ {
+ for (x = 0; x < im->w; x++)
+ {
+ a = 0;
+ r = 0;
+ g = 0;
+ b = 0;
+ mx = x - rad;
+ mw = (rad << 1) + 1;
+ if (mx < 0)
+ {
+ mw += mx;
+ mx = 0;
+ }
+ if ((mx + mw) > im->w)
+ mw = im->w - mx;
+ mt = mw * mh;
+ for (xx = mx; xx < (mw + mx); xx++)
+ {
+ a += as[xx];
+ r += rs[xx];
+ g += gs[xx];
+ b += bs[xx];
+ }
+ a = a / mt;
+ r = r / mt;
+ g = g / mt;
+ b = b / mt;
+ *p1 = (a << 24) | (r << 16) | (g << 8) | b;
+ p1++;
+ }
+ }
+ else
+ {
+ }
+ }
free(as);
free(rs);
free(gs);
@@ -255,61 +255,61 @@ __imlib_BlurImage(ImlibImage * im, int rad)
void
__imlib_SharpenImage(ImlibImage * im, int rad)
{
- DATA32 *data, *p1, *p2;
- int a, r, g, b, x, y;
+ DATA32 *data, *p1, *p2;
+ int a, r, g, b, x, y;
data = malloc(im->w * im->h * sizeof(DATA32));
if (rad == 0)
return;
else
- {
- int mul, mul2, tot;
-
- mul = (rad * 4) + 1;
- mul2 = rad;
- tot = mul - (mul2 * 4);
- for (y = 1; y < (im->h - 1); y++)
- {
- p1 = im->data + 1 + (y * im->w);
- p2 = data + 1 + (y * im->w);
- for (x = 1; x < (im->w - 1); x++)
- {
- b = (int) ((p1[0]) & 0xff) * 5;
- g = (int) ((p1[0] >> 8) & 0xff) * 5;
- r = (int) ((p1[0] >> 16) & 0xff) * 5;
- a = (int) ((p1[0] >> 24) & 0xff) * 5;
- b -= (int) ((p1[-1]) & 0xff);
- g -= (int) ((p1[-1] >> 8) & 0xff);
- r -= (int) ((p1[-1] >> 16) & 0xff);
- a -= (int) ((p1[-1] >> 24) & 0xff);
- b -= (int) ((p1[1]) & 0xff);
- g -= (int) ((p1[1] >> 8) & 0xff);
- r -= (int) ((p1[1] >> 16) & 0xff);
- a -= (int) ((p1[1] >> 24) & 0xff);
- b -= (int) ((p1[-im->w]) & 0xff);
- g -= (int) ((p1[-im->w] >> 8) & 0xff);
- r -= (int) ((p1[-im->w] >> 16) & 0xff);
- a -= (int) ((p1[-im->w] >> 24) & 0xff);
- b -= (int) ((p1[im->w]) & 0xff);
- g -= (int) ((p1[im->w] >> 8) & 0xff);
- r -= (int) ((p1[im->w] >> 16) & 0xff);
- a -= (int) ((p1[im->w] >> 24) & 0xff);
-
- a = (a & ((~a) >> 16));
- a = ((a | ((a & 256) - ((a & 256) >> 8))));
- r = (r & ((~r) >> 16));
- r = ((r | ((r & 256) - ((r & 256) >> 8))));
- g = (g & ((~g) >> 16));
- g = ((g | ((g & 256) - ((g & 256) >> 8))));
- b = (b & ((~b) >> 16));
- b = ((b | ((b & 256) - ((b & 256) >> 8))));
-
- *p2 = (a << 24) | (r << 16) | (g << 8) | b;
- p2++;
- p1++;
- }
- }
- }
+ {
+ int mul, mul2, tot;
+
+ mul = (rad * 4) + 1;
+ mul2 = rad;
+ tot = mul - (mul2 * 4);
+ for (y = 1; y < (im->h - 1); y++)
+ {
+ p1 = im->data + 1 + (y * im->w);
+ p2 = data + 1 + (y * im->w);
+ for (x = 1; x < (im->w - 1); x++)
+ {
+ b = (int)((p1[0]) & 0xff) * 5;
+ g = (int)((p1[0] >> 8) & 0xff) * 5;
+ r = (int)((p1[0] >> 16) & 0xff) * 5;
+ a = (int)((p1[0] >> 24) & 0xff) * 5;
+ b -= (int)((p1[-1]) & 0xff);
+ g -= (int)((p1[-1] >> 8) & 0xff);
+ r -= (int)((p1[-1] >> 16) & 0xff);
+ a -= (int)((p1[-1] >> 24) & 0xff);
+ b -= (int)((p1[1]) & 0xff);
+ g -= (int)((p1[1] >> 8) & 0xff);
+ r -= (int)((p1[1] >> 16) & 0xff);
+ a -= (int)((p1[1] >> 24) & 0xff);
+ b -= (int)((p1[-im->w]) & 0xff);
+ g -= (int)((p1[-im->w] >> 8) & 0xff);
+ r -= (int)((p1[-im->w] >> 16) & 0xff);
+ a -= (int)((p1[-im->w] >> 24) & 0xff);
+ b -= (int)((p1[im->w]) & 0xff);
+ g -= (int)((p1[im->w] >> 8) & 0xff);
+ r -= (int)((p1[im->w] >> 16) & 0xff);
+ a -= (int)((p1[im->w] >> 24) & 0xff);
+
+ a = (a & ((~a) >> 16));
+ a = ((a | ((a & 256) - ((a & 256) >> 8))));
+ r = (r & ((~r) >> 16));
+ r = ((r | ((r & 256) - ((r & 256) >> 8))));
+ g = (g & ((~g) >> 16));
+ g = ((g | ((g & 256) - ((g & 256) >> 8))));
+ b = (b & ((~b) >> 16));
+ b = ((b | ((b & 256) - ((b & 256) >> 8))));
+
+ *p2 = (a << 24) | (r << 16) | (g << 8) | b;
+ p2++;
+ p1++;
+ }
+ }
+ }
free(im->data);
im->data = data;
}
@@ -317,72 +317,73 @@ __imlib_SharpenImage(ImlibImage * im, int rad)
void
__imlib_TileImageHoriz(ImlibImage * im)
{
- DATA32 *p1, *p2, *p3, *p, *data;
- int x, y, per, tmp, na, nr, ng, nb, mix, a, r, g, b, aa, rr, gg, bb;
+ DATA32 *p1, *p2, *p3, *p, *data;
+ int x, y, per, tmp, na, nr, ng, nb, mix, a, r, g, b, aa, rr,
+ gg, bb;
data = malloc(im->w * im->h * sizeof(DATA32));
p1 = im->data;
p = data;
for (y = 0; y < im->h; y++)
- {
- p2 = p1 + (im->w >> 1);
- p3 = p1;
- per = (im->w >> 1);
- for (x = 0; x < (im->w >> 1); x++)
- {
- mix = (x * 255) / per;
- b = (*p1) & 0xff;
- g = (*p1 >> 8) & 0xff;
- r = (*p1 >> 16) & 0xff;
- a = (*p1 >> 24) & 0xff;
-
- bb = (*p2) & 0xff;
- gg = (*p2 >> 8) & 0xff;
- rr = (*p2 >> 16) & 0xff;
- aa = (*p2 >> 24) & 0xff;
-
- tmp = (r - rr) * mix;
- nr = rr + ((tmp + (tmp >> 8) + 0x80) >> 8);
- tmp = (g - gg) * mix;
- ng = gg + ((tmp + (tmp >> 8) + 0x80) >> 8);
- tmp = (b - bb) * mix;
- nb = bb + ((tmp + (tmp >> 8) + 0x80) >> 8);
- tmp = (a - aa) * mix;
- na = aa + ((tmp + (tmp >> 8) + 0x80) >> 8);
- *p = (na << 24) | (nr << 16) | (ng << 8) | nb;
- p++;
- p1++;
- p2++;
- }
- p2 = p3;
- per = (im->w - (im->w >> 1));
- for (; x < im->w; x++)
- {
- mix = ((im->w - 1 - x) * 255) / per;
- b = (*p1) & 0xff;
- g = (*p1 >> 8) & 0xff;
- r = (*p1 >> 16) & 0xff;
- a = (*p1 >> 24) & 0xff;
-
- bb = (*p2) & 0xff;
- gg = (*p2 >> 8) & 0xff;
- rr = (*p2 >> 16) & 0xff;
- aa = (*p2 >> 24) & 0xff;
-
- tmp = (r - rr) * mix;
- nr = rr + ((tmp + (tmp >> 8) + 0x80) >> 8);
- tmp = (g - gg) * mix;
- ng = gg + ((tmp + (tmp >> 8) + 0x80) >> 8);
- tmp = (b - bb) * mix;
- nb = bb + ((tmp + (tmp >> 8) + 0x80) >> 8);
- tmp = (a - aa) * mix;
- na = aa + ((tmp + (tmp >> 8) + 0x80) >> 8);
- *p = (na << 24) | (nr << 16) | (ng << 8) | nb;
- p++;
- p1++;
- p2++;
- }
- }
+ {
+ p2 = p1 + (im->w >> 1);
+ p3 = p1;
+ per = (im->w >> 1);
+ for (x = 0; x < (im->w >> 1); x++)
+ {
+ mix = (x * 255) / per;
+ b = (*p1) & 0xff;
+ g = (*p1 >> 8) & 0xff;
+ r = (*p1 >> 16) & 0xff;
+ a = (*p1 >> 24) & 0xff;
+
+ bb = (*p2) & 0xff;
+ gg = (*p2 >> 8) & 0xff;
+ rr = (*p2 >> 16) & 0xff;
+ aa = (*p2 >> 24) & 0xff;
+
+ tmp = (r - rr) * mix;
+ nr = rr + ((tmp + (tmp >> 8) + 0x80) >> 8);
+ tmp = (g - gg) * mix;
+ ng = gg + ((tmp + (tmp >> 8) + 0x80) >> 8);
+ tmp = (b - bb) * mix;
+ nb = bb + ((tmp + (tmp >> 8) + 0x80) >> 8);
+ tmp = (a - aa) * mix;
+ na = aa + ((tmp + (tmp >> 8) + 0x80) >> 8);
+ *p = (na << 24) | (nr << 16) | (ng << 8) | nb;
+ p++;
+ p1++;
+ p2++;
+ }
+ p2 = p3;
+ per = (im->w - (im->w >> 1));
+ for (; x < im->w; x++)
+ {
+ mix = ((im->w - 1 - x) * 255) / per;
+ b = (*p1) & 0xff;
+ g = (*p1 >> 8) & 0xff;
+ r = (*p1 >> 16) & 0xff;
+ a = (*p1 >> 24) & 0xff;
+
+ bb = (*p2) & 0xff;
+ gg = (*p2 >> 8) & 0xff;
+ rr = (*p2 >> 16) & 0xff;
+ aa = (*p2 >> 24) & 0xff;
+
+ tmp = (r - rr) * mix;
+ nr = rr + ((tmp + (tmp >> 8) + 0x80) >> 8);
+ tmp = (g - gg) * mix;
+ ng = gg + ((tmp + (tmp >> 8) + 0x80) >> 8);
+ tmp = (b - bb) * mix;
+ nb = bb + ((tmp + (tmp >> 8) + 0x80) >> 8);
+ tmp = (a - aa) * mix;
+ na = aa + ((tmp + (tmp >> 8) + 0x80) >> 8);
+ *p = (na << 24) | (nr << 16) | (ng << 8) | nb;
+ p++;
+ p1++;
+ p2++;
+ }
+ }
free(im->data);
im->data = data;
}
@@ -390,838 +391,839 @@ __imlib_TileImageHoriz(ImlibImage * im)
void
__imlib_TileImageVert(ImlibImage * im)
{
- DATA32 *p1, *p2, *p, *data;
- int x, y, tmp, na, nr, ng, nb, mix, a, r, g, b, aa, rr, gg, bb;
+ DATA32 *p1, *p2, *p, *data;
+ int x, y, tmp, na, nr, ng, nb, mix, a, r, g, b, aa, rr, gg,
+ bb;
data = malloc(im->w * im->h * sizeof(DATA32));
p = data;
for (y = 0; y < im->h; y++)
- {
- p1 = im->data + (y * im->w);
- if (y < (im->h >> 1))
- {
- p2 = im->data + ((y + (im->h >> 1)) * im->w);
- mix = (y * 255) / (im->h >> 1);
- }
- else
- {
- p2 = im->data + ((y - (im->h >> 1)) * im->w);
- mix = ((im->h - y) * 255) / (im->h - (im->h >> 1));
- }
- for (x = 0; x < im->w; x++)
- {
- b = (*p1) & 0xff;
- g = (*p1 >> 8) & 0xff;
- r = (*p1 >> 16) & 0xff;
- a = (*p1 >> 24) & 0xff;
-
- bb = (*p2) & 0xff;
- gg = (*p2 >> 8) & 0xff;
- rr = (*p2 >> 16) & 0xff;
- aa = (*p2 >> 24) & 0xff;
-
- tmp = (r - rr) * mix;
- nr = rr + ((tmp + (tmp >> 8) + 0x80) >> 8);
- tmp = (g - gg) * mix;
- ng = gg + ((tmp + (tmp >> 8) + 0x80) >> 8);
- tmp = (b - bb) * mix;
- nb = bb + ((tmp + (tmp >> 8) + 0x80) >> 8);
- tmp = (a - aa) * mix;
- na = aa + ((tmp + (tmp >> 8) + 0x80) >> 8);
- *p = (na << 24) | (nr << 16) | (ng << 8) | nb;
- p++;
- p1++;
- p2++;
- }
- }
+ {
+ p1 = im->data + (y * im->w);
+ if (y < (im->h >> 1))
+ {
+ p2 = im->data + ((y + (im->h >> 1)) * im->w);
+ mix = (y * 255) / (im->h >> 1);
+ }
+ else
+ {
+ p2 = im->data + ((y - (im->h >> 1)) * im->w);
+ mix = ((im->h - y) * 255) / (im->h - (im->h >> 1));
+ }
+ for (x = 0; x < im->w; x++)
+ {
+ b = (*p1) & 0xff;
+ g = (*p1 >> 8) & 0xff;
+ r = (*p1 >> 16) & 0xff;
+ a = (*p1 >> 24) & 0xff;
+
+ bb = (*p2) & 0xff;
+ gg = (*p2 >> 8) & 0xff;
+ rr = (*p2 >> 16) & 0xff;
+ aa = (*p2 >> 24) & 0xff;
+
+ tmp = (r - rr) * mix;
+ nr = rr + ((tmp + (tmp >> 8) + 0x80) >> 8);
+ tmp = (g - gg) * mix;
+ ng = gg + ((tmp + (tmp >> 8) + 0x80) >> 8);
+ tmp = (b - bb) * mix;
+ nb = bb + ((tmp + (tmp >> 8) + 0x80) >> 8);
+ tmp = (a - aa) * mix;
+ na = aa + ((tmp + (tmp >> 8) + 0x80) >> 8);
+ *p = (na << 24) | (nr << 16) | (ng << 8) | nb;
+ p++;
+ p1++;
+ p2++;
+ }
+ }
free(im->data);
im->data = data;
}
-ImlibUpdate *
+ImlibUpdate *
__imlib_draw_line(ImlibImage * im, int x1, int y1, int x2, int y2, DATA8 r,
DATA8 g, DATA8 b, DATA8 a, ImlibOp op, char make_updates)
{
- int x, y, dx, dy, yy, xx, am, tmp;
- DATA32 *p;
- DATA8 aaa, nr, ng, nb, rr, gg, bb, aa, na;
+ int x, y, dx, dy, yy, xx, am, tmp;
+ DATA32 *p;
+ DATA8 aaa, nr, ng, nb, rr, gg, bb, aa, na;
/* clip to top edge */
if ((y1 < 0) && (y2 < 0))
return NULL;
if (y1 < 0)
- {
- x1 += (y1 * (x1 - x2)) / (y2 - y1);
- y1 = 0;
- }
+ {
+ x1 += (y1 * (x1 - x2)) / (y2 - y1);
+ y1 = 0;
+ }
if (y2 < 0)
- {
- x2 += (y2 * (x1 - x2)) / (y2 - y1);
- y2 = 0;
- }
+ {
+ x2 += (y2 * (x1 - x2)) / (y2 - y1);
+ y2 = 0;
+ }
/* clip to bottom edge */
if ((y1 >= im->h) && (y2 >= im->h))
return NULL;
if (y1 >= im->h)
- {
- x1 -= ((im->h - y1) * (x1 - x2)) / (y2 - y1);
- y1 = im->h - 1;
- }
+ {
+ x1 -= ((im->h - y1) * (x1 - x2)) / (y2 - y1);
+ y1 = im->h - 1;
+ }
if (y2 >= im->h)
- {
- x2 -= ((im->h - y2) * (x1 - x2)) / (y2 - y1);
- y2 = im->h - 1;
- }
+ {
+ x2 -= ((im->h - y2) * (x1 - x2)) / (y2 - y1);
+ y2 = im->h - 1;
+ }
/* clip to left edge */
if ((x1 < 0) && (x2 < 0))
return NULL;
if (x1 < 0)
- {
- y1 += (x1 * (y1 - y2)) / (x2 - x1);
- x1 = 0;
- }
+ {
+ y1 += (x1 * (y1 - y2)) / (x2 - x1);
+ x1 = 0;
+ }
if (x2 < 0)
- {
- y2 += (x2 * (y1 - y2)) / (x2 - x1);
- x2 = 0;
- }
+ {
+ y2 += (x2 * (y1 - y2)) / (x2 - x1);
+ x2 = 0;
+ }
/* clip to right edge */
if ((x1 >= im->w) && (x2 >= im->w))
return NULL;
if (x1 >= im->w)
- {
- y1 -= ((im->w - x1) * (y1 - y2)) / (x2 - x1);
- x1 = im->w - 1;
- }
+ {
+ y1 -= ((im->w - x1) * (y1 - y2)) / (x2 - x1);
+ x1 = im->w - 1;
+ }
if (x2 >= im->w)
- {
- y2 -= ((im->w - x2) * (y1 - y2)) / (x2 - x1);
- x2 = im->w - 1;
- }
+ {
+ y2 -= ((im->w - x2) * (y1 - y2)) / (x2 - x1);
+ x2 = im->w - 1;
+ }
dx = x2 - x1;
dy = y2 - y1;
if (x1 > x2)
- {
- int tmp;
-
- tmp = x1;
- x1 = x2;
- x2 = tmp;
- tmp = y1;
- y1 = y2;
- y2 = tmp;
- dx = x2 - x1;
- dy = y2 - y1;
- }
+ {
+ int tmp;
+
+ tmp = x1;
+ x1 = x2;
+ x2 = tmp;
+ tmp = y1;
+ y1 = y2;
+ y2 = tmp;
+ dx = x2 - x1;
+ dy = y2 - y1;
+ }
switch (op)
- {
- case OP_COPY:
- /* vertical line */
- if (dx == 0)
- {
- if (y1 < y2)
- {
- p = &(im->data[(im->w * y1) + x1]);
- for (y = y1; y <= y2; y++)
- {
- BLEND(r, g, b, a, p);
- p += im->w;
- }
- if (!make_updates)
- return NULL;
- return __imlib_AddUpdate(NULL, x1, y1, 1, (y2 - y1 + 1));
- }
- else
- {
- p = &(im->data[(im->w * y2) + x1]);
- for (y = y2; y <= y1; y++)
- {
- BLEND(r, g, b, a, p);
- p += im->w;
- }
- if (!make_updates)
- return NULL;
- return __imlib_AddUpdate(NULL, x1, y2, 1, (y1 - y2 + 1));
- }
- }
- /* horizontal line */
- if (dy == 0)
- {
- if (x1 < x2)
- {
- p = &(im->data[(im->w * y1) + x1]);
- for (x = x1; x <= x2; x++)
- {
- BLEND(r, g, b, a, p);
- p++;
- }
- if (!make_updates)
- return NULL;
- return __imlib_AddUpdate(NULL, x1, y1, (x2 - x1 + 1), 1);
- }
- else
- {
- p = &(im->data[(im->w * y1) + x2]);
- for (x = x2; x <= x1; x++)
- {
- BLEND(r, g, b, a, p);
- p++;
- }
- if (!make_updates)
- return NULL;
- return __imlib_AddUpdate(NULL, x2, y1, (x1 - x2 + 1), 1);
- }
- }
- /* 1 */
- /* \ */
- /* \ */
- /* 2 */
- if (y2 > y1)
- {
- /* steep */
- if (dy > dx)
- {
- dx = ((dx << 16) / dy);
- x = x1 << 16;
- for (y = y1; y <= y2; y++)
- {
- xx = x >> 16;
- am = 256 - (((x - (xx << 16)) + 1) >> 8);
- aaa = (a * am) >> 8;
- p = &(im->data[(im->w * y) + xx]);
- BLEND(r, g, b, aaa, p);
- if (xx < (im->w - 1))
+ {
+ case OP_COPY:
+ /* vertical line */
+ if (dx == 0)
+ {
+ if (y1 < y2)
{
- am = 256 - am;
- aaa = (a * am) >> 8;
- p++;
- BLEND(r, g, b, aaa, p);
+ p = &(im->data[(im->w * y1) + x1]);
+ for (y = y1; y <= y2; y++)
+ {
+ BLEND(r, g, b, a, p);
+ p += im->w;
+ }
+ if (!make_updates)
+ return NULL;
+ return __imlib_AddUpdate(NULL, x1, y1, 1, (y2 - y1 + 1));
}
- x += dx;
- }
- if (!make_updates)
- return NULL;
- return __imlib_AddUpdate(NULL, x1, y1, (x2 - x1 + 1),
- (y2 - y1 + 1));
- }
- /* shallow */
- else
- {
- dy = ((dy << 16) / dx);
- y = y1 << 16;
- for (x = x1; x <= x2; x++)
- {
- yy = y >> 16;
- am = 256 - (((y - (yy << 16)) + 1) >> 8);
- aaa = (a * am) >> 8;
- p = &(im->data[(im->w * yy) + x]);
- BLEND(r, g, b, aaa, p);
- if (yy < (im->h - 1))
+ else
{
- am = 256 - am;
- aaa = (a * am) >> 8;
- p += im->w;
- BLEND(r, g, b, aaa, p);
+ p = &(im->data[(im->w * y2) + x1]);
+ for (y = y2; y <= y1; y++)
+ {
+ BLEND(r, g, b, a, p);
+ p += im->w;
+ }
+ if (!make_updates)
+ return NULL;
+ return __imlib_AddUpdate(NULL, x1, y2, 1, (y1 - y2 + 1));
}
- y += dy;
- }
- if (!make_updates)
- return NULL;
- return __imlib_AddUpdate(NULL, x1, y1, (x2 - x1 + 1),
- (y2 - y1 + 1));
- }
- }
- /* 2 */
- /* / */
- /* / */
- /* 1 */
- else
- {
- /* steep */
- if (-dy > dx)
- {
- dx = ((dx << 16) / -dy);
- x = (x1 + 1) << 16;
- for (y = y1; y >= y2; y--)
- {
- xx = x >> 16;
- am = (((x - (xx << 16)) + 1) >> 8);
- aaa = (a * am) >> 8;
- p = &(im->data[(im->w * y) + xx]);
- BLEND(r, g, b, aaa, p);
- if (xx < (im->w - 1))
+ }
+ /* horizontal line */
+ if (dy == 0)
+ {
+ if (x1 < x2)
{
- am = 256 - am;
- aaa = (a * am) >> 8;
- p--;
- BLEND(r, g, b, aaa, p);
+ p = &(im->data[(im->w * y1) + x1]);
+ for (x = x1; x <= x2; x++)
+ {
+ BLEND(r, g, b, a, p);
+ p++;
+ }
+ if (!make_updates)
+ return NULL;
+ return __imlib_AddUpdate(NULL, x1, y1, (x2 - x1 + 1), 1);
}
- x += dx;
- }
- if (!make_updates)
- return NULL;
- return __imlib_AddUpdate(NULL, x1, y2, (x2 - x1 + 1),
- (y1 - y2 + 1));
- }
- /* shallow */
- else
- {
- dy = ((dy << 16) / dx);
- y = y1 << 16;
- for (x = x1; x <= x2; x++)
- {
- yy = y >> 16;
- am = 256 - (((y - (yy << 16)) + 1) >> 8);
- aaa = (a * am) >> 8;
- p = &(im->data[(im->w * yy) + x]);
- BLEND(r, g, b, aaa, p);
- if (yy < (im->h - 1))
+ else
{
- am = 256 - am;
- aaa = (a * am) >> 8;
- p += im->w;
- BLEND(r, g, b, aaa, p);
+ p = &(im->data[(im->w * y1) + x2]);
+ for (x = x2; x <= x1; x++)
+ {
+ BLEND(r, g, b, a, p);
+ p++;
+ }
+ if (!make_updates)
+ return NULL;
+ return __imlib_AddUpdate(NULL, x2, y1, (x1 - x2 + 1), 1);
}
- y += dy;
- }
- if (!make_updates)
- return NULL;
- return __imlib_AddUpdate(NULL, x1, y2, (x2 - x1 + 1),
- (y1 - y2 + 1));
- }
- }
- break;
- case OP_ADD:
- /* vertical line */
- if (dx == 0)
- {
- if (y1 < y2)
- {
- p = &(im->data[(im->w * y1) + x1]);
- for (y = y1; y <= y2; y++)
- {
- BLEND_ADD(r, g, b, a, p);
- p += im->w;
- }
- if (!make_updates)
- return NULL;
- return __imlib_AddUpdate(NULL, x1, y1, 1, (y2 - y1 + 1));
- }
- else
- {
- p = &(im->data[(im->w * y2) + x1]);
- for (y = y2; y <= y1; y++)
- {
- BLEND_ADD(r, g, b, a, p);
- p += im->w;
- }
- if (!make_updates)
- return NULL;
- return __imlib_AddUpdate(NULL, x1, y2, 1, (y1 - y2 + 1));
- }
- }
- /* horizontal line */
- if (dy == 0)
- {
- if (x1 < x2)
- {
- p = &(im->data[(im->w * y1) + x1]);
- for (x = x1; x <= x2; x++)
- {
- BLEND_ADD(r, g, b, a, p);
- p++;
- }
- if (!make_updates)
- return NULL;
- return __imlib_AddUpdate(NULL, x1, y1, (x2 - x1 + 1), 1);
- }
- else
- {
- p = &(im->data[(im->w * y1) + x2]);
- for (x = x2; x <= x1; x++)
- {
- BLEND_ADD(r, g, b, a, p);
- p++;
- }
- if (!make_updates)
- return NULL;
- return __imlib_AddUpdate(NULL, x2, y1, (x1 - x2 + 1), 1);
- }
- }
- /* 1 */
- /* \ */
- /* \ */
- /* 2 */
- if (y2 > y1)
- {
- /* steep */
- if (dy > dx)
- {
- dx = ((dx << 16) / dy);
- x = x1 << 16;
- for (y = y1; y <= y2; y++)
- {
- xx = x >> 16;
- am = 256 - (((x - (xx << 16)) + 1) >> 8);
- aaa = (a * am) >> 8;
- p = &(im->data[(im->w * y) + xx]);
- BLEND_ADD(r, g, b, aaa, p);
- if (xx < (im->w - 1))
+ }
+ /* 1 */
+ /* \ */
+ /* \ */
+ /* 2 */
+ if (y2 > y1)
+ {
+ /* steep */
+ if (dy > dx)
{
- am = 256 - am;
- aaa = (a * am) >> 8;
- p++;
- BLEND_ADD(r, g, b, aaa, p);
+ dx = ((dx << 16) / dy);
+ x = x1 << 16;
+ for (y = y1; y <= y2; y++)
+ {
+ xx = x >> 16;
+ am = 256 - (((x - (xx << 16)) + 1) >> 8);
+ aaa = (a * am) >> 8;
+ p = &(im->data[(im->w * y) + xx]);
+ BLEND(r, g, b, aaa, p);
+ if (xx < (im->w - 1))
+ {
+ am = 256 - am;
+ aaa = (a * am) >> 8;
+ p++;
+ BLEND(r, g, b, aaa, p);
+ }
+ x += dx;
+ }
+ if (!make_updates)
+ return NULL;
+ return __imlib_AddUpdate(NULL, x1, y1, (x2 - x1 + 1),
+ (y2 - y1 + 1));
}
- x += dx;
- }
- if (!make_updates)
- return NULL;
- return __imlib_AddUpdate(NULL, x1, y1, (x2 - x1 + 1),
- (y2 - y1 + 1));
- }
- /* shallow */
- else
- {
- dy = ((dy << 16) / dx);
- y = y1 << 16;
- for (x = x1; x <= x2; x++)
- {
- yy = y >> 16;
- am = 256 - (((y - (yy << 16)) + 1) >> 8);
- aaa = (a * am) >> 8;
- p = &(im->data[(im->w * yy) + x]);
- BLEND_ADD(r, g, b, aaa, p);
- if (yy < (im->h - 1))
+ /* shallow */
+ else
{
- am = 256 - am;
- aaa = (a * am) >> 8;
- p += im->w;
- BLEND_ADD(r, g, b, aaa, p);
+ dy = ((dy << 16) / dx);
+ y = y1 << 16;
+ for (x = x1; x <= x2; x++)
+ {
+ yy = y >> 16;
+ am = 256 - (((y - (yy << 16)) + 1) >> 8);
+ aaa = (a * am) >> 8;
+ p = &(im->data[(im->w * yy) + x]);
+ BLEND(r, g, b, aaa, p);
+ if (yy < (im->h - 1))
+ {
+ am = 256 - am;
+ aaa = (a * am) >> 8;
+ p += im->w;
+ BLEND(r, g, b, aaa, p);
+ }
+ y += dy;
+ }
+ if (!make_updates)
+ return NULL;
+ return __imlib_AddUpdate(NULL, x1, y1, (x2 - x1 + 1),
+ (y2 - y1 + 1));
}
- y += dy;
- }
- if (!make_updates)
- return NULL;
- return __imlib_AddUpdate(NULL, x1, y1, (x2 - x1 + 1),
- (y2 - y1 + 1));
- }
- }
- /* 2 */
- /* / */
- /* / */
- /* 1 */
- else
- {
- /* steep */
- if (-dy > dx)
- {
- dx = ((dx << 16) / -dy);
- x = (x1 + 1) << 16;
- for (y = y1; y >= y2; y--)
- {
- xx = x >> 16;
- am = (((x - (xx << 16)) + 1) >> 8);
- aaa = (a * am) >> 8;
- p = &(im->data[(im->w * y) + xx]);
- BLEND_ADD(r, g, b, aaa, p);
- if (xx < (im->w - 1))
+ }
+ /* 2 */
+ /* / */
+ /* / */
+ /* 1 */
+ else
+ {
+ /* steep */
+ if (-dy > dx)
{
- am = 256 - am;
- aaa = (a * am) >> 8;
- p--;
- BLEND_ADD(r, g, b, aaa, p);
+ dx = ((dx << 16) / -dy);
+ x = (x1 + 1) << 16;
+ for (y = y1; y >= y2; y--)
+ {
+ xx = x >> 16;
+ am = (((x - (xx << 16)) + 1) >> 8);
+ aaa = (a * am) >> 8;
+ p = &(im->data[(im->w * y) + xx]);
+ BLEND(r, g, b, aaa, p);
+ if (xx < (im->w - 1))
+ {
+ am = 256 - am;
+ aaa = (a * am) >> 8;
+ p--;
+ BLEND(r, g, b, aaa, p);
+ }
+ x += dx;
+ }
+ if (!make_updates)
+ return NULL;
+ return __imlib_AddUpdate(NULL, x1, y2, (x2 - x1 + 1),
+ (y1 - y2 + 1));
}
- x += dx;
- }
- if (!make_updates)
- return NULL;
- return __imlib_AddUpdate(NULL, x1, y2, (x2 - x1 + 1),
- (y1 - y2 + 1));
- }
- /* shallow */
- else
- {
- dy = ((dy << 16) / dx);
- y = y1 << 16;
- for (x = x1; x <= x2; x++)
- {
- yy = y >> 16;
- am = 256 - (((y - (yy << 16)) + 1) >> 8);
- aaa = (a * am) >> 8;
- p = &(im->data[(im->w * yy) + x]);
- BLEND_ADD(r, g, b, aaa, p);
- if (yy < (im->h - 1))
+ /* shallow */
+ else
{
- am = 256 - am;
- aaa = (a * am) >> 8;
- p += im->w;
- BLEND_ADD(r, g, b, aaa, p);
+ dy = ((dy << 16) / dx);
+ y = y1 << 16;
+ for (x = x1; x <= x2; x++)
+ {
+ yy = y >> 16;
+ am = 256 - (((y - (yy << 16)) + 1) >> 8);
+ aaa = (a * am) >> 8;
+ p = &(im->data[(im->w * yy) + x]);
+ BLEND(r, g, b, aaa, p);
+ if (yy < (im->h - 1))
+ {
+ am = 256 - am;
+ aaa = (a * am) >> 8;
+ p += im->w;
+ BLEND(r, g, b, aaa, p);
+ }
+ y += dy;
+ }
+ if (!make_updates)
+ return NULL;
+ return __imlib_AddUpdate(NULL, x1, y2, (x2 - x1 + 1),
+ (y1 - y2 + 1));
}
- y += dy;
- }
- if (!make_updates)
- return NULL;
- return __imlib_AddUpdate(NULL, x1, y2, (x2 - x1 + 1),
- (y1 - y2 + 1));
- }
- }
- break;
- case OP_SUBTRACT:
- /* vertical line */
- if (dx == 0)
- {
- if (y1 < y2)
- {
- p = &(im->data[(im->w * y1) + x1]);
- for (y = y1; y <= y2; y++)
- {
- BLEND_SUB(r, g, b, a, p);
- p += im->w;
- }
- if (!make_updates)
- return NULL;
- return __imlib_AddUpdate(NULL, x1, y1, 1, (y2 - y1 + 1));
- }
- else
- {
- p = &(im->data[(im->w * y2) + x1]);
- for (y = y2; y <= y1; y++)
- {
- BLEND_SUB(r, g, b, a, p);
- p += im->w;
- }
- if (!make_updates)
- return NULL;
- return __imlib_AddUpdate(NULL, x1, y2, 1, (y1 - y2 + 1));
- }
- }
- /* horizontal line */
- if (dy == 0)
- {
- if (x1 < x2)
- {
- p = &(im->data[(im->w * y1) + x1]);
- for (x = x1; x <= x2; x++)
- {
- BLEND_SUB(r, g, b, a, p);
- p++;
- }
- if (!make_updates)
- return NULL;
- return __imlib_AddUpdate(NULL, x1, y1, (x2 - x1 + 1), 1);
- }
- else
- {
- p = &(im->data[(im->w * y1) + x2]);
- for (x = x2; x <= x1; x++)
- {
- BLEND_SUB(r, g, b, a, p);
- p++;
- }
- if (!make_updates)
- return NULL;
- return __imlib_AddUpdate(NULL, x2, y1, (x1 - x2 + 1), 1);
- }
- }
- /* 1 */
- /* \ */
- /* \ */
- /* 2 */
- if (y2 > y1)
- {
- /* steep */
- if (dy > dx)
- {
- dx = ((dx << 16) / dy);
- x = x1 << 16;
- for (y = y1; y <= y2; y++)
- {
- xx = x >> 16;
- am = 256 - (((x - (xx << 16)) + 1) >> 8);
- aaa = (a * am) >> 8;
- p = &(im->data[(im->w * y) + xx]);
- BLEND_SUB(r, g, b, aaa, p);
- if (xx < (im->w - 1))
+ }
+ break;
+ case OP_ADD:
+ /* vertical line */
+ if (dx == 0)
+ {
+ if (y1 < y2)
{
- am = 256 - am;
- aaa = (a * am) >> 8;
- p++;
- BLEND_SUB(r, g, b, aaa, p);
+ p = &(im->data[(im->w * y1) + x1]);
+ for (y = y1; y <= y2; y++)
+ {
+ BLEND_ADD(r, g, b, a, p);
+ p += im->w;
+ }
+ if (!make_updates)
+ return NULL;
+ return __imlib_AddUpdate(NULL, x1, y1, 1, (y2 - y1 + 1));
}
- x += dx;
- }
- if (!make_updates)
- return NULL;
- return __imlib_AddUpdate(NULL, x1, y1, (x2 - x1 + 1),
- (y2 - y1 + 1));
- }
- /* shallow */
- else
- {
- dy = ((dy << 16) / dx);
- y = y1 << 16;
- for (x = x1; x <= x2; x++)
- {
- yy = y >> 16;
- am = 256 - (((y - (yy << 16)) + 1) >> 8);
- aaa = (a * am) >> 8;
- p = &(im->data[(im->w * yy) + x]);
- BLEND_SUB(r, g, b, aaa, p);
- if (yy < (im->h - 1))
+ else
{
- am = 256 - am;
- aaa = (a * am) >> 8;
- p += im->w;
- BLEND_SUB(r, g, b, aaa, p);
+ p = &(im->data[(im->w * y2) + x1]);
+ for (y = y2; y <= y1; y++)
+ {
+ BLEND_ADD(r, g, b, a, p);
+ p += im->w;
+ }
+ if (!make_updates)
+ return NULL;
+ return __imlib_AddUpdate(NULL, x1, y2, 1, (y1 - y2 + 1));
}
- y += dy;
- }
- if (!make_updates)
- return NULL;
- return __imlib_AddUpdate(NULL, x1, y1, (x2 - x1 + 1),
- (y2 - y1 + 1));
- }
- }
- /* 2 */
- /* / */
- /* / */
- /* 1 */
- else
- {
- /* steep */
- if (-dy > dx)
- {
- dx = ((dx << 16) / -dy);
- x = (x1 + 1) << 16;
- for (y = y1; y >= y2; y--)
- {
- xx = x >> 16;
- am = (((x - (xx << 16)) + 1) >> 8);
- aaa = (a * am) >> 8;
- p = &(im->data[(im->w * y) + xx]);
- BLEND_SUB(r, g, b, aaa, p);
- if (xx < (im->w - 1))
+ }
+ /* horizontal line */
+ if (dy == 0)
+ {
+ if (x1 < x2)
{
- am = 256 - am;
- aaa = (a * am) >> 8;
- p--;
- BLEND_SUB(r, g, b, aaa, p);
+ p = &(im->data[(im->w * y1) + x1]);
+ for (x = x1; x <= x2; x++)
+ {
+ BLEND_ADD(r, g, b, a, p);
+ p++;
+ }
+ if (!make_updates)
+ return NULL;
+ return __imlib_AddUpdate(NULL, x1, y1, (x2 - x1 + 1), 1);
}
- x += dx;
- }
- if (!make_updates)
- return NULL;
- return __imlib_AddUpdate(NULL, x1, y2, (x2 - x1 + 1),
- (y1 - y2 + 1));
- }
- /* shallow */
- else
- {
- dy = ((dy << 16) / dx);
- y = y1 << 16;
- for (x = x1; x <= x2; x++)
- {
- yy = y >> 16;
- am = 256 - (((y - (yy << 16)) + 1) >> 8);
- aaa = (a * am) >> 8;
- p = &(im->data[(im->w * yy) + x]);
- BLEND_SUB(r, g, b, aaa, p);
- if (yy < (im->h - 1))
+ else
{
- am = 256 - am;
- aaa = (a * am) >> 8;
- p += im->w;
- BLEND_SUB(r, g, b, aaa, p);
+ p = &(im->data[(im->w * y1) + x2]);
+ for (x = x2; x <= x1; x++)
+ {
+ BLEND_ADD(r, g, b, a, p);
+ p++;
+ }
+ if (!make_updates)
+ return NULL;
+ return __imlib_AddUpdate(NULL, x2, y1, (x1 - x2 + 1), 1);
}
- y += dy;
- }
- if (!make_updates)
- return NULL;
- return __imlib_AddUpdate(NULL, x1, y2, (x2 - x1 + 1),
- (y1 - y2 + 1));
- }
- }
- break;
- case OP_RESHADE:
- /* vertical line */
- if (dx == 0)
- {
- if (y1 < y2)
- {
- p = &(im->data[(im->w * y1) + x1]);
- for (y = y1; y <= y2; y++)
- {
- BLEND_RE(r, g, b, a, p);
- p += im->w;
- }
- if (!make_updates)
- return NULL;
- return __imlib_AddUpdate(NULL, x1, y1, 1, (y2 - y1 + 1));
- }
- else
- {
- p = &(im->data[(im->w * y2) + x1]);
- for (y = y2; y <= y1; y++)
- {
- BLEND_RE(r, g, b, a, p);
- p += im->w;
- }
- if (!make_updates)
- return NULL;
- return __imlib_AddUpdate(NULL, x1, y2, 1, (y1 - y2 + 1));
- }
- }
- /* horizontal line */
- if (dy == 0)
- {
- if (x1 < x2)
- {
- p = &(im->data[(im->w * y1) + x1]);
- for (x = x1; x <= x2; x++)
- {
- BLEND_RE(r, g, b, a, p);
- p++;
- }
- if (!make_updates)
- return NULL;
- return __imlib_AddUpdate(NULL, x1, y1, (x2 - x1 + 1), 1);
- }
- else
- {
- p = &(im->data[(im->w * y1) + x2]);
- for (x = x2; x <= x1; x++)
- {
- BLEND_RE(r, g, b, a, p);
- p++;
- }
- if (!make_updates)
- return NULL;
- return __imlib_AddUpdate(NULL, x2, y1, (x1 - x2 + 1), 1);
- }
- }
- /* 1 */
- /* \ */
- /* \ */
- /* 2 */
- if (y2 > y1)
- {
- /* steep */
- if (dy > dx)
- {
- dx = ((dx << 16) / dy);
- x = x1 << 16;
- for (y = y1; y <= y2; y++)
- {
- xx = x >> 16;
- am = 256 - (((x - (xx << 16)) + 1) >> 8);
- aaa = (a * am) >> 8;
- p = &(im->data[(im->w * y) + xx]);
- BLEND_RE(r, g, b, aaa, p);
- if (xx < (im->w - 1))
+ }
+ /* 1 */
+ /* \ */
+ /* \ */
+ /* 2 */
+ if (y2 > y1)
+ {
+ /* steep */
+ if (dy > dx)
{
- am = 256 - am;
- aaa = (a * am) >> 8;
- p++;
- BLEND_RE(r, g, b, aaa, p);
+ dx = ((dx << 16) / dy);
+ x = x1 << 16;
+ for (y = y1; y <= y2; y++)
+ {
+ xx = x >> 16;
+ am = 256 - (((x - (xx << 16)) + 1) >> 8);
+ aaa = (a * am) >> 8;
+ p = &(im->data[(im->w * y) + xx]);
+ BLEND_ADD(r, g, b, aaa, p);
+ if (xx < (im->w - 1))
+ {
+ am = 256 - am;
+ aaa = (a * am) >> 8;
+ p++;
+ BLEND_ADD(r, g, b, aaa, p);
+ }
+ x += dx;
+ }
+ if (!make_updates)
+ return NULL;
+ return __imlib_AddUpdate(NULL, x1, y1, (x2 - x1 + 1),
+ (y2 - y1 + 1));
}
- x += dx;
- }
- if (!make_updates)
- return NULL;
- return __imlib_AddUpdate(NULL, x1, y1, (x2 - x1 + 1),
- (y2 - y1 + 1));
- }
- /* shallow */
- else
- {
- dy = ((dy << 16) / dx);
- y = y1 << 16;
- for (x = x1; x <= x2; x++)
- {
- yy = y >> 16;
- am = 256 - (((y - (yy << 16)) + 1) >> 8);
- aaa = (a * am) >> 8;
- p = &(im->data[(im->w * yy) + x]);
- BLEND_RE(r, g, b, aaa, p);
- if (yy < (im->h - 1))
+ /* shallow */
+ else
{
- am = 256 - am;
- aaa = (a * am) >> 8;
- p += im->w;
- BLEND_RE(r, g, b, aaa, p);
+ dy = ((dy << 16) / dx);
+ y = y1 << 16;
+ for (x = x1; x <= x2; x++)
+ {
+ yy = y >> 16;
+ am = 256 - (((y - (yy << 16)) + 1) >> 8);
+ aaa = (a * am) >> 8;
+ p = &(im->data[(im->w * yy) + x]);
+ BLEND_ADD(r, g, b, aaa, p);
+ if (yy < (im->h - 1))
+ {
+ am = 256 - am;
+ aaa = (a * am) >> 8;
+ p += im->w;
+ BLEND_ADD(r, g, b, aaa, p);
+ }
+ y += dy;
+ }
+ if (!make_updates)
+ return NULL;
+ return __imlib_AddUpdate(NULL, x1, y1, (x2 - x1 + 1),
+ (y2 - y1 + 1));
}
- y += dy;
- }
- if (!make_updates)
- return NULL;
- return __imlib_AddUpdate(NULL, x1, y1, (x2 - x1 + 1),
- (y2 - y1 + 1));
- }
- }
- /* 2 */
- /* / */
- /* / */
- /* 1 */
- else
- {
- /* steep */
- if (-dy > dx)
- {
- dx = ((dx << 16) / -dy);
- x = (x1 + 1) << 16;
- for (y = y1; y >= y2; y--)
- {
- xx = x >> 16;
- am = (((x - (xx << 16)) + 1) >> 8);
- aaa = (a * am) >> 8;
- p = &(im->data[(im->w * y) + xx]);
- BLEND_RE(r, g, b, aaa, p);
- if (xx < (im->w - 1))
+ }
+ /* 2 */
+ /* / */
+ /* / */
+ /* 1 */
+ else
+ {
+ /* steep */
+ if (-dy > dx)
{
- am = 256 - am;
- aaa = (a * am) >> 8;
- p--;
- BLEND_RE(r, g, b, aaa, p);
+ dx = ((dx << 16) / -dy);
+ x = (x1 + 1) << 16;
+ for (y = y1; y >= y2; y--)
+ {
+ xx = x >> 16;
+ am = (((x - (xx << 16)) + 1) >> 8);
+ aaa = (a * am) >> 8;
+ p = &(im->data[(im->w * y) + xx]);
+ BLEND_ADD(r, g, b, aaa, p);
+ if (xx < (im->w - 1))
+ {
+ am = 256 - am;
+ aaa = (a * am) >> 8;
+ p--;
+ BLEND_ADD(r, g, b, aaa, p);
+ }
+ x += dx;
+ }
+ if (!make_updates)
+ return NULL;
+ return __imlib_AddUpdate(NULL, x1, y2, (x2 - x1 + 1),
+ (y1 - y2 + 1));
}
- x += dx;
- }
- if (!make_updates)
- return NULL;
- return __imlib_AddUpdate(NULL, x1, y2, (x2 - x1 + 1),
- (y1 - y2 + 1));
- }
- /* shallow */
- else
- {
- dy = ((dy << 16) / dx);
- y = y1 << 16;
- for (x = x1; x <= x2; x++)
- {
- yy = y >> 16;
- am = 256 - (((y - (yy << 16)) + 1) >> 8);
- aaa = (a * am) >> 8;
- p = &(im->data[(im->w * yy) + x]);
- BLEND_RE(r, g, b, aaa, p);
- if (yy < (im->h - 1))
+ /* shallow */
+ else
{
- am = 256 - am;
- aaa = (a * am) >> 8;
- p += im->w;
- BLEND_RE(r, g, b, aaa, p);
+ dy = ((dy << 16) / dx);
+ y = y1 << 16;
+ for (x = x1; x <= x2; x++)
+ {
+ yy = y >> 16;
+ am = 256 - (((y - (yy << 16)) + 1) >> 8);
+ aaa = (a * am) >> 8;
+ p = &(im->data[(im->w * yy) + x]);
+ BLEND_ADD(r, g, b, aaa, p);
+ if (yy < (im->h - 1))
+ {
+ am = 256 - am;
+ aaa = (a * am) >> 8;
+ p += im->w;
+ BLEND_ADD(r, g, b, aaa, p);
+ }
+ y += dy;
+ }
+ if (!make_updates)
+ return NULL;
+ return __imlib_AddUpdate(NULL, x1, y2, (x2 - x1 + 1),
+ (y1 - y2 + 1));
}
- y += dy;
- }
- if (!make_updates)
- return NULL;
- return __imlib_AddUpdate(NULL, x1, y2, (x2 - x1 + 1),
- (y1 - y2 + 1));
- }
- }
- break;
- default:
- break;
- }
+ }
+ break;
+ case OP_SUBTRACT:
+ /* vertical line */
+ if (dx == 0)
+ {
+ if (y1 < y2)
+ {
+ p = &(im->data[(im->w * y1) + x1]);
+ for (y = y1; y <= y2; y++)
+ {
+ BLEND_SUB(r, g, b, a, p);
+ p += im->w;
+ }
+ if (!make_updates)
+ return NULL;
+ return __imlib_AddUpdate(NULL, x1, y1, 1, (y2 - y1 + 1));
+ }
+ else
+ {
+ p = &(im->data[(im->w * y2) + x1]);
+ for (y = y2; y <= y1; y++)
+ {
+ BLEND_SUB(r, g, b, a, p);
+ p += im->w;
+ }
+ if (!make_updates)
+ return NULL;
+ return __imlib_AddUpdate(NULL, x1, y2, 1, (y1 - y2 + 1));
+ }
+ }
+ /* horizontal line */
+ if (dy == 0)
+ {
+ if (x1 < x2)
+ {
+ p = &(im->data[(im->w * y1) + x1]);
+ for (x = x1; x <= x2; x++)
+ {
+ BLEND_SUB(r, g, b, a, p);
+ p++;
+ }
+ if (!make_updates)
+ return NULL;
+ return __imlib_AddUpdate(NULL, x1, y1, (x2 - x1 + 1), 1);
+ }
+ else
+ {
+ p = &(im->data[(im->w * y1) + x2]);
+ for (x = x2; x <= x1; x++)
+ {
+ BLEND_SUB(r, g, b, a, p);
+ p++;
+ }
+ if (!make_updates)
+ return NULL;
+ return __imlib_AddUpdate(NULL, x2, y1, (x1 - x2 + 1), 1);
+ }
+ }
+ /* 1 */
+ /* \ */
+ /* \ */
+ /* 2 */
+ if (y2 > y1)
+ {
+ /* steep */
+ if (dy > dx)
+ {
+ dx = ((dx << 16) / dy);
+ x = x1 << 16;
+ for (y = y1; y <= y2; y++)
+ {
+ xx = x >> 16;
+ am = 256 - (((x - (xx << 16)) + 1) >> 8);
+ aaa = (a * am) >> 8;
+ p = &(im->data[(im->w * y) + xx]);
+ BLEND_SUB(r, g, b, aaa, p);
+ if (xx < (im->w - 1))
+ {
+ am = 256 - am;
+ aaa = (a * am) >> 8;
+ p++;
+ BLEND_SUB(r, g, b, aaa, p);
+ }
+ x += dx;
+ }
+ if (!make_updates)
+ return NULL;
+ return __imlib_AddUpdate(NULL, x1, y1, (x2 - x1 + 1),
+ (y2 - y1 + 1));
+ }
+ /* shallow */
+ else
+ {
+ dy = ((dy << 16) / dx);
+ y = y1 << 16;
+ for (x = x1; x <= x2; x++)
+ {
+ yy = y >> 16;
+ am = 256 - (((y - (yy << 16)) + 1) >> 8);
+ aaa = (a * am) >> 8;
+ p = &(im->data[(im->w * yy) + x]);
+ BLEND_SUB(r, g, b, aaa, p);
+ if (yy < (im->h - 1))
+ {
+ am = 256 - am;
+ aaa = (a * am) >> 8;
+ p += im->w;
+ BLEND_SUB(r, g, b, aaa, p);
+ }
+ y += dy;
+ }
+ if (!make_updates)
+ return NULL;
+ return __imlib_AddUpdate(NULL, x1, y1, (x2 - x1 + 1),
+ (y2 - y1 + 1));
+ }
+ }
+ /* 2 */
+ /* / */
+ /* / */
+ /* 1 */
+ else
+ {
+ /* steep */
+ if (-dy > dx)
+ {
+ dx = ((dx << 16) / -dy);
+ x = (x1 + 1) << 16;
+ for (y = y1; y >= y2; y--)
+ {
+ xx = x >> 16;
+ am = (((x - (xx << 16)) + 1) >> 8);
+ aaa = (a * am) >> 8;
+ p = &(im->data[(im->w * y) + xx]);
+ BLEND_SUB(r, g, b, aaa, p);
+ if (xx < (im->w - 1))
+ {
+ am = 256 - am;
+ aaa = (a * am) >> 8;
+ p--;
+ BLEND_SUB(r, g, b, aaa, p);
+ }
+ x += dx;
+ }
+ if (!make_updates)
+ return NULL;
+ return __imlib_AddUpdate(NULL, x1, y2, (x2 - x1 + 1),
+ (y1 - y2 + 1));
+ }
+ /* shallow */
+ else
+ {
+ dy = ((dy << 16) / dx);
+ y = y1 << 16;
+ for (x = x1; x <= x2; x++)
+ {
+ yy = y >> 16;
+ am = 256 - (((y - (yy << 16)) + 1) >> 8);
+ aaa = (a * am) >> 8;
+ p = &(im->data[(im->w * yy) + x]);
+ BLEND_SUB(r, g, b, aaa, p);
+ if (yy < (im->h - 1))
+ {
+ am = 256 - am;
+ aaa = (a * am) >> 8;
+ p += im->w;
+ BLEND_SUB(r, g, b, aaa, p);
+ }
+ y += dy;
+ }
+ if (!make_updates)
+ return NULL;
+ return __imlib_AddUpdate(NULL, x1, y2, (x2 - x1 + 1),
+ (y1 - y2 + 1));
+ }
+ }
+ break;
+ case OP_RESHADE:
+ /* vertical line */
+ if (dx == 0)
+ {
+ if (y1 < y2)
+ {
+ p = &(im->data[(im->w * y1) + x1]);
+ for (y = y1; y <= y2; y++)
+ {
+ BLEND_RE(r, g, b, a, p);
+ p += im->w;
+ }
+ if (!make_updates)
+ return NULL;
+ return __imlib_AddUpdate(NULL, x1, y1, 1, (y2 - y1 + 1));
+ }
+ else
+ {
+ p = &(im->data[(im->w * y2) + x1]);
+ for (y = y2; y <= y1; y++)
+ {
+ BLEND_RE(r, g, b, a, p);
+ p += im->w;
+ }
+ if (!make_updates)
+ return NULL;
+ return __imlib_AddUpdate(NULL, x1, y2, 1, (y1 - y2 + 1));
+ }
+ }
+ /* horizontal line */
+ if (dy == 0)
+ {
+ if (x1 < x2)
+ {
+ p = &(im->data[(im->w * y1) + x1]);
+ for (x = x1; x <= x2; x++)
+ {
+ BLEND_RE(r, g, b, a, p);
+ p++;
+ }
+ if (!make_updates)
+ return NULL;
+ return __imlib_AddUpdate(NULL, x1, y1, (x2 - x1 + 1), 1);
+ }
+ else
+ {
+ p = &(im->data[(im->w * y1) + x2]);
+ for (x = x2; x <= x1; x++)
+ {
+ BLEND_RE(r, g, b, a, p);
+ p++;
+ }
+ if (!make_updates)
+ return NULL;
+ return __imlib_AddUpdate(NULL, x2, y1, (x1 - x2 + 1), 1);
+ }
+ }
+ /* 1 */
+ /* \ */
+ /* \ */
+ /* 2 */
+ if (y2 > y1)
+ {
+ /* steep */
+ if (dy > dx)
+ {
+ dx = ((dx << 16) / dy);
+ x = x1 << 16;
+ for (y = y1; y <= y2; y++)
+ {
+ xx = x >> 16;
+ am = 256 - (((x - (xx << 16)) + 1) >> 8);
+ aaa = (a * am) >> 8;
+ p = &(im->data[(im->w * y) + xx]);
+ BLEND_RE(r, g, b, aaa, p);
+ if (xx < (im->w - 1))
+ {
+ am = 256 - am;
+ aaa = (a * am) >> 8;
+ p++;
+ BLEND_RE(r, g, b, aaa, p);
+ }
+ x += dx;
+ }
+ if (!make_updates)
+ return NULL;
+ return __imlib_AddUpdate(NULL, x1, y1, (x2 - x1 + 1),
+ (y2 - y1 + 1));
+ }
+ /* shallow */
+ else
+ {
+ dy = ((dy << 16) / dx);
+ y = y1 << 16;
+ for (x = x1; x <= x2; x++)
+ {
+ yy = y >> 16;
+ am = 256 - (((y - (yy << 16)) + 1) >> 8);
+ aaa = (a * am) >> 8;
+ p = &(im->data[(im->w * yy) + x]);
+ BLEND_RE(r, g, b, aaa, p);
+ if (yy < (im->h - 1))
+ {
+ am = 256 - am;
+ aaa = (a * am) >> 8;
+ p += im->w;
+ BLEND_RE(r, g, b, aaa, p);
+ }
+ y += dy;
+ }
+ if (!make_updates)
+ return NULL;
+ return __imlib_AddUpdate(NULL, x1, y1, (x2 - x1 + 1),
+ (y2 - y1 + 1));
+ }
+ }
+ /* 2 */
+ /* / */
+ /* / */
+ /* 1 */
+ else
+ {
+ /* steep */
+ if (-dy > dx)
+ {
+ dx = ((dx << 16) / -dy);
+ x = (x1 + 1) << 16;
+ for (y = y1; y >= y2; y--)
+ {
+ xx = x >> 16;
+ am = (((x - (xx << 16)) + 1) >> 8);
+ aaa = (a * am) >> 8;
+ p = &(im->data[(im->w * y) + xx]);
+ BLEND_RE(r, g, b, aaa, p);
+ if (xx < (im->w - 1))
+ {
+ am = 256 - am;
+ aaa = (a * am) >> 8;
+ p--;
+ BLEND_RE(r, g, b, aaa, p);
+ }
+ x += dx;
+ }
+ if (!make_updates)
+ return NULL;
+ return __imlib_AddUpdate(NULL, x1, y2, (x2 - x1 + 1),
+ (y1 - y2 + 1));
+ }
+ /* shallow */
+ else
+ {
+ dy = ((dy << 16) / dx);
+ y = y1 << 16;
+ for (x = x1; x <= x2; x++)
+ {
+ yy = y >> 16;
+ am = 256 - (((y - (yy << 16)) + 1) >> 8);
+ aaa = (a * am) >> 8;
+ p = &(im->data[(im->w * yy) + x]);
+ BLEND_RE(r, g, b, aaa, p);
+ if (yy < (im->h - 1))
+ {
+ am = 256 - am;
+ aaa = (a * am) >> 8;
+ p += im->w;
+ BLEND_RE(r, g, b, aaa, p);
+ }
+ y += dy;
+ }
+ if (!make_updates)
+ return NULL;
+ return __imlib_AddUpdate(NULL, x1, y2, (x2 - x1 + 1),
+ (y1 - y2 + 1));
+ }
+ }
+ break;
+ default:
+ break;
+ }
return NULL;
}
@@ -1231,10 +1233,8 @@ __imlib_draw_box(ImlibImage * im, int x, int y, int w, int h, DATA8 r,
{
__imlib_draw_line(im, x, y, x + w - 1, y, r, g, b, a, op, 0);
__imlib_draw_line(im, x, y, x, y + h - 1, r, g, b, a, op, 0);
- __imlib_draw_line(im, x, y + h - 1, x + w - 1, y + h - 1, r, g, b, a, op,
- 0);
- __imlib_draw_line(im, x + w - 1, y, x + w - 1, y + h - 1, r, g, b, a, op,
- 0);
+ __imlib_draw_line(im, x, y + h - 1, x + w - 1, y + h - 1, r, g, b, a, op, 0);
+ __imlib_draw_line(im, x + w - 1, y, x + w - 1, y + h - 1, r, g, b, a, op, 0);
}
void
@@ -1261,15 +1261,15 @@ __imlib_draw_filled_box_clipped(ImlibImage * im, int x, int y, int w, int h,
int clip_ymax, DATA8 r, DATA8 g, DATA8 b,
DATA8 a, ImlibOp op)
{
- int yy, xx, tmp;
- DATA32 *p;
- DATA8 nr, ng, nb, rr, gg, bb, aa, na;
+ int yy, xx, tmp;
+ DATA32 *p;
+ DATA8 nr, ng, nb, rr, gg, bb, aa, na;
if (x < 0)
- {
- w += x;
- x = 0;
- }
+ {
+ w += x;
+ x = 0;
+ }
if (w <= 0)
return;
if ((x + w) > im->w)
@@ -1277,10 +1277,10 @@ __imlib_draw_filled_box_clipped(ImlibImage * im, int x, int y, int w, int h,
if (w <= 0)
return;
if (y < 0)
- {
- h += y;
- y = 0;
- }
+ {
+ h += y;
+ y = 0;
+ }
if (h <= 0)
return;
if ((y + h) > im->h)
@@ -1298,84 +1298,84 @@ __imlib_draw_filled_box_clipped(ImlibImage * im, int x, int y, int w, int h,
clip_ymax = im->h;
if (x < clip_xmin)
- {
- w -= (clip_xmin - x);
- x = clip_xmin;
- }
+ {
+ w -= (clip_xmin - x);
+ x = clip_xmin;
+ }
if ((x + w) > clip_xmax)
w = clip_xmax - x;
if (y < clip_ymin)
- {
- h -= (clip_ymin - y);
- y = clip_ymin;
- }
+ {
+ h -= (clip_ymin - y);
+ y = clip_ymin;
+ }
if ((y + h) > clip_ymax)
h = clip_ymax - y;
switch (op)
- {
- case OP_COPY:
- for (yy = 0; yy < h; yy++)
- {
- p = im->data + ((y + yy) * im->w) + x;
- for (xx = 0; xx < w; xx++)
- {
- BLEND(r, g, b, a, p);
- p++;
- }
- }
- break;
- case OP_ADD:
- for (yy = 0; yy < h; yy++)
- {
- p = im->data + ((y + yy) * im->w) + x;
- for (xx = 0; xx < w; xx++)
- {
- BLEND_ADD(r, g, b, a, p);
- p++;
- }
- }
- break;
- case OP_SUBTRACT:
- for (yy = 0; yy < h; yy++)
- {
- p = im->data + ((y + yy) * im->w) + x;
- for (xx = 0; xx < w; xx++)
- {
- BLEND_SUB(r, g, b, a, p);
- p++;
- }
- }
- break;
- case OP_RESHADE:
- for (yy = 0; yy < h; yy++)
- {
- p = im->data + ((y + yy) * im->w) + x;
- for (xx = 0; xx < w; xx++)
- {
- BLEND_RE(r, g, b, a, p);
- p++;
- }
- }
- break;
- default:
- break;
- }
+ {
+ case OP_COPY:
+ for (yy = 0; yy < h; yy++)
+ {
+ p = im->data + ((y + yy) * im->w) + x;
+ for (xx = 0; xx < w; xx++)
+ {
+ BLEND(r, g, b, a, p);
+ p++;
+ }
+ }
+ break;
+ case OP_ADD:
+ for (yy = 0; yy < h; yy++)
+ {
+ p = im->data + ((y + yy) * im->w) + x;
+ for (xx = 0; xx < w; xx++)
+ {
+ BLEND_ADD(r, g, b, a, p);
+ p++;
+ }
+ }
+ break;
+ case OP_SUBTRACT:
+ for (yy = 0; yy < h; yy++)
+ {
+ p = im->data + ((y + yy) * im->w) + x;
+ for (xx = 0; xx < w; xx++)
+ {
+ BLEND_SUB(r, g, b, a, p);
+ p++;
+ }
+ }
+ break;
+ case OP_RESHADE:
+ for (yy = 0; yy < h; yy++)
+ {
+ p = im->data + ((y + yy) * im->w) + x;
+ for (xx = 0; xx < w; xx++)
+ {
+ BLEND_RE(r, g, b, a, p);
+ p++;
+ }
+ }
+ break;
+ default:
+ break;
+ }
}
void
__imlib_draw_filled_box(ImlibImage * im, int x, int y, int w, int h, DATA8 r,
DATA8 g, DATA8 b, DATA8 a, ImlibOp op)
{
- int yy, xx, tmp;
- DATA32 *p;
- DATA8 nr, ng, nb, rr, gg, bb, aa, na;
+ int yy, xx, tmp;
+ DATA32 *p;
+ DATA8 nr, ng, nb, rr, gg, bb, aa, na;
if (x < 0)
- {
- w += x;
- x = 0;
- }
+ {
+ w += x;
+ x = 0;
+ }
if (w <= 0)
return;
if ((x + w) > im->w)
@@ -1383,10 +1383,10 @@ __imlib_draw_filled_box(ImlibImage * im, int x, int y, int w, int h, DATA8 r,
if (w <= 0)
return;
if (y < 0)
- {
- h += y;
- y = 0;
- }
+ {
+ h += y;
+ y = 0;
+ }
if (h <= 0)
return;
if ((y + h) > im->h)
@@ -1394,79 +1394,79 @@ __imlib_draw_filled_box(ImlibImage * im, int x, int y, int w, int h, DATA8 r,
if (h <= 0)
return;
switch (op)
- {
- case OP_COPY:
- for (yy = 0; yy < h; yy++)
- {
- p = im->data + ((y + yy) * im->w) + x;
- for (xx = 0; xx < w; xx++)
- {
- BLEND(r, g, b, a, p);
- p++;
- }
- }
- break;
- case OP_ADD:
- for (yy = 0; yy < h; yy++)
- {
- p = im->data + ((y + yy) * im->w) + x;
- for (xx = 0; xx < w; xx++)
- {
- BLEND_ADD(r, g, b, a, p);
- p++;
- }
- }
- break;
- case OP_SUBTRACT:
- for (yy = 0; yy < h; yy++)
- {
- p = im->data + ((y + yy) * im->w) + x;
- for (xx = 0; xx < w; xx++)
- {
- BLEND_SUB(r, g, b, a, p);
- p++;
- }
- }
- break;
- case OP_RESHADE:
- for (yy = 0; yy < h; yy++)
- {
- p = im->data + ((y + yy) * im->w) + x;
- for (xx = 0; xx < w; xx++)
- {
- BLEND_RE(r, g, b, a, p);
- p++;
- }
- }
- break;
- default:
- break;
- }
+ {
+ case OP_COPY:
+ for (yy = 0; yy < h; yy++)
+ {
+ p = im->data + ((y + yy) * im->w) + x;
+ for (xx = 0; xx < w; xx++)
+ {
+ BLEND(r, g, b, a, p);
+ p++;
+ }
+ }
+ break;
+ case OP_ADD:
+ for (yy = 0; yy < h; yy++)
+ {
+ p = im->data + ((y + yy) * im->w) + x;
+ for (xx = 0; xx < w; xx++)
+ {
+ BLEND_ADD(r, g, b, a, p);
+ p++;
+ }
+ }
+ break;
+ case OP_SUBTRACT:
+ for (yy = 0; yy < h; yy++)
+ {
+ p = im->data + ((y + yy) * im->w) + x;
+ for (xx = 0; xx < w; xx++)
+ {
+ BLEND_SUB(r, g, b, a, p);
+ p++;
+ }
+ }
+ break;
+ case OP_RESHADE:
+ for (yy = 0; yy < h; yy++)
+ {
+ p = im->data + ((y + yy) * im->w) + x;
+ for (xx = 0; xx < w; xx++)
+ {
+ BLEND_RE(r, g, b, a, p);
+ p++;
+ }
+ }
+ break;
+ default:
+ break;
+ }
}
void
__imlib_copy_image_data(ImlibImage * im, int x, int y, int w, int h, int nx,
int ny)
{
- int xx, yy, jump;
- DATA32 *p1, *p2;
+ int xx, yy, jump;
+ DATA32 *p1, *p2;
/* clip horizontal co-ordinates so that both dest and src fit inside */
/* the image */
if (x < 0)
- {
- w += x;
- nx -= x;
- x = 0;
- }
+ {
+ w += x;
+ nx -= x;
+ x = 0;
+ }
if (w <= 0)
return;
if (nx < 0)
- {
- w += nx;
- x -= nx;
- nx = 0;
- }
+ {
+ w += nx;
+ x -= nx;
+ nx = 0;
+ }
if (w <= 0)
return;
if ((x + w) > im->w)
@@ -1480,19 +1480,19 @@ __imlib_copy_image_data(ImlibImage * im, int x, int y, int w, int h, int nx,
/* clip vertical co-ordinates so that both dest and src fit inside */
/* the image */
if (y < 0)
- {
- h += y;
- ny -= y;
- y = 0;
- }
+ {
+ h += y;
+ ny -= y;
+ y = 0;
+ }
if (h <= 0)
return;
if (ny < 0)
- {
- h += ny;
- y -= ny;
- ny = 0;
- }
+ {
+ h += ny;
+ y -= ny;
+ ny = 0;
+ }
if (h <= 0)
return;
if ((y + h) > im->h)
@@ -1511,64 +1511,64 @@ __imlib_copy_image_data(ImlibImage * im, int x, int y, int w, int h, int nx,
jump = (im->w - w);
/* dest < src address - we can copy forwards */
if (p2 < p1)
- {
- /* work our way thru the array */
- for (yy = 0; yy < h; yy++)
- {
- for (xx = 0; xx < w; xx++)
- {
- *p2 = *p1;
- p1++;
- p2++;
- }
- p1 += jump;
- p2 += jump;
- }
- }
+ {
+ /* work our way thru the array */
+ for (yy = 0; yy < h; yy++)
+ {
+ for (xx = 0; xx < w; xx++)
+ {
+ *p2 = *p1;
+ p1++;
+ p2++;
+ }
+ p1 += jump;
+ p2 += jump;
+ }
+ }
/* dst > src - we must copy backwards */
else
- {
- /* new pointers to start working at (bottom-right of rect) */
- p1 = im->data + ((y + h - 1) * im->w) + x + w - 1;
- p2 = im->data + ((ny + h - 1) * im->w) + nx + w - 1;
- /* work our way thru the array */
- for (yy = 0; yy < h; yy++)
- {
- for (xx = 0; xx < w; xx++)
- {
- *p2 = *p1;
- p1--;
- p2--;
- }
- p1 -= jump;
- p2 -= jump;
- }
- }
+ {
+ /* new pointers to start working at (bottom-right of rect) */
+ p1 = im->data + ((y + h - 1) * im->w) + x + w - 1;
+ p2 = im->data + ((ny + h - 1) * im->w) + nx + w - 1;
+ /* work our way thru the array */
+ for (yy = 0; yy < h; yy++)
+ {
+ for (xx = 0; xx < w; xx++)
+ {
+ *p2 = *p1;
+ p1--;
+ p2--;
+ }
+ p1 -= jump;
+ p2 -= jump;
+ }
+ }
}
void
__imlib_copy_alpha_data(ImlibImage * src, ImlibImage * dst, int x, int y,
int w, int h, int nx, int ny)
{
- int xx, yy, jump, jump2;
- DATA32 *p1, *p2;
+ int xx, yy, jump, jump2;
+ DATA32 *p1, *p2;
/* clip horizontal co-ordinates so that both dest and src fit inside */
/* the image */
if (x < 0)
- {
- w += x;
- nx -= x;
- x = 0;
- }
+ {
+ w += x;
+ nx -= x;
+ x = 0;
+ }
if (w <= 0)
return;
if (nx < 0)
- {
- w += nx;
- x -= nx;
- nx = 0;
- }
+ {
+ w += nx;
+ x -= nx;
+ nx = 0;
+ }
if (w <= 0)
return;
if ((x + w) > src->w)
@@ -1582,19 +1582,19 @@ __imlib_copy_alpha_data(ImlibImage * src, ImlibImage * dst, int x, int y,
/* clip vertical co-ordinates so that both dest and src fit inside */
/* the image */
if (y < 0)
- {
- h += y;
- ny -= y;
- y = 0;
- }
+ {
+ h += y;
+ ny -= y;
+ y = 0;
+ }
if (h <= 0)
return;
if (ny < 0)
- {
- h += ny;
- y -= ny;
- ny = 0;
- }
+ {
+ h += ny;
+ y -= ny;
+ ny = 0;
+ }
if (h <= 0)
return;
if ((y + h) > src->h)
@@ -1614,37 +1614,37 @@ __imlib_copy_alpha_data(ImlibImage * src, ImlibImage * dst, int x, int y,
jump2 = (dst->w - w);
/* copy forwards */
if (p2 < p1)
- {
- /* work our way thru the array */
- for (yy = 0; yy < h; yy++)
- {
- for (xx = 0; xx < w; xx++)
- {
- *p2 = (*p1 & 0xff000000) | (*p2 & 0x00ffffff);
- p1++;
- p2++;
- }
- p1 += jump;
- p2 += jump2;
- }
- }
+ {
+ /* work our way thru the array */
+ for (yy = 0; yy < h; yy++)
+ {
+ for (xx = 0; xx < w; xx++)
+ {
+ *p2 = (*p1 & 0xff000000) | (*p2 & 0x00ffffff);
+ p1++;
+ p2++;
+ }
+ p1 += jump;
+ p2 += jump2;
+ }
+ }
}
-ImlibUpdate *
+ImlibUpdate *
__imlib_draw_line_clipped(ImlibImage * im, int x1, int y1, int x2, int y2,
int clip_xmin, int clip_xmax, int clip_ymin,
int clip_ymax, DATA8 r, DATA8 g, DATA8 b, DATA8 a,
ImlibOp op, char make_updates)
{
- int cx0, cx1, cy0, cy1;
+ int cx0, cx1, cy0, cy1;
if (imlib_clip_line
(x1, y1, x2, y2, clip_xmin, clip_xmax - 1, clip_ymin, clip_ymax, &cx0,
&cy0, &cx1, &cy1))
- {
- return __imlib_draw_line(im, cx0, cy0, cx1, cy1, r, g, b, a, op,
- make_updates);
- }
+ {
+ return __imlib_draw_line(im, cx0, cy0, cx1, cy1, r, g, b, a, op,
+ make_updates);
+ }
else
return NULL;
}
@@ -1654,9 +1654,9 @@ imlib_clip_line(int x0, int y0, int x1, int y1, int xmin, int xmax, int ymin,
int ymax, int *clip_x0, int *clip_y0, int *clip_x1,
int *clip_y1)
{
- ImlibOutCode outcode0, outcode1, outcode_out;
- unsigned char accept = FALSE, done = FALSE;
- double dx0, dy0, dx1, dy1;
+ ImlibOutCode outcode0, outcode1, outcode_out;
+ unsigned char accept = FALSE, done = FALSE;
+ double dx0, dy0, dx1, dy1;
dx0 = x0;
dx1 = x1;
@@ -1667,53 +1667,55 @@ imlib_clip_line(int x0, int y0, int x1, int y1, int xmin, int xmax, int ymin,
outcode1 = __imlib_comp_outcode(dx1, dy1, xmin, xmax, ymin, ymax);
do
- {
- if (!(outcode0 | outcode1))
- {
- accept = TRUE;
- done = TRUE;
- }
- else if (outcode0 & outcode1)
- done = TRUE;
- else
- {
- double x, y;
-
- outcode_out = outcode0 ? outcode0 : outcode1;
- if (outcode_out & TOP)
- {
- x = dx0 + (dx1 - dx0) * ((double) ymax - dy0) / (dy1 - dy0);
- y = ymax;
- }
- else if (outcode_out & BOTTOM)
- {
- x = dx0 + (dx1 - dx0) * ((double) ymin - dy0) / (dy1 - dy0);
- y = ymin;
- }
- else if (outcode_out & RIGHT)
- {
- y = dy0 + (dy1 - dy0) * ((double) xmax - dx0) / (dx1 - dx0);
- x = xmax;
- }
- else
- {
- y = dy0 + (dy1 - dy0) * ((double) xmin - dx0) / (dx1 - dx0);
- x = xmin;
- }
- if (outcode_out == outcode0)
- {
- dx0 = x;
- dy0 = y;
- outcode0 = __imlib_comp_outcode(dx0, dy0, xmin, xmax, ymin, ymax);
- }
- else
- {
- dx1 = x;
- dy1 = y;
- outcode1 = __imlib_comp_outcode(dx1, dy1, xmin, xmax, ymin, ymax);
- }
- }
- }
+ {
+ if (!(outcode0 | outcode1))
+ {
+ accept = TRUE;
+ done = TRUE;
+ }
+ else if (outcode0 & outcode1)
+ done = TRUE;
+ else
+ {
+ double x, y;
+
+ outcode_out = outcode0 ? outcode0 : outcode1;
+ if (outcode_out & TOP)
+ {
+ x = dx0 + (dx1 - dx0) * ((double)ymax - dy0) / (dy1 - dy0);
+ y = ymax;
+ }
+ else if (outcode_out & BOTTOM)
+ {
+ x = dx0 + (dx1 - dx0) * ((double)ymin - dy0) / (dy1 - dy0);
+ y = ymin;
+ }
+ else if (outcode_out & RIGHT)
+ {
+ y = dy0 + (dy1 - dy0) * ((double)xmax - dx0) / (dx1 - dx0);
+ x = xmax;
+ }
+ else
+ {
+ y = dy0 + (dy1 - dy0) * ((double)xmin - dx0) / (dx1 - dx0);
+ x = xmin;
+ }
+ if (outcode_out == outcode0)
+ {
+ dx0 = x;
+ dy0 = y;
+ outcode0 =
+ __imlib_comp_outcode(dx0, dy0, xmin, xmax, ymin, ymax);
+ }
+ else
+ {
+ dx1 = x;
+ dy1 = y;
+ outcode1 =
+ __imlib_comp_outcode(dx1, dy1, xmin, xmax, ymin, ymax);
+ }
+ }
+ }
while (done == FALSE);
/* round up before converting down to ints */
@@ -1730,10 +1732,11 @@ imlib_clip_line(int x0, int y0, int x1, int y1, int xmin, int xmax, int ymin,
return accept;
}
-ImlibOutCode __imlib_comp_outcode(double x, double y, double xmin,
- double xmax, double ymin, double ymax)
+ImlibOutCode
+__imlib_comp_outcode(double x, double y, double xmin,
+ double xmax, double ymin, double ymax)
{
- ImlibOutCode code = 0;
+ ImlibOutCode code = 0;
if (y > ymax)
code |= TOP;
@@ -1749,7 +1752,7 @@ ImlibOutCode __imlib_comp_outcode(double x, double y, double xmin,
ImlibPoly
__imlib_polygon_new()
{
- ImlibPoly poly;
+ ImlibPoly poly;
poly = malloc(sizeof(_ImlibPoly));
if (!poly)
@@ -1766,7 +1769,7 @@ __imlib_polygon_add_point(ImlibPoly poly, int x, int y)
poly->points = malloc(sizeof(ImlibPoint));
else
poly->points =
- realloc(poly->points, (poly->pointcount * sizeof(ImlibPoint)));
+ realloc(poly->points, (poly->pointcount * sizeof(ImlibPoint)));
poly->points[poly->pointcount - 1].x = x;
poly->points[poly->pointcount - 1].y = y;
}
@@ -1779,29 +1782,28 @@ __imlib_polygon_free(ImlibPoly poly)
free(poly);
}
-
void
__imlib_draw_polygon(ImlibImage * im, ImlibPoly poly, unsigned char closed,
DATA8 r, DATA8 g, DATA8 b, DATA8 a, ImlibOp op)
{
- int i;
+ int i;
if (!poly || !poly->points || (poly->pointcount < 2))
return;
for (i = 0; i < poly->pointcount; i++)
- {
- if (i < poly->pointcount - 1)
- __imlib_draw_line(im, poly->points[i].x, poly->points[i].y,
- poly->points[i + 1].x, poly->points[i + 1].y, r, g,
- b, a, op, 0);
- else if (closed)
- __imlib_draw_line(im, poly->points[i].x, poly->points[i].y,
- poly->points[0].x, poly->points[0].y, r, g, b, a,
- op, 0);
- else
- break;
- }
+ {
+ if (i < poly->pointcount - 1)
+ __imlib_draw_line(im, poly->points[i].x, poly->points[i].y,
+ poly->points[i + 1].x, poly->points[i + 1].y, r, g,
+ b, a, op, 0);
+ else if (closed)
+ __imlib_draw_line(im, poly->points[i].x, poly->points[i].y,
+ poly->points[0].x, poly->points[0].y, r, g, b, a,
+ op, 0);
+ else
+ break;
+ }
}
void
@@ -1810,47 +1812,47 @@ __imlib_draw_polygon_clipped(ImlibImage * im, ImlibPoly poly,
int clip_xmax, int clip_ymin, int clip_ymax,
DATA8 r, DATA8 g, DATA8 b, DATA8 a, ImlibOp op)
{
- int i;
+ int i;
if (!poly || !poly->points || (poly->pointcount < 2))
return;
for (i = 0; i < poly->pointcount; i++)
- {
- if (i < poly->pointcount - 1)
- __imlib_draw_line_clipped(im, poly->points[i].x, poly->points[i].y,
- poly->points[i + 1].x,
- poly->points[i + 1].y, clip_xmin,
- clip_xmax, clip_ymin, clip_ymax, r, g, b,
- a, op, 0);
- else if (closed)
- __imlib_draw_line_clipped(im, poly->points[i].x, poly->points[i].y,
- poly->points[0].x, poly->points[0].y,
- clip_xmin, clip_xmax, clip_ymin, clip_ymax,
- r, g, b, a, op, 0);
- else
- break;
- }
+ {
+ if (i < poly->pointcount - 1)
+ __imlib_draw_line_clipped(im, poly->points[i].x, poly->points[i].y,
+ poly->points[i + 1].x,
+ poly->points[i + 1].y, clip_xmin,
+ clip_xmax, clip_ymin, clip_ymax, r, g, b,
+ a, op, 0);
+ else if (closed)
+ __imlib_draw_line_clipped(im, poly->points[i].x, poly->points[i].y,
+ poly->points[0].x, poly->points[0].y,
+ clip_xmin, clip_xmax, clip_ymin, clip_ymax,
+ r, g, b, a, op, 0);
+ else
+ break;
+ }
}
void
__imlib_polygon_get_bounds(ImlibPoly poly, int *px1, int *py1, int *px2,
int *py2)
{
- int x1 = 0, y1 = 0, x2 = 0, y2 = 0;
- int i;
-
- *px1=0;
- *py1=0;
- *px2=0;
- *py2=0;
-
+ int x1 = 0, y1 = 0, x2 = 0, y2 = 0;
+ int i;
+
+ *px1 = 0;
+ *py1 = 0;
+ *px2 = 0;
+ *py2 = 0;
+
if (!poly || !poly->points || (poly->pointcount < 1))
return;
x1 = x2 = poly->points[0].x;
y1 = y2 = poly->points[0].y;
-
+
for (i = 1; i < poly->pointcount; i++)
GROW_BOUNDS(x1, y1, x2, y2, poly->points[i].x, poly->points[i].y);
@@ -1864,36 +1866,34 @@ void
__imlib_draw_ellipse(ImlibImage * im, int xc, int yc, int aa, int bb, DATA8 r,
DATA8 g, DATA8 b, DATA8 a, ImlibOp op)
{
- int a2 = aa * aa;
- int b2 = bb * bb;
+ int a2 = aa * aa;
+ int b2 = bb * bb;
- int x, y, dec;
+ int x, y, dec;
- for (x = 0, y = bb, dec = 2 * b2 + a2 * (1 - 2 * bb); b2 * x <= a2 * y;
- x++)
- {
- __imlib_draw_set_point(im, xc + x, yc + y, r, g, b, a, op);
- __imlib_draw_set_point(im, xc - x, yc + y, r, g, b, a, op);
- __imlib_draw_set_point(im, xc + x, yc - y, r, g, b, a, op);
- __imlib_draw_set_point(im, xc - x, yc - y, r, g, b, a, op);
-
- if (dec >= 0)
- dec += 4 * a2 * (1 - (y--));
- dec += b2 * (4 * x + 6);
- }
+ for (x = 0, y = bb, dec = 2 * b2 + a2 * (1 - 2 * bb); b2 * x <= a2 * y; x++)
+ {
+ __imlib_draw_set_point(im, xc + x, yc + y, r, g, b, a, op);
+ __imlib_draw_set_point(im, xc - x, yc + y, r, g, b, a, op);
+ __imlib_draw_set_point(im, xc + x, yc - y, r, g, b, a, op);
+ __imlib_draw_set_point(im, xc - x, yc - y, r, g, b, a, op);
+
+ if (dec >= 0)
+ dec += 4 * a2 * (1 - (y--));
+ dec += b2 * (4 * x + 6);
+ }
- for (x = aa, y = 0, dec = 2 * a2 + b2 * (1 - 2 * aa); a2 * y <= b2 * x;
- y++)
- {
- __imlib_draw_set_point(im, xc + x, yc + y, r, g, b, a, op);
- __imlib_draw_set_point(im, xc - x, yc + y, r, g, b, a, op);
- __imlib_draw_set_point(im, xc + x, yc - y, r, g, b, a, op);
- __imlib_draw_set_point(im, xc - x, yc - y, r, g, b, a, op);
-
- if (dec >= 0)
- dec += 4 * b2 * (1 - (x--));
- dec += a2 * (4 * y + 6);
- }
+ for (x = aa, y = 0, dec = 2 * a2 + b2 * (1 - 2 * aa); a2 * y <= b2 * x; y++)
+ {
+ __imlib_draw_set_point(im, xc + x, yc + y, r, g, b, a, op);
+ __imlib_draw_set_point(im, xc - x, yc + y, r, g, b, a, op);
+ __imlib_draw_set_point(im, xc + x, yc - y, r, g, b, a, op);
+ __imlib_draw_set_point(im, xc - x, yc - y, r, g, b, a, op);
+
+ if (dec >= 0)
+ dec += 4 * b2 * (1 - (x--));
+ dec += a2 * (4 * y + 6);
+ }
}
void
@@ -1902,18 +1902,19 @@ __imlib_fill_ellipse(ImlibImage * im, int xc, int yc, int aa, int bb,
int clip_ymax, DATA8 r, DATA8 g, DATA8 b, DATA8 a,
ImlibOp op, unsigned char antialias)
{
- int a2 = aa * aa;
- int b2 = bb * bb;
- int y;
- int x, dec;
- int miny, maxy;
- int clip = 0;
+ int a2 = aa * aa;
+ int b2 = bb * bb;
+ int y;
+ int x, dec;
+ int miny, maxy;
+ int clip = 0;
- edgeRec *table1, *table2;
+ edgeRec *table1, *table2;
- if((clip_xmin != 0) && (clip_ymin != 0) && (clip_xmax != -1) && (clip_ymax != -1))
+ if ((clip_xmin != 0) && (clip_ymin != 0) && (clip_xmax != -1)
+ && (clip_ymax != -1))
clip = 1;
-
+
table1 = malloc(sizeof(edgeRec) * (im->h + 1));
table2 = malloc(sizeof(edgeRec) * (im->h + 1));
memset(table1, 0, sizeof(edgeRec) * (im->h + 1));
@@ -1922,45 +1923,43 @@ __imlib_fill_ellipse(ImlibImage * im, int xc, int yc, int aa, int bb,
miny = yc - bb - 1;
maxy = yc + bb + 1;
- for (x = 0, y = bb, dec = 2 * b2 + a2 * (1 - 2 * bb); b2 * x <= a2 * y;
- x++)
- {
- if (((yc - y) >= 0) && ((yc - y) < im->h))
- {
- table1[yc - y].x = xc - x;
- table2[yc - y].x = xc + x;
- }
-
- if (((yc + y) >= 0) && ((yc + y) < im->h))
- {
- table1[yc + y].x = xc - x;
- table2[yc + y].x = xc + x;
- }
-
- if (dec >= 0.0)
- dec += 4.0 * a2 * (1 - (y--));
- dec += b2 * (4 * x + 6);
- }
+ for (x = 0, y = bb, dec = 2 * b2 + a2 * (1 - 2 * bb); b2 * x <= a2 * y; x++)
+ {
+ if (((yc - y) >= 0) && ((yc - y) < im->h))
+ {
+ table1[yc - y].x = xc - x;
+ table2[yc - y].x = xc + x;
+ }
+
+ if (((yc + y) >= 0) && ((yc + y) < im->h))
+ {
+ table1[yc + y].x = xc - x;
+ table2[yc + y].x = xc + x;
+ }
+
+ if (dec >= 0.0)
+ dec += 4.0 * a2 * (1 - (y--));
+ dec += b2 * (4 * x + 6);
+ }
- for (x = aa, y = 0, dec = 2 * a2 + b2 * (1 - 2 * aa); a2 * y <= b2 * x;
- y++)
- {
- if (((yc - y) >= 0) && ((yc - y) < im->h))
- {
- table1[yc - y].x = xc - x;
- table2[yc - y].x = xc + x;
- }
-
- if (((yc + y) >= 0) && ((yc + y) < im->h))
- {
- table1[yc + y].x = xc - x;
- table2[yc + y].x = xc + x;
- }
-
- if (dec >= 0)
- dec += 4 * b2 * (1 - (x--));
- dec += a2 * (4 * y + 6);
- }
+ for (x = aa, y = 0, dec = 2 * a2 + b2 * (1 - 2 * aa); a2 * y <= b2 * x; y++)
+ {
+ if (((yc - y) >= 0) && ((yc - y) < im->h))
+ {
+ table1[yc - y].x = xc - x;
+ table2[yc - y].x = xc + x;
+ }
+
+ if (((yc + y) >= 0) && ((yc + y) < im->h))
+ {
+ table1[yc + y].x = xc - x;
+ table2[yc + y].x = xc + x;
+ }
+
+ if (dec >= 0)
+ dec += 4 * b2 * (1 - (x--));
+ dec += a2 * (4 * y + 6);
+ }
/* clip spans to image size */
__spanlist_clip(table1, table2, &miny, &maxy, 0, im->w, 0, im->h - 1);
@@ -1970,37 +1969,40 @@ __imlib_fill_ellipse(ImlibImage * im, int xc, int yc, int aa, int bb,
__spanlist_clip(table1, table2, &miny, &maxy, clip_xmin, clip_xmax,
clip_ymin, clip_ymax);
- if (miny < 0) miny = 0;
- if (miny >= im->h)
+ if (miny < 0)
+ miny = 0;
+ if (miny >= im->h)
{
- free(table1);
- free(table2);
- return;
+ free(table1);
+ free(table2);
+ return;
}
if (maxy < 0)
{
- free(table1);
- free(table2);
- return;
+ free(table1);
+ free(table2);
+ return;
}
if (maxy >= im->h)
- maxy = im->h - 1;
+ maxy = im->h - 1;
{
do
- {
- int x1, x2;
-
- x1 = table1[miny].x;
- x2 = table2[miny].x;
- if(clip)
- {
- if (x1 < clip_xmin) x1 = clip_xmin;
- if (x2 > clip_xmax) x2 = clip_xmax;
- }
- if((x1 != x2) && (x1 < im->w))
- span(im, miny, x1, x2, r, g, b, a, op);
- miny++;
- }
+ {
+ int x1, x2;
+
+ x1 = table1[miny].x;
+ x2 = table2[miny].x;
+ if (clip)
+ {
+ if (x1 < clip_xmin)
+ x1 = clip_xmin;
+ if (x2 > clip_xmax)
+ x2 = clip_xmax;
+ }
+ if ((x1 != x2) && (x1 < im->w))
+ span(im, miny, x1, x2, r, g, b, a, op);
+ miny++;
+ }
while (miny < maxy);
}
free(table1);
@@ -2013,52 +2015,49 @@ __imlib_draw_ellipse_clipped(ImlibImage * im, int xc, int yc, int aa, int bb,
int clip_ymax, DATA8 r, DATA8 g, DATA8 b,
DATA8 a, ImlibOp op)
{
- int a2 = aa * aa;
- int b2 = bb * bb;
+ int a2 = aa * aa;
+ int b2 = bb * bb;
- int x, y, dec;
+ int x, y, dec;
- for (x = 0, y = bb, dec = 2 * b2 + a2 * (1 - 2 * bb); b2 * x <= a2 * y;
- x++)
- {
- __imlib_draw_set_point_clipped(im, xc + x, yc + y, clip_xmin, clip_xmax,
- clip_ymin, clip_ymax, r, g, b, a, op);
- __imlib_draw_set_point_clipped(im, xc - x, yc + y, clip_xmin, clip_xmax,
- clip_ymin, clip_ymax, r, g, b, a, op);
- __imlib_draw_set_point_clipped(im, xc + x, yc - y, clip_xmin, clip_xmax,
- clip_ymin, clip_ymax, r, g, b, a, op);
- __imlib_draw_set_point_clipped(im, xc - x, yc - y, clip_xmin, clip_xmax,
- clip_ymin, clip_ymax, r, g, b, a, op);
-
- if (dec >= 0)
- dec += 4 * a2 * (1 - (y--));
- dec += b2 * (4 * x + 6);
- }
+ for (x = 0, y = bb, dec = 2 * b2 + a2 * (1 - 2 * bb); b2 * x <= a2 * y; x++)
+ {
+ __imlib_draw_set_point_clipped(im, xc + x, yc + y, clip_xmin, clip_xmax,
+ clip_ymin, clip_ymax, r, g, b, a, op);
+ __imlib_draw_set_point_clipped(im, xc - x, yc + y, clip_xmin, clip_xmax,
+ clip_ymin, clip_ymax, r, g, b, a, op);
+ __imlib_draw_set_point_clipped(im, xc + x, yc - y, clip_xmin, clip_xmax,
+ clip_ymin, clip_ymax, r, g, b, a, op);
+ __imlib_draw_set_point_clipped(im, xc - x, yc - y, clip_xmin, clip_xmax,
+ clip_ymin, clip_ymax, r, g, b, a, op);
+
+ if (dec >= 0)
+ dec += 4 * a2 * (1 - (y--));
+ dec += b2 * (4 * x + 6);
+ }
- for (x = aa, y = 0, dec = 2 * a2 + b2 * (1 - 2 * aa); a2 * y <= b2 * x;
- y++)
- {
- __imlib_draw_set_point_clipped(im, xc + x, yc + y, clip_xmin, clip_xmax,
- clip_ymin, clip_ymax, r, g, b, a, op);
- __imlib_draw_set_point_clipped(im, xc - x, yc + y, clip_xmin, clip_xmax,
- clip_ymin, clip_ymax, r, g, b, a, op);
- __imlib_draw_set_point_clipped(im, xc + x, yc - y, clip_xmin, clip_xmax,
- clip_ymin, clip_ymax, r, g, b, a, op);
- __imlib_draw_set_point_clipped(im, xc - x, yc - y, clip_xmin, clip_xmax,
- clip_ymin, clip_ymax, r, g, b, a, op);
-
- if (dec >= 0)
- dec += 4 * b2 * (1 - (x--));
- dec += a2 * (4 * y + 6);
- }
+ for (x = aa, y = 0, dec = 2 * a2 + b2 * (1 - 2 * aa); a2 * y <= b2 * x; y++)
+ {
+ __imlib_draw_set_point_clipped(im, xc + x, yc + y, clip_xmin, clip_xmax,
+ clip_ymin, clip_ymax, r, g, b, a, op);
+ __imlib_draw_set_point_clipped(im, xc - x, yc + y, clip_xmin, clip_xmax,
+ clip_ymin, clip_ymax, r, g, b, a, op);
+ __imlib_draw_set_point_clipped(im, xc + x, yc - y, clip_xmin, clip_xmax,
+ clip_ymin, clip_ymax, r, g, b, a, op);
+ __imlib_draw_set_point_clipped(im, xc - x, yc - y, clip_xmin, clip_xmax,
+ clip_ymin, clip_ymax, r, g, b, a, op);
+
+ if (dec >= 0)
+ dec += 4 * b2 * (1 - (x--));
+ dec += a2 * (4 * y + 6);
+ }
}
-
static void
edge(edgeRec * table, ImlibPoint * pt1, ImlibPoint * pt2)
{
- double x, dx;
- int idy, iy1, iy2;
+ double x, dx;
+ int idy, iy1, iy2;
if (pt2->y < pt1->y)
exchange(ImlibPoint *, pt1, pt2);
@@ -2069,13 +2068,13 @@ edge(edgeRec * table, ImlibPoint * pt1, ImlibPoint * pt2)
return;
idy = MAX(2, idy - 1);
x = pt1->x;
- dx = (pt2->x - pt1->x) / (double) idy;
+ dx = (pt2->x - pt1->x) / (double)idy;
do
- {
- table[iy1].x = x;
- x += dx;
- iy1++;
- }
+ {
+ table[iy1].x = x;
+ x += dx;
+ iy1++;
+ }
while (iy1 <= iy2);
}
@@ -2083,72 +2082,71 @@ static void
span(ImlibImage * im, int y, int x1, int x2, DATA8 r, DATA8 g,
DATA8 b, DATA8 a, ImlibOp op)
{
- DATA32 *p;
- int ix1, ix2;
- int tmp;
-
- if (x1 > x2)
+ DATA32 *p;
+ int ix1, ix2;
+ int tmp;
+
+ if (x1 > x2)
{
- tmp = x1;
- x1 = x2;
- x2 = tmp;
+ tmp = x1;
+ x1 = x2;
+ x2 = tmp;
}
-
+
ix2 = x2;
ix1 = x1;
p = &(im->data[(im->w * y) + x1]);
switch (op)
{
- /* unrolled loop - on loop inside each render mode per span */
- case OP_RESHADE:
- do
- {
- BLEND_RE(r, g, b, a, p);
- p++;
- ix1++;
- }
- while (ix1 <= ix2);
- break;
- case OP_SUBTRACT:
- do
- {
- BLEND_SUB(r, g, b, a, p);
- p++;
- ix1++;
- }
- while (ix1 <= ix2);
- break;
- case OP_ADD:
- do
- {
- BLEND_ADD(r, g, b, a, p);
- p++;
- ix1++;
- }
- while (ix1 <= ix2);
- break;
- case OP_COPY:
- do
- {
- BLEND(r, g, b, a, p);
- p++;
- ix1++;
- }
- while (ix1 <= ix2);
- break;
- default:
- break;
- }
+ /* unrolled loop - on loop inside each render mode per span */
+ case OP_RESHADE:
+ do
+ {
+ BLEND_RE(r, g, b, a, p);
+ p++;
+ ix1++;
+ }
+ while (ix1 <= ix2);
+ break;
+ case OP_SUBTRACT:
+ do
+ {
+ BLEND_SUB(r, g, b, a, p);
+ p++;
+ ix1++;
+ }
+ while (ix1 <= ix2);
+ break;
+ case OP_ADD:
+ do
+ {
+ BLEND_ADD(r, g, b, a, p);
+ p++;
+ ix1++;
+ }
+ while (ix1 <= ix2);
+ break;
+ case OP_COPY:
+ do
+ {
+ BLEND(r, g, b, a, p);
+ p++;
+ ix1++;
+ }
+ while (ix1 <= ix2);
+ break;
+ default:
+ break;
+ }
}
typedef struct _span Span;
-struct _span
-{
- int x, xstart, ystart, vert, xend, yend;
- int pol, point;
- double gradient;
- Span *next;
+struct _span {
+ int x, xstart, ystart, vert, xend, yend;
+ int pol, point;
+ double gradient;
+ Span *next;
};
#define SPANS_COMMON(x1, w1, x2, w2) \
@@ -2159,247 +2157,281 @@ __imlib_draw_polygon_filled(ImlibImage * im, ImlibPoly poly, int clip_xmin,
DATA8 r, DATA8 g, DATA8 b, DATA8 a, ImlibOp op,
unsigned char antialias)
{
- Span **spans = NULL;
- int i, h, j, top, right, left, pol, ppol, dir;
-
+ Span **spans = NULL;
+ int i, h, j, top, right, left, pol, ppol, dir;
+
/* less than 3 points - not even a tirangle - abort */
- if (poly->pointcount < 3) return;
-
+ if (poly->pointcount < 3)
+ return;
+
/* if no clip is set or clip is outside image, clip it to the image */
if (clip_xmin < clip_xmax)
{
- if (clip_xmax < 0) return;
- if (clip_xmin >= im->w) return;
- if (clip_ymax < 0) return;
- if (clip_ymin >= im->h) return;
- if (clip_xmin < 0) clip_xmin = 0;
- if (clip_xmax >= im->w) clip_xmax = im->w - 1;
- if (clip_ymin < 0) clip_ymin = 0;
- if (clip_ymax >= im->h) clip_ymax = im->h - 1;
+ if (clip_xmax < 0)
+ return;
+ if (clip_xmin >= im->w)
+ return;
+ if (clip_ymax < 0)
+ return;
+ if (clip_ymin >= im->h)
+ return;
+ if (clip_xmin < 0)
+ clip_xmin = 0;
+ if (clip_xmax >= im->w)
+ clip_xmax = im->w - 1;
+ if (clip_ymin < 0)
+ clip_ymin = 0;
+ if (clip_ymax >= im->h)
+ clip_ymax = im->h - 1;
}
/* set clip to image size */
else
{
- clip_xmin = 0;
- clip_xmax = im->w - 1;
- clip_ymin = 0;
- clip_ymax = im->h - 1;
+ clip_xmin = 0;
+ clip_xmax = im->w - 1;
+ clip_ymin = 0;
+ clip_ymax = im->h - 1;
}
/* clip is invalid - ie 0 or less than size - abort */
- if (clip_ymax < clip_ymin) return;
- if (clip_xmax < clip_xmin) return;
-
+ if (clip_ymax < clip_ymin)
+ return;
+ if (clip_xmax < clip_xmin)
+ return;
+
/* allocate spanlist for the output image */
h = clip_ymax - clip_ymin + 1;
- if (h < 1) return;
+ if (h < 1)
+ return;
spans = malloc(h * sizeof(Span *));
- if (!spans) return;
+ if (!spans)
+ return;
memset(spans, 0, h * sizeof(Span *));
-
+
/* find top most poly pont */
top = 0;
left = 0;
right = 0;
- {
- int miny, maxx, minx;
-
- miny = poly->points[0].y;
- minx = poly->points[0].x;
- maxx = poly->points[0].x;
- for (j = 0; j < poly->pointcount; j++)
- {
- if (poly->points[j].y < miny)
- {
- top = j;
- miny = poly->points[j].y;
- }
- if (poly->points[j].x < minx)
- {
- left = j;
- minx = poly->points[j].x;
- }
- if (poly->points[j].x > maxx)
- {
- right = j;
- maxx = poly->points[j].x;
- }
- }
- }
+ {
+ int miny, maxx, minx;
+
+ miny = poly->points[0].y;
+ minx = poly->points[0].x;
+ maxx = poly->points[0].x;
+ for (j = 0; j < poly->pointcount; j++)
+ {
+ if (poly->points[j].y < miny)
+ {
+ top = j;
+ miny = poly->points[j].y;
+ }
+ if (poly->points[j].x < minx)
+ {
+ left = j;
+ minx = poly->points[j].x;
+ }
+ if (poly->points[j].x > maxx)
+ {
+ right = j;
+ maxx = poly->points[j].x;
+ }
+ }
+ }
/* for every point in the poly figure a span for it and the next point */
pol = 0;
ppol = 0;
dir = 1;
- if (right > top) dir = 1;
+ if (right > top)
+ dir = 1;
else if (right == top)
{
- if (left < top) dir = 1;
- else dir = -1;
+ if (left < top)
+ dir = 1;
+ else
+ dir = -1;
}
- else dir = -1;
+ else
+ dir = -1;
for (j = 0; (j != poly->pointcount) && (j != -poly->pointcount); j += dir)
{
- int pt1, pt2, x1, y1, x2, y2, vert, step;
- double grad;
-
- /* current point and next point - line connecting the 2 */
- pt1 = ((j + top) % poly->pointcount);
- pt2 = ((j + top + 1) % poly->pointcount);
- while (pt1 < 0) pt1 += poly->pointcount;
- while (pt2 < 0) pt2 += poly->pointcount;
- /* conveneince for 2 points */
- x1 = poly->points[pt1].x;
- y1 = poly->points[pt1].y;
- x2 = poly->points[pt2].x;
- y2 = poly->points[pt2].y;
- ppol = pol;
- if (y2 > y1) pol = 1;
- else pol = -1;
- vert = 0;
- grad = 0;
- /* vertical ? */
- if (x2 == x1) vert = 1;
- /* gradient */
- else grad = (double)(y2 - y1) / (double)(x2 - x1);
- /* go thru the line span by span */
- step = 1;
- if (y1 >= y2) step = -1;
- for (i = y1;;)
- {
- Span *s;
- int x, sx, bx, w;
-
- sx = x1;
- bx = x2;
- if (x2 < x1)
- {
- sx = x2;
- bx = x1;
- }
- w = clip_xmax - clip_xmin + 1;
- if (grad != 0)
- {
- double dbx;
-
- dbx = ((double)x1 + ((double)(i - y1) / grad));
- x = (int)dbx;
- if ((dbx - ((double)x)) >= 0.5) x += 1;
- }
- else if (vert) x = x1;
- else x = x1;
- if ((i >= clip_ymin) && (i <= clip_ymax))
- {
- /* for every scanline this line spans add a span point */
- s = malloc(sizeof(Span));
- if (pol == 1) s->x = x + 1;
- else s->x = x;
- s->pol = pol;
- s->xstart = x1;
- s->ystart = y1;
- s->xend = x2;
- s->yend = y2;
- s->vert = vert;
- s->gradient = grad;
- s->next = NULL;
-
- if ((i == y1) || (i == y2)) s->point = 1;
- else s->point = 0;
-
- /* actually add the scan point to the scan list array */
- if (!(spans[i - clip_ymin])) spans[i - clip_ymin] = s;
- else
- {
- Span *ps, *ss;
-
- ps = NULL;
- for (ss = spans[i - clip_ymin];
- ss;
- ss = ss->next)
- {
- if (s->x <= ss->x)
- {
- if (!ps) spans[i - clip_ymin] = s;
- else ps->next = s;
- s->next = ss;
- goto nospans;
- }
- ps = ss;
- }
- /* last span on line and still not < ss->x */
- if (ps) ps->next = s;
- nospans:
- }
- }
- if (i == y2) goto nolines;
- i += step;
- }
- nolines:
+ int pt1, pt2, x1, y1, x2, y2, vert, step;
+ double grad;
+
+ /* current point and next point - line connecting the 2 */
+ pt1 = ((j + top) % poly->pointcount);
+ pt2 = ((j + top + 1) % poly->pointcount);
+ while (pt1 < 0)
+ pt1 += poly->pointcount;
+ while (pt2 < 0)
+ pt2 += poly->pointcount;
+ /* conveneince for 2 points */
+ x1 = poly->points[pt1].x;
+ y1 = poly->points[pt1].y;
+ x2 = poly->points[pt2].x;
+ y2 = poly->points[pt2].y;
+ ppol = pol;
+ if (y2 > y1)
+ pol = 1;
+ else
+ pol = -1;
+ vert = 0;
+ grad = 0;
+ /* vertical ? */
+ if (x2 == x1)
+ vert = 1;
+ /* gradient */
+ else
+ grad = (double)(y2 - y1) / (double)(x2 - x1);
+ /* go thru the line span by span */
+ step = 1;
+ if (y1 >= y2)
+ step = -1;
+ for (i = y1;;)
+ {
+ Span *s;
+ int x, sx, bx, w;
+
+ sx = x1;
+ bx = x2;
+ if (x2 < x1)
+ {
+ sx = x2;
+ bx = x1;
+ }
+ w = clip_xmax - clip_xmin + 1;
+ if (grad != 0)
+ {
+ double dbx;
+
+ dbx = ((double)x1 + ((double)(i - y1) / grad));
+ x = (int)dbx;
+ if ((dbx - ((double)x)) >= 0.5)
+ x += 1;
+ }
+ else if (vert)
+ x = x1;
+ else
+ x = x1;
+ if ((i >= clip_ymin) && (i <= clip_ymax))
+ {
+ /* for every scanline this line spans add a span point */
+ s = malloc(sizeof(Span));
+ if (pol == 1)
+ s->x = x + 1;
+ else
+ s->x = x;
+ s->pol = pol;
+ s->xstart = x1;
+ s->ystart = y1;
+ s->xend = x2;
+ s->yend = y2;
+ s->vert = vert;
+ s->gradient = grad;
+ s->next = NULL;
+
+ if ((i == y1) || (i == y2))
+ s->point = 1;
+ else
+ s->point = 0;
+
+ /* actually add the scan point to the scan list array */
+ if (!(spans[i - clip_ymin]))
+ spans[i - clip_ymin] = s;
+ else
+ {
+ Span *ps, *ss;
+
+ ps = NULL;
+ for (ss = spans[i - clip_ymin]; ss; ss = ss->next)
+ {
+ if (s->x <= ss->x)
+ {
+ if (!ps)
+ spans[i - clip_ymin] = s;
+ else
+ ps->next = s;
+ s->next = ss;
+ goto nospans;
+ }
+ ps = ss;
+ }
+ /* last span on line and still not < ss->x */
+ if (ps)
+ ps->next = s;
+ nospans:
+ }
+ }
+ if (i == y2)
+ goto nolines;
+ i += step;
+ }
+ nolines:
}
for (i = 0; i < h; i++)
{
- Span *s;
-
- if (spans[i])
- {
- for (s = spans[i]; s; s = s->next)
- {
- if ((s->next) &&
- (s->next->x == s->x) &&
- (s->next->pol == s->pol)
- )
- {
- Span *ss;
-
- ss = s->next;
- s->next = ss->next;
- free(ss);
- }
- }
- }
- /* go thru the spans again */
- for (s = spans[i]; s; s = s->next)
- {
- int x1, x2;
- Span *ss;
-
- x1 = s->x;
- ss = s;
- s = s->next;
- /* if there is... draw it */
- if (s)
- {
- x2 = s->x;
- if ((ss->pol == 1) && (s->pol == -1))
- {
- x1 = ss->x - 1;
- x2 = s->x + 1;
- }
- if ((x1 <= clip_xmax) && (x2 > clip_xmin) && (x1 < x2))
- {
- if (x1 < clip_xmin) x1 = clip_xmin;
- if (x2 > (clip_xmax + 1)) x2 = clip_xmax + 1;
- span(im, i + clip_ymin, x1, x2 - 1, r, g, b, a, op);
- }
- }
- else
- {
- if ((x1 <= clip_xmax) && (x1 >= clip_xmin))
- span(im, i + clip_ymin, x1, x1, r, g, b, a, op);
- break;
- }
- }
+ Span *s;
+
+ if (spans[i])
+ {
+ for (s = spans[i]; s; s = s->next)
+ {
+ if ((s->next) &&
+ (s->next->x == s->x) && (s->next->pol == s->pol))
+ {
+ Span *ss;
+
+ ss = s->next;
+ s->next = ss->next;
+ free(ss);
+ }
+ }
+ }
+ /* go thru the spans again */
+ for (s = spans[i]; s; s = s->next)
+ {
+ int x1, x2;
+ Span *ss;
+
+ x1 = s->x;
+ ss = s;
+ s = s->next;
+ /* if there is... draw it */
+ if (s)
+ {
+ x2 = s->x;
+ if ((ss->pol == 1) && (s->pol == -1))
+ {
+ x1 = ss->x - 1;
+ x2 = s->x + 1;
+ }
+ if ((x1 <= clip_xmax) && (x2 > clip_xmin) && (x1 < x2))
+ {
+ if (x1 < clip_xmin)
+ x1 = clip_xmin;
+ if (x2 > (clip_xmax + 1))
+ x2 = clip_xmax + 1;
+ span(im, i + clip_ymin, x1, x2 - 1, r, g, b, a, op);
+ }
+ }
+ else
+ {
+ if ((x1 <= clip_xmax) && (x1 >= clip_xmin))
+ span(im, i + clip_ymin, x1, x1, r, g, b, a, op);
+ break;
+ }
+ }
}
/* free the spans */
for (i = 0; i < h; i++)
{
- Span *s, *ss;
-
- s = spans[i];
- while (s)
- {
- ss = s;
- s = s->next;
- free(ss);
- }
+ Span *s, *ss;
+
+ s = spans[i];
+ while (s)
+ {
+ ss = s;
+ s = s->next;
+ free(ss);
+ }
}
free(spans);
}
@@ -2408,8 +2440,8 @@ void
__spanlist_clip(edgeRec * table1, edgeRec * table2, int *sy, int *ey,
int xmin, int xmax, int ymin, int ymax)
{
- edgeRec *pt1, *pt2;
- int iy1, iy2;
+ edgeRec *pt1, *pt2;
+ int iy1, iy2;
iy1 = MAX(*sy, ymin);
iy2 = MIN(*ey, ymax);
@@ -2417,113 +2449,116 @@ __spanlist_clip(edgeRec * table1, edgeRec * table2, int *sy, int *ey,
*ey = iy2;
do
- {
- pt1 = &(table1[iy1]);
- pt2 = &(table2[iy1]);
-
- if (pt2->x < pt1->x)
- exchange(double, pt2->x, pt1->x);
- if(pt1->x < xmax) {
- pt1->x = MAX(pt1->x, xmin);
- pt2->x = MIN(pt2->x, xmax);
- }
- iy1++;
- }
+ {
+ pt1 = &(table1[iy1]);
+ pt2 = &(table2[iy1]);
+
+ if (pt2->x < pt1->x)
+ exchange(double, pt2->x, pt1->x);
+
+ if (pt1->x < xmax)
+ {
+ pt1->x = MAX(pt1->x, xmin);
+ pt2->x = MIN(pt2->x, xmax);
+ }
+ iy1++;
+ }
while (iy1 <= iy2);
}
unsigned char
__imlib_polygon_contains_point(ImlibPoly poly, int x, int y)
{
- int count = 0;
- int start = 0;
- int ysave = 0; /* initial value arbitrary */
- int cx, nx, out_x, out_y, i, n;
- int curr_x, curr_y, next_x, next_y;
+ int count = 0;
+ int start = 0;
+ int ysave = 0; /* initial value arbitrary */
+ int cx, nx, out_x, out_y, i, n;
+ int curr_x, curr_y, next_x, next_y;
/* find a vertex of poly that does not lie on the test line */
while (start < poly->pointcount && poly->points[start].y == y)
start++;
/* if one doesn't exist we will use point on segment test
- and can start with vertex 0 anyway */
+ * and can start with vertex 0 anyway */
cx = start % poly->pointcount;
out_x = poly->points[0].x;
out_y = y;
for (i = 1; i < poly->pointcount; i++)
- {
- out_x = MAX(out_x, poly->points[i].x);
- }
- out_x++; /* out now guaranteed to be outside poly */
+ {
+ out_x = MAX(out_x, poly->points[i].x);
+ }
+ out_x++; /* out now guaranteed to be outside poly */
for (n = 0; n < poly->pointcount; n++)
- {
- nx = (cx + 1) % poly->pointcount;
-
- curr_x = poly->points[cx].x;
- curr_y = poly->points[cx].y;
- next_x = poly->points[nx].x;
- next_y = poly->points[nx].y;
-
- if (__imlib_point_on_segment(x, y, curr_x, curr_y, next_x, next_y))
- return TRUE;
-
- /* ignore horizontal segments from this point on */
- if (poly->points[cx].y != poly->points[nx].y)
- {
- if (__imlib_segments_intersect
- (curr_x, curr_y, next_x, next_y, x, y, out_x, out_y))
- {
- count++;
-
- if (__imlib_point_on_segment(next_x, next_y, x, y, out_x, out_y))
- {
- /* current seg intersects test seg @ 2nd vtx
- reset ysave */
- ysave = curr_y;
- }
- if (__imlib_point_on_segment(curr_x, curr_y, x, y, out_x, out_y)
- && (ysave < y != next_y < y))
- {
- /* current seg xsects test seg @ 1st vtx and
- ysave on opposite side of test line from
- curr seg 2nd vtx;
- decrement hits (2-1) for odd parity */
- count--;
- }
- }
- }
- cx = nx;
- }
+ {
+ nx = (cx + 1) % poly->pointcount;
+
+ curr_x = poly->points[cx].x;
+ curr_y = poly->points[cx].y;
+ next_x = poly->points[nx].x;
+ next_y = poly->points[nx].y;
+
+ if (__imlib_point_on_segment(x, y, curr_x, curr_y, next_x, next_y))
+ return TRUE;
+
+ /* ignore horizontal segments from this point on */
+ if (poly->points[cx].y != poly->points[nx].y)
+ {
+ if (__imlib_segments_intersect
+ (curr_x, curr_y, next_x, next_y, x, y, out_x, out_y))
+ {
+ count++;
+
+ if (__imlib_point_on_segment
+ (next_x, next_y, x, y, out_x, out_y))
+ {
+ /* current seg intersects test seg @ 2nd vtx
+ * reset ysave */
+ ysave = curr_y;
+ }
+ if (__imlib_point_on_segment
+ (curr_x, curr_y, x, y, out_x, out_y)
+ && (ysave < y != next_y < y))
+ {
+ /* current seg xsects test seg @ 1st vtx and
+ * ysave on opposite side of test line from
+ * curr seg 2nd vtx;
+ * decrement hits (2-1) for odd parity */
+ count--;
+ }
+ }
+ }
+ cx = nx;
+ }
return (count % 2 == 1);
}
-
unsigned char
__imlib_segments_intersect(int r1_x, int r1_y, int r2_x, int r2_y, int s1_x,
int s1_y, int s2_x, int s2_y)
{
- double testS1R =
- __imlib_point_delta_from_line(s1_x, s1_y, r1_x, r1_y, r2_x, r2_y);
- double testS2R =
- __imlib_point_delta_from_line(s2_x, s2_y, r1_x, r1_y, r2_x, r2_y);
- double testR1S =
- __imlib_point_delta_from_line(r1_x, r1_y, s1_x, s1_y, s2_x, s2_y);
- double testR2S =
- __imlib_point_delta_from_line(r2_x, r2_y, s1_x, s1_y, s2_x, s2_y);
+ double testS1R =
+ __imlib_point_delta_from_line(s1_x, s1_y, r1_x, r1_y, r2_x, r2_y);
+ double testS2R =
+ __imlib_point_delta_from_line(s2_x, s2_y, r1_x, r1_y, r2_x, r2_y);
+ double testR1S =
+ __imlib_point_delta_from_line(r1_x, r1_y, s1_x, s1_y, s2_x, s2_y);
+ double testR2S =
+ __imlib_point_delta_from_line(r2_x, r2_y, s1_x, s1_y, s2_x, s2_y);
/* check if segments are collinear */
if (testS1R == 0.0 && testS2R == 0.0)
- {
- if (__imlib_point_inside_segment(s1_x, s1_y, r1_x, r1_y, r2_x, r2_y)
- || __imlib_point_inside_segment(s2_x, s2_y, r1_x, r1_y, r2_x, r2_y)
- || __imlib_point_inside_segment(r1_x, r1_y, s1_x, s1_y, s2_x, s2_y)
- || __imlib_point_inside_segment(r2_x, r2_y, s1_x, s1_y, s2_x, s2_y))
- return TRUE;
- else
- return FALSE;
- }
+ {
+ if (__imlib_point_inside_segment(s1_x, s1_y, r1_x, r1_y, r2_x, r2_y)
+ || __imlib_point_inside_segment(s2_x, s2_y, r1_x, r1_y, r2_x, r2_y)
+ || __imlib_point_inside_segment(r1_x, r1_y, s1_x, s1_y, s2_x, s2_y)
+ || __imlib_point_inside_segment(r2_x, r2_y, s1_x, s1_y, s2_x, s2_y))
+ return TRUE;
+ else
+ return FALSE;
+ }
if (testS1R * testS2R <= 0.0 && testR1S * testR2S <= 0.0)
return TRUE;
@@ -2538,9 +2573,9 @@ __imlib_point_delta_from_line(int p_x, int p_y, int s1_x, int s1_y, int s2_x,
if (s2_x - s1_x == 0.0)
return p_x - s1_x;
else
- {
- double m = (double) (s2_y - s1_y) / (double) (s2_x - s1_x);
+ {
+ double m = (double)(s2_y - s1_y) / (double)(s2_x - s1_x);
- return (p_y - s1_y - (double) (p_x - s1_x) * m);
- }
+ return (p_y - s1_y - (double)(p_x - s1_x) * m);
+ }
}
diff --git a/src/rotate.c b/src/rotate.c
index e8b2b20..900a242 100644
--- a/src/rotate.c
+++ b/src/rotate.c
@@ -50,58 +50,66 @@
/*\ Rotate by pixel sampling only, target inside source \*/
static void
-__imlib_RotateSampleInside(DATA32 *src, DATA32 *dest, int sow, int dow,
- int dw, int dh, int x, int y,
- int dxh, int dyh, int dxv, int dyv)
+__imlib_RotateSampleInside(DATA32 * src, DATA32 * dest, int sow, int dow,
+ int dw, int dh, int x, int y,
+ int dxh, int dyh, int dxv, int dyv)
{
- int i;
-
- if ((dw < 1) || (dh < 1)) return;
-
- while (1) {
- i = dw - 1;
- do {
- *dest = src[(x >> _ROTATE_PREC) + ((y >> _ROTATE_PREC) * sow)];
- /*\ RIGHT; \*/
- x += dxh;
- y += dyh;
- dest++;
- } while (--i >= 0);
- if (--dh <= 0) break;
- /*\ DOWN/LEFT; \*/
- x += dxv - dw * dxh;
- y += dyv - dw * dyh;
- dest += (dow - dw);
- }
+ int i;
+
+ if ((dw < 1) || (dh < 1))
+ return;
+
+ while (1)
+ {
+ i = dw - 1;
+ do
+ {
+ *dest = src[(x >> _ROTATE_PREC) + ((y >> _ROTATE_PREC) * sow)];
+ /*\ RIGHT; \ */
+ x += dxh;
+ y += dyh;
+ dest++;
+ } while (--i >= 0);
+ if (--dh <= 0)
+ break;
+ /*\ DOWN/LEFT; \ */
+ x += dxv - dw * dxh;
+ y += dyv - dw * dyh;
+ dest += (dow - dw);
+ }
}
/*\ Same as last function, but with antialiasing \*/
static void
-__imlib_RotateAAInside(DATA32 *src, DATA32 *dest, int sow, int dow,
- int dw, int dh, int x, int y,
- int dxh, int dyh, int dxv, int dyv)
+__imlib_RotateAAInside(DATA32 * src, DATA32 * dest, int sow, int dow,
+ int dw, int dh, int x, int y,
+ int dxh, int dyh, int dxv, int dyv)
{
- int i;
-
- if ((dw < 1) || (dh < 1)) return;
-
- while (1) {
- i = dw - 1;
- do {
- DATA32 *src_x_y = (src + (x >> _ROTATE_PREC) +
- ((y >> _ROTATE_PREC) * sow));
- INTERP_ARGB(dest, src_x_y, sow, x, y);
- /*\ RIGHT; \*/
- x += dxh;
- y += dyh;
- dest++;
- } while (--i >= 0);
- if (--dh <= 0) break;
- /*\ DOWN/LEFT; \*/
- x += dxv - dw * dxh;
- y += dyv - dw * dyh;
- dest += (dow - dw);
- }
+ int i;
+
+ if ((dw < 1) || (dh < 1))
+ return;
+
+ while (1)
+ {
+ i = dw - 1;
+ do
+ {
+ DATA32 *src_x_y = (src + (x >> _ROTATE_PREC) +
+ ((y >> _ROTATE_PREC) * sow));
+ INTERP_ARGB(dest, src_x_y, sow, x, y);
+ /*\ RIGHT; \ */
+ x += dxh;
+ y += dyh;
+ dest++;
+ } while (--i >= 0);
+ if (--dh <= 0)
+ break;
+ /*\ DOWN/LEFT; \ */
+ x += dxv - dw * dxh;
+ y += dyv - dw * dyh;
+ dest += (dow - dw);
+ }
}
/*\ NOTE: To check if v is in [b .. t) ((v >= b) && (v < t))
@@ -113,64 +121,73 @@ __imlib_RotateAAInside(DATA32 *src, DATA32 *dest, int sow, int dow,
\*/
static int
__check_inside_coords(int x, int y, int dxh, int dyh, int dxv, int dyv,
- int dw, int dh, int sw, int sh)
+ int dw, int dh, int sw, int sh)
{
sw <<= _ROTATE_PREC;
sh <<= _ROTATE_PREC;
-
+
if (((unsigned)x >= sw) || ((unsigned)y >= sh))
return 0;
- x += dxh * dw; y += dyh * dw;
+ x += dxh * dw;
+ y += dyh * dw;
if (((unsigned)x >= sw) || ((unsigned)y >= sh))
return 0;
- x += dxv * dh; y += dyv * dh;
+ x += dxv * dh;
+ y += dyv * dh;
if (((unsigned)x >= sw) || ((unsigned)y >= sh))
return 0;
- x -= dxh * dw; y -= dyh * dw;
+ x -= dxh * dw;
+ y -= dyh * dw;
if (((unsigned)x >= sw) || ((unsigned)y >= sh))
return 0;
-
+
return 1;
}
/*\ These ones don't need the target to be inside the source \*/
void
-__imlib_RotateSample(DATA32 *src, DATA32 *dest, int sow, int sw, int sh,
- int dow, int dw, int dh, int x, int y,
- int dxh, int dyh, int dxv, int dyv)
+__imlib_RotateSample(DATA32 * src, DATA32 * dest, int sow, int sw, int sh,
+ int dow, int dw, int dh, int x, int y,
+ int dxh, int dyh, int dxv, int dyv)
{
- int i;
-
- if ((dw < 1) || (dh < 1)) return;
-
- if (__check_inside_coords(x, y, dxh, dyh, dxv, dyv, dw, dh, sw, sh)) {
- __imlib_RotateSampleInside(src, dest, sow, dow, dw, dh, x, y,
- dxh, dyh, dxv, dyv);
+ int i;
+
+ if ((dw < 1) || (dh < 1))
return;
-
- }
-
+
+ if (__check_inside_coords(x, y, dxh, dyh, dxv, dyv, dw, dh, sw, sh))
+ {
+ __imlib_RotateSampleInside(src, dest, sow, dow, dw, dh, x, y,
+ dxh, dyh, dxv, dyv);
+ return;
+
+ }
+
sw <<= _ROTATE_PREC;
sh <<= _ROTATE_PREC;
- while (1) {
- i = dw - 1;
- do {
- if (((unsigned)x < sw) && ((unsigned)y < sh))
- *dest = src[(x >> _ROTATE_PREC) + ((y >> _ROTATE_PREC) * sow)];
- else *dest = 0;
- /*\ RIGHT; \*/
- x += dxh;
- y += dyh;
- dest++;
-
- } while (--i >= 0);
- if (--dh <= 0) break;
- /*\ DOWN/LEFT; \*/
- x += dxv - dw * dxh;
- y += dyv - dw * dyh;
- dest += (dow - dw);
-
- }
+ while (1)
+ {
+ i = dw - 1;
+ do
+ {
+ if (((unsigned)x < sw) && ((unsigned)y < sh))
+ *dest = src[(x >> _ROTATE_PREC) + ((y >> _ROTATE_PREC) * sow)];
+ else
+ *dest = 0;
+ /*\ RIGHT; \ */
+ x += dxh;
+ y += dyh;
+ dest++;
+
+ } while (--i >= 0);
+ if (--dh <= 0)
+ break;
+ /*\ DOWN/LEFT; \ */
+ x += dxv - dw * dxh;
+ y += dyv - dw * dyh;
+ dest += (dow - dw);
+
+ }
}
/*\ With antialiasing.
@@ -180,116 +197,152 @@ __imlib_RotateSample(DATA32 *src, DATA32 *dest, int sow, int sw, int sh,
|*| the bounding box.
\*/
void
-__imlib_RotateAA(DATA32 *src, DATA32 *dest, int sow, int sw, int sh,
- int dow, int dw, int dh, int x, int y,
- int dxh, int dyh, int dxv, int dyv)
+__imlib_RotateAA(DATA32 * src, DATA32 * dest, int sow, int sw, int sh,
+ int dow, int dw, int dh, int x, int y,
+ int dxh, int dyh, int dxv, int dyv)
{
- int i;
-
- if ((dw < 1) || (dh < 1)) return;
-
- if (__check_inside_coords(x, y, dxh, dyh, dxv, dyv, dw, dh, sw-1, sh-1)) {
- __imlib_RotateAAInside(src, dest, sow, dow, dw, dh, x, y,
- dxh, dyh, dxv, dyv);
+ int i;
+
+ if ((dw < 1) || (dh < 1))
return;
-
- }
-
- sw--; sh--;
+
+ if (__check_inside_coords(x, y, dxh, dyh, dxv, dyv, dw, dh, sw - 1, sh - 1))
+ {
+ __imlib_RotateAAInside(src, dest, sow, dow, dw, dh, x, y,
+ dxh, dyh, dxv, dyv);
+ return;
+
+ }
+
+ sw--;
+ sh--;
sw <<= _ROTATE_PREC;
sh <<= _ROTATE_PREC;
- while (1) {
- i = dw - 1;
- do {
- DATA32 *src_x_y = (src + (x >> _ROTATE_PREC) +
- ((y >> _ROTATE_PREC) * sow));
- if ((unsigned)x < sw) {
- if ((unsigned)y < sh) {
- /*\ 12
- |*| 34
- \*/
- INTERP_ARGB(dest, src_x_y, sow, x, y);
- } else if ((unsigned)(y - sh) < _ROTATE_PREC_MAX) {
- /*\ 12
- |*| ..
- \*/
- INTERP_RGB_A0(dest, src_x_y, src_x_y + 1, x, ~y);
- } else if ((unsigned)(~y) < _ROTATE_PREC_MAX) {
- /*\ ..
- |*| 34
- \*/
- INTERP_RGB_A0(dest, src_x_y + sow, src_x_y + sow + 1, x, y);
- } else *dest = 0;
- } else if ((unsigned)(x - sw) < (_ROTATE_PREC_MAX)) {
- if ((unsigned)y < sh) {
- /*\ 1.
- |*| 3.
- \*/
- INTERP_RGB_A0(dest, src_x_y, src_x_y + sow, y, ~x);
- } else if ((unsigned)(y - sh) < _ROTATE_PREC_MAX) {
- /*\ 1.
- |*| ..
- \*/
- INTERP_A000(dest, src_x_y, ~x, ~y);
- } else if ((unsigned)(~y) < _ROTATE_PREC_MAX) {
- /*\ ..
- |*| 3.
- \*/
- INTERP_A000(dest, src_x_y + sow, ~x, y);
- } else *dest = 0;
- } else if ((unsigned)(~x) < _ROTATE_PREC_MAX) {
- if ((unsigned)y < sh) {
- /*\ .2
- |*| .4
- \*/
- INTERP_RGB_A0(dest, src_x_y + 1, src_x_y + sow + 1, y, x);
- } else if ((unsigned)(y - sh) < _ROTATE_PREC_MAX) {
- /*\ .2
- |*| ..
- \*/
- INTERP_A000(dest, src_x_y + 1, x, ~y);
- } else if ((unsigned)(~y) < _ROTATE_PREC_MAX) {
- /*\ ..
- |*| .4
- \*/
- INTERP_A000(dest, src_x_y + sow + 1, x, y);
- } else *dest = 0;
- } else *dest = 0;
- /*\ RIGHT; \*/
- x += dxh;
- y += dyh;
- dest++;
-
- } while (--i >= 0);
- if (--dh <= 0) break;
- /*\ DOWN/LEFT; \*/
- x += dxv - dw * dxh;
- y += dyv - dw * dyh;
- dest += (dow - dw);
-
- }
+ while (1)
+ {
+ i = dw - 1;
+ do
+ {
+ DATA32 *src_x_y = (src + (x >> _ROTATE_PREC) +
+ ((y >> _ROTATE_PREC) * sow));
+ if ((unsigned)x < sw)
+ {
+ if ((unsigned)y < sh)
+ {
+ /*\ 12
+ * |*| 34
+ * \ */
+ INTERP_ARGB(dest, src_x_y, sow, x, y);
+ }
+ else if ((unsigned)(y - sh) < _ROTATE_PREC_MAX)
+ {
+ /*\ 12
+ * |*| ..
+ * \ */
+ INTERP_RGB_A0(dest, src_x_y, src_x_y + 1, x, ~y);
+ }
+ else if ((unsigned)(~y) < _ROTATE_PREC_MAX)
+ {
+ /*\ ..
+ * |*| 34
+ * \ */
+ INTERP_RGB_A0(dest, src_x_y + sow, src_x_y + sow + 1, x,
+ y);
+ }
+ else
+ *dest = 0;
+ }
+ else if ((unsigned)(x - sw) < (_ROTATE_PREC_MAX))
+ {
+ if ((unsigned)y < sh)
+ {
+ /*\ 1.
+ * |*| 3.
+ * \ */
+ INTERP_RGB_A0(dest, src_x_y, src_x_y + sow, y, ~x);
+ }
+ else if ((unsigned)(y - sh) < _ROTATE_PREC_MAX)
+ {
+ /*\ 1.
+ * |*| ..
+ * \ */
+ INTERP_A000(dest, src_x_y, ~x, ~y);
+ }
+ else if ((unsigned)(~y) < _ROTATE_PREC_MAX)
+ {
+ /*\ ..
+ * |*| 3.
+ * \ */
+ INTERP_A000(dest, src_x_y + sow, ~x, y);
+ }
+ else
+ *dest = 0;
+ }
+ else if ((unsigned)(~x) < _ROTATE_PREC_MAX)
+ {
+ if ((unsigned)y < sh)
+ {
+ /*\ .2
+ * |*| .4
+ * \ */
+ INTERP_RGB_A0(dest, src_x_y + 1, src_x_y + sow + 1, y,
+ x);
+ }
+ else if ((unsigned)(y - sh) < _ROTATE_PREC_MAX)
+ {
+ /*\ .2
+ * |*| ..
+ * \ */
+ INTERP_A000(dest, src_x_y + 1, x, ~y);
+ }
+ else if ((unsigned)(~y) < _ROTATE_PREC_MAX)
+ {
+ /*\ ..
+ * |*| .4
+ * \ */
+ INTERP_A000(dest, src_x_y + sow + 1, x, y);
+ }
+ else
+ *dest = 0;
+ }
+ else
+ *dest = 0;
+ /*\ RIGHT; \ */
+ x += dxh;
+ y += dyh;
+ dest++;
+
+ } while (--i >= 0);
+ if (--dh <= 0)
+ break;
+ /*\ DOWN/LEFT; \ */
+ x += dxv - dw * dxh;
+ y += dyv - dw * dyh;
+ dest += (dow - dw);
+
+ }
}
/*\ Should this be in blend.c ?? \*/
#define LINESIZE 16
void
-__imlib_BlendImageToImageSkewed(ImlibImage *im_src, ImlibImage *im_dst,
- char aa, char blend, char merge_alpha,
- int ssx, int ssy, int ssw, int ssh,
- int ddx, int ddy,
- int hsx, int hsy, int vsx, int vsy,
- ImlibColorModifier *cm, ImlibOp op,
+__imlib_BlendImageToImageSkewed(ImlibImage * im_src, ImlibImage * im_dst,
+ char aa, char blend, char merge_alpha,
+ int ssx, int ssy, int ssw, int ssh,
+ int ddx, int ddy,
+ int hsx, int hsy, int vsx, int vsy,
+ ImlibColorModifier * cm, ImlibOp op,
int clx, int cly, int clw, int clh)
{
- int x, y, dxh, dyh, dxv, dyv, i;
- double xy2;
- DATA32 *data, *src;
- int do_mmx;
+ int x, y, dxh, dyh, dxv, dyv, i;
+ double xy2;
+ DATA32 *data, *src;
+ int do_mmx;
if ((ssw < 0) || (ssh < 0))
return;
-
+
if ((!(im_src->data)) && (im_src->loader) && (im_src->loader->load))
im_src->loader->load(im_src, NULL, 0, 1);
if (!im_src->data)
@@ -298,150 +351,192 @@ __imlib_BlendImageToImageSkewed(ImlibImage *im_src, ImlibImage *im_dst,
im_dst->loader->load(im_dst, NULL, 0, 1);
if (!im_dst->data)
return;
-
+
/*\ Complicated gonio. Works on paper..
- |*| Too bad it doesn't all fit into integer math..
- \*/
- if (vsx | vsy) {
- xy2 = (double)(hsx * vsy - vsx * hsy) / _ROTATE_PREC_MAX;
- if (xy2 == 0.0) return;
- dxh = (double)(ssw * vsy) / xy2;
- dxv = (double)-(ssw * vsx) / xy2;
- dyh = (double)-(ssh * hsy) / xy2;
- dyv = (double)(ssh * hsx) / xy2;
- } else {
- xy2 = (double)(hsx * hsx + hsy * hsy) / _ROTATE_PREC_MAX;
- if (xy2 == 0.0) return;
- dxh = (double)(ssw * hsx) / xy2;
- dyh = (double)-(ssw * hsy) / xy2;
- dxv = -dyh;
- dyv = dxh;
- }
- x = - (ddx * dxh + ddy * dxv);
- y = - (ddx * dyh + ddy * dyv);
-
- if (ssx < 0) {
- x += ssx * _ROTATE_PREC_MAX;
- ssw += ssx;
- ssx = 0;
-
- }
- if (ssy < 0) {
- y += ssy * _ROTATE_PREC_MAX;
- ssh += ssy;
- ssy = 0;
-
- }
- if ((ssw + ssx) > im_src->w) ssw = im_src->w - ssx;
- if ((ssh + ssy) > im_src->h) ssh = im_src->h - ssy;
-
+ * |*| Too bad it doesn't all fit into integer math..
+ * \ */
+ if (vsx | vsy)
+ {
+ xy2 = (double)(hsx * vsy - vsx * hsy) / _ROTATE_PREC_MAX;
+ if (xy2 == 0.0)
+ return;
+ dxh = (double)(ssw * vsy) / xy2;
+ dxv = (double)-(ssw * vsx) / xy2;
+ dyh = (double)-(ssh * hsy) / xy2;
+ dyv = (double)(ssh * hsx) / xy2;
+ }
+ else
+ {
+ xy2 = (double)(hsx * hsx + hsy * hsy) / _ROTATE_PREC_MAX;
+ if (xy2 == 0.0)
+ return;
+ dxh = (double)(ssw * hsx) / xy2;
+ dyh = (double)-(ssw * hsy) / xy2;
+ dxv = -dyh;
+ dyv = dxh;
+ }
+ x = -(ddx * dxh + ddy * dxv);
+ y = -(ddx * dyh + ddy * dyv);
+
+ if (ssx < 0)
+ {
+ x += ssx * _ROTATE_PREC_MAX;
+ ssw += ssx;
+ ssx = 0;
+
+ }
+ if (ssy < 0)
+ {
+ y += ssy * _ROTATE_PREC_MAX;
+ ssh += ssy;
+ ssy = 0;
+
+ }
+ if ((ssw + ssx) > im_src->w)
+ ssw = im_src->w - ssx;
+ if ((ssh + ssy) > im_src->h)
+ ssh = im_src->h - ssy;
+
src = im_src->data + ssx + ssy * im_src->w;
data = malloc(im_dst->w * LINESIZE * sizeof(DATA32));
if (!data)
return;
- if (aa) {
- /*\ Account for virtual transparent border \*/
- x += _ROTATE_PREC_MAX;
- y += _ROTATE_PREC_MAX;
- }
+ if (aa)
+ {
+ /*\ Account for virtual transparent border \ */
+ x += _ROTATE_PREC_MAX;
+ y += _ROTATE_PREC_MAX;
+ }
#ifdef DO_MMX_ASM
do_mmx = __imlib_get_cpuid() & CPUID_MMX;
#endif
- for (i = 0; i < im_dst->h; i += LINESIZE) {
- int x2, y2, w, h, l, r;
-
- h = MIN(LINESIZE, im_dst->h - i);
-
- x2 = x + h * dxv;
- y2 = y + h * dyv;
-
- w = ssw << _ROTATE_PREC;
- h = ssh << _ROTATE_PREC;
- if (aa) {
- /*\ Account for virtual transparent border \*/
- w += 2 << _ROTATE_PREC;
- h += 2 << _ROTATE_PREC;
- }
- /*\ Pretty similar code \*/
- if (dxh > 0) {
- if (dyh > 0) {
- l = MAX(-MAX(y, y2) / dyh, -MAX(x, x2) / dxh);
- r = MIN((h - MIN(y, y2)) / dyh, (w - MIN(x, x2)) / dxh);
-
- } else if (dyh < 0) {
- l = MAX(-MAX(x, x2) / dxh, (h - MIN(y, y2)) / dyh);
- r = MIN(-MAX(y, y2) / dyh, (w - MIN(x, x2)) / dxh);
-
- } else {
- l = -MAX(x, x2) / dxh;
- r = (w - MIN(x, x2)) / dxh;
-
- }
- } else if (dxh < 0) {
- if (dyh > 0) {
- l = MAX(-MAX(y, y2) / dyh, (w - MIN(x, x2)) / dxh);
- r = MIN(-MAX(x, x2) / dxh, (h - MIN(y, y2)) / dyh);
-
- } else if (dyh < 0) {
- l = MAX((h - MIN(y, y2)) / dyh, (w - MIN(x, x2)) / dxh);
- r = MIN(-MAX(y, y2) / dyh, -MAX(x, x2) / dxh);
-
- } else {
- l = (w - MIN(x, x2)) / dxh;
- r = -MAX(x, x2) / dxh;
-
- }
-
- } else {
- if (dyh > 0) {
- l = -MAX(y, y2) / dyh;
- r = (h - MIN(y, y2)) / dyh;
-
- } else if (dyh < 0) {
- l = (h - MIN(y, y2)) / dyh;
- r = -MAX(y, y2) / dyh;
-
- } else {
- l = 0;
- r = 0;
-
- }
-
- }
- l--; r += 2; /*\ Be paranoid about roundoff errors \*/
- if (l < 0) l = 0;
- if (r > im_dst->w) r = im_dst->w;
- if (r <= l) {
- x = x2; y = y2;
- continue;
-
- }
-
- w = r - l;
- h = MIN(LINESIZE, im_dst->h - i);
- x += l * dxh;
- y += l * dyh;
- if (aa) {
- x -= _ROTATE_PREC_MAX; y -= _ROTATE_PREC_MAX;
+ for (i = 0; i < im_dst->h; i += LINESIZE)
+ {
+ int x2, y2, w, h, l, r;
+
+ h = MIN(LINESIZE, im_dst->h - i);
+
+ x2 = x + h * dxv;
+ y2 = y + h * dyv;
+
+ w = ssw << _ROTATE_PREC;
+ h = ssh << _ROTATE_PREC;
+ if (aa)
+ {
+ /*\ Account for virtual transparent border \ */
+ w += 2 << _ROTATE_PREC;
+ h += 2 << _ROTATE_PREC;
+ }
+ /*\ Pretty similar code \ */
+ if (dxh > 0)
+ {
+ if (dyh > 0)
+ {
+ l = MAX(-MAX(y, y2) / dyh, -MAX(x, x2) / dxh);
+ r = MIN((h - MIN(y, y2)) / dyh, (w - MIN(x, x2)) / dxh);
+
+ }
+ else if (dyh < 0)
+ {
+ l = MAX(-MAX(x, x2) / dxh, (h - MIN(y, y2)) / dyh);
+ r = MIN(-MAX(y, y2) / dyh, (w - MIN(x, x2)) / dxh);
+
+ }
+ else
+ {
+ l = -MAX(x, x2) / dxh;
+ r = (w - MIN(x, x2)) / dxh;
+
+ }
+ }
+ else if (dxh < 0)
+ {
+ if (dyh > 0)
+ {
+ l = MAX(-MAX(y, y2) / dyh, (w - MIN(x, x2)) / dxh);
+ r = MIN(-MAX(x, x2) / dxh, (h - MIN(y, y2)) / dyh);
+
+ }
+ else if (dyh < 0)
+ {
+ l = MAX((h - MIN(y, y2)) / dyh, (w - MIN(x, x2)) / dxh);
+ r = MIN(-MAX(y, y2) / dyh, -MAX(x, x2) / dxh);
+
+ }
+ else
+ {
+ l = (w - MIN(x, x2)) / dxh;
+ r = -MAX(x, x2) / dxh;
+
+ }
+
+ }
+ else
+ {
+ if (dyh > 0)
+ {
+ l = -MAX(y, y2) / dyh;
+ r = (h - MIN(y, y2)) / dyh;
+
+ }
+ else if (dyh < 0)
+ {
+ l = (h - MIN(y, y2)) / dyh;
+ r = -MAX(y, y2) / dyh;
+
+ }
+ else
+ {
+ l = 0;
+ r = 0;
+
+ }
+
+ }
+ l--;
+ r += 2; /*\ Be paranoid about roundoff errors \ */
+ if (l < 0)
+ l = 0;
+ if (r > im_dst->w)
+ r = im_dst->w;
+ if (r <= l)
+ {
+ x = x2;
+ y = y2;
+ continue;
+
+ }
+
+ w = r - l;
+ h = MIN(LINESIZE, im_dst->h - i);
+ x += l * dxh;
+ y += l * dyh;
+ if (aa)
+ {
+ x -= _ROTATE_PREC_MAX;
+ y -= _ROTATE_PREC_MAX;
#ifdef DO_MMX_ASM
- if (do_mmx)
- __imlib_mmx_RotateAA(src, data, im_src->w, ssw, ssh, w, w, h,
- x, y, dxh, dyh, dxv, dyv);
- else
+ if (do_mmx)
+ __imlib_mmx_RotateAA(src, data, im_src->w, ssw, ssh, w, w, h,
+ x, y, dxh, dyh, dxv, dyv);
+ else
#endif
- __imlib_RotateAA(src, data, im_src->w, ssw, ssh, w, w, h,
- x, y, dxh, dyh, dxv, dyv);
-
- } else {
- __imlib_RotateSample(src, data, im_src->w, ssw, ssh, w, w, h,
- x, y, dxh, dyh, dxv, dyv);
-
- }
- __imlib_BlendRGBAToData(data, w, h, im_dst->data,
- im_dst->w, im_dst->h, 0, 0, l, i, w, h,
- blend, merge_alpha, cm, op, 0);
- x = x2; y = y2;
-
- }
+ __imlib_RotateAA(src, data, im_src->w, ssw, ssh, w, w, h,
+ x, y, dxh, dyh, dxv, dyv);
+
+ }
+ else
+ {
+ __imlib_RotateSample(src, data, im_src->w, ssw, ssh, w, w, h,
+ x, y, dxh, dyh, dxv, dyv);
+
+ }
+ __imlib_BlendRGBAToData(data, w, h, im_dst->data,
+ im_dst->w, im_dst->h, 0, 0, l, i, w, h,
+ blend, merge_alpha, cm, op, 0);
+ x = x2;
+ y = y2;
+
+ }
free(data);
}
diff --git a/src/scale.c b/src/scale.c
index b5db427..71e523d 100644
--- a/src/scale.c
+++ b/src/scale.c
@@ -7,13 +7,12 @@
#include <assert.h>
/*\ NB: If you change this, don't forget asm_scale.S \*/
-struct _imlib_scale_info
-{
- int *xpoints;
- DATA32 **ypoints;
- int *xapoints, *yapoints;
- int xup_yup;
- DATA32 *pix_assert;
+struct _imlib_scale_info {
+ int *xpoints;
+ DATA32 **ypoints;
+ int *xapoints, *yapoints;
+ int xup_yup;
+ DATA32 *pix_assert;
};
#define RGBA_COMPOSE(r, g, b, a) ((a) << 24) | ((r) << 16) | ((g) << 8) | (b)
@@ -22,226 +21,234 @@ struct _imlib_scale_info
#define INV_YAP (256 - yapoints[dyy + y])
#define YAP (yapoints[dyy + y])
-static DATA32 **
-__imlib_CalcYPoints(DATA32 *src, int sw, int sh, int dh, int b1, int b2)
+static DATA32 **
+__imlib_CalcYPoints(DATA32 * src, int sw, int sh, int dh, int b1, int b2)
{
- DATA32 **p;
- int i, j = 0;
- int val, inc, rv = 0;
-
- if (dh < 0) {
- dh = -dh;
- rv = 1;
- }
+ DATA32 **p;
+ int i, j = 0;
+ int val, inc, rv = 0;
+
+ if (dh < 0)
+ {
+ dh = -dh;
+ rv = 1;
+ }
p = malloc((dh + 1) * sizeof(DATA32 *));
if (dh < (b1 + b2))
{
- if (dh < b1)
- {
- b1 = dh;
- b2 = 0;
- }
- else
- b2 = dh - b1;
+ if (dh < b1)
+ {
+ b1 = dh;
+ b2 = 0;
+ }
+ else
+ b2 = dh - b1;
}
val = 0;
inc = 1 << 16;
for (i = 0; i < b1; i++)
{
- p[j++] = src + ((val >> 16) * sw);
- val += inc;
+ p[j++] = src + ((val >> 16) * sw);
+ val += inc;
}
if (dh > (b1 + b2))
{
- val = (b1 << 16);
- inc = ((sh - b1 - b2) << 16) / (dh - b1 - b2);
- for (i = 0; i < (dh - b1 - b2); i++)
- {
- p[j++] = src + ((val >> 16) * sw);
- val += inc;
- }
+ val = (b1 << 16);
+ inc = ((sh - b1 - b2) << 16) / (dh - b1 - b2);
+ for (i = 0; i < (dh - b1 - b2); i++)
+ {
+ p[j++] = src + ((val >> 16) * sw);
+ val += inc;
+ }
}
val = (sh - b2) << 16;
inc = 1 << 16;
for (i = 0; i <= b2; i++)
{
- p[j++] = src + ((val >> 16) * sw);
- val += inc;
+ p[j++] = src + ((val >> 16) * sw);
+ val += inc;
}
if (rv)
- for (i = dh / 2; --i >= 0; )
- {
- DATA32 *tmp = p[i];
- p[i] = p[dh - i - 1];
- p[dh - i - 1] = tmp;
- }
+ for (i = dh / 2; --i >= 0;)
+ {
+ DATA32 *tmp = p[i];
+
+ p[i] = p[dh - i - 1];
+ p[dh - i - 1] = tmp;
+ }
return p;
}
-static int *
+static int *
__imlib_CalcXPoints(int sw, int dw, int b1, int b2)
{
- int *p, i, j = 0;
- int val, inc, rv = 0;
+ int *p, i, j = 0;
+ int val, inc, rv = 0;
- if (dw < 0) {
- dw = -dw;
- rv = 1;
- }
+ if (dw < 0)
+ {
+ dw = -dw;
+ rv = 1;
+ }
p = malloc((dw + 1) * sizeof(int));
if (dw < (b1 + b2))
{
- if (dw < b1)
- {
- b1 = dw;
- b2 = 0;
- }
- else
- b2 = dw - b1;
+ if (dw < b1)
+ {
+ b1 = dw;
+ b2 = 0;
+ }
+ else
+ b2 = dw - b1;
}
val = 0;
inc = 1 << 16;
for (i = 0; i < b1; i++)
{
- p[j++] = (val >> 16);
- val += inc;
+ p[j++] = (val >> 16);
+ val += inc;
}
if (dw > (b1 + b2))
{
- val = (b1 << 16);
- inc = ((sw - b1 - b2) << 16) / (dw - b1 - b2);
- for (i = 0; i < (dw - b1 - b2); i++)
- {
- p[j++] = (val >> 16);
- val += inc;
- }
+ val = (b1 << 16);
+ inc = ((sw - b1 - b2) << 16) / (dw - b1 - b2);
+ for (i = 0; i < (dw - b1 - b2); i++)
+ {
+ p[j++] = (val >> 16);
+ val += inc;
+ }
}
val = (sw - b2) << 16;
inc = 1 << 16;
for (i = 0; i <= b2; i++)
{
- p[j++] = (val >> 16);
- val += inc;
+ p[j++] = (val >> 16);
+ val += inc;
}
if (rv)
- for (i = dw / 2; --i >= 0; )
- {
- int tmp = p[i];
- p[i] = p[dw - i - 1];
- p[dw - i - 1] = tmp;
- }
+ for (i = dw / 2; --i >= 0;)
+ {
+ int tmp = p[i];
+
+ p[i] = p[dw - i - 1];
+ p[dw - i - 1] = tmp;
+ }
return p;
}
-static int *
+static int *
__imlib_CalcApoints(int s, int d, int b1, int b2, int up)
{
- int *p, i, j = 0, rv = 0;
+ int *p, i, j = 0, rv = 0;
- if (d < 0) {
- rv = 1;
- d = -d;
- }
+ if (d < 0)
+ {
+ rv = 1;
+ d = -d;
+ }
p = malloc(d * sizeof(int));
if (d < (b1 + b2))
{
- if (d < b1)
- {
- b1 = d;
- b2 = 0;
- }
- else
- b2 = d - b1;
+ if (d < b1)
+ {
+ b1 = d;
+ b2 = 0;
+ }
+ else
+ b2 = d - b1;
}
/* scaling up */
if (up)
{
- int val, inc;
-
- for (i = 0; i < b1; i++)
- p[j++] = 0;
- if (d > (b1 + b2))
- {
- int ss, dd;
-
- ss = s - b1 - b2;
- dd = d - b1 - b2;
- val = 0;
- inc = (ss << 16) / dd;
- for (i = 0; i < dd; i++)
- {
- p[j++] = (val >> 8) - ((val >> 8) & 0xffffff00);
- if (((val >> 16) + b1) >= (s - 1))
- p[j - 1] = 0;
- val += inc;
- }
- }
- for (i = 0; i < b2; i++)
- p[j++] = 0;
+ int val, inc;
+
+ for (i = 0; i < b1; i++)
+ p[j++] = 0;
+ if (d > (b1 + b2))
+ {
+ int ss, dd;
+
+ ss = s - b1 - b2;
+ dd = d - b1 - b2;
+ val = 0;
+ inc = (ss << 16) / dd;
+ for (i = 0; i < dd; i++)
+ {
+ p[j++] = (val >> 8) - ((val >> 8) & 0xffffff00);
+ if (((val >> 16) + b1) >= (s - 1))
+ p[j - 1] = 0;
+ val += inc;
+ }
+ }
+ for (i = 0; i < b2; i++)
+ p[j++] = 0;
}
/* scaling down */
else
{
- int val, inc;
-
- for (i = 0; i < b1; i++)
- p[j++] = (1 << (16 + 14)) + (1 << 14);
- if (d > (b1 + b2))
- {
- int ss, dd, ap, Cp;
-
- ss = s - b1 - b2;
- dd = d - b1 - b2;
- val = 0;
- inc = (ss << 16) / dd;
- Cp = ((dd << 14) / ss) + 1;
- for (i = 0; i < dd; i++)
- {
- ap = ((0x100 - ((val >> 8) & 0xff)) * Cp) >> 8;
- p[j] = ap | (Cp << 16);
- j++;
- val += inc;
- }
- }
- for (i = 0; i < b2; i++)
- p[j++] = (1 << (16 + 14)) + (1 << 14);
+ int val, inc;
+
+ for (i = 0; i < b1; i++)
+ p[j++] = (1 << (16 + 14)) + (1 << 14);
+ if (d > (b1 + b2))
+ {
+ int ss, dd, ap, Cp;
+
+ ss = s - b1 - b2;
+ dd = d - b1 - b2;
+ val = 0;
+ inc = (ss << 16) / dd;
+ Cp = ((dd << 14) / ss) + 1;
+ for (i = 0; i < dd; i++)
+ {
+ ap = ((0x100 - ((val >> 8) & 0xff)) * Cp) >> 8;
+ p[j] = ap | (Cp << 16);
+ j++;
+ val += inc;
+ }
+ }
+ for (i = 0; i < b2; i++)
+ p[j++] = (1 << (16 + 14)) + (1 << 14);
}
if (rv)
{
- for (i = d / 2; --i >= 0; )
- {
- int tmp = p[i];
- p[i] = p[d - i - 1];
- p[d - i - 1] = tmp;
- }
+ for (i = d / 2; --i >= 0;)
+ {
+ int tmp = p[i];
+
+ p[i] = p[d - i - 1];
+ p[d - i - 1] = tmp;
+ }
}
return p;
}
-ImlibScaleInfo *
-__imlib_FreeScaleInfo(ImlibScaleInfo *isi)
+ImlibScaleInfo *
+__imlib_FreeScaleInfo(ImlibScaleInfo * isi)
{
- if (isi) {
- free(isi->xpoints);
- free(isi->ypoints);
- free(isi->xapoints);
- free(isi->yapoints);
- free(isi);
- }
+ if (isi)
+ {
+ free(isi->xpoints);
+ free(isi->ypoints);
+ free(isi->xapoints);
+ free(isi->yapoints);
+ free(isi);
+ }
return NULL;
}
-ImlibScaleInfo *
-__imlib_CalcScaleInfo(ImlibImage *im, int sw, int sh, int dw, int dh, char aa)
+ImlibScaleInfo *
+__imlib_CalcScaleInfo(ImlibImage * im, int sw, int sh, int dw, int dh, char aa)
{
- ImlibScaleInfo *isi;
- int scw, sch;
+ ImlibScaleInfo *isi;
+ int scw, sch;
scw = dw * im->w / sw;
sch = dh * im->h / sh;
isi = malloc(sizeof(ImlibScaleInfo));
- if (!isi) return NULL;
+ if (!isi)
+ return NULL;
memset(isi, 0, sizeof(ImlibScaleInfo));
isi->pix_assert = im->data + im->w * im->h;
@@ -249,48 +256,50 @@ __imlib_CalcScaleInfo(ImlibImage *im, int sw, int sh, int dw, int dh, char aa)
isi->xup_yup = (abs(dw) >= sw) + ((abs(dh) >= sh) << 1);
isi->xpoints = __imlib_CalcXPoints(im->w, scw,
- im->border.left, im->border.right);
+ im->border.left, im->border.right);
if (!isi->xpoints)
return __imlib_FreeScaleInfo(isi);
isi->ypoints = __imlib_CalcYPoints(im->data, im->w, im->h, sch,
- im->border.top, im->border.bottom);
+ im->border.top, im->border.bottom);
if (!isi->ypoints)
return __imlib_FreeScaleInfo(isi);
- if (aa) {
- isi->xapoints = __imlib_CalcApoints(im->w, scw, im->border.left,
- im->border.right, isi->xup_yup & 1);
- if (!isi->xapoints)
- return __imlib_FreeScaleInfo(isi);
- isi->yapoints = __imlib_CalcApoints(im->h, sch, im->border.top,
- im->border.bottom, isi->xup_yup & 2);
- if (!isi->yapoints)
- return __imlib_FreeScaleInfo(isi);
- }
+ if (aa)
+ {
+ isi->xapoints = __imlib_CalcApoints(im->w, scw, im->border.left,
+ im->border.right, isi->xup_yup & 1);
+ if (!isi->xapoints)
+ return __imlib_FreeScaleInfo(isi);
+ isi->yapoints = __imlib_CalcApoints(im->h, sch, im->border.top,
+ im->border.bottom,
+ isi->xup_yup & 2);
+ if (!isi->yapoints)
+ return __imlib_FreeScaleInfo(isi);
+ }
return isi;
}
/* scale by pixel sampling only */
void
-__imlib_ScaleSampleRGBA(ImlibScaleInfo *isi, DATA32 *dest, int dxx, int dyy,
- int dx, int dy, int dw, int dh, int dow)
+__imlib_ScaleSampleRGBA(ImlibScaleInfo * isi, DATA32 * dest, int dxx, int dyy,
+ int dx, int dy, int dw, int dh, int dow)
{
- DATA32 *sptr, *dptr;
- int x, y, end;
- DATA32 **ypoints = isi->ypoints;
- int *xpoints = isi->xpoints;
-
+ DATA32 *sptr, *dptr;
+ int x, y, end;
+ DATA32 **ypoints = isi->ypoints;
+ int *xpoints = isi->xpoints;
+
/* whats the last pixel ont he line so we stop there */
end = dxx + dw;
/* go through every scanline in the output buffer */
for (y = 0; y < dh; y++)
{
- /* get the pointer to the start of the destination scanline */
- dptr = dest + dx + ((y + dy) * dow);
- /* calculate the source line we'll scan from */
- sptr = ypoints[dyy + y];
- /* go thru the scanline and copy across */
- for (x = dxx; x < end; x++)
- *dptr++ = sptr[xpoints[x]];
+ /* get the pointer to the start of the destination scanline */
+ dptr = dest + dx + ((y + dy) * dow);
+ /* calculate the source line we'll scan from */
+ sptr = ypoints[dyy + y];
+ /* go thru the scanline and copy across */
+ for (x = dxx; x < end; x++)
+ *dptr++ = sptr[xpoints[x]];
}
}
@@ -298,1069 +307,1075 @@ __imlib_ScaleSampleRGBA(ImlibScaleInfo *isi, DATA32 *dest, int dxx, int dyy,
/* scale by area sampling */
void
-__imlib_ScaleAARGBA(ImlibScaleInfo *isi, DATA32 *dest, int dxx, int dyy,
- int dx, int dy, int dw, int dh, int dow, int sow)
+__imlib_ScaleAARGBA(ImlibScaleInfo * isi, DATA32 * dest, int dxx, int dyy,
+ int dx, int dy, int dw, int dh, int dow, int sow)
{
- DATA32 *sptr, *dptr;
- int x, y, end;
- DATA32 **ypoints = isi->ypoints;
- int *xpoints = isi->xpoints;
- int *xapoints = isi->xapoints;
- int *yapoints = isi->yapoints;
-
+ DATA32 *sptr, *dptr;
+ int x, y, end;
+ DATA32 **ypoints = isi->ypoints;
+ int *xpoints = isi->xpoints;
+ int *xapoints = isi->xapoints;
+ int *yapoints = isi->yapoints;
+
end = dxx + dw;
/* scaling up both ways */
if (isi->xup_yup == 3)
{
- /* go through every scanline in the output buffer */
- for (y = 0; y < dh; y++)
- {
- /* calculate the source line we'll scan from */
- dptr = dest + dx + ((y + dy) * dow);
- sptr = ypoints[dyy + y];
- if (YAP > 0)
- {
- for (x = dxx; x < end; x++)
- {
- int r, g, b, a;
- int rr, gg, bb, aa;
- DATA32 *pix;
-
- if (XAP > 0)
- {
- pix = ypoints[dyy + y] + xpoints[x];
- r = R_VAL(pix) * INV_XAP;
- g = G_VAL(pix) * INV_XAP;
- b = B_VAL(pix) * INV_XAP;
- a = A_VAL(pix) * INV_XAP;
- pix++;
- r += R_VAL(pix) * XAP;
- g += G_VAL(pix) * XAP;
- b += B_VAL(pix) * XAP;
- a += A_VAL(pix) * XAP;
- pix += sow;
- rr = R_VAL(pix) * XAP;
- gg = G_VAL(pix) * XAP;
- bb = B_VAL(pix) * XAP;
- aa = A_VAL(pix) * XAP;
- pix--;
- rr += R_VAL(pix) * INV_XAP;
- gg += G_VAL(pix) * INV_XAP;
- bb += B_VAL(pix) * INV_XAP;
- aa += A_VAL(pix) * INV_XAP;
- r = ((rr * YAP) + (r * INV_YAP)) >> 16;
- g = ((gg * YAP) + (g * INV_YAP)) >> 16;
- b = ((bb * YAP) + (b * INV_YAP)) >> 16;
- a = ((aa * YAP) + (a * INV_YAP)) >> 16;
- *dptr++ = RGBA_COMPOSE(r, g, b, a);
- }
- else
- {
- pix = ypoints[dyy + y] + xpoints[x];
- r = R_VAL(pix) * INV_YAP;
- g = G_VAL(pix) * INV_YAP;
- b = B_VAL(pix) * INV_YAP;
- a = A_VAL(pix) * INV_YAP;
- pix += sow;
- r += R_VAL(pix) * YAP;
- g += G_VAL(pix) * YAP;
- b += B_VAL(pix) * YAP;
- a += A_VAL(pix) * YAP;
- r >>= 8;
- g >>= 8;
- b >>= 8;
- a >>= 8;
- *dptr++ = RGBA_COMPOSE(r, g, b, a);
- }
- }
- }
- else
- {
- for (x = dxx; x < end; x++)
- {
- int r, g, b, a;
- DATA32 *pix;
-
- if (XAP > 0)
- {
- pix = ypoints[dyy + y] + xpoints[x];
- r = R_VAL(pix) * INV_XAP;
- g = G_VAL(pix) * INV_XAP;
- b = B_VAL(pix) * INV_XAP;
- a = A_VAL(pix) * INV_XAP;
- pix++;
- r += R_VAL(pix) * XAP;
- g += G_VAL(pix) * XAP;
- b += B_VAL(pix) * XAP;
- a += A_VAL(pix) * XAP;
- r >>= 8;
- g >>= 8;
- b >>= 8;
- a >>= 8;
- *dptr++ = RGBA_COMPOSE(r, g, b, a);
- }
- else
- *dptr++ = sptr[xpoints[x] ];
- }
- }
- }
+ /* go through every scanline in the output buffer */
+ for (y = 0; y < dh; y++)
+ {
+ /* calculate the source line we'll scan from */
+ dptr = dest + dx + ((y + dy) * dow);
+ sptr = ypoints[dyy + y];
+ if (YAP > 0)
+ {
+ for (x = dxx; x < end; x++)
+ {
+ int r, g, b, a;
+ int rr, gg, bb, aa;
+ DATA32 *pix;
+
+ if (XAP > 0)
+ {
+ pix = ypoints[dyy + y] + xpoints[x];
+ r = R_VAL(pix) * INV_XAP;
+ g = G_VAL(pix) * INV_XAP;
+ b = B_VAL(pix) * INV_XAP;
+ a = A_VAL(pix) * INV_XAP;
+ pix++;
+ r += R_VAL(pix) * XAP;
+ g += G_VAL(pix) * XAP;
+ b += B_VAL(pix) * XAP;
+ a += A_VAL(pix) * XAP;
+ pix += sow;
+ rr = R_VAL(pix) * XAP;
+ gg = G_VAL(pix) * XAP;
+ bb = B_VAL(pix) * XAP;
+ aa = A_VAL(pix) * XAP;
+ pix--;
+ rr += R_VAL(pix) * INV_XAP;
+ gg += G_VAL(pix) * INV_XAP;
+ bb += B_VAL(pix) * INV_XAP;
+ aa += A_VAL(pix) * INV_XAP;
+ r = ((rr * YAP) + (r * INV_YAP)) >> 16;
+ g = ((gg * YAP) + (g * INV_YAP)) >> 16;
+ b = ((bb * YAP) + (b * INV_YAP)) >> 16;
+ a = ((aa * YAP) + (a * INV_YAP)) >> 16;
+ *dptr++ = RGBA_COMPOSE(r, g, b, a);
+ }
+ else
+ {
+ pix = ypoints[dyy + y] + xpoints[x];
+ r = R_VAL(pix) * INV_YAP;
+ g = G_VAL(pix) * INV_YAP;
+ b = B_VAL(pix) * INV_YAP;
+ a = A_VAL(pix) * INV_YAP;
+ pix += sow;
+ r += R_VAL(pix) * YAP;
+ g += G_VAL(pix) * YAP;
+ b += B_VAL(pix) * YAP;
+ a += A_VAL(pix) * YAP;
+ r >>= 8;
+ g >>= 8;
+ b >>= 8;
+ a >>= 8;
+ *dptr++ = RGBA_COMPOSE(r, g, b, a);
+ }
+ }
+ }
+ else
+ {
+ for (x = dxx; x < end; x++)
+ {
+ int r, g, b, a;
+ DATA32 *pix;
+
+ if (XAP > 0)
+ {
+ pix = ypoints[dyy + y] + xpoints[x];
+ r = R_VAL(pix) * INV_XAP;
+ g = G_VAL(pix) * INV_XAP;
+ b = B_VAL(pix) * INV_XAP;
+ a = A_VAL(pix) * INV_XAP;
+ pix++;
+ r += R_VAL(pix) * XAP;
+ g += G_VAL(pix) * XAP;
+ b += B_VAL(pix) * XAP;
+ a += A_VAL(pix) * XAP;
+ r >>= 8;
+ g >>= 8;
+ b >>= 8;
+ a >>= 8;
+ *dptr++ = RGBA_COMPOSE(r, g, b, a);
+ }
+ else
+ *dptr++ = sptr[xpoints[x]];
+ }
+ }
+ }
}
/* if we're scaling down vertically */
else if (isi->xup_yup == 1)
#ifndef OLD_SCALE_DOWN
{
- /*\ 'Correct' version, with math units prepared for MMXification \*/
- int Cy, j;
- DATA32 *pix;
- int r, g, b, a, rr, gg, bb, aa;
- int yap;
-
- /* go through every scanline in the output buffer */
- for (y = 0; y < dh; y++)
- {
- Cy = YAP >> 16;
- yap = YAP & 0xffff;
-
- dptr = dest + dx + ((y + dy) * dow);
- for (x = dxx; x < end; x++)
- {
- pix = ypoints[dyy + y] + xpoints[x];
- r = (R_VAL(pix) * yap) >> 10;
- g = (G_VAL(pix) * yap) >> 10;
- b = (B_VAL(pix) * yap) >> 10;
- a = (A_VAL(pix) * yap) >> 10;
- for (j = (1 << 14) - yap; j > Cy; j -= Cy)
- {
- pix += sow;
- r += (R_VAL(pix) * Cy) >> 10;
- g += (G_VAL(pix) * Cy) >> 10;
- b += (B_VAL(pix) * Cy) >> 10;
- a += (A_VAL(pix) * Cy) >> 10;
- }
- if (j > 0)
- {
- pix += sow;
- r += (R_VAL(pix) * j) >> 10;
- g += (G_VAL(pix) * j) >> 10;
- b += (B_VAL(pix) * j) >> 10;
- a += (A_VAL(pix) * j) >> 10;
- }
- assert(pix < isi->pix_assert);
- if (XAP > 0)
- {
- pix = ypoints[dyy + y] + xpoints[x] + 1;
- rr = (R_VAL(pix) * yap) >> 10;
- gg = (G_VAL(pix) * yap) >> 10;
- bb = (B_VAL(pix) * yap) >> 10;
- aa = (A_VAL(pix) * yap) >> 10;
- for (j = (1 << 14) - yap; j > Cy; j -= Cy)
- {
- pix += sow;
- rr += (R_VAL(pix) * Cy) >> 10;
- gg += (G_VAL(pix) * Cy) >> 10;
- bb += (B_VAL(pix) * Cy) >> 10;
- aa += (A_VAL(pix) * Cy) >> 10;
- }
- if (j > 0)
- {
- pix += sow;
- rr += (R_VAL(pix) * j) >> 10;
- gg += (G_VAL(pix) * j) >> 10;
- bb += (B_VAL(pix) * j) >> 10;
- aa += (A_VAL(pix) * j) >> 10;
- }
- assert(pix < isi->pix_assert);
- r = r * INV_XAP;
- g = g * INV_XAP;
- b = b * INV_XAP;
- a = a * INV_XAP;
- r = (r + ((rr * XAP))) >> 12;
- g = (g + ((gg * XAP))) >> 12;
- b = (b + ((bb * XAP))) >> 12;
- a = (a + ((aa * XAP))) >> 12;
- }
- else
- {
- r >>= 4;
- g >>= 4;
- b >>= 4;
- a >>= 4;
- }
- *dptr = RGBA_COMPOSE(r, g, b, a);
- dptr++;
- }
- }
+ /*\ 'Correct' version, with math units prepared for MMXification \ */
+ int Cy, j;
+ DATA32 *pix;
+ int r, g, b, a, rr, gg, bb, aa;
+ int yap;
+
+ /* go through every scanline in the output buffer */
+ for (y = 0; y < dh; y++)
+ {
+ Cy = YAP >> 16;
+ yap = YAP & 0xffff;
+
+ dptr = dest + dx + ((y + dy) * dow);
+ for (x = dxx; x < end; x++)
+ {
+ pix = ypoints[dyy + y] + xpoints[x];
+ r = (R_VAL(pix) * yap) >> 10;
+ g = (G_VAL(pix) * yap) >> 10;
+ b = (B_VAL(pix) * yap) >> 10;
+ a = (A_VAL(pix) * yap) >> 10;
+ for (j = (1 << 14) - yap; j > Cy; j -= Cy)
+ {
+ pix += sow;
+ r += (R_VAL(pix) * Cy) >> 10;
+ g += (G_VAL(pix) * Cy) >> 10;
+ b += (B_VAL(pix) * Cy) >> 10;
+ a += (A_VAL(pix) * Cy) >> 10;
+ }
+ if (j > 0)
+ {
+ pix += sow;
+ r += (R_VAL(pix) * j) >> 10;
+ g += (G_VAL(pix) * j) >> 10;
+ b += (B_VAL(pix) * j) >> 10;
+ a += (A_VAL(pix) * j) >> 10;
+ }
+ assert(pix < isi->pix_assert);
+ if (XAP > 0)
+ {
+ pix = ypoints[dyy + y] + xpoints[x] + 1;
+ rr = (R_VAL(pix) * yap) >> 10;
+ gg = (G_VAL(pix) * yap) >> 10;
+ bb = (B_VAL(pix) * yap) >> 10;
+ aa = (A_VAL(pix) * yap) >> 10;
+ for (j = (1 << 14) - yap; j > Cy; j -= Cy)
+ {
+ pix += sow;
+ rr += (R_VAL(pix) * Cy) >> 10;
+ gg += (G_VAL(pix) * Cy) >> 10;
+ bb += (B_VAL(pix) * Cy) >> 10;
+ aa += (A_VAL(pix) * Cy) >> 10;
+ }
+ if (j > 0)
+ {
+ pix += sow;
+ rr += (R_VAL(pix) * j) >> 10;
+ gg += (G_VAL(pix) * j) >> 10;
+ bb += (B_VAL(pix) * j) >> 10;
+ aa += (A_VAL(pix) * j) >> 10;
+ }
+ assert(pix < isi->pix_assert);
+ r = r * INV_XAP;
+ g = g * INV_XAP;
+ b = b * INV_XAP;
+ a = a * INV_XAP;
+ r = (r + ((rr * XAP))) >> 12;
+ g = (g + ((gg * XAP))) >> 12;
+ b = (b + ((bb * XAP))) >> 12;
+ a = (a + ((aa * XAP))) >> 12;
+ }
+ else
+ {
+ r >>= 4;
+ g >>= 4;
+ b >>= 4;
+ a >>= 4;
+ }
+ *dptr = RGBA_COMPOSE(r, g, b, a);
+ dptr++;
+ }
+ }
}
#else
{
- /* go through every scanline in the output buffer */
- for (y = 0; y < dh; y++)
- {
- int yap;
- /* calculate the source line we'll scan from */
- dptr = dest + dx + ((y + dy) * dow);
- sptr = ypoints[dyy + y];
-
- yap = (ypoints[dyy + y + 1] - ypoints[dyy + y]) / sow;
- if (yap > 1)
- {
- for (x = dxx; x < end; x++)
- {
- int r = 0, g = 0, b = 0, a = 0;
- int rr = 0, gg = 0, bb = 0, aa = 0;
- DATA32 *pix;
-
- if (XAP > 0)
- {
- pix = sptr + xpoints[x];
- for (j = 0; j < yap; j++)
- {
- r += R_VAL(pix);
- g += G_VAL(pix);
- b += B_VAL(pix);
- a += A_VAL(pix);
- rr += R_VAL(pix + 1);
- gg += G_VAL(pix + 1);
- bb += B_VAL(pix + 1);
- aa += A_VAL(pix + 1);
- pix += sow;
- }
- r = r * INV_XAP / yap;
- g = g * INV_XAP / yap;
- b = b * INV_XAP / yap;
- a = a * INV_XAP / yap;
- r = (r + ((rr * XAP) / yap)) >> 8;
- g = (g + ((gg * XAP) / yap)) >> 8;
- b = (b + ((bb * XAP) / yap)) >> 8;
- a = (a + ((aa * XAP) / yap)) >> 8;
- *dptr++ = RGBA_COMPOSE(r, g, b, a);
- }
- else
- {
- pix = sptr + xpoints[x];
- for (j = 0; j < yap; j++)
- {
- r += R_VAL(pix);
- g += G_VAL(pix);
- b += B_VAL(pix);
- a += A_VAL(pix);
- pix += sow;
- }
- r /= yap;
- g /= yap;
- b /= yap;
- a /= yap;
- *dptr++ = RGBA_COMPOSE(r, g, b, a);
- }
- }
- }
- else
- {
- for (x = dxx; x < end; x++)
- {
- int r = 0, g = 0, b = 0, a = 0;
- int count;
- DATA32 *pix;
-
- if (XAP > 0)
- {
- pix = ypoints[dyy + y] + xpoints[x];
- r = R_VAL(pix) * INV_XAP;
- g = G_VAL(pix) * INV_XAP;
- b = B_VAL(pix) * INV_XAP;
- a = A_VAL(pix) * INV_XAP;
- pix++;
- r += R_VAL(pix) * XAP;
- g += G_VAL(pix) * XAP;
- b += B_VAL(pix) * XAP;
- a += A_VAL(pix) * XAP;
- r >>= 8;
- g >>= 8;
- b >>= 8;
- a >>= 8;
- *dptr++ = RGBA_COMPOSE(r, g, b, a);
- }
- else
- *dptr++ = sptr[xpoints[x]];
- }
- }
- }
+ /* go through every scanline in the output buffer */
+ for (y = 0; y < dh; y++)
+ {
+ int yap;
+
+ /* calculate the source line we'll scan from */
+ dptr = dest + dx + ((y + dy) * dow);
+ sptr = ypoints[dyy + y];
+
+ yap = (ypoints[dyy + y + 1] - ypoints[dyy + y]) / sow;
+ if (yap > 1)
+ {
+ for (x = dxx; x < end; x++)
+ {
+ int r = 0, g = 0, b = 0, a = 0;
+ int rr = 0, gg = 0, bb = 0, aa = 0;
+ DATA32 *pix;
+
+ if (XAP > 0)
+ {
+ pix = sptr + xpoints[x];
+ for (j = 0; j < yap; j++)
+ {
+ r += R_VAL(pix);
+ g += G_VAL(pix);
+ b += B_VAL(pix);
+ a += A_VAL(pix);
+ rr += R_VAL(pix + 1);
+ gg += G_VAL(pix + 1);
+ bb += B_VAL(pix + 1);
+ aa += A_VAL(pix + 1);
+ pix += sow;
+ }
+ r = r * INV_XAP / yap;
+ g = g * INV_XAP / yap;
+ b = b * INV_XAP / yap;
+ a = a * INV_XAP / yap;
+ r = (r + ((rr * XAP) / yap)) >> 8;
+ g = (g + ((gg * XAP) / yap)) >> 8;
+ b = (b + ((bb * XAP) / yap)) >> 8;
+ a = (a + ((aa * XAP) / yap)) >> 8;
+ *dptr++ = RGBA_COMPOSE(r, g, b, a);
+ }
+ else
+ {
+ pix = sptr + xpoints[x];
+ for (j = 0; j < yap; j++)
+ {
+ r += R_VAL(pix);
+ g += G_VAL(pix);
+ b += B_VAL(pix);
+ a += A_VAL(pix);
+ pix += sow;
+ }
+ r /= yap;
+ g /= yap;
+ b /= yap;
+ a /= yap;
+ *dptr++ = RGBA_COMPOSE(r, g, b, a);
+ }
+ }
+ }
+ else
+ {
+ for (x = dxx; x < end; x++)
+ {
+ int r = 0, g = 0, b = 0, a = 0;
+ int count;
+ DATA32 *pix;
+
+ if (XAP > 0)
+ {
+ pix = ypoints[dyy + y] + xpoints[x];
+ r = R_VAL(pix) * INV_XAP;
+ g = G_VAL(pix) * INV_XAP;
+ b = B_VAL(pix) * INV_XAP;
+ a = A_VAL(pix) * INV_XAP;
+ pix++;
+ r += R_VAL(pix) * XAP;
+ g += G_VAL(pix) * XAP;
+ b += B_VAL(pix) * XAP;
+ a += A_VAL(pix) * XAP;
+ r >>= 8;
+ g >>= 8;
+ b >>= 8;
+ a >>= 8;
+ *dptr++ = RGBA_COMPOSE(r, g, b, a);
+ }
+ else
+ *dptr++ = sptr[xpoints[x]];
+ }
+ }
+ }
}
#endif
/* if we're scaling down horizontally */
else if (isi->xup_yup == 2)
#ifndef OLD_SCALE_DOWN
{
- /*\ 'Correct' version, with math units prepared for MMXification \*/
- int Cx, j;
- DATA32 *pix;
- int r, g, b, a, rr, gg, bb, aa;
- int xap;
-
- /* go through every scanline in the output buffer */
- for (y = 0; y < dh; y++)
- {
- dptr = dest + dx + ((y + dy) * dow);
- for (x = dxx; x < end; x++)
- {
- Cx = XAP >> 16;
- xap = XAP & 0xffff;
-
- pix = ypoints[dyy + y] + xpoints[x];
- r = (R_VAL(pix) * xap) >> 10;
- g = (G_VAL(pix) * xap) >> 10;
- b = (B_VAL(pix) * xap) >> 10;
- a = (A_VAL(pix) * xap) >> 10;
- for (j = (1 << 14) - xap; j > Cx; j -= Cx)
- {
- pix++;
- r += (R_VAL(pix) * Cx) >> 10;
- g += (G_VAL(pix) * Cx) >> 10;
- b += (B_VAL(pix) * Cx) >> 10;
- a += (A_VAL(pix) * Cx) >> 10;
- }
- if (j > 0)
- {
- pix++;
- r += (R_VAL(pix) * j) >> 10;
- g += (G_VAL(pix) * j) >> 10;
- b += (B_VAL(pix) * j) >> 10;
- a += (A_VAL(pix) * j) >> 10;
- }
- assert(pix < isi->pix_assert);
- if (YAP > 0)
- {
- pix = ypoints[dyy + y] + xpoints[x] + sow;
- rr = (R_VAL(pix) * xap) >> 10;
- gg = (G_VAL(pix) * xap) >> 10;
- bb = (B_VAL(pix) * xap) >> 10;
- aa = (A_VAL(pix) * xap) >> 10;
- for (j = (1 << 14) - xap; j > Cx; j -= Cx)
- {
- pix++;
- rr += (R_VAL(pix) * Cx) >> 10;
- gg += (G_VAL(pix) * Cx) >> 10;
- bb += (B_VAL(pix) * Cx) >> 10;
- aa += (A_VAL(pix) * Cx) >> 10;
- }
- if (j > 0)
- {
- pix++;
- rr += (R_VAL(pix) * j) >> 10;
- gg += (G_VAL(pix) * j) >> 10;
- bb += (B_VAL(pix) * j) >> 10;
- aa += (A_VAL(pix) * j) >> 10;
- }
- assert(pix < isi->pix_assert);
- r = r * INV_YAP;
- g = g * INV_YAP;
- b = b * INV_YAP;
- a = a * INV_YAP;
- r = (r + ((rr * YAP))) >> 12;
- g = (g + ((gg * YAP))) >> 12;
- b = (b + ((bb * YAP))) >> 12;
- a = (a + ((aa * YAP))) >> 12;
- }
- else
- {
- r >>= 4;
- g >>= 4;
- b >>= 4;
- a >>= 4;
- }
- *dptr = RGBA_COMPOSE(r, g, b, a);
- dptr++;
- }
- }
+ /*\ 'Correct' version, with math units prepared for MMXification \ */
+ int Cx, j;
+ DATA32 *pix;
+ int r, g, b, a, rr, gg, bb, aa;
+ int xap;
+
+ /* go through every scanline in the output buffer */
+ for (y = 0; y < dh; y++)
+ {
+ dptr = dest + dx + ((y + dy) * dow);
+ for (x = dxx; x < end; x++)
+ {
+ Cx = XAP >> 16;
+ xap = XAP & 0xffff;
+
+ pix = ypoints[dyy + y] + xpoints[x];
+ r = (R_VAL(pix) * xap) >> 10;
+ g = (G_VAL(pix) * xap) >> 10;
+ b = (B_VAL(pix) * xap) >> 10;
+ a = (A_VAL(pix) * xap) >> 10;
+ for (j = (1 << 14) - xap; j > Cx; j -= Cx)
+ {
+ pix++;
+ r += (R_VAL(pix) * Cx) >> 10;
+ g += (G_VAL(pix) * Cx) >> 10;
+ b += (B_VAL(pix) * Cx) >> 10;
+ a += (A_VAL(pix) * Cx) >> 10;
+ }
+ if (j > 0)
+ {
+ pix++;
+ r += (R_VAL(pix) * j) >> 10;
+ g += (G_VAL(pix) * j) >> 10;
+ b += (B_VAL(pix) * j) >> 10;
+ a += (A_VAL(pix) * j) >> 10;
+ }
+ assert(pix < isi->pix_assert);
+ if (YAP > 0)
+ {
+ pix = ypoints[dyy + y] + xpoints[x] + sow;
+ rr = (R_VAL(pix) * xap) >> 10;
+ gg = (G_VAL(pix) * xap) >> 10;
+ bb = (B_VAL(pix) * xap) >> 10;
+ aa = (A_VAL(pix) * xap) >> 10;
+ for (j = (1 << 14) - xap; j > Cx; j -= Cx)
+ {
+ pix++;
+ rr += (R_VAL(pix) * Cx) >> 10;
+ gg += (G_VAL(pix) * Cx) >> 10;
+ bb += (B_VAL(pix) * Cx) >> 10;
+ aa += (A_VAL(pix) * Cx) >> 10;
+ }
+ if (j > 0)
+ {
+ pix++;
+ rr += (R_VAL(pix) * j) >> 10;
+ gg += (G_VAL(pix) * j) >> 10;
+ bb += (B_VAL(pix) * j) >> 10;
+ aa += (A_VAL(pix) * j) >> 10;
+ }
+ assert(pix < isi->pix_assert);
+ r = r * INV_YAP;
+ g = g * INV_YAP;
+ b = b * INV_YAP;
+ a = a * INV_YAP;
+ r = (r + ((rr * YAP))) >> 12;
+ g = (g + ((gg * YAP))) >> 12;
+ b = (b + ((bb * YAP))) >> 12;
+ a = (a + ((aa * YAP))) >> 12;
+ }
+ else
+ {
+ r >>= 4;
+ g >>= 4;
+ b >>= 4;
+ a >>= 4;
+ }
+ *dptr = RGBA_COMPOSE(r, g, b, a);
+ dptr++;
+ }
+ }
}
#else
{
- /* go through every scanline in the output buffer */
- for (y = 0; y < dh; y++)
- {
- /* calculate the source line we'll scan from */
- dptr = dest + dx + ((y + dy) * dow);
- sptr = ypoints[dyy + y];
- if (YAP > 0)
- {
- for (x = dxx; x < end; x++)
- {
- int r = 0, g = 0, b = 0, a = 0;
- int rr = 0, gg = 0, bb = 0, aa = 0;
- int xap;
- DATA32 *pix;
-
- xap = xpoints[x + 1] - xpoints[x];
- if (xap > 1)
- {
- pix = ypoints[dyy + y] + xpoints[x];
- for (i = 0; i < xap; i++)
- {
- r += R_VAL(pix + i);
- g += G_VAL(pix + i);
- b += B_VAL(pix + i);
- a += A_VAL(pix + i);
- }
- r = r * INV_YAP / xap;
- g = g * INV_YAP / xap;
- b = b * INV_YAP / xap;
- a = a * INV_YAP / xap;
- pix = ypoints[dyy + y] + xpoints[x] + sow;
- for (i = 0; i < xap; i++)
- {
- rr += R_VAL(pix + i);
- gg += G_VAL(pix + i);
- bb += B_VAL(pix + i);
- aa += A_VAL(pix + i);
- }
- r = (r + ((rr * YAP) / xap)) >> 8;
- g = (g + ((gg * YAP) / xap)) >> 8;
- b = (b + ((bb * YAP) / xap)) >> 8;
- a = (a + ((aa * YAP) / xap)) >> 8;
- *dptr++ = RGBA_COMPOSE(r, g, b, a);
- }
- else
- {
- pix = ypoints[dyy + y] + xpoints[x];
- r = R_VAL(pix) * INV_YAP;
- g = G_VAL(pix) * INV_YAP;
- b = B_VAL(pix) * INV_YAP;
- a = A_VAL(pix) * INV_YAP;
- pix += sow;
- r += R_VAL(pix) * YAP;
- g += G_VAL(pix) * YAP;
- b += B_VAL(pix) * YAP;
- a += A_VAL(pix) * YAP;
- r >>= 8;
- g >>= 8;
- b >>= 8;
- a >>= 8;
- *dptr++ = RGBA_COMPOSE(r, g, b, a);
- }
- }
- }
- else
- {
- for (x = dxx; x < end; x++)
- {
- int r = 0, g = 0, b = 0, a = 0;
- int xap;
- DATA32 *pix;
-
- xap = xpoints[x + 1] - xpoints[x];
- if (xap > 1)
- {
- pix = ypoints[dyy + y] + xpoints[x];
- for (i = 0; i < xap; i++)
- {
- r += R_VAL(pix + i);
- g += G_VAL(pix + i);
- b += B_VAL(pix + i);
- a += A_VAL(pix + i);
- }
- r /= xap;
- g /= xap;
- b /= xap;
- a /= xap;
- *dptr++ = RGBA_COMPOSE(r, g, b, a);
- }
- else
- *dptr++ = sptr[xpoints[x]];
- }
- }
- }
+ /* go through every scanline in the output buffer */
+ for (y = 0; y < dh; y++)
+ {
+ /* calculate the source line we'll scan from */
+ dptr = dest + dx + ((y + dy) * dow);
+ sptr = ypoints[dyy + y];
+ if (YAP > 0)
+ {
+ for (x = dxx; x < end; x++)
+ {
+ int r = 0, g = 0, b = 0, a = 0;
+ int rr = 0, gg = 0, bb = 0, aa = 0;
+ int xap;
+ DATA32 *pix;
+
+ xap = xpoints[x + 1] - xpoints[x];
+ if (xap > 1)
+ {
+ pix = ypoints[dyy + y] + xpoints[x];
+ for (i = 0; i < xap; i++)
+ {
+ r += R_VAL(pix + i);
+ g += G_VAL(pix + i);
+ b += B_VAL(pix + i);
+ a += A_VAL(pix + i);
+ }
+ r = r * INV_YAP / xap;
+ g = g * INV_YAP / xap;
+ b = b * INV_YAP / xap;
+ a = a * INV_YAP / xap;
+ pix = ypoints[dyy + y] + xpoints[x] + sow;
+ for (i = 0; i < xap; i++)
+ {
+ rr += R_VAL(pix + i);
+ gg += G_VAL(pix + i);
+ bb += B_VAL(pix + i);
+ aa += A_VAL(pix + i);
+ }
+ r = (r + ((rr * YAP) / xap)) >> 8;
+ g = (g + ((gg * YAP) / xap)) >> 8;
+ b = (b + ((bb * YAP) / xap)) >> 8;
+ a = (a + ((aa * YAP) / xap)) >> 8;
+ *dptr++ = RGBA_COMPOSE(r, g, b, a);
+ }
+ else
+ {
+ pix = ypoints[dyy + y] + xpoints[x];
+ r = R_VAL(pix) * INV_YAP;
+ g = G_VAL(pix) * INV_YAP;
+ b = B_VAL(pix) * INV_YAP;
+ a = A_VAL(pix) * INV_YAP;
+ pix += sow;
+ r += R_VAL(pix) * YAP;
+ g += G_VAL(pix) * YAP;
+ b += B_VAL(pix) * YAP;
+ a += A_VAL(pix) * YAP;
+ r >>= 8;
+ g >>= 8;
+ b >>= 8;
+ a >>= 8;
+ *dptr++ = RGBA_COMPOSE(r, g, b, a);
+ }
+ }
+ }
+ else
+ {
+ for (x = dxx; x < end; x++)
+ {
+ int r = 0, g = 0, b = 0, a = 0;
+ int xap;
+ DATA32 *pix;
+
+ xap = xpoints[x + 1] - xpoints[x];
+ if (xap > 1)
+ {
+ pix = ypoints[dyy + y] + xpoints[x];
+ for (i = 0; i < xap; i++)
+ {
+ r += R_VAL(pix + i);
+ g += G_VAL(pix + i);
+ b += B_VAL(pix + i);
+ a += A_VAL(pix + i);
+ }
+ r /= xap;
+ g /= xap;
+ b /= xap;
+ a /= xap;
+ *dptr++ = RGBA_COMPOSE(r, g, b, a);
+ }
+ else
+ *dptr++ = sptr[xpoints[x]];
+ }
+ }
+ }
}
#endif
/* if we're scaling down horizontally & vertically */
else
#ifndef OLD_SCALE_DOWN
{
- /*\ 'Correct' version, with math units prepared for MMXification:
- |*| The operation 'b = (b * c) >> 16' translates to pmulhw,
- |*| so the operation 'b = (b * c) >> d' would translate to
- |*| psllw (16 - d), %mmb; pmulh %mmc, %mmb
- \*/
- int Cx, Cy, i, j;
- DATA32 *pix;
- int a, r, g, b, ax, rx, gx, bx;
- int xap, yap;
-
- for (y = 0; y < dh; y++)
- {
- Cy = YAP >> 16;
- yap = YAP & 0xffff;
-
- dptr = dest + dx + ((y + dy) * dow);
- for (x = dxx; x < end; x++)
- {
- Cx = XAP >> 16;
- xap = XAP & 0xffff;
-
- sptr = ypoints[dyy + y] + xpoints[x];
- pix = sptr;
- sptr += sow;
- rx = (R_VAL(pix) * xap) >> 9;
- gx = (G_VAL(pix) * xap) >> 9;
- bx = (B_VAL(pix) * xap) >> 9;
- ax = (A_VAL(pix) * xap) >> 9;
- pix++;
- for (i = (1 << 14) - xap; i > Cx; i -= Cx)
- {
- rx += (R_VAL(pix) * Cx) >> 9;
- gx += (G_VAL(pix) * Cx) >> 9;
- bx += (B_VAL(pix) * Cx) >> 9;
- ax += (A_VAL(pix) * Cx) >> 9;
- pix++;
- }
- if (i > 0)
- {
- rx += (R_VAL(pix) * i) >> 9;
- gx += (G_VAL(pix) * i) >> 9;
- bx += (B_VAL(pix) * i) >> 9;
- ax += (A_VAL(pix) * i) >> 9;
- }
-
- r = (rx * yap) >> 14;
- g = (gx * yap) >> 14;
- b = (bx * yap) >> 14;
- a = (ax * yap) >> 14;
-
- for (j = (1 << 14) - yap; j > Cy; j -= Cy)
- {
- pix = sptr;
- sptr += sow;
- rx = (R_VAL(pix) * xap) >> 9;
- gx = (G_VAL(pix) * xap) >> 9;
- bx = (B_VAL(pix) * xap) >> 9;
- ax = (A_VAL(pix) * xap) >> 9;
- pix++;
- for (i = (1 << 14) - xap; i > Cx; i -= Cx)
- {
- rx += (R_VAL(pix) * Cx) >> 9;
- gx += (G_VAL(pix) * Cx) >> 9;
- bx += (B_VAL(pix) * Cx) >> 9;
- ax += (A_VAL(pix) * Cx) >> 9;
- pix++;
- }
- if (i > 0)
- {
- rx += (R_VAL(pix) * i) >> 9;
- gx += (G_VAL(pix) * i) >> 9;
- bx += (B_VAL(pix) * i) >> 9;
- ax += (A_VAL(pix) * i) >> 9;
- }
-
- r += (rx * Cy) >> 14;
- g += (gx * Cy) >> 14;
- b += (bx * Cy) >> 14;
- a += (ax * Cy) >> 14;
- }
- if (j > 0)
- {
- pix = sptr;
- sptr += sow;
- rx = (R_VAL(pix) * xap) >> 9;
- gx = (G_VAL(pix) * xap) >> 9;
- bx = (B_VAL(pix) * xap) >> 9;
- ax = (A_VAL(pix) * xap) >> 9;
- pix++;
- for (i = (1 << 14) - xap; i > Cx; i -= Cx)
- {
- rx += (R_VAL(pix) * Cx) >> 9;
- gx += (G_VAL(pix) * Cx) >> 9;
- bx += (B_VAL(pix) * Cx) >> 9;
- ax += (A_VAL(pix) * Cx) >> 9;
- pix++;
- }
- if (i > 0)
- {
- rx += (R_VAL(pix) * i) >> 9;
- gx += (G_VAL(pix) * i) >> 9;
- bx += (B_VAL(pix) * i) >> 9;
- ax += (A_VAL(pix) * i) >> 9;
- }
-
- r += (rx * j) >> 14;
- g += (gx * j) >> 14;
- b += (bx * j) >> 14;
- a += (ax * j) >> 14;
- }
-
- R_VAL(dptr) = r >> 5;
- G_VAL(dptr) = g >> 5;
- B_VAL(dptr) = b >> 5;
- A_VAL(dptr) = a >> 5;
- dptr++;
- }
- }
+ /*\ 'Correct' version, with math units prepared for MMXification:
+ * |*| The operation 'b = (b * c) >> 16' translates to pmulhw,
+ * |*| so the operation 'b = (b * c) >> d' would translate to
+ * |*| psllw (16 - d), %mmb; pmulh %mmc, %mmb
+ * \ */
+ int Cx, Cy, i, j;
+ DATA32 *pix;
+ int a, r, g, b, ax, rx, gx, bx;
+ int xap, yap;
+
+ for (y = 0; y < dh; y++)
+ {
+ Cy = YAP >> 16;
+ yap = YAP & 0xffff;
+
+ dptr = dest + dx + ((y + dy) * dow);
+ for (x = dxx; x < end; x++)
+ {
+ Cx = XAP >> 16;
+ xap = XAP & 0xffff;
+
+ sptr = ypoints[dyy + y] + xpoints[x];
+ pix = sptr;
+ sptr += sow;
+ rx = (R_VAL(pix) * xap) >> 9;
+ gx = (G_VAL(pix) * xap) >> 9;
+ bx = (B_VAL(pix) * xap) >> 9;
+ ax = (A_VAL(pix) * xap) >> 9;
+ pix++;
+ for (i = (1 << 14) - xap; i > Cx; i -= Cx)
+ {
+ rx += (R_VAL(pix) * Cx) >> 9;
+ gx += (G_VAL(pix) * Cx) >> 9;
+ bx += (B_VAL(pix) * Cx) >> 9;
+ ax += (A_VAL(pix) * Cx) >> 9;
+ pix++;
+ }
+ if (i > 0)
+ {
+ rx += (R_VAL(pix) * i) >> 9;
+ gx += (G_VAL(pix) * i) >> 9;
+ bx += (B_VAL(pix) * i) >> 9;
+ ax += (A_VAL(pix) * i) >> 9;
+ }
+
+ r = (rx * yap) >> 14;
+ g = (gx * yap) >> 14;
+ b = (bx * yap) >> 14;
+ a = (ax * yap) >> 14;
+
+ for (j = (1 << 14) - yap; j > Cy; j -= Cy)
+ {
+ pix = sptr;
+ sptr += sow;
+ rx = (R_VAL(pix) * xap) >> 9;
+ gx = (G_VAL(pix) * xap) >> 9;
+ bx = (B_VAL(pix) * xap) >> 9;
+ ax = (A_VAL(pix) * xap) >> 9;
+ pix++;
+ for (i = (1 << 14) - xap; i > Cx; i -= Cx)
+ {
+ rx += (R_VAL(pix) * Cx) >> 9;
+ gx += (G_VAL(pix) * Cx) >> 9;
+ bx += (B_VAL(pix) * Cx) >> 9;
+ ax += (A_VAL(pix) * Cx) >> 9;
+ pix++;
+ }
+ if (i > 0)
+ {
+ rx += (R_VAL(pix) * i) >> 9;
+ gx += (G_VAL(pix) * i) >> 9;
+ bx += (B_VAL(pix) * i) >> 9;
+ ax += (A_VAL(pix) * i) >> 9;
+ }
+
+ r += (rx * Cy) >> 14;
+ g += (gx * Cy) >> 14;
+ b += (bx * Cy) >> 14;
+ a += (ax * Cy) >> 14;
+ }
+ if (j > 0)
+ {
+ pix = sptr;
+ sptr += sow;
+ rx = (R_VAL(pix) * xap) >> 9;
+ gx = (G_VAL(pix) * xap) >> 9;
+ bx = (B_VAL(pix) * xap) >> 9;
+ ax = (A_VAL(pix) * xap) >> 9;
+ pix++;
+ for (i = (1 << 14) - xap; i > Cx; i -= Cx)
+ {
+ rx += (R_VAL(pix) * Cx) >> 9;
+ gx += (G_VAL(pix) * Cx) >> 9;
+ bx += (B_VAL(pix) * Cx) >> 9;
+ ax += (A_VAL(pix) * Cx) >> 9;
+ pix++;
+ }
+ if (i > 0)
+ {
+ rx += (R_VAL(pix) * i) >> 9;
+ gx += (G_VAL(pix) * i) >> 9;
+ bx += (B_VAL(pix) * i) >> 9;
+ ax += (A_VAL(pix) * i) >> 9;
+ }
+
+ r += (rx * j) >> 14;
+ g += (gx * j) >> 14;
+ b += (bx * j) >> 14;
+ a += (ax * j) >> 14;
+ }
+
+ R_VAL(dptr) = r >> 5;
+ G_VAL(dptr) = g >> 5;
+ B_VAL(dptr) = b >> 5;
+ A_VAL(dptr) = a >> 5;
+ dptr++;
+ }
+ }
}
#else
{
- int count;
- DATA32 *pix;
- int a, r, g, b;
-
- /* go through every scanline in the output buffer */
- for (y = 0; y < dh; y++)
- {
- int yap = (ypoints[dyy + y + 1] - ypoints[dyy + y]) / sow;
- /* calculate the source line we'll scan from */
- dptr = dest + dx + ((y + dy) * dow);
- sptr = ypoints[dyy + y];
- for (x = dxx; x < end; x++)
- {
- int xap = xpoints[x + 1] - xpoints[x];
- if ((xap > 1) || (yap > 1))
- {
- r = 0; g = 0; b = 0;
- pix = ypoints[dyy + y] + xpoints[x];
- for (j = yap; --j >= 0; )
- {
- for (i = xap; --i >= 0; )
- {
- r += R_VAL(pix + i);
- g += G_VAL(pix + i);
- b += B_VAL(pix + i);
- a += A_VAL(pix + i);
- }
- pix += sow;
- }
- count = xap * yap;
- R_VAL(dptr) = r / count;
- G_VAL(dptr) = g / count;
- B_VAL(dptr) = b / count;
- A_VAL(dptr) = a / count;
- dptr++;
- }
- else
- *dptr++ = sptr[xpoints[x]];
- }
- }
+ int count;
+ DATA32 *pix;
+ int a, r, g, b;
+
+ /* go through every scanline in the output buffer */
+ for (y = 0; y < dh; y++)
+ {
+ int yap =
+ (ypoints[dyy + y + 1] - ypoints[dyy + y]) / sow;
+ /* calculate the source line we'll scan from */
+ dptr = dest + dx + ((y + dy) * dow);
+ sptr = ypoints[dyy + y];
+ for (x = dxx; x < end; x++)
+ {
+ int xap = xpoints[x + 1] - xpoints[x];
+
+ if ((xap > 1) || (yap > 1))
+ {
+ r = 0;
+ g = 0;
+ b = 0;
+ pix = ypoints[dyy + y] + xpoints[x];
+ for (j = yap; --j >= 0;)
+ {
+ for (i = xap; --i >= 0;)
+ {
+ r += R_VAL(pix + i);
+ g += G_VAL(pix + i);
+ b += B_VAL(pix + i);
+ a += A_VAL(pix + i);
+ }
+ pix += sow;
+ }
+ count = xap * yap;
+ R_VAL(dptr) = r / count;
+ G_VAL(dptr) = g / count;
+ B_VAL(dptr) = b / count;
+ A_VAL(dptr) = a / count;
+ dptr++;
+ }
+ else
+ *dptr++ = sptr[xpoints[x]];
+ }
+ }
}
#endif
}
/* scale by area sampling - IGNORE the ALPHA byte*/
void
-__imlib_ScaleAARGB(ImlibScaleInfo *isi, DATA32 *dest, int dxx, int dyy,
- int dx, int dy, int dw, int dh, int dow, int sow)
+__imlib_ScaleAARGB(ImlibScaleInfo * isi, DATA32 * dest, int dxx, int dyy,
+ int dx, int dy, int dw, int dh, int dow, int sow)
{
- DATA32 *sptr, *dptr;
- int x, y, end;
- DATA32 **ypoints = isi->ypoints;
- int *xpoints = isi->xpoints;
- int *xapoints = isi->xapoints;
- int *yapoints = isi->yapoints;
-
+ DATA32 *sptr, *dptr;
+ int x, y, end;
+ DATA32 **ypoints = isi->ypoints;
+ int *xpoints = isi->xpoints;
+ int *xapoints = isi->xapoints;
+ int *yapoints = isi->yapoints;
+
end = dxx + dw;
/* scaling up both ways */
if (isi->xup_yup == 3)
{
- /* go through every scanline in the output buffer */
- for (y = 0; y < dh; y++)
- {
- /* calculate the source line we'll scan from */
- dptr = dest + dx + ((y + dy) * dow);
- sptr = ypoints[dyy + y];
- if (YAP > 0)
- {
- for (x = dxx; x < end; x++)
- {
- int r = 0, g = 0, b = 0;
- int rr = 0, gg = 0, bb = 0;
- DATA32 *pix;
-
- if (XAP > 0)
- {
- pix = ypoints[dyy + y] + xpoints[x];
- r = R_VAL(pix) * INV_XAP;
- g = G_VAL(pix) * INV_XAP;
- b = B_VAL(pix) * INV_XAP;
- pix++;
- r += R_VAL(pix) * XAP;
- g += G_VAL(pix) * XAP;
- b += B_VAL(pix) * XAP;
- pix += sow;
- rr = R_VAL(pix) * XAP;
- gg = G_VAL(pix) * XAP;
- bb = B_VAL(pix) * XAP;
- pix --;
- rr += R_VAL(pix) * INV_XAP;
- gg += G_VAL(pix) * INV_XAP;
- bb += B_VAL(pix) * INV_XAP;
- r = ((rr * YAP) + (r * INV_YAP)) >> 16;
- g = ((gg * YAP) + (g * INV_YAP)) >> 16;
- b = ((bb * YAP) + (b * INV_YAP)) >> 16;
- *dptr++ = RGBA_COMPOSE(r, g, b, 0xff);
- }
- else
- {
- pix = ypoints[dyy + y] + xpoints[x];
- r = R_VAL(pix) * INV_YAP;
- g = G_VAL(pix) * INV_YAP;
- b = B_VAL(pix) * INV_YAP;
- pix += sow;
- r += R_VAL(pix) * YAP;
- g += G_VAL(pix) * YAP;
- b += B_VAL(pix) * YAP;
- r >>= 8;
- g >>= 8;
- b >>= 8;
- *dptr++ = RGBA_COMPOSE(r, g, b, 0xff);
- }
- }
- }
- else
- {
- for (x = dxx; x < end; x++)
- {
- int r = 0, g = 0, b = 0;
- DATA32 *pix;
-
- if (XAP > 0)
- {
- pix = ypoints[dyy + y] + xpoints[x];
- r = R_VAL(pix) * INV_XAP;
- g = G_VAL(pix) * INV_XAP;
- b = B_VAL(pix) * INV_XAP;
- pix++;
- r += R_VAL(pix) * XAP;
- g += G_VAL(pix) * XAP;
- b += B_VAL(pix) * XAP;
- r >>= 8;
- g >>= 8;
- b >>= 8;
- *dptr++ = RGBA_COMPOSE(r, g, b, 0xff);
- }
- else
- *dptr++ = sptr[xpoints[x] ];
- }
- }
- }
+ /* go through every scanline in the output buffer */
+ for (y = 0; y < dh; y++)
+ {
+ /* calculate the source line we'll scan from */
+ dptr = dest + dx + ((y + dy) * dow);
+ sptr = ypoints[dyy + y];
+ if (YAP > 0)
+ {
+ for (x = dxx; x < end; x++)
+ {
+ int r = 0, g = 0, b = 0;
+ int rr = 0, gg = 0, bb = 0;
+ DATA32 *pix;
+
+ if (XAP > 0)
+ {
+ pix = ypoints[dyy + y] + xpoints[x];
+ r = R_VAL(pix) * INV_XAP;
+ g = G_VAL(pix) * INV_XAP;
+ b = B_VAL(pix) * INV_XAP;
+ pix++;
+ r += R_VAL(pix) * XAP;
+ g += G_VAL(pix) * XAP;
+ b += B_VAL(pix) * XAP;
+ pix += sow;
+ rr = R_VAL(pix) * XAP;
+ gg = G_VAL(pix) * XAP;
+ bb = B_VAL(pix) * XAP;
+ pix--;
+ rr += R_VAL(pix) * INV_XAP;
+ gg += G_VAL(pix) * INV_XAP;
+ bb += B_VAL(pix) * INV_XAP;
+ r = ((rr * YAP) + (r * INV_YAP)) >> 16;
+ g = ((gg * YAP) + (g * INV_YAP)) >> 16;
+ b = ((bb * YAP) + (b * INV_YAP)) >> 16;
+ *dptr++ = RGBA_COMPOSE(r, g, b, 0xff);
+ }
+ else
+ {
+ pix = ypoints[dyy + y] + xpoints[x];
+ r = R_VAL(pix) * INV_YAP;
+ g = G_VAL(pix) * INV_YAP;
+ b = B_VAL(pix) * INV_YAP;
+ pix += sow;
+ r += R_VAL(pix) * YAP;
+ g += G_VAL(pix) * YAP;
+ b += B_VAL(pix) * YAP;
+ r >>= 8;
+ g >>= 8;
+ b >>= 8;
+ *dptr++ = RGBA_COMPOSE(r, g, b, 0xff);
+ }
+ }
+ }
+ else
+ {
+ for (x = dxx; x < end; x++)
+ {
+ int r = 0, g = 0, b = 0;
+ DATA32 *pix;
+
+ if (XAP > 0)
+ {
+ pix = ypoints[dyy + y] + xpoints[x];
+ r = R_VAL(pix) * INV_XAP;
+ g = G_VAL(pix) * INV_XAP;
+ b = B_VAL(pix) * INV_XAP;
+ pix++;
+ r += R_VAL(pix) * XAP;
+ g += G_VAL(pix) * XAP;
+ b += B_VAL(pix) * XAP;
+ r >>= 8;
+ g >>= 8;
+ b >>= 8;
+ *dptr++ = RGBA_COMPOSE(r, g, b, 0xff);
+ }
+ else
+ *dptr++ = sptr[xpoints[x]];
+ }
+ }
+ }
}
/* if we're scaling down vertically */
else if (isi->xup_yup == 1)
#ifndef OLD_SCALE_DOWN
{
- /*\ 'Correct' version, with math units prepared for MMXification \*/
- int Cy, j;
- DATA32 *pix;
- int r, g, b, rr, gg, bb;
- int yap;
-
- /* go through every scanline in the output buffer */
- for (y = 0; y < dh; y++)
- {
- Cy = YAP >> 16;
- yap = YAP & 0xffff;
-
- dptr = dest + dx + ((y + dy) * dow);
- for (x = dxx; x < end; x++)
- {
- pix = ypoints[dyy + y] + xpoints[x];
- r = (R_VAL(pix) * yap) >> 10;
- g = (G_VAL(pix) * yap) >> 10;
- b = (B_VAL(pix) * yap) >> 10;
- pix += sow;
- for (j = (1 << 14) - yap; j > Cy; j -= Cy)
- {
- r += (R_VAL(pix) * Cy) >> 10;
- g += (G_VAL(pix) * Cy) >> 10;
- b += (B_VAL(pix) * Cy) >> 10;
- pix += sow;
- }
- if (j > 0)
- {
- r += (R_VAL(pix) * j) >> 10;
- g += (G_VAL(pix) * j) >> 10;
- b += (B_VAL(pix) * j) >> 10;
- }
- if (XAP > 0)
- {
- pix = ypoints[dyy + y] + xpoints[x] + 1;
- rr = (R_VAL(pix) * yap) >> 10;
- gg = (G_VAL(pix) * yap) >> 10;
- bb = (B_VAL(pix) * yap) >> 10;
- pix += sow;
- for (j = (1 << 14) - yap; j > Cy; j -= Cy)
- {
- rr += (R_VAL(pix) * Cy) >> 10;
- gg += (G_VAL(pix) * Cy) >> 10;
- bb += (B_VAL(pix) * Cy) >> 10;
- pix += sow;
- }
- if (j > 0)
- {
- rr += (R_VAL(pix) * j) >> 10;
- gg += (G_VAL(pix) * j) >> 10;
- bb += (B_VAL(pix) * j) >> 10;
- }
- r = r * INV_XAP;
- g = g * INV_XAP;
- b = b * INV_XAP;
- r = (r + ((rr * XAP))) >> 12;
- g = (g + ((gg * XAP))) >> 12;
- b = (b + ((bb * XAP))) >> 12;
- }
- else
- {
- r >>= 4;
- g >>= 4;
- b >>= 4;
- }
- *dptr = RGBA_COMPOSE(r, g, b, 0xff);
- dptr++;
- }
- }
+ /*\ 'Correct' version, with math units prepared for MMXification \ */
+ int Cy, j;
+ DATA32 *pix;
+ int r, g, b, rr, gg, bb;
+ int yap;
+
+ /* go through every scanline in the output buffer */
+ for (y = 0; y < dh; y++)
+ {
+ Cy = YAP >> 16;
+ yap = YAP & 0xffff;
+
+ dptr = dest + dx + ((y + dy) * dow);
+ for (x = dxx; x < end; x++)
+ {
+ pix = ypoints[dyy + y] + xpoints[x];
+ r = (R_VAL(pix) * yap) >> 10;
+ g = (G_VAL(pix) * yap) >> 10;
+ b = (B_VAL(pix) * yap) >> 10;
+ pix += sow;
+ for (j = (1 << 14) - yap; j > Cy; j -= Cy)
+ {
+ r += (R_VAL(pix) * Cy) >> 10;
+ g += (G_VAL(pix) * Cy) >> 10;
+ b += (B_VAL(pix) * Cy) >> 10;
+ pix += sow;
+ }
+ if (j > 0)
+ {
+ r += (R_VAL(pix) * j) >> 10;
+ g += (G_VAL(pix) * j) >> 10;
+ b += (B_VAL(pix) * j) >> 10;
+ }
+ if (XAP > 0)
+ {
+ pix = ypoints[dyy + y] + xpoints[x] + 1;
+ rr = (R_VAL(pix) * yap) >> 10;
+ gg = (G_VAL(pix) * yap) >> 10;
+ bb = (B_VAL(pix) * yap) >> 10;
+ pix += sow;
+ for (j = (1 << 14) - yap; j > Cy; j -= Cy)
+ {
+ rr += (R_VAL(pix) * Cy) >> 10;
+ gg += (G_VAL(pix) * Cy) >> 10;
+ bb += (B_VAL(pix) * Cy) >> 10;
+ pix += sow;
+ }
+ if (j > 0)
+ {
+ rr += (R_VAL(pix) * j) >> 10;
+ gg += (G_VAL(pix) * j) >> 10;
+ bb += (B_VAL(pix) * j) >> 10;
+ }
+ r = r * INV_XAP;
+ g = g * INV_XAP;
+ b = b * INV_XAP;
+ r = (r + ((rr * XAP))) >> 12;
+ g = (g + ((gg * XAP))) >> 12;
+ b = (b + ((bb * XAP))) >> 12;
+ }
+ else
+ {
+ r >>= 4;
+ g >>= 4;
+ b >>= 4;
+ }
+ *dptr = RGBA_COMPOSE(r, g, b, 0xff);
+ dptr++;
+ }
+ }
}
#else
{
- /* go through every scanline in the output buffer */
- for (y = 0; y < dh; y++)
- {
- int yap;
- /* calculate the source line we'll scan from */
- dptr = dest + dx + ((y + dy) * dow);
- sptr = ypoints[dyy + y];
-
- yap = (ypoints[dyy + y + 1] - ypoints[dyy + y]) / sow;
- if (yap > 1)
- {
- for (x = dxx; x < end; x++)
- {
- int r = 0, g = 0, b = 0;
- int rr = 0, gg = 0, bb = 0;
- DATA32 *pix;
-
- if (XAP > 0)
- {
- pix = sptr + xpoints[x];
- for (j = 0; j < yap; j++)
- {
- r += R_VAL(pix);
- g += G_VAL(pix);
- b += B_VAL(pix);
- rr += R_VAL(pix + 1);
- gg += G_VAL(pix + 1);
- bb += B_VAL(pix + 1);
- pix += sow;
- }
- r = r * INV_XAP / yap;
- g = g * INV_XAP / yap;
- b = b * INV_XAP / yap;
- r = (r + ((rr * XAP) / yap)) >> 8;
- g = (g + ((gg * XAP) / yap)) >> 8;
- b = (b + ((bb * XAP) / yap)) >> 8;
- *dptr++ = RGBA_COMPOSE(r, g, b, 0xff);
- }
- else
- {
- pix = sptr + xpoints[x];
- for (j = 0; j < yap; j++)
- {
- r += R_VAL(pix);
- g += G_VAL(pix);
- b += B_VAL(pix);
- pix += sow;
- }
- r /= yap;
- g /= yap;
- b /= yap;
- *dptr++ = RGBA_COMPOSE(r, g, b, 0xff);
- }
- }
- }
- else
- {
- for (x = dxx; x < end; x++)
- {
- int r = 0, g = 0, b = 0;
- DATA32 *pix;
-
- if (XAP > 0)
- {
- pix = ypoints[dyy + y] + xpoints[x];
- r = R_VAL(pix) * INV_XAP;
- g = G_VAL(pix) * INV_XAP;
- b = B_VAL(pix) * INV_XAP;
- pix++;
- r += R_VAL(pix) * XAP;
- g += G_VAL(pix) * XAP;
- b += B_VAL(pix) * XAP;
- r >>= 8;
- g >>= 8;
- b >>= 8;
- *dptr++ = RGBA_COMPOSE(r, g, b, 0xff);
- }
- else
- *dptr++ = sptr[xpoints[x]];
- }
- }
- }
+ /* go through every scanline in the output buffer */
+ for (y = 0; y < dh; y++)
+ {
+ int yap;
+
+ /* calculate the source line we'll scan from */
+ dptr = dest + dx + ((y + dy) * dow);
+ sptr = ypoints[dyy + y];
+
+ yap = (ypoints[dyy + y + 1] - ypoints[dyy + y]) / sow;
+ if (yap > 1)
+ {
+ for (x = dxx; x < end; x++)
+ {
+ int r = 0, g = 0, b = 0;
+ int rr = 0, gg = 0, bb = 0;
+ DATA32 *pix;
+
+ if (XAP > 0)
+ {
+ pix = sptr + xpoints[x];
+ for (j = 0; j < yap; j++)
+ {
+ r += R_VAL(pix);
+ g += G_VAL(pix);
+ b += B_VAL(pix);
+ rr += R_VAL(pix + 1);
+ gg += G_VAL(pix + 1);
+ bb += B_VAL(pix + 1);
+ pix += sow;
+ }
+ r = r * INV_XAP / yap;
+ g = g * INV_XAP / yap;
+ b = b * INV_XAP / yap;
+ r = (r + ((rr * XAP) / yap)) >> 8;
+ g = (g + ((gg * XAP) / yap)) >> 8;
+ b = (b + ((bb * XAP) / yap)) >> 8;
+ *dptr++ = RGBA_COMPOSE(r, g, b, 0xff);
+ }
+ else
+ {
+ pix = sptr + xpoints[x];
+ for (j = 0; j < yap; j++)
+ {
+ r += R_VAL(pix);
+ g += G_VAL(pix);
+ b += B_VAL(pix);
+ pix += sow;
+ }
+ r /= yap;
+ g /= yap;
+ b /= yap;
+ *dptr++ = RGBA_COMPOSE(r, g, b, 0xff);
+ }
+ }
+ }
+ else
+ {
+ for (x = dxx; x < end; x++)
+ {
+ int r = 0, g = 0, b = 0;
+ DATA32 *pix;
+
+ if (XAP > 0)
+ {
+ pix = ypoints[dyy + y] + xpoints[x];
+ r = R_VAL(pix) * INV_XAP;
+ g = G_VAL(pix) * INV_XAP;
+ b = B_VAL(pix) * INV_XAP;
+ pix++;
+ r += R_VAL(pix) * XAP;
+ g += G_VAL(pix) * XAP;
+ b += B_VAL(pix) * XAP;
+ r >>= 8;
+ g >>= 8;
+ b >>= 8;
+ *dptr++ = RGBA_COMPOSE(r, g, b, 0xff);
+ }
+ else
+ *dptr++ = sptr[xpoints[x]];
+ }
+ }
+ }
}
#endif
/* if we're scaling down horizontally */
else if (isi->xup_yup == 2)
#ifndef OLD_SCALE_DOWN
{
- /*\ 'Correct' version, with math units prepared for MMXification \*/
- int Cx, j;
- DATA32 *pix;
- int r, g, b, rr, gg, bb;
- int xap;
-
- /* go through every scanline in the output buffer */
- for (y = 0; y < dh; y++)
- {
- dptr = dest + dx + ((y + dy) * dow);
- for (x = dxx; x < end; x++)
- {
- Cx = XAP >> 16;
- xap = XAP & 0xffff;
-
- pix = ypoints[dyy + y] + xpoints[x];
- r = (R_VAL(pix) * xap) >> 10;
- g = (G_VAL(pix) * xap) >> 10;
- b = (B_VAL(pix) * xap) >> 10;
- pix++;
- for (j = (1 << 14) - xap; j > Cx; j -= Cx)
- {
- r += (R_VAL(pix) * Cx) >> 10;
- g += (G_VAL(pix) * Cx) >> 10;
- b += (B_VAL(pix) * Cx) >> 10;
- pix++;
- }
- if (j > 0)
- {
- r += (R_VAL(pix) * j) >> 10;
- g += (G_VAL(pix) * j) >> 10;
- b += (B_VAL(pix) * j) >> 10;
- }
- if (YAP > 0)
- {
- pix = ypoints[dyy + y] + xpoints[x] + sow;
- rr = (R_VAL(pix) * xap) >> 10;
- gg = (G_VAL(pix) * xap) >> 10;
- bb = (B_VAL(pix) * xap) >> 10;
- pix++;
- for (j = (1 << 14) - xap; j > Cx; j -= Cx)
- {
- rr += (R_VAL(pix) * Cx) >> 10;
- gg += (G_VAL(pix) * Cx) >> 10;
- bb += (B_VAL(pix) * Cx) >> 10;
- pix++;
- }
- if (j > 0)
- {
- rr += (R_VAL(pix) * j) >> 10;
- gg += (G_VAL(pix) * j) >> 10;
- bb += (B_VAL(pix) * j) >> 10;
- }
- r = r * INV_YAP;
- g = g * INV_YAP;
- b = b * INV_YAP;
- r = (r + ((rr * YAP))) >> 12;
- g = (g + ((gg * YAP))) >> 12;
- b = (b + ((bb * YAP))) >> 12;
- }
- else
- {
- r >>= 4;
- g >>= 4;
- b >>= 4;
- }
- *dptr = RGBA_COMPOSE(r, g, b, 0xff);
- dptr++;
- }
- }
+ /*\ 'Correct' version, with math units prepared for MMXification \ */
+ int Cx, j;
+ DATA32 *pix;
+ int r, g, b, rr, gg, bb;
+ int xap;
+
+ /* go through every scanline in the output buffer */
+ for (y = 0; y < dh; y++)
+ {
+ dptr = dest + dx + ((y + dy) * dow);
+ for (x = dxx; x < end; x++)
+ {
+ Cx = XAP >> 16;
+ xap = XAP & 0xffff;
+
+ pix = ypoints[dyy + y] + xpoints[x];
+ r = (R_VAL(pix) * xap) >> 10;
+ g = (G_VAL(pix) * xap) >> 10;
+ b = (B_VAL(pix) * xap) >> 10;
+ pix++;
+ for (j = (1 << 14) - xap; j > Cx; j -= Cx)
+ {
+ r += (R_VAL(pix) * Cx) >> 10;
+ g += (G_VAL(pix) * Cx) >> 10;
+ b += (B_VAL(pix) * Cx) >> 10;
+ pix++;
+ }
+ if (j > 0)
+ {
+ r += (R_VAL(pix) * j) >> 10;
+ g += (G_VAL(pix) * j) >> 10;
+ b += (B_VAL(pix) * j) >> 10;
+ }
+ if (YAP > 0)
+ {
+ pix = ypoints[dyy + y] + xpoints[x] + sow;
+ rr = (R_VAL(pix) * xap) >> 10;
+ gg = (G_VAL(pix) * xap) >> 10;
+ bb = (B_VAL(pix) * xap) >> 10;
+ pix++;
+ for (j = (1 << 14) - xap; j > Cx; j -= Cx)
+ {
+ rr += (R_VAL(pix) * Cx) >> 10;
+ gg += (G_VAL(pix) * Cx) >> 10;
+ bb += (B_VAL(pix) * Cx) >> 10;
+ pix++;
+ }
+ if (j > 0)
+ {
+ rr += (R_VAL(pix) * j) >> 10;
+ gg += (G_VAL(pix) * j) >> 10;
+ bb += (B_VAL(pix) * j) >> 10;
+ }
+ r = r * INV_YAP;
+ g = g * INV_YAP;
+ b = b * INV_YAP;
+ r = (r + ((rr * YAP))) >> 12;
+ g = (g + ((gg * YAP))) >> 12;
+ b = (b + ((bb * YAP))) >> 12;
+ }
+ else
+ {
+ r >>= 4;
+ g >>= 4;
+ b >>= 4;
+ }
+ *dptr = RGBA_COMPOSE(r, g, b, 0xff);
+ dptr++;
+ }
+ }
}
#else
{
- /* go through every scanline in the output buffer */
- for (y = 0; y < dh; y++)
- {
- /* calculate the source line we'll scan from */
- dptr = dest + dx + ((y + dy) * dow);
- sptr = ypoints[dyy + y];
- if (YAP > 0)
- {
- for (x = dxx; x < end; x++)
- {
- int r = 0, g = 0, b = 0;
- int rr = 0, gg = 0, bb = 0;
- int xap;
- DATA32 *pix;
-
- xap = xpoints[x + 1] - xpoints[x];
- if (xap > 1)
- {
- pix = ypoints[dyy + y] + xpoints[x];
- for (i = 0; i < xap; i++)
- {
- r += R_VAL(pix + i);
- g += G_VAL(pix + i);
- b += B_VAL(pix + i);
- }
- r = r * INV_YAP / xap;
- g = g * INV_YAP / xap;
- b = b * INV_YAP / xap;
- pix = ypoints[dyy + y] + xpoints[x] + sow;
- for (i = 0; i < xap; i++)
- {
- rr += R_VAL(pix + i);
- gg += G_VAL(pix + i);
- bb += B_VAL(pix + i);
- }
- r = (r + ((rr * YAP) / xap)) >> 8;
- g = (g + ((gg * YAP) / xap)) >> 8;
- b = (b + ((bb * YAP) / xap)) >> 8;
- *dptr++ = RGBA_COMPOSE(r, g, b, 0xff);
- }
- else
- {
- pix = ypoints[dyy + y] + xpoints[x];
- r = R_VAL(pix) * INV_YAP;
- g = G_VAL(pix) * INV_YAP;
- b = B_VAL(pix) * INV_YAP;
- pix += sow;
- r += R_VAL(pix) * YAP;
- g += G_VAL(pix) * YAP;
- b += B_VAL(pix) * YAP;
- r >>= 8;
- g >>= 8;
- b >>= 8;
- *dptr++ = RGBA_COMPOSE(r, g, b, 0xff);
- }
- }
- }
- else
- {
- for (x = dxx; x < end; x++)
- {
- int r = 0, g = 0, b = 0;
- int xap;
- DATA32 *pix;
-
- xap = xpoints[x + 1] - xpoints[x];
- if (xap > 1)
- {
- pix = ypoints[dyy + y] + xpoints[x];
- for (i = 0; i < xap; i++)
- {
- r += R_VAL(pix + i);
- g += G_VAL(pix + i);
- b += B_VAL(pix + i);
- }
- r /= xap;
- g /= xap;
- b /= xap;
- *dptr++ = RGBA_COMPOSE(r, g, b, 0xff);
- }
- else
- *dptr++ = sptr[xpoints[x]];
- }
- }
- }
+ /* go through every scanline in the output buffer */
+ for (y = 0; y < dh; y++)
+ {
+ /* calculate the source line we'll scan from */
+ dptr = dest + dx + ((y + dy) * dow);
+ sptr = ypoints[dyy + y];
+ if (YAP > 0)
+ {
+ for (x = dxx; x < end; x++)
+ {
+ int r = 0, g = 0, b = 0;
+ int rr = 0, gg = 0, bb = 0;
+ int xap;
+ DATA32 *pix;
+
+ xap = xpoints[x + 1] - xpoints[x];
+ if (xap > 1)
+ {
+ pix = ypoints[dyy + y] + xpoints[x];
+ for (i = 0; i < xap; i++)
+ {
+ r += R_VAL(pix + i);
+ g += G_VAL(pix + i);
+ b += B_VAL(pix + i);
+ }
+ r = r * INV_YAP / xap;
+ g = g * INV_YAP / xap;
+ b = b * INV_YAP / xap;
+ pix = ypoints[dyy + y] + xpoints[x] + sow;
+ for (i = 0; i < xap; i++)
+ {
+ rr += R_VAL(pix + i);
+ gg += G_VAL(pix + i);
+ bb += B_VAL(pix + i);
+ }
+ r = (r + ((rr * YAP) / xap)) >> 8;
+ g = (g + ((gg * YAP) / xap)) >> 8;
+ b = (b + ((bb * YAP) / xap)) >> 8;
+ *dptr++ = RGBA_COMPOSE(r, g, b, 0xff);
+ }
+ else
+ {
+ pix = ypoints[dyy + y] + xpoints[x];
+ r = R_VAL(pix) * INV_YAP;
+ g = G_VAL(pix) * INV_YAP;
+ b = B_VAL(pix) * INV_YAP;
+ pix += sow;
+ r += R_VAL(pix) * YAP;
+ g += G_VAL(pix) * YAP;
+ b += B_VAL(pix) * YAP;
+ r >>= 8;
+ g >>= 8;
+ b >>= 8;
+ *dptr++ = RGBA_COMPOSE(r, g, b, 0xff);
+ }
+ }
+ }
+ else
+ {
+ for (x = dxx; x < end; x++)
+ {
+ int r = 0, g = 0, b = 0;
+ int xap;
+ DATA32 *pix;
+
+ xap = xpoints[x + 1] - xpoints[x];
+ if (xap > 1)
+ {
+ pix = ypoints[dyy + y] + xpoints[x];
+ for (i = 0; i < xap; i++)
+ {
+ r += R_VAL(pix + i);
+ g += G_VAL(pix + i);
+ b += B_VAL(pix + i);
+ }
+ r /= xap;
+ g /= xap;
+ b /= xap;
+ *dptr++ = RGBA_COMPOSE(r, g, b, 0xff);
+ }
+ else
+ *dptr++ = sptr[xpoints[x]];
+ }
+ }
+ }
}
#endif
/* fully optimized (i think) - onyl change of algorithm can help */
@@ -1368,149 +1383,152 @@ __imlib_ScaleAARGB(ImlibScaleInfo *isi, DATA32 *dest, int dxx, int dyy,
else
#ifndef OLD_SCALE_DOWN
{
- /*\ 'Correct' version, with math units prepared for MMXification \*/
- int Cx, Cy, i, j;
- DATA32 *pix;
- int r, g, b, rx, gx, bx;
- int xap, yap;
-
- for (y = 0; y < dh; y++)
- {
- Cy = YAP >> 16;
- yap = YAP & 0xffff;
-
- dptr = dest + dx + ((y + dy) * dow);
- for (x = dxx; x < end; x++)
- {
- Cx = XAP >> 16;
- xap = XAP & 0xffff;
-
- sptr = ypoints[dyy + y] + xpoints[x];
- pix = sptr;
- sptr += sow;
- rx = (R_VAL(pix) * xap) >> 9;
- gx = (G_VAL(pix) * xap) >> 9;
- bx = (B_VAL(pix) * xap) >> 9;
- pix++;
- for (i = (1 << 14) - xap; i > Cx; i -= Cx)
- {
- rx += (R_VAL(pix) * Cx) >> 9;
- gx += (G_VAL(pix) * Cx) >> 9;
- bx += (B_VAL(pix) * Cx) >> 9;
- pix++;
- }
- if (i > 0)
- {
- rx += (R_VAL(pix) * i) >> 9;
- gx += (G_VAL(pix) * i) >> 9;
- bx += (B_VAL(pix) * i) >> 9;
- }
-
- r = (rx * yap) >> 14;
- g = (gx * yap) >> 14;
- b = (bx * yap) >> 14;
-
- for (j = (1 << 14) - yap; j > Cy; j -= Cy)
- {
- pix = sptr;
- sptr += sow;
- rx = (R_VAL(pix) * xap) >> 9;
- gx = (G_VAL(pix) * xap) >> 9;
- bx = (B_VAL(pix) * xap) >> 9;
- pix++;
- for (i = (1 << 14) - xap; i > Cx; i -= Cx)
- {
- rx += (R_VAL(pix) * Cx) >> 9;
- gx += (G_VAL(pix) * Cx) >> 9;
- bx += (B_VAL(pix) * Cx) >> 9;
- pix++;
- }
- if (i > 0)
- {
- rx += (R_VAL(pix) * i) >> 9;
- gx += (G_VAL(pix) * i) >> 9;
- bx += (B_VAL(pix) * i) >> 9;
- }
-
- r += (rx * Cy) >> 14;
- g += (gx * Cy) >> 14;
- b += (bx * Cy) >> 14;
- }
- if (j > 0)
- {
- pix = sptr;
- sptr += sow;
- rx = (R_VAL(pix) * xap) >> 9;
- gx = (G_VAL(pix) * xap) >> 9;
- bx = (B_VAL(pix) * xap) >> 9;
- pix++;
- for (i = (1 << 14) - xap; i > Cx; i -= Cx)
- {
- rx += (R_VAL(pix) * Cx) >> 9;
- gx += (G_VAL(pix) * Cx) >> 9;
- bx += (B_VAL(pix) * Cx) >> 9;
- pix++;
- }
- if (i > 0)
- {
- rx += (R_VAL(pix) * i) >> 9;
- gx += (G_VAL(pix) * i) >> 9;
- bx += (B_VAL(pix) * i) >> 9;
- }
-
- r += (rx * j) >> 14;
- g += (gx * j) >> 14;
- b += (bx * j) >> 14;
- }
-
- R_VAL(dptr) = r >> 5;
- G_VAL(dptr) = g >> 5;
- B_VAL(dptr) = b >> 5;
- dptr++;
- }
- }
+ /*\ 'Correct' version, with math units prepared for MMXification \ */
+ int Cx, Cy, i, j;
+ DATA32 *pix;
+ int r, g, b, rx, gx, bx;
+ int xap, yap;
+
+ for (y = 0; y < dh; y++)
+ {
+ Cy = YAP >> 16;
+ yap = YAP & 0xffff;
+
+ dptr = dest + dx + ((y + dy) * dow);
+ for (x = dxx; x < end; x++)
+ {
+ Cx = XAP >> 16;
+ xap = XAP & 0xffff;
+
+ sptr = ypoints[dyy + y] + xpoints[x];
+ pix = sptr;
+ sptr += sow;
+ rx = (R_VAL(pix) * xap) >> 9;
+ gx = (G_VAL(pix) * xap) >> 9;
+ bx = (B_VAL(pix) * xap) >> 9;
+ pix++;
+ for (i = (1 << 14) - xap; i > Cx; i -= Cx)
+ {
+ rx += (R_VAL(pix) * Cx) >> 9;
+ gx += (G_VAL(pix) * Cx) >> 9;
+ bx += (B_VAL(pix) * Cx) >> 9;
+ pix++;
+ }
+ if (i > 0)
+ {
+ rx += (R_VAL(pix) * i) >> 9;
+ gx += (G_VAL(pix) * i) >> 9;
+ bx += (B_VAL(pix) * i) >> 9;
+ }
+
+ r = (rx * yap) >> 14;
+ g = (gx * yap) >> 14;
+ b = (bx * yap) >> 14;
+
+ for (j = (1 << 14) - yap; j > Cy; j -= Cy)
+ {
+ pix = sptr;
+ sptr += sow;
+ rx = (R_VAL(pix) * xap) >> 9;
+ gx = (G_VAL(pix) * xap) >> 9;
+ bx = (B_VAL(pix) * xap) >> 9;
+ pix++;
+ for (i = (1 << 14) - xap; i > Cx; i -= Cx)
+ {
+ rx += (R_VAL(pix) * Cx) >> 9;
+ gx += (G_VAL(pix) * Cx) >> 9;
+ bx += (B_VAL(pix) * Cx) >> 9;
+ pix++;
+ }
+ if (i > 0)
+ {
+ rx += (R_VAL(pix) * i) >> 9;
+ gx += (G_VAL(pix) * i) >> 9;
+ bx += (B_VAL(pix) * i) >> 9;
+ }
+
+ r += (rx * Cy) >> 14;
+ g += (gx * Cy) >> 14;
+ b += (bx * Cy) >> 14;
+ }
+ if (j > 0)
+ {
+ pix = sptr;
+ sptr += sow;
+ rx = (R_VAL(pix) * xap) >> 9;
+ gx = (G_VAL(pix) * xap) >> 9;
+ bx = (B_VAL(pix) * xap) >> 9;
+ pix++;
+ for (i = (1 << 14) - xap; i > Cx; i -= Cx)
+ {
+ rx += (R_VAL(pix) * Cx) >> 9;
+ gx += (G_VAL(pix) * Cx) >> 9;
+ bx += (B_VAL(pix) * Cx) >> 9;
+ pix++;
+ }
+ if (i > 0)
+ {
+ rx += (R_VAL(pix) * i) >> 9;
+ gx += (G_VAL(pix) * i) >> 9;
+ bx += (B_VAL(pix) * i) >> 9;
+ }
+
+ r += (rx * j) >> 14;
+ g += (gx * j) >> 14;
+ b += (bx * j) >> 14;
+ }
+
+ R_VAL(dptr) = r >> 5;
+ G_VAL(dptr) = g >> 5;
+ B_VAL(dptr) = b >> 5;
+ dptr++;
+ }
+ }
}
#else
{
- int count;
- DATA32 *pix;
- int r, g, b;
-
- /* go through every scanline in the output buffer */
- for (y = 0; y < dh; y++)
- {
- int yap = (ypoints[dyy + y + 1] - ypoints[dyy + y]) / sow;
- /* calculate the source line we'll scan from */
- dptr = dest + dx + ((y + dy) * dow);
- sptr = ypoints[dyy + y];
- for (x = dxx; x < end; x++)
- {
- int xap = xpoints[x + 1] - xpoints[x];
- if ((xap > 1) || (yap > 1))
- {
- r = 0; g = 0; b = 0;
- pix = sptr + xpoints[x];
- for (j = yap; --j >= 0; )
- {
- for (i = xap; --i >= 0; )
- {
- r += R_VAL(pix + i);
- g += G_VAL(pix + i);
- b += B_VAL(pix + i);
- }
- pix += sow;
- }
- count = xap * yap;
- R_VAL(dptr) = r / count;
- G_VAL(dptr) = g / count;
- B_VAL(dptr) = b / count;
- dptr++;
- }
- else
- *dptr++ = sptr[xpoints[x]];
- }
- }
+ int count;
+ DATA32 *pix;
+ int r, g, b;
+
+ /* go through every scanline in the output buffer */
+ for (y = 0; y < dh; y++)
+ {
+ int yap =
+ (ypoints[dyy + y + 1] - ypoints[dyy + y]) / sow;
+ /* calculate the source line we'll scan from */
+ dptr = dest + dx + ((y + dy) * dow);
+ sptr = ypoints[dyy + y];
+ for (x = dxx; x < end; x++)
+ {
+ int xap = xpoints[x + 1] - xpoints[x];
+
+ if ((xap > 1) || (yap > 1))
+ {
+ r = 0;
+ g = 0;
+ b = 0;
+ pix = sptr + xpoints[x];
+ for (j = yap; --j >= 0;)
+ {
+ for (i = xap; --i >= 0;)
+ {
+ r += R_VAL(pix + i);
+ g += G_VAL(pix + i);
+ b += B_VAL(pix + i);
+ }
+ pix += sow;
+ }
+ count = xap * yap;
+ R_VAL(dptr) = r / count;
+ G_VAL(dptr) = g / count;
+ B_VAL(dptr) = b / count;
+ dptr++;
+ }
+ else
+ *dptr++ = sptr[xpoints[x]];
+ }
+ }
}
#endif
}
-
diff --git a/src/script.c b/src/script.c
index de1f636..4359c87 100644
--- a/src/script.c
+++ b/src/script.c
@@ -25,246 +25,273 @@
*/
#ifdef FDEBUG
# define D( str ) printf( "DEBUG: %s\n", str )
-#else
+#else
#define D( str )
#endif
-IVariable *vars, *current_var, *curtail;
+IVariable *vars, *current_var, *curtail;
-
-static int __imlib_find_string( char *haystack, char *needle )
+static int
+__imlib_find_string(char *haystack, char *needle)
{
- if( strstr( haystack, needle ) != NULL )
- return ( strstr( haystack, needle ) - haystack );
+ if (strstr(haystack, needle) != NULL)
+ return (strstr(haystack, needle) - haystack);
return 0;
}
-static char *__imlib_stripwhitespace( char *str )
+static char *
+__imlib_stripwhitespace(char *str)
{
- int i, strt = 0, in_quote = 0;
- char *tmpstr = calloc( strlen(str)+1, sizeof(char) );
- for( i = 0; i < strlen(str); i++ )
- {
- if( str[i] == '\"' )
- in_quote = (in_quote == 0 ? 1 : 0);
- if( in_quote || ! isspace(*(str+i)) )
- tmpstr[strt++] = str[i];
- }
- strcpy( str, tmpstr );
+ int i, strt = 0, in_quote = 0;
+ char *tmpstr = calloc(strlen(str) + 1, sizeof(char));
+
+ for (i = 0; i < strlen(str); i++)
+ {
+ if (str[i] == '\"')
+ in_quote = (in_quote == 0 ? 1 : 0);
+ if (in_quote || !isspace(*(str + i)))
+ tmpstr[strt++] = str[i];
+ }
+ strcpy(str, tmpstr);
free(tmpstr);
return str;
}
-static char *__imlib_copystr( char *str, int start, int end )
+static char *
+__imlib_copystr(char *str, int start, int end)
{
- int i = 0;
- char *rstr = calloc( 1024, sizeof( char ) );
- if( start <= end && end < strlen( str ) )
- {
- for( i = start; i <= end; i++ )
- rstr[i-start] = str[i];
- return rstr;
- }
+ int i = 0;
+ char *rstr = calloc(1024, sizeof(char));
+
+ if (start <= end && end < strlen(str))
+ {
+ for (i = start; i <= end; i++)
+ rstr[i - start] = str[i];
+ return rstr;
+ }
return NULL;
}
-static void __imlib_script_tidyup_params( IFunctionParam *param )
+static void
+__imlib_script_tidyup_params(IFunctionParam * param)
{
- if( param->next ){
- __imlib_script_tidyup_params( param->next );
- }
- free( param->key );
- if( param->type == VAR_CHAR )
- free( param->data );
- free( param );
+ if (param->next)
+ {
+ __imlib_script_tidyup_params(param->next);
+ }
+ free(param->key);
+ if (param->type == VAR_CHAR)
+ free(param->data);
+ free(param);
}
-static void __imlib_script_delete_variable( IVariable *var )
+static void
+__imlib_script_delete_variable(IVariable * var)
{
- if( var->next != NULL )
- __imlib_script_delete_variable( var->next );
- free( var );
+ if (var->next != NULL)
+ __imlib_script_delete_variable(var->next);
+ free(var);
}
-void __imlib_script_tidyup(void)
+void
+__imlib_script_tidyup(void)
{
- __imlib_script_delete_variable( vars );
+ __imlib_script_delete_variable(vars);
}
-void *__imlib_script_get_next_var(void)
+void *
+__imlib_script_get_next_var(void)
{
- if( current_var != NULL )
- current_var = current_var->next;
- if( current_var != NULL )
- return current_var->ptr;
+ if (current_var != NULL)
+ current_var = current_var->next;
+ if (current_var != NULL)
+ return current_var->ptr;
else
- return NULL;
+ return NULL;
}
-void __imlib_script_add_var( void *ptr )
+void
+__imlib_script_add_var(void *ptr)
{
- curtail->next = malloc( sizeof( IVariable ) );
+ curtail->next = malloc(sizeof(IVariable));
curtail = curtail->next;
curtail->ptr = ptr;
curtail->next = NULL;
}
-IFunctionParam *__imlib_script_parse_parameters( Imlib_Image im, char *parameters )
+IFunctionParam *
+__imlib_script_parse_parameters(Imlib_Image im, char *parameters)
{
- int i = 0, in_quote = 0, depth=0, start=0, value_start=0;
- char *value = NULL;
- IFunctionParam *rootptr, *ptr;
-
- D( "(--) ===> Entering __imlib_script_parse_parameters()" );
-
- rootptr = malloc( sizeof( IFunctionParam ) );
- rootptr->key = strdup( "NO-KEY" );
+ int i = 0, in_quote = 0, depth = 0, start = 0, value_start =
+ 0;
+ char *value = NULL;
+ IFunctionParam *rootptr, *ptr;
+
+ D("(--) ===> Entering __imlib_script_parse_parameters()");
+
+ rootptr = malloc(sizeof(IFunctionParam));
+ rootptr->key = strdup("NO-KEY");
rootptr->type = VAR_CHAR;
- rootptr->data = strdup( "NO-VALUE" );
+ rootptr->data = strdup("NO-VALUE");
rootptr->next = NULL;
ptr = rootptr;
-
- for( i = 0; i <= strlen( parameters ); i++ )
- {
- if( parameters[i] == '\"' )
- in_quote = (in_quote == 0 ? 1 : 0);
- if( !in_quote && parameters[i] == '(' ) depth++;
- if( !in_quote && parameters[i] == ')' ) depth--;
- if( !in_quote && parameters[i] == '=' && depth == 0) value_start=i+1;
- if( !in_quote && (parameters[i] == ',' || i == (strlen(parameters))) && depth == 0 )
- {
- ptr->next = malloc( sizeof( IFunctionParam ) );
- ptr = ptr->next;
- ptr->key = __imlib_copystr( parameters, start, value_start - 2 );
- value = __imlib_copystr( parameters, value_start, i-1 );
+
+ for (i = 0; i <= strlen(parameters); i++)
+ {
+ if (parameters[i] == '\"')
+ in_quote = (in_quote == 0 ? 1 : 0);
+ if (!in_quote && parameters[i] == '(')
+ depth++;
+ if (!in_quote && parameters[i] == ')')
+ depth--;
+ if (!in_quote && parameters[i] == '=' && depth == 0)
+ value_start = i + 1;
+ if (!in_quote && (parameters[i] == ',' || i == (strlen(parameters)))
+ && depth == 0)
+ {
+ ptr->next = malloc(sizeof(IFunctionParam));
+ ptr = ptr->next;
+ ptr->key = __imlib_copystr(parameters, start, value_start - 2);
+ value = __imlib_copystr(parameters, value_start, i - 1);
#ifdef FDEBUG
- printf( "DEBUG: (--) --> Variable \"%s\" = \"%s\"\n", ptr->key, value );
+ printf("DEBUG: (--) --> Variable \"%s\" = \"%s\"\n", ptr->key,
+ value);
#endif
- if( __imlib_find_string( value, "(" ) < __imlib_find_string( value, "\"" ) )
- {
- D( "(--) Found a function" );
- ptr->data = __imlib_script_parse_function( im, value );
- ptr->type = VAR_PTR;
- free( value );
- }
- else
- {
- if( strcmp( value, "[]" ) == 0 )
- {
- ptr->data = __imlib_script_get_next_var();
- if( ptr->data == NULL )
- D( "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEK" );
- /* printf( "Using pointer variable %p\n", ptr->data );*/
- ptr->type = VAR_PTR;
- free(value);
- }
- else
- {
- ptr->data = value;
- ptr->type = VAR_CHAR;
- }
- }
- ptr->next = NULL;
- start = i+1;
- }
- }
- D( "(--) <=== Leaving __imlib_script_parse_parameters()" );
+ if (__imlib_find_string(value, "(") <
+ __imlib_find_string(value, "\""))
+ {
+ D("(--) Found a function");
+ ptr->data = __imlib_script_parse_function(im, value);
+ ptr->type = VAR_PTR;
+ free(value);
+ }
+ else
+ {
+ if (strcmp(value, "[]") == 0)
+ {
+ ptr->data = __imlib_script_get_next_var();
+ if (ptr->data == NULL)
+ D("EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEK");
+ /* printf( "Using pointer variable %p\n", ptr->data ); */
+ ptr->type = VAR_PTR;
+ free(value);
+ }
+ else
+ {
+ ptr->data = value;
+ ptr->type = VAR_CHAR;
+ }
+ }
+ ptr->next = NULL;
+ start = i + 1;
+ }
+ }
+ D("(--) <=== Leaving __imlib_script_parse_parameters()");
return rootptr;
}
-Imlib_Image __imlib_script_parse_function( Imlib_Image im, char *function )
+Imlib_Image
+__imlib_script_parse_function(Imlib_Image im, char *function)
{
- char *funcname, *funcparams;
- IFunctionParam *params;
+ char *funcname, *funcparams;
+ IFunctionParam *params;
ImlibExternalFilter *filter = NULL;
- Imlib_Image retval;
-
- D( "(--) ===> Entering __imlib_script_parse_function()" );
- funcname = __imlib_copystr( function, 0, __imlib_find_string( function, "(" ) - 1 );
- funcparams = __imlib_copystr( function, __imlib_find_string( function, "(" ) + 1, strlen(function)-2 );
+ Imlib_Image retval;
+
+ D("(--) ===> Entering __imlib_script_parse_function()");
+ funcname =
+ __imlib_copystr(function, 0, __imlib_find_string(function, "(") - 1);
+ funcparams =
+ __imlib_copystr(function, __imlib_find_string(function, "(") + 1,
+ strlen(function) - 2);
#ifdef FDEBUG
- printf( "DEBUG: (??) = function <%s>( \"%s\" )\n", funcname, funcparams );
+ printf("DEBUG: (??) = function <%s>( \"%s\" )\n", funcname, funcparams);
#endif
- params = __imlib_script_parse_parameters( im, funcparams );
+ params = __imlib_script_parse_parameters(im, funcparams);
/* excute the filter */
- filter = __imlib_get_dynamic_filter( funcname );
- if( filter != NULL )
- {
+ filter = __imlib_get_dynamic_filter(funcname);
+ if (filter != NULL)
+ {
#ifdef FDEBUG
- printf( "DEBUG: (--) Executing Filter \"%s\".\n", funcname );
+ printf("DEBUG: (--) Executing Filter \"%s\".\n", funcname);
#endif
- retval = filter->exec_filter( funcname, im, params );
- }
+ retval = filter->exec_filter(funcname, im, params);
+ }
else
- {
+ {
#ifdef FDEBUG
- printf( "DEBUG: (!!) Can't find filter \"%s\", returning given image.\n", funcname );
+ printf
+ ("DEBUG: (!!) Can't find filter \"%s\", returning given image.\n",
+ funcname);
#endif
- retval = im;
- }
- D( "Get Here" );
+ retval = im;
+ }
+ D("Get Here");
/* clean up params */
- free( funcname );
- free( funcparams );
- __imlib_script_tidyup_params( params );
- D( "(--) <=== Leaving __imlib_script_parse_function()" );
+ free(funcname);
+ free(funcparams);
+ __imlib_script_tidyup_params(params);
+ D("(--) <=== Leaving __imlib_script_parse_function()");
return retval;
}
-Imlib_Image __imlib_script_parse( Imlib_Image im, char *script, va_list param_list )
+Imlib_Image
+__imlib_script_parse(Imlib_Image im, char *script, va_list param_list)
{
- int i = 0, in_quote = 0, start = 0, depth = 0;
- char *scriptbuf = NULL, *function;
-
- D( "(--) Script Parser Start." );
- if( script != NULL && strlen(script) > 0 )
- {
- vars = malloc( sizeof( IVariable ) );
- vars->ptr = NULL;
- vars->next = NULL;
- curtail = vars;
- current_var = vars;
- /* gather up variable from the command line */
- D( "(--) String Whitespace from script." );
- scriptbuf = __imlib_stripwhitespace( strdup( script ) );
-
- i = __imlib_find_string( scriptbuf+start, "=[]") - 1;
- while( i > 0 )
- {
- __imlib_script_add_var( va_arg( param_list, void * ) );
- start = start+i+2;
- i = __imlib_find_string( scriptbuf+start, "=[]") - 1;
- i = ( i == 0 ? 0 : i );
- D( "(??) Found pointer variable" );
- }
-
- start = 0;
- i = 0;
- for( i = 0; i < strlen( scriptbuf ); i++ )
- {
- if( script[i] == '\"' )
- in_quote = (in_quote == 0 ? 1 : 0);
- if( !in_quote && script[i] == '(' ) depth++;
- if( !in_quote && script[i] == ')' ) depth--;
- if( !in_quote && (script[i] == ';') && depth == 0 )
- {
- function = __imlib_copystr( scriptbuf, start, i-1 );
- im = __imlib_script_parse_function( im, function );
- imlib_context_set_image( im );
- start = i+1;
- free( function );
- }
- }
- D( "(--) Cleaning up parameter list" );
- __imlib_script_tidyup();
- D( "(--) Script Parser Successful." );
- free( scriptbuf );
- return im;
- }
+ int i = 0, in_quote = 0, start = 0, depth = 0;
+ char *scriptbuf = NULL, *function;
+
+ D("(--) Script Parser Start.");
+ if (script != NULL && strlen(script) > 0)
+ {
+ vars = malloc(sizeof(IVariable));
+ vars->ptr = NULL;
+ vars->next = NULL;
+ curtail = vars;
+ current_var = vars;
+ /* gather up variable from the command line */
+ D("(--) String Whitespace from script.");
+ scriptbuf = __imlib_stripwhitespace(strdup(script));
+
+ i = __imlib_find_string(scriptbuf + start, "=[]") - 1;
+ while (i > 0)
+ {
+ __imlib_script_add_var(va_arg(param_list, void *));
+
+ start = start + i + 2;
+ i = __imlib_find_string(scriptbuf + start, "=[]") - 1;
+ i = (i == 0 ? 0 : i);
+ D("(??) Found pointer variable");
+ }
+
+ start = 0;
+ i = 0;
+ for (i = 0; i < strlen(scriptbuf); i++)
+ {
+ if (script[i] == '\"')
+ in_quote = (in_quote == 0 ? 1 : 0);
+ if (!in_quote && script[i] == '(')
+ depth++;
+ if (!in_quote && script[i] == ')')
+ depth--;
+ if (!in_quote && (script[i] == ';') && depth == 0)
+ {
+ function = __imlib_copystr(scriptbuf, start, i - 1);
+ im = __imlib_script_parse_function(im, function);
+ imlib_context_set_image(im);
+ start = i + 1;
+ free(function);
+ }
+ }
+ D("(--) Cleaning up parameter list");
+ __imlib_script_tidyup();
+ D("(--) Script Parser Successful.");
+ free(scriptbuf);
+ return im;
+ }
else
- {
- D( "(!!) Script Parser Failed." );
- return NULL;
- }
+ {
+ D("(!!) Script Parser Failed.");
+ return NULL;
+ }
}
-
diff --git a/src/updates.c b/src/updates.c
index e9f91ba..c96c2e8 100644
--- a/src/updates.c
+++ b/src/updates.c
@@ -1,15 +1,13 @@
#include "common.h"
#include "updates.h"
-enum _t_used
-{
- T_UNUSED = 0,
+enum _t_used {
+ T_UNUSED = 0,
T_USED = 1
};
-struct _tile
-{
- enum _t_used used;
+struct _tile {
+ enum _t_used used;
};
#define TBITS 5
@@ -19,13 +17,13 @@ struct _tile
#define T(x, y) t[((y) * tw) + (x)]
-ImlibUpdate *
-__imlib_MergeUpdate(ImlibUpdate *u, int w, int h, int hgapmax)
+ImlibUpdate *
+__imlib_MergeUpdate(ImlibUpdate * u, int w, int h, int hgapmax)
{
- ImlibUpdate *nu = NULL, *uu;
- struct _tile *t;
- int tw, th, x, y, i;
- int *gaps = NULL;
+ ImlibUpdate *nu = NULL, *uu;
+ struct _tile *t;
+ int tw, th, x, y, i;
+ int *gaps = NULL;
/* if theres no rects to process.. return NULL */
if (!u)
@@ -40,117 +38,114 @@ __imlib_MergeUpdate(ImlibUpdate *u, int w, int h, int hgapmax)
/* fill in tiles to be all not used */
for (i = 0, y = 0; y < th; y++)
{
- for (x = 0; x < tw; x++)
- t[i++].used = T_UNUSED;
+ for (x = 0; x < tw; x++)
+ t[i++].used = T_UNUSED;
}
- /* fill in all tiles*/
+ /* fill in all tiles */
for (uu = u; uu; uu = uu->next)
{
- CLIP(uu->x, uu->y, uu->w, uu->h, 0, 0, w, h);
- for (y = uu->y >> TB; y <= ((uu->y + uu->h - 1) >> TB); y++)
- {
- for (x = uu->x >> TB; x <= ((uu->x + uu->w - 1) >> TB); x++)
- T(x, y).used = T_USED;
- }
+ CLIP(uu->x, uu->y, uu->w, uu->h, 0, 0, w, h);
+ for (y = uu->y >> TB; y <= ((uu->y + uu->h - 1) >> TB); y++)
+ {
+ for (x = uu->x >> TB; x <= ((uu->x + uu->w - 1) >> TB); x++)
+ T(x, y).used = T_USED;
+ }
}
/* scan each line - if > hgapmax gaps between tiles, then fill smallest */
- gaps = malloc(tw *sizeof(int));
+ gaps = malloc(tw * sizeof(int));
for (y = 0; y < th; y++)
{
- int hgaps = 0, start = -1, min;
- char have = 1, gap = 0;
-
- for (x = 0; x < tw; x++)
- gaps[x] = 0;
- for (x = 0; x < tw; x++)
- {
- if ((have) && (T(x, y).used == T_UNUSED))
- {
- start = x;
- gap = 1;
- have = 0;
- }
- else if ((!have) && (gap) && (T(x, y).used & T_USED))
- {
- gap = 0;
- hgaps++;
- have = 1;
- gaps[start] = x - start;
- }
- else if (T(x, y).used & T_USED)
- have = 1;
- }
- while (hgaps > hgapmax)
- {
- start = -1;
- min = tw;
-
- for (x = 0; x < tw; x++)
- {
- if ((gaps[x] > 0) && (gaps[x] < min))
- {
- start = x;
- min = gaps[x];
- }
- }
- if (start >= 0)
- {
- gaps[start] = 0;
- for (x = start;
- T(x, y).used == T_UNUSED;
- T(x++, y).used = T_USED);
- hgaps--;
- }
- }
+ int hgaps = 0, start = -1, min;
+ char have = 1, gap = 0;
+
+ for (x = 0; x < tw; x++)
+ gaps[x] = 0;
+ for (x = 0; x < tw; x++)
+ {
+ if ((have) && (T(x, y).used == T_UNUSED))
+ {
+ start = x;
+ gap = 1;
+ have = 0;
+ }
+ else if ((!have) && (gap) && (T(x, y).used & T_USED))
+ {
+ gap = 0;
+ hgaps++;
+ have = 1;
+ gaps[start] = x - start;
+ }
+ else if (T(x, y).used & T_USED)
+ have = 1;
+ }
+ while (hgaps > hgapmax)
+ {
+ start = -1;
+ min = tw;
+
+ for (x = 0; x < tw; x++)
+ {
+ if ((gaps[x] > 0) && (gaps[x] < min))
+ {
+ start = x;
+ min = gaps[x];
+ }
+ }
+ if (start >= 0)
+ {
+ gaps[start] = 0;
+ for (x = start;
+ T(x, y).used == T_UNUSED; T(x++, y).used = T_USED);
+ hgaps--;
+ }
+ }
}
free(gaps);
/* coalesce tiles into larger blocks and make new rect list */
for (y = 0; y < th; y++)
{
- for (x = 0; x < tw; x++)
- {
- if (T(x, y).used & T_USED)
- {
- int xx, yy, ww, hh, ok;
-
- for (xx = x + 1, ww = 1;
- (T(xx, y).used & T_USED) && (xx < tw);
- xx++, ww++);
- for (yy = y + 1, hh = 1, ok = 1;
- (yy < th) && (ok);
- yy++, hh++)
- {
- for (xx = x; xx < (x + ww); xx++)
- {
- if (!(T(xx, yy).used & T_USED))
- {
- ok = 0;
- xx = x + ww;
- hh--;
- }
- }
- }
- for (yy = y; yy < (y + hh); yy++)
- {
- for (xx = x; xx < (x + ww); xx++)
- T(xx, yy).used = T_UNUSED;
- }
- nu = __imlib_AddUpdate(nu, (x << TB), (y << TB),
- (ww << TB), (hh << TB));
- }
- }
+ for (x = 0; x < tw; x++)
+ {
+ if (T(x, y).used & T_USED)
+ {
+ int xx, yy, ww, hh, ok;
+
+ for (xx = x + 1, ww = 1;
+ (T(xx, y).used & T_USED) && (xx < tw); xx++, ww++);
+ for (yy = y + 1, hh = 1, ok = 1;
+ (yy < th) && (ok); yy++, hh++)
+ {
+ for (xx = x; xx < (x + ww); xx++)
+ {
+ if (!(T(xx, yy).used & T_USED))
+ {
+ ok = 0;
+ xx = x + ww;
+ hh--;
+ }
+ }
+ }
+ for (yy = y; yy < (y + hh); yy++)
+ {
+ for (xx = x; xx < (x + ww); xx++)
+ T(xx, yy).used = T_UNUSED;
+ }
+ nu = __imlib_AddUpdate(nu, (x << TB), (y << TB),
+ (ww << TB), (hh << TB));
+ }
+ }
}
free(t);
__imlib_FreeUpdates(u);
return nu;
}
-ImlibUpdate *
-__imlib_AddUpdate(ImlibUpdate *u, int x, int y, int w, int h)
+ImlibUpdate *
+__imlib_AddUpdate(ImlibUpdate * u, int x, int y, int w, int h)
{
- ImlibUpdate *nu;
+ ImlibUpdate *nu;
- if ((w < 1) || (h < 1) || ((x + w) < 1) || ((y + h) < 1))
+ if ((w < 1) || (h < 1) || ((x + w) < 1) || ((y + h) < 1))
return u;
nu = malloc(sizeof(ImlibUpdate));
nu->x = x;
@@ -162,27 +157,27 @@ __imlib_AddUpdate(ImlibUpdate *u, int x, int y, int w, int h)
}
void
-__imlib_FreeUpdates(ImlibUpdate *u)
+__imlib_FreeUpdates(ImlibUpdate * u)
{
- ImlibUpdate *uu;
-
+ ImlibUpdate *uu;
+
uu = u;
while (uu)
{
- u = uu;
- uu = uu->next;
- free(u);
+ u = uu;
+ uu = uu->next;
+ free(u);
}
}
-ImlibUpdate *
-__imlib_DupUpdates(ImlibUpdate *u)
+ImlibUpdate *
+__imlib_DupUpdates(ImlibUpdate * u)
{
- ImlibUpdate *uu, *cu, *pu, *ru;
-
+ ImlibUpdate *uu, *cu, *pu, *ru;
+
if (!u)
return NULL;
-
+
uu = malloc(sizeof(ImlibUpdate));
memcpy(uu, u, sizeof(ImlibUpdate));
cu = u->next;
@@ -190,11 +185,11 @@ __imlib_DupUpdates(ImlibUpdate *u)
ru = uu;
while (cu)
{
- uu = malloc(sizeof(ImlibUpdate));
- memcpy(uu, u, sizeof(ImlibUpdate));
- pu->next = uu;
- pu = cu;
- cu = cu->next;
+ uu = malloc(sizeof(ImlibUpdate));
+ memcpy(uu, u, sizeof(ImlibUpdate));
+ pu->next = uu;
+ pu = cu;
+ cu = cu->next;
}
return ru;
}
diff --git a/src/ximage.c b/src/ximage.c
index 6f80842..6351df4 100644
--- a/src/ximage.c
+++ b/src/ximage.c
@@ -7,18 +7,18 @@
#include "ximage.h"
/* static private variables */
-static signed char x_does_shm = -1;
-static int list_num = 0;
-static XImage **list_xim = NULL;
+static signed char x_does_shm = -1;
+static int list_num = 0;
+static XImage **list_xim = NULL;
static XShmSegmentInfo **list_si = NULL;
-static Display **list_d = NULL;
-static char *list_used = NULL;
-static int list_mem_use = 0;
-static int list_max_mem = 1024 * 1024 * 1024;
-static int list_max_count = 0;
+static Display **list_d = NULL;
+static char *list_used = NULL;
+static int list_mem_use = 0;
+static int list_max_mem = 1024 * 1024 * 1024;
+static int list_max_count = 0;
/* temporary X error catcher we use later */
-static char _x_err = 0;
+static char _x_err = 0;
/* the fucntion we use for catching the error */
static void
@@ -31,132 +31,140 @@ TmpXError(Display * d, XErrorEvent * ev)
}
void
-__imlib_SetMaxXImageCount(Display *d, int num)
+__imlib_SetMaxXImageCount(Display * d, int num)
{
list_max_count = num;
__imlib_FlushXImage(d);
}
int
-__imlib_GetMaxXImageCount(Display *d)
+__imlib_GetMaxXImageCount(Display * d)
{
return list_max_count;
d = NULL;
}
void
-__imlib_SetMaxXImageTotalSize(Display *d, int num)
+__imlib_SetMaxXImageTotalSize(Display * d, int num)
{
list_max_mem = num;
__imlib_FlushXImage(d);
}
int
-__imlib_GetMaxXImageTotalSize(Display *d)
+__imlib_GetMaxXImageTotalSize(Display * d)
{
return list_max_mem;
d = NULL;
}
void
-__imlib_FlushXImage(Display *d)
+__imlib_FlushXImage(Display * d)
{
- int i;
- XImage *xim;
- char did_free = 1;
-
+ int i;
+ XImage *xim;
+ char did_free = 1;
+
while (((list_mem_use > list_max_mem) || (list_num > list_max_count)) &&
- (did_free))
+ (did_free))
{
- did_free = 0;
- for (i = 0; i < list_num; i++)
- {
- if (list_used[i] == 0)
- {
- int j;
-
- xim = list_xim[i];
- list_mem_use -= xim->bytes_per_line * xim->height;
- if (list_si[i])
- XShmDetach(d, list_si[i]);
- XDestroyImage(xim);
- if (list_si[i])
- {
- shmdt(list_si[i]->shmaddr);
- shmctl(list_si[i]->shmid, IPC_RMID, 0);
- free(list_si[i]);
- }
- list_num--;
- for (j = i; j < list_num; j++)
- {
- list_xim[j] = list_xim[j + 1];
- list_si[j] = list_si[j + 1];
- list_used[j] = list_used[j + 1];
- list_d[j] = list_d[j + 1];
- }
- if (list_num == 0)
- {
- if (list_xim) free(list_xim);
- if (list_si) free(list_si);
- if (list_used) free(list_used);
- if (list_d) free(list_d);
- list_xim = NULL;
- list_si = NULL;
- list_used = NULL;
- list_d = NULL;
- }
- else
- {
- list_xim = realloc(list_xim, sizeof(XImage *) * list_num);
- list_si = realloc(list_si, sizeof(XShmSegmentInfo *) * list_num);
- list_used = realloc(list_used, sizeof(char) * list_num);
- list_d = realloc(list_d, sizeof(Display *) * list_num);
- }
- did_free = 1;
- }
- }
+ did_free = 0;
+ for (i = 0; i < list_num; i++)
+ {
+ if (list_used[i] == 0)
+ {
+ int j;
+
+ xim = list_xim[i];
+ list_mem_use -= xim->bytes_per_line * xim->height;
+ if (list_si[i])
+ XShmDetach(d, list_si[i]);
+ XDestroyImage(xim);
+ if (list_si[i])
+ {
+ shmdt(list_si[i]->shmaddr);
+ shmctl(list_si[i]->shmid, IPC_RMID, 0);
+ free(list_si[i]);
+ }
+ list_num--;
+ for (j = i; j < list_num; j++)
+ {
+ list_xim[j] = list_xim[j + 1];
+ list_si[j] = list_si[j + 1];
+ list_used[j] = list_used[j + 1];
+ list_d[j] = list_d[j + 1];
+ }
+ if (list_num == 0)
+ {
+ if (list_xim)
+ free(list_xim);
+ if (list_si)
+ free(list_si);
+ if (list_used)
+ free(list_used);
+ if (list_d)
+ free(list_d);
+ list_xim = NULL;
+ list_si = NULL;
+ list_used = NULL;
+ list_d = NULL;
+ }
+ else
+ {
+ list_xim =
+ realloc(list_xim, sizeof(XImage *) * list_num);
+ list_si =
+ realloc(list_si,
+ sizeof(XShmSegmentInfo *) * list_num);
+ list_used = realloc(list_used, sizeof(char) * list_num);
+ list_d = realloc(list_d, sizeof(Display *) * list_num);
+ }
+ did_free = 1;
+ }
+ }
}
}
/* free (consume == opposite of produce) the XImage (mark as unused) */
void
-__imlib_ConsumeXImage(Display *d, XImage *xim)
+__imlib_ConsumeXImage(Display * d, XImage * xim)
{
- int i;
-
+ int i;
+
/* march through the XImage list */
for (i = 0; i < list_num; i++)
{
- /* find a match */
- if (list_xim[i] == xim)
- {
- /* we have a match = mark as unused */
- list_used[i] = 0;
- /* flush the XImage list to get rud of stuff we dont want */
- __imlib_FlushXImage(d);
- /* return */
- return;
- }
+ /* find a match */
+ if (list_xim[i] == xim)
+ {
+ /* we have a match = mark as unused */
+ list_used[i] = 0;
+ /* flush the XImage list to get rud of stuff we dont want */
+ __imlib_FlushXImage(d);
+ /* return */
+ return;
+ }
}
}
/* create a new XImage or find it on our list of currently available ones so */
/* we dont need to create a new one */
-XImage *
-__imlib_ProduceXImage(Display *d, Visual *v, int depth, int w, int h, char *shared)
+XImage *
+__imlib_ProduceXImage(Display * d, Visual * v, int depth, int w, int h,
+ char *shared)
{
- XImage *xim;
- int i;
-
+ XImage *xim;
+ int i;
+
/* if we havent check the shm extension before - see if its there */
if (x_does_shm < 0)
{
- /* if its there set dose_xhm flag */
- if (XShmQueryExtension(d))
- x_does_shm = 1;
- /* clear the flag - no shm at all */
- else
- x_does_shm = 0;
+ /* if its there set dose_xhm flag */
+ if (XShmQueryExtension(d))
+ x_does_shm = 1;
+ /* clear the flag - no shm at all */
+ else
+ x_does_shm = 0;
}
/* find a cached XImage (to avoid server to & fro) that is big enough */
/* for our needs and the right depth */
@@ -164,145 +172,144 @@ __imlib_ProduceXImage(Display *d, Visual *v, int depth, int w, int h, char *shar
/* go thru the current image list */
for (i = 0; i < list_num; i++)
{
- /* if the image has the same depth, width and height - recycle it */
- /* as long as its not used */
- if ((list_xim[i]->bits_per_pixel == depth) &&
- (list_xim[i]->width >= w) &&
- (list_xim[i]->height >= h) &&
- /* (list_d[i] == d) &&*/
- (!list_used[i]))
- {
- /* mark it as used */
- list_used[i] = 1;
- /* if its shared set shared flag */
- if (list_si[i])
- *shared = 1;
- /* return it */
- return list_xim[i];
- }
+ /* if the image has the same depth, width and height - recycle it */
+ /* as long as its not used */
+ if ((list_xim[i]->bits_per_pixel == depth) &&
+ (list_xim[i]->width >= w) && (list_xim[i]->height >= h) &&
+ /* (list_d[i] == d) && */
+ (!list_used[i]))
+ {
+ /* mark it as used */
+ list_used[i] = 1;
+ /* if its shared set shared flag */
+ if (list_si[i])
+ *shared = 1;
+ /* return it */
+ return list_xim[i];
+ }
}
/* can't find a usable XImage on the cache - create one */
/* add the new XImage to the XImage cache */
list_num++;
if (list_num == 1)
{
- list_xim = malloc(sizeof(XImage *) * list_num);
- list_si = malloc(sizeof(XShmSegmentInfo *) * list_num);
- list_used = malloc(sizeof(char) * list_num);
- list_d = malloc(sizeof(Display *) * list_num);
+ list_xim = malloc(sizeof(XImage *) * list_num);
+ list_si = malloc(sizeof(XShmSegmentInfo *) * list_num);
+ list_used = malloc(sizeof(char) * list_num);
+ list_d = malloc(sizeof(Display *) * list_num);
}
else
{
- list_xim = realloc(list_xim, sizeof(XImage *) * list_num);
- list_si = realloc(list_si, sizeof(XShmSegmentInfo *) * list_num);
- list_used = realloc(list_used, sizeof(char) * list_num);
- list_d = realloc(list_d, sizeof(Display *) * list_num);
+ list_xim = realloc(list_xim, sizeof(XImage *) * list_num);
+ list_si = realloc(list_si, sizeof(XShmSegmentInfo *) * list_num);
+ list_used = realloc(list_used, sizeof(char) * list_num);
+ list_d = realloc(list_d, sizeof(Display *) * list_num);
}
list_si[list_num - 1] = malloc(sizeof(XShmSegmentInfo));
-
+
/* work on making a shared image */
xim = NULL;
/* if the server does shm */
if (x_does_shm)
{
- /* try create an shm image */
- xim = XShmCreateImage(d, v, depth, ZPixmap, NULL,
- list_si[list_num - 1], w, h);
- /* if it succeeds */
- if (xim)
- {
- /* add to list */
- list_xim[list_num - 1] = xim;
- /* get an shm id of this image */
- list_si[list_num - 1]->shmid =
- shmget(IPC_PRIVATE, xim->bytes_per_line * xim->height,
- IPC_CREAT | 0777);
- /* if the get succeeds */
- if (list_si[list_num - 1]->shmid != -1)
- {
- /* set the params for the shm segment */
- list_si[list_num - 1]->readOnly = False;
- list_si[list_num - 1]->shmaddr = xim->data =
- shmat(list_si[list_num - 1]->shmid, 0, 0);
- /* get the shm addr for this data chunk */
- if (xim->data != (char *)-1)
- {
- XErrorHandler ph;
-
- /* setup a temporary error handler */
- _x_err = 0;
- ph = XSetErrorHandler((XErrorHandler) TmpXError);
- /* ask X to attach to the shared mem segment */
- XShmAttach(d, list_si[list_num - 1]);
- /* wait for X to reply and do this */
- XSync(d, False);
- /* reset the error handler */
- XSetErrorHandler((XErrorHandler) ph);
- /* if we attached without an error we're set */
- if (!_x_err)
- {
- /* mark the image as used */
- list_used[list_num - 1] = 1;
- /* incrument our memory count */
- list_mem_use += xim->bytes_per_line * xim->height;
- /* set shared flag */
- *shared = 1;
- }
- /* attach by X failed... must be remote client */
- else
- {
- /* flag shm foevere to not work - remote */
- x_does_shm = 0;
- /* destroy our previous image */
- XDestroyImage(xim);
- /* detach */
- shmdt(list_si[list_num - 1]->shmaddr);
- /* remove the shm id */
- shmctl(list_si[list_num - 1]->shmid, IPC_RMID, 0);
- /* flag out xim as NULL */
- xim = NULL;
- }
- }
- /* get failed - out of shm id's or shm segment too big ? */
- else
- {
- /* destroy previous image */
- XDestroyImage(xim);
- /* remove the shm id we created */
- shmctl(list_si[list_num - 1]->shmid, IPC_RMID, 0);
- /* flag xim as NULL */
- xim = NULL;
- }
- }
- /* couldnt create SHM image ? */
- else
- {
- /* destroy previous image */
- XDestroyImage(xim);
- /* flag xim as NULL */
- xim = NULL;
- }
- }
+ /* try create an shm image */
+ xim = XShmCreateImage(d, v, depth, ZPixmap, NULL,
+ list_si[list_num - 1], w, h);
+ /* if it succeeds */
+ if (xim)
+ {
+ /* add to list */
+ list_xim[list_num - 1] = xim;
+ /* get an shm id of this image */
+ list_si[list_num - 1]->shmid =
+ shmget(IPC_PRIVATE, xim->bytes_per_line * xim->height,
+ IPC_CREAT | 0777);
+ /* if the get succeeds */
+ if (list_si[list_num - 1]->shmid != -1)
+ {
+ /* set the params for the shm segment */
+ list_si[list_num - 1]->readOnly = False;
+ list_si[list_num - 1]->shmaddr = xim->data =
+ shmat(list_si[list_num - 1]->shmid, 0, 0);
+ /* get the shm addr for this data chunk */
+ if (xim->data != (char *)-1)
+ {
+ XErrorHandler ph;
+
+ /* setup a temporary error handler */
+ _x_err = 0;
+ ph = XSetErrorHandler((XErrorHandler) TmpXError);
+ /* ask X to attach to the shared mem segment */
+ XShmAttach(d, list_si[list_num - 1]);
+ /* wait for X to reply and do this */
+ XSync(d, False);
+ /* reset the error handler */
+ XSetErrorHandler((XErrorHandler) ph);
+ /* if we attached without an error we're set */
+ if (!_x_err)
+ {
+ /* mark the image as used */
+ list_used[list_num - 1] = 1;
+ /* incrument our memory count */
+ list_mem_use += xim->bytes_per_line * xim->height;
+ /* set shared flag */
+ *shared = 1;
+ }
+ /* attach by X failed... must be remote client */
+ else
+ {
+ /* flag shm foevere to not work - remote */
+ x_does_shm = 0;
+ /* destroy our previous image */
+ XDestroyImage(xim);
+ /* detach */
+ shmdt(list_si[list_num - 1]->shmaddr);
+ /* remove the shm id */
+ shmctl(list_si[list_num - 1]->shmid, IPC_RMID, 0);
+ /* flag out xim as NULL */
+ xim = NULL;
+ }
+ }
+ /* get failed - out of shm id's or shm segment too big ? */
+ else
+ {
+ /* destroy previous image */
+ XDestroyImage(xim);
+ /* remove the shm id we created */
+ shmctl(list_si[list_num - 1]->shmid, IPC_RMID, 0);
+ /* flag xim as NULL */
+ xim = NULL;
+ }
+ }
+ /* couldnt create SHM image ? */
+ else
+ {
+ /* destroy previous image */
+ XDestroyImage(xim);
+ /* flag xim as NULL */
+ xim = NULL;
+ }
+ }
}
/* ok if xim == NULL it all failed - fall back to XImages */
if (!xim)
{
- /* get rid of out shm info struct */
- free(list_si[list_num - 1]);
- /* flag it as NULL ot indicate a normal XImage */
- list_si[list_num - 1] = NULL;
- /* create a normal ximage */
- xim = XCreateImage(d, v, depth, ZPixmap, 0, NULL, w, h, 32, 0);
- /* allocate data for it */
- xim->data = malloc(xim->bytes_per_line * xim->height);
- /* add xim to our list */
- list_xim[list_num - 1] = xim;
- /* incriment our memory count */
- list_mem_use += xim->bytes_per_line * xim->height;
- /* mark image as used */
- list_used[list_num - 1] = 1;
- /* remember what display that XImage was for */
- list_d[list_num - 1] = d;
+ /* get rid of out shm info struct */
+ free(list_si[list_num - 1]);
+ /* flag it as NULL ot indicate a normal XImage */
+ list_si[list_num - 1] = NULL;
+ /* create a normal ximage */
+ xim = XCreateImage(d, v, depth, ZPixmap, 0, NULL, w, h, 32, 0);
+ /* allocate data for it */
+ xim->data = malloc(xim->bytes_per_line * xim->height);
+ /* add xim to our list */
+ list_xim[list_num - 1] = xim;
+ /* incriment our memory count */
+ list_mem_use += xim->bytes_per_line * xim->height;
+ /* mark image as used */
+ list_used[list_num - 1] = 1;
+ /* remember what display that XImage was for */
+ list_d[list_num - 1] = d;
}
/* flush unused images from the image list */
__imlib_FlushXImage(d);
diff --git a/test/bmtest.c b/test/bmtest.c
index 9ee0464..5a48138 100644
--- a/test/bmtest.c
+++ b/test/bmtest.c
@@ -21,35 +21,39 @@
*/
#include "Imlib2.h"
-Display *disp;
-Window win;
-Visual *vis;
-Colormap cm;
-int depth;
+Display *disp;
+Window win;
+Visual *vis;
+Colormap cm;
+int depth;
-int main (int argc, char **argv)
+int
+main(int argc, char **argv)
{
- int i, j, w, h, x, y;
- Imlib_Image im = NULL, im_bg = NULL;
- XEvent ev;
-
+ int i, j, w, h, x, y;
+ Imlib_Image im = NULL, im_bg = NULL;
+ XEvent ev;
+
/**
* Initialization according to options
*/
printf("Initialising\n");
-
+
/**
* First tests to determine which rendering task to perform
*/
- 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, 100, 100, 0, 0, 0);
- XSelectInput(disp, win, ButtonPressMask | ButtonReleaseMask |
- ButtonMotionMask | PointerMotionMask | ExposureMask);
+ 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, 100, 100, 0, 0,
+ 0);
+ XSelectInput(disp, win,
+ ButtonPressMask | ButtonReleaseMask | ButtonMotionMask |
+ PointerMotionMask | ExposureMask);
XMapWindow(disp, win);
-
+
/**
* Start rendering
*/
@@ -61,61 +65,63 @@ int main (int argc, char **argv)
imlib_context_set_dither(1);
imlib_context_set_blend(0);
imlib_context_set_color_modifier(NULL);
-
+
im_bg = imlib_load_image("test_images/imlib2.png");
im = imlib_load_image("test_images/imlib2.png");
-
+
imlib_context_set_image(im_bg);
w = imlib_image_get_width();
h = imlib_image_get_height();
- printf( "Resizing Window to %d by %d\n", w, h );
+ printf("Resizing Window to %d by %d\n", w, h);
XResizeWindow(disp, win, w, h);
XSync(disp, False);
x = -9999;
y = -9999;
while (1)
- {
- Imlib_Image *temp, *temp2;
- do
- {
- 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;
-
- }
- }
- while (XPending(disp));
-
- imlib_context_set_blend( 0 );
- imlib_context_set_image(im_bg);
- temp = imlib_clone_image();
- imlib_context_set_image( temp );
-
- /* imlib_blend_image_onto_image(im_bg, 0,
- 0, 0, w, h,
- 0, 0, w, h);
- first = 0;*/
-
- imlib_apply_filter("bump_map_point(x=[],y=[],map=test_images/imlib2.png);", &x, &y );
+ {
+ Imlib_Image *temp, *temp2;
+
+ do
+ {
+ 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;
+
+ }
+ }
+ while (XPending(disp));
+
+ imlib_context_set_blend(0);
+ imlib_context_set_image(im_bg);
+ temp = imlib_clone_image();
+ imlib_context_set_image(temp);
+
+ /* imlib_blend_image_onto_image(im_bg, 0,
+ * 0, 0, w, h,
+ * 0, 0, w, h);
+ * first = 0; */
+
+ imlib_apply_filter
+ ("bump_map_point(x=[],y=[],map=test_images/imlib2.png);", &x, &y);
- temp2 = im_bg;
- im_bg = temp;
- imlib_context_set_image(im_bg);
- imlib_render_image_on_drawable(0, 0 );
- im_bg = temp2;
- imlib_context_set_image(temp);
- imlib_free_image();
- }
+ temp2 = im_bg;
+ im_bg = temp;
+ imlib_context_set_image(im_bg);
+ imlib_render_image_on_drawable(0, 0);
+ im_bg = temp2;
+ imlib_context_set_image(temp);
+ imlib_free_image();
+ }
return 0;
}
diff --git a/test/color_spaces.c b/test/color_spaces.c
index 4bb270a..c5cc593 100644
--- a/test/color_spaces.c
+++ b/test/color_spaces.c
@@ -12,23 +12,23 @@
#include "Imlib2.h"
-Display *disp;
-Window win;
-Visual *vis;
-Colormap cm;
-int depth;
+Display *disp;
+Window win;
+Visual *vis;
+Colormap cm;
+int depth;
int
main(int argc, char **argv)
{
- int w, h, tw, th;
- Imlib_Image im_bg = NULL;
- XEvent ev;
- KeySym keysym;
- static char kbuf[20];
- Imlib_Font font;
- Imlib_Color_Range range;
-
+ int w, h, tw, th;
+ Imlib_Image im_bg = NULL;
+ XEvent ev;
+ KeySym keysym;
+ static char kbuf[20];
+ Imlib_Font font;
+ Imlib_Color_Range range;
+
/**
* First tests to determine which rendering task to perform
*/
@@ -37,8 +37,8 @@ main(int argc, char **argv)
depth = DefaultDepth(disp, DefaultScreen(disp));
cm = DefaultColormap(disp, DefaultScreen(disp));
win =
- XCreateSimpleWindow(disp, DefaultRootWindow(disp), 0, 0, 100, 100, 0, 0,
- 0);
+ XCreateSimpleWindow(disp, DefaultRootWindow(disp), 0, 0, 100, 100, 0, 0,
+ 0);
XSelectInput(disp, win,
ButtonPressMask | ButtonReleaseMask | ButtonMotionMask |
PointerMotionMask | ExposureMask | KeyPressMask);
@@ -67,76 +67,76 @@ main(int argc, char **argv)
XSync(disp, False);
while (1)
- {
- do
- {
- XNextEvent(disp, &ev);
- switch (ev.type)
- {
- case ButtonRelease:
- exit(0);
- break;
- case KeyPress:
- XLookupString(&ev.xkey, (char *) kbuf, sizeof(kbuf), &keysym,
- NULL);
- switch (*kbuf)
- {
- case 'q':
- exit(0);
- default:
- break;
- }
- break;
- default:
- break;
+ {
+ do
+ {
+ XNextEvent(disp, &ev);
+ switch (ev.type)
+ {
+ case ButtonRelease:
+ exit(0);
+ break;
+ case KeyPress:
+ XLookupString(&ev.xkey, (char *)kbuf, sizeof(kbuf), &keysym,
+ NULL);
+ switch (*kbuf)
+ {
+ case 'q':
+ exit(0);
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
- }
- }
- while (XPending(disp));
+ }
+ }
+ while (XPending(disp));
- imlib_context_set_image(im_bg);
- imlib_context_set_color(128, 128, 255, 255);
- imlib_image_fill_rectangle(0, 0, w, h);
- imlib_context_set_color(0, 0, 0, 255);
- imlib_image_draw_rectangle(20, 20, 560, 140);
- imlib_image_draw_rectangle(20, 220, 560, 140);
- font = imlib_load_font("notepad/15");
- if (font)
- {
- char text[4096];
+ imlib_context_set_image(im_bg);
+ imlib_context_set_color(128, 128, 255, 255);
+ imlib_image_fill_rectangle(0, 0, w, h);
+ imlib_context_set_color(0, 0, 0, 255);
+ imlib_image_draw_rectangle(20, 20, 560, 140);
+ imlib_image_draw_rectangle(20, 220, 560, 140);
+ font = imlib_load_font("notepad/15");
+ if (font)
+ {
+ char text[4096];
- imlib_context_set_font(font);
- imlib_context_set_color(0, 0, 0, 255);
- sprintf(text,"RGBA range, 2 points, from red to magenta");
- imlib_get_text_size(text, &tw, &th);
- imlib_text_draw(300-tw/2, 180-th/2, text);
- sprintf(text,"HSVA range, 2 points, from red to magenta");
- imlib_get_text_size(text, &tw, &th);
- imlib_text_draw(300-tw/2, 380-th/2, text);
- imlib_free_font();
- }
+ imlib_context_set_font(font);
+ imlib_context_set_color(0, 0, 0, 255);
+ sprintf(text, "RGBA range, 2 points, from red to magenta");
+ imlib_get_text_size(text, &tw, &th);
+ imlib_text_draw(300 - tw / 2, 180 - th / 2, text);
+ sprintf(text, "HSVA range, 2 points, from red to magenta");
+ imlib_get_text_size(text, &tw, &th);
+ imlib_text_draw(300 - tw / 2, 380 - th / 2, text);
+ imlib_free_font();
+ }
- /* Draw rectangle w/ RGBA gradient */
- range = imlib_create_color_range();
- imlib_context_set_color_range(range);
- imlib_context_set_color(255, 0, 0, 255);
- imlib_add_color_to_color_range(0);
- imlib_context_set_color(255, 0, 255, 255);
- imlib_add_color_to_color_range(20);
- imlib_image_fill_color_range_rectangle(21, 21, 558, 138, -90.0);
- imlib_free_color_range();
+ /* Draw rectangle w/ RGBA gradient */
+ range = imlib_create_color_range();
+ imlib_context_set_color_range(range);
+ imlib_context_set_color(255, 0, 0, 255);
+ imlib_add_color_to_color_range(0);
+ imlib_context_set_color(255, 0, 255, 255);
+ imlib_add_color_to_color_range(20);
+ imlib_image_fill_color_range_rectangle(21, 21, 558, 138, -90.0);
+ imlib_free_color_range();
- /* Draw rectangle w/ HSVA gradient */
- range = imlib_create_color_range();
- imlib_context_set_color_range(range);
- imlib_context_set_color_hsva(0, 1, 1, 255);
- imlib_add_color_to_color_range(0);
- imlib_context_set_color_hsva(300, 1, 1, 255);
- imlib_add_color_to_color_range(20);
- imlib_image_fill_hsva_color_range_rectangle(21, 221, 558, 138, -90.0);
- imlib_free_color_range();
+ /* Draw rectangle w/ HSVA gradient */
+ range = imlib_create_color_range();
+ imlib_context_set_color_range(range);
+ imlib_context_set_color_hsva(0, 1, 1, 255);
+ imlib_add_color_to_color_range(0);
+ imlib_context_set_color_hsva(300, 1, 1, 255);
+ imlib_add_color_to_color_range(20);
+ imlib_image_fill_hsva_color_range_rectangle(21, 221, 558, 138, -90.0);
+ imlib_free_color_range();
- imlib_render_image_on_drawable(0, 0);
- }
+ imlib_render_image_on_drawable(0, 0);
+ }
return 0;
}
diff --git a/test/imlib2_test.c b/test/imlib2_test.c
index 7daf10d..68d01aa 100644
--- a/test/imlib2_test.c
+++ b/test/imlib2_test.c
@@ -6,41 +6,47 @@
#include <stdio.h>
/* some globals for our window & X display */
-Display *disp;
-Window win;
-Visual *vis;
-Colormap cm;
-int depth;
+Display *disp;
+Window win;
+Visual *vis;
+Colormap cm;
+int depth;
/* the program... */
-int main(int argc, char **argv)
+int
+main(int argc, char **argv)
{
/* events we get from X */
- XEvent ev;
+ XEvent ev;
+
/* areas to update */
- Imlib_Updates updates, current_update;
+ Imlib_Updates updates, current_update;
+
/* our virtual framebuffer image we draw into */
- Imlib_Image buffer;
+ Imlib_Image buffer;
+
/* a font */
- Imlib_Font font;
+ Imlib_Font font;
+
/* our color range */
- Imlib_Color_Range range;
+ Imlib_Color_Range range;
+
/* our mouse x, y coordinates */
- int mouse_x = 0, mouse_y = 0;
-
+ int mouse_x = 0, mouse_y = 0;
+
/* connect to X */
- disp = XOpenDisplay(NULL);
+ disp = XOpenDisplay(NULL);
/* get default visual , colormap etc. you could ask imlib2 for what it */
/* thinks is the best, but this example is intended to be simple */
- vis = DefaultVisual(disp, DefaultScreen(disp));
+ vis = DefaultVisual(disp, DefaultScreen(disp));
depth = DefaultDepth(disp, DefaultScreen(disp));
- cm = DefaultColormap(disp, DefaultScreen(disp));
+ cm = DefaultColormap(disp, DefaultScreen(disp));
/* create a window 640x480 */
- win = XCreateSimpleWindow(disp, DefaultRootWindow(disp),
- 0, 0, 640, 480, 0, 0, 0);
+ win = XCreateSimpleWindow(disp, DefaultRootWindow(disp),
+ 0, 0, 640, 480, 0, 0, 0);
/* tell X what events we are interested in */
- XSelectInput(disp, win, ButtonPressMask | ButtonReleaseMask |
- PointerMotionMask | ExposureMask);
+ XSelectInput(disp, win, ButtonPressMask | ButtonReleaseMask |
+ PointerMotionMask | ExposureMask);
/* show the window */
XMapWindow(disp, win);
/* set our cache to 2 Mb so it doesnt have to go hit the disk as long as */
@@ -63,197 +69,205 @@ int main(int argc, char **argv)
/* infinite event loop */
for (;;)
{
- /* image variable */
- Imlib_Image image;
- /* width and height values */
- int w, h, text_w, text_h;
-
- /* init our updates to empty */
- updates = imlib_updates_init();
- /* while there are events form X - handle them */
- do
- {
- XNextEvent(disp, &ev);
- switch (ev.type)
- {
- case Expose:
- /* window rectangle was exposed - add it to the list of */
- /* rectangles we need to re-render */
- updates = imlib_update_append_rect(updates,
- ev.xexpose.x, ev.xexpose.y,
- ev.xexpose.width, ev.xexpose.height);
- break;
- case ButtonPress:
- /* if we click anywhere in the window, exit */
- exit(0);
- break;
- case MotionNotify:
- /* if the mouse moves - note it */
- /* add a rectangle update for the new mouse position */
- image = imlib_load_image("./test_images/mush.png");
- imlib_context_set_image(image);
- w = imlib_image_get_width();
- h = imlib_image_get_height();
- imlib_context_set_image(image);
- imlib_free_image();
- /* the old position - so we wipe over where it used to be */
- updates = imlib_update_append_rect(updates,
- mouse_x - (w / 2), mouse_y - (h / 2),
- w, h);
- font = imlib_load_font("notepad/30");
- if (font)
- {
- char text[4096];
-
- imlib_context_set_font(font);
- sprintf(text, "Mouse is at %i, %i", mouse_x, mouse_y);
- imlib_get_text_size(text, &text_w, &text_h);
- imlib_free_font();
- updates = imlib_update_append_rect(updates,
- 320 - (text_w / 2), 240 - (text_h / 2),
- text_w, text_h);
- }
-
- mouse_x = ev.xmotion.x;
- mouse_y = ev.xmotion.y;
- /* the new one */
- updates = imlib_update_append_rect(updates,
- mouse_x - (w / 2), mouse_y - (h / 2),
- w, h);
- font = imlib_load_font("notepad/30");
- if (font)
- {
- char text[4096];
-
- imlib_context_set_font(font);
- sprintf(text, "Mouse is at %i, %i", mouse_x, mouse_y);
- imlib_get_text_size(text, &text_w, &text_h);
- imlib_free_font();
- updates = imlib_update_append_rect(updates,
- 320 - (text_w / 2), 240 - (text_h / 2),
- text_w, text_h);
- }
- default:
- /* any other events - do nothing */
- break;
- }
- }
- while (XPending(disp));
-
- /* no more events for now ? ok - idle time so lets draw stuff */
-
- /* take all the little rectangles to redraw and merge them into */
- /* something sane for rendering */
- updates = imlib_updates_merge_for_rendering(updates, 640, 480);
- for (current_update = updates;
- current_update;
- current_update = imlib_updates_get_next(current_update))
- {
- int up_x, up_y, up_w, up_h;
+ /* image variable */
+ Imlib_Image image;
+
+ /* width and height values */
+ int w, h, text_w, text_h;
+
+ /* init our updates to empty */
+ updates = imlib_updates_init();
+ /* while there are events form X - handle them */
+ do
+ {
+ XNextEvent(disp, &ev);
+ switch (ev.type)
+ {
+ case Expose:
+ /* window rectangle was exposed - add it to the list of */
+ /* rectangles we need to re-render */
+ updates = imlib_update_append_rect(updates,
+ ev.xexpose.x,
+ ev.xexpose.y,
+ ev.xexpose.width,
+ ev.xexpose.height);
+ break;
+ case ButtonPress:
+ /* if we click anywhere in the window, exit */
+ exit(0);
+ break;
+ case MotionNotify:
+ /* if the mouse moves - note it */
+ /* add a rectangle update for the new mouse position */
+ image = imlib_load_image("./test_images/mush.png");
+ imlib_context_set_image(image);
+ w = imlib_image_get_width();
+ h = imlib_image_get_height();
+ imlib_context_set_image(image);
+ imlib_free_image();
+ /* the old position - so we wipe over where it used to be */
+ updates = imlib_update_append_rect(updates,
+ mouse_x - (w / 2),
+ mouse_y - (h / 2), w, h);
+ font = imlib_load_font("notepad/30");
+ if (font)
+ {
+ char text[4096];
+
+ imlib_context_set_font(font);
+ sprintf(text, "Mouse is at %i, %i", mouse_x, mouse_y);
+ imlib_get_text_size(text, &text_w, &text_h);
+ imlib_free_font();
+ updates = imlib_update_append_rect(updates,
+ 320 - (text_w / 2),
+ 240 - (text_h / 2),
+ text_w, text_h);
+ }
+
+ mouse_x = ev.xmotion.x;
+ mouse_y = ev.xmotion.y;
+ /* the new one */
+ updates = imlib_update_append_rect(updates,
+ mouse_x - (w / 2),
+ mouse_y - (h / 2), w, h);
+ font = imlib_load_font("notepad/30");
+ if (font)
+ {
+ char text[4096];
+
+ imlib_context_set_font(font);
+ sprintf(text, "Mouse is at %i, %i", mouse_x, mouse_y);
+ imlib_get_text_size(text, &text_w, &text_h);
+ imlib_free_font();
+ updates = imlib_update_append_rect(updates,
+ 320 - (text_w / 2),
+ 240 - (text_h / 2),
+ text_w, text_h);
+ }
+ default:
+ /* any other events - do nothing */
+ break;
+ }
+ }
+ while (XPending(disp));
+
+ /* no more events for now ? ok - idle time so lets draw stuff */
+
+ /* take all the little rectangles to redraw and merge them into */
+ /* something sane for rendering */
+ updates = imlib_updates_merge_for_rendering(updates, 640, 480);
+ for (current_update = updates;
+ current_update;
+ current_update = imlib_updates_get_next(current_update))
+ {
+ int up_x, up_y, up_w, up_h;
+
+ /* find out where the first update is */
+ imlib_updates_get_coordinates(current_update,
+ &up_x, &up_y, &up_w, &up_h);
+
+ /* create our buffer image for renderign this update */
+ buffer = imlib_create_image(up_w, up_h);
+
+ /* we can blend stuff now */
+ imlib_context_set_blend(1);
+
+ /* fill the window background */
+ /* load the background image - you'll need to have some images */
+ /* in ./test_images lying around for this to actually work */
+ image = imlib_load_image("./test_images/bg.png");
+ /* we're working with this image now */
+ imlib_context_set_image(image);
+ /* get its size */
+ w = imlib_image_get_width();
+ h = imlib_image_get_height();
+ /* now we want to work with the buffer */
+ imlib_context_set_image(buffer);
+ /* if the iimage loaded */
+ if (image)
+ {
+ /* blend image onto the buffer and scale it to 640x480 */
+ imlib_blend_image_onto_image(image, 0,
+ 0, 0, w, h,
+ -up_x, -up_y, 640, 480);
+ /* working with the loaded image */
+ imlib_context_set_image(image);
+ /* free it */
+ imlib_free_image();
+ }
+
+ /* draw an icon centered around the mouse position */
+ image = imlib_load_image("./test_images/mush.png");
+ imlib_context_set_image(image);
+ w = imlib_image_get_width();
+ h = imlib_image_get_height();
+ imlib_context_set_image(buffer);
+ if (image)
+ {
+ imlib_blend_image_onto_image(image, 0,
+ 0, 0, w, h,
+ mouse_x - (w / 2) - up_x,
+ mouse_y - (h / 2) - up_y, w, h);
+ imlib_context_set_image(image);
+ imlib_free_image();
+ }
+
+ /* draw a gradient on top of things at the top left of the window */
+ /* create a range */
+ range = imlib_create_color_range();
+ imlib_context_set_color_range(range);
+ /* add white opaque as the first color */
+ imlib_context_set_color(255, 255, 255, 255);
+ imlib_add_color_to_color_range(0);
+ /* add an orange color, semi-transparent 10 units from the first */
+ imlib_context_set_color(255, 200, 10, 100);
+ imlib_add_color_to_color_range(10);
+ /* add black, fully transparent at the end 20 units away */
+ imlib_context_set_color(0, 0, 0, 0);
+ imlib_add_color_to_color_range(20);
+ /* draw the range */
+ imlib_context_set_image(buffer);
+ imlib_image_fill_color_range_rectangle(-up_x, -up_y, 128, 128,
+ -45.0);
+ /* free it */
+ imlib_free_color_range();
+
+ /* draw text - centered with the current mouse x, y */
+ font = imlib_load_font("notepad/30");
+ if (font)
+ {
+ char text[4096];
+
+ /* set the current font */
+ imlib_context_set_font(font);
+ /* set the image */
+ imlib_context_set_image(buffer);
+ /* set the color (black) */
+ imlib_context_set_color(0, 0, 0, 255);
+ /* print text to display in the buffer */
+ sprintf(text, "Mouse is at %i, %i", mouse_x, mouse_y);
+ /* query the size it will be */
+ imlib_get_text_size(text, &text_w, &text_h);
+ /* draw it */
+ imlib_text_draw(320 - (text_w / 2) - up_x,
+ 240 - (text_h / 2) - up_y, text);
+ /* free the font */
+ imlib_free_font();
+ }
- /* find out where the first update is */
- imlib_updates_get_coordinates(current_update,
- &up_x, &up_y, &up_w, &up_h);
-
- /* create our buffer image for renderign this update */
- buffer = imlib_create_image(up_w, up_h);
-
- /* we can blend stuff now */
- imlib_context_set_blend(1);
-
- /* fill the window background */
- /* load the background image - you'll need to have some images */
- /* in ./test_images lying around for this to actually work */
- image = imlib_load_image("./test_images/bg.png");
- /* we're working with this image now */
- imlib_context_set_image(image);
- /* get its size */
- w = imlib_image_get_width();
- h = imlib_image_get_height();
- /* now we want to work with the buffer */
- imlib_context_set_image(buffer);
- /* if the iimage loaded */
- if (image)
- {
- /* blend image onto the buffer and scale it to 640x480 */
- imlib_blend_image_onto_image(image, 0,
- 0, 0, w, h,
- - up_x, - up_y, 640, 480);
- /* working with the loaded image */
- imlib_context_set_image(image);
- /* free it */
- imlib_free_image();
- }
-
- /* draw an icon centered around the mouse position */
- image = imlib_load_image("./test_images/mush.png");
- imlib_context_set_image(image);
- w = imlib_image_get_width();
- h = imlib_image_get_height();
- imlib_context_set_image(buffer);
- if (image)
- {
- imlib_blend_image_onto_image(image, 0,
- 0, 0, w, h,
- mouse_x - (w / 2) - up_x, mouse_y - (h / 2) - up_y, w, h);
- imlib_context_set_image(image);
- imlib_free_image();
- }
-
- /* draw a gradient on top of things at the top left of the window */
- /* create a range */
- range = imlib_create_color_range();
- imlib_context_set_color_range(range);
- /* add white opaque as the first color */
- imlib_context_set_color(255, 255, 255, 255);
- imlib_add_color_to_color_range(0);
- /* add an orange color, semi-transparent 10 units from the first */
- imlib_context_set_color(255, 200, 10, 100);
- imlib_add_color_to_color_range(10);
- /* add black, fully transparent at the end 20 units away */
- imlib_context_set_color(0, 0, 0, 0);
- imlib_add_color_to_color_range(20);
- /* draw the range */
- imlib_context_set_image(buffer);
- imlib_image_fill_color_range_rectangle(- up_x, - up_y, 128, 128, -45.0);
- /* free it */
- imlib_free_color_range();
-
- /* draw text - centered with the current mouse x, y */
- font = imlib_load_font("notepad/30");
- if (font)
- {
- char text[4096];
-
- /* set the current font */
- imlib_context_set_font(font);
- /* set the image */
- imlib_context_set_image(buffer);
- /* set the color (black) */
- imlib_context_set_color(0, 0, 0, 255);
- /* print text to display in the buffer */
- sprintf(text, "Mouse is at %i, %i", mouse_x, mouse_y);
- /* query the size it will be */
- imlib_get_text_size(text, &text_w, &text_h);
- /* draw it */
- imlib_text_draw(320 - (text_w / 2) - up_x, 240 - (text_h / 2) - up_y, text);
- /* free the font */
- imlib_free_font();
- }
-
- /* dont blend the image onto the drawable - slower */
- imlib_context_set_blend(0);
- /* set the buffer image as our current image */
- imlib_context_set_image(buffer);
- /* render the image at 0, 0 */
- imlib_render_image_on_drawable(up_x, up_y);
- /* don't need that temproary buffer image anymore */
- imlib_free_image();
- }
- /* if we had updates - free them */
- if (updates)
- imlib_updates_free(updates);
- /* loop again waiting for events */
+ /* dont blend the image onto the drawable - slower */
+ imlib_context_set_blend(0);
+ /* set the buffer image as our current image */
+ imlib_context_set_image(buffer);
+ /* render the image at 0, 0 */
+ imlib_render_image_on_drawable(up_x, up_y);
+ /* don't need that temproary buffer image anymore */
+ imlib_free_image();
+ }
+ /* if we had updates - free them */
+ if (updates)
+ imlib_updates_free(updates);
+ /* loop again waiting for events */
}
return 0;
}
diff --git a/test/main.c b/test/main.c
index 4943c2d..1f5a0e3 100644
--- a/test/main.c
+++ b/test/main.c
@@ -22,19 +22,18 @@
*/
#include "Imlib2.h"
-Display *disp;
-Window win;
-Visual *vis;
-Colormap cm;
-int depth;
+Display *disp;
+Window win;
+Visual *vis;
+Colormap cm;
+int depth;
-void progress(Imlib_Image *im, char percent, int update_x, int update_y,
- int update_w, int update_h);
+void progress(Imlib_Image * im, char percent, int update_x,
+ int update_y, int update_w, int update_h);
void
-progress(Imlib_Image *im, char percent,
- int update_x, int update_y,
- int update_w, int update_h)
+progress(Imlib_Image * im, char percent,
+ int update_x, int update_y, int update_w, int update_h)
{
imlib_context_set_display(disp);
imlib_context_set_visual(vis);
@@ -45,281 +44,293 @@ progress(Imlib_Image *im, char percent,
imlib_context_set_color_modifier(NULL);
imlib_context_set_operation(IMLIB_OP_COPY);
imlib_context_set_image(im);
- imlib_render_image_part_on_drawable_at_size(update_x, update_y,
- update_w, update_h,
- 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);
}
-int main (int argc, char **argv)
+int
+main(int argc, char **argv)
{
- int i, j;
- Imlib_Image *im = NULL;
- int sec1, usec1, sec2, usec2;
- int pixels = 0;
- struct timeval timev;
- double sec;
- char *file = NULL;
- char *fon = NULL, *str = NULL;
-
- int root = 0;
- int scale = 0;
- int w = 20;
- int h = 20;
- int aa = 0;
- int dith = 0;
- int loop = 0;
- int blend = 1;
- int interactive = 1;
- int blendtest = 0;
- int filter = 0;
- int pol = 0;
- int rotate = 0;
- int rottest = 0;
- int scaleup = 0;
- int scaleboth = 0;
- int origone = 0;
- int bump_map_to_point = 0;
+ int i, j;
+ Imlib_Image *im = NULL;
+ int sec1, usec1, sec2, usec2;
+ int pixels = 0;
+ struct timeval timev;
+ double sec;
+ char *file = NULL;
+ char *fon = NULL, *str = NULL;
+
+ int root = 0;
+ int scale = 0;
+ int w = 20;
+ int h = 20;
+ int aa = 0;
+ int dith = 0;
+ int loop = 0;
+ int blend = 1;
+ int interactive = 1;
+ int blendtest = 0;
+ int filter = 0;
+ int pol = 0;
+ int rotate = 0;
+ int rottest = 0;
+ int scaleup = 0;
+ int scaleboth = 0;
+ int origone = 0;
+ int bump_map_to_point = 0;
Imlib_Color_Modifier colormod = 0;
- ImlibPolygon poly, poly2, poly3;
- int textdir = IMLIB_TEXT_TO_RIGHT;
- int xfdtest = 0;
- int xfdcachetest = 0;
- char *xfdfname = NULL;
- int xfdloop = 1;
-
+ ImlibPolygon poly, poly2, poly3;
+ int textdir = IMLIB_TEXT_TO_RIGHT;
+ int xfdtest = 0;
+ int xfdcachetest = 0;
+ char *xfdfname = NULL;
+ int xfdloop = 1;
+
/* now we'll set the locale */
setlocale(LC_ALL, "");
if (!XSupportsLocale())
- setlocale(LC_ALL, "C");
+ setlocale(LC_ALL, "C");
XSetLocaleModifiers("");
setlocale(LC_ALL, NULL);
-
+
/**
* Parse all the command line arguments
*/
if ((argc > 1) && (!strcmp(argv[1], "-help")))
{
- printf ("Imlib2 program test. (Imlib v2.0.0.4)\n");
- printf ("usage: imlib2 [options] [file]\n");
- printf ("options are:\n");
- printf ("-help\t\tDisplays this help.\n");
- printf ("-root\t\tDraw in the root window.\n");
- printf ("-smooth\t\tWhen scaling images scale with anti-aliasing.\n");
- printf ("-up\t\tWhen doing scal test scale up, not down.\n");
- printf ("-both\t\tScale horizontally AND vertically in scale test.\n");
- printf ("-orig\t\tKeep original width and height in each pass of scale test.\n");
- printf ("-blend\t\tBlending test.\n");
- printf ("-dither\t\tTurn dithering on for depths < 24bpp\n");
- printf ("-colormod <r> <g> <b> <a>\t\tSet up color mod tables\n");
- printf ("-scale\t\tScale test.\n");
- printf ("-noloop\t\tDont loop - timing test.\n");
- printf ("-rotate\t\tAlso rotate background image with mouse in interative test.\n");
- printf ("-size <w> <h>\t\tScale from w x h down in scaling test.\n"); // require parameters w / h
- printf ("-maxcolors <n>\t\tLimit color allocation count to n colors.\n"); // require parameter nb colors
- printf ("-text\t\tDisplays the text following this option. Need a loaded font.\n");
- printf ("-font\t\tLoads a font. The parameter must follow the police_name/size format. Example: loading the grunge font at size 18 is : grunge/18.\n\t\tThe XFD font also can be specified. Ex. 'notepad/32,-*--24-*'.\n");
- printf ("-poly\t\tPerforms a poly test\n");
- printf ("The following options requires a file to work properly.\n");
- printf ("-textdir\t\tText Direction. 0: L to R, 1: R to L\n");
- printf (" 2: U to D, 3: D to U, 4: angle\n");
- printf ("-xfdtest\t\tXFD Font queue test.\n");
- printf ("-xfdcachetest <f> [<l>]\t\tXFD tFont cache test.\n\t\tThe file f is drawn l times\n");
- printf ("-blast\t\tDisplays the file.\n");
- printf ("-loop\t\tScales down the image.\n");
- printf ("-blendtest\tPerforms a blending test on the file.\n");
- printf ("-rotatetest\tPerforms a rotate test on the file.\n");
- printf ("-filter\t\tPerforms filtering. Possible filters are,\n\t\t\t1:Blur filter, 2:Sharpen filter, 3:Color blur filter, \n\t\t\t4:Emboss filter, 5:Grayscale filter, 6:Saturation filter,\n\t\t\t7:Edge detection filter.\n");
- printf ("-bmp2pt\t\tPerformas Bump Mapping to a point\n");
- return 0;
+ printf("Imlib2 program test. (Imlib v2.0.0.4)\n");
+ printf("usage: imlib2 [options] [file]\n");
+ printf("options are:\n");
+ printf("-help\t\tDisplays this help.\n");
+ printf("-root\t\tDraw in the root window.\n");
+ printf("-smooth\t\tWhen scaling images scale with anti-aliasing.\n");
+ printf("-up\t\tWhen doing scal test scale up, not down.\n");
+ printf("-both\t\tScale horizontally AND vertically in scale test.\n");
+ printf
+ ("-orig\t\tKeep original width and height in each pass of scale test.\n");
+ printf("-blend\t\tBlending test.\n");
+ printf("-dither\t\tTurn dithering on for depths < 24bpp\n");
+ printf("-colormod <r> <g> <b> <a>\t\tSet up color mod tables\n");
+ printf("-scale\t\tScale test.\n");
+ printf("-noloop\t\tDont loop - timing test.\n");
+ printf
+ ("-rotate\t\tAlso rotate background image with mouse in interative test.\n");
+ printf("-size <w> <h>\t\tScale from w x h down in scaling test.\n"); // require parameters w / h
+ printf("-maxcolors <n>\t\tLimit color allocation count to n colors.\n"); // require parameter nb colors
+ printf
+ ("-text\t\tDisplays the text following this option. Need a loaded font.\n");
+ printf
+ ("-font\t\tLoads a font. The parameter must follow the police_name/size format. Example: loading the grunge font at size 18 is : grunge/18.\n\t\tThe XFD font also can be specified. Ex. 'notepad/32,-*--24-*'.\n");
+ printf("-poly\t\tPerforms a poly test\n");
+ printf("The following options requires a file to work properly.\n");
+ printf("-textdir\t\tText Direction. 0: L to R, 1: R to L\n");
+ printf(" 2: U to D, 3: D to U, 4: angle\n");
+ printf("-xfdtest\t\tXFD Font queue test.\n");
+ printf
+ ("-xfdcachetest <f> [<l>]\t\tXFD tFont cache test.\n\t\tThe file f is drawn l times\n");
+ printf("-blast\t\tDisplays the file.\n");
+ printf("-loop\t\tScales down the image.\n");
+ printf("-blendtest\tPerforms a blending test on the file.\n");
+ printf("-rotatetest\tPerforms a rotate test on the file.\n");
+ printf
+ ("-filter\t\tPerforms filtering. Possible filters are,\n\t\t\t1:Blur filter, 2:Sharpen filter, 3:Color blur filter, \n\t\t\t4:Emboss filter, 5:Grayscale filter, 6:Saturation filter,\n\t\t\t7:Edge detection filter.\n");
+ printf("-bmp2pt\t\tPerformas Bump Mapping to a point\n");
+ return 0;
}
-
+
for (i = 1; i < argc; i++)
{
- if (!strcmp(argv[i], "-root"))
- root = 1;
- else if (!strcmp(argv[i], "-smooth"))
- aa = 1;
- else if (!strcmp(argv[i], "-blast"))
- interactive = 0;
- else if (!strcmp(argv[i], "-loop"))
- {
- interactive = 0;
- loop = 1;
- }
- else if (!strcmp(argv[i], "-up"))
- scaleup = 1;
- else if (!strcmp(argv[i], "-both"))
- scaleboth = 1;
- else if (!strcmp(argv[i], "-bmp2pt"))
- bump_map_to_point = 1;
- else if (!strcmp(argv[i], "-orig"))
- origone = 1;
- else if (!strcmp(argv[i], "-blend"))
- blend = 1;
- else if (!strcmp(argv[i], "-poly"))
- pol = 1;
- else if (!strcmp(argv[i], "-blendtest"))
- {
- blendtest = 1;
- interactive = 0;
- }
- else if (!strcmp(argv[i], "-colormod"))
- {
- DATA8 rt[256], gt[256], bt[256], at[256];
- double rm, gm, bm, am;
- int j;
- /*\ Setup color mod tables \*/
- if (!colormod) colormod = imlib_create_color_modifier();
- imlib_context_set_color_modifier(colormod);
- rm = strtod(argv[++i], 0);
- gm = strtod(argv[++i], 0);
- bm = strtod(argv[++i], 0);
- am = strtod(argv[++i], 0);
- imlib_get_color_modifier_tables(rt, gt, bt, at);
- for (j = 0x100; --j >= 0; ) {
- rt[j] = ((double)rt[j]) * rm;
- gt[j] = ((double)gt[j]) * gm;
- bt[j] = ((double)bt[j]) * bm;
- at[j] = ((double)at[j]) * am;
- }
- imlib_set_color_modifier_tables(rt, gt, bt, at);
- }
- 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]);
- }
- else if (!strcmp(argv[i], "-maxcolors"))
- {
- i++;
- imlib_set_color_usage(atoi(argv[i]));
- }
- else if (!strcmp(argv[i], "-font"))
- {
- i++;
- fon = argv[i];
- }
- else if (!strcmp(argv[i], "-text"))
- {
- i++;
- str = argv[i];
- }
- else if (!strcmp(argv[i], "-xfdtest"))
- xfdtest = 1;
- else if (!strcmp(argv[i], "-xfdcachetest"))
- {
- xfdcachetest = 1;
- i++;
- xfdfname = argv[i];
- i++;
- if (i < argc)
- xfdloop = atoi(argv[i]);
- }
- else if (!strcmp(argv[i], "-textdir"))
- {
- i++;
- textdir = atoi(argv[i]);
- }
- else if (!strcmp(argv[i], "-rotate"))
- rotate = 1;
- else if (!strcmp(argv[i], "-filter"))
- {
- filter = atoi(argv[++i]);
- interactive = 0;
- }
- else if (!strcmp(argv[i], "-rotatetest"))
- {
- rottest = 1;
- interactive = 0;
- }
- else
- file = argv[i];
+ if (!strcmp(argv[i], "-root"))
+ root = 1;
+ else if (!strcmp(argv[i], "-smooth"))
+ aa = 1;
+ else if (!strcmp(argv[i], "-blast"))
+ interactive = 0;
+ else if (!strcmp(argv[i], "-loop"))
+ {
+ interactive = 0;
+ loop = 1;
+ }
+ else if (!strcmp(argv[i], "-up"))
+ scaleup = 1;
+ else if (!strcmp(argv[i], "-both"))
+ scaleboth = 1;
+ else if (!strcmp(argv[i], "-bmp2pt"))
+ bump_map_to_point = 1;
+ else if (!strcmp(argv[i], "-orig"))
+ origone = 1;
+ else if (!strcmp(argv[i], "-blend"))
+ blend = 1;
+ else if (!strcmp(argv[i], "-poly"))
+ pol = 1;
+ else if (!strcmp(argv[i], "-blendtest"))
+ {
+ blendtest = 1;
+ interactive = 0;
+ }
+ else if (!strcmp(argv[i], "-colormod"))
+ {
+ DATA8 rt[256], gt[256], bt[256], at[256];
+ double rm, gm, bm, am;
+ int j;
+
+ /*\ Setup color mod tables \ */
+ if (!colormod)
+ colormod = imlib_create_color_modifier();
+ imlib_context_set_color_modifier(colormod);
+ rm = strtod(argv[++i], 0);
+ gm = strtod(argv[++i], 0);
+ bm = strtod(argv[++i], 0);
+ am = strtod(argv[++i], 0);
+ imlib_get_color_modifier_tables(rt, gt, bt, at);
+ for (j = 0x100; --j >= 0;)
+ {
+ rt[j] = ((double)rt[j]) * rm;
+ gt[j] = ((double)gt[j]) * gm;
+ bt[j] = ((double)bt[j]) * bm;
+ at[j] = ((double)at[j]) * am;
+ }
+ imlib_set_color_modifier_tables(rt, gt, bt, at);
+ }
+ 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]);
+ }
+ else if (!strcmp(argv[i], "-maxcolors"))
+ {
+ i++;
+ imlib_set_color_usage(atoi(argv[i]));
+ }
+ else if (!strcmp(argv[i], "-font"))
+ {
+ i++;
+ fon = argv[i];
+ }
+ else if (!strcmp(argv[i], "-text"))
+ {
+ i++;
+ str = argv[i];
+ }
+ else if (!strcmp(argv[i], "-xfdtest"))
+ xfdtest = 1;
+ else if (!strcmp(argv[i], "-xfdcachetest"))
+ {
+ xfdcachetest = 1;
+ i++;
+ xfdfname = argv[i];
+ i++;
+ if (i < argc)
+ xfdloop = atoi(argv[i]);
+ }
+ else if (!strcmp(argv[i], "-textdir"))
+ {
+ i++;
+ textdir = atoi(argv[i]);
+ }
+ else if (!strcmp(argv[i], "-rotate"))
+ rotate = 1;
+ else if (!strcmp(argv[i], "-filter"))
+ {
+ filter = atoi(argv[++i]);
+ interactive = 0;
+ }
+ else if (!strcmp(argv[i], "-rotatetest"))
+ {
+ rottest = 1;
+ interactive = 0;
+ }
+ else
+ file = argv[i];
}
-
+
/**
* Initialization according to options
*/
printf("init\n");
-
+
/**
* First tests to determine which rendering task to perform
*/
if (!blendtest)
{
- disp = XOpenDisplay(NULL);
- vis = DefaultVisual(disp, DefaultScreen(disp));
- depth = DefaultDepth(disp, DefaultScreen(disp));
- cm = DefaultColormap(disp, DefaultScreen(disp));
- /* nasty - using imlib internal function.. but it makes benchmarks fair */
- if (!interactive)
- __imlib_SetMaxXImageCount(disp, 3);
- if (root)
- win = DefaultRootWindow(disp);
- else
- {
- win = XCreateSimpleWindow(disp, DefaultRootWindow(disp), 0, 0, 10, 10, 0, 0, 0);
- XSelectInput(disp, win, ButtonPressMask | ButtonReleaseMask |
- ButtonMotionMask | PointerMotionMask | ExposureMask);
- }
+ disp = XOpenDisplay(NULL);
+ vis = DefaultVisual(disp, DefaultScreen(disp));
+ depth = DefaultDepth(disp, DefaultScreen(disp));
+ cm = DefaultColormap(disp, DefaultScreen(disp));
+ /* nasty - using imlib internal function.. but it makes benchmarks fair */
+ if (!interactive)
+ __imlib_SetMaxXImageCount(disp, 3);
+ if (root)
+ win = DefaultRootWindow(disp);
+ else
+ {
+ win =
+ XCreateSimpleWindow(disp, DefaultRootWindow(disp), 0, 0, 10,
+ 10, 0, 0, 0);
+ XSelectInput(disp, win,
+ ButtonPressMask | ButtonReleaseMask | ButtonMotionMask
+ | PointerMotionMask | ExposureMask);
+ }
}
-
+
if (!interactive)
{
- printf("load %s\n", file);
- im = imlib_load_image_immediately(file);
- if (!im)
- {
- printf("load failed\n");
- exit(0);
- }
- imlib_context_set_image(im);
- w = imlib_image_get_width();
- h = imlib_image_get_height();
- printf("image %i x %i\n", w, h);
+ printf("load %s\n", file);
+ im = imlib_load_image_immediately(file);
+ if (!im)
+ {
+ printf("load failed\n");
+ exit(0);
+ }
+ imlib_context_set_image(im);
+ w = imlib_image_get_width();
+ h = imlib_image_get_height();
+ printf("image %i x %i\n", w, h);
}
-
+
if (!blendtest)
{
- if (!root)
- {
- if (scaleup)
- XResizeWindow(disp, win, w * 4, h * 4);
- else if (scaleboth)
- XResizeWindow(disp, win, w * 2, h * 2);
- else
- XResizeWindow(disp, win, w, h);
- XMapWindow(disp, win);
- }
- if (scale)
- {
- Window d;
- int dd;
-
- XGetGeometry(disp, win, &d, &dd, &dd, &dd, &dd, &dd, &dd);
- }
- XSync(disp, False);
+ if (!root)
+ {
+ if (scaleup)
+ XResizeWindow(disp, win, w * 4, h * 4);
+ else if (scaleboth)
+ XResizeWindow(disp, win, w * 2, h * 2);
+ else
+ XResizeWindow(disp, win, w, h);
+ XMapWindow(disp, win);
+ }
+ if (scale)
+ {
+ Window d;
+ int dd;
+
+ XGetGeometry(disp, win, &d, &dd, &dd, &dd, &dd, &dd, &dd);
+ }
+ XSync(disp, False);
}
-
-
+
/**
* Start rendering
*/
printf("rend\n");
-
+
if (!blendtest)
{
- imlib_context_set_display(disp);
- imlib_context_set_visual(vis);
- imlib_context_set_colormap(cm);
- imlib_context_set_drawable(win);
+ imlib_context_set_display(disp);
+ imlib_context_set_visual(vis);
+ imlib_context_set_colormap(cm);
+ imlib_context_set_drawable(win);
}
imlib_context_set_anti_alias(aa);
imlib_context_set_dither(dith);
@@ -327,990 +338,1040 @@ int main (int argc, char **argv)
imlib_context_set_color_modifier(NULL);
imlib_context_set_operation(IMLIB_OP_COPY);
imlib_context_set_image(im);
-
- 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 */
+
+ 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 */
poly = imlib_polygon_new();
- imlib_polygon_add_point(poly, 400,50);
- imlib_polygon_add_point(poly, 450,100);
- imlib_polygon_add_point(poly, 350,100);
+ imlib_polygon_add_point(poly, 400, 50);
+ imlib_polygon_add_point(poly, 450, 100);
+ imlib_polygon_add_point(poly, 350, 100);
poly2 = imlib_polygon_new();
- imlib_polygon_add_point(poly2, 400,150);
- imlib_polygon_add_point(poly2, 450,200);
- imlib_polygon_add_point(poly2, 350,200);
+ imlib_polygon_add_point(poly2, 400, 150);
+ imlib_polygon_add_point(poly2, 450, 200);
+ imlib_polygon_add_point(poly2, 350, 200);
poly3 = imlib_polygon_new();
- imlib_polygon_add_point(poly3, 400,250);
- imlib_polygon_add_point(poly3, 450,300);
- imlib_polygon_add_point(poly3, 350,300);
-
+ imlib_polygon_add_point(poly3, 400, 250);
+ imlib_polygon_add_point(poly3, 450, 300);
+ imlib_polygon_add_point(poly3, 350, 300);
-#define A90 (3.141592654 / 2)
+#define A90 (3.141592654 / 2)
if (pol)
{
- Imlib_Image im_bg, im;
- int w, h;
- int i;
- double a, points[8][2];
-
+ Imlib_Image im_bg, im;
+ int w, h;
+ int i;
+ double a, points[8][2];
+
if (file)
- im_bg = imlib_load_image(file);
- else
- im_bg = imlib_load_image("test_images/bg.png");
- imlib_context_set_image(im_bg);
- w = imlib_image_get_width();
- h = imlib_image_get_height();
- XResizeWindow(disp, win, w, h);
- XSync(disp, False);
- im = imlib_create_image(w, h);
- srand(time(NULL));
- for (i = 0; i < 8; i++)
- {
- points[i][0] = (rand()%w) - (w / 2);
- points[i][1] = (rand()%h) - (h / 2);
- }
- a = 0.0;
- for (;;)
- {
- imlib_context_set_image(im);
+ im_bg = imlib_load_image(file);
+ else
+ im_bg = imlib_load_image("test_images/bg.png");
+ imlib_context_set_image(im_bg);
+ w = imlib_image_get_width();
+ h = imlib_image_get_height();
+ XResizeWindow(disp, win, w, h);
+ XSync(disp, False);
+ im = imlib_create_image(w, h);
+ srand(time(NULL));
+ for (i = 0; i < 8; i++)
+ {
+ points[i][0] = (rand() % w) - (w / 2);
+ points[i][1] = (rand() % h) - (h / 2);
+ }
+ a = 0.0;
+ for (;;)
+ {
+ imlib_context_set_image(im);
imlib_blend_image_onto_image(im_bg, 0, 0, 0, w, h, 0, 0, w, h);
-
- poly = imlib_polygon_new();
- for (i = 0; i < 8; i++)
- {
- double xx, yy;
- xx = (w / 2) +
- (cos(a) * points[i][0]) +
- (cos(a + A90) * points[i][1]);
- yy = (h / 2) +
- (sin(a) * points[i][0]) +
- (sin(a + A90) * points[i][1]);
- imlib_polygon_add_point(poly, xx, yy);
- }
- printf("draw angle %3.3f\n", a);
- imlib_context_set_color(255, 255, 255, 100);
- imlib_image_fill_polygon(poly);
- imlib_context_set_color(0, 0, 0, 20);
- imlib_image_draw_polygon(poly, 1);
- imlib_polygon_free(poly);
-
-
- imlib_render_image_on_drawable(0, 0);
- a += 0.05;
- }
+
+ poly = imlib_polygon_new();
+ for (i = 0; i < 8; i++)
+ {
+ double xx, yy;
+
+ xx = (w / 2) +
+ (cos(a) * points[i][0]) + (cos(a + A90) * points[i][1]);
+ yy = (h / 2) +
+ (sin(a) * points[i][0]) + (sin(a + A90) * points[i][1]);
+ imlib_polygon_add_point(poly, xx, yy);
+ }
+ printf("draw angle %3.3f\n", a);
+ imlib_context_set_color(255, 255, 255, 100);
+ imlib_image_fill_polygon(poly);
+ imlib_context_set_color(0, 0, 0, 20);
+ imlib_image_draw_polygon(poly, 1);
+ imlib_polygon_free(poly);
+
+ imlib_render_image_on_drawable(0, 0);
+ a += 0.05;
+ }
}
-
+
if (loop)
{
- printf("loop\n");
-
- // first test
- if (scaleup)
- {
- printf("scale up\n");
- for (i = 0; i < w * 3; i+= 8)
- {
- if (!blendtest)
- {
- Imlib_Image im_tmp;
-
- im_tmp = imlib_create_cropped_scaled_image(0, 0, w, h,
- w + i, (((w + i) * h) / w));
- if (im_tmp)
- {
- imlib_context_set_image(im_tmp);
- imlib_render_image_on_drawable(0, 0);
- imlib_free_image();
- }
- imlib_context_set_image(im);
- }
- else
- {
- Imlib_Image im_tmp;
- im_tmp = imlib_create_cropped_scaled_image(0, 0, w, h,
- w + i, (((w + i) * h) / w));
- if (im_tmp)
- {
- imlib_context_set_image(im_tmp);
- imlib_free_image();
- }
- imlib_context_set_image(im);
- }
- pixels += (w + i) * (((w + i) * h) / w);
- }
- }
-
- // else if // second
- else if (scaleboth)
- {
- if (origone)
- {
- for (i = 0; i < w * 2; i+= 4)
- {
- if (!blendtest)
- {
- Imlib_Image im_tmp;
-
- im_tmp = imlib_create_cropped_scaled_image(0, 0, w, h,
- w, (((i) * h) / w));
- if (im_tmp)
- {
- imlib_context_set_image(im_tmp);
- imlib_render_image_on_drawable(0, 0);
- imlib_free_image();
- }
- imlib_context_set_image(im);
- }
- else
- {
- Imlib_Image im_tmp;
- im_tmp = imlib_create_cropped_scaled_image(0, 0, w, h,
- w, (((i) * h) / w));
- if (im_tmp)
- {
- imlib_context_set_image(im_tmp);
- imlib_free_image();
- }
- imlib_context_set_image(im);
- }
- XSync(disp, False);
- pixels += (2 * w - i) * (((i) * h) / w);
- }
- for (i = 0; i < w * 2; i+= 4)
- {
- if (!blendtest)
- imlib_render_image_on_drawable_at_size(0, 0,
- 2 * w - i, h);
- else
- {
- Imlib_Image im_tmp;
- im_tmp = imlib_create_cropped_scaled_image(0, 0, w, h,
- 2 * w - i, h);
- if (im_tmp)
- {
- imlib_context_set_image(im_tmp);
- imlib_free_image();
- }
- imlib_context_set_image(im);
- }
- pixels += (2 * w - i) * h;
- }
- }
- else
- {
- for (i = 0; i < w * 2; i+= 4)
- {
- if (!blendtest)
- imlib_render_image_on_drawable_at_size(0, 0,
- 2 * w - i, (((i) * h) / w));
- else
- {
- Imlib_Image im_tmp;
- im_tmp = imlib_create_cropped_scaled_image(0, 0, w, h,
- 2 * w - i, (((i) * h) / w));
- if (im_tmp)
- {
- imlib_context_set_image(im_tmp);
- imlib_free_image();
- }
- imlib_context_set_image(im);
- }
- pixels += w * (((i) * h) / w);
- }
- }
- }
- else
- {
- printf("scale down 0 -> %i incriment by 1\n", w);
- for (i = 0; i < w; i++)
- {
- if (!blendtest)
- imlib_render_image_on_drawable_at_size(0, 0,
- w - i, (((w - i) * h) / w));
- else
- {
- Imlib_Image im_tmp;
- im_tmp = imlib_create_cropped_scaled_image(0, 0, w, h,
- w - i, (((w - i) * h) / w));
- if (im_tmp)
- {
- imlib_context_set_image(im_tmp);
- imlib_free_image();
- }
- imlib_context_set_image(im);
- }
- pixels += (w + i) * (((w + i) * h) / w);
- }
- }
+ printf("loop\n");
+
+ // first test
+ if (scaleup)
+ {
+ printf("scale up\n");
+ for (i = 0; i < w * 3; i += 8)
+ {
+ if (!blendtest)
+ {
+ Imlib_Image im_tmp;
+
+ im_tmp = imlib_create_cropped_scaled_image(0, 0, w, h,
+ w + i,
+ (((w +
+ i) * h) /
+ w));
+ if (im_tmp)
+ {
+ imlib_context_set_image(im_tmp);
+ imlib_render_image_on_drawable(0, 0);
+ imlib_free_image();
+ }
+ imlib_context_set_image(im);
+ }
+ else
+ {
+ Imlib_Image im_tmp;
+
+ im_tmp = imlib_create_cropped_scaled_image(0, 0, w, h,
+ w + i,
+ (((w +
+ i) * h) /
+ w));
+ if (im_tmp)
+ {
+ imlib_context_set_image(im_tmp);
+ imlib_free_image();
+ }
+ imlib_context_set_image(im);
+ }
+ pixels += (w + i) * (((w + i) * h) / w);
+ }
+ }
+
+ // else if // second
+ else if (scaleboth)
+ {
+ if (origone)
+ {
+ for (i = 0; i < w * 2; i += 4)
+ {
+ if (!blendtest)
+ {
+ Imlib_Image im_tmp;
+
+ im_tmp =
+ imlib_create_cropped_scaled_image(0, 0, w, h, w,
+ (((i) * h) /
+ w));
+ if (im_tmp)
+ {
+ imlib_context_set_image(im_tmp);
+ imlib_render_image_on_drawable(0, 0);
+ imlib_free_image();
+ }
+ imlib_context_set_image(im);
+ }
+ else
+ {
+ Imlib_Image im_tmp;
+
+ im_tmp =
+ imlib_create_cropped_scaled_image(0, 0, w, h, w,
+ (((i) * h) /
+ w));
+ if (im_tmp)
+ {
+ imlib_context_set_image(im_tmp);
+ imlib_free_image();
+ }
+ imlib_context_set_image(im);
+ }
+ XSync(disp, False);
+ pixels += (2 * w - i) * (((i) * h) / w);
+ }
+ for (i = 0; i < w * 2; i += 4)
+ {
+ if (!blendtest)
+ imlib_render_image_on_drawable_at_size(0, 0,
+ 2 * w - i, h);
+ else
+ {
+ Imlib_Image im_tmp;
+
+ im_tmp =
+ imlib_create_cropped_scaled_image(0, 0, w, h,
+ 2 * w - i, h);
+ if (im_tmp)
+ {
+ imlib_context_set_image(im_tmp);
+ imlib_free_image();
+ }
+ imlib_context_set_image(im);
+ }
+ pixels += (2 * w - i) * h;
+ }
+ }
+ else
+ {
+ for (i = 0; i < w * 2; i += 4)
+ {
+ if (!blendtest)
+ imlib_render_image_on_drawable_at_size(0, 0,
+ 2 * w - i,
+ (((i) * h) /
+ w));
+ else
+ {
+ Imlib_Image im_tmp;
+
+ im_tmp =
+ imlib_create_cropped_scaled_image(0, 0, w, h,
+ 2 * w - i,
+ (((i) * h) /
+ w));
+ if (im_tmp)
+ {
+ imlib_context_set_image(im_tmp);
+ imlib_free_image();
+ }
+ imlib_context_set_image(im);
+ }
+ pixels += w * (((i) * h) / w);
+ }
+ }
+ }
+ else
+ {
+ printf("scale down 0 -> %i incriment by 1\n", w);
+ for (i = 0; i < w; i++)
+ {
+ if (!blendtest)
+ imlib_render_image_on_drawable_at_size(0, 0,
+ w - i,
+ (((w -
+ i) * h) / w));
+ else
+ {
+ Imlib_Image im_tmp;
+
+ im_tmp = imlib_create_cropped_scaled_image(0, 0, w, h,
+ w - i,
+ (((w -
+ i) * h) /
+ w));
+ if (im_tmp)
+ {
+ imlib_context_set_image(im_tmp);
+ imlib_free_image();
+ }
+ imlib_context_set_image(im);
+ }
+ pixels += (w + i) * (((w + i) * h) / w);
+ }
+ }
}
-
+
// last test
- /* else if (scaleboth)
- {
- for (i = 0; i < w * 2; i+= 1)
- {
- if (!blendtest)
- imlib_render_image_on_drawable_at_size(0, 0,
- 2 * w - i, (((i) * h) / w));
- else
- {
- Imlib_Image im_tmp;
- im_tmp = imlib_create_cropped_scaled_image(0, 0, w, h,
- 2 * w - i, (((i) * h) / w));
- if (im_tmp)
- {
- imlib_context_set_image(im_tmp);
- imlib_free_image();
- }
- imlib_context_set_image(im);
- }
- pixels += (2 * w - i) * (((i) * h) / w);
- }
- }
- } */// end if loop
+ /* else if (scaleboth)
+ * {
+ * for (i = 0; i < w * 2; i+= 1)
+ * {
+ * if (!blendtest)
+ * imlib_render_image_on_drawable_at_size(0, 0,
+ * 2 * w - i, (((i) * h) / w));
+ * else
+ * {
+ * Imlib_Image im_tmp;
+ * im_tmp = imlib_create_cropped_scaled_image(0, 0, w, h,
+ * 2 * w - i, (((i) * h) / w));
+ * if (im_tmp)
+ * {
+ * imlib_context_set_image(im_tmp);
+ * imlib_free_image();
+ * }
+ * imlib_context_set_image(im);
+ * }
+ * pixels += (2 * w - i) * (((i) * h) / w);
+ * }
+ * }
+ * } */// end if loop
else if (blendtest)
{
- Imlib_Image im2;
-
- im2 = imlib_create_image(w, h);
- imlib_context_set_image(im2);
- w = imlib_image_get_width();
- h = imlib_image_get_height();
- imlib_context_set_image(im2);
- imlib_context_set_color_modifier(colormod);
- for (i = 0; i < 256; i++)
- {
+ Imlib_Image im2;
+
+ im2 = imlib_create_image(w, h);
+ imlib_context_set_image(im2);
+ w = imlib_image_get_width();
+ h = imlib_image_get_height();
+ imlib_context_set_image(im2);
+ imlib_context_set_color_modifier(colormod);
+ for (i = 0; i < 256; i++)
+ {
imlib_blend_image_onto_image(im, 0, 0, 0, w, h, 0, 0, w, h);
- pixels += (w * h);
- }
+ pixels += (w * h);
+ }
}
else if (rottest)
{
- int w, h;
- double i;
-
- imlib_context_set_image(im);
- imlib_render_image_on_drawable(0, 0);
-
- w = imlib_image_get_width();
- h = imlib_image_get_height();
- printf("rotating inside %dx%d frame\n", w, h);
-
- imlib_context_set_blend(1);
- imlib_context_set_image(imlib_create_image(w, h));
- for (i = 0; i < 1; i += 0.01) {
- imlib_blend_image_onto_image(im, 0, 0, 0, w, h, 0, 0, w, h);
- imlib_context_set_color_modifier(colormod);
- imlib_blend_image_onto_image_at_angle(im, 0, 0, 0, w, h,
- 0, h * i,
- w * (1 - i), -(h * i));
- imlib_context_set_color_modifier(NULL);
- imlib_render_image_on_drawable(0, 0);
- pixels += w * h;
- }
- for (i = 0; i < 1; i += 0.01) {
- imlib_blend_image_onto_image(im, 0, 0, 0, w, h, 0, 0, w, h);
- imlib_context_set_color_modifier(colormod);
- imlib_context_set_operation(IMLIB_OP_ADD);
- imlib_blend_image_onto_image_at_angle(im, 0, 0, 0, w, h,
- w * i, h,
- -(w * i), h * (i - 1));
- imlib_context_set_operation(IMLIB_OP_COPY);
- imlib_context_set_color_modifier(NULL);
- imlib_render_image_on_drawable(0, 0);
- pixels += w * h;
- }
- for (i = 0; i < 1; i += 0.01) {
- imlib_blend_image_onto_image(im, 0, 0, 0, w, h, 0, 0, w, h);
- imlib_context_set_color_modifier(colormod);
- imlib_context_set_operation(IMLIB_OP_SUBTRACT);
- imlib_blend_image_onto_image_at_angle(im, 0, 0, 0, w, h,
- w, h * (1 - i),
- w * (i - 1), h * i);
- imlib_context_set_operation(IMLIB_OP_COPY);
- imlib_context_set_color_modifier(NULL);
- imlib_render_image_on_drawable(0, 0);
- pixels += w * h;
- }
- for (i = 0; i < 1; i += 0.01) {
- imlib_blend_image_onto_image(im, 0, 0, 0, w, h, 0, 0, w, h);
- imlib_context_set_color_modifier(colormod);
- imlib_context_set_operation(IMLIB_OP_RESHADE);
- imlib_blend_image_onto_image_at_angle(im, 0, 0, 0, w, h,
- w * (1 - i), 0,
- w * i, h * (1 - i));
- imlib_context_set_operation(IMLIB_OP_COPY);
- imlib_context_set_color_modifier(NULL);
- imlib_render_image_on_drawable(0, 0);
- pixels += w * h;
- }
- imlib_free_image();
+ int w, h;
+ double i;
+
+ imlib_context_set_image(im);
+ imlib_render_image_on_drawable(0, 0);
+
+ w = imlib_image_get_width();
+ h = imlib_image_get_height();
+ printf("rotating inside %dx%d frame\n", w, h);
+
+ imlib_context_set_blend(1);
+ imlib_context_set_image(imlib_create_image(w, h));
+ for (i = 0; i < 1; i += 0.01)
+ {
+ imlib_blend_image_onto_image(im, 0, 0, 0, w, h, 0, 0, w, h);
+ imlib_context_set_color_modifier(colormod);
+ imlib_blend_image_onto_image_at_angle(im, 0, 0, 0, w, h,
+ 0, h * i,
+ w * (1 - i), -(h * i));
+ imlib_context_set_color_modifier(NULL);
+ imlib_render_image_on_drawable(0, 0);
+ pixels += w * h;
+ }
+ for (i = 0; i < 1; i += 0.01)
+ {
+ imlib_blend_image_onto_image(im, 0, 0, 0, w, h, 0, 0, w, h);
+ imlib_context_set_color_modifier(colormod);
+ imlib_context_set_operation(IMLIB_OP_ADD);
+ imlib_blend_image_onto_image_at_angle(im, 0, 0, 0, w, h,
+ w * i, h,
+ -(w * i), h * (i - 1));
+ imlib_context_set_operation(IMLIB_OP_COPY);
+ imlib_context_set_color_modifier(NULL);
+ imlib_render_image_on_drawable(0, 0);
+ pixels += w * h;
+ }
+ for (i = 0; i < 1; i += 0.01)
+ {
+ imlib_blend_image_onto_image(im, 0, 0, 0, w, h, 0, 0, w, h);
+ imlib_context_set_color_modifier(colormod);
+ imlib_context_set_operation(IMLIB_OP_SUBTRACT);
+ imlib_blend_image_onto_image_at_angle(im, 0, 0, 0, w, h,
+ w, h * (1 - i),
+ w * (i - 1), h * i);
+ imlib_context_set_operation(IMLIB_OP_COPY);
+ imlib_context_set_color_modifier(NULL);
+ imlib_render_image_on_drawable(0, 0);
+ pixels += w * h;
+ }
+ for (i = 0; i < 1; i += 0.01)
+ {
+ imlib_blend_image_onto_image(im, 0, 0, 0, w, h, 0, 0, w, h);
+ imlib_context_set_color_modifier(colormod);
+ imlib_context_set_operation(IMLIB_OP_RESHADE);
+ imlib_blend_image_onto_image_at_angle(im, 0, 0, 0, w, h,
+ w * (1 - i), 0,
+ w * i, h * (1 - i));
+ imlib_context_set_operation(IMLIB_OP_COPY);
+ imlib_context_set_color_modifier(NULL);
+ imlib_render_image_on_drawable(0, 0);
+ pixels += w * h;
+ }
+ imlib_free_image();
}
else if (filter)
{
- imlib_context_set_filter(imlib_create_filter(0));
- switch (filter) {
- default:
- case 1:
- /*\ Blur filter \*/
- imlib_filter_set( 0, 0, 0, 8, 8, 8);
- imlib_filter_set(-1, 0, 0, 4, 4, 4);
- imlib_filter_set( 0, -1, 0, 4, 4, 4);
- imlib_filter_set( 1, 0, 0, 4, 4, 4);
- imlib_filter_set( 0, 1, 0, 4, 4, 4);
- imlib_filter_set(-2, 0, 0, 1, 1, 1);
- imlib_filter_set( 0, -2, 0, 1, 1, 1);
- imlib_filter_set( 2, 0, 0, 1, 1, 1);
- imlib_filter_set( 0, 2, 0, 1, 1, 1);
- imlib_filter_set(-1, -1, 0, 1, 1, 1);
- imlib_filter_set(-1, 1, 0, 1, 1, 1);
- imlib_filter_set( 1, -1, 0, 1, 1, 1);
- imlib_filter_set( 1, 1, 0, 1, 1, 1);
- break;
- case 2:
- /*\ Sharpen filter \*/
- imlib_filter_set( 0, 0, 0, 5, 5, 5);
- imlib_filter_set(-1, 0, 0, -1, -1, -1);
- imlib_filter_set( 0, -1, 0, -1, -1, -1);
- imlib_filter_set( 1, 0, 0, -1, -1, -1);
- imlib_filter_set( 0, 1, 0, -1, -1, -1);
- break;
- case 3:
- /*\ Color blur filter \*/
- imlib_filter_set( 0, 0, 0, 3, 3, 3);
- imlib_filter_set(-1, -1, 0, 1, 0, 0);
- imlib_filter_set( 1, -1, 0, 0, 1, 0);
- imlib_filter_set( 0, 1, 0, 0, 0, 1);
- break;
- case 4:
- /*\ Emboss filter \*/
- imlib_filter_set_red (-1, -1, 0, -1, -1, -1);
- imlib_filter_set_red ( 0, 0, 0, 1, 1, 1);
- imlib_filter_set_green(-1, -1, 0, -1, -1, -1);
- imlib_filter_set_green( 0, 0, 0, 1, 1, 1);
- imlib_filter_set_blue (-1, -1, 0, -1, -1, -1);
- imlib_filter_set_blue ( 0, 0, 0, 1, 1, 1);
-
- imlib_filter_constants(0, 768, 768, 768);
- imlib_filter_divisors (0, 6, 6, 6);
- break;
- case 5:
- /*\ Grayscale filter \*/
- imlib_filter_set_red (0, 0, 0, 80, 1, 1);
- imlib_filter_set_green(0, 0, 0, 1, 80, 1);
- imlib_filter_set_blue (0, 0, 0, 1, 1, 80);
- break;
- case 6:
- /*\ Saturation filter \*/
- imlib_filter_set_red (0, 0, 0, 80, -1, -1);
- imlib_filter_set_green(0, 0, 0, -1, 80, -1);
- imlib_filter_set_blue (0, 0, 0, -1, -1, 80);
- break;
- case 7:
- /*\ Edge detection filter \*/
- imlib_filter_set(-1, -1, 0, -1, -1, -1);
- imlib_filter_set(-1, 0, 0, -3, -3, -3);
- imlib_filter_set(-1, 1, 0, -1, -1, -1);
- imlib_filter_set( 0, -1, 0, -3, -3, -3);
- imlib_filter_set( 0, 0, 0, 16, 16, 16);
- imlib_filter_set( 0, 1, 0, -3, -3, -3);
- imlib_filter_set( 1, -1, 0, -1, -1, -1);
- imlib_filter_set( 1, 0, 0, -3, -3, -3);
- imlib_filter_set( 1, 1, 0, -1, -1, -1);
- imlib_filter_divisors (0, 3, 3, 3);
- }
- pixels = 0;
- imlib_render_image_on_drawable_at_size(0, 0, w, h);
- for (i = 0; i < w; i++)
- {
- imlib_image_filter();
- imlib_render_image_on_drawable_at_size(0, 0, w, h);
- pixels += w * h;
- }
- imlib_free_filter();
+ imlib_context_set_filter(imlib_create_filter(0));
+ switch (filter)
+ {
+ default:
+ case 1:
+ /*\ Blur filter \ */
+ imlib_filter_set(0, 0, 0, 8, 8, 8);
+ imlib_filter_set(-1, 0, 0, 4, 4, 4);
+ imlib_filter_set(0, -1, 0, 4, 4, 4);
+ imlib_filter_set(1, 0, 0, 4, 4, 4);
+ imlib_filter_set(0, 1, 0, 4, 4, 4);
+ imlib_filter_set(-2, 0, 0, 1, 1, 1);
+ imlib_filter_set(0, -2, 0, 1, 1, 1);
+ imlib_filter_set(2, 0, 0, 1, 1, 1);
+ imlib_filter_set(0, 2, 0, 1, 1, 1);
+ imlib_filter_set(-1, -1, 0, 1, 1, 1);
+ imlib_filter_set(-1, 1, 0, 1, 1, 1);
+ imlib_filter_set(1, -1, 0, 1, 1, 1);
+ imlib_filter_set(1, 1, 0, 1, 1, 1);
+ break;
+ case 2:
+ /*\ Sharpen filter \ */
+ imlib_filter_set(0, 0, 0, 5, 5, 5);
+ imlib_filter_set(-1, 0, 0, -1, -1, -1);
+ imlib_filter_set(0, -1, 0, -1, -1, -1);
+ imlib_filter_set(1, 0, 0, -1, -1, -1);
+ imlib_filter_set(0, 1, 0, -1, -1, -1);
+ break;
+ case 3:
+ /*\ Color blur filter \ */
+ imlib_filter_set(0, 0, 0, 3, 3, 3);
+ imlib_filter_set(-1, -1, 0, 1, 0, 0);
+ imlib_filter_set(1, -1, 0, 0, 1, 0);
+ imlib_filter_set(0, 1, 0, 0, 0, 1);
+ break;
+ case 4:
+ /*\ Emboss filter \ */
+ imlib_filter_set_red(-1, -1, 0, -1, -1, -1);
+ imlib_filter_set_red(0, 0, 0, 1, 1, 1);
+ imlib_filter_set_green(-1, -1, 0, -1, -1, -1);
+ imlib_filter_set_green(0, 0, 0, 1, 1, 1);
+ imlib_filter_set_blue(-1, -1, 0, -1, -1, -1);
+ imlib_filter_set_blue(0, 0, 0, 1, 1, 1);
+
+ imlib_filter_constants(0, 768, 768, 768);
+ imlib_filter_divisors(0, 6, 6, 6);
+ break;
+ case 5:
+ /*\ Grayscale filter \ */
+ imlib_filter_set_red(0, 0, 0, 80, 1, 1);
+ imlib_filter_set_green(0, 0, 0, 1, 80, 1);
+ imlib_filter_set_blue(0, 0, 0, 1, 1, 80);
+ break;
+ case 6:
+ /*\ Saturation filter \ */
+ imlib_filter_set_red(0, 0, 0, 80, -1, -1);
+ imlib_filter_set_green(0, 0, 0, -1, 80, -1);
+ imlib_filter_set_blue(0, 0, 0, -1, -1, 80);
+ break;
+ case 7:
+ /*\ Edge detection filter \ */
+ imlib_filter_set(-1, -1, 0, -1, -1, -1);
+ imlib_filter_set(-1, 0, 0, -3, -3, -3);
+ imlib_filter_set(-1, 1, 0, -1, -1, -1);
+ imlib_filter_set(0, -1, 0, -3, -3, -3);
+ imlib_filter_set(0, 0, 0, 16, 16, 16);
+ imlib_filter_set(0, 1, 0, -3, -3, -3);
+ imlib_filter_set(1, -1, 0, -1, -1, -1);
+ imlib_filter_set(1, 0, 0, -3, -3, -3);
+ imlib_filter_set(1, 1, 0, -1, -1, -1);
+ imlib_filter_divisors(0, 3, 3, 3);
+ }
+ pixels = 0;
+ imlib_render_image_on_drawable_at_size(0, 0, w, h);
+ for (i = 0; i < w; i++)
+ {
+ imlib_image_filter();
+ imlib_render_image_on_drawable_at_size(0, 0, w, h);
+ pixels += w * h;
+ }
+ imlib_free_filter();
}
else if (interactive)
{
- int wo, ho, px, py, first = 1;
- Imlib_Image im_bg, im_sh1, im_sh2, im_sh3, im_ic[13], im_tmp;
- /* Imlib_Border border; */
- Imlib_Updates up = NULL;
- int x, y, i, j;
- XEvent ev;
- Imlib_Font fn=NULL;
- struct font_hdr
- {
- int type;
- struct font_hdr *next;
- char *name;
- int ref;
- XFontSet xfontset;
- int font_count;
- XFontStruct **font_struct;
- char **font_name;
- int ascent;
- int descent;
- int max_ascent;
- int max_descent;
- int max_width;
- struct font_hdr *ttf;
- } *f, *f1, *f2, *f3, *f4;
-
- /* "ARIAL/30" "COMIC/30" "IMPACT/30" "Prole/30" "Proteron/30" */
- /* "TIMES/30" "badacid/30" "bajoran/30" "bigfish/30" */
- imlib_add_path_to_font_path("./ttfonts");
-
- if (xfdtest)
- {
- printf( "Font Cache test start\n" );
-
- f = imlib_load_font( "notepad/10" );
- printf("imlib_load_font: f=%x, next=%8x, type=%d, ref=%d, '%s'\n",
- f, f->next, f->type, f->ref, f->name);
- imlib_context_set_font((Imlib_Font)f);
- printf( "\t\t ascent=%d, descent=%d, max_ascent=%d, max_descent=%d\n",
- imlib_get_font_ascent(),imlib_get_font_descent(),
- imlib_get_maximum_font_ascent(), imlib_get_maximum_font_descent() );
- imlib_free_font();
- printf("imlib_free_font: f=%x, next=%8x, type=%d, ref=%d, '%s'\n",
- f, f->next, f->type, f->ref, f->name);
- printf("\n");
-
- f = imlib_load_font( "-*-fixed-*--14-*" );
- printf("imlib_load_font: f=%x, next=%8x, type=%d, ref=%d, '%s'\n",
- f, f->next, f->type, f->ref, f->name);
- imlib_context_set_font((Imlib_Font)f);
- printf( "\t\t ascent=%d, descent=%d, max_ascent=%d, max_descent=%d\n",
- imlib_get_font_ascent(),imlib_get_font_descent(),
- imlib_get_maximum_font_ascent(), imlib_get_maximum_font_descent() );
- imlib_free_font();
- printf("imlib_free_font: f=%x, next=%8x, type=%d, ref=%d, '%s'\n",
- f, f->next, f->type, f->ref, f->name);
- printf("\n");
-
- f1 = imlib_load_font( "notepad/10" );
- printf("imlib_load_font: f=%x, next=%8x, type=%d, ref=%d, '%s'\n",
- f1, f1->next, f1->type, f1->ref, f1->name);
- f2 = imlib_load_font( "-*-fixed-*--14-*" );
- printf("imlib_load_font: f=%x, next=%8x, type=%d, ref=%d, '%s'\n",
- f2, f2->next, f2->type, f2->ref, f2->name);
- f3 = imlib_load_font( "notepad/10,-*-fixed-*--14-*" );
- printf("imlib_load_font: f=%x, next=%8x, type=%d, ref=%d, '%s'\n",
- f3, f3->next, f3->type, f3->ref, f3->name);
- f = f3->ttf;
- printf(" f->ttf: f=%x, next=%8x, type=%d, ref=%d, '%s'\n",
- f, f->next, f->type, f->ref, f->name);
- f4 = imlib_load_font( "notepad/10,-*-fixed-*--14-*" );
- printf("imlib_load_font: f=%x, next=%8x, type=%d, ref=%d, '%s'\n",
- f4, f4->next, f4->type, f4->ref, f4->name);
- f = f4->ttf;
- printf(" f->ttf: f=%x, next=%8x, type=%d, ref=%d, '%s'\n",
- f, f->next, f->type, f->ref, f->name);
- printf("\n");
-
- imlib_context_set_font((Imlib_Font)f4);
- imlib_free_font();
- printf("imlib_free_font: f=%x, next=%8x, type=%d, ref=%d, '%s'\n",
- f4, f4->next, f4->type, f4->ref, f4->name);
- f = f4->ttf;
- printf(" f->ttf: f=%x, next=%8x, type=%d, ref=%d, '%s'\n",
- f, f->next, f->type, f->ref, f->name);
- imlib_context_set_font((Imlib_Font)f1);
- imlib_free_font();
- printf("imlib_free_font: f=%x, next=%8x, type=%d, ref=%d, '%s'\n",
- f1, f1->next, f1->type, f1->ref, f1->name);
- imlib_context_set_font((Imlib_Font)f2);
- imlib_free_font();
- printf("imlib_free_font: f=%x, next=%8x, type=%d, ref=%d, '%s'\n",
- f2, f2->next, f2->type, f2->ref, f2->name);
- imlib_context_set_font((Imlib_Font)f3);
- imlib_free_font();
- printf("imlib_free_font: f=%x, next=%8x, type=%d, ref=%d, '%s'\n",
- f3, f3->next, f3->type, f3->ref, f3->name);
- f = f3->ttf;
- printf(" f->ttf: f=%x, next=%8x, type=%d, ref=%d, '%s'\n",
- f, f->next, f->type, f->ref, f->name);
- printf("\n");
- imlib_flush_font_cache();
- printf("imlib_flush_font_cache: \n");
- printf("\n");
- f1 = imlib_load_font( "notepad/10,-*-fixed-*--14-*" );
- printf("imlib_load_font: f=%x, next=%8x, type=%d, ref=%d, '%s'\n",
- f1, f1->next, f1->type, f1->ref, f1->name);
- f = f1->ttf;
- printf(" f->ttf: f=%x, next=%8x, type=%d, ref=%d, '%s'\n",
- f, f->next, f->type, f->ref, f->name);
- imlib_context_set_font((Imlib_Font)f1);
- printf( "\t\t ascent=%d, descent=%d, max_ascent=%d, max_descent=%d\n",
- imlib_get_font_ascent(),imlib_get_font_descent(),
- imlib_get_maximum_font_ascent(), imlib_get_maximum_font_descent() );
-
- printf( "Font Cache test end\n" );
- }
-
- if (fon)
- {
- fn = imlib_load_font(fon);
-
- if (xfdtest)
- {
- int i;
-
- f = fn;
- if (fn != NULL && f->type & 2)
- for (i=0; i<f->font_count; i++)
- printf("xfont%d: %s\n", i, f->font_name[i]);
- }
-
- imlib_context_set_font(fn);
- if (!fn)
- fon = NULL;
- }
-
- imlib_context_set_progress_function(NULL);
- imlib_context_set_progress_granularity(0);
- if (file)
- im_bg = imlib_load_image(file);
- else
- im_bg = imlib_load_image("test_images/bg.png");
- imlib_context_set_image(im_bg);
- im_tmp = imlib_clone_image();
- w = imlib_image_get_width();
- h = imlib_image_get_height();
- wo = w;
- ho = h;
- w *= 1;
- h *= 1;
- XResizeWindow(disp, win, w, h);
- XSync(disp, False);
- im = imlib_create_image(w, h);
- imlib_set_cache_size(4 * 1024 * 1024);
- i = 0;
- up = imlib_update_append_rect(up, 0, 0, w, h);
- x = -9999;
- y = -9999;
- while (1)
- {
- 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;
- case ButtonRelease:
- if (fon)
- {
- imlib_context_set_font(fn);
- imlib_free_font();
- }
- exit(0);
- break;
- case MotionNotify:
- x = ev.xmotion.x;
- y = ev.xmotion.y;
- default:
- break;
-
- }
- }
- while (XPending(disp));
-
- 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");
- 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");
-
- imlib_context_set_image(im);
- if (first)
- {
- imlib_blend_image_onto_image(im_bg, 0,
- 0, 0, w, h,
- 0, 0, w, h);
- first = 0;
- }
- else if (rotate)
- {
- Imlib_Image rotim;
- double s, c;
- int x1, y1, x2, y2, w, h;
-
- w = imlib_image_get_width();
- h = imlib_image_get_height();
- s = sin(6.2831853 * (double)y / (double)h);
- c = cos(6.2831853 * (double)y / (double)h);
-
- x1 = (w - w * c + h * s) / 2;
- y1 = (h - h * c - w * s) / 2;
- x2 = (w + w * c - h * s) / 2;
- y2 = (h + h * c + w * s) / 2;
-
- imlib_context_set_blend(1);
- imlib_blend_image_onto_image_at_angle(im_bg, 0,
- 0, 0,
- imlib_image_get_width(),
- imlib_image_get_height(),
- x1, y1, x2, y2);
- up = imlib_update_append_rect(up, 0, 0,
- imlib_image_get_width(),
- imlib_image_get_height());
-
- }
+ int wo, ho, px, py, first = 1;
+ Imlib_Image im_bg, im_sh1, im_sh2, im_sh3, im_ic[13], im_tmp;
+
+ /* Imlib_Border border; */
+ Imlib_Updates up = NULL;
+ int x, y, i, j;
+ XEvent ev;
+ Imlib_Font fn = NULL;
+ struct font_hdr {
+ int type;
+ struct font_hdr *next;
+ char *name;
+ int ref;
+ XFontSet xfontset;
+ int font_count;
+ XFontStruct **font_struct;
+ char **font_name;
+ int ascent;
+ int descent;
+ int max_ascent;
+ int max_descent;
+ int max_width;
+ struct font_hdr *ttf;
+ } *f, *f1, *f2, *f3, *f4;
+
+ /* "ARIAL/30" "COMIC/30" "IMPACT/30" "Prole/30" "Proteron/30" */
+ /* "TIMES/30" "badacid/30" "bajoran/30" "bigfish/30" */
+ imlib_add_path_to_font_path("./ttfonts");
+
+ if (xfdtest)
+ {
+ printf("Font Cache test start\n");
+
+ f = imlib_load_font("notepad/10");
+ printf("imlib_load_font: f=%x, next=%8x, type=%d, ref=%d, '%s'\n",
+ f, f->next, f->type, f->ref, f->name);
+ imlib_context_set_font((Imlib_Font) f);
+ printf
+ ("\t\t ascent=%d, descent=%d, max_ascent=%d, max_descent=%d\n",
+ imlib_get_font_ascent(), imlib_get_font_descent(),
+ imlib_get_maximum_font_ascent(),
+ imlib_get_maximum_font_descent());
+ imlib_free_font();
+ printf("imlib_free_font: f=%x, next=%8x, type=%d, ref=%d, '%s'\n",
+ f, f->next, f->type, f->ref, f->name);
+ printf("\n");
+
+ f = imlib_load_font("-*-fixed-*--14-*");
+ printf("imlib_load_font: f=%x, next=%8x, type=%d, ref=%d, '%s'\n",
+ f, f->next, f->type, f->ref, f->name);
+ imlib_context_set_font((Imlib_Font) f);
+ printf
+ ("\t\t ascent=%d, descent=%d, max_ascent=%d, max_descent=%d\n",
+ imlib_get_font_ascent(), imlib_get_font_descent(),
+ imlib_get_maximum_font_ascent(),
+ imlib_get_maximum_font_descent());
+ imlib_free_font();
+ printf("imlib_free_font: f=%x, next=%8x, type=%d, ref=%d, '%s'\n",
+ f, f->next, f->type, f->ref, f->name);
+ printf("\n");
+
+ f1 = imlib_load_font("notepad/10");
+ printf("imlib_load_font: f=%x, next=%8x, type=%d, ref=%d, '%s'\n",
+ f1, f1->next, f1->type, f1->ref, f1->name);
+ f2 = imlib_load_font("-*-fixed-*--14-*");
+ printf("imlib_load_font: f=%x, next=%8x, type=%d, ref=%d, '%s'\n",
+ f2, f2->next, f2->type, f2->ref, f2->name);
+ f3 = imlib_load_font("notepad/10,-*-fixed-*--14-*");
+ printf("imlib_load_font: f=%x, next=%8x, type=%d, ref=%d, '%s'\n",
+ f3, f3->next, f3->type, f3->ref, f3->name);
+ f = f3->ttf;
+ printf(" f->ttf: f=%x, next=%8x, type=%d, ref=%d, '%s'\n",
+ f, f->next, f->type, f->ref, f->name);
+ f4 = imlib_load_font("notepad/10,-*-fixed-*--14-*");
+ printf("imlib_load_font: f=%x, next=%8x, type=%d, ref=%d, '%s'\n",
+ f4, f4->next, f4->type, f4->ref, f4->name);
+ f = f4->ttf;
+ printf(" f->ttf: f=%x, next=%8x, type=%d, ref=%d, '%s'\n",
+ f, f->next, f->type, f->ref, f->name);
+ printf("\n");
+
+ imlib_context_set_font((Imlib_Font) f4);
+ imlib_free_font();
+ printf("imlib_free_font: f=%x, next=%8x, type=%d, ref=%d, '%s'\n",
+ f4, f4->next, f4->type, f4->ref, f4->name);
+ f = f4->ttf;
+ printf(" f->ttf: f=%x, next=%8x, type=%d, ref=%d, '%s'\n",
+ f, f->next, f->type, f->ref, f->name);
+ imlib_context_set_font((Imlib_Font) f1);
+ imlib_free_font();
+ printf("imlib_free_font: f=%x, next=%8x, type=%d, ref=%d, '%s'\n",
+ f1, f1->next, f1->type, f1->ref, f1->name);
+ imlib_context_set_font((Imlib_Font) f2);
+ imlib_free_font();
+ printf("imlib_free_font: f=%x, next=%8x, type=%d, ref=%d, '%s'\n",
+ f2, f2->next, f2->type, f2->ref, f2->name);
+ imlib_context_set_font((Imlib_Font) f3);
+ imlib_free_font();
+ printf("imlib_free_font: f=%x, next=%8x, type=%d, ref=%d, '%s'\n",
+ f3, f3->next, f3->type, f3->ref, f3->name);
+ f = f3->ttf;
+ printf(" f->ttf: f=%x, next=%8x, type=%d, ref=%d, '%s'\n",
+ f, f->next, f->type, f->ref, f->name);
+ printf("\n");
+ imlib_flush_font_cache();
+ printf("imlib_flush_font_cache: \n");
+ printf("\n");
+ f1 = imlib_load_font("notepad/10,-*-fixed-*--14-*");
+ printf("imlib_load_font: f=%x, next=%8x, type=%d, ref=%d, '%s'\n",
+ f1, f1->next, f1->type, f1->ref, f1->name);
+ f = f1->ttf;
+ printf(" f->ttf: f=%x, next=%8x, type=%d, ref=%d, '%s'\n",
+ f, f->next, f->type, f->ref, f->name);
+ imlib_context_set_font((Imlib_Font) f1);
+ printf
+ ("\t\t ascent=%d, descent=%d, max_ascent=%d, max_descent=%d\n",
+ imlib_get_font_ascent(), imlib_get_font_descent(),
+ imlib_get_maximum_font_ascent(),
+ imlib_get_maximum_font_descent());
+
+ printf("Font Cache test end\n");
+ }
+
+ if (fon)
+ {
+ fn = imlib_load_font(fon);
+
+ if (xfdtest)
+ {
+ int i;
+
+ f = fn;
+ if (fn != NULL && f->type & 2)
+ for (i = 0; i < f->font_count; i++)
+ printf("xfont%d: %s\n", i, f->font_name[i]);
+ }
+
+ imlib_context_set_font(fn);
+ if (!fn)
+ fon = NULL;
+ }
+
+ imlib_context_set_progress_function(NULL);
+ imlib_context_set_progress_granularity(0);
+ if (file)
+ im_bg = imlib_load_image(file);
+ else
+ im_bg = imlib_load_image("test_images/bg.png");
+ imlib_context_set_image(im_bg);
+ im_tmp = imlib_clone_image();
+ w = imlib_image_get_width();
+ h = imlib_image_get_height();
+ wo = w;
+ ho = h;
+ w *= 1;
+ h *= 1;
+ XResizeWindow(disp, win, w, h);
+ XSync(disp, False);
+ im = imlib_create_image(w, h);
+ imlib_set_cache_size(4 * 1024 * 1024);
+ i = 0;
+ up = imlib_update_append_rect(up, 0, 0, w, h);
+ x = -9999;
+ y = -9999;
+ while (1)
+ {
+ 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;
+ case ButtonRelease:
+ if (fon)
+ {
+ imlib_context_set_font(fn);
+ imlib_free_font();
+ }
+ exit(0);
+ break;
+ case MotionNotify:
+ x = ev.xmotion.x;
+ y = ev.xmotion.y;
+ default:
+ break;
+
+ }
+ }
+ while (XPending(disp));
+
+ 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");
+ 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");
+
+ imlib_context_set_image(im);
+ if (first)
+ {
+ imlib_blend_image_onto_image(im_bg, 0,
+ 0, 0, w, h, 0, 0, w, h);
+ first = 0;
+ }
+ else if (rotate)
+ {
+ Imlib_Image rotim;
+ double s, c;
+ int x1, y1, x2, y2, w, h;
+
+ w = imlib_image_get_width();
+ h = imlib_image_get_height();
+ s = sin(6.2831853 * (double)y / (double)h);
+ c = cos(6.2831853 * (double)y / (double)h);
+
+ x1 = (w - w * c + h * s) / 2;
+ y1 = (h - h * c - w * s) / 2;
+ x2 = (w + w * c - h * s) / 2;
+ y2 = (h + h * c + w * s) / 2;
+
+ imlib_context_set_blend(1);
+ imlib_blend_image_onto_image_at_angle(im_bg, 0,
+ 0, 0,
+ imlib_image_get_width(),
+ imlib_image_get_height
+ (), x1, y1, x2, y2);
+ up = imlib_update_append_rect(up, 0, 0,
+ imlib_image_get_width(),
+ imlib_image_get_height());
+
+ }
/*
if( bump_map_to_point )
imlib_apply_filter("bump_map_point(x=[],y=[],map=test_images/bulb.png);", &x, &y );
else
imlib_apply_filter("bump_map(x=[],y=[],map=test_images/bulb.png);", &x, &y );
-*/
- up = imlib_update_append_rect(up, 0, 0,
- imlib_image_get_width(),
- imlib_image_get_height());
- {
- Imlib_Updates uu;
-
- imlib_context_set_cliprect(0,0,0,0);
- imlib_context_set_color(255, 255, 255, 255);
- uu = imlib_image_draw_line(200, 200, x, y, 1);
- up = imlib_updates_append_updates(up, uu);
-
- /* test ellipses */
- imlib_context_set_color(255, 255, 255, 255);
- imlib_image_draw_ellipse(50,250,30,40);
- imlib_image_fill_ellipse(50,300,30,40);
-
- imlib_image_draw_rectangle(120,245,70,70);
- up = imlib_update_append_rect(up, 120,245,70,70);
- imlib_image_draw_ellipse(160,280,50,20);
-
- imlib_context_set_cliprect(120,245,70,70);
- imlib_context_set_color(255, 55, 55, 255);
- imlib_image_draw_ellipse(160,280,50,20);
-
- /* test line clipping */
- imlib_context_set_cliprect(0,0,0,0);
- imlib_image_draw_rectangle(50,50,100,100);
- up = imlib_update_append_rect(up, 50,50,100,100);
-
- imlib_context_set_color(255, 255, 255, 255);
-
- uu = imlib_image_draw_line(0, 0, 200, 200, 1);
- up = imlib_updates_append_updates(up, uu);
-
- uu = imlib_image_draw_line(305, 25, 20, 200, 1);
- up = imlib_updates_append_updates(up, uu);
-
- uu = imlib_image_draw_line(100, 5, 100, 205, 1);
- up = imlib_updates_append_updates(up, uu);
-
- uu = imlib_image_draw_line(275, 5, 20, 100, 1);
- up = imlib_updates_append_updates(up, uu);
-
-
- imlib_context_set_color(255, 55, 55, 255);
- imlib_context_set_cliprect(50,50,100,100);
-
- uu = imlib_image_draw_line(0, 0, 200, 200,1);
- up = imlib_updates_append_updates(up, uu);
-
- uu = imlib_image_draw_line(305, 25, 20, 200,1);
- up = imlib_updates_append_updates(up, uu);
-
- uu = imlib_image_draw_line(100, 5, 100, 205,1);
- up = imlib_updates_append_updates(up, uu);
-
- uu = imlib_image_draw_line(275, 5, 20, 100,1);
- up = imlib_updates_append_updates(up, uu);
-
-
- /* test rectangle clipping */
- imlib_context_set_color(255, 255, 255, 255);
- imlib_context_set_cliprect(0,0,0,0);
-
- imlib_image_draw_rectangle(70,90,20,20);
- imlib_image_draw_rectangle(115,70,60,30);
- imlib_image_draw_rectangle(30,120,50,50);
-
- imlib_context_set_color(255, 55, 55, 255);
- imlib_context_set_cliprect(50,50,100,100);
-
- imlib_image_draw_rectangle(70,90,20,20);
- up = imlib_update_append_rect(up, 70,90,20,20);
- imlib_image_draw_rectangle(115,70,60,30);
- up = imlib_update_append_rect(up, 115,70,60,30);
- imlib_image_draw_rectangle(30,120,50,50);
- up = imlib_update_append_rect(up, 30,120,50,50);
-
- imlib_context_set_cliprect(0,0,0,0);
-
- /* test polygons */
- imlib_context_set_color(255, 0, 0, 128);
- imlib_image_fill_polygon(poly);
- imlib_context_set_color(255, 255, 255, 255);
- imlib_image_draw_polygon(poly2,0);
- imlib_image_draw_polygon(poly3,1);
- imlib_image_draw_rectangle(380,260,50,50);
-
- imlib_context_set_color(255, 55, 55, 255);
- imlib_context_set_cliprect(380,260,50,50);
- imlib_image_fill_polygon(poly3);
- imlib_context_set_cliprect(0,0,0,0);
-
- }
- {
- static Imlib_Color_Range rg = NULL;
-
- if (!rg)
- {
- rg = imlib_create_color_range();
- imlib_context_set_color_range(rg);
- imlib_context_set_color(255, 255, 255, 255);
- imlib_add_color_to_color_range(0);
- imlib_context_set_color(255, 255,160, 255);
- imlib_add_color_to_color_range(1);
- imlib_context_set_color(255, 160, 120, 255);
- imlib_add_color_to_color_range(1);
- imlib_context_set_color(255, 80, 100, 128);
- imlib_add_color_to_color_range(1);
- imlib_context_set_color(32, 48, 80, 0);
- imlib_add_color_to_color_range(1);
- }
- imlib_context_set_operation(IMLIB_OP_RESHADE);
- imlib_image_fill_color_range_rectangle(60, 60, 256, 256, (double)x);
- up = imlib_update_append_rect(up, 60, 60, 256, 256);
- imlib_context_set_operation(IMLIB_OP_COPY);
- }
-
- if (xfdcachetest)
- {
- int l;
- int retw, reth, tx, ty, nx, ny;
- int secs, usecs, sece, usece;
- FILE *f;
- char buf[129];
-
- f = fopen(xfdfname, "r");
- if (!f)
- {
- printf("file %s can not be opened!\n", file);
- exit(-1);
- }
-
- tx = ty = 0;
- imlib_context_set_color(255, 255, 255, 255);
-
- gettimeofday(&timev,NULL);
- secs=(int)timev.tv_sec;
- usecs=(int)timev.tv_usec;
-
- l = xfdloop;
- while(l)
- {
- fseek(f, 0, SEEK_SET);
- while (fgets(buf, 128, f))
- {
- if ( buf[strlen(buf)-1] == '\n' )
- buf[strlen(buf)-1] = '\0';
- imlib_text_draw_with_return_metrics(tx, ty, buf,
- &retw, &reth,
- &nx, &ny);
- up = imlib_update_append_rect(up, tx, ty, retw, reth);
- ty += ny;
- if (ty > h)
- ty = 0;
- }
- l--;
- }
-
- gettimeofday(&timev,NULL);
- sece=(int)timev.tv_sec;
- usece=(int)timev.tv_usec;
- {
- double t1, t2;
-
- t1 = (double)secs + ((double)usecs / 1000000);
- t2 = (double)sece + ((double)usece / 1000000);
- sec = t2 - t1;
- }
- printf("%3.3f sec\n", sec);
-
- }
- else if (fon)
- {
- int retw, reth, tx, ty, nx, ny, cx, cy, cw, ch, cp;
- int cx2, cy2, cw2, ch2;
-
- if (!str)
- str = "This is a test string";
- tx = ty = 50;
- for (i = 0; i < 16; i++)
- {
- int al;
-
- imlib_context_set_direction(textdir);
- if (textdir == IMLIB_TEXT_TO_ANGLE)
- {
- double an = (double)i / 10.0;
- imlib_context_set_angle(an);
- }
-
- al = (15 - i) * 16;
- if (al > 255)
- al = 255;
- imlib_context_set_color(255, 255, 255, al);
- imlib_text_draw_with_return_metrics(tx, ty, str,
- &retw, &reth,
- &nx, &ny);
- up = imlib_update_append_rect(up, tx, ty, retw, reth);
- switch(textdir)
- {
- case IMLIB_TEXT_TO_RIGHT:
- case IMLIB_TEXT_TO_LEFT:
- case IMLIB_TEXT_TO_ANGLE:
- ty += ny;
- break;
- case IMLIB_TEXT_TO_DOWN:
- case IMLIB_TEXT_TO_UP:
- tx += nx;
- break;
- }
- }
- cp = imlib_text_get_index_and_location(str, x - 50, y - 50,
- &cx, &cy, &cw, &ch);
- if (cp >= 0)
- {
- char tmp[16];
- int len;
-
- len = mblen(str+cp, MB_CUR_MAX);
- if (len < 0)
- len = 1;
- strncpy(tmp, str+cp, len);
- tmp[len] = '\0';
- printf("over char %s : cp=%d cx=%d cy=%d cw=%d ch=%d : ",
- tmp, cp, cx, cy, cw, ch);
- imlib_text_get_location_at_index(str, cp, &cx2, &cy2,
- &cw2, &ch2);
- printf("cx2=%d cy2=%d cw2=%d ch2=%d \n",
- cx2, cy2, cw2, ch2);
- }
- }
- imlib_context_set_blend(1);
- if ((px != x) || (py != y))
- {
- for (j = 0; j < 32; j++)
- {
- for (i = 0; i < 32; i++)
- {
- int ic, iw, ih, ww, hh;
-
- ic = ((j * 32) + i) % 13;
- imlib_context_set_image(im_ic[ic]);
- iw = imlib_image_get_width();
- ih = imlib_image_get_height();
- 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_context_set_image(im);
- imlib_blend_image_onto_image(im_ic[ic], 0,
- 0, 0, iw, ih,
- x + (i * iw * 2),
- y + (j * ih * 2),
- ww, hh);
- }
- }
- }
+*/
+ up = imlib_update_append_rect(up, 0, 0,
+ imlib_image_get_width(),
+ imlib_image_get_height());
+ {
+ Imlib_Updates uu;
+
+ imlib_context_set_cliprect(0, 0, 0, 0);
+ imlib_context_set_color(255, 255, 255, 255);
+ uu = imlib_image_draw_line(200, 200, x, y, 1);
+ up = imlib_updates_append_updates(up, uu);
+
+ /* test ellipses */
+ imlib_context_set_color(255, 255, 255, 255);
+ imlib_image_draw_ellipse(50, 250, 30, 40);
+ imlib_image_fill_ellipse(50, 300, 30, 40);
+
+ imlib_image_draw_rectangle(120, 245, 70, 70);
+ up = imlib_update_append_rect(up, 120, 245, 70, 70);
+ imlib_image_draw_ellipse(160, 280, 50, 20);
+
+ imlib_context_set_cliprect(120, 245, 70, 70);
+ imlib_context_set_color(255, 55, 55, 255);
+ imlib_image_draw_ellipse(160, 280, 50, 20);
+
+ /* test line clipping */
+ imlib_context_set_cliprect(0, 0, 0, 0);
+ imlib_image_draw_rectangle(50, 50, 100, 100);
+ up = imlib_update_append_rect(up, 50, 50, 100, 100);
+
+ imlib_context_set_color(255, 255, 255, 255);
+
+ uu = imlib_image_draw_line(0, 0, 200, 200, 1);
+ up = imlib_updates_append_updates(up, uu);
+
+ uu = imlib_image_draw_line(305, 25, 20, 200, 1);
+ up = imlib_updates_append_updates(up, uu);
+
+ uu = imlib_image_draw_line(100, 5, 100, 205, 1);
+ up = imlib_updates_append_updates(up, uu);
+
+ uu = imlib_image_draw_line(275, 5, 20, 100, 1);
+ up = imlib_updates_append_updates(up, uu);
+
+ imlib_context_set_color(255, 55, 55, 255);
+ imlib_context_set_cliprect(50, 50, 100, 100);
+
+ uu = imlib_image_draw_line(0, 0, 200, 200, 1);
+ up = imlib_updates_append_updates(up, uu);
+
+ uu = imlib_image_draw_line(305, 25, 20, 200, 1);
+ up = imlib_updates_append_updates(up, uu);
+
+ uu = imlib_image_draw_line(100, 5, 100, 205, 1);
+ up = imlib_updates_append_updates(up, uu);
+
+ uu = imlib_image_draw_line(275, 5, 20, 100, 1);
+ up = imlib_updates_append_updates(up, uu);
+
+ /* test rectangle clipping */
+ imlib_context_set_color(255, 255, 255, 255);
+ imlib_context_set_cliprect(0, 0, 0, 0);
+
+ imlib_image_draw_rectangle(70, 90, 20, 20);
+ imlib_image_draw_rectangle(115, 70, 60, 30);
+ imlib_image_draw_rectangle(30, 120, 50, 50);
+
+ imlib_context_set_color(255, 55, 55, 255);
+ imlib_context_set_cliprect(50, 50, 100, 100);
+
+ imlib_image_draw_rectangle(70, 90, 20, 20);
+ up = imlib_update_append_rect(up, 70, 90, 20, 20);
+ imlib_image_draw_rectangle(115, 70, 60, 30);
+ up = imlib_update_append_rect(up, 115, 70, 60, 30);
+ imlib_image_draw_rectangle(30, 120, 50, 50);
+ up = imlib_update_append_rect(up, 30, 120, 50, 50);
+
+ imlib_context_set_cliprect(0, 0, 0, 0);
+
+ /* test polygons */
+ imlib_context_set_color(255, 0, 0, 128);
+ imlib_image_fill_polygon(poly);
+ imlib_context_set_color(255, 255, 255, 255);
+ imlib_image_draw_polygon(poly2, 0);
+ imlib_image_draw_polygon(poly3, 1);
+ imlib_image_draw_rectangle(380, 260, 50, 50);
+
+ imlib_context_set_color(255, 55, 55, 255);
+ imlib_context_set_cliprect(380, 260, 50, 50);
+ imlib_image_fill_polygon(poly3);
+ imlib_context_set_cliprect(0, 0, 0, 0);
+
+ }
+ {
+ static Imlib_Color_Range rg = NULL;
+
+ if (!rg)
+ {
+ rg = imlib_create_color_range();
+ imlib_context_set_color_range(rg);
+ imlib_context_set_color(255, 255, 255, 255);
+ imlib_add_color_to_color_range(0);
+ imlib_context_set_color(255, 255, 160, 255);
+ imlib_add_color_to_color_range(1);
+ imlib_context_set_color(255, 160, 120, 255);
+ imlib_add_color_to_color_range(1);
+ imlib_context_set_color(255, 80, 100, 128);
+ imlib_add_color_to_color_range(1);
+ imlib_context_set_color(32, 48, 80, 0);
+ imlib_add_color_to_color_range(1);
+ }
+ imlib_context_set_operation(IMLIB_OP_RESHADE);
+ imlib_image_fill_color_range_rectangle(60, 60, 256, 256,
+ (double)x);
+ up = imlib_update_append_rect(up, 60, 60, 256, 256);
+ imlib_context_set_operation(IMLIB_OP_COPY);
+ }
+
+ if (xfdcachetest)
+ {
+ int l;
+ int retw, reth, tx, ty, nx, ny;
+ int secs, usecs, sece, usece;
+ FILE *f;
+ char buf[129];
+
+ f = fopen(xfdfname, "r");
+ if (!f)
+ {
+ printf("file %s can not be opened!\n", file);
+ exit(-1);
+ }
+
+ tx = ty = 0;
+ imlib_context_set_color(255, 255, 255, 255);
+
+ gettimeofday(&timev, NULL);
+ secs = (int)timev.tv_sec;
+ usecs = (int)timev.tv_usec;
+
+ l = xfdloop;
+ while (l)
+ {
+ fseek(f, 0, SEEK_SET);
+ while (fgets(buf, 128, f))
+ {
+ if (buf[strlen(buf) - 1] == '\n')
+ buf[strlen(buf) - 1] = '\0';
+ imlib_text_draw_with_return_metrics(tx, ty, buf,
+ &retw, &reth,
+ &nx, &ny);
+ up = imlib_update_append_rect(up, tx, ty, retw,
+ reth);
+ ty += ny;
+ if (ty > h)
+ ty = 0;
+ }
+ l--;
+ }
+
+ gettimeofday(&timev, NULL);
+ sece = (int)timev.tv_sec;
+ usece = (int)timev.tv_usec;
+ {
+ double t1, t2;
+
+ t1 = (double)secs + ((double)usecs / 1000000);
+ t2 = (double)sece + ((double)usece / 1000000);
+ sec = t2 - t1;
+ }
+ printf("%3.3f sec\n", sec);
+
+ }
+ else if (fon)
+ {
+ int retw, reth, tx, ty, nx, ny, cx, cy, cw,
+ ch, cp;
+ int cx2, cy2, cw2, ch2;
+
+ if (!str)
+ str = "This is a test string";
+ tx = ty = 50;
+ for (i = 0; i < 16; i++)
+ {
+ int al;
+
+ imlib_context_set_direction(textdir);
+ if (textdir == IMLIB_TEXT_TO_ANGLE)
+ {
+ double an = (double)i / 10.0;
+
+ imlib_context_set_angle(an);
+ }
+
+ al = (15 - i) * 16;
+ if (al > 255)
+ al = 255;
+ imlib_context_set_color(255, 255, 255, al);
+ imlib_text_draw_with_return_metrics(tx, ty, str,
+ &retw, &reth,
+ &nx, &ny);
+ up = imlib_update_append_rect(up, tx, ty, retw, reth);
+ switch (textdir)
+ {
+ case IMLIB_TEXT_TO_RIGHT:
+ case IMLIB_TEXT_TO_LEFT:
+ case IMLIB_TEXT_TO_ANGLE:
+ ty += ny;
+ break;
+ case IMLIB_TEXT_TO_DOWN:
+ case IMLIB_TEXT_TO_UP:
+ tx += nx;
+ break;
+ }
+ }
+ cp = imlib_text_get_index_and_location(str, x - 50, y - 50,
+ &cx, &cy, &cw, &ch);
+ if (cp >= 0)
+ {
+ char tmp[16];
+ int len;
+
+ len = mblen(str + cp, MB_CUR_MAX);
+ if (len < 0)
+ len = 1;
+ strncpy(tmp, str + cp, len);
+ tmp[len] = '\0';
+ printf("over char %s : cp=%d cx=%d cy=%d cw=%d ch=%d : ",
+ tmp, cp, cx, cy, cw, ch);
+ imlib_text_get_location_at_index(str, cp, &cx2, &cy2,
+ &cw2, &ch2);
+ printf("cx2=%d cy2=%d cw2=%d ch2=%d \n",
+ cx2, cy2, cw2, ch2);
+ }
+ }
+ imlib_context_set_blend(1);
+ if ((px != x) || (py != y))
+ {
+ for (j = 0; j < 32; j++)
+ {
+ for (i = 0; i < 32; i++)
+ {
+ int ic, iw, ih, ww, hh;
+
+ ic = ((j * 32) + i) % 13;
+ imlib_context_set_image(im_ic[ic]);
+ iw = imlib_image_get_width();
+ ih = imlib_image_get_height();
+ 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_context_set_image(im);
+ imlib_blend_image_onto_image(im_ic[ic], 0,
+ 0, 0, iw, ih,
+ x + (i * iw * 2),
+ y + (j * ih * 2),
+ ww, hh);
+ }
+ }
+ }
/*
imlib_apply_filter( "tint(x=200,y=200,w=300,h=100,alpha=100,red=155,green=25,blue=25);"\
"tint(green=20,red=20,blue=20,alpha=200,x=30,y=30);" \
"tint(green=40,red=40,blue=240,alpha=60,x=50,y=150,h=200);" );
-*/
- imlib_blend_image_onto_image(im_sh1, 0, 0, 0, 50, 50, 0, 0, 50, 50);
- up = imlib_update_append_rect(up, 0, 0, 50, 50);
- imlib_blend_image_onto_image(im_sh2, 0, 0, 0, 50, 50, 50, 0, w - 50, 50);
- up = imlib_update_append_rect(up, 50, 0, w - 50, 50);
- imlib_blend_image_onto_image(im_sh3, 0, 0, 0, 50, 50, 0, 50, 50, h - 50);
- up = imlib_update_append_rect(up, 0, 50, 50, h - 50);
- up = imlib_updates_merge_for_rendering(up, w, h);
- imlib_context_set_blend(0);
- imlib_render_image_updates_on_drawable(up, 0, 0);
- if ((px != x) || (py != y))
+*/
+ imlib_blend_image_onto_image(im_sh1, 0, 0, 0, 50, 50, 0, 0, 50,
+ 50);
+ up = imlib_update_append_rect(up, 0, 0, 50, 50);
+ imlib_blend_image_onto_image(im_sh2, 0, 0, 0, 50, 50, 50, 0,
+ w - 50, 50);
+ up = imlib_update_append_rect(up, 50, 0, w - 50, 50);
+ imlib_blend_image_onto_image(im_sh3, 0, 0, 0, 50, 50, 0, 50, 50,
+ h - 50);
+ up = imlib_update_append_rect(up, 0, 50, 50, h - 50);
+ up = imlib_updates_merge_for_rendering(up, w, h);
+ imlib_context_set_blend(0);
+ imlib_render_image_updates_on_drawable(up, 0, 0);
+ 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, 0,
- ux, uy, uw, uh,
- ux, uy, uw, uh);
- u = imlib_updates_get_next(u);
- }
- }
- imlib_updates_free(up);
- up = NULL;
- imlib_context_set_image(im_sh1);imlib_free_image();
- imlib_context_set_image(im_sh1);imlib_free_image();
- imlib_context_set_image(im_sh1);imlib_free_image();
- imlib_context_set_image(im_ic[0]);imlib_free_image();
- imlib_context_set_image(im_ic[1]);imlib_free_image();
- imlib_context_set_image(im_ic[2]);imlib_free_image();
- imlib_context_set_image(im_ic[3]);imlib_free_image();
-
- }
+ 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, 0,
+ ux, uy, uw, uh,
+ ux, uy, uw, uh);
+ u = imlib_updates_get_next(u);
+ }
+ }
+ imlib_updates_free(up);
+ up = NULL;
+ imlib_context_set_image(im_sh1);
+ imlib_free_image();
+ imlib_context_set_image(im_sh1);
+ imlib_free_image();
+ imlib_context_set_image(im_sh1);
+ imlib_free_image();
+ imlib_context_set_image(im_ic[0]);
+ imlib_free_image();
+ imlib_context_set_image(im_ic[1]);
+ imlib_free_image();
+ imlib_context_set_image(im_ic[2]);
+ imlib_free_image();
+ imlib_context_set_image(im_ic[3]);
+ imlib_free_image();
+
+ }
}
else
{
- printf("blast test\n");
- pixels = 0;
- imlib_context_set_color_modifier(colormod);
- for (i = 0; i < w; i++)
- {
- imlib_render_image_on_drawable_at_size(0, 0, w, h);
- pixels += w * h;
- }
+ printf("blast test\n");
+ pixels = 0;
+ imlib_context_set_color_modifier(colormod);
+ for (i = 0; i < w; i++)
+ {
+ imlib_render_image_on_drawable_at_size(0, 0, w, h);
+ pixels += w * h;
+ }
}
-
+
/**
* Determine horse power of your video card driver
*/
- 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 */
+ 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");
- {
- double t1, t2;
-
- t1 = (double)sec1 + ((double)usec1 / 1000000);
- t2 = (double)sec2 + ((double)usec2 / 1000000);
- sec = t2 - t1;
- }
- printf("%3.3f sec, %3.3f M pixels (%i)\n", sec, (double)pixels / 1000000, pixels);
+ {
+ double t1, t2;
+
+ t1 = (double)sec1 + ((double)usec1 / 1000000);
+ t2 = (double)sec2 + ((double)usec2 / 1000000);
+ sec = t2 - t1;
+ }
+ printf("%3.3f sec, %3.3f M pixels (%i)\n", sec, (double)pixels / 1000000,
+ pixels);
printf("%3.3f Mpixels / sec\n", (double)(pixels) / (sec * 1000000));
return 0;
}
diff --git a/test/polytest.c b/test/polytest.c
index 2cbcf36..c7d5d72 100644
--- a/test/polytest.c
+++ b/test/polytest.c
@@ -12,21 +12,21 @@
#include "Imlib2.h"
-Display *disp;
-Window win;
-Visual *vis;
-Colormap cm;
-int depth;
+Display *disp;
+Window win;
+Visual *vis;
+Colormap cm;
+int depth;
int
main(int argc, char **argv)
{
- int w, h;
- Imlib_Image im_bg = NULL;
- XEvent ev;
- KeySym keysym;
- static char kbuf[20];
- ImlibPolygon poly, poly1, poly2;
+ int w, h;
+ Imlib_Image im_bg = NULL;
+ XEvent ev;
+ KeySym keysym;
+ static char kbuf[20];
+ ImlibPolygon poly, poly1, poly2;
/**
* First tests to determine which rendering task to perform
@@ -36,8 +36,8 @@ main(int argc, char **argv)
depth = DefaultDepth(disp, DefaultScreen(disp));
cm = DefaultColormap(disp, DefaultScreen(disp));
win =
- XCreateSimpleWindow(disp, DefaultRootWindow(disp), 0, 0, 100, 100, 0, 0,
- 0);
+ XCreateSimpleWindow(disp, DefaultRootWindow(disp), 0, 0, 100, 100, 0, 0,
+ 0);
XSelectInput(disp, win,
ButtonPressMask | ButtonReleaseMask | ButtonMotionMask |
PointerMotionMask | ExposureMask | KeyPressMask);
@@ -80,47 +80,47 @@ main(int argc, char **argv)
imlib_polygon_add_point(poly2, 270, 70);
while (1)
- {
- do
- {
- XNextEvent(disp, &ev);
- switch (ev.type)
- {
- case ButtonRelease:
- exit(0);
- break;
- case KeyPress:
- XLookupString(&ev.xkey, (char *) kbuf, sizeof(kbuf), &keysym,
- NULL);
- switch (*kbuf)
- {
- case ' ':
- imlib_context_set_anti_alias(!imlib_context_get_anti_alias
- ());
- printf("AA is %s\n",
- imlib_context_get_anti_alias()? "on" : "off");
- break;
- case 'q':
- exit(0);
- default:
- break;
- }
- break;
- default:
- break;
+ {
+ do
+ {
+ XNextEvent(disp, &ev);
+ switch (ev.type)
+ {
+ case ButtonRelease:
+ exit(0);
+ break;
+ case KeyPress:
+ XLookupString(&ev.xkey, (char *)kbuf, sizeof(kbuf), &keysym,
+ NULL);
+ switch (*kbuf)
+ {
+ case ' ':
+ imlib_context_set_anti_alias
+ (!imlib_context_get_anti_alias());
+ printf("AA is %s\n",
+ imlib_context_get_anti_alias()? "on" : "off");
+ break;
+ case 'q':
+ exit(0);
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
- }
- }
- while (XPending(disp));
+ }
+ }
+ while (XPending(disp));
- imlib_context_set_image(im_bg);
- imlib_context_set_color(0, 0, 0, 255);
- imlib_image_fill_rectangle(0, 0, w, h);
- imlib_context_set_color(255, 255, 255, 255);
- imlib_image_fill_polygon(poly);
- imlib_image_fill_polygon(poly1);
- imlib_image_fill_polygon(poly2);
- imlib_render_image_on_drawable(0, 0);
- }
+ imlib_context_set_image(im_bg);
+ imlib_context_set_color(0, 0, 0, 255);
+ imlib_image_fill_rectangle(0, 0, w, h);
+ imlib_context_set_color(255, 255, 255, 255);
+ imlib_image_fill_polygon(poly);
+ imlib_image_fill_polygon(poly1);
+ imlib_image_fill_polygon(poly2);
+ imlib_render_image_on_drawable(0, 0);
+ }
return 0;
}