summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2004-11-01 09:34:29 +0000
committerCarsten Haitzler <raster@rasterman.com>2004-11-01 09:34:29 +0000
commit31660022d05efa77cd606e4ebf8d2e43bc492027 (patch)
tree21b0a6ff5f28ad5f27a8c3e7af206b779910075f
parent4c824dfe923d00b9900a00f5098366d749e9deb8 (diff)
downloadimlib2-31660022d05efa77cd606e4ebf8d2e43bc492027.tar.gz
remooov!
SVN revision: 12112
-rw-r--r--.cvsignore34
-rw-r--r--AUTHORS30
-rw-r--r--COPYING20
-rw-r--r--ChangeLog3007
-rw-r--r--Doxyfile139
-rw-r--r--Makefile.am46
-rw-r--r--README41
-rw-r--r--TODO6
-rwxr-xr-xautogen.sh13
-rw-r--r--configure.in435
-rw-r--r--debian/.cvsignore11
-rw-r--r--debian/Makefile.am9
-rw-r--r--debian/changelog5
-rw-r--r--debian/control44
-rw-r--r--debian/copyright32
-rw-r--r--debian/imlib2-config.117
-rw-r--r--debian/imlib2-demo.install2
-rw-r--r--debian/imlib2-test.install5
-rw-r--r--debian/libimlib2-dev.doc-base10
-rw-r--r--debian/libimlib2-dev.install10
-rw-r--r--debian/libimlib2.install3
-rw-r--r--debian/rules88
-rw-r--r--demo/.cvsignore26
-rw-r--r--demo/Makefile.am28
-rw-r--r--demo/imconvert.c91
-rw-r--r--demo/view.c345
-rw-r--r--doc/.cvsignore2
-rw-r--r--doc/Makefile.am3
-rw-r--r--doc/blank.gifbin266 -> 0 bytes
-rw-r--r--doc/foot.html2
-rw-r--r--doc/head.html19
-rw-r--r--doc/img/hilite.pngbin6127 -> 0 bytes
-rw-r--r--doc/img/imlib2.pngbin6433 -> 0 bytes
-rw-r--r--doc/img/imlib2_mini.pngbin753 -> 0 bytes
-rw-r--r--doc/imlib2.css178
-rw-r--r--doc/imlib2.gifbin6794 -> 0 bytes
-rw-r--r--doc/index.html2268
-rw-r--r--filters/.cvsignore21
-rw-r--r--filters/Makefile.am27
-rw-r--r--filters/filter_bumpmap.c292
-rw-r--r--filters/filter_colormod.c269
-rw-r--r--filters/filter_test.c115
-rwxr-xr-xgendoc17
-rw-r--r--imlib2-config.in59
-rw-r--r--imlib2.c.in547
-rw-r--r--imlib2.pc.in12
-rw-r--r--imlib2.spec184
-rw-r--r--loaders/.cvsignore22
-rw-r--r--loaders/Makefile.am90
-rw-r--r--loaders/loader_argb.c201
-rw-r--r--loaders/loader_bmp.c739
-rw-r--r--loaders/loader_bz2.c107
-rw-r--r--loaders/loader_gif.c247
-rw-r--r--loaders/loader_jpeg.c376
-rw-r--r--loaders/loader_lbm.c550
-rw-r--r--loaders/loader_png.c440
-rw-r--r--loaders/loader_pnm.c832
-rw-r--r--loaders/loader_tga.c584
-rw-r--r--loaders/loader_tiff.c494
-rw-r--r--loaders/loader_xpm.c691
-rw-r--r--loaders/loader_zlib.c124
-rw-r--r--m4/ac_expand_dir.m414
-rw-r--r--m4/ac_path_generic.m4136
-rw-r--r--src/.cvsignore23
-rw-r--r--src/Imlib2.h481
-rw-r--r--src/Makefile.am44
-rw-r--r--src/api.c5454
-rw-r--r--src/asm_blend.S1059
-rw-r--r--src/asm_blend_cmod.S1604
-rw-r--r--src/asm_rgba.S301
-rw-r--r--src/asm_rotate.S469
-rw-r--r--src/asm_scale.S809
-rw-r--r--src/blend.c1820
-rw-r--r--src/blend.h556
-rw-r--r--src/color.c569
-rw-r--r--src/color.h16
-rw-r--r--src/color_helpers.c235
-rw-r--r--src/color_helpers.h9
-rw-r--r--src/colormod.c254
-rw-r--r--src/colormod.h72
-rw-r--r--src/common.h42
-rw-r--r--src/context.c208
-rw-r--r--src/context.h32
-rw-r--r--src/draw.c88
-rw-r--r--src/draw.h10
-rw-r--r--src/dynamic_filters.c193
-rw-r--r--src/dynamic_filters.h43
-rw-r--r--src/ellipse.c737
-rw-r--r--src/file.c506
-rw-r--r--src/file.h20
-rw-r--r--src/filter.c241
-rw-r--r--src/filter.h42
-rw-r--r--src/font.h126
-rw-r--r--src/font_draw.c421
-rw-r--r--src/font_load.c431
-rw-r--r--src/font_main.c418
-rw-r--r--src/font_query.c313
-rw-r--r--src/format.c1
-rw-r--r--src/format.h3
-rw-r--r--src/grab.c725
-rw-r--r--src/grab.h13
-rw-r--r--src/grad.c614
-rw-r--r--src/grad.h28
-rw-r--r--src/image.c1352
-rw-r--r--src/image.h202
-rw-r--r--src/line.c711
-rw-r--r--src/loaderpath.h3
-rw-r--r--src/loaderpath.h.in2
-rw-r--r--src/polygon.c1733
-rw-r--r--src/rectangle.c192
-rw-r--r--src/rend.c594
-rw-r--r--src/rend.h25
-rw-r--r--src/rgba.c4966
-rw-r--r--src/rgba.h28
-rw-r--r--src/rgbadraw.c624
-rw-r--r--src/rgbadraw.h141
-rw-r--r--src/rotate.c542
-rw-r--r--src/rotate.h33
-rw-r--r--src/scale.c1534
-rw-r--r--src/scale.h22
-rw-r--r--src/script.c297
-rw-r--r--src/script.h64
-rw-r--r--src/span.c1160
-rw-r--r--src/span.h24
-rw-r--r--src/updates.c195
-rw-r--r--src/updates.h16
-rw-r--r--src/ximage.c326
-rw-r--r--src/ximage.h10
-rw-r--r--test/.cvsignore27
-rw-r--r--test/Makefile.am61
-rw-r--r--test/bmtest.c127
-rw-r--r--test/color_spaces.c142
-rw-r--r--test/imlib2_test.c273
-rw-r--r--test/main.c1377
-rw-r--r--test/polytest.c126
-rw-r--r--test/test_images/.cvsignore1
-rw-r--r--test/test_images/audio.pngbin4263 -> 0 bytes
-rw-r--r--test/test_images/bg.pngbin132721 -> 0 bytes
-rw-r--r--test/test_images/bulb.pngbin3504 -> 0 bytes
-rw-r--r--test/test_images/cal.pngbin2755 -> 0 bytes
-rw-r--r--test/test_images/calc.pngbin3949 -> 0 bytes
-rw-r--r--test/test_images/folder.pngbin2873 -> 0 bytes
-rw-r--r--test/test_images/globe.pngbin3388 -> 0 bytes
-rw-r--r--test/test_images/imlib2.pngbin53192 -> 0 bytes
-rw-r--r--test/test_images/lock.pngbin2770 -> 0 bytes
-rw-r--r--test/test_images/mail.pngbin3222 -> 0 bytes
-rw-r--r--test/test_images/menu.pngbin3240 -> 0 bytes
-rw-r--r--test/test_images/mush.pngbin3244 -> 0 bytes
-rw-r--r--test/test_images/paper.pngbin3410 -> 0 bytes
-rw-r--r--test/test_images/sh1.pngbin768 -> 0 bytes
-rw-r--r--test/test_images/sh2.pngbin280 -> 0 bytes
-rw-r--r--test/test_images/sh3.pngbin360 -> 0 bytes
-rw-r--r--test/test_images/stop.pngbin2684 -> 0 bytes
-rw-r--r--test/test_images/tnt.pngbin3010 -> 0 bytes
-rw-r--r--test/ttfonts/cinema.ttfbin11584 -> 0 bytes
-rw-r--r--test/ttfonts/grunge.ttfbin53189 -> 0 bytes
-rw-r--r--test/ttfonts/morpheus.ttfbin68023 -> 0 bytes
-rw-r--r--test/ttfonts/notepad.ttfbin31293 -> 0 bytes
158 files changed, 0 insertions, 50119 deletions
diff --git a/.cvsignore b/.cvsignore
deleted file mode 100644
index 6bbc1f5..0000000
--- a/.cvsignore
+++ /dev/null
@@ -1,34 +0,0 @@
-config.guess
-config.h.in
-config.sub
-ltconfig
-ltmain.sh
-aclocal.m4
-stamp-h.in
-Makefile.in
-configure
-config.log
-config.h
-config.cache
-libtool
-config.status
-stamp-h
-Makefile
-.deps
-.libs
-*.lo
-*.la
-imlib2
-loaderpath.h
-*.tar.gz
-.icons
-imlib2-config
-dox
-install-sh
-missing
-mkinstalldirs
-build-stamp
-configure-stamp
-stamp-h1
-autom4te.cache
-*.pc
diff --git a/AUTHORS b/AUTHORS
deleted file mode 100644
index 06ce4f0..0000000
--- a/AUTHORS
+++ /dev/null
@@ -1,30 +0,0 @@
-The Rasterman (Carsten Haitzler) <raster@rasterman.com> <raster@valinux.com>
-Ryan Gustafson <ryan_gustafson@yahoo.com>
-Mandrake (Geoff Harrison) <mandrake@mandrake.net>
-Willem Monsuwe <willem@stack.nl>
-KainX (Michael Jennings) <mej@eterm.org>
-Eric Dorland <dorland@lords.com>
-Chutt (Isaac Richards) <ijr@po.cwru.edu>
-giblet (Tom Gilbert) <tom@linuxbrit.co.uk>
-Takis <takis@lumumba.luc.ac.be>
-Dan Maas <dmaas@dcine.com>
-Platon Fomichev <pla@cland.ru>
-boris (Chris Ross) <chris@darkrock.co.uk>
-Martin Grimm <grimm.martin@gmx.de>
-Matt McClanahan <cardinal@dodds.net>
-Steve Langasek <vorlon@dodds.net>
-Christophe Tronche <ch.tronche@computer.org>
-Nathan Ingersoll <ningerso@d.umn.edu>
-Masa(Masahiko) Mori <masa@engr.sgi.com>
-Term (Lyle Kempler) <term@twistedpath.org>
-Adam Kisiel <kisiel@if.pw.edu.pl>
-Carsten Pfeiffer <carpdjih@sp.zrz.tu-berlin.de>
-Lightman (Franz Marini) <marini@pcmenelao.mi.infn.it>
-Mark Bainter <mark-e@cymry.org>
-Brian Lindholm <brian_lindholm@users.sourceforge.net>
-Renchi Raju <renchi@pooh.tam.uiuc.edu>
-Yuri Hudobin <glassy_ape@users.sourceforge.net>
-Radoslaw Grzanka <radekg2@poczta.onet.pl>
-Kim Woelders <kim@woelders.dk>
-Nick Blievers <nickb@sgi.com>
-Mike Castle <dalgoda@ix.netcom.com>
diff --git a/COPYING b/COPYING
deleted file mode 100644
index 0b959c1..0000000
--- a/COPYING
+++ /dev/null
@@ -1,20 +0,0 @@
-Copyright (C) 1999 Carsten Haitzler and various contributors
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to
-deal in the Software without restriction, including without limitation the
-rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-sell copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies of the Software, its documentation and marketing & publicity
-materials, and acknowledgment shall be given in the documentation, materials
-and software packages that this Software was used.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
-IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/ChangeLog b/ChangeLog
deleted file mode 100644
index b5c1a59..0000000
--- a/ChangeLog
+++ /dev/null
@@ -1,3007 +0,0 @@
-
-
-Changes by: raster 99/08/01 15:14:14
-
-Log message:
- adding imlib2 code in.. NOT a lib yet... :) but playable code and loader
- system
-
- Status:
-
- Vendor Tag: imlib2
- Release Tags: A
-
- N imlib2/loader_png.c
- N imlib2/Makefile
- N imlib2/README
- N imlib2/blend.c
- N imlib2/blend.h
- N imlib2/color.c
- N imlib2/color.h
- N imlib2/common.h
- N imlib2/file.c
- N imlib2/file.h
- N imlib2/grab.c
- N imlib2/grab.h
- N imlib2/image.c
- N imlib2/image.h
- N imlib2/main.c
- N imlib2/rend.c
- N imlib2/rend.h
- N imlib2/rgba.c
- N imlib2/rgba.h
- N imlib2/scale.c
- N imlib2/scale.h
- N imlib2/ximage.c
- N imlib2/ximage.h
- N imlib2/test_images/im_rgb.png
- N imlib2/test_images/im.png
-
- No conflicts created by this import
-
-_______________________________________________
-
-Changes by: raster 99/08/02 15:50:36
-
-Modified files:
- . : loader_png.c
-Added files:
- . : COPYING
-
-Log message:
-fixed minor bug in png loader.... added copying file :)
-
-_______________________________________________
-
-Changes by: raster 99/08/02 22:15:35
-
-Modified files:
- . : image.c image.h loader_png.c main.c
-
-Log message:
-updated loader api to include progress callback stuff.... :)
-
-_______________________________________________
-
-Changes by: raster 99/09/01 10:36:17
-
-Modified files:
- . : api.c api.h context.c image.c image.h main.c
-
-Log message:
-remember to not free images made form external data if it wasnt copied.. and
-free colors from color cubes once the context is invalid.. :)
-
-_______________________________________________
-
-Changes by: raster 99/09/08 10:27:41
-
-Modified files:
- . : api.c api.h blend.c blend.h draw.c grab.c
- grab.h loader_png.c main.c rend.c rend.h rgba.c
-
-Log message:
-lots more work on mr imlib2 :)
-
-_______________________________________________
-
-Changes by: raster 99/09/08 11:15:04
-
-Modified files:
- . : api.c main.c
-
-Log message:
-and more updates :) wheeeeeeeee
-
-_______________________________________________
-
-Changes by: raster 99/09/08 19:39:19
-
-Modified files:
- . : Makefile api.c
- libltdl : Makefile.am Makefile.in acinclude.m4 aclocal.m4
- config.h.in configure configure.in ltdl.c
- ltdl.h
-
-Log message:
-more work on imlib2.. :)
-
-_______________________________________________
-
-Changes by: raster 99/09/09 19:33:12
-
-Modified files:
- . : api.c blend.c blend.h loader_png.c main.c
- rend.c
-
-Log message:
-ooh is imlib2 ever workign fast now baybeee.. blending one image onto
-another .. with clipping, scaling, anti-aliasing and more.. need to add
-a bit to the api, and move the stuff nowin api.c off into imlib backend
-sinc ethat stuff doesnt belong in api.c
-
-_______________________________________________
-
-Changes by: raster 99/09/10 11:11:47
-
-Modified files:
- . : Makefile Makefile.am api.c api.h main.c
-Added files:
- . : loader_jpeg.c
-
-Log message:
-jpeg loader added that does everything RIGHT - needto mapk the png loader
-do the same. :)
-
-_______________________________________________
-
-Changes by: raster 99/09/10 19:04:10
-
-Modified files:
- . : api.c loader_png.c main.c
-
-Log message:
-and now the png loader does full progress callbacks and multi-phase loading
-correctly... WHEEEEEEEEEEe :)
-
-_______________________________________________
-
-Changes by: raster 99/09/12 18:56:57
-
-Modified files:
- . : Makefile README api.c api.h blend.c blend.h
- image.c loader_png.c main.c
- libltdl : Makefile.am Makefile.in acinclude.m4 aclocal.m4
- config.h.in configure configure.in ltdl.c
- ltdl.h
-Added files:
- test_images : audio.png bg.png folder.png mush.png paper.png
- sh1.png sh2.png sh3.png
-
-Log message:
-ooh now imlib2 has a sexy demo for you people :) mmmmm watch the alpha
-blending... mmmmmmmmm
-
-_______________________________________________
-
-Changes by: raster 99/09/12 21:06:58
-
-Modified files:
- . : color.c context.c main.c rgba.c
-
-Log message:
-more playing with imlib2... :)
-
-_______________________________________________
-
-Changes by: raster 99/09/12 22:32:36
-
-Modified files:
- . : main.c
-Added files:
- test_images : bulb.png cal.png calc.png globe.png lock.png
- mail.png menu.png stop.png tnt.png
-
-Log message:
-add some more images just to show off :)
-
-_______________________________________________
-
-Changes by: raster 99/09/12 22:34:51
-
-Modified files:
- . : context.c
-
-Log message:
-get rid of printfs i dont need no more :)
-
-_______________________________________________
-
-Changes by: raster 99/09/13 21:21:29
-
-Modified files:
- . : Makefile api.c api.h blend.c blend.h draw.c
- main.c rend.c rend.h
- libltdl : Makefile.am Makefile.in acinclude.m4 aclocal.m4
- config.h.in configure configure.in ltdl.c
- ltdl.h
-
-Log message:
-add operation type to blend ops.. :)
-
-_______________________________________________
-
-Changes by: mej 99/09/14 17:16:44
-
-Modified files:
- . : autogen.sh
-
-Log message:
-*sigh*
-
-This should fix those weird autogen.sh problems. Apparently
-automake --copy thinks it fails even though it really doesn't.
-
-_______________________________________________
-
-Changes by: raster 99/09/14 18:15:55
-
-Modified files:
- . : blend.c main.c
-
-Log message:
-oooh more blending and operation code :)
-
-_______________________________________________
-
-Changes by: raster 99/09/14 18:23:00
-
-Modified files:
- . : autogen.sh
-
-Log message:
-better autogen.sh comments to help you build imlib2
-
-_______________________________________________
-
-Changes by: raster 99/09/14 18:24:28
-
-Modified files:
- . : autogen.sh
-
-Log message:
-some mroe echos...
-
-_______________________________________________
-
-Changes by: raster 99/09/16 18:31:57
-
-Modified files:
- . : Makefile Makefile.am api.c api.h blend.c rend.c
-Added files:
- . : updates.c updates.h
-
-Log message:
-added updates work.. well starting on it.. :)
-
-_______________________________________________
-
-Changes by: raster 99/09/16 18:47:49
-
-Modified files:
- . : updates.c
-
-Log message:
-more wokr on updates
-
-_______________________________________________
-
-Changes by: raster 99/09/18 00:50:37
-
-Modified files:
- . : Makefile Makefile.am api.c api.h image.c main.c
- rgbadraw.c rgbadraw.h updates.c
-
-Log message:
-lots of new image manipulation functions and minor fix in loader module code.
-
-_______________________________________________
-
-Changes by: raster 99/09/18 09:40:24
-
-Added files:
- . : colormod.c colormod.h config.h loaderpath.h
-
-Log message:
-add some files
-
-_______________________________________________
-
-Changes by: raster 99/09/18 09:41:59
-
-Removed files:
- . : config.h loaderpath.h
-
-Log message:
-rewmove files i didnt mean tot add
-
-_______________________________________________
-
-Changes by: raster 99/09/18 23:28:54
-
-Modified files:
- . : Makefile api.c api.h blend.c blend.h file.c
- image.c image.h loader_jpeg.c loader_png.c
- main.c rend.c rgbadraw.c scale.c
- libltdl : Makefile.am Makefile.in acinclude.m4 aclocal.m4
- config.h.in configure configure.in ltdl.c
- ltdl.h
-
-Log message:
-cleaned up code a bit... :) minor speedup for sparse (lost of transparent
-bits in images) for alpha blending :)
-
-_______________________________________________
-
-Changes by: raster 99/09/19 11:33:15
-
-Modified files:
- . : rgba.c
-
-Log message:
-get rid of extra space
-
-_______________________________________________
-
-Changes by: raster 99/09/19 13:05:23
-
-Modified files:
- . : api.c api.h color.c color.h main.c
-
-Log message:
-ok- fix depth retireval code :)
-
-_______________________________________________
-
-Changes by: raster 99/09/19 14:00:17
-
-Modified files:
- . : loader_png.c
-
-Log message:
-try make png laoder work on big endian... :)
-
-_______________________________________________
-
-Changes by: raster 99/09/19 14:18:15
-
-Modified files:
- . : loader_png.c
-
-Log message:
-and one mroe fix for big endian boxes for imlib png loader
-
-_______________________________________________
-
-Changes by: raster 99/09/19 14:22:21
-
-Modified files:
- . : loader_png.c
-
-Log message:
-and add soem comments
-
-_______________________________________________
-
-Changes by: raster 99/09/19 14:43:59
-
-Modified files:
- . : rend.c
-
-Log message:
-fix 15/16bpp depth problems
-
-_______________________________________________
-
-Changes by: raster 99/09/19 14:53:59
-
-Modified files:
- . : configure.in loader_png.c rgba.c
-
-Log message:
-let autoconf figure out our endianess
-
-_______________________________________________
-
-Changes by: raster 99/09/19 14:56:55
-
-Modified files:
- . : Makefile Makefile.am
-
-Log message:
-make install isnot system loader dirs
-
-_______________________________________________
-
-Changes by: raster 99/09/19 14:57:37
-
-Modified files:
- . : autogen.sh
-
-Log message:
-update autogen.sh
-
-_______________________________________________
-
-Changes by: raster 99/09/19 15:05:59
-
-Modified files:
- . : main.c
-
-Log message:
-fix main.c
-
-_______________________________________________
-
-Changes by: raster 99/09/26 14:36:51
-
-Modified files:
- . : api.c api.h color.c color.h common.h main.c
- rend.c rgbadraw.c updates.c
-
-Log message:
-make imlib2 demo event based - test rect combining code in handling exposures
-and stuff - works it seesm - need to expand api though... expose handlign works
-fine as does rect mergeing and stuff.. must more efficient updating method now
-for demo.. template for stuff to be used by apps later :)
-
-_______________________________________________
-
-Changes by: raster 99/09/26 21:33:58
-
-Modified files:
- . : Makefile.am api.c api.h
-Added files:
- . : font.c font.h format.c format.h
-
-Log message:
-add some files...
-
-_______________________________________________
-
-Changes by: raster 99/09/26 22:24:42
-
-Modified files:
- . : Makefile font.c font.h
-
-Log message:
-more font stuff
-
-_______________________________________________
-
-Changes by: raster 99/09/27 08:16:52
-
-Modified files:
- . : Makefile Makefile.am font.c font.h
-
-Log message:
-more code for font stugff being added.. more to come...
-
-_______________________________________________
-
-Changes by: raster 99/09/27 08:19:11
-
-Removed files:
- . : Makefile
-
-Log message:
-why did i have a Makefile in cvs ?
-
-_______________________________________________
-
-Changes by: raster 99/09/27 15:47:45
-
-imlib2/ttfonts
-
-Update of /cvs/enlightenment/imlib2/ttfonts
-In directory ford:/tmp/cvs-serv11657/ttfonts
-
-Log Message:
-Directory /cvs/enlightenment/imlib2/ttfonts added to the repository
-
-_______________________________________________
-
-Changes by: raster 99/09/27 15:52:03
-
-Modified files:
- . : api.h font.c main.c ximage.c
-Added files:
- ttfonts : Gadzoox.ttf Glypic.ttf Lemonfnt.ttf
- Tejartchi.ttf Terminator.ttf Virginlo.ttf
- adlib.ttf andes.ttf angular.ttf anklepants.ttf
- arabian.ttf arnprior.ttf asimov.ttf
- aurabesh.ttf autobot.ttf axaxax.ttf axaxaxl.ttf
- badfilms.ttf balconyangels.ttf baltar.ttf
- baltar01.ttf bastarda.ttf battlest.ttf
- battlestar.ttf beebop.ttf beebopp.ttf
- bellbottomlaser.ttf berliner.ttf bevel.ttf
- bigfish.ttf bitchin.ttf blackadderii.ttf
- blackforest.ttf bloodofdracula.ttf bloody.ttf
- blueregular.ttf bookworm.ttf branson.ttf
- burnout.ttf busorama.ttf
- butterflychromosome.ttf calligrapher.ttf
- cardas1.ttf carrdin2.ttf carrding.ttf
- carrelec.ttf carrkeys.ttf casloninitials.ttf
- celticmd.ttf checkbk.ttf chemicalgus.ttf
- choc.ttf chromosomelight.ttf cinema.ttf
- cld_____.ttf comics.ttf competitor.ttf
- computerfont.ttf crackbabies.ttf crackman.ttf
- crapola.ttf crysta.ttf crystalradiokit.ttf
- ctype.ttf cupertino.ttf dazzleships.ttf
- decaying.ttf deceptgr.ttf demonnight.ttf
- diamondgothic.ttf dienasty.ttf
- dirtybakersdozen.ttf dogsonmars.ttf dolphin.ttf
- down.ttf dragonwick.ttf duedate.ttf
- dustmites.ttf dutchtreat.ttf eccentrical.ttf
- elbjorgscript.ttf electrichermes.ttf enya.ttf
- erasure.ttf fleur_tt.ttf flouridebeings.ttf
- flytningar.ttf frowf___.ttf gaeil1.ttf
- galab___.ttf galactic.ttf gardenparty.ttf
- gathora.ttf glazkrak.ttf glypic.ttf goethe.ttf
- goldengirdle.ttf goofball.ttf grease.ttf
- grunge.ttf hackers.ttf handwriting.ttf
- headhunter.ttf heavyheap.ttf hirosh.ttf
- hman.ttf hman2.ttf holstein.ttf huskystash.ttf
- hydrogenwhiskey.ttf id4.ttf igloo.ttf
- inavelkusin.ttf inavelmutant.ttf
- incantation.ttf induction2.ttf instanttunes.ttf
- invisiblekiller.ttf joycircuit.ttf joystix.ttf
- karloff.ttf kewken.ttf khaf____.ttf
- khan____.ttf khb_____.ttf khf_____.ttf
- khl_____.ttf kho_____.ttf kiloton.ttf
- kingarthur.ttf kissmekissmekissme.ttf
- klingonblade.ttf klingonscript.ttf kontrast.ttf
- kurtrussell.ttf lansbury.ttf lavalava.ttf
- lemonfnt.ttf lochen.ttf lockergn.ttf
- lockergnome.ttf logger.ttf lombardic.ttf
- lombnarr.ttf lowereastside.ttf
- lowerwestside.ttf lunauror.ttf lunaurora.ttf
- lynx.ttf machuman.ttf magdelena.ttf
- marqueem.ttf massiveretaliation.ttf mechoba.ttf
- metallord.ttf mickey.ttf minya.ttf monst___.ttf
- monstro.ttf morpheus.ttf nasalization.ttf
- neon2.ttf newworldvibes.ttf nightcourt.ttf
- nine____.ttf nosferatu.ttf notepad.ttf
- notepad_.ttf oldgermen.ttf oliver.ttf
- oliviabrush.ttf ollon.ttf omnibus.ttf
- parkavenue.ttf pastorofmuppets.ttf
- planetbenson.ttf plasticbag.ttf
- pleasantlyplump.ttf plump.ttf popticsone.ttf
- popticsoneextras.ttf popticsthree.ttf
- popticsthreeextras.ttf popticstwo.ttf
- popticstwoextras.ttf pormask2039.ttf prick.ttf
- prima.ttf puppf___.ttf purptete.ttf
- quadrangle.ttf quake.ttf radiostars.ttf
- ransom.ttf rattpick.ttf rebucked.ttf
- refluxed.ttf reticulan.ttf reverb.ttf roar.ttf
- robokoz.ttf romeo.ttf rotondosilver.ttf
- rylodian.ttf saf.ttf sand____.ttf schizm.ttf
- scritz.ttf seawfa__.ttf sham.ttf shlop.ttf
- singothic.ttf slumberp.ttf snidely.ttf
- solsticeofsuffering.ttf spillm~1.ttf
- spirits.ttf spongy.ttf spund.ttf squealer.ttf
- squire.ttf stonehenge.ttf stop.ttf
- superglue.ttf superheterodyne.ttf
- taxidermist.ttf thalia.ttf thickhead.ttf
- tofu8.ttf tomhand.ttf toontime.ttf topbond.ttf
- tosscasu.ttf touchofnature.ttf transylvania.ttf
- trash.ttf tron.ttf turkeys.ttf ventilate.ttf
- village.ttf virginlo.ttf wacko.ttf warlock.ttf
- whitebld.ttf xenowort.ttf xoltoa.ttf yadou.ttf
- yoinks.ttf zerohour.ttf
- zodillinstrisstirust.ttf
-
-Log message:
-add some test truetype fonts - just for testing... and truetype font
-rendering code... :)
-
-_______________________________________________
-
-Changes by: raster 99/09/27 15:52:56
-
-Removed files:
- ttfonts : zodillinstrisstirust.ttf
-
-Log message:
-bad bad font.......
-
-_______________________________________________
-
-Changes by: raster 99/09/27 15:55:56
-
-Modified files:
- . : main.c
-Removed files:
- ttfonts : instanttunes.ttf
-
-Log message:
-actualyl chekc if the font laod works and remove another bad font
-
-_______________________________________________
-
-Changes by: raster 99/09/27 16:09:07
-
-Removed files:
- ttfonts : Tejartchi.ttf beebop.ttf beebopp.ttf bevel.ttf
- blackadderii.ttf carrelec.ttf computerfont.ttf
- crysta.ttf galab___.ttf handwriting.ttf
- lynx.ttf omnibus.ttf popticsthree.ttf
- popticsthreeextras.ttf transylvania.ttf
-
-Log message:
-get rid of soem useless fonts...
-
-_______________________________________________
-
-Changes by: raster 99/09/27 16:09:55
-
-Removed files:
- ttfonts : cld_____.ttf fleur_tt.ttf frowf___.ttf
- khaf____.ttf khan____.ttf khb_____.ttf
- khf_____.ttf khl_____.ttf kho_____.ttf
- monst___.ttf nine____.ttf notepad_.ttf
- puppf___.ttf sand____.ttf seawfa__.ttf
-
-Log message:
-get rid of silyl fonts with silyl names... i hate those names... :)
-
-_______________________________________________
-
-Changes by: raster 99/09/27 16:12:12
-
-Removed files:
- ttfonts : hman2.ttf
-
-Log message:
-this font segfaults freetype.. ooh nice freetype :)
-
-_______________________________________________
-
-Changes by: raster 99/09/27 16:17:22
-
-Removed files:
- ttfonts : calligrapher.ttf inavelmutant.ttf
- nasalization.ttf
-
-Log message:
-nuke some more unusable fonts :)
-
-_______________________________________________
-
-Changes by: raster 99/09/27 17:03:20
-
-Removed files:
- ttfonts : bastarda.ttf
-
-Log message:
-another useless font
-
-_______________________________________________
-
-Changes by: raster 99/09/27 17:33:23
-
-Removed files:
- ttfonts : Terminator.ttf carrdin2.ttf carrding.ttf
- carrkeys.ttf gaeil1.ttf goldengirdle.ttf
- klingonblade.ttf kontrast.ttf lockergn.ttf
- planetbenson.ttf popticstwo.ttf pormask2039.ttf
- quake.ttf refluxed.ttf reverb.ttf roar.ttf
- saf.ttf stop.ttf
-
-Log message:
-remove some more useless fonts
-
-_______________________________________________
-
-Changes by: raster 99/09/27 17:36:41
-
-Modified files:
- . : font.c main.c
-
-Log message:
-some fixes to font code... :)
-
-_______________________________________________
-
-Changes by: raster 99/09/27 19:13:50
-
-Modified files:
- . : font.c font.h main.c
-
-Log message:
-fix raster map over-allocation problem for fonts.. :)
-
-_______________________________________________
-
-Changes by: raster 99/09/27 19:22:57
-
-Modified files:
- . : font.c font.h
-
-Log message:
-add prototypes and cleanup unused vars
-
-_______________________________________________
-
-Changes by: raster 99/09/27 23:59:55
-
-Modified files:
- . : font.c
-
-Log message:
-you mightnt guess it - but rotated text all works now.. :)
-
-_______________________________________________
-
-Changes by: raster 99/09/28 11:51:08
-
-Modified files:
- . : api.c api.h font.c updates.c updates.h
-
-Log message:
-fix ups some toehr stuff...
-
-_______________________________________________
-
-Changes by: raster 99/09/28 16:08:40
-
-Modified files:
- . : font.c main.c
-
-Log message:
-some fixes to get the output nextx and nexty right... :)
-
-_______________________________________________
-
-Changes by: raster 99/09/28 16:48:39
-
-Modified files:
- . : api.c api.h font.c font.h main.c
-
-Log message:
-add some of the font api to the api :)
-
-_______________________________________________
-
-Changes by: raster 99/09/29 10:25:52
-
-Modified files:
- . : api.c api.h font.c font.h main.c
-
-Log message:
-add speculative fotn cache ability - just like we have for images and pixmaps
-and ximages.
-
-_______________________________________________
-
-Changes by: raster 99/09/29 11:10:14
-
-Modified files:
- . : api.c api.h font.c font.h
-
-Log message:
-add actual api.h calls to the font caching stuff...
-
-_______________________________________________
-
-Changes by: raster 99/09/30 09:46:04
-
-Modified files:
- . : main.c rgbadraw.c
-
-Log message:
-we have... anti-aliased line drawing code now... :) (and funnily enough -
-UNLIKE gimp it actually CAN draw a straight line for shit with anti-aliasing)
-
-_______________________________________________
-
-Changes by: raster 99/10/21 10:07:21
-
-Modified files:
- . : api.c api.h blend.c blend.h colormod.c
- colormod.h common.h draw.c font.c font.h grab.c
- image.c image.h rend.c rgbadraw.c ximage.c
- libltdl : Makefile.am Makefile.in acinclude.m4 aclocal.m4
- config.h.in configure configure.in ltdl.c
- ltdl.h
-
-Log message:
-color modifiers in imlib2 now done.. cleaned up soem code...
-
-_______________________________________________
-
-Changes by: mandrake 99/10/22 04:19:11
-
-Modified files:
- . : api.h file.h font.c grab.c loader_jpeg.c
- loader_png.c main.c rgbadraw.c rgbadraw.h
- libltdl : Makefile.am Makefile.in acinclude.m4 aclocal.m4
- config.h.in configure configure.in ltdl.c
- ltdl.h
-Added files:
- . : ChangeLog
-
-Log message:
-Fri Oct 22 10:53:26 PDT 1999
-(Mandrake)
-
-removed almost all the warnings.
-except for:
-main.c:287: warning: implicit declaration of function `__imlib_draw_line'
-which I believe is because it's not using the appropriate API call yet.
-
-_______________________________________________
-
-Changes by: raster 99/10/22 04:40:45
-
-Modified files:
- . : api.h
-
-Log message:
-again........ :)
-
-_______________________________________________
-
-Changes by: raster 99/10/25 09:36:24
-
-Modified files:
- . : Makefile.am api.c api.h image.h main.c
- rgbadraw.c rgbadraw.h
- libltdl : ltdl.c
-
-Log message:
-work work work...
-
-_______________________________________________
-
-Changes by: raster 99/10/25 16:30:01
-
-Modified files:
- . : draw.c image.c
-
-Log message:
-more flim
-
-_______________________________________________
-
-Changes by: raster 99/10/25 16:30:46
-
-Modified files:
- . : api.c api.h image.h
-
-Log message:
-more flim code..... >8)
-
-_______________________________________________
-
-Changes by: raster 99/10/27 06:48:39
-
-Modified files:
- . : rgba.c
-
-Log message:
-memcpy :)
-
-_______________________________________________
-
-Changes by: raster 99/10/27 07:08:32
-
-Modified files:
- . : api.c api.h main.c
-Added files:
- . : grad.c grad.h
-
-Log message:
-nice FAST gradient drawing code.... :) eat my dast... MUHAHAHAHAHHA! :)
-
-_______________________________________________
-
-Changes by: raster 99/10/27 07:20:27
-
-Modified files:
- . : api.c api.h
-
-Log message:
-pixel query call.... need this one
-
-_______________________________________________
-
-Changes by: raster 99/10/27 10:44:15
-
-Modified files:
- . : api.c main.c
-
-Log message:
-and the flim goes on..........
-
-_______________________________________________
-
-Changes by: raster 99/10/28 03:40:02
-
-Modified files:
- . : color.c
-
-Log message:
-dont chose visuals > 24bit :)
-
-_______________________________________________
-
-Changes by: mandrake 99/10/28 06:09:03
-
-Added files:
- libltdl : .cvsignore
-Removed files:
- libltdl : configure
-
-Log message:
-trying to "fix" imlib2's cvs tree
-
-_______________________________________________
-
-Changes by: mandrake 99/10/28 06:11:27
-
-Added files:
- . : .cvsignore
-
-Log message:
-more "hush yo mouf cvs" changes
-
-_______________________________________________
-
-Changes by: raster 99/10/28 08:26:19
-
-Modified files:
- . : api.c api.h blend.c grab.c
-
-Log message:
-LOTS of checkign in the api now to make sure the calling program can't stuff
-things up too badly...
-
-_______________________________________________
-
-Changes by: raster 99/10/28 10:43:42
-
-Removed files:
- test_images : im.png im_rgb.png
-
-Log message:
-get rid of images i'm nto using...
-
-_______________________________________________
-
-Changes by: raster 99/10/28 16:04:27
-
-Modified files:
- . : api.h main.c
- test_images : bg.png
-
-Log message:
-better api.h
-
-_______________________________________________
-
-Changes by: raster 99/10/29 02:11:58
-
-Modified files:
- . : rgbadraw.c
-
-Log message:
-oooooooooops - thanks hans! :)
-
-_______________________________________________
-
-Changes by: raster 99/10/29 03:39:09
-
-Modified files:
- . : color.h
-
-Log message:
-dont need that fixme..
-
-_______________________________________________
-
-Changes by: raster 99/10/30 04:22:48
-
-Modified files:
- . : main.c rgba.c
- libltdl : Makefile.am Makefile.in acinclude.m4 aclocal.m4
- config.h.in configure.in ltdl.c ltdl.h
-
-Log message:
-speed testing code back.. just testing...
-
-_______________________________________________
-
-Changes by: raster 99/10/30 04:54:01
-
-Modified files:
- . : loader_png.c
-
-Log message:
-try this..
-
-_______________________________________________
-
-Changes by: raster 99/10/30 10:41:08
-
-Modified files:
- . : blend.c
-
-Log message:
-optmiseeeeeeeeeeeeeeeeeee. :)
-
-_______________________________________________
-
-Changes by: mandrake 99/10/31 11:45:23
-
-Modified files:
- . : ChangeLog
- libltdl : .cvsignore
-Removed files:
- libltdl : Makefile.am Makefile.in acinclude.m4 aclocal.m4
- config.h.in configure.in ltdl.c ltdl.h
-
-Log message:
-Sun Oct 31 20:21:13 PST 1999
-(Mandrake)
-
-libltdl (large chunks of it) is automatically generated by autogen.sh.
-no need for those files to be in CVS.
-
-_______________________________________________
-
-Changes by: mandrake 99/10/31 11:50:50
-
-Modified files:
- . : rgba.c
-
-Log message:
-removed a warning
-
-_______________________________________________
-
-Changes by: raster 99/10/31 14:50:06
-
-Modified files:
- . : blend.c
-
-Log message:
-eeek math error at 255 (becomes 254) not surprising i didnt notice.. i
-looked at the results rsather than numerically evaluating...
-
-_______________________________________________
-
-Changes by: raster 99/10/31 15:08:18
-
-Modified files:
- . : grab.c rend.c rgba.c rgba.h
-
-Log message:
-and handle ABGR ordering in 24/32bpp
-
-_______________________________________________
-
-Changes by: raster 99/11/01 02:00:06
-
-Modified files:
- . : api.c api.h blend.c image.c image.h
-
-Log message:
-added ability to attach integert vlue and data poitner tags to images by
-string keys (with destructors optional) - wil be used for saving of images
-(savers will look for these keys to gleen parameters for saaving)
-
-_______________________________________________
-
-Changes by: raster 99/11/01 02:07:14
-
-Modified files:
- . : grad.c main.c rgbadraw.c
-
-Log message:
-fix some minro roundoff problems as before...
-
-_______________________________________________
-
-Changes by: raster 99/11/01 03:05:17
-
-Modified files:
- . : blend.c grad.c rgbadraw.c
-
-Log message:
-udless &'s
-
-_______________________________________________
-
-Changes by: raster 99/11/01 04:11:30
-
-Modified files:
- . : ChangeLog image.c image.h
-Added files:
- . : TODO
-
-Log message:
-add TODO...
-
-_______________________________________________
-
-Changes by: raster 99/11/01 06:35:25
-
-Modified files:
- . : api.c api.h image.c image.h
-
-Log message:
-structure for savign all done - now just need to fill in the save() functions
-in the loaders (yes laoder are also savers - loader and saver are
-interchangeable).
-
-_______________________________________________
-
-Changes by: raster 99/11/01 07:27:34
-
-Modified files:
- . : api.c image.c loader_jpeg.c main.c
-
-Log message:
-we have a jpeg saver and the saver code works
-
-_______________________________________________
-
-Changes by: raster 99/11/01 07:30:56
-
-Modified files:
- . : image.c
-
-Log message:
-whee more robus tagging...
-
-_______________________________________________
-
-Changes by: raster 99/11/01 08:14:00
-
-Modified files:
- . : image.c loader_png.c main.c
-
-Log message:
-and now it all works...
-
-_______________________________________________
-
-Changes by: raster 99/11/01 08:15:37
-
-Modified files:
- . : main.c
-
-Log message:
-flim
-
-_______________________________________________
-
-Changes by: raster 99/11/01 08:34:01
-
-Modified files:
- . : blend.c
-
-Log message:
-and now thats all better.
-
-_______________________________________________
-
-Changes by: raster 99/11/01 08:52:52
-
-Modified files:
- . : blend.c
-
-Log message:
-fix that........
-
-_______________________________________________
-
-Changes by: raster 99/11/01 08:54:49
-
-Modified files:
- . : blend.c
-
-Log message:
-fix that bitchift..
-
-_______________________________________________
-
-Changes by: raster 99/11/01 09:12:39
-
-imlib2/loaders
-
-Update of /cvs/enlightenment/imlib2/loaders
-In directory ford:/tmp/cvs-serv13720/loaders
-
-Log Message:
-Directory /cvs/enlightenment/imlib2/loaders added to the repository
-
-_______________________________________________
-
-Changes by: raster 99/11/01 09:12:40
-
-imlib2/src
-
-Update of /cvs/enlightenment/imlib2/src
-In directory ford:/tmp/cvs-serv13720/src
-
-Log Message:
-Directory /cvs/enlightenment/imlib2/src added to the repository
-
-_______________________________________________
-
-Changes by: raster 99/11/01 09:40:51
-
-Modified files:
- . : Makefile.am configure.in
-Added files:
- loaders : Makefile.am loader_jpeg.c loader_png.c
- src : Imlib2.h Makefile.am api.c blend.c blend.h
- color.c color.h colormod.c colormod.h common.h
- context.c context.h draw.c draw.h file.c file.h
- font.c font.h format.c format.h grab.c grab.h
- grad.c grad.h image.c image.h main.c rend.c
- rend.h rgba.c rgba.h rgbadraw.c rgbadraw.h
- scale.c scale.h updates.c updates.h ximage.c
- ximage.h
-Removed files:
- . : api.c api.h blend.c blend.h color.c color.h
- colormod.c colormod.h common.h context.c
- context.h draw.c draw.h file.c file.h font.c
- font.h format.c format.h grab.c grab.h grad.c
- grad.h image.c image.h loader_jpeg.c
- loader_png.c main.c rend.c rend.h rgba.c rgba.h
- rgbadraw.c rgbadraw.h scale.c scale.h updates.c
- updates.h ximage.c ximage.h
-
-Log message:
-re-structure......
-
-_______________________________________________
-
-Changes by: raster 99/11/01 09:41:03
-
-imlib2/test
-
-Update of /cvs/enlightenment/imlib2/test
-In directory ford:/tmp/cvs-serv14123/test
-
-Log Message:
-Directory /cvs/enlightenment/imlib2/test added to the repository
-
-_______________________________________________
-
-Changes by: raster 99/11/01 09:47:48
-
-imlib2/test/test_images
-
-Update of /cvs/enlightenment/imlib2/test/test_images
-In directory ford:/tmp/cvs-serv14183/test_images
-
-Log Message:
-Directory /cvs/enlightenment/imlib2/test/test_images added to the repository
-
-_______________________________________________
-
-Changes by: raster 99/11/01 09:48:23
-
-imlib2/test/ttfonts
-
-Update of /cvs/enlightenment/imlib2/test/ttfonts
-In directory ford:/tmp/cvs-serv14198/ttfonts
-
-Log Message:
-Directory /cvs/enlightenment/imlib2/test/ttfonts added to the repository
-
-_______________________________________________
-
-Changes by: raster 99/11/01 09:49:59
-
-Modified files:
- . : configure.in
-Added files:
- test : Makefile.am main.c
- test/test_images: audio.png bg.png bulb.png cal.png calc.png
- folder.png globe.png lock.png mail.png
- menu.png mush.png paper.png sh1.png sh2.png
- sh3.png stop.png tnt.png
- test/ttfonts : cinema.ttf grunge.ttf morpheus.ttf notepad.ttf
-Removed files:
- src : main.c
- test_images : audio.png bg.png bulb.png cal.png calc.png
- folder.png globe.png lock.png mail.png menu.png
- mush.png paper.png sh1.png sh2.png sh3.png
- stop.png tnt.png
- ttfonts : Gadzoox.ttf Glypic.ttf Lemonfnt.ttf
- Virginlo.ttf adlib.ttf andes.ttf angular.ttf
- anklepants.ttf arabian.ttf arnprior.ttf
- asimov.ttf aurabesh.ttf autobot.ttf axaxax.ttf
- axaxaxl.ttf badfilms.ttf balconyangels.ttf
- baltar.ttf baltar01.ttf battlest.ttf
- battlestar.ttf bellbottomlaser.ttf berliner.ttf
- bigfish.ttf bitchin.ttf blackforest.ttf
- bloodofdracula.ttf bloody.ttf blueregular.ttf
- bookworm.ttf branson.ttf burnout.ttf
- busorama.ttf butterflychromosome.ttf
- cardas1.ttf casloninitials.ttf celticmd.ttf
- checkbk.ttf chemicalgus.ttf choc.ttf
- chromosomelight.ttf cinema.ttf comics.ttf
- competitor.ttf crackbabies.ttf crackman.ttf
- crapola.ttf crystalradiokit.ttf ctype.ttf
- cupertino.ttf dazzleships.ttf decaying.ttf
- deceptgr.ttf demonnight.ttf diamondgothic.ttf
- dienasty.ttf dirtybakersdozen.ttf
- dogsonmars.ttf dolphin.ttf down.ttf
- dragonwick.ttf duedate.ttf dustmites.ttf
- dutchtreat.ttf eccentrical.ttf
- elbjorgscript.ttf electrichermes.ttf enya.ttf
- erasure.ttf flouridebeings.ttf flytningar.ttf
- galactic.ttf gardenparty.ttf gathora.ttf
- glazkrak.ttf glypic.ttf goethe.ttf goofball.ttf
- grease.ttf grunge.ttf hackers.ttf
- headhunter.ttf heavyheap.ttf hirosh.ttf
- hman.ttf holstein.ttf huskystash.ttf
- hydrogenwhiskey.ttf id4.ttf igloo.ttf
- inavelkusin.ttf incantation.ttf induction2.ttf
- invisiblekiller.ttf joycircuit.ttf joystix.ttf
- karloff.ttf kewken.ttf kiloton.ttf
- kingarthur.ttf kissmekissmekissme.ttf
- klingonscript.ttf kurtrussell.ttf lansbury.ttf
- lavalava.ttf lemonfnt.ttf lochen.ttf
- lockergnome.ttf logger.ttf lombardic.ttf
- lombnarr.ttf lowereastside.ttf
- lowerwestside.ttf lunauror.ttf lunaurora.ttf
- machuman.ttf magdelena.ttf marqueem.ttf
- massiveretaliation.ttf mechoba.ttf
- metallord.ttf mickey.ttf minya.ttf monstro.ttf
- morpheus.ttf neon2.ttf newworldvibes.ttf
- nightcourt.ttf nosferatu.ttf notepad.ttf
- oldgermen.ttf oliver.ttf oliviabrush.ttf
- ollon.ttf parkavenue.ttf pastorofmuppets.ttf
- plasticbag.ttf pleasantlyplump.ttf plump.ttf
- popticsone.ttf popticsoneextras.ttf
- popticstwoextras.ttf prick.ttf prima.ttf
- purptete.ttf quadrangle.ttf radiostars.ttf
- ransom.ttf rattpick.ttf rebucked.ttf
- reticulan.ttf robokoz.ttf romeo.ttf
- rotondosilver.ttf rylodian.ttf schizm.ttf
- scritz.ttf sham.ttf shlop.ttf singothic.ttf
- slumberp.ttf snidely.ttf
- solsticeofsuffering.ttf spillm~1.ttf
- spirits.ttf spongy.ttf spund.ttf squealer.ttf
- squire.ttf stonehenge.ttf superglue.ttf
- superheterodyne.ttf taxidermist.ttf thalia.ttf
- thickhead.ttf tofu8.ttf tomhand.ttf
- toontime.ttf topbond.ttf tosscasu.ttf
- touchofnature.ttf trash.ttf tron.ttf
- turkeys.ttf ventilate.ttf village.ttf
- virginlo.ttf wacko.ttf warlock.ttf whitebld.ttf
- xenowort.ttf xoltoa.ttf yadou.ttf yoinks.ttf
- zerohour.ttf
-
-Log message:
-restructure the direcotry a bit.......
-
-_______________________________________________
-
-Changes by: raster 99/11/01 10:00:02
-
-Modified files:
- . : configure.in
-
-Log message:
-fix the version
-
-_______________________________________________
-
-Changes by: raster 99/11/01 10:05:48
-
-Modified files:
- . : README
-
-Log message:
-update README
-
-_______________________________________________
-
-Changes by: raster 99/11/01 10:06:33
-
-Added files:
- loaders : .cvsignore
- src : .cvsignore
- test : .cvsignore
-
-Log message:
-add ignores......
-
-_______________________________________________
-
-Changes by: raster 99/11/01 10:07:34
-
-Modified files:
- . : .cvsignore
-
-Log message:
-more in ignore
-
-_______________________________________________
-
-Changes by: raster 99/11/01 10:10:30
-
-Modified files:
- loaders : loader_png.c
-
-Log message:
-handle progress callback for saving in png loader..
-
-_______________________________________________
-
-Changes by: raster 99/11/01 10:12:42
-
-Modified files:
- test : main.c
-
-Log message:
-stop testing saving.. it works..
-
-_______________________________________________
-
-Changes by: raster 99/11/01 10:13:02
-
-Modified files:
- src : blend.c
-
-Log message:
-no printf
-
-_______________________________________________
-
-Changes by: raster 99/11/01 10:45:29
-
-Modified files:
- loaders : Makefile.am loader_jpeg.c loader_png.c
- src : image.c
-Added files:
- loaders : loader_pnm.c
-
-Log message:
-starting on pnm loader (ppm, pgm pbm, pam) - will finish later...
-
-_______________________________________________
-
-Changes by: raster 99/11/01 10:46:23
-
-Modified files:
- loaders : Makefile.am
-
-Log message:
-oops makefile......
-
-_______________________________________________
-
-Changes by: raster 99/11/01 12:50:16
-
-Modified files:
- loaders : loader_pnm.c
-
-Log message:
-hmm that didnt compile.. ooh fun :)
-
-_______________________________________________
-
-Changes by: raster 99/11/01 16:24:17
-
-Modified files:
- loaders : loader_pnm.c
-
-Log message:
-pnm loader handles binary formats allright... :)
-
-_______________________________________________
-
-Changes by: raster 99/11/01 16:53:45
-
-Modified files:
- loaders : loader_pnm.c
-
-Log message:
-binary png loaders done..plus speculating on the P8 format... dont like it
-much... i think ineed a FAST trivial to load ARGB format.
-
-_______________________________________________
-
-Changes by: raster 99/11/02 00:25:18
-
-Modified files:
- loaders : loader_pnm.c
-
-Log message:
-pnm loader can save now...
-
-_______________________________________________
-
-Changes by: raster 99/11/02 02:16:50
-
-Modified files:
- loaders : Makefile.am loader_pnm.c
- src : api.c
- test : main.c
-Added files:
- loaders : loader_argb.c
-
-Log message:
-argb format loader & saver. my own format just so i can load and save raw ARGB
-data blindingly fast for imlib2 :)
-
-_______________________________________________
-
-Changes by: raster 99/11/02 02:17:07
-
-Modified files:
- test : main.c
-
-Log message:
-get rid of saver func
-
-_______________________________________________
-
-Changes by: raster 99/11/02 02:46:34
-
-imlib2/demo
-
-Update of /cvs/enlightenment/imlib2/demo
-In directory ford:/tmp/cvs-serv28365/demo
-
-Log Message:
-Directory /cvs/enlightenment/imlib2/demo added to the repository
-
-_______________________________________________
-
-Changes by: raster 99/11/02 03:12:59
-
-Modified files:
- . : configure.in
- src : rgbadraw.c
-Added files:
- demo : Makefile.am view.c
-
-Log message:
-oops - fix that filled rect drawing code
-
-_______________________________________________
-
-Changes by: raster 99/11/02 03:13:59
-
-Added files:
- demo : .cvsignore
-
-Log message:
-add ignores.......
-
-_______________________________________________
-
-Changes by: raster 99/11/02 05:32:40
-
-Modified files:
- demo : view.c
- loaders : loader_argb.c loader_jpeg.c loader_pnm.c
- src : rend.c
-
-Log message:
-fix a little of the rend code - never testyed that bit...
-andf the imlib2_view works nicely iwth zooming too :)
-
-_______________________________________________
-
-Changes by: raster 99/11/02 06:34:48
-
-Modified files:
- demo : view.c
-
-Log message:
-primitive timeout.. its not even that good.. :)
-
-_______________________________________________
-
-Changes by: raster 99/11/02 06:42:05
-
-Modified files:
- demo : view.c
-
-Log message:
-now that works better
-
-_______________________________________________
-
-Changes by: raster 99/11/02 07:29:52
-
-Modified files:
- . : configure.in
-
-Log message:
-Makefile NOT Makefil ! :)
-
-_______________________________________________
-
-Changes by: raster 99/11/02 07:56:23
-
-Modified files:
- . : Makefile.am
-Added files:
- . : imlib2.spec
-
-Log message:
-more correct makefile.am in base........
-
-_______________________________________________
-
-Changes by: raster 99/11/03 08:21:02
-
-Modified files:
- demo : Makefile.am
- src : blend.c
-Added files:
- demo : blend.c
-
-Log message:
-add soem stuff and new blend.c from ryan :)
-
-_______________________________________________
-
-Changes by: raster 99/11/03 08:22:21
-
-Modified files:
- src : blend.c
-
-Log message:
-again..........
-
-_______________________________________________
-
-Changes by: raster 99/11/04 01:02:58
-
-Modified files:
- src : Imlib2.h api.c
-
-Log message:
-mising 2 important calls inthe font code... :)
-
-_______________________________________________
-
-Changes by: raster 99/11/04 08:20:08
-
-Modified files:
- src : font.c
-
-Log message:
-ooooooooops :)
-
-_______________________________________________
-
-Changes by: raster 99/11/07 00:51:47
-
-Modified files:
- . : COPYING
- demo : blend.c
- src : blend.c blend.h font.c rend.c
-Added files:
- . : AUTHORS
-
-Log message:
-added AUTHORS file.. fixed copyting....
-
-_______________________________________________
-
-Changes by: raster 99/11/13 10:55:40
-
-Modified files:
- src : blend.c
-
-Log message:
-oopsie in blend.c
-
-_______________________________________________
-
-Changes by: raster 99/11/15 16:06:54
-
-Modified files:
- src : rgbadraw.c
-
-Log message:
-oop s- clipping problme wiht lines.. fixed :)
-
-_______________________________________________
-
-Changes by: raster 99/11/16 16:01:58
-
-Modified files:
- src : api.c
-
-Log message:
-oh oops - image blending whilst scaling want quite right in the api.. :)
-
-_______________________________________________
-
-Changes by: raster 99/11/18 23:42:21
-
-Modified files:
- src : grad.c
-
-Log message:
-ok - gradients now dont overflow the precision buffer as badly.. :)
-
-_______________________________________________
-
-Changes by: raster 99/12/02 13:02:01
-
-Modified files:
- src : image.c
-
-Log message:
-oops saver does rescan loader - so unless you laoded an image no laoders
-will be around... and it wont get rescanned on save.. :)
-
-_______________________________________________
-
-Changes by: raster 99/12/07 09:28:53
-
-Modified files:
- src : Imlib2.h api.c
- test : main.c
-
-Log message:
-lets break the Imlib2 api and chnage it... now its context based.. :)
-
-_______________________________________________
-
-Changes by: raster 99/12/07 09:30:01
-
-Modified files:
- . : configure.in
- src : Makefile.am
-
-Log message:
-just up the versions to show i did something... :)
-
-_______________________________________________
-
-Changes by: raster 99/12/07 09:30:56
-
-Modified files:
- . : imlib2.spec
-
-Log message:
-spec file too...
-
-_______________________________________________
-
-Changes by: raster 99/12/07 10:02:48
-
-Modified files:
- test : main.c
-
-Log message:
-test program back to normal.. nwo works with api changes...
-
-_______________________________________________
-
-Changes by: raster 99/12/07 10:20:57
-
-Modified files:
- demo : Makefile.am view.c
-Removed files:
- demo : blend.c
-
-Log message:
-fixe view to compile & work
-
-_______________________________________________
-
-Changes by: raster 99/12/07 10:28:51
-
-Modified files:
- demo : Makefile.am view.c
-
-Log message:
-imlib2_view works again...
-
-_______________________________________________
-
-Changes by: raster 99/12/10 04:34:12
-
-Modified files:
- src : api.c
-
-Log message:
-oops :) fixed :)
-
-_______________________________________________
-
-Changes by: raster 99/12/10 06:26:13
-
-Modified files:
- . : configure.in
-
-Log message:
-blum
-
-_______________________________________________
-
-Changes by: raster 99/12/10 06:27:54
-
-Modified files:
- src : api.c font.c
-
-Log message:
-more blum - bloody freetype - why does debian have to go move the headre to a
-different location to where it always was?
-
-_______________________________________________
-
-Changes by: raster 99/12/10 06:30:10
-
-Modified files:
- src : api.c font.c
-
-Log message:
-compile damnit...
-
-_______________________________________________
-
-Changes by: raster 99/12/10 06:31:32
-
-Modified files:
- src : font.c
-
-Log message:
-include config.h
-
-_______________________________________________
-
-Changes by: raster 99/12/14 01:18:24
-
-Modified files:
- src : blend.c colormod.h
-
-Log message:
-fix fix fix fix......................... :)
-
-_______________________________________________
-
-Changes by: raster 99/12/17 07:37:20
-
-Modified files:
- . : configure.in
- loaders : Makefile.am
-
-Log message:
-create .a's :)
-
-_______________________________________________
-
-Changes by: llane 99/12/19 13:05:33
-
-imlib2/debian
-
-Update of /cvs/enlightenment/imlib2/debian
-In directory ford:/tmp/cvs-serv24002/debian
-
-Log Message:
-Directory /cvs/enlightenment/imlib2/debian added to the repository
-
-_______________________________________________
-
-Changes by: llane 99/12/19 13:08:33
-
-Modified files:
- debian : changelog
-Added files:
- debian : changelog control libeconfig0.postinst rules
- shlibs.local
- debian : changelog control libimlib2.postinst rules
- shlibs.local
-
-Log message:
-more preliminary assimilation
-
-_______________________________________________
-
-Changes by: raster 99/12/19 15:03:06
-
-Modified files:
- loaders : loader_jpeg.c
- test : main.c
-
-Log message:
-fix loaders......
-
-_______________________________________________
-
-Changes by: mej 99/12/21 12:46:42
-
-Modified files:
- loaders : Makefile.am
-Added files:
- loaders : loader_gif.c
-
-Log message:
-A GIF loader. There is no save function yet, and you'll need libgif to
-use it.
-
-_______________________________________________
-
-Changes by: raster 99/12/22 00:04:00
-
-Modified files:
- src : Imlib2.h api.c
-
-Log message:
-for acceleration to work i nee to add a parameter to put_back_data
-
-_______________________________________________
-
-Changes by: mej 99/12/22 02:48:31
-
-Modified files:
- loaders : loader_gif.c
-
-Log message:
-Whoops. Forgot to call the progress callback one last time.
-
-_______________________________________________
-
-Changes by: raster 99/12/23 08:43:26
-
-Modified files:
- src : api.c
-
-Log message:
-oops typo :)
-
-_______________________________________________
-
-Changes by: raster 99/12/23 15:30:18
-
-Modified files:
- src : blend.c
-
-Log message:
-fix missing case in scaling for blending objects...
-
-_______________________________________________
-
-Changes by: raster 99/12/26 10:27:05
-
-Modified files:
- src : blend.c rend.c updates.c
-
-Log message:
-get clipping right...
-
-_______________________________________________
-
-Changes by: raster 00/01/05 02:26:40
-
-Modified files:
- loaders : loader_gif.c
- src : Imlib2.h api.c image.c
-
-Log message:
-add loader flush call and fix gif loader to be able to load when theres no
-progress set :)
-
-_______________________________________________
-
-Changes by: raster 00/01/05 04:23:25
-
-Modified files:
- loaders : loader_png.c
-
-Log message:
-oops - expand indexed images...
-
-_______________________________________________
-
-Changes by: mej 00/01/05 06:28:50
-
-Modified files:
- loaders : loader_gif.c
-
-Log message:
-Don't ask me how this got out of sync....
-
-_______________________________________________
-
-Changes by: mej 00/01/05 06:29:58
-
-Modified files:
- loaders : loader_gif.c
-
-Log message:
-*grumble*
-
-_______________________________________________
-
-Changes by: raster 00/01/05 21:58:21
-
-Modified files:
- src : font.c
-
-Log message:
-allow full paths for font names too..
-
-_______________________________________________
-
-Changes by: raster 00/01/05 22:32:45
-
-Modified files:
- src : font.c
-
-Log message:
-search path for font mroe sanely
-
-_______________________________________________
-
-Changes by: raster 00/01/07 10:40:51
-
-Modified files:
- src : font.c
-
-Log message:
-dont be so anal abotu ewncodings... if no apple or windows encoding is there
-just use encoding charmap 0 :)
-
-_______________________________________________
-
-Changes by: raster 00/01/09 21:41:18
-
-Modified files:
- src : Imlib2.h api.c image.c
-
-Log message:
-i cant beleieve i missed wrappign the pixmap free function....
-
-_______________________________________________
-
-Changes by: raster 00/01/09 21:42:41
-
-Modified files:
- src : api.c
-
-Log message:
-add to header.....
-
-_______________________________________________
-
-Changes by: raster 00/01/09 22:49:20
-
-Modified files:
- src : Imlib2.h api.c
-
-Log message:
-add dither mask pixmap rendering contexts...
-
-_______________________________________________
-
-Changes by: raster 00/01/10 04:25:14
-
-Modified files:
- src : Imlib2.h Makefile.am
-
-Log message:
-up version... add c++ usability..
-
-_______________________________________________
-
-Changes by: raster 00/01/10 19:15:59
-
-Modified files:
- . : configure.in
-
-Log message:
-updates and fixes.. versioning etc...
-
-_______________________________________________
-
-Changes by: mej 00/01/11 14:42:07
-
-Modified files:
- loaders : loader_gif.c
-
-Log message:
-Ummm...
-
-_______________________________________________
-
-Changes by: raster 00/01/17 10:20:29
-
-Modified files:
- src : Imlib2.h api.c
-
-Log message:
-oops - forgort to remove param from imlib_free_color_rangex
-
-_______________________________________________
-
-Changes by: raster 00/01/17 14:21:02
-
-Modified files:
- loaders : loader_gif.c
-
-Log message:
-put that back...
-
-_______________________________________________
-
-Changes by: mej 00/01/17 14:50:08
-
-Modified files:
- loaders : loader_gif.c
-
-Log message:
-Put those back. I hate warnings.
-
-_______________________________________________
-
-Changes by: raster 00/01/21 12:36:28
-
-Modified files:
- src : api.c
-
-Log message:
-2 more checks in save calls for image data...
-
-_______________________________________________
-
-Changes by: raster 00/01/24 09:07:05
-
-Modified files:
- src : font.c
-
-Log message:
-that was silly! fix fix fix - thanks alan :)
-
-_______________________________________________
-
-Changes by: raster 00/01/24 11:18:17
-
-Modified files:
- src : font.c
-
-Log message:
-ooops - fix :)
-
-_______________________________________________
-
-Changes by: raster 00/01/25 21:14:38
-
-Modified files:
- src : rgba.c
-
-Log message:
-endinaness for masks broken onf sparc.. fix...
-
-_______________________________________________
-
-Changes by: raster 00/01/25 21:18:32
-
-Modified files:
- src : rgba.c
-
-Log message:
-oops typo
-
-_______________________________________________
-
-Changes by: raster 00/01/25 21:25:19
-
-Modified files:
- src : rgba.c
-
-Log message:
-get enmdianess roight for sparc (and ppc) for masks...
-
-_______________________________________________
-
-Changes by: llane 00/02/02 16:10:14
-
-Modified files:
- debian : rules
-
-Log message:
-clean target
-
-_______________________________________________
-
-Changes by: raster 00/02/07 09:53:25
-
-Modified files:
- src : image.c
-
-Log message:
-oopsie - problem with non extension format images :)
-
-_______________________________________________
-
-Changes by: raster 00/02/07 14:04:05
-
-Modified files:
- src : image.c
-
-Log message:
-oooops - image and pixmap cache baddies.. :(
-
-_______________________________________________
-
-Changes by: raster 00/02/07 14:38:01
-
-Modified files:
- src : Imlib2.h api.c
-
-Log message:
-const char *
-
-_______________________________________________
-
-Changes by: raster 00/02/19 12:10:37
-
-Modified files:
- loaders : loader_argb.c
-
-Log message:
-ooops - big eng9ian bug! :)
-
-_______________________________________________
-
-Changes by: mandrake 00/02/22 14:29:17
-
-Modified files:
- . : configure.in
-
-Log message:
-fixing freetype detection stuff, maybe?
-
-_______________________________________________
-
-Changes by: raster 00/02/27 10:36:26
-
-Modified files:
- src : Imlib2.h Makefile.am api.c
- test : main.c
-
-Log message:
-rotattion code added... :)
-
-_______________________________________________
-
-Changes by: raster 00/02/27 10:37:28
-
-Modified files:
- . : AUTHORS
-
-Log message:
-authors.. BTW - anyone watching commtis list please check AUTHORS...
-if your'e nto listed plese tell me to add you... I never do well maintaining
-it.
-
-_______________________________________________
-
-Changes by: raster 00/02/27 11:23:21
-
-Added files:
- src : loaderpath.h rotate.c rotate.h
-
-Log message:
-add files...
-
-_______________________________________________
-
-Changes by: raster 00/02/27 11:23:36
-
-Removed files:
- src : loaderpath.h
-
-Log message:
-dont add that1
-
-_______________________________________________
-
-Changes by: raster 00/03/01 09:04:23
-
-Modified files:
- src : Imlib2.h api.c rotate.c rotate.h
- test : main.c
-
-Log message:
-flum..........
-
-_______________________________________________
-
-Changes by: raster 00/03/03 08:42:18
-
-Modified files:
- src : Imlib2.h api.c font.c rgbadraw.c rgbadraw.h
- rotate.c
- test : main.c
-
-Log message:
-flum
-
-_______________________________________________
-
-Changes by: raster 00/03/03 09:15:51
-
-Modified files:
- src : Imlib2.h api.c rotate.c rotate.h
-
-Log message:
-better
-
-_______________________________________________
-
-Changes by: raster 00/03/03 09:24:46
-
-Modified files:
- test : main.c
-
-Log message:
-poatch main.c - but rottest doesnt work.. must fix later
-
-_______________________________________________
-
-Changes by: raster 00/03/03 18:45:09
-
-Modified files:
- src : api.c
-
-Log message:
-get context patch from tom......
-
-_______________________________________________
-
-Changes by: llane 00/03/07 09:15:24
-
-Modified files:
- debian : changelog
-
-Log message:
-stuff
-
-_______________________________________________
-
-Changes by: llane 00/03/07 14:39:28
-
-Modified files:
- debian : rules
- debian : rules
- debian : rules
- debian : rules
- debian : rules
- debian : rules
- debian : rules
- debian : rules
-
-Log message:
-removed dh_testversion
-
-_______________________________________________
-
-Changes by: llane 00/03/07 17:58:06
-
-Modified files:
- debian : changelog
- debian : changelog
- debian : changelog rules
- debian : changelog
- debian : changelog
- debian : changelog
- debian : changelog
-
-Log message:
-stuff
-
-_______________________________________________
-
-Changes by: mej 00/03/07 20:05:01
-
-Modified files:
- loaders : Makefile.am
-Added files:
- loaders : loader_tiff.c
-
-Log message:
-TIFF loader from Eric Dorland <dorland@lords.com>.
-
-_______________________________________________
-
-Changes by: mej 00/03/07 22:08:29
-
-Modified files:
- loaders : Makefile.am
-Added files:
- loaders : loader_bmp.c
-
-Log message:
-BMP loader from Isaac Richards <ijr@po.cwru.edu>. It currently has issues
-with progressive loading, so don't use it with feh. :-)
-
-_______________________________________________
-
-Changes by: mej 00/03/07 22:11:04
-
-Modified files:
- . : AUTHORS
-
-Log message:
-Keep raster happy.
-
-_______________________________________________
-
-Changes by: mej 00/03/08 08:20:06
-
-Modified files:
- loaders : loader_bmp.c
-
-Log message:
-BMP loader fix for progressive loading from Chutt.
-
-_______________________________________________
-
-Changes by: mej 00/03/08 12:01:31
-
-Modified files:
- loaders : loader_bmp.c
-
-Log message:
-Murple.
-
-_______________________________________________
-
-Changes by: gilbertt 00/03/17 12:54:19
-
-Modified files:
- loaders : loader_tiff.c
-
-Log message:
-Shaddup ;)
-
-_______________________________________________
-
-Changes by: gilbertt 00/03/17 17:20:55
-
-Modified files:
- loaders : loader_gif.c
-
-Log message:
-shaddup ;)
-
-_______________________________________________
-
-Changes by: gilbertt 00/03/17 19:37:54
-
-Modified files:
- loaders : loader_gif.c
-
-Log message:
-AARGH. Godamn file decriptor leak which has been driving me CRAZY for a
-WEEK! Got the BASTARD. DIE!
-
-(what complicated matters was that it only leaked on when it *couldn't* load
-the image).
-
-Please note. there is also a filedes leak in the tiff loader, also when it
-fails to load. I haven't been able to fix this yet, because libtiff sucks
-ass and has totally encapsulated the file descriptor. Lemme work on it
-tomorrow...
-
-_______________________________________________
-
-Changes by: gilbertt 00/03/17 20:12:23
-
-Modified files:
- src : image.c
-
-Log message:
-Removed a crufty bit.
-
-_______________________________________________
-
-Changes by: gilbertt 00/03/17 20:43:47
-
-Modified files:
- src : image.c
-
-Log message:
-nothing major
-
-_______________________________________________
-e-develop mailing list - e-develop@lists.on.openprojects.net
-
-Changes by: gilbertt 00/03/18 05:07:53
-
-Modified files:
- loaders : loader_tiff.c
-
-Log message:
-Leak plugged. Thanks Eric :)
-
-_______________________________________________
-
-Changes by: gilbertt 00/03/18 05:56:29
-
-Modified files:
- src : image.c image.h
-
-Log message:
-Okay. The loader list is now trimmed. Where it would previously contain:
-argb.a bmp.a gif.a jpeg.a png.a pnm.a tiff.a
-argb.la bmp.la gif.la jpeg.la png.la pnm.la tiff.la
-argb.so bmp.so gif.so jpeg.so png.so pnm.so tiff.so
-
-It now contains:
-argb
-bmp
-gif
-jpeg
-png
-pnm
-tiff
-
-lt_dlopen knows how to do the Right Thing with these, trying first the .la,
-then the .so. Now the loaders are each tried once per image (if none of them
-manage to load it).
-
-Added the following functions to achieve this:
-char **__imlib_TrimLoaderList(char **list, int *num);
-int __imlib_LoaderInList(char **list, int size, char *item);
-
-_______________________________________________
-
-Changes by: gilbertt 00/03/18 06:26:13
-
-Modified files:
- . : AUTHORS
-
-Log message:
-Bite me =P
-
-_______________________________________________
-
-Changes by: gilbertt 00/03/18 15:45:47
-
-Modified files:
- loaders : loader_tiff.c
-
-Log message:
-Partial loader_tiff rewrite from Eric Dorland. Much nicer :)
-
-_______________________________________________
-
-Changes by: raster 00/03/19 14:53:42
-
-Modified files:
- src : blend.c blend.h colormod.c grad.c rgbadraw.c
-
-Log message:
-I'm back....... :)
-
-_______________________________________________
-
-Changes by: raster 00/03/21 01:38:40
-
-Modified files:
- src : blend.c blend.h
-
-Log message:
-fix cmod.......
-
-_______________________________________________
-
-Changes by: raster 00/03/22 14:26:58
-
-Modified files:
- src : blend.c blend.h colormod.c colormod.h rotate.h
-
-Log message:
-optmize.. fix endianess stuff... :)
-
-_______________________________________________
-
-Changes by: raster 00/03/24 11:03:24
-
-Modified files:
- src : blend.c
-
-Log message:
-oops - missed modfifying colros there.. :)
-
-_______________________________________________
-
-Changes by: raster 00/03/24 11:06:01
-
-Modified files:
- src : api.c rend.c rotate.c rotate.h
-
-Log message:
-rotate speedups - rend bugfix... wheeeeeee
-
-_______________________________________________
-
-Changes by: raster 00/03/25 16:10:46
-
-Modified files:
- src : blend.h
-
-Log message:
-fix endianes problems..... works now on sparc solaris nicely.. :)
-
-_______________________________________________
-
-Changes by: raster 00/03/25 16:35:44
-
-Modified files:
- src : blend.h
-
-Log message:
-ummmm fix dat.....
-
-_______________________________________________
-
-Changes by: raster 00/03/27 11:17:37
-
-Modified files:
- src : color.c rend.c rgba.c rgba.h
- test : main.c
-
-Log message:
-BGR56r & BGR555 support.......... please test if u have a display like this :)
-
-_______________________________________________
-
-Changes by: raster 00/03/27 11:20:29
-
-Modified files:
- src : blend.h
-
-Log message:
-nicer including of config.h
-
-_______________________________________________
-
-Changes by: raster 00/03/27 11:39:36
-
-Modified files:
- src : rgba.c
-
-Log message:
-oopsa typo
-
-_______________________________________________
-
-Changes by: raster 00/03/28 10:09:46
-
-Modified files:
- loaders : loader_png.c
- src : Imlib2.h api.c file.c file.h font.c font.h
- image.c image.h rotate.c
-
-Log message:
-damn willem! you love playing with imlib2 don;t you? :-) good show :)
-
-_______________________________________________
-
-Changes by: raster 00/03/28 14:25:45
-
-Modified files:
- src : scale.c
- test : main.c
-
-Log message:
-speedup scaling down....... but i cant seem to get any speedup for up scaling
-
-_______________________________________________
-
-Changes by: raster 00/03/28 15:20:38
-
-Modified files:
- src : scale.c
-
-Log message:
-optimize scalign down routine for RGBA as well as RGB...
-
-_______________________________________________
-
-Changes by: raster 00/03/28 18:57:28
-
-Modified files:
- libltdl : COPYING.LIB README
- src : scale.c
-
-Log message:
-um ooops - how did that happen?
-
-_______________________________________________
-
-Changes by: raster 00/03/29 19:28:56
-
-Modified files:
- src : scale.c
-
-Log message:
-no more of that thanks
-
-_______________________________________________
-
-Changes by: raster 00/04/02 13:31:40
-
-Modified files:
- src : Imlib2.h api.c
-
-Log message:
-need new updates call.....
-
-_______________________________________________
-
-Changes by: raster 00/04/02 13:42:42
-
-Modified files:
- src : updates.c
-
-Log message:
-updates..... actually clip if only 1!
-
-_______________________________________________
-
-Changes by: raster 00/04/03 15:38:01
-
-Modified files:
- src : scale.c
-
-Log message:
-faster scaling up.......... :)
-
-_______________________________________________
-
-Changes by: raster 00/04/04 18:34:06
-
-Modified files:
- src : rgba.c
-
-Log message:
-fix dither mask generation.. works again now.. use for icons to dnd
-
-_______________________________________________
-
-Changes by: raster 00/04/04 20:56:27
-
-Modified files:
- src : rgba.c
-
-Log message:
-dont need that code no more
-
-_______________________________________________
-
-Changes by: raster 00/04/07 21:13:52
-
-Modified files:
- src : Makefile.am api.c blend.c updates.c
-
-Log message:
-now that was bad! fix update appending :)
-
-_______________________________________________
-
-Changes by: raster 00/04/08 11:45:18
-
-Added files:
- src : asm_blend.S
-
-Log message:
-add asm for blending.... this will break imlib2 right now for all platforms that
-arent xz86 intel 9unless you rmove the asm form the makefile and blend.c
-
-_______________________________________________
-
-Changes by: raster 00/04/08 12:15:48
-
-Modified files:
- . : configure.in
- src : asm_blend.S blend.c blend.h common.h
-
-Log message:
-check for i686 artch and only then compile the mmx asm (i586 isnt guaranteed
-to have mmx - NB libs built for mmx will NOt work on non mmx boxes right now
-need to do a runtime chekc for that)
-
-_______________________________________________
-
-Changes by: raster 00/04/08 12:20:13
-
-Modified files:
- src : blend.c
-
-Log message:
-dont compile mmx data struct in if no mmx asm is used
-
-_______________________________________________
-
-Changes by: raster 00/04/08 14:06:17
-
-Modified files:
- . : imlib2.spec
-
-Log message:
-fix spec file - dont buidl demos package
-
-_______________________________________________
-
-Changes by: raster 00/04/13 09:48:48
-
-..........
-summary:
-added mmx rotuines for blending - optimized them further
-thanks to some poitners form willem. added willems filter code. willem did
-mmx asm for the other blend rotuines too - added - needs fixing because
-math in C routines chnaged tobe fixed (there was a bug in RGBa destination
-alpha routines). fixed minor scaling calculation bug for clipping when
-blending. thansk everyone - please make sure your names are in the AUTHORS
-file at some point... :)
-
-_______________________________________________
-
-Thu Apr 27 02:59:57 GMT 2000
-(gilbertt)
-
-Well, I'm gonna use the damn ChangeLog anyhow ;-)
-
-Changed all the loaders to use ImlibProgressFunction instead of defining it
-themselves. This is so I can change them all at once tomorrow.
-
-_______________________________________________
-
-Thu Apr 27 03:16:59 GMT 2000
-(gilbertt)
-
-Okay, an ImlibProgressFunction now return int, not void. The idea of this is
-so that a progressive load may be aborted midway, simply by returning 0 from
-the progress callback. There are a number of reasons for wanting this.
-
-This is a slight breakage to people currently using progressive loading -
-you'll have to change your definition to int, and return 1 to get normal
-behaviour again. As far as I know, only feh and imlib2_view uses progressive
-loading, and I'll sort those two out. To anyone else, sorry, but it's not
-released yet, what did you expect? ;-)
-
-Notice. I haven't changed the loaders yet, so returning 0 won't do squat
-until tomorrow, when I change them all. What they will do is clean up and
-return what they've got so far. If anyone who wrote a loader wants to do
-their own, cool, it'll save me learning the api of every damn image lib ;-)
-It's just a case of swapping
-progress(params, ...);
-with
-if(!progress(params, ...)
- cleanup_some_stuff_and_return_what_there_is();
-Otherwise, I'll do it myself tomorrow.
-
-_______________________________________________
-
-Wed Apr 26 19:58:05 PDT 2000
-(KainX)
-
-If progress() returns 0, clip the last row and
-return 2.
-
-_______________________________________________
-
-Thu Apr 27 04:00:28 GMT 2000
-(gilbertt)
-
-All done except the tiff loader. This one is gonna be hard. Libtiff is quite
-broken in many ways ;-)
-
-_______________________________________________
-
-Thu Apr 27 04:22:06 GMT 2000
-(gilbertt)
-
-Return 2 from interrupted loaders.
-
-_______________________________________________
-
-Thu Apr 27 13:41:11 GMT 2000
-(gilbertt)
-
-Free up some RAM and close the filehandle when interrupted.
-
-_______________________________________________
-
-Thu Apr 27 13:43:49 GMT 2000
-(gilbertt)
-
-Actually, made the gif loader give back what it's got without changing im->h
-to reflect, or reallocing the image data. The reason for this is that it
-already told apps what the image size was in the first progressive loader
-callback, and changing it afterwards can cause confusion. Also, an app can
-still handle/display a half-loaded image, as the rest is just filled black,
-and the programmer knows how much of the image he got, 'cos he interrupted
-it from the callback. If the programmer wants to trim the image, he knows
-where to trim it, but if he/she wants to display a part-loaded image,
-that'll work sanely.
-
-I think this is more sane behaviour, having tested it in feh and
-imlib2_view, but feel free to disagree ;-)
-
-_______________________________________________
-
-Wed Jul 12 22:20:53 PDT 2000
-(KainX)
-
-It's generally a good idea to increment the reference count when you
-implement reference counting. This should fix the mysterious problems
-people have been having with Imlib2 stealing pixmaps out from under
-Eterm.
-
-_______________________________________________
-
-Fri Aug 10 13:33:13 PDT 2001
-(KainX)
-
-None of the libraries are now absolute requirements. Everything that
-requires external support which Imlib2 itself doesn't specifically
-need can now be optionally built.
-
-_______________________________________________
-
-Tue Jan 15 15:22:06 EST 2002
-(KainX)
-
-Fixed a whole slew of potential buffer overflows, hopefully including
-the one recently posted to BUGTRAQ.
-
-_______________________________________________
-
-Mon Mar 31 15:20:43 EST 2003
-(KainX)
-
-Finally got around to fixing the build. Having Imlib2 already installed
-should no longer be necessary to build it.
-
-_______________________________________________
-
-Thu Apr 3 14:06:53 EST 2003
-(KainX)
-
-Rearranged include directory order to make sure
-local headers are found before system ones.
-
-_______________________________________________
-
-Thu Apr 3 20:48:27 EST 2003
-(KainX)
-
-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.
-
-_______________________________________________
-
-Sat Jul 12 21:33:20 EDT 2003
-(KainX)
-
-Up version numbers.
-
-_______________________________________________
-
-Fri Jul 2 14:39:46 EDT 2004
-(KainX)
-
-Fixed build (again).
-
-_______________________________________________
-
-Tue Aug 31 11:46:49 JST 2004
-(Raster)
-
-Fixed bmp security issue.
-New IFF ILBM loader
-Up to 1.1.2
-
-_______________________________________________
diff --git a/Doxyfile b/Doxyfile
deleted file mode 100644
index ea1f29d..0000000
--- a/Doxyfile
+++ /dev/null
@@ -1,139 +0,0 @@
-PROJECT_NAME = Imlib2
-PROJECT_NUMBER =
-OUTPUT_DIRECTORY = doc
-INPUT = imlib2.c
-IMAGE_PATH = doc/img
-OUTPUT_LANGUAGE = English
-GENERATE_HTML = YES
-HTML_OUTPUT = html
-HTML_FILE_EXTENSION = .html
-HTML_HEADER = doc/head.html
-HTML_FOOTER = doc/foot.html
-HTML_STYLESHEET = doc/imlib2.css
-HTML_ALIGN_MEMBERS = YES
-ENUM_VALUES_PER_LINE = 1
-GENERATE_HTMLHELP = NO
-CHM_FILE =
-HHC_LOCATION =
-GENERATE_CHI = NO
-BINARY_TOC = NO
-TOC_EXPAND = NO
-DISABLE_INDEX = NO
-EXTRACT_ALL = NO
-EXTRACT_PRIVATE = NO
-EXTRACT_STATIC = NO
-EXTRACT_LOCAL_CLASSES = NO
-HIDE_UNDOC_MEMBERS = YES
-HIDE_UNDOC_CLASSES = YES
-HIDE_FRIEND_COMPOUNDS = YES
-BRIEF_MEMBER_DESC = YES
-REPEAT_BRIEF = YES
-ALWAYS_DETAILED_SEC = NO
-INLINE_INHERITED_MEMB = NO
-FULL_PATH_NAMES = NO
-STRIP_FROM_PATH =
-INTERNAL_DOCS = NO
-STRIP_CODE_COMMENTS = YES
-CASE_SENSE_NAMES = YES
-SHORT_NAMES = NO
-HIDE_SCOPE_NAMES = NO
-VERBATIM_HEADERS = NO
-SHOW_INCLUDE_FILES = NO
-JAVADOC_AUTOBRIEF = YES
-MULTILINE_CPP_IS_BRIEF = NO
-DETAILS_AT_TOP = NO
-INHERIT_DOCS = YES
-INLINE_INFO = YES
-SORT_MEMBER_DOCS = YES
-DISTRIBUTE_GROUP_DOC = NO
-TAB_SIZE = 2
-GENERATE_TODOLIST = YES
-GENERATE_TESTLIST = YES
-GENERATE_BUGLIST = YES
-GENERATE_DEPRECATEDLIST= YES
-ALIASES =
-ENABLED_SECTIONS =
-MAX_INITIALIZER_LINES = 30
-OPTIMIZE_OUTPUT_FOR_C = YES
-OPTIMIZE_OUTPUT_JAVA = NO
-SHOW_USED_FILES = NO
-QUIET = NO
-WARNINGS = YES
-WARN_IF_UNDOCUMENTED = YES
-WARN_FORMAT = "$file:$line: $text"
-WARN_LOGFILE =
-FILE_PATTERNS =
-RECURSIVE = NO
-EXCLUDE =
-EXCLUDE_SYMLINKS = NO
-EXCLUDE_PATTERNS =
-EXAMPLE_PATH =
-EXAMPLE_PATTERNS =
-EXAMPLE_RECURSIVE = NO
-INPUT_FILTER =
-FILTER_SOURCE_FILES = NO
-SOURCE_BROWSER = NO
-INLINE_SOURCES = NO
-REFERENCED_BY_RELATION = YES
-REFERENCES_RELATION = YES
-ALPHABETICAL_INDEX = YES
-COLS_IN_ALPHA_INDEX = 2
-IGNORE_PREFIX =
-GENERATE_TREEVIEW = NO
-TREEVIEW_WIDTH = 250
-GENERATE_LATEX = YES
-LATEX_OUTPUT = latex
-LATEX_CMD_NAME = latex
-MAKEINDEX_CMD_NAME = makeindex
-COMPACT_LATEX = NO
-PAPER_TYPE = a4wide
-EXTRA_PACKAGES =
-LATEX_HEADER =
-PDF_HYPERLINKS = YES
-USE_PDFLATEX = NO
-LATEX_BATCHMODE = NO
-GENERATE_RTF = NO
-RTF_OUTPUT = rtf
-COMPACT_RTF = NO
-RTF_HYPERLINKS = NO
-RTF_STYLESHEET_FILE =
-RTF_EXTENSIONS_FILE =
-GENERATE_MAN = YES
-MAN_OUTPUT = man
-MAN_EXTENSION = .3
-MAN_LINKS = YES
-GENERATE_XML = YES
-XML_SCHEMA =
-XML_DTD =
-GENERATE_AUTOGEN_DEF = NO
-ENABLE_PREPROCESSING = YES
-MACRO_EXPANSION = NO
-EXPAND_ONLY_PREDEF = NO
-SEARCH_INCLUDES = NO
-INCLUDE_PATH =
-INCLUDE_FILE_PATTERNS =
-PREDEFINED =
-EXPAND_AS_DEFINED =
-SKIP_FUNCTION_MACROS = YES
-TAGFILES =
-GENERATE_TAGFILE =
-ALLEXTERNALS = NO
-EXTERNAL_GROUPS = YES
-PERL_PATH = /usr/bin/perl
-CLASS_DIAGRAMS = NO
-HIDE_UNDOC_RELATIONS = YES
-HAVE_DOT = NO
-CLASS_GRAPH = NO
-COLLABORATION_GRAPH = NO
-TEMPLATE_RELATIONS = NO
-INCLUDE_GRAPH = NO
-INCLUDED_BY_GRAPH = NO
-GRAPHICAL_HIERARCHY = NO
-DOT_IMAGE_FORMAT = png
-DOT_PATH =
-DOTFILE_DIRS =
-MAX_DOT_GRAPH_WIDTH = 512
-MAX_DOT_GRAPH_HEIGHT = 512
-GENERATE_LEGEND = YES
-DOT_CLEANUP = YES
-SEARCHENGINE = NO
diff --git a/Makefile.am b/Makefile.am
deleted file mode 100644
index 3907b8f..0000000
--- a/Makefile.am
+++ /dev/null
@@ -1,46 +0,0 @@
-AUTOMAKE_OPTIONS = 1.4 foreign
-
-MAINTAINERCLEANFILES = INSTALL Makefile.in aclocal.m4 config.guess \
- config.h.in config.sub configure install-sh \
- ltconfig ltmain.sh missing mkinstalldirs \
- stamp-h.in
-
-SUBDIRS = src filters doc loaders test demo
-
-bin_SCRIPTS = imlib2-config
-
-EXTRA_DIST = \
-imlib2.spec \
-imlib2.pc.in \
-demo/Makefile.am \
-demo/Makefile.in \
-demo/view.c \
-demo/imconvert.c \
-test/Makefile.am \
-test/Makefile.in \
-test/main.c \
-test/test_images/cal.png \
-test/test_images/lock.png \
-test/test_images/paper.png \
-test/test_images/stop.png \
-test/test_images/audio.png \
-test/test_images/calc.png \
-test/test_images/mail.png \
-test/test_images/sh1.png \
-test/test_images/tnt.png \
-test/test_images/bg.png \
-test/test_images/folder.png \
-test/test_images/menu.png \
-test/test_images/sh2.png \
-test/test_images/bulb.png \
-test/test_images/globe.png \
-test/test_images/mush.png \
-test/test_images/sh3.png \
-test/ttfonts/cinema.ttf \
-test/ttfonts/grunge.ttf \
-test/ttfonts/morpheus.ttf \
-test/ttfonts/notepad.ttf
-
-pkgconfigdir = $(libdir)/pkgconfig
-pkgconfig_DATA = imlib2.pc
-
diff --git a/README b/README
deleted file mode 100644
index b9b8086..0000000
--- a/README
+++ /dev/null
@@ -1,41 +0,0 @@
-###############################################################################
-# #
-# I M L I B 2 #
-# #
-###############################################################################
-
-This is the Imlib 2 library - a library that does image file loading and
-saving as well as rendering, manipulation, arbitrary polygon support, etc.
-
-It does ALL of these operations FAST. Imlib2 also tries to be highly
-intelligent about doing them, so writing naive programs can be done
-easily, without sacrificing speed.
-
-This is a complete rewrite over the Imlib 1.x series. The architecture is
-more modular, simple, and flexible. See index.html in the doc/ directory
-for more information.
-
-Imlib2 requires several libraries to be already installed. These are:
-
-libjpeg http://www.ijg.org/
-libpng http://www.libpng.org/pub/png/libpng.html
-freetype 2.1.x http://www.freetype.org/
-
-
-For examples of this library in use, seek:
-
-Eterm http://www.eterm.org/ (CVS version only, currently)
-feh http://www.linuxbrit.co.uk/feh.html
-geist http://www.linuxbrit.co.uk/geist.html
-
-
-A blurb about each of the directories:
-
-debian/ Debian build files
-demo/ Demo view program
-doc/ Documentation for imlib2, primarily in html
-filters/ Filter shared objects
-libltdl/ Libtool LGPL-licensed loadable module support library source
-loaders/ Imlib2's image loader-savers (jpg, png, etc)
-src/ Imlib2 main source
-test/ Test program(s)
diff --git a/TODO b/TODO
deleted file mode 100644
index e754229..0000000
--- a/TODO
+++ /dev/null
@@ -1,6 +0,0 @@
-* line code doesnt draw nice liens when clipping - fix
-* filled polygons can break fill bounds on corner cases - fix
-* go thru TODOs and FIXMEs
-
-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/autogen.sh b/autogen.sh
deleted file mode 100755
index 9d8816d..0000000
--- a/autogen.sh
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/bin/sh
-
-rm -rf autom4te.cache
-rm -f aclocal.m4
-
-echo "Running aclocal..."; aclocal $ACLOCAL_FLAGS -I m4 \
-&& echo "Running autoheader..."; autoheader \
-&& echo "Running autoconf..."; autoconf \
-&& echo "Running libtoolize..."; (libtoolize --automake || glibtoolize --automake) \
-&& echo "Running automake..."; automake --add-missing --copy --gnu
-
-### If you want this, uncomment it.
-./configure "$@"
diff --git a/configure.in b/configure.in
deleted file mode 100644
index f726bbb..0000000
--- a/configure.in
+++ /dev/null
@@ -1,435 +0,0 @@
-# get rid of that stupid cache mechanism
-rm -f config.cache
-
-AC_INIT(configure.in)
-AC_CANONICAL_BUILD
-AC_CANONICAL_HOST
-AC_CANONICAL_TARGET
-AC_ISC_POSIX
-AM_INIT_AUTOMAKE(imlib2, 1.1.2)
-AM_CONFIG_HEADER(config.h)
-
-AC_C_BIGENDIAN
-AC_PROG_CC
-AM_PROG_CC_STDC
-AC_HEADER_STDC
-AC_C_CONST
-AM_ENABLE_SHARED
-AM_PROG_LIBTOOL
-
-if test "x${exec_prefix}" = "xNONE"; then
- if test "x${prefix}" = "xNONE"; then
- bindir="${ac_default_prefix}/bin";
- else
- bindir="${prefix}/bin";
- fi
-else
- if test "x${prefix}" = "xNONE"; then
- bindir="${ac_default_prefix}/bin";
- else
- bindir="${prefix}/bin";
- fi
-fi
-
-if test "x${exec_prefix}" = "xNONE"; then
- if test "x${prefix}" = "xNONE"; then
- libdir="${ac_default_prefix}/lib";
- else
- libdir="${prefix}/lib";
- fi
-else
- if test "x${prefix}" = "xNONE"; then
- libdir="${ac_default_prefix}/lib";
- else
- libdir="${prefix}/lib";
- fi
-fi
-
-dnl Set PACKAGE_BIN_DIR in config.h.
-if test "x${bindir}" = 'xNONE'; then
- if test "x${prefix}" = "xNONE"; then
- AC_DEFINE_UNQUOTED(PACKAGE_BIN_DIR, "${ac_default_prefix}/bin", [Installation directory for user executables])
- else
- AC_DEFINE_UNQUOTED(PACKAGE_BIN_DIR, "${prefix}/bin", [Installation directory for user executables])
- fi
-else
- AC_DEFINE_UNQUOTED(PACKAGE_BIN_DIR, "${bindir}", [Installation directory for user executables])
-fi
-
-if test "x${libdir}" = 'xNONE'; then
- if test "x${prefix}" = "xNONE"; then
- AC_DEFINE_UNQUOTED(PACKAGE_LIB_DIR, "${ac_default_prefix}/lib", [Installation directory for libraries] )
- else
- AC_DEFINE_UNQUOTED(PACKAGE_LIB_DIR, "${prefix}/lib", [Installation directory for libraries])
- fi
-else
- AC_DEFINE_UNQUOTED(PACKAGE_LIB_DIR, "${libdir}", [Installation directory for libraries])
-fi
-
-dnl Set PACKAGE_SOURCE_DIR in config.h.
-packagesrcdir=`cd $srcdir && pwd`
-AC_DEFINE_UNQUOTED(PACKAGE_SOURCE_DIR, "${packagesrcdir}", [Source code directory])
-
-
-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 library 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]],
-[
- if test x$enableval = xyes; then
- mmx=yes
- fi
-],
-[
- if test x$target_os = xlinux-gnu; then
- mmx=`cat /proc/cpuinfo | grep mmx`
- if test -n "$mmx"; then
- mmx=yes
- fi
-else
- echo ""
- echo "You are not running Linux - This script cannot auto-detect mmx assembly."
- echo "You will have to enable the mmx assembly (which gives anywhere from 10%"
- echo "to 300% speedups) by adding --enable-mmx on the configure command-line."
- echo ""
-fi
-]
-)
-if test x$mmx = xyes; then
- AC_DEFINE(DO_MMX_ASM, 1, [enabling MMX Assembly])
-fi
-AM_CONDITIONAL(HAVE_MMX, test x$mmx = xyes)
-
-pkglibdir='${libdir}'/imlib2_loaders
-AC_SUBST(pkglibdir)
-
-#if test X"$enable_shared" = Xyes; then
-# DLLDFLAGS=-export-dynamic
-# AC_SUBST(DLLDFLAGS)
-#fi
-
-dnl AM_PROG_AS
-ASFLAGS="$ASFLAGS -I../"
-AS=$CC
-AC_SUBST(ASFLAGS)
-AC_SUBST(AS)
-
-CCASFLAGS="$ASFLAGS"
-CCAS="$AS"
-AC_SUBST(CCASFLAGS)
-AC_SUBST(CCAS)
-
-
-AC_MSG_CHECKING(whether fopen accepts "b" mode)
-AC_CACHE_VAL([ag_cv_func_fopen_binary],
-[AC_TRY_RUN([#include <stdio.h>
-int main (int argc, char *argv[])
-{
- FILE *fp = fopen("/bin/sh", "rb");
- return (fclose(fp) >= 0);
-}],[ag_cv_func_fopen_binary=yes],
-[ag_cv_func_fopen_binary=yes],[ag_cv_func_fopen_binary=yes])
-rm -f core *.exe.core])
-AC_MSG_RESULT([$ag_cv_func_fopen_binary])
-if test x$ag_cv_func_fopen_binary = xyes; then
- AC_DEFINE(USE_FOPEN_BINARY, 1,
- [Define this if we can use the "b" mode for fopen safely.])
-fi
-
-AC_PATH_X
-AC_PATH_XTRA
-
-if test "x$have_x" = "xdisabled"; then
- AC_MSG_WARN([Xlib support is disabled.])
- AM_CONDITIONAL(HAVE_X, false)
- XMISS="-DX_DISPLAY_MISSING"
-else
- AM_CONDITIONAL(HAVE_X, true)
- XMISS=""
-
-if test "x$x_includes" = "x"; then
- x_includes="/usr/include"
-fi
-
-x_cflags="$X_CFLAGS"
-x_ldflags="$X_LDFLAGS"
-x_libs="$X_LIBS $X_EXTRA_LIBS"
-X_OBJS="color.lo context.lo draw.lo grab.lo rend.lo rgba.lo ximage.lo"
-
-AC_CHECK_LIB(X11, XOpenDisplay, x_libs="-lX11 $x_libs",
- AC_MSG_ERROR([ERROR: libX11 not found.]); exit,
- $X_LDFLAGS $X_EXTRA_LIBS $X_LIBS)
-AC_CHECK_LIB(Xext, XShmAttach, x_libs="-lXext $x_libs",
- AC_CHECK_LIB(XextSam, XShmAttach,
- x_libs="-lXextSam -lXext $x_libs",
- AC_MSG_ERROR([ERROR: XShm not found.]); exit,
- $x_libs),
- $x_libs)
-AC_CHECK_LIB(Xext, XShapeCombineMask, x_libs="-lXext $x_libs",
- AC_MSG_ERROR([ERROR: XShape not found.]); exit,
- $x_libs)
-fi
-AC_SUBST(XMISS)
-AC_SUBST(XDIR)
-AC_SUBST(X_OBJS)
-
-# This is necessary so that .o files in LIBOBJS are also built via
-# the ANSI2KNR-filtering rules.
-dnl# Doesn't work with autoconf-2.13!
-dnl# LIB@&t@OBJS=`echo "$LIB@&t@OBJS" |
-dnl# sed 's,\.[[^.]]* ,$U&,g;s,\.[[^.]]*$,$U&,'`
-LTLIBOBJS=`echo "$LIB@&t@OBJS" |
- sed 's,\.[[^.]]* ,.lo ,g;s,\.[[^.]]*$,.lo,'`
-AC_SUBST(LTLIBOBJS)
-
-dnl here was freetype headers checking
-
-
-
-dnl /here was freetype headers checking
-
-AC_CHECK_LIB(dl, dlopen, dlopen_libs=-ldl)
-AC_CHECK_LIB(ltdl, lt_dlopen, ltdlopen_libs=-lltdl)
-
-EXTRA_LIBS="-L/usr/local/lib -L/usr/X11R6/lib"
-
-# Test for libjpeg
-AC_CHECK_LIB(jpeg, jpeg_destroy_decompress,
- jpeg_ok=yes,
- jpeg_ok=no
- AC_MSG_WARN(*** Native JPEG support will not be built (JPEG library not found) ***), $EXTRA_LIBS)
-if test "$jpeg_ok" = yes; then
- AC_MSG_CHECKING([for jpeglib.h])
- AC_TRY_CPP(
- [#include <stdio.h>
- #undef PACKAGE
- #undef VERSION
- #include <jpeglib.h>],
- jpeg_ok=yes,
- jpeg_ok=no)
- AC_MSG_RESULT($jpeg_ok)
- if test "$jpeg_ok" = yes; then
- JPEGLIBS="-ljpeg"
- else
- AC_MSG_WARN(*** Native JPEG support will not be built (JPEG header file not found) ***)
- fi
-fi
-
-# Test for libpng
-AC_CHECK_LIB(png, png_read_info,
- png_ok=yes,
- png_ok=no
- AC_MSG_WARN(*** Native PNG support will not be built (PNG library not found) ***), $EXTRA_LIBS -lz -lm)
-if test "$png_ok" = yes; then
- AC_MSG_CHECKING([for png.h])
- AC_TRY_CPP(
- [#include <stdio.h>
- #undef PACKAGE
- #undef VERSION
- #include <png.h>],
- png_ok=yes,
- png_ok=no)
- AC_MSG_RESULT($png_ok)
- if test "$png_ok" = yes; then
- PNGLIBS="-lpng -lz -lm"
- REQUIREMENTS=libpng12
- else
- AC_MSG_WARN(*** Native PNG support will not be built (PNG header file not found) ***)
- fi
-fi
-
-# Test for libtiff
-AC_CHECK_LIB(tiff, TIFFReadScanline,
- tiff_libs="-ltiff"
- tiff_ok=yes,
-AC_CHECK_LIB(tiff, TIFFWriteScanline,
- tiff_libs="-ltiff -ljpeg -lz -lm"
- tiff_ok=yes,
-AC_CHECK_LIB(tiff34, TIFFFlushData,
- tiff_libs="-ltiff -ljpeg -lz -lm"
- tiff_ok=yes,
- tiff_ok=no
- AC_MSG_WARN(*** Native TIFF support will not be built (TIFF library not found) ***),
- $EXTRA_LIBS -ljpeg -lz -lm),
- $EXTRA_LIBS -ljpeg -lz -lm),
- $EXTRA_LIBS)
-if test "$tiff_ok" = yes; then
- AC_MSG_CHECKING([for tiffio.h])
- AC_TRY_CPP(
- [#include <stdio.h>
- #undef PACKAGE
- #undef VERSION
- #include <tiffio.h>],
- tiff_ok=yes,
- tiff_ok=no)
- AC_MSG_RESULT($tiff_ok)
- if test "$tiff_ok" = yes; then
- TIFFLIBS=$tiff_libs
- else
- AC_MSG_WARN(*** Native TIFF support will not be built (TIFF header file not found) ***)
- fi
-fi
-
-# Test for libungif
-AC_CHECK_LIB(ungif, DGifOpenFileName,
- gif_libs="-lungif"
- gif_ok=yes,
- gif_ok=no,
- $EXTRA_LIBS -lX11)
-if test "$gif_ok" = yes; then
- AC_MSG_CHECKING([for gif_lib.h])
- AC_TRY_CPP(
- [#include <stdio.h>
- #undef PACKAGE
- #undef VERSION
- #include <gif_lib.h>],
- gif_ok=yes,
- gif_ok=no)
- AC_MSG_RESULT($gif_ok)
- if test "$gif_ok" = yes; then
- GIFLIBS=$gif_libs
- fi
-fi
-
-# Test for libgif
-if test "$gif_ok" = no; then
- AC_CHECK_LIB(gif, DGifOpenFileName,
- gif_libs="-lgif"
- gif_ok=yes,
- gif_ok=no
- AC_MSG_WARN(*** Native GIF support will not be built (GIF library not found) ***),
- $EXTRA_LIBS)
- if test "$gif_ok" = yes; then
- AC_MSG_CHECKING([for gif_lib.h])
- AC_TRY_CPP(
- [#include <stdio.h>
- #undef PACKAGE
- #undef VERSION
- #include <gif_lib.h>],
- gif_ok=yes,
- gif_ok=no)
- AC_MSG_RESULT($gif_ok)
- if test "$gif_ok" = yes; then
- GIFLIBS=$gif_libs
- else
- AC_MSG_WARN(*** Native GIF support will not be built (GIF header file not found) ***)
- fi
- fi
-fi
-
-# Test for zlib
-AC_CHECK_LIB(z, uncompress,
- zlib_ok=yes,
- zlib_ok=no
- AC_MSG_WARN(*** Native zlib support will not be built (zlib not found) ***), $EXTRA_LIBS -lz)
-if test "$zlib_ok" = yes; then
- AC_MSG_CHECKING([for zlib.h])
- AC_TRY_CPP(
- [#include <stdio.h>
- #undef PACKAGE
- #undef VERSION
- #include <zlib.h>],
- zlib_ok=yes,
- zlib_ok=no)
- AC_MSG_RESULT($zlib_ok)
- if test "$zlib_ok" = yes; then
- ZLIBLIBS="-lz"
- else
- AC_MSG_WARN(*** Native zlib support will not be built (zlib header file not found) ***)
- fi
-fi
-
-# Test for libbzip2
-AC_CHECK_LIB(bz2, BZ2_bzRead,
- bz2_ok=yes,
- bz2_ok=no
- AC_MSG_WARN(*** Native bz2 support will not be built (bzip2 library not found) ***), $EXTRA_LIBS -lbz2)
-if test "$bz2_ok" = yes; then
- AC_MSG_CHECKING([for bzlib.h])
- AC_TRY_CPP(
- [#include <stdio.h>
- #undef PACKAGE
- #undef VERSION
- #include <bzlib.h>],
- bz2_ok=yes,
- bz2_ok=no)
- AC_MSG_RESULT($bz2_ok)
- if test "$bz2_ok" = yes; then
- BZ2LIBS="-lbz2"
- else
- AC_MSG_WARN(*** Native bz2 support will not be built (bzip2 header file not found) ***)
- fi
-fi
-
-AM_CONDITIONAL(JPEG_LOADER, test "$jpeg_ok" = yes)
-AM_CONDITIONAL(PNG_LOADER, test "$png_ok" = yes)
-AM_CONDITIONAL(TIFF_LOADER, test "$tiff_ok" = yes)
-AM_CONDITIONAL(GIF_LOADER, test "$gif_ok" = yes)
-AM_CONDITIONAL(ZLIB_LOADER, test "$zlib_ok" = yes)
-AM_CONDITIONAL(BZ2_LOADER, test "$bz2_ok" = yes)
-
-AC_SUBST(JPEGLIBS)
-AC_SUBST(PNGLIBS)
-AC_SUBST(TIFFLIBS)
-AC_SUBST(GIFLIBS)
-AC_SUBST(ZLIBLIBS)
-AC_SUBST(BZ2LIBS)
-AC_SUBST(REQUIREMENTS)
-
-AC_SUBST(x_cflags)
-AC_SUBST(x_includes)
-AC_SUBST(x_ldflags)
-AC_SUBST(x_libs)
-AC_SUBST(dlopen_libs)
-AC_SUBST(ltdlopen_libs)
-AC_SUBST(freetype_cflags)
-AC_SUBST(freetype_libs)
-
-dnl AC_SUBST(freetype_libs)
-dnl AC_SUBST(freetype_includes)
-
-dnl# This stuff is not compatible with autoconf-2.13
-dnl# AC_CONFIG_FILES([imlib2-config imlib2.pc Makefile loaders/Makefile src/Makefile test/Makefile \
-dnl# filters/Makefile demo/Makefile doc/Makefile libltdl/Makefile \
-dnl# ])
-dnl# AC_CONFIG_COMMANDS([default],[[
-dnl# chmod +x imlib2-config
-dnl# ]],[[]])
-dnl# AC_OUTPUT
-
-AC_OUTPUT([
-Makefile
-loaders/Makefile
-src/Makefile
-test/Makefile
-filters/Makefile
-demo/Makefile
-doc/Makefile
-imlib2-config
-imlib2.pc
-],[
-chmod +x imlib2-config
-])
diff --git a/debian/.cvsignore b/debian/.cvsignore
deleted file mode 100644
index 21ea042..0000000
--- a/debian/.cvsignore
+++ /dev/null
@@ -1,11 +0,0 @@
-Makefile
-Makefile.in
-files
-libimlib2
-libimlib2-dev
-libimlib2-dev.postinst.debhelper
-libimlib2-dev.prerm.debhelper
-libimlib2.postinst.debhelper
-libimlib2.postrm.debhelper
-libimlib2.substvars
-tmp
diff --git a/debian/Makefile.am b/debian/Makefile.am
deleted file mode 100644
index ba35b62..0000000
--- a/debian/Makefile.am
+++ /dev/null
@@ -1,9 +0,0 @@
-EXTRA_DIST = \
-changelog \
-control \
-copyright \
-imlib2-config.1 \
-libimlib2-dev.doc-base \
-libimlib2.files \
-libimlib2-dev.files \
-rules
diff --git a/debian/changelog b/debian/changelog
deleted file mode 100644
index f5790d8..0000000
--- a/debian/changelog
+++ /dev/null
@@ -1,5 +0,0 @@
-imlib2 (1.1.2-0cvs20040918) unstable; urgency=low
-
- * a CVS release
-
- -- Sytse Wielinga <s.b.wielinga@student.utwente.nl> Sat, 18 Sep 2004 12:48:44 +0200
diff --git a/debian/control b/debian/control
deleted file mode 100644
index 6998ca2..0000000
--- a/debian/control
+++ /dev/null
@@ -1,44 +0,0 @@
-Source: imlib2
-Section: libs
-Priority: optional
-Maintainer: Laurence J. Lane <ljlane@debian.org>
-Build-Depends: libjpeg62-dev, libttf-dev, libpng3-dev | libpng2-dev | libpng-dev, libtiff4-dev | libtiff-dev, zlib1g-dev, libungif4-dev | libungif3g-dev | giflib3g-dev, xlibs-dev, libfreetype6-dev | freetype2-dev, libbz2-dev, libltdl3-dev, automake1.7 | automaken, libtool, debhelper (>= 4.0)
-Standards-Version: 3.5.7.0
-
-Package: imlib2-demo
-Architecture: any
-Section: graphics
-Depends: ${shlibs:Depends}
-Description: Imlib2 demo's
- This package contains two small Imlib2-based programs: a simple
- image viewer and a simple image conversion program.
-
-Package: imlib2-test
-Architecture: any
-Section: graphics
-Depends: ${shlibs:Depends}
-Description: Imlib2 test programs
- This package contains some, not generally usable, test programs
- for Imlib2.
-
-Package: libimlib2
-Section: libs
-Architecture: any
-Depends: ${shlibs:Depends}
-Suggests: imlib2-loaders, imlib2-demo (= ${Source-Version})
-Description: Powerful image loading and rendering library
- Imlib2 is an advanced replacement library for libraries like
- libXpm that provides many more features with much greater
- flexibility and speed than standard libraries, including font
- rasterization, rotation, RGBA space rendering and blending,
- dynamic binary filters, scripting, and more.
- .
- Imlib2 is not a drop-in replacement for Imlib 1.x.
-
-Package: libimlib2-dev
-Architecture: any
-Section: devel
-Architecture: any
-Depends: libimlib2 (= ${Source-Version}), libc6-dev | libc-dev, libjpeg62-dev, libpng3-dev | libpng2-dev | libpng-dev, libtiff4-dev | libtiff-dev, zlib1g-dev, libttf-dev, libungif4-dev | libungif3g-dev | giflib3g-dev, xlibs-dev, libfreetype6-dev | freetype2-dev, libbz2-dev
-Description: Imlib2 headers, static libraries and documentation
- Headers, static libraries and documentation for Imlib2.
diff --git a/debian/copyright b/debian/copyright
deleted file mode 100644
index 25d1164..0000000
--- a/debian/copyright
+++ /dev/null
@@ -1,32 +0,0 @@
-This package was debianized by Laurence J. Lane <ljlane@debian.org> on
-Sat, 28 Oct 2000 17:56:46 -0400.
-
-The source code is from the e17/libs/imlib2 module of the enlightenment CVS
-tree. For more information, see:
-
- http://www.enlightenment.org/cvs.html
-
-Upstream Author: Carsten Haitzler <raster@rasterman.com>
-
-Copyright:
-
-Copyright (C) 2000 Carsten Haitzler and various contributors (see AUTHORS)
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to
-deal in the Software without restriction, including without limitation the
-rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-sell copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies of the Software, its documentation and marketing & publicity
-materials, and acknowledgment shall be given in the documentation, materials
-and software packages that this Software was used.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
-IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/debian/imlib2-config.1 b/debian/imlib2-config.1
deleted file mode 100644
index 6d00705..0000000
--- a/debian/imlib2-config.1
+++ /dev/null
@@ -1,17 +0,0 @@
-.TH imlib2-config 1 "29 Oct 2000" imlib2-config
-.SH NAME
-.HP
-imlib2-config - imlib2 build information script
-.SH SYNOPSIS
-.HP
-imlib2-config [options]
-.P
-.SH DESCRIPTION
-.HP
-.I imlib2-config
-is a script that's used by make and other build enviroments to
-gather imlib2 information.
-.HP
-Run
-.I imlib2-config
-for additional information.
diff --git a/debian/imlib2-demo.install b/debian/imlib2-demo.install
deleted file mode 100644
index 16f5b43..0000000
--- a/debian/imlib2-demo.install
+++ /dev/null
@@ -1,2 +0,0 @@
-usr/bin/imconvert
-usr/bin/imlib2_view
diff --git a/debian/imlib2-test.install b/debian/imlib2-test.install
deleted file mode 100644
index 0f6203c..0000000
--- a/debian/imlib2-test.install
+++ /dev/null
@@ -1,5 +0,0 @@
-usr/bin/imlib2
-usr/bin/imlib2_test
-usr/bin/bumpmaptest
-usr/bin/color_spaces
-usr/bin/polytest
diff --git a/debian/libimlib2-dev.doc-base b/debian/libimlib2-dev.doc-base
deleted file mode 100644
index 09d1d32..0000000
--- a/debian/libimlib2-dev.doc-base
+++ /dev/null
@@ -1,10 +0,0 @@
-Document: imlib2
-Title: Imlib2 Guide
-Author: Carsten Haitzler
-Abstract: This document describes Imlib2 API
- and provides sample C code.
-Section: Apps/Programming
-
-Format: HTML
-Index: /usr/share/doc/libimlib2-dev/html/index.html
-Files: /usr/share/doc/libimlib2-dev/html/index.html
diff --git a/debian/libimlib2-dev.install b/debian/libimlib2-dev.install
deleted file mode 100644
index f3094ca..0000000
--- a/debian/libimlib2-dev.install
+++ /dev/null
@@ -1,10 +0,0 @@
-usr/bin/imlib2-config
-usr/lib/pkgconfig/*
-usr/include
-usr/lib/*.so
-usr/lib/*.a
-usr/lib/*.la
-usr/lib/imlib2_loaders/filter/*.a
-usr/lib/imlib2_loaders/filter/*.la
-usr/lib/imlib2_loaders/image/*.a
-usr/lib/imlib2_loaders/image/*.la
diff --git a/debian/libimlib2.install b/debian/libimlib2.install
deleted file mode 100644
index 58c526b..0000000
--- a/debian/libimlib2.install
+++ /dev/null
@@ -1,3 +0,0 @@
-usr/lib/*.so.*
-usr/lib/imlib2_loaders/filter/*.so
-usr/lib/imlib2_loaders/image/*.so
diff --git a/debian/rules b/debian/rules
deleted file mode 100644
index 9cc7640..0000000
--- a/debian/rules
+++ /dev/null
@@ -1,88 +0,0 @@
-#!/usr/bin/make -f
-# Sample debian/rules that uses debhelper.
-# GNU copyright 1997 to 1999 by Joey Hess.
-
-# Uncomment this to turn on verbose mode.
-#export DH_VERBOSE=1
-
-# This is the debhelper compatability version to use.
-export DH_COMPAT=4
-
-# These are used for cross-compiling and for saving the configure script
-# from having to guess our platform (since we know it already)
-DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
-DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
-
-CFLAGS ?= -Wall -g
-
-ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
- CFLAGS += -O0
-else
- CFLAGS += -O2
-endif
-ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
- INSTALL_PROGRAM += -s
-endif
-ifneq (,$(findstring mmx,$(DEB_BUILD_OPTIONS)))
- ENABLE_MMX = yes
-else
- ENABLE_MMX = no
-endif
-
-INSTALL=/usr/bin/install -p
-CONFIGUREOPTS = --prefix=/usr --enable-mmx=$(ENABLE_MMX) --build=$(DEB_BUILD_GNU_TYPE) --host=$(DEB_HOST_GNU_TYPE)
-package=libimlib2
-
-configure: configure-stamp
-configure-stamp:
- test -x autogen.sh && ./autogen.sh $(CONFIGUREOPTS) || ./configure $(CONFIGUREOPTS)
- touch configure-stamp
-
-build: build-stamp
-build-stamp: configure-stamp
- dh_testdir
- $(MAKE)
- touch build-stamp
-
-clean:
- dh_testdir
- rm -f build-stamp configure-stamp
-
- -$(MAKE) distclean
-
- dh_clean
-
-install: build
- dh_testdir
- dh_testroot
- dh_clean -k
- dh_installdirs
-
- $(MAKE) install DESTDIR=$(CURDIR)/debian/tmp/
-
- $(INSTALL) -d debian/$(package)-dev/usr/share/doc/$(package)-dev/html
- $(INSTALL) -m 644 doc/*.html doc/*.gif \
- debian/$(package)-dev/usr/share/doc/$(package)-dev/html
-
-binary-indep: build install
-
-binary-arch: build install
- dh_testdir
- dh_testroot
- dh_install --sourcedir=debian/tmp --list-missing
-
- dh_installdocs AUTHORS README
- dh_installchangelogs
- dh_link
- dh_strip
- dh_compress
- dh_fixperms
- dh_makeshlibs
- dh_installdeb
- dh_shlibdeps
- dh_gencontrol
- dh_md5sums
- dh_builddeb
-
-binary: binary-indep binary-arch
-.PHONY: build clean binary-indep binary-arch binary install configure
diff --git a/demo/.cvsignore b/demo/.cvsignore
deleted file mode 100644
index 9bffad3..0000000
--- a/demo/.cvsignore
+++ /dev/null
@@ -1,26 +0,0 @@
-config.guess
-imconvert
-config.h.in
-config.sub
-ltconfig
-ltmain.sh
-aclocal.m4
-stamp-h.in
-Makefile.in
-configure
-config.log
-config.h
-config.cache
-libtool
-config.status
-stamp-h
-Makefile
-.deps
-.libs
-*.lo
-*.la
-imlib2
-loaderpath.h
-imlib2_blend
-imlib2_view
-.icons
diff --git a/demo/Makefile.am b/demo/Makefile.am
deleted file mode 100644
index e857182..0000000
--- a/demo/Makefile.am
+++ /dev/null
@@ -1,28 +0,0 @@
-## Process this file with automake to produce Makefile.in
-
-AUTOMAKE_OPTIONS = 1.4 foreign
-
-# A list of all the files in the current directory which can be regenerated
-MAINTAINERCLEANFILES = Makefile.in
-
-LDFLAGS =
-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)
-
-if HAVE_X
-
-LDADD = $(top_builddir)/src/libImlib2.la
-
-bin_PROGRAMS = imlib2_view imconvert
-
-imconvert_SOURCES = imconvert.c
-imconvert_LDFLAGS = $(LDFLAGS) -L/usr/X11R6/lib
-
-imlib2_view_SOURCES = view.c
-imlib2_view_LDFLAGS = $(LDFLAGS) -L/usr/X11R6/lib
-
-endif
-
-EXTRA_DIST = imconvert.c view.c
diff --git a/demo/imconvert.c b/demo/imconvert.c
deleted file mode 100644
index 7be8352..0000000
--- a/demo/imconvert.c
+++ /dev/null
@@ -1,91 +0,0 @@
-/* Convert images between formats, using Imlib2's API. Smart enough to know
- * about edb files; defaults to jpg's.
- */
-
-#include <ctype.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#include <X11/Xlib.h>
-#include <Imlib2.h>
-
-#define PROG_NAME "imconvert"
-
-static void usage(int exit_status);
-
-int
-main(int argc, char **argv)
-{
- 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);
- }
-
- /* 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");
-
- imlib_save_image(argv[2]);
-
- return 0;
-}
-
-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);
-}
diff --git a/demo/view.c b/demo/view.c
deleted file mode 100644
index 1b319bd..0000000
--- a/demo/view.c
+++ /dev/null
@@ -1,345 +0,0 @@
-#include <X11/Xlib.h>
-#include <X11/extensions/XShm.h>
-#include <X11/Xutil.h>
-#include <X11/extensions/shape.h>
-#include <X11/Xatom.h>
-#include <X11/Xos.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <unistd.h>
-#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;
-
-static int
- 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)
-{
- /* first time it's called */
- imlib_context_set_drawable(pm);
- imlib_context_set_anti_alias(0);
- imlib_context_set_dither(0);
- imlib_context_set_blend(0);
- if (image_width == 0)
- {
- int x, y, onoff;
-
- 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_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);
- 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)
-{
- 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);
- imlib_context_set_display(disp);
- imlib_context_set_visual(vis);
- imlib_context_set_colormap(cm);
- imlib_context_set_progress_function(progress);
- imlib_context_set_progress_granularity(10);
- imlib_context_set_drawable(win);
- 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 (!im)
- {
- fprintf(stderr, "Image format not available\n");
- exit(0);
- }
- 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);
- 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;
- }
- }
-
- }
- }
- return 0;
-}
diff --git a/doc/.cvsignore b/doc/.cvsignore
deleted file mode 100644
index 282522d..0000000
--- a/doc/.cvsignore
+++ /dev/null
@@ -1,2 +0,0 @@
-Makefile
-Makefile.in
diff --git a/doc/Makefile.am b/doc/Makefile.am
deleted file mode 100644
index e973fcb..0000000
--- a/doc/Makefile.am
+++ /dev/null
@@ -1,3 +0,0 @@
-EXTRA_DIST = imlib2.gif \
- blank.gif \
- index.html
diff --git a/doc/blank.gif b/doc/blank.gif
deleted file mode 100644
index 60fa7a1..0000000
--- a/doc/blank.gif
+++ /dev/null
Binary files differ
diff --git a/doc/foot.html b/doc/foot.html
deleted file mode 100644
index 308b1d0..0000000
--- a/doc/foot.html
+++ /dev/null
@@ -1,2 +0,0 @@
-</body>
-</html>
diff --git a/doc/head.html b/doc/head.html
deleted file mode 100644
index 3fdb33d..0000000
--- a/doc/head.html
+++ /dev/null
@@ -1,19 +0,0 @@
-<html>
-
-<head>
-
-<title>$title</title>
-<link href=imlib2.css rel=stylesheet type=text/css>
-
-</head>
-
-<body>
-<div class=nav>
-<table border=0 align=center><tr>
-<td width=16><img src=imlib2_mini.png width=16 height=16 alt=E></td>
-<td width=100% align=center>
-I : M : L : I : B : 2
-</td>
-<td width=16><img src=imlib2_mini.png width=16 height=16 alt=E></td>
-</tr></table>
-</div>
diff --git a/doc/img/hilite.png b/doc/img/hilite.png
deleted file mode 100644
index 88a4381..0000000
--- a/doc/img/hilite.png
+++ /dev/null
Binary files differ
diff --git a/doc/img/imlib2.png b/doc/img/imlib2.png
deleted file mode 100644
index 76f84eb..0000000
--- a/doc/img/imlib2.png
+++ /dev/null
Binary files differ
diff --git a/doc/img/imlib2_mini.png b/doc/img/imlib2_mini.png
deleted file mode 100644
index f4f99f0..0000000
--- a/doc/img/imlib2_mini.png
+++ /dev/null
Binary files differ
diff --git a/doc/imlib2.css b/doc/imlib2.css
deleted file mode 100644
index 6117b39..0000000
--- a/doc/imlib2.css
+++ /dev/null
@@ -1,178 +0,0 @@
-td.md {
- background-color: #ffffff;
- font-family: monospace;
- text-align: left;
- vertical-align: center;
- font-size: 10;
- padding-right : 1px;
- padding-top : 1px;
- padding-left : 1px;
- padding-bottom : 1px;
- margin-left : 1px;
- margin-right : 1px;
- margin-top : 1px;
- margin-bottom : 1px
-}
-td.mdname {
- font-family: monospace;
- text-align: left;
- vertical-align: center;
- font-size: 10;
- padding-right : 1px;
- padding-top : 1px;
- padding-left : 1px;
- padding-bottom : 1px;
- margin-left : 1px;
- margin-right : 1px;
- margin-top : 1px;
- margin-bottom : 1px
-}
-h1
-{
- text-align: center;
- color: #333333
-}
-h2
-{
- text-align: left;
- color: #333333
-}
-h3
-{
- text-align: left;
- color: #333333
-}
-a:link
-{
- text-decoration: none;
- color: #444444;
- font-weight: bold;
-}
-a:visited
-{
- text-decoration: none;
- color: #666666;
- font-weight: bold;
-}
-a:hover
-{
- text-decoration: none;
- color: #000000;
- font-weight: bold;
-}
-a.nav:link
-{
- text-decoration: none;
- color: #444444;
- font-weight: normal;
-}
-a.nav:visited
-{
- text-decoration: none;
- color: #666666;
- font-weight: normal;
-}
-a.nav:hover
-{
- text-decoration: none;
- color: #000000;
- font-weight: normal;
-}
-a.qindex:link
-{
- text-decoration: none;
- color: #444444;
- font-weight: normal;
-}
-a.qindex:visited
-{
- text-decoration: none;
- color: #666666;
- font-weight: normal;
-}
-a.qindex:hover
-{
- text-decoration: none;
- color: #000000;
- font-weight: normal;
-}
-p
-{
- color: #000000;
- font-family: sans-serif;
- font-size: 10;
-}
-body {
- background-image: url("hilite.png");
- background-repeat: no-repeat;
- background-position: left top;
- background-color: #dddddd;
- color: #000000;
- font-family: sans-serif;
- padding: 8px;
- margin: 0;
-}
-div.fragment
-{
- background-image: url("hilite.png");
- background-repeat: no-repeat;
- background-position: left top;
- border: thin solid #888888;
- background-color: #eeeeee;
- padding: 4px;
- text-align: left;
- vertical-align: center;
- font-size: 12;
-}
-hr
-{
- border: 0;
- background-color: #000000;
- width: 80%;
- height: 1;
-}
-dl
-{
- background-image: url("hilite.png");
- background-repeat: no-repeat;
- background-position: left top;
- border: thin solid #aaaaaa;
- background-color: #eeeeee;
- padding: 4px;
- text-align: left;
- vertical-align: center;
- font-size: 12;
-}
-em
-{
- color: #334466;
- font-family: courier;
- font-size: 10;
- font-style: normal;
-}
-
-div.nav
-{
- border: thin solid #000000;
- background-color: #ffffff;
- padding: 1px;
- text-align: center;
- vertical-align: center;
- font-size: 12;
-}
-div.body
-{
- border: thin solid #000000;
- background-color: #ffffff;
- padding: 4px;
- text-align: left;
- font-size: 10;
-}
-div.diag
-{
- border: thin solid #888888;
- background-color: #eeeeee;
- padding: 4px;
- text-align: center;
- font-size: 8;
-}
diff --git a/doc/imlib2.gif b/doc/imlib2.gif
deleted file mode 100644
index 1fcd7f3..0000000
--- a/doc/imlib2.gif
+++ /dev/null
Binary files differ
diff --git a/doc/index.html b/doc/index.html
deleted file mode 100644
index 2ec4735..0000000
--- a/doc/index.html
+++ /dev/null
@@ -1,2268 +0,0 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <meta name="GENERATOR" content="Mozilla/4.72 [en] (X11; U; Linux 2.2.16-3ext3 i686) [Netscape]">
- <meta name="Author" content="The Rasterman & Lightman">
- <title>Imlib 2 - Documentation.</title>
-</head>
-<body text="#000000" bgcolor="#FFFFFF" link="#0000EF" vlink="#51188E" alink="#FFFF00">
-
-
-<center>
-<h1>
-<img SRC="imlib2.gif" ALT="Imlib2" height=128 width=256></h1></center>
-
-<center><table BORDER=0 CELLSPACING=0 WIDTH="95%" BGCOLOR="#666666" NOSAVE ROWS="5" >
-<tr NOSAVE>
-<td WIDTH="1" NOSAVE><img SRC="img/blank.gif" height=1 width=1></td>
-
-<td NOSAVE><img SRC="img/blank.gif" height=1 width=1></td>
-
-<td WIDTH="1" NOSAVE><img SRC="img/blank.gif" height=1 width=1></td>
-</tr>
-
-<tr NOSAVE>
-<td WIDTH="1" NOSAVE><img SRC="img/blank.gif" height=1 width=1></td>
-
-<td ALIGN=CENTER VALIGN=CENTER NOSAVE><b><font color="#FFFFFF"><font size=+2>What
-is it?</font></font></b></td>
-
-<td WIDTH="1" NOSAVE><img SRC="img/blank.gif" height=1 width=1></td>
-</tr>
-
-<tr NOSAVE>
-<td WIDTH="1" NOSAVE><img SRC="img/blank.gif" height=1 width=1></td>
-
-<td NOSAVE><img SRC="img/blank.gif" height=1 width=1></td>
-
-<td WIDTH="1" NOSAVE><img SRC="img/blank.gif" height=1 width=1></td>
-</tr>
-
-<tr NOSAVE>
-<td><img SRC="img/blank.gif" height=1 width=1></td>
-
-<td VALIGN=TOP HEIGHT="100%" BGCOLOR="#6a7a8a" NOSAVE>Imlib 2 is the successor
-to Imlib. It is NOT a newer version - it is a completely new library. Imlib
-2 can be installed alongside Imlib 1.x without any problems since they
-are effectively different libraries - BUT they Have very similar functionality.
-<p>Imlib 2 does the following:
-<ul>
-<li>
-Load image files from disk in one of many formats</li>
-
-<li>
-Save images to disk in one of many formats</li>
-
-<li>
-Render image data onto other images</li>
-
-<li>
-Render images to an X-Windows drawable</li>
-
-<li>
-Produce pixmaps and pixmap masks of Images</li>
-
-<li>
-Apply filters to images</li>
-
-<li>
-Rotate images</li>
-
-<li>
-Accept RGBA Data for images</li>
-
-<li>
-Scale images</li>
-
-<li>
-Alpha blend Images on other images or drawables</li>
-
-<li>
-Apply color correction and modification tables and factors to images</li>
-
-<li>
-Render images onto images with color correction and modification tables</li>
-
-<li>
-Render truetype anti-aliased text</li>
-
-<li>
-Render truetype anti-aliased text at any angle</li>
-
-<li>
-Render anti-aliased lines</li>
-
-<li>
-Render rectangles</li>
-
-<li>
-Render linear multi-colored gradients</li>
-
-<li>
-Cache data intelligently for maximum performance</li>
-
-<li>
-Allocate colors automatically</li>
-
-<li>
-Allow full control over caching and color allocation</li>
-
-<li>
-Provide highly optimized MMX assembly for core routines</li>
-
-<li>
-Provide plug-in filter interface</li>
-
-<li>
-Provide on-the-fly runtime plug-in image loading and saving interface</li>
-
-<li>
-Fastest image compositing, rendering and manipulation library for X</li>
-</ul>
-If what you want isn't in the list above somewhere then likely Imlib 2
-does not do it. If it does it it likely does it faster than any other library
-you can find (this includes gdk-pixbuf, gdkrgb, etc.) primarily because
-of highly optimized code and a smart subsystem that does the dirty work
-for you and picks up the pieces for you so you can be lazy and let all
-the optimizations for FOR you.
-<p>Imlib 2 can run without a display, so it can be easily used for background
-image processing for web sites or servers - it only requires the X libraries
-to be installed - that is all - it does not require an XServer to run unless
-you wish to display images.
-<p>The interface is simple - once you get used to it, the functions do
-exactly what they say they do.</td>
-
-<td><img SRC="img/blank.gif" height=1 width=1></td>
-</tr>
-
-<tr NOSAVE>
-<td WIDTH="1" NOSAVE><img SRC="img/blank.gif" height=1 width=1></td>
-
-<td NOSAVE><img SRC="img/blank.gif" height=1 width=1></td>
-
-<td WIDTH="1" NOSAVE><img SRC="img/blank.gif" height=1 width=1></td>
-</tr>
-</table></center>
-
-<br>
-<center><table BORDER=0 CELLSPACING=0 WIDTH="95%" BGCOLOR="#666666" NOSAVE ROWS="5" >
-<tr NOSAVE>
-<td WIDTH="1" NOSAVE><img SRC="img/blank.gif" height=1 width=1></td>
-
-<td NOSAVE><img SRC="img/blank.gif" height=1 width=1></td>
-
-<td WIDTH="1" NOSAVE><img SRC="img/blank.gif" height=1 width=1></td>
-</tr>
-
-<tr NOSAVE>
-<td WIDTH="1" NOSAVE><img SRC="img/blank.gif" height=1 width=1></td>
-
-<td ALIGN=CENTER VALIGN=CENTER NOSAVE><b><font color="#FFFFFF"><font size=+2>A
-Simple Example</font></font></b></td>
-
-<td WIDTH="1" NOSAVE><img SRC="img/blank.gif" height=1 width=1></td>
-</tr>
-
-<tr NOSAVE>
-<td WIDTH="1" NOSAVE><img SRC="img/blank.gif" height=1 width=1></td>
-
-<td NOSAVE><img SRC="img/blank.gif" height=1 width=1></td>
-
-<td WIDTH="1" NOSAVE><img SRC="img/blank.gif" height=1 width=1></td>
-</tr>
-
-<tr NOSAVE>
-<td><img SRC="img/blank.gif" height=1 width=1></td>
-
-<td VALIGN=TOP HEIGHT="100%" BGCOLOR="#6a7a8a" NOSAVE>The best way to start
-is to show a simple example of an Imlib2 program. This one will load an
-image of any format you have a loader installed for (all loaders are dynamic
-code objects that Imlib2 will use and update automatically runtime - anyone
-is free to write a loader. All that has to be done is for the object to
-be dropped into the loaders directory with the others and all Imlib2 programs
-will automatically be able to use it - without a restart).
-<blockquote>
-<pre><tt><font color="#660000">/* standard headers */
-#include &lt;X11/Xlib.h&gt;
-#include &lt;Imlib2.h&gt;
-#include &lt;stdio.h&gt;
-#include &lt;string.h&gt;
-
-/* main program */
-int main(int argc, char **argv)
-{
- /* an image handle */
- Imlib_Image image;
-
- /* if we provided &lt; 2 arguments after the command - exit */
- if (argc != 3) exit(1);
- /* load the image */
- image = imlib_load_image(argv[1]);
- /* if the load was successful */
- if (image)
- {
- char *tmp;
- /* set the image we loaded as the current context image to work on */
- imlib_context_set_image(image);
- /* set the image format to be the format of the extension of our last */
- /* argument - i.e. .png = png, .tif = tiff etc. */
- tmp = strrchr(argv[2], '.');
- if(tmp)
- imlib_image_set_format(tmp + 1);
- /* save the image */
- imlib_save_image(argv[2]);
- }
-}</font></tt></pre>
-Now to compile this
-<br>
-<tt><font color="#000099">cc imlib2_convert.c -o imlib2_convert `imlib2-config --cflags` `imlib2-config --libs`</font></tt>
-<br>
-You now have a program that if used as follows:
-<br>
-<tt><font color="#000099">./imlib2_convert image1.jpg image2.png</font></tt>
-<br>
-will convert image1.jpg into a png called image2.png. It is that simple.</blockquote>
-</td>
-
-<td><img SRC="img/blank.gif" height=1 width=1></td>
-</tr>
-
-<tr NOSAVE>
-<td WIDTH="1" NOSAVE><img SRC="img/blank.gif" height=1 width=1></td>
-
-<td NOSAVE><img SRC="img/blank.gif" height=1 width=1></td>
-
-<td WIDTH="1" NOSAVE><img SRC="img/blank.gif" height=1 width=1></td>
-</tr>
-</table></center>
-
-<br>
-<center><table BORDER=0 CELLSPACING=0 WIDTH="95%" BGCOLOR="#666666" NOSAVE ROWS="5" >
-<tr NOSAVE>
-<td WIDTH="1" NOSAVE><img SRC="img/blank.gif" height=1 width=1></td>
-
-<td NOSAVE><img SRC="img/blank.gif" height=1 width=1></td>
-
-<td WIDTH="1" NOSAVE><img SRC="img/blank.gif" height=1 width=1></td>
-</tr>
-
-<tr NOSAVE>
-<td WIDTH="1" NOSAVE><img SRC="img/blank.gif" height=1 width=1></td>
-
-<td ALIGN=CENTER VALIGN=CENTER NOSAVE><b><font color="#FFFFFF"><font size=+2>How
-Image Loading Works</font></font></b></td>
-
-<td WIDTH="1" NOSAVE><img SRC="img/blank.gif" height=1 width=1></td>
-</tr>
-
-<tr NOSAVE>
-<td WIDTH="1" NOSAVE><img SRC="img/blank.gif" height=1 width=1></td>
-
-<td NOSAVE><img SRC="img/blank.gif" height=1 width=1></td>
-
-<td WIDTH="1" NOSAVE><img SRC="img/blank.gif" height=1 width=1></td>
-</tr>
-
-<tr NOSAVE>
-<td><img SRC="img/blank.gif" height=1 width=1></td>
-
-<td VALIGN=TOP HEIGHT="100%" BGCOLOR="#6a7a8a" NOSAVE>It is probably a
-good idea to discuss how Imlib2 actually loads an Image so the programmer
-knows what is going on, how to take advantage of the optimizations already
-there and to explain why things work as they do.
-<br>
-<blockquote>
-<h3>
-Loading using imlib_load_image();</h3>
-This is likely to be by far the most common way to load an image - when
-you don't really care about the details of the loading process or why it
-failed - all you care about is if you got a valid image handle.
-<p>When you call this function Imlib2 attempts to find the file specified
-as the parameter. This will involve Imlib2 first checking to see if that
-file path already has been loaded and is in Imlib2's cache (a cache of
-already decoded images in memory to save having to load and decode from
-disk all the time). If there already is a copy in the cache (either already
-active or speculatively cached from a previous load &amp; free) this copy
-will have its handle returned instead of Imlib2 checking on disk (in some
-circumstances this is not true - see later in this section to find out).
-This means if your program blindly loads an Image, renders it, then frees
-it - then soon afterwards loads the same image again, it will not be loaded
-from disk at all, instead it will simply be re-referenced from the cache
-- meaning the load will be almost instant. A great way to take full advantage
-of this is to set the cache to some size you are happy with for the image
-data being used by your application and then all rendering o an image follows
-the pseudo code:
-<pre><tt><font color="#006600">set cache to some amount (e.g. 4 Mb)
-...
-rendering loop ...
- load image
- render image
- free image
-... continue loop</font></tt></pre>
-This may normally sound silly - load image, render then free - EVERY time
-we want to use it, BUT - it is actually the smartest way to use Imlib2
-- since the caching will find the image for you in the cache - you do not
-need to manage your own cache, or worry about filling up memory with image
-data - only as much memory as you have set for the cache size will actually
-ever be used to store image data - if you have lots of image data to work
-with then increase the cache size for better performance, but this is the
-only thing you need to worry about. you won't have problems of accidentally
-forgetting to free images later since you free them immediately after use.
-<p>Now what happens if the file changes on disk while it's in cache? By
-default nothing. The file is ignored. This is an optimization (to avoid
-hitting the disk to check if the file changed for every load if it's cached).
-You can inform Imlib2 that you care about this by using the <tt><font color="#660000">imlib_image_set_changes_on_disk();
-</font></tt><font color="#000000">call.
-Do this whenever you load an Image that you expect will change on disk,
-and the fact that it changes really matters. Remember this will marginally
-reduce the caching performance.</font>
-<p><font color="#000000">Now what actually happens when we try and load
-an image using a filename? First the filename is broken down into 2 parts.
-the filename before a colon (:) and the key after the colon. This means
-when we have a filename like:</font>
-<p><tt><font color="#000099">/path/to/file.jpg</font></tt>
-<p><font color="#000000">the filename is:</font>
-<p><tt><font color="#000099">/path/to/file.jpg</font></tt>
-<p><font color="#000000">and the key is blank. If we have:</font>
-<p><tt><font color="#000099">/path/to/file.db:key.value/blah</font></tt>
-<p><font color="#000000">the filename is:</font>
-<p><tt><font color="#000099">/path/to/file.db</font></tt>
-<p><font color="#000000">and the key is:</font>
-<p><tt><font color="#000099">key.value/blah</font></tt>
-<p><font color="#000000">You may ask what is this thing with keys and filenames?
-Well Imlib2 has loaders that are able to load data that is WITHIN a file
-(the loader capable of this right now is the database loader that is able
-to load image data stored with a key in a Berkeley-db database file). The
-colon is used to delimit where the filename ends and the key begins. Fro
-the majority of files you load you won't have to worry, but there is a
-limit in this case that filenames cannot contain a color character.</font>
-<p><font color="#000000">First Imlib2 checks to see if the file exists
-and that you have permission to read it. If this fails it will abort the
-load. Now that it has checked that this is the case it evaluates that it's
-list of dynamically loaded loader modules it up to date then it runs through
-the loader modules until one of them claims it can load this file. If this
-is the case that loader is now used to decode the image and return
-an Image handle to the calling program. If the loader is written correctly
-and the file format sanely supports this, the loader will NOT decode any
-image data at this point. It will ONLY read the header of the image to
-figure out its size, if it has an alpha channel, format and any other header
-information. The loader is remembered and it will be re-used to load the
-image data itself later if and ONLY if the actual image data itself is
-needed. This means you can scan vast directories of files figuring their
-format and size and other such information just by loading and freeing
-- and it will be fast because no image data is decoded. You can take advantage
-of this by loading the image and checking its size to calculate the size
-of an output area before you ever load the data. This means geometry
-calculations can be done fast ahead of time.</font>
-<p><font color="#000000">If you desire more detailed information about
-why a load failed you can use </font><tt><font color="#000099">imlib_load_image_with_error_return();
-</font></tt><font color="#000000">and
-it will return a detailed error return code.</font>
-<p><font color="#000000">If you do not wish to have the image data loaded
-later using the optimized "deferred" method of loading, you can force the
-data to be decoded immediately with </font><tt><font color="#000099">imlib_load_image_immediately();</font></tt>
-<p><font color="#000000">If you wish to bypass the cache when loading images
-you can using </font><tt><font color="#000099">imlib_load_image_without_cache();
-</font></tt><font color="#000000">and
-</font><tt><font color="#000099">imlib_load_image_immediately_without_cache();</font></tt><font color="#000000">.</font>
-<p><font color="#000000">Sometimes loading images can take a while. Often
-it is a good idea to provide feedback to the user whilst this is happening.
-This is when you set the progress function callback. Setting this to NULL
-will mean no progress function is called during load - this is the default.
-When it is set you set it to a function that will get called every so often
-(depending on the progress granularity) during load. Use </font><tt><font color="#000099">imlib_context_set_progress_function();</font></tt><font color="#000000">
-and </font><tt><font color="#000099">imlib_context_set_progress_granularity();
-</font></tt><font color="#000000">to
-set this up.</font></blockquote>
-</td>
-
-<td><img SRC="img/blank.gif" height=1 width=1></td>
-</tr>
-
-<tr NOSAVE>
-<td WIDTH="1" NOSAVE><img SRC="img/blank.gif" height=1 width=1></td>
-
-<td NOSAVE><img SRC="img/blank.gif" height=1 width=1></td>
-
-<td WIDTH="1" NOSAVE><img SRC="img/blank.gif" height=1 width=1></td>
-</tr>
-</table></center>
-
-<br>
-<center><table BORDER=0 CELLSPACING=0 WIDTH="95%" BGCOLOR="#666666" NOSAVE ROWS="5" >
-<tr NOSAVE>
-<td WIDTH="1" NOSAVE><img SRC="img/blank.gif" height=1 width=1></td>
-
-<td NOSAVE><img SRC="img/blank.gif" height=1 width=1></td>
-
-<td WIDTH="1" NOSAVE><img SRC="img/blank.gif" height=1 width=1></td>
-</tr>
-
-<tr NOSAVE>
-<td WIDTH="1" NOSAVE><img SRC="img/blank.gif" height=1 width=1></td>
-
-<td ALIGN=CENTER VALIGN=CENTER NOSAVE><b><font color="#FFFFFF"><font size=+2>A
-more advanced Example</font></font></b></td>
-
-<td WIDTH="1" NOSAVE><img SRC="img/blank.gif" height=1 width=1></td>
-</tr>
-
-<tr NOSAVE>
-<td WIDTH="1" NOSAVE><img SRC="img/blank.gif" height=1 width=1></td>
-
-<td NOSAVE><img SRC="img/blank.gif" height=1 width=1></td>
-
-<td WIDTH="1" NOSAVE><img SRC="img/blank.gif" height=1 width=1></td>
-</tr>
-
-<tr NOSAVE>
-<td><img SRC="img/blank.gif" height=1 width=1></td>
-
-<td VALIGN=TOP HEIGHT="100%" BGCOLOR="#6a7a8a" NOSAVE>This is a more comprehensive
-example that should show off a fair number of features of imlib2. The code
-this was based off can be found in Imlib2's test directory. This covers
-a lot of the core of Imlib2's API so you should have a pretty good idea
-on how it works if you understand this code snippet.
-<blockquote>
-<pre><tt><font color="#660000">/* include X11 stuff */
-#include &lt;X11/Xlib.h>
-/* include Imlib2 stuff */
-#include &lt;Imlib2.h>
-/* sprintf include */
-#include &lt;stdio.h>
-
-/* some globals for our window &amp; X display */
-Display *disp;
-Window win;
-Visual *vis;
-Colormap cm;
-int depth;
-
-/* the program... */
-int main(int argc, char **argv)
-{
- /* events we get from X */
- XEvent ev;
- /* areas to update */
- Imlib_Updates updates, current_update;
- /* our virtual framebuffer image we draw into */
- Imlib_Image buffer;
- /* a font */
- Imlib_Font font;
- /* our color range */
- Imlib_Color_Range range;
- /* our mouse x, y coordinates */
- int mouse_x = 0, mouse_y = 0;
-
- /* connect to X */
- 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));
- depth = DefaultDepth(disp, DefaultScreen(disp));
- cm = DefaultColormap(disp, DefaultScreen(disp));
- /* create a window 640x480 */
- 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);
- /* show the window */
- XMapWindow(disp, win);
- /* set our cache to 2 Mb so it doesn't have to go hit the disk as long as */
- /* the images we use use less than 2Mb of RAM (that is uncompressed) */
- imlib_set_cache_size(2048 * 1024);
- /* set the font cache to 512Kb - again to avoid re-loading */
- imlib_set_font_cache_size(512 * 1024);
- /* add the ./ttfonts dir to our font path - you'll want a notepad.ttf */
- /* in that dir for the text to display */
- imlib_add_path_to_font_path("./ttfonts");
- /* set the maximum number of colors to allocate for 8bpp and less to 128 */
- imlib_set_color_usage(128);
- /* dither for depths &lt; 24bpp */
- imlib_context_set_dither(1);
- /* set the display , visual, colormap and drawable we are using */
- imlib_context_set_display(disp);
- imlib_context_set_visual(vis);
- imlib_context_set_colormap(cm);
- imlib_context_set_drawable(win);
- /* 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, &amp;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, &amp;text_w, &amp;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, &amp;text_w, &amp;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,
- &amp;up_x, &amp;up_y, &amp;up_w, &amp;up_h);
-
- /* create our buffer image for rendering 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, &amp;text_w, &amp;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();
- }
-
- /* don't 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 temporary 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;
-}</font></tt></pre>
-</blockquote>
-</td>
-
-<td><img SRC="img/blank.gif" height=1 width=1></td>
-</tr>
-
-<tr NOSAVE>
-<td WIDTH="1" NOSAVE><img SRC="img/blank.gif" height=1 width=1></td>
-
-<td NOSAVE><img SRC="img/blank.gif" height=1 width=1></td>
-
-<td WIDTH="1" NOSAVE><img SRC="img/blank.gif" height=1 width=1></td>
-</tr>
-</table></center>
-
-<br>
-<center><table BORDER=0 CELLSPACING=0 WIDTH="95%" BGCOLOR="#666666" NOSAVE ROWS="5" >
-<tr NOSAVE>
-<td WIDTH="1" NOSAVE><img SRC="img/blank.gif" height=1 width=1></td>
-
-<td NOSAVE><img SRC="img/blank.gif" height=1 width=1></td>
-
-<td WIDTH="1" NOSAVE><img SRC="img/blank.gif" height=1 width=1></td>
-</tr>
-
-<tr NOSAVE>
-<td WIDTH="1" NOSAVE><img SRC="img/blank.gif" height=1 width=1></td>
-
-<td ALIGN=CENTER VALIGN=CENTER NOSAVE><b><font color="#FFFFFF"><font size=+2>API
-Reference</font></font></b></td>
-
-<td WIDTH="1" NOSAVE><img SRC="img/blank.gif" height=1 width=1></td>
-</tr>
-
-<tr NOSAVE>
-<td WIDTH="1" NOSAVE><img SRC="img/blank.gif" height=1 width=1></td>
-
-<td NOSAVE><img SRC="img/blank.gif" height=1 width=1></td>
-
-<td WIDTH="1" NOSAVE><img SRC="img/blank.gif" height=1 width=1></td>
-</tr>
-
-<tr NOSAVE>
-<td>
-<img SRC="img/blank.gif" height=1 width=1>
-</td>
-
-<td VALIGN=TOP HEIGHT="100%" BGCOLOR="#6a7a8a" NOSAVE><p>This is a list of
-all the Imlib2 API calls and what each of them do. You should familiarize
-yourself well with this API so you have a good idea of what can be done.</p>
-<b><tt><font color="#660000"><font size=+2>void imlib_context_set_display(Display *display);</font></font></tt></b>
-
-<blockquote>Sets the current X display to be used for rendering of images
-to drawables. You do not need to set this if you do not intend to render
-an image to an X drawable. If you do you will need to set this. If you
-change displays just set this to the new display pointer. Do not use a
-Display pointer if you have closed that display already - also note that
-if you close a display connection and continue to render using Imlib2 without
-setting the display pointer to NULL or something new, crashes may occur.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_context_set_visual(Visual *visual);</font></font></tt></b>
-
-<blockquote>This sets the current visual to use when rendering images to
-drawables or producing pixmaps. You need to set this for anything to render
-to a drawable or produce any pixmaps (this can be the default visual).</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_context_set_colormap(Colormap colormap);</font></font></tt></b>
-
-<blockquote>Sets the colormap to use when rendering to drawables and allocating
-colors. You must set this to the colormap you are using to render any images
-or produce any pixmaps (this can be the default colormap).</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_context_set_drawable(Drawable drawable);</font></font></tt></b>
-
-<blockquote>This sets the X drawable to which images will be rendered when
-you call a render call in Imlib2. This may be either a pixmap or a window.
-You must set this to render anything.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_context_set_mask(Pixmap mask);</font></font></tt></b>
-
-<blockquote>This sets the 1-bit deep pixmap to be drawn to when rendering
-to generate a mask pixmap. This is only useful if the image you are rendering
-has alpha. Set this to 0 to not render a pixmap mask.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_context_set_dither_mask(char dither_mask);</font></font></tt></b>
-
-<blockquote>Selects if, you are rendering to a mask, or producing pixmap
-masks from images, if the mask is to be dithered or not. passing in 1 for
-dither_mask means the mask pixmap will be dithered, 0 means it will not
-be dithered.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_context_set_anti_alias(char anti_alias);</font></font></tt></b>
-
-<blockquote>Toggles "anti-aliased" scaling of images. This isn't quite
-correct since it's actually super and sub pixel sampling that it turns
-on and off, but anti-aliasing is used for having "smooth" edges to lines
-and shapes and this means when images are scaled they will keep their smooth
-appearance. Passing in 1 turns this on and 0 turns it off.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_context_set_dither(char dither);</font></font></tt></b>
-
-<blockquote>Sets the dithering flag for rendering to a drawable or when
-pixmaps are produced. This affects the color image appearance by enabling
-dithering. Dithering slows down rendering but produces considerably better
-results. this option has no effect foe rendering in 24 bit and up, but
-in 16 bit and lower it will dither, producing smooth gradients and much
-better quality images. setting dither to 1 enables it and 0 disables it.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_context_set_blend(char blend);</font></font></tt></b>
-
-<blockquote>When rendering an image to a drawable, Imlib2 is able to blend
-the image directly onto the drawable during rendering. setting this to
-1 will enable this. If the image has no alpha channel this has no effect.
-Setting it to 0 will disable this.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_context_set_color_modifier(Imlib_Color_Modifier color_modifier);</font></font></tt></b>
-
-<blockquote>This sets the current color modifier used for rendering pixmaps
-or images to a drawable or images onto other images. Color modifiers are
-lookup tables that map the values in the red, green, blue and alpha channels
-to other values in the same channel when rendering, allowing for fades,
-color correction etc. to be done whilst rendering. pass in NULL as the
-color_modifier to disable the color modifier for rendering.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_context_set_operation(Imlib_Operation operation);</font></font></tt></b>
-
-<blockquote>When Imlib2 draws an image onto another or an image onto a
-drawable it is able to do more than just blend the result on using the
-given alpha channel of the image. It is also able to do saturating additive,
-subtractive and a combination of the both (called reshade) rendering. The
-default mode is IMLIB_OP_COPY. you can also set it to IMLIB_OP_ADD, IMLIB_OP_SUBTRACT
-or IMLIB_OP_RESHADE. Use this function to set the rendering operation.
-IMLIB_OP_COPY performs basic alpha blending: DST = (SRC * A) + (DST * (1
-- A)). IMLIB_OP_ADD does DST = DST + (SRC * A). IMLIB_OP_SUBTRACT does
-DST = DST - (SRC * A) and IMLIB_OP_RESHADE does DST = DST + (((SRC - 0.5)
-/ 2) * A).</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_context_set_font(Imlib_Font font);</font></font></tt></b>
-
-<blockquote>This function sets the current font to use when rendering text.
-you should load the font first with imlib_load_font().</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_context_set_direction(Imlib_Text_Direction direction);</font></font></tt></b>
-
-<blockquote>This sets the direction in which to draw text in terms of simple
-90 degree orientations or an arbitrary angle. The direction can be one
-of IMLIB_TEXT_TO_RIGHT, IMLIB_TEXT_TO_LEFT, IMLIB_TEXT_TO_DOWN, IMLIB_TEXT_TO_UP
-or IMLIB_TEXT_TO_ANGLE. The default is IMLIB_TEXT_TO_RIGHT. If you use
-IMLIB_TEXT_TO_ANGLE, you will also have to set the angle with imlib_context_set_angle().</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_context_set_angle(double angle);</font></font></tt></b>
-
-<blockquote>This sets the angle at which text strings will be drawn if
-the text direction has been set to IMLIB_TEXT_TO_ANGLE with imlib_context_set_direction().</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_context_set_color(int red, int green, int blue, int alpha);</font></font></tt></b>
-
-<blockquote>This sets the color with which text, lines and rectangles are
-drawn when being rendered onto an image. Values for red, green, blue and
-alpha are between 0 and 255 - any other values have undefined results.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_context_set_color_cmya(int cyan, magenta, int yellow, int alpha);</font></font></tt></b>
-
-<blockquote>This sets the color in CMYA space. Values for cyan, magenta,
-yellow and alpha are between 0 and 255 - any other values have undefined results.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_context_set_color_hsva(float hue, float saturation, float value, int alpha);</font></font></tt></b>
-
-<blockquote>This sets the color in HSVA space. Values for hue are between 0 and 360,
-values for saturation and value between 0 and 1, and values for alpha are between 0
-and 255 - any other values have undefined results.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_context_set_color_hlsa(float hue, float lightness, float saturation, int alpha);</font></font></tt></b>
-
-<blockquote>This sets the color in HLSA space. Values for hue are between 0 and 360,
-values for lightness and saturation between 0 and 1, and values for alpha are
-between 0 and 255 - any other values have undefined results.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_context_set_color_range(Imlib_Color_Range color_range);</font></font></tt></b>
-
-<blockquote>This sets the current color range to use for rendering gradients.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_context_set_progress_function(Imlib_Progress_Function progress_function);</font></font></tt></b>
-
-<blockquote>This sets the progress function to be called back whilst loading
-images. Set this to the function to be called, or set it to NULL to disable
-progress callbacks whilst loading.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_context_set_progress_granularity(char progress_granularity);</font></font></tt></b>
-
-<blockquote>This hints as to how often to call the progress callback. 0
-means as often as possible. 1 means whenever 15 more of the image has been
-decoded, 10 means every 10% of the image decoding, 50 means every 50% and
-100 means only call at the end. Values outside of the range 0-100 are undefined.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_context_set_image(Imlib_Image image);</font></font></tt></b>
-
-<blockquote>This sets the current image Imlib2 will be using with its function
-calls.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_context_set_filter(Imlib_Filter filter);</font></font></tt></b>
-
-<blockquote>This sets the current filter to be used when applying filters
-to images. Set this to NULL to disable filters.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>Display *imlib_context_get_display(void);</font></font></tt></b>
-
-<blockquote>This returns the current display used for Imlib2's display
-context.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>Visual *imlib_context_get_visual(void);</font></font></tt></b>
-
-<blockquote>Returns the current visual used for Imlib2's context.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>Colormap imlib_context_get_colormap(void);</font></font></tt></b>
-
-<blockquote>Returns the current Colormap used for Imlib2's context.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>Drawable imlib_context_get_drawable(void);</font></font></tt></b>
-
-<blockquote>Returns the current Drawable used for Imlib2's context.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>Pixmap imlib_context_get_mask(void);</font></font></tt></b>
-
-<blockquote>Returns the current pixmap destination to be used to render
-a mask into.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>char imlib_context_get_dither_mask(void);</font></font></tt></b>
-
-<blockquote>Returns the current mode for dithering pixmap masks. 1 means
-dithering is enabled and 0 means it is not.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>char imlib_context_get_anti_alias(void);</font></font></tt></b>
-
-<blockquote>Returns if Imlib2 currently will smoothly scale images. 1 means
-it will and 0 means it will not.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>char imlib_context_get_dither(void);</font></font></tt></b>
-
-<blockquote>Returns if image data is rendered with dithering currently.
-1 means yes and 0 means no.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>char imlib_context_get_blend(void);</font></font></tt></b>
-
-<blockquote>Returns if Imlib2 will blend images onto a drawable whilst
-rendering to that drawable. 1 means yes and 0 means no.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>Imlib_Color_Modifier imlib_context_get_color_modifier(void);</font></font></tt></b>
-
-<blockquote>Returns the current colormodifier being used.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>Imlib_Operation imlib_context_get_operation(void);</font></font></tt></b>
-
-<blockquote>Returns the current operation mode.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>Imlib_Font imlib_context_get_font(void);</font></font></tt></b>
-
-<blockquote>Returns the current font.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>double imlib_context_get_angle(void);</font></font></tt></b>
-
-<blockquote>Returns the current angle used to render text at if the direction
-is IMLIB_TEXT_TO_ANGLE.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>Imlib_Text_Direction imlib_context_get_direction(void);</font></font></tt></b>
-
-<blockquote>Returns the current direction to render text in.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_context_get_color(int *red, int *green, int *blue, int *alpha);</font></font></tt></b>
-
-<blockquote>Returns the current color for rendering text, rectangles and
-lines.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_context_get_color_cmya(int *cyan, int *magenta, int *yellow, int *alpha);</font></font></tt></b>
-
-<blockquote>Returns the current color for rendering text, rectangles and
-lines in CMYA space.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_context_get_color_hsva(float *hue, float *saturation, float *value, int *alpha);</font></font></tt></b>
-
-<blockquote>Returns the current color for rendering text, rectangles and
-lines in HSVA space.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_context_get_color_hlsa(float *hue, float * lightness, float *saturation, int *alpha);</font></font></tt></b>
-
-<blockquote>Returns the current color for rendering text, rectangles and
-lines in HLSA space.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>Imlib_Color *imlib_context_get_imlib_color(void);</font></font></tt></b>
-
-<blockquote>Returns the current color as a color struct. Do NOT free this
-pointer.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>Imlib_Color_Range imlib_context_get_color_range(void);</font></font></tt></b>
-
-<blockquote>Return the current color range being used for gradients.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>Imlib_Progress_Function imlib_context_get_progress_function(void);</font></font></tt></b>
-
-<blockquote>Return the current progress function being used.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>char imlib_context_get_progress_granularity(void);</font></font></tt></b>
-
-<blockquote>Get the current progress granularity being used.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>Imlib_Image imlib_context_get_image(void);</font></font></tt></b>
-
-<blockquote>Return the current context image.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>Imlib_Filter imlib_context_get_filter(void);</font></font></tt></b>
-
-<blockquote>Get the current context image filter.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>int imlib_get_cache_size(void);</font></font></tt></b>
-
-<blockquote>Return the current size of the image cache in bytes. The cache
-is a unified cache used for image data AND pixmaps.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_set_cache_size(int bytes);</font></font></tt></b>
-
-<blockquote>Set the cache size. The size is in bytes. Setting the cache
-size to 0 effectively flushes the cache and keeps the cache size at 0 until
-set to another value. Whenever you set the cache size Imlib2 will flush
-as many old images and pixmap from the cache as needed until the current
-cache usage is less than or equal to the cache size.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>int imlib_get_color_usage(void);</font></font></tt></b>
-
-<blockquote>Get the number of colors Imlib2 currently at a maximum is allowed
-to allocate for rendering. The default is 256.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_set_color_usage(int max);</font></font></tt></b>
-
-<blockquote>Set the maximum number of colors you would like Imlib2 to allocate
-for you when rendering. The default ids 256. This has no effect in depths
-greater than 8 bit.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_flush_loaders(void);</font></font></tt></b>
-
-<blockquote>If you want Imlib2 to forcibly flush any cached loaders it
-has and re-load them from disk (this is useful if the program just installed
-a new loader and does not want to wait till Imlib2 deems it an optimal
-time to rescan the loaders)</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>int imlib_get_visual_depth(Display *display, Visual *visual);</font></font></tt></b>
-
-<blockquote>Convenience function that returns the depth of a visual for
-that display.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>Visual *imlib_get_best_visual(Display *display, int screen, int *depth_return);</font></font></tt></b>
-
-<blockquote>Returns the visual for that display and screen that Imlib2
-thinks will give you the best quality output. depth_return should point
-to an int that will be filled with the depth of that visual too.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>Imlib_Image imlib_load_image(const char *file);</font></font></tt></b>
-
-<blockquote>This function loads an image from disk located at the path
-specified by file. Please see the "How image loading works" section for
-more detail. Returns an image handle on success or NULL on failure.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>Imlib_Image imlib_load_image_immediately(const char *file);</font></font></tt></b>
-
-<blockquote>Loads an image from disk located at the path specified by file.
-This forces the image data to be decoded at load time too, instead of decoding
-being deferred until it is needed. Returns an image handle on success or
-NULL on failure.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>Imlib_Image imlib_load_image_without_cache(const char *file);</font></font></tt></b>
-
-<blockquote>This loads the image without looking in the cache first. Returns
-an image handle on success or NULL on failure.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>Imlib_Image imlib_load_image_immediately_without_cache(const char *file);</font></font></tt></b>
-
-<blockquote>Loads the image without deferred image data decoding (i.e.
-it is decoded straight away) and without looking in the cache. Returns
-an image handle on success or NULL on failure.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>Imlib_Image imlib_load_image_with_error_return(const char *file, Imlib_Load_Error *error_return);</font></font></tt></b>
-
-<blockquote>This loads an image at the path file on disk. If it succeeds
-it returns a valid image handle, if not NULL is returned and the error_return
-pointed to is set to the detail of the error.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_free_image(void);</font></font></tt></b>
-
-<blockquote>This frees the image that is set as the current image in Imlib2's
-context.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_free_image_and_decache(void);</font></font></tt></b>
-
-<blockquote>Frees the current image in Imlib2's context AND removes it
-from the cache.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>int imlib_image_get_width(void);</font></font></tt></b>
-
-<blockquote>Returns the width in pixels of the current image in Imlib2's
-context.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>int imlib_image_get_height(void);</font></font></tt></b>
-
-<blockquote>Returns the height in pixels of the current image in Imlib2's
-context.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>const char *imlib_image_get_filename(void);</font></font></tt></b>
-
-<blockquote>This returns the filename for the file that is set as the current
-context. The pointer returned is only valid as long as no operations cause
-the filename of the image to change. Saving the file with a different name
-would cause this. It is suggested you duplicate the string if you wish
-to continue to use the string for later processing. Do not free the string
-pointer returned by this function.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>DATA32 *imlib_image_get_data(void);</font></font></tt></b>
-
-<blockquote>This returns a pointer to the image data in the image set as
-the image for the current context. When you get this pointer it is assumed
-you are planning on writing to the data, thus once you do this the image
-can no longer be used for caching - in fact all images cached from this
-one will also be affected when you put the data back. If this matters it
-is suggested you clone the image first before playing with the image data.
-The image data is returned in the format of a DATA32 (32 bits) per pixel
-in a linear array ordered from the top left of the image to the bottom
-right going from left to right each line. Each pixel has the upper 8 bits
-as the alpha channel and the lower 8 bits are the blue channel - so a pixel's
-bits are ARGB (from most to least significant, 8 bits per channel). You
-must put the data back at some point.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>DATA32 *imlib_image_get_data_for_reading_only(void);</font></font></tt></b>
-
-<blockquote>This functions the same way as imlib_image_get_data(), but
-returns a pointer expecting the program to NOT write to the data returned
-(it is for inspection purposes only). Writing to this data has undefined
-results. The data does not need to be put back.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_image_put_back_data(DATA32 *data);</font></font></tt></b>
-
-<blockquote>This will put back data when it was obtained by imlib_image_get_data().
-The data must be the same pointer returned by imlib_image_get_data(). This
-operated on the current context image.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>char imlib_image_has_alpha(void);</font></font></tt></b>
-
-<blockquote>Returns 1 if the current context image has an alpha channel,
-or 0 if it does not (the alpha data space is still there and available
-- just "unused").</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_image_set_changes_on_disk(void);</font></font></tt></b>
-
-<blockquote>By default Imlib2 will not check the timestamp of an image
-on disk and compare it with the image in its cache - this is to minimize
-disk activity when using the cache. Call this function and it will flag
-the current context image as being liable to change on disk and Imlib2
-will check the timestamp of the image file on disk and compare it with
-the cached image when it next needs to use this image in the cache.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_image_get_border(Imlib_Border *border);</font></font></tt></b>
-
-<blockquote>This function fills the Imlib_Border structure to which border
-points to with the values of the border of the current context image. The
-border is the area at the edge of the image that does not scale with the
-rest of the image when resized - the borders remain constant in size. This
-is useful for scaling bevels at the edge of images differently to the image
-center.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_image_set_border(Imlib_Border *border);</font></font></tt></b>
-
-<blockquote>This sets the border of the current context image to the values
-contained in the Imlib_Border structure border points to.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_image_set_format(const char *format);</font></font></tt></b>
-
-<blockquote>This sets the format of the current image. This is used for
-when you wish to save an image in a different format that it was loaded
-in, or if the image currently has no file format associated with it.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_image_set_irrelevant_format(char irrelevant);</font></font></tt></b>
-
-<blockquote>This sets if the format value of the current image is irrelevant
-for caching purposes - by default it is. pass irrelevant as 1 to make it
-irrelevant and 0 to make it relevant for caching.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_image_set_irrelevant_border(char irrelevant);</font></font></tt></b>
-
-<blockquote>This sets if the border of the current image is irrelevant
-for caching purposes. By default it is. Set irrelevant to 1 to make it
-irrelevant, and 0 to make it relevant.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_image_set_irrelevant_alpha(char irrelevant);</font></font></tt></b>
-
-<blockquote>This sets if the alpha channel status of the current image
-(i.e. if there is or is not one) is important for caching purposes. By
-default it is not. Set irrelevant to 1 to make it irrelevant and 0 to make
-it relevant.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>char *imlib_image_format(void);</font></font></tt></b>
-
-<blockquote>This returns the current image's format. Do not free this string.
-Duplicate it if you need it for later use.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_image_set_has_alpha(char has_alpha);</font></font></tt></b>
-
-<blockquote>Sets the alpha flag for the current image. Set has_alpha to
-1 to enable the alpha channel in the current image, or 0 to disable it.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_render_pixmaps_for_whole_image(Pixmap *pixmap_return, Pixmap *mask_return);</font></font></tt></b>
-
-<blockquote>This function will create a pixmap of the current image (and
-a mask if the image has an alpha value) and return the id's of the pixmap
-and mask to the pixmap_return and mask_return pixmap id's. You must free
-these pixmaps using Imlib2's free function imlib_free_pixmap_and_mask();.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_render_pixmaps_for_whole_image_at_size(Pixmap *pixmap_return, Pixmap *mask_return, int width, int height);</font></font></tt></b>
-
-<blockquote>This function works just like imlib_render_pixmaps_for_whole_image(),
-but will scale the output result to the width and height specified. Scaling
-is done before depth conversion so pixels used for dithering don't grow
-large.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_free_pixmap_and_mask(Pixmap pixmap);</font></font></tt></b>
-
-<blockquote>This will free the pixmap (and any mask generated in association
-with that pixmap). The pixmap will remain cached until the image the pixmap
-was generated from is dirtied or decached, or the cache is flushed.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_render_image_on_drawable(int x, int y);</font></font></tt></b>
-
-<blockquote>This renders the current image onto the current drawable at
-the x, y pixel location specified without scaling.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_render_image_on_drawable_at_size(int x, int y, int width, int height);</font></font></tt></b>
-
-<blockquote>This will render the current image onto the current drawable
-at the x, y location specified AND scale the image to the width and height
-specified.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_render_image_part_on_drawable_at_size(int source_x, int source_y, int source_width, int source_height, int x, int y, int width, int height);</font></font></tt></b>
-
-<blockquote>This renders the source x, y, width, height pixel rectangle
-from the current image onto the current drawable at the x, y location scaled
-to the width and height specified.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_blend_image_onto_image(Imlib_Image source_image, char merge_alpha, int source_x, int source_y, int source_width, int source_height, int destination_x, int destination_y, int destination_width, int destination_height);</font></font></tt></b>
-
-<blockquote>This will blend the source rectangle x, y, width, height from
-the source_image onto the current image at the destination x, y location
-scaled to the width and height specified. If merge_alpha is set to 1 it
-will also modify the destination image alpha channel, otherwise the destination
-alpha channel is left untouched.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>Imlib_Image imlib_create_image(int width, int height);</font></font></tt></b>
-
-<blockquote>This creates a new blank image of size width and height. The
-contents of this image at creation time are undefined (they could be garbage
-memory). You are free to do whatever you like with this image. It is not
-cached. On success an image handle is returned - on failure NULL is returned.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>Imlib_Image imlib_create_image_using_data(int width, int height, DATA32 *data);</font></font></tt></b>
-
-<blockquote>This creates an image from the image data specified with the
-width and height specified. The image data must be in the same format as
-imlib_image_get_data() would return. You are responsible for freeing this
-image data once the image is freed - Imlib2 will not do that for you. This
-is useful for when you already have static buffers of the same format Imlib2
-uses (many video grabbing devices use such a format) and wish to use Imlib2
-to render the results onto another image, or X drawable. You should free
-the image when you are done with it. Imlib2 returns a valid image handle
-on success or NULL on failure</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>Imlib_Image imlib_create_image_using_copied_data(int width,
- int height,
- DATA32 *data);</font></font></tt></b>
-
-<blockquote>This works the same way as imlib_create_image_using_data()
-but Imlib2 copies the image data to the image structure. You may now do
-whatever you wish with the original data as it will not be needed anymore.
-Imlib2 returns a valid image handle on success or NULL on failure.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>Imlib_Image imlib_create_image_from_drawable(Pixmap mask,
- int x,
- int y,
- int width,
- int height,
- char need_to_grab_x);</font></font></tt></b>
-
-<blockquote>This will return an image (using the mask to determine the
-alpha channel) from the current drawable. If the mask is 0 it will not
-create a useful alpha channel in the image. It will create an image from
-the x, y, width , height rectangle in the drawable. If need_to_grab_x is
-1 it will also grab the X Server to avoid possible race conditions in grabbing.
-If you have not already grabbed the server you MUST set this to 1. Imlib2
-returns a valid image handle on success or NULL on failure.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>Imlib_Image imlib_create_scaled_image_from_drawable(Pixmap mask,
- int source_x,
- int source_y,
- int source_width,
- int source_height,
- int destination_width,
- int destination_height,
- char need_to_grab_x,
- char get_mask_from_shape);</font></font></tt></b>
-
-<blockquote>This will create an image from the current drawable (optionally
-using the mask pixmap specified to determine alpha transparency) and scale
-the grabbed data first before converting to an actual image (to minimize
-reads from the frame buffer which can be slow). The source x, y, width,
-height rectangle will be grabbed, scaled to the destination width and height,
-then converted to an image. If need_to_grab_x is set to 1, X is grabbed
-(set this to 1 unless you have already grabbed the server) and if get_mask_from_shape
-and the current drawable is a window its shape is used for determining
-the alpha channel. If successful this function will return a valid image
-handle, otherwise NULL is returned.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>char 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);</font></font></tt></b>
-
-<blockquote>This routine will grab a section of the current drawable (optionally
-using the pixmap provided as a corresponding mask for that drawable - if
-mask is 0 this is not used). It grabs the x, y, width, height rectangle
-and places it at the destination x, y location in the current image. If
-need_to_grab_x is 1 it will grab and ungrab the server whilst doing this
-- you need to do this if you have not already grabbed the server.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>Imlib_Image imlib_clone_image(void);</font></font></tt></b>
-
-<blockquote>This creates an exact duplicate of the current image and returns
-a valid image handle on success, or NULL on failure.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>Imlib_Image imlib_create_cropped_image(int x,
- int y,
- int width,
- int height);</font></font></tt></b>
-
-<blockquote>This creates a duplicate of a x, y, width, height rectangle
-in the current image and returns a valid image handle on success, or NULL
-on failure.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>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);</font></font></tt></b>
-
-<blockquote>This function works the same as imlib_create_cropped_image()
-but will scale the new image to the new destination width and height whilst
-cropping.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>Imlib_Updates imlib_updates_clone(Imlib_Updates updates);</font></font></tt></b>
-
-<blockquote>This function creates a duplicate of the updates list passed
-into the function.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>Imlib_Updates imlib_update_append_rect(Imlib_Updates updates,
- int x,
- int y,
- int w,
- int h);</font></font></tt></b>
-
-<blockquote>This function appends an update rectangle to the updates list
-passed in (if the updates is NULL it will create a new updates list) and
-returns a handle to the modified updates list (the handle may be modified
-so only use the new updates handle returned)</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>Imlib_Updates imlib_updates_merge(Imlib_Updates updates,
- int w,
- int h);</font></font></tt></b>
-
-<blockquote>This function takes an updates list, and modifies it by merging
-overlapped rectangles and lots of tiny rectangles into larger rectangles
-to minimize the number of rectangles in the list for optimized redrawing.
-The new updates handle is now valid and the old one passed in is not.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>Imlib_Updates imlib_updates_merge_for_rendering(Imlib_Updates updates,
- int w,
- int h);</font></font></tt></b>
-
-<blockquote>This works almost exactly as imlib_updates_merge() but is more
-lenient on the spacing between update rectangles - if they are very close
-it amalgamates 2 smaller rectangles into 1 larger one.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_updates_free(Imlib_Updates updates);</font></font></tt></b>
-
-<blockquote>This frees an updates list.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>Imlib_Updates imlib_updates_get_next(Imlib_Updates updates);</font></font></tt></b>
-
-<blockquote>This gets the next update in the updates list relative to the
-one passed in.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_updates_get_coordinates(Imlib_Updates updates,
- int *x_return,
- int *y_return,
- int *width_return,
- int *height_return);</font></font></tt></b>
-
-<blockquote>This returns the coordinates of an update.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_updates_set_coordinates(Imlib_Updates updates,
- int x,
- int y,
- int width,
- int height);</font></font></tt></b>
-
-<blockquote>This modifies the coordinates of an update in an updates list.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_render_image_updates_on_drawable(Imlib_Updates updates,
- int x,
- int y);</font></font></tt></b>
-
-<blockquote>Given an updates list (preferable already merged for rendering)
-this will render the corresponding parts of the image to the current drawable
-at an offset of x, y in the drawable.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>Imlib_Updates imlib_updates_init(void);</font></font></tt></b>
-
-<blockquote>This initializes an updates list before you add any updates
-to it or merge it for rendering etc.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>Imlib_Updates imlib_updates_append_updates(Imlib_Updates updates,
- Imlib_Updates appended_updates);</font></font></tt></b>
-
-<blockquote>This appends one updates list (appended_updates) to the updates
-list (updates) and returns the new list.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_image_flip_horizontal(void);</font></font></tt></b>
-
-<blockquote>This will flip/mirror the current image horizontally.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_image_flip_vertical(void);</font></font></tt></b>
-
-<blockquote>This will flip/mirror the current image vertically.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_image_flip_diagonal(void);</font></font></tt></b>
-
-<blockquote>This will flip/mirror the current image diagonally (good for
-quick and dirty 90 degree rotations if used before to after a horizontal
-or vertical flip).</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_image_orientate(int orientation);</font></font></tt></b>
-
-<blockquote>This will perform 90 degree rotations on the current image.
-Passing in orientation does not rotate, 1 rotates clockwise by 90 degree,
-2, rotates clockwise by 180 degrees, 3 rotates clockwise by 270 degrees.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_image_blur(int radius);</font></font></tt></b>
-
-<blockquote>This will blur the current image. A radius of 0 has no effect,
-1 and above determine the blur matrix radius that determine how much to
-blur the image.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_image_sharpen(int radius);</font></font></tt></b>
-
-<blockquote>This sharpens the current image. The radius affects how much
-to sharpen by.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_image_tile_horizontal(void);</font></font></tt></b>
-
-<blockquote>This modifies an image so it will tile seamlessly horizontally
-if used as a tile (i.e. drawn multiple times horizontally)</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_image_tile_vertical(void);</font></font></tt></b>
-
-<blockquote>This modifies an image so it will tile seamlessly vertically
-if used as a tile (i.e. drawn multiple times vertically)</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_image_tile(void);</font></font></tt></b>
-
-<blockquote>This modifies an image so it will tile seamlessly horizontally
-and vertically if used as a tile (i.e. drawn multiple times horizontally
-and vertically)</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>Imlib_Font imlib_load_font(const char *font_name);</font></font></tt></b>
-
-<blockquote>This function will load a truetype font from the first directory
-in the font path that contains that font. The font name format is "font_name/size".
-For example. If there is a font file called blum.ttf somewhere in the font
-path you might use "blum/20" to load a 20 pixel sized font of blum. If
-the font cannot be found NULL is returned.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_free_font(void);</font></font></tt></b>
-
-<blockquote>This frees the current font.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_text_draw(int x, int y, const char *text);</font></font></tt></b>
-
-<blockquote>Call this function to draw the null-byte terminated string text
-using the current font on the current image at the x, y location (x, y
-denoting the top left corner of the font string)</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_text_draw_with_return_metrics(int x,
- int y,
- const char *text,
- int *width_return,
- int *height_return,
- int *horizontal_advance_return,
- int *vertical_advance_return);</font></font></tt></b>
-
-<blockquote>This function works just like imlib_text_draw() but also returns
-the width and height of the string drawn, and horizontal_advance_return
-returns the number of pixels you should advance horizontally to draw another
-string (useful if you are drawing a line of text word by word) and vertical_advance_return
-does the same for the vertical direction (i.e. drawing text line by line).</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_get_text_size(const char *text,
- int *width_return,
- int *height_return);</font></font></tt></b>
-
-<blockquote>This function returns the width and height in pixels the text
-string would use up if drawn with the current font.</blockquote>
-
-
-<b><tt><font color="#660000"><font size=+2>void imlib_get_text_advance(const char *text,
- int *horizontal_advance_return,
- int *vertical_advance_return);</font></font></tt></b>
-
-<blockquote>This function returns the advance horizontally and vertically
-in pixels the next text string would need to be placed at for the current
-font. The advances are not adjusted for rotation so you will have to translate
-the advances (which are calculated as if the text was drawn horizontally
-from left to right) depending on the text orientation.</blockquote>
-
-
-<b><tt><font color="#660000"><font size=+2>int imlib_get_text_inset(const char *text);</font></font></tt></b>
-
-<blockquote>This function returns the inset of the first character of the
-text string passed in using the current font and returns that value in pixels.
-</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_add_path_to_font_path(const char *path);</font></font></tt></b>
-
-<blockquote>This function adds the directory path to the end of the current
-list of directories to scan for fonts.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_remove_path_from_font_path(const char *path);</font></font></tt></b>
-
-<blockquote>This function removes all directories in the font path that
-match the path specified.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>char **imlib_list_font_path(int *number_return);</font></font></tt></b>
-
-<blockquote>This returns a list of strings that are the directories in
-the font path. Do not free this list or change it in any way. If you add
-or delete members of the font path this list will be invalid. If you intend
-to use this list later duplicate it for your own use. The number of elements
-in the array of strings is put into number_return.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>int imlib_text_get_index_and_location(const char *text,
- int x,
- int y,
- int *char_x_return,
- int *char_y_return,
- int *char_width_return,
- int *char_height_return);</font></font></tt></b>
-
-<blockquote>This will return the character number in the string text using
-the current font at the x, y pixel location which is an offset relative
-to the top left of that string. -1 is returned if there is no character
-there. If there is a character, character x, y, width and height are also
-filled in.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_text_get_location_at_index(const char *text,
- int index,
- int *char_x_return,
- int *char_y_return,
- int *char_width_return,
- int *char_height_return);</font></font></tt></b>
-
-<blockquote>This will return the geometry of the character at index index
-in the text string using the current font.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>char **imlib_list_fonts(int *number_return);</font></font></tt></b>
-
-<blockquote>This returns a list of fonts imlib2 can find in its font path.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_free_font_list(char **font_list,
- int number);</font></font></tt></b>
-
-<blockquote>This will free the font list returned by imlib_list_fonts().</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>int imlib_get_font_cache_size(void);</font></font></tt></b>
-
-<blockquote>This returns the font cache size in bytes.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_set_font_cache_size(int bytes);</font></font></tt></b>
-
-<blockquote>This sets the font cache in bytes. Whenever you set the font
-cache size Imlib2 will flush fonts from the cache until the memory used
-by fonts is less than or equal to the font cache size. Setting the size
-to 0 effectively frees all speculatively cached fonts.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_flush_font_cache(void);</font></font></tt></b>
-
-<blockquote>This will cause a flush of all speculatively cached fonts from
-the font cache.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>int imlib_get_font_ascent(void);</font></font></tt></b>
-
-<blockquote>Returns the current font's ascent value in pixels.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>int imlib_get_font_descent(void);</font></font></tt></b>
-
-<blockquote>Returns the current font's descent value in pixels.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>int imlib_get_maximum_font_ascent(void);</font></font></tt></b>
-
-<blockquote>Returns the current font's maximum ascent extent.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>int imlib_get_maximum_font_descent(void);</font></font></tt></b>
-
-<blockquote>Returns the current font's maximum descent extent.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>Imlib_Color_Modifier imlib_create_color_modifier(void);</font></font></tt></b>
-
-<blockquote>This function creates a new empty color modifier and returns
-a valid handle on success. NULL is returned on failure.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_free_color_modifier(void);</font></font></tt></b>
-
-<blockquote>Calling this function frees the current color modifier.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_modify_color_modifier_gamma(double gamma_value);</font></font></tt></b>
-
-<blockquote>This function modifies the current color modifier by adjusting
-the gamma by the value specified. The color modifier is modified not set,
-so calling this repeatedly has cumulative effects. A gamma of 1.0 is normal
-linear, 2.0 brightens and 0.5 darkens etc. Negative values are not allows.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_modify_color_modifier_brightness(double brightness_value);</font></font></tt></b>
-
-<blockquote>This function modifies the current color modifier by adjusting
-the brightness by the value specified. The color modifier is modified not
-set, so calling this repeatedly has cumulative effects. brightness values
-of 0 do not affect anything. -1.0 will make things completely black and
-1.0 will make things all white. Values in-between vary brightness linearly.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_modify_color_modifier_contrast(double contrast_value);</font></font></tt></b>
-
-<blockquote>This function modifies the current color modifier by adjusting
-the contrast by the value specified. The color modifier is modified not
-set, so calling this repeatedly has cumulative effects. Contrast of 1.0
-does nothing. 0.0 will merge to gray, 2.0 will double contrast etc.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_set_color_modifier_tables(DATA8 *red_table,
- DATA8 *green_table,
- DATA8 *blue_table,
- DATA8 *alpha_table);</font></font></tt></b>
-
-<blockquote>This function explicitly copies the mapping tables from the
-table pointers passed into this function into those of the current color
-modifier. Tables are 256 entry arrays of DATA8 which are a mapping of that
-channel value to a new channel value. A normal mapping would be linear
-(v[0] = 0, v[10] = 10, v[50] = 50, v[200] = 200, v[255] = 255).</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_get_color_modifier_tables(DATA8 *red_table,
- DATA8 *green_table,
- DATA8 *blue_table,
- DATA8 *alpha_table);</font></font></tt></b>
-
-<blockquote>This copies the table values from the current color modifier
-into the pointers to mapping tables specified. They must have 256 entries
-and be DATA8 format.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_reset_color_modifier(void);</font></font></tt></b>
-
-<blockquote>This function resets the current color modifier to have linear
-mapping tables.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_apply_color_modifier(void);</font></font></tt></b>
-
-<blockquote>This uses the current color modifier and modifies the current
-image using the mapping tables in the current color modifier.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_apply_color_modifier_to_rectangle(int x,
- int y,
- int width,
- int height);</font></font></tt></b>
-
-<blockquote>This works the same way as imlib_apply_color_modifier() but
-only modifies a selected rectangle in the current image.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>Imlib_Updates imlib_image_draw_line(int x1,
- int y1,
- int x2,
- int y2,
- char make_updates);</font></font></tt></b>
-
-<blockquote>Draw a line using the current color on the current image from
-coordinates x1, y1 to x2, y2. If make_updates is 1 it will also return
-an update you can use for an updates list, otherwise it returns NULL.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_image_draw_rectangle(int x,
- int y,
- int width,
- int height);</font></font></tt></b>
-
-<blockquote>This draws the outline of a rectangle on the current image
-at the x, y coordinates with a size of width and height pixels, using the
-current color.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_image_fill_rectangle(int x,
- int y,
- int width,
- int height);</font></font></tt></b>
-
-<blockquote>This draws a filled rectangle on the current image at the x,
-y coordinates with a size of width and height pixels, using the current
-color.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_image_copy_alpha_to_image(Imlib_Image image_source,
- int x,
- int y);</font></font></tt></b>
-
-<blockquote>This copies the alpha channel of the source image to the x,
-y coordinates of the current image, replacing the alpha channel there.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>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);</font></font></tt></b>
-
-<blockquote>This copies the source x, y, width, height rectangle alpha
-channel from the source image and replaces the alpha channel on the destination
-image at the x, y, coordinates.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_image_scroll_rect(int x,
- int y,
- int width,
- int height,
- int delta_x,
- int delta_y);</font></font></tt></b>
-
-<blockquote>This scrolls a rectangle at x, y, width, height within the
-current image by the delta x, y distance (in pixels).</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_image_copy_rect(int x,
- int y,
- int width,
- int height,
- int new_x,
- int new_y);</font></font></tt></b>
-
-<blockquote>This copies a rectangle of size width, height at the x, y location
-specified in the current image to a new location x, y in the same image.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>Imlib_Color_Range imlib_create_color_range(void);</font></font></tt></b>
-
-<blockquote>This creates a new empty color range and returns a valid handle
-to that color range.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_free_color_range(void);</font></font></tt></b>
-
-<blockquote>This frees the current color range.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_add_color_to_color_range(int distance_away);</font></font></tt></b>
-
-<blockquote>This adds the current color to the current color range at a
-distance_away distance from the previous color in the range (if it's the
-first color in the range this is irrelevant).</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_image_fill_color_range_rectangle(int x,
- int y,
- int width,
- int height,
- double angle);</font></font></tt></b>
-
-<blockquote>This fills a rectangle of width and height at the x, y location
-specified in the current image with a linear gradient of the current color
-range at an angle of angle degrees with 0 degrees being vertical from top
-to bottom going clockwise from there.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_image_fill_hsva_color_range_rectangle(int x,
- int y,
- int width,
- int height,
- double angle);</font></font></tt></b>
-
-<blockquote>This fills a rectangle of width and height at the x, y location
-specified in the current image with a linear gradient in HSVA color space of
-the current color range at an angle of angle degrees with 0 degrees being
-vertical from top to bottom going clockwise from there.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_image_query_pixel(int x,
- int y,
- Imlib_Color *color_return);</font></font></tt></b>
-
-<blockquote>This fills the color_return color structure with the color
-of the pixel in the current image that is at the x, y location specified.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_image_query_pixel_cmya(int x,
- int y,
- int *cyan,
- int *magenta,
- int *yellow,
- int *alpha);</font></font></tt></b>
-
-<blockquote>This returns the CMYA color of the pixel in the current image
-that is at the x, y location specified.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_image_query_pixel_hsva(int x,
- int y,
- float *hue,
- float *saturation,
- float *value,
- int *alpha);</font></font></tt></b>
-
-<blockquote>This returns the HSVA color of the pixel in the current image
-that is at the x, y location specified.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_image_query_pixel_hlsa(int x,
- int y,
- float *hue,
- float *lightness,
- float *saturation,
- int *alpha);</font></font></tt></b>
-
-<blockquote>This returns the HLSA color of the pixel in the current image
-that is at the x, y location specified.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_image_attach_data_value(const char *key,
- void *data,
- int value,
- Imlib_Data_Destructor_Function destructor_function);</font></font></tt></b>
-
-<blockquote>This attaches data to the current image with the string key
-of key, and the data of data and an integer of value. The destructor function,
-if not NULL is called when this image is freed so the destructor can free
-the data, if this is needed.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void *imlib_image_get_attached_data(const char *key);</font></font></tt></b>
-
-<blockquote>This returns the data attached to the current image with the
-key specified. NULL is returned if no data could be found with that key
-on the current image.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>int imlib_image_get_attached_value(const char *key);</font></font></tt></b>
-
-<blockquote>This returns the value attached to the current image with the
-specified key. If none could be found 0 is returned.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_image_remove_attached_data_value(const char *key);</font></font></tt></b>
-
-<blockquote>This detaches the data &amp; value attached with the specified
-key from the current image.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_image_remove_and_free_attached_data_value(const char *key);</font></font></tt></b>
-
-<blockquote>This removes the data and value attached to the current image
-with the specified key and also calls the destructor function that was
-supplied when attaching it.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_save_image(const char *filename);</font></font></tt></b>
-
-<blockquote>This saves the current image in the format specified by the
-current image's format settings to the filename specified.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_save_image_with_error_return(const char *filename,
- Imlib_Load_Error *error_return);</font></font></tt></b>
-
-<blockquote>This works the same way imlib_save_image() works, but will
-set the error_return to an error value if the save fails.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>Imlib_Image imlib_create_rotated_image(double angle);</font></font></tt></b>
-
-<blockquote>This creates an new copy of the current image, but rotated
-by angle degrees. On success it returns a valid image handle, otherwise
-NULL.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_blend_image_onto_image_at_angle(Imlib_Image source_image,
- char merge_alpha,
- int source_x,
- int source_y,
- int source_width,
- int source_height,
- int destination_x,
- int destination_y,
- int angle_x,
- int angle_y);</font></font></tt></b>
-
-<blockquote>This function works just like imlib_blend_image_onto_image_skewed()
-except you cannot skew an image (v_angle_x and v_angle_y are 0).</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_blend_image_onto_image_skewed(Imlib_Image source_image,
- char merge_alpha,
- int source_x,
- 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);</font></font></tt></b>
-
-<blockquote>This will blend the source rectangle x, y, width, height from
-the source_image onto the current image at the destination x, y location.
-<p>It will be rotated and scaled so that the upper right corner will be
-positioned h_angle_x pixels to the right (or left, if negative) and h_angle_y
-pixels down (from destination_[x|y]).
-<p>If v_angle_x and v_angle_y are not 0, the image will also be skewed
-so that the lower left corner will be positioned v_angle_x pixels to the
-right and v_angle_y pixels down.
-<p>The at_angle versions simply have the v_angle_x and v_angle_y set to
-0 so the rotation doesn't get skewed, and the render_..._on_drawable ones
-seem obvious enough; they do the same on a drawable.
-<p>Examples:
-<ul>
-<li>
-imlib_blend_image_onto_image_skewed(..., 0, 0, 100, 0, 0, 100);</li>
-
-<p><br>will simply scale the image to be 100x100.
-<br>
-<li>
-imlib_blend_image_onto_image_skewed(..., 0, 0, 0, 100, 100, 0);</li>
-
-<p><br>will scale the image to be 100x100, and flip it diagonally.
-<br>
-<li>
-imlib_blend_image_onto_image_skewed(..., 100, 0, 0, 100, -100, 0);</li>
-
-<p><br>will scale the image and rotate it 90 degrees clockwise.
-<br>
-<li>
-imlib_blend_image_onto_image_skewed(..., 50, 0, 50, 50, -50, 50);</li>
-
-<p><br>will rotate the image 45 degrees clockwise, and will scale it so
-its corners are at (50,0)-(100,50)-(50,100)-(0,50) i.e. it fits into the
-100x100 square, so it's scaled down to 70.7% (sqrt(2)/2).
-<br>
-<li>
-imlib_blend_image_onto_image_skewed(..., 50, 50, 100 * cos(a), 100 * sin(a),
-0);</li>
-
-<p><br>will rotate the image `a' degrees, with its upper left corner at
-(50,50).
-<br> </ul>
-</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_render_image_on_drawable_skewed(int source_x,
- 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);</font></font></tt></b>
-
-<blockquote>This works just like imlib_blend_image_onto_image_skewed(),
-except it blends the image onto the current drawable instead of the current
-image.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_render_image_on_drawable_at_angle(int source_x,
- int source_y,
- int source_width,
- int source_height,
- int destination_x,
- int destination_y,
- int angle_x,
- int angle_y);</font></font></tt></b>
-
-<blockquote>This function works just like imlib_render_image_on_drawable_skewed()
-except you cannot skew an image (v_angle_x and v_angle_y are 0).</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_context_set_cliprect(int x, int y, int w, int h);</font></font></tt></b>
-
-<blockquote>Sets the current clipping rectangle to (x,y w*h). The clipping
-rectangle effects all image drawing functions and prevents the area outside
-the rectangle from being edited. Set w to 0 to disable clipping.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>int 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);</font></font></tt></b>
-
-<blockquote>A utility function to return clipped line coordinates.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_polygon_new(void);</font></font></tt></b>
-
-<blockquote>Returns a new polygon object with no points set.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_polygon_free(ImlibPolygon poly);</font></font></tt></b>
-
-<blockquote>Frees a polygon object.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_polygon_add_point(ImlibPolygon poly, int x, int y);</font></font></tt></b>
-
-<blockquote>Adds the point (x,y) to a polygon object. The point will be
-added to the end of the polygon's internal point list. The points are drawn
-in order, from the first to the last.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_image_draw_polygon(ImlibPolygon poly, unsigned char closed);</font></font></tt></b>
-
-<blockquote>Draws a polygon onto the current context image. Points which
-have been added to the polygon are drawn in sequence, first to last. The
-final point will be joined with the first point if <b>closed</b> is non-zero.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_image_fill_polygon(ImlibPolygon poly);</font></font></tt></b>
-
-<blockquote>Fill the area defined by the polygon on the current context
-image with the current context colour.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_polygon_get_bounds(ImlibPolygon poly, int *px1, int *py1, int *px2, int *py2);</font></font></tt></b>
-
-<blockquote>Calculate the bounding area of the polygon. (px1, py1) defines
-the upper left corner of the bounding box and (px2, py2) defines it's lower
-right corner.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>unsigned char imlib_polygon_contains_point(ImlibPolygon poly, int x, int y);</font></font></tt></b>
-
-<blockquote>Returns non-zero if the point (x,y) is within the area defined
-by the polygon.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_image_draw_ellipse(int xc, int yc, int a, int b);</font></font></tt></b>
-
-<blockquote>Draw an ellipse on the current context image. The ellipse is
-defined as (x-xc)^2/a^2 + (y-yc)^2/b^2 = 1. This means that the point (<b>xc</b>,<b>yc</b>)
-marks the center of the ellipse, <b>a</b> defines the horizontal amplitude
-of the ellipse, and <b>b</b> defines the vertical amplitude.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_image_fill_ellipse(int xc, int yc, int a, int b);</font></font></tt></b>
-
-<blockquote>Fills an ellipse on the current context image using the current
-context colour. The ellipse is defined as (x-xc)^2/a^2 + (y-yc)^2/b^2 =
-1. This means that the point (<b>xc</b>,<b>yc</b>) marks the center of
-the ellipse, <b>a</b> defines the horizontal amplitude of the ellipse,
-and <b>b</b> defines the vertical amplitude.</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_image_filter(void);</font></font></tt></b>
-
-<blockquote>
-</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>Imlib_Filter imlib_create_filter(int initsize);</font></font></tt></b>
-
-<blockquote>
-</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_free_filter(void);</font></font></tt></b>
-<blockquote>
-</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_filter_set(int xoff,
- int yoff,
- int a,
- int r,
- int g,
- int b);</font></font></tt></b>
-
-<blockquote>
-</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_filter_set_alpha(int xoff,
- int yoff,
- int a,
- int r,
- int g,
- int b);</font></font></tt></b>
-
-<blockquote>
-</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_filter_set_red(int xoff,
- int yoff,
- int a,
- int r,
- int g,
- int b);</font></font></tt></b>
-
-<blockquote>
-</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_filter_set_green(int xoff,
- int yoff,
- int a,
- int r,
- int g,
- int b);</font></font></tt></b>
-
-<blockquote>
-</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_filter_set_blue(int xoff,
- int yoff,
- int a,
- int r,
- int g,
- int b);</font></font></tt></b>
-
-<blockquote>
-</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_filter_constants(int a,
- int r,
- int g,
- int b);</font></font></tt></b>
-
-<blockquote>
-</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_filter_divisors(int a,
- int r,
- int g,
- int b);</font></font></tt></b>
-
-<blockquote>
-</blockquote>
-
-<b><tt><font color="#660000"><font size=+2>void imlib_apply_filter( char *script, ... );</font></font></tt></b>
-
-<blockquote>
-</blockquote>
-
-<p>
-<b>Imlib 2 Dynamic Filters</b>
-<p>
-Imlib2 has built in features allowing filters and effects to be applied at
-run time through a very small scripting language, this is similar to that
-of script-fu found in the GIMP (http://www.gimp.org). There are two parts
-to the system, the client library call ``imlib_apply_filter'' and the
-library side filters. The library side filters are synonymous with image
-loaders.
-<p>
-To run a script on an image you need to set the context image then call:
-<p>
-<blockquote>
-<pre>
-imlib_apply_filter( script_string, ... );
-</pre>
-</blockquote>
-<p>
-The script_string variable is made up of the script language, which is
-very simple and made up of only function calls. Functions calls look like
-this:
-<p>
-<blockquote>
-<pre>
-filter name( key=value [, ...] );
-</pre>
-</blockquote>
-<p>
-Where,
-<p>
-<blockquote>
-<b>filter name</b> is the name of the filter you wish to apply<br>
-<b>key</b> is an expected value<br>
-<b>value</b> is a ``string'', a number, or an actual variable in<br>
-</blockquote>
-<p>
-the program, or the result of another filter.
-<p>
-eg.
-<p>
-<blockquote>
-<pre>
-bump_map( map=tint(red=50,tint=200), blue=10 );
-</pre>
-</blockquote>
-<p>
-This example would bump map using a a map generated from the tint filter.
-<p>
-It is also possible to pass application information to the filters via the
-usage of the [] operator. When the script is being compiled the script
-engine looks on the parameters passed to it and picks up a pointer for
-every [] found.
-<p>
-eg2.
-<p>
-<blockquote>
-<pre>
-imlib_apply_filter( "tint( x=[], y=[], red=255, alpha=55 );", &myxint, &myyint );
-</pre>
-</blockquote>
-<p>
-This will cause a tint to the current image at (myxint,myyint) to be
-done. This is very useful for when you want the filters to dynamically
-change according to program variables.
-The system is very quick as the code is pseudo-compiled and then run. The
-advantage of having the scripting system allows customization of the image
-manipulations, this is particularly useful in applications that allow
-modifications to be done (eg. image viewers).
-<p>
-<b>Filter Library</b>
-<p>
-There are three functions that must be in every filter library
-<p>
-<blockquote>
-<pre>
-void init( struct imlib_filter_info *info ); - Called once on loading of the filter
-</pre>
-</blockquote>
-<p>
-info - a structure passed to the filter to be filled in with information about the filter
-info-&gt;name - Name of the filter library<br>
-info-&gt;author - Name of the library author<br>
-info-&gt;description - Description of the filter library<br>
-info-&gt;num_filters - Number of filters the library exports<br>
-info-&gt;filters - An array of ``char *'' with each filter name in it.<br>
-<p>
-<blockquote>
-<pre>
-void deinit(); - Called when the filter is closed
-</pre>
-</blockquote>
-<p>
-<blockquote>
-<pre>
-/* Called every time a filter the library exports is called */
-void *exec( char *filter, void *im, pIFunctionParam params );
-</pre>
-</blockquote>
-<p>
-filter - The name of the filter being asked for
-im - The image that the filter should be applied against
-params - A linked list of parameters.
-<p>
-The best way to get all the values is such:
-<blockquote>
-Declare all parameters and initialize them to there default values.
-<blockquote>
-<pre>
- for( ptr = params; ptr != NULL; ptr = ptr-&gt;next )
- {
- ..MACRO TO GET VALUE..
- }
-</pre>
-</blockquote>
-Current Macros are:
-<blockquote>
-<pre>
- ASSIGN_INT( keyname, local variable )
- ASSIGN_DATA8( keyname, local variable )
- ASSIGN_IMAGE( keyname, local variable )
-</pre>
-</blockquote>
-eg.
-<blockquote>
-<pre>
- int r = 50;
- IFunctionParam *ptr;
-
- for( ptr = params; ptr != NULL; ptr = ptr-&gt;next )
- {
- ASSIGN_INT( "red", r );
- }
-</pre>
-</blockquote>
-</blockquote>
-<p>
-If the value "red" is not passed to the filter then it will remain
-at 50, but it a value is passed, it will be assign to r.
-<p>
-return type - Imlib_Image, this is the result of filter.
-<p>
-
-</td>
-
-<td><img SRC="img/blank.gif" height=1 width=1></td>
-</tr>
-
-<tr>
-<td WIDTH="1"><img SRC="img/blank.gif" height=1 width=1></td>
-
-<td><img SRC="img/blank.gif" height=1 width=1></td>
-
-<td WIDTH="1"><img SRC="img/blank.gif" height=1 width=1></td>
-</tr>
-</table></center>
-
-</body></html>
-
-
diff --git a/filters/.cvsignore b/filters/.cvsignore
deleted file mode 100644
index f7965f2..0000000
--- a/filters/.cvsignore
+++ /dev/null
@@ -1,21 +0,0 @@
-config.guess
-config.h.in
-config.sub
-ltconfig
-ltmain.sh
-aclocal.m4
-stamp-h.in
-Makefile.in
-configure
-config.log
-config.h
-config.cache
-libtool
-config.status
-stamp-h
-Makefile
-.deps
-.libs
-*.lo
-*.la
-.icons
diff --git a/filters/Makefile.am b/filters/Makefile.am
deleted file mode 100644
index 60de9b9..0000000
--- a/filters/Makefile.am
+++ /dev/null
@@ -1,27 +0,0 @@
-## Process this file with automake to produce Makefile.in
-
-AUTOMAKE_OPTIONS = 1.4 foreign
-
-# A list of all the files in the current directory which can be regenerated
-MAINTAINERCLEANFILES = Makefile.in
-
-LDFLAGS = -L$(top_builddir)/src -L$(top_builddir)/src/.libs -L/usr/X11R6/lib
-INCLUDES = -I. -I$(top_srcdir) -I$(top_srcdir)/src \
- -I$(top_srcdir)/loaders \
- -I/usr/X11R6/include $(X_CFLAGS) \
- -I$(prefix)/include -I$(includedir)
-
-pkgdir = $(libdir)/imlib2_loaders/filter
-pkg_LTLIBRARIES = testfilter.la bump_map.la colormod.la
-
-testfilter_la_SOURCES = filter_test.c
-testfilter_la_LDFLAGS = -no-undefined -module -avoid-version -L$(top_builddir)/src -L$(top_builddir)/src/.libs
-testfilter_la_LIBADD = -lImlib2
-
-bump_map_la_SOURCES = filter_bumpmap.c
-bump_map_la_LDFLAGS = -no-undefined -module -avoid-version -L$(top_builddir)/src -L$(top_builddir)/src/.libs
-bump_map_la_LIBADD = -lImlib2
-
-colormod_la_SOURCES = filter_colormod.c
-colormod_la_LDFLAGS = -no-undefined -module -avoid-version -L$(top_builddir)/src -L$(top_builddir)/src/.libs
-colormod_la_LIBADD = -lImlib2
diff --git a/filters/filter_bumpmap.c b/filters/filter_bumpmap.c
deleted file mode 100644
index 47c7631..0000000
--- a/filters/filter_bumpmap.c
+++ /dev/null
@@ -1,292 +0,0 @@
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "common.h"
-#include <string.h>
-
-#ifndef X_DISPLAY_MISSING
-# include <X11/Xlib.h>
-# include <X11/extensions/XShm.h>
-# include <X11/Xutil.h>
-#endif
-
-#include <math.h>
-#include "image.h"
-#include "script.h"
-#include "dynamic_filters.h"
-#include "colormod.h"
-#include "blend.h"
-
-#define PI (4 * atan(1))
-
-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;
-
- 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;
-
- 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(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);
-
- x2 = sin(an) * cos(el);
- y2 = cos(an) * cos(el);
- z = sin(el);
-
- 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;
-
- 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;
-}
-
-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;
-
- 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;
-
- 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(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;
-
- 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;
-
- 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.");
- info->num_filters = i;
- info->filters = malloc(sizeof(char *) * i);
- while (--i >= 0)
- info->filters[i] = strdup(filters[i]);
-
-}
-
-void
-deinit()
-{
- return;
-}
-
-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;
-}
diff --git a/filters/filter_colormod.c b/filters/filter_colormod.c
deleted file mode 100644
index 1706cbb..0000000
--- a/filters/filter_colormod.c
+++ /dev/null
@@ -1,269 +0,0 @@
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "common.h"
-#include <string.h>
-
-#ifndef X_DISPLAY_MISSING
-# include <X11/Xlib.h>
-# include <X11/extensions/XShm.h>
-# include <X11/Xutil.h>
-#endif
-
-#include <math.h>
-#include "image.h"
-#include "script.h"
-#include "dynamic_filters.h"
-
-#define GET_INT(x, ptr) (((ptr)->type == VAR_PTR) ? \
- (x) = (*(int *)(ptr)->data) : \
- ((ptr)->type == VAR_CHAR) ? \
- (x) = strtol((ptr)->data, 0, 0) \
- : 0)
-
-#define GET_DOUBLE(x, ptr) (((ptr)->type == VAR_PTR) ? \
- (x) = (*(double *)(ptr)->data) : \
- ((ptr)->type == VAR_CHAR) ? \
- (x) = strtod((ptr)->data, 0) \
- : 0)
-
-static void
-mod_brightness(double t[256], double 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;
-}
-
-static void
-mod_gamma(double t[256], double 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;
-}
-
-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;
-}
-
-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.");
- info->num_filters = i;
- info->filters = malloc(sizeof(char *) * i);
- while (--i >= 0)
- info->filters[i] = strdup(filters[i]);
-
-}
-
-void
-deinit()
-{
- return;
-}
-
-void *
-exec(char *filter, void *im, pIFunctionParam par)
-{
- if (!strcmp(filter, "colormod"))
- return colormod((Imlib_Image) im, par);
- return im;
-}
diff --git a/filters/filter_test.c b/filters/filter_test.c
deleted file mode 100644
index cc9f448..0000000
--- a/filters/filter_test.c
+++ /dev/null
@@ -1,115 +0,0 @@
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "common.h"
-#include <string.h>
-#include "image.h"
-#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)
-{
- 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->num_filters = 3;
- info->filters = malloc(sizeof(char *) * 3);
- for (i = 0; i < info->num_filters; i++)
- info->filters[i] = strdup(filters[i]);
-
-}
-
-void
-deinit(void)
-{
- return;
-}
-
-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;
-
-/*
- 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);
- }
-/*
- 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;
- }
- return imge;
-}
diff --git a/gendoc b/gendoc
deleted file mode 100755
index ed1fed4..0000000
--- a/gendoc
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/bin/sh
-cp ./imlib2.c.in ./imlib2.c
-
-for I in `find ./src -name "api.c" -print`; do
- cat $I >> ./imlib2.c
-done
-
-#for I in `find ./src/lib -name "*.c" -print`; do
-# cat $I >> ./imlib2.c
-#done
-rm -rf ./doc/html ./doc/latex ./doc/man
-doxygen
-cp doc/img/*.png doc/html/
-rm -f imlib2_docs.tar imlib2_docs.tar.gz
-tar -cvf imlib2_docs.tar doc/html doc/man doc/latex
-gzip -9 imlib2_docs.tar
-exit 0
diff --git a/imlib2-config.in b/imlib2-config.in
deleted file mode 100644
index efa524e..0000000
--- a/imlib2-config.in
+++ /dev/null
@@ -1,59 +0,0 @@
-#!/bin/sh
-
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-exec_prefix_set=no
-
-usage="\
-Usage: imlib2-config [--prefix[=DIR]] [--exec-prefix[=DIR]] [--version] [--libs] [--cflags]"
-
-if test $# -eq 0; then
- echo "${usage}" 1>&2
- exit 1
-fi
-
-while test $# -gt 0; do
- case "$1" in
- -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
- *) optarg= ;;
- esac
-
- case $1 in
- --prefix=*)
- prefix=$optarg
- if test $exec_prefix_set = no ; then
- exec_prefix=$optarg
- fi
- ;;
- --prefix)
- echo $prefix
- ;;
- --exec-prefix=*)
- exec_prefix=$optarg
- exec_prefix_set=yes
- ;;
- --exec-prefix)
- echo $exec_prefix
- ;;
- --version)
- echo @VERSION@
- ;;
- --cflags)
- if test @includedir@ != /usr/include ; then
- includes=-I@includedir@
- fi
- echo $includes @x_cflags@
- ;;
- --libs)
- libdirs=-L@libdir@
- echo $libdirs -lImlib2 @freetype_libs@ -lm @dlopen_libs@ @x_ldflags@ @x_libs@
- ;;
- *)
- echo "${usage}" 1>&2
- exit 1
- ;;
- esac
- shift
-done
-
-exit 0
diff --git a/imlib2.c.in b/imlib2.c.in
deleted file mode 100644
index 3439287..0000000
--- a/imlib2.c.in
+++ /dev/null
@@ -1,547 +0,0 @@
-/**
-@file
-@brief Imlib2 library
-
-Brief of imlib2 library
-*/
-/**
-
-@mainpage Imlib2 Library Documentation
-@image html imlib2.png
-@version 1.1.1
-@author Carsten Haitzler <raster@rasterman.com>
-@date 1999-2004
-
-@section intro What is Imlib2 ?
-
-
-Imlib 2 is the successor to Imlib. It is NOT a newer version - it is a completely new library. Imlib 2 can be installed alongside Imlib 1.x without any problems since they are effectively different libraries - BUT they Have very similar functionality.
-
-Imlib 2 does the following:
-
-\li Load image files from disk in one of many formats
-\li Save images to disk in one of many formats
-\li Render image data onto other images
-\li Render images to an X-Windows drawable
-\li Produce pixmaps and pixmap masks of Images
-\li Apply filters to images
-\li Rotate images
-\li Accept RGBA Data for images
-\li Scale images
-\li Alpha blend Images on other images or drawables
-\li Apply color correction and modification tables and factors to images
-\li Render images onto images with color correction and modification tables
-\li Render truetype anti-aliased text
-\li Render truetype anti-aliased text at any angle
-\li Render anti-aliased lines
-\li Render rectangles
-\li Render linear multi-colored gradients
-\li Cache data intelligently for maximum performance
-\li Allocate colors automatically
-\li Allow full control over caching and color allocation
-\li Provide highly optimized MMX assembly for core routines
-\li Provide plug-in filter interface
-\li Provide on-the-fly runtime plug-in image loading and saving interface
-\li Fastest image compositing, rendering and manipulation library for X
-
-If what you want isn't in the list above somewhere then likely Imlib 2 does not do it. If it does it it likely does it faster than any other library you can find (this includes gdk-pixbuf, gdkrgb, etc.) primarily because of highly optimized code and a smart subsystem that does the dirty work for you and picks up the pieces for you so you can be lazy and let all the optimizations for FOR you.
-
-Imlib 2 can run without a display, so it can be easily used for background image processing for web sites or servers - it only requires the X libraries to be installed - that is all - it does not require an XServer to run unless you wish to display images.
-
-The interface is simple - once you get used to it, the functions do exactly what they say they do.
-
-@section first_ex A Simple Example
-
-The best way to start is to show a simple example of an Imlib2
-program. This one will load an image of any format you have a loader
-installed for (all loaders are dynamic code objects that Imlib2 will
-use and update automatically runtime - anyone is free to write a
-loader. All that has to be done is for the object to be dropped into
-the loaders directory with the others and all Imlib2 programs will
-automatically be able to use it - without a restart).
-
-@code
-/* main program */
-int main(int argc, char **argv)
-{
- /* an image handle */
- Imlib_Image image;
-
- /* if we provided < 2 arguments after the command - exit */
- if (argc != 3) exit(1);
- /* load the image */
- image = imlib_load_image(argv[1]);
- /* if the load was successful */
- if (image)
- {
- char *tmp;
- /* set the image we loaded as the current context image to work on */
- imlib_context_set_image(image);
- /* set the image format to be the format of the extension of our last */
- /* argument - i.e. .png = png, .tif = tiff etc. */
- tmp = strrchr(argv[2], '.');
- if(tmp)
- imlib_image_set_format(tmp + 1);
- /* save the image */
- imlib_save_image(argv[2]);
- }
-}
-@endcode
-
-Now to compile this
-
-@verbatim
-cc imlib2_convert.c -o imlib2_convert `imlib2-config --cflags` `imlib2-config --libs`
-@endverbatim
-
-You now have a program that if used as follows:
-
-@verbatim
-cc imlib2_con
-./imlib2_convert image1.jpg image2.png
-@endverbatim
-
-will convert image1.jpg into a png called image2.png. It is that simple.
-
-@section loading How Image Loading Works
-
-It is probably a good idea to discuss how Imlib2 actually loads an Image so the programmer knows what is going on, how to take advantage of the optimizations already there and to explain why things work as they do.
-
-@subsection load_func Loading using imlib_load_image();
-
-This is likely to be by far the most common way to load an image - when you don't really care about the details of the loading process or why it failed - all you care about is if you got a valid image handle.
-
-When you call this function Imlib2 attempts to find the file specified as the parameter. This will involve Imlib2 first checking to see if that file path already has been loaded and is in Imlib2's cache (a cache of already decoded images in memory to save having to load and decode from disk all the time). If there already is a copy in the cache (either already active or speculatively cached from a previous load & free) this copy will have its handle returned instead of Imlib2 checking on disk (in some circumstances this is not true - see later in this section to find out). This means if your program blindly loads an Image, renders it, then frees it - then soon afterwards loads the same image again, it will not be loaded from disk at all, instead it will simply be re-referenced from the cache - meaning the load will be almost instant. A great way to take full advantage of this is to set the cache to some size you are happy with for the image data being used by your application and then all rendering o an image follows the pseudo code:
-
-@verbatim
-set cache to some amount (e.g. 4 Mb)
-...
-rendering loop ...
- load image
- render image
- free image
-... continue loop
-@endverbatim
-
-This may normally sound silly - load image, render then free - EVERY time we want to use it, BUT - it is actually the smartest way to use Imlib2 - since the caching will find the image for you in the cache - you do not need to manage your own cache, or worry about filling up memory with image data - only as much memory as you have set for the cache size will actually ever be used to store image data - if you have lots of image data to work with then increase the cache size for better performance, but this is the only thing you need to worry about. you won't have problems of accidentally forgetting to free images later since you free them immediately after use.
-
-Now what happens if the file changes on disk while it's in cache? By default nothing. The file is ignored. This is an optimization (to avoid hitting the disk to check if the file changed for every load if it's cached). You can inform Imlib2 that you care about this by using the imlib_image_set_changes_on_disk(); call. Do this whenever you load an Image that you expect will change on disk, and the fact that it changes really matters. Remember this will marginally reduce the caching performance.
-
-Now what actually happens when we try and load an image using a
-filename? First the filename is broken down into 2 parts. the filename
-before a colon (:) and the key after the colon. This means when we
-have a filename like:
-
-@verbatim
-/path/to/file.jpg
-@endverbatim
-
-the filename is:
-
-@verbatim
-/path/to/file.jpg
-@endverbatim
-
-and the key is blank. If we have:
-
-@verbatim
-/path/to/file.db:key.value/blah
-@endverbatim
-
-the filename is:
-
-@verbatim
-/path/to/file.db
-@endverbatim
-
-and the key is:
-
-@verbatim
-key.value/blah
-@endverbatim
-
-You may ask what is this thing with keys and filenames? Well Imlib2 has loaders that are able to load data that is WITHIN a file (the loader capable of this right now is the database loader that is able to load image data stored with a key in a Berkeley-db database file). The colon is used to delimit where the filename ends and the key begins. Fro the majority of files you load you won't have to worry, but there is a limit in this case that filenames cannot contain a color character.
-
-First Imlib2 checks to see if the file exists and that you have permission to read it. If this fails it will abort the load. Now that it has checked that this is the case it evaluates that it's list of dynamically loaded loader modules it up to date then it runs through the loader modules until one of them claims it can load this file. If this is the case that loader is now used to decode the image and return an Image handle to the calling program. If the loader is written correctly and the file format sanely supports this, the loader will NOT decode any image data at this point. It will ONLY read the header of the image to figure out its size, if it has an alpha channel, format and any other header information. The loader is remembered and it will be re-used to load the image data itself later if and ONLY if the actual image data itself is needed. This means you can scan vast directories of files figuring their format and size and other such information just by loading and freeing - and it will be fast because no image data is decoded. You can take advantage of this by loading the image and checking its size to calculate the size of an output area before you ever load the data. This means geometry calculations can be done fast ahead of time.
-
-If you desire more detailed information about why a load failed you can use imlib_load_image_with_error_return(); and it will return a detailed error return code.
-
-If you do not wish to have the image data loaded later using the optimized "deferred" method of loading, you can force the data to be decoded immediately with imlib_load_image_immediately();
-
-If you wish to bypass the cache when loading images you can using imlib_load_image_without_cache(); and imlib_load_image_immediately_without_cache();.
-
-Sometimes loading images can take a while. Often it is a good idea to provide feedback to the user whilst this is happening. This is when you set the progress function callback. Setting this to NULL will mean no progress function is called during load - this is the default. When it is set you set it to a function that will get called every so often (depending on the progress granularity) during load. Use imlib_context_set_progress_function(); and imlib_context_set_progress_granularity(); to set this up.
-
-@section second_ex A more advanced Example
-
-This is a more comprehensive example that should show off a fair number of features of imlib2. The code this was based off can be found in Imlib2's test directory. This covers a lot of the core of Imlib2's API so you should have a pretty good idea on how it works if you understand this code snippet.
-
-@code
-/* include X11 stuff */
-#include <X11/Xlib.h>
-/* include Imlib2 stuff */
-#include <Imlib2.h>
-/* sprintf include */
-#include <stdio.h>
-
-/* some globals for our window & X display */
-Display *disp;
-Window win;
-Visual *vis;
-Colormap cm;
-int depth;
-
-/* the program... */
-int main(int argc, char **argv)
-{
- /* events we get from X */
- XEvent ev;
- /* areas to update */
- Imlib_Updates updates, current_update;
- /* our virtual framebuffer image we draw into */
- Imlib_Image buffer;
- /* a font */
- Imlib_Font font;
- /* our color range */
- Imlib_Color_Range range;
- /* our mouse x, y coordinates */
- int mouse_x = 0, mouse_y = 0;
-
- /* connect to X */
- 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));
- depth = DefaultDepth(disp, DefaultScreen(disp));
- cm = DefaultColormap(disp, DefaultScreen(disp));
- /* create a window 640x480 */
- 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);
- /* show the window */
- XMapWindow(disp, win);
- /* set our cache to 2 Mb so it doesn't have to go hit the disk as long as */
- /* the images we use use less than 2Mb of RAM (that is uncompressed) */
- imlib_set_cache_size(2048 * 1024);
- /* set the font cache to 512Kb - again to avoid re-loading */
- imlib_set_font_cache_size(512 * 1024);
- /* add the ./ttfonts dir to our font path - you'll want a notepad.ttf */
- /* in that dir for the text to display */
- imlib_add_path_to_font_path("./ttfonts");
- /* set the maximum number of colors to allocate for 8bpp and less to 128 */
- imlib_set_color_usage(128);
- /* dither for depths < 24bpp */
- imlib_context_set_dither(1);
- /* set the display , visual, colormap and drawable we are using */
- imlib_context_set_display(disp);
- imlib_context_set_visual(vis);
- imlib_context_set_colormap(cm);
- imlib_context_set_drawable(win);
- /* 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;
-
- /* 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 rendering 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();
- }
-
- /* don't 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 temporary 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;
-}
-@endcode
-
-@section filters Imlib2 filters
-
-@subsection dyn_filter Imlib 2 Dynamic Filters
-
-Imlib2 has built in features allowing filters and effects to be applied at run time through a very small scripting language, this is similar to that of script-fu found in the GIMP (http://www.gimp.org). There are two parts to the system, the client library call ``imlib_apply_filter'' and the library side filters. The library side filters are synonymous with image loaders.
-
-To run a script on an image you need to set the context image then call:
-
-@verbatim
-imlib_apply_filter( script_string, ... );
-@endverbatim
-
-The script_string variable is made up of the script language, which is very simple and made up of only function calls. Functions calls look like this:
-
-@verbatim
-filter name( key=value [, ...] );
-@endverbatim
-
-Where,
-
-\li <b>filter name</b> is the name of the filter you wish to apply
-\li \b key is an expected value
-\li \b value is a ``string'', a number, or an actual variable in
-
-the program, or the result of another filter.
-
-eg.
-
-@verbatim
-bump_map( map=tint(red=50,tint=200), blue=10 );
-@endverbatim
-
-This example would bump map using a a map generated from the tint filter.
-
-It is also possible to pass application information to the filters via the usage of the [] operator. When the script is being compiled the script engine looks on the parameters passed to it and picks up a pointer for every [] found.
-
-eg2.
-
-@verbatim
-imlib_apply_filter( "tint( x=[], y=[], red=255, alpha=55 );", &myxint, &myyint );
-@endverbatim
-
-This will cause a tint to the current image at (myxint,myyint) to be done. This is very useful for when you want the filters to dynamically change according to program variables. The system is very quick as the code is pseudo-compiled and then run. The advantage of having the scripting system allows customization of the image manipulations, this is particularly useful in applications that allow modifications to be done (eg. image viewers).
-
-
-@subsection lib_filter Filter Library
-There are three functions that must be in every filter library
-
-@code
-void init( struct imlib_filter_info *info ); - Called once on loading of the filter
-@endcode
-
-info - a structure passed to the filter to be filled in with information about the filter info->name - Name of the filter library
-info->author - Name of the library author
-info->description - Description of the filter library
-info->num_filters - Number of filters the library exports
-info->filters - An array of ``char *'' with each filter name in it.
-
-@code
-void deinit(); - Called when the filter is closed
-
-/* Called every time a filter the library exports is called */
-void *exec( char *filter, void *im, pIFunctionParam params );
-@endcode
-
-filter - The name of the filter being asked for im - The image that the filter should be applied against params - A linked list of parameters.
-
-The best way to get all the values is such:
-
-Declare all parameters and initialize them to there default values.
-
-@code
-for( ptr = params; ptr != NULL; ptr = ptr->next )
- {
- ..MACRO TO GET VALUE..
- }
-@endcode
-
-Current Macros are:
-
-@verbatim
- ASSIGN_INT( keyname, local variable )
- ASSIGN_DATA8( keyname, local variable )
- ASSIGN_IMAGE( keyname, local variable )
-@endverbatim
-
-eg.
-
-@code
-int r = 50;
-IFunctionParam *ptr;
-
-for( ptr = params; ptr != NULL; ptr = ptr->next )
- {
- ASSIGN_INT( "red", r );
- }
-@endcode
-
-If the value "red" is not passed to the filter then it will remain at 50, but it a value is passed, it will be assign to r.
-
-return type - Imlib_Image, this is the result of filter.
-
-@todo line code doesnt draw nice liens when clipping - fix
-@todo filled polygons can break fill bounds on corner cases - fix
-@todo go thru TODOs and FIXMEs
-
-*/ \ No newline at end of file
diff --git a/imlib2.pc.in b/imlib2.pc.in
deleted file mode 100644
index 27a7894..0000000
--- a/imlib2.pc.in
+++ /dev/null
@@ -1,12 +0,0 @@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-includedir=@includedir@
-
-Name: imlib2
-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} -I@x_cflags@ @freetype_cflags@
-
diff --git a/imlib2.spec b/imlib2.spec
deleted file mode 100644
index 6965691..0000000
--- a/imlib2.spec
+++ /dev/null
@@ -1,184 +0,0 @@
-Summary: Powerful image loading and rendering library
-Name: imlib2
-Version: 1.1.2
-Release: 1.%(date '+%Y%m%d')
-Copyright: BSD
-Group: System Environment/Libraries
-Source: ftp://ftp.enlightenment.org/pub/enlightenment/e17/libs/%{name}-%{version}.tar.gz
-BuildRoot: %{_tmppath}/%{name}-root
-Packager: Michael Jennings <mej@eterm.org>
-URL: http://www.rasterman.com/raster/imlib.html
-#BuildSuggests: freetype-devel xorg-x11-devel
-Requires: %{name}-loader_jpeg = %{version}
-Requires: %{name}-loader_png = %{version}
-Requires: %{name}-loader_argb = %{version}
-
-%description
-Imlib2 is an advanced replacement library for libraries like libXpm that
-provides many more features with much greater flexibility and speed than
-standard libraries, including font rasterization, rotation, RGBA space
-rendering and blending, dynamic binary filters, scripting, and more.
-
-%package devel
-Summary: Imlib2 headers, static libraries and documentation
-Group: System Environment/Libraries
-Requires: %{name} = %{version}
-%description devel
-Headers, static libraries and documentation for Imlib2.
-
-%package filters
-Summary: Imlib2 basic plugin filters set
-Group: System Environment/Libraries
-Requires: %{name} = %{version}
-%description filters
-Basic set of plugin filters that come with Imlib2
-
-%package loader_lbm
-Summary: Imlib2 LBM loader
-Group: System Environment/Libraries
-%description loader_lbm
-LBM image loader/saver for Imlib2
-
-%package loader_jpeg
-Summary: Imlib2 JPEG loader
-Group: System Environment/Libraries
-BuildRequires: libjpeg-devel
-%description loader_jpeg
-JPEG image loader/saver for Imlib2
-
-%package loader_png
-Summary: Imlib2 PNG loader
-Group: System Environment/Libraries
-BuildRequires: libpng-devel
-BuildRequires: zlib-devel
-%description loader_png
-PNG image loader/saver for Imlib2
-
-%package loader_argb
-Summary: Imlib2 ARGB loader
-Group: System Environment/Libraries
-%description loader_argb
-ARGB image loader/saver for Imlib2
-
-%package loader_bmp
-Summary: Imlib2 BMP loader
-Group: System Environment/Libraries
-%description loader_bmp
-BMP image loader/saver for Imlib2
-
-%package loader_gif
-Summary: Imlib2 GIF loader
-Group: System Environment/Libraries
-%description loader_gif
-GIF image loader for Imlib2
-
-%package loader_pnm
-Summary: Imlib2 PNM loader
-Group: System Environment/Libraries
-%description loader_pnm
-PNM image loader/saver for Imlib2
-
-%package loader_tga
-Summary: Imlib2 TGA loader
-Group: System Environment/Libraries
-%description loader_tga
-TGA image loader/saver for Imlib2
-
-%package loader_tiff
-Summary: Imlib2 TIFF loader
-Group: System Environment/Libraries
-BuildRequires: libtiff-devel
-%description loader_tiff
-TIFF image loader/saver for Imlib2
-
-%package loader_xpm
-Summary: Imlib2 XPM loader
-Group: System Environment/Libraries
-%description loader_xpm
-XPM image loader/saver for Imlib2
-
-%package loader_bz2
-Summary: Imlib2 .bz2 loader
-Group: System Environment/Libraries
-%description loader_bz2
-Bzip2 compressed image loader/saver for Imlib2
-
-%package loader_gz
-Summary: Imlib2 .gz loader
-Group: System Environment/Libraries
-%description loader_gz
-gz compressed image loader/saver for Imlib2
-
-%prep
-%setup -q
-
-%build
-%{configure} --prefix=%{_prefix}
-%{__make} %{?_smp_mflags} %{?mflags}
-
-%install
-%{__make} %{?mflags_install} DESTDIR=$RPM_BUILD_ROOT install
-
-%clean
-test "x$RPM_BUILD_ROOT" != "x/" && rm -rf $RPM_BUILD_ROOT
-
-%post
-/sbin/ldconfig
-
-%postun
-/sbin/ldconfig
-
-%files
-%defattr(-, root, root)
-%doc AUTHORS COPYING README ChangeLog doc/index.html doc/imlib2.gif doc/blank.gif
-%{_libdir}/lib*.so.*
-%{_bindir}/*
-
-%files devel
-%defattr(-, root, root, 0755)
-%{_libdir}/libImlib2.so
-%{_libdir}/*.a
-%{_libdir}/*.la
-%{_libdir}/pkgconfig/imlib2.pc
-%{_includedir}/*
-
-%files filters
-%attr(755,root,root) %{_libdir}/imlib2_loaders/filter/*
-
-%files loader_lbm
-%attr(755,root,root) %{_libdir}/imlib2_loaders/image/lbm.*
-
-%files loader_jpeg
-%attr(755,root,root) %{_libdir}/imlib2_loaders/image/jpeg.*
-
-%files loader_png
-%attr(755,root,root) %{_libdir}/imlib2_loaders/image/png.*
-
-%files loader_argb
-%attr(755,root,root) %{_libdir}/imlib2_loaders/image/argb.*
-
-%files loader_bmp
-%attr(755,root,root) %{_libdir}/imlib2_loaders/image/bmp.*
-
-%files loader_gif
-%attr(755,root,root) %{_libdir}/imlib2_loaders/image/gif.*
-
-%files loader_pnm
-%attr(755,root,root) %{_libdir}/imlib2_loaders/image/pnm.*
-
-%files loader_tga
-%attr(755,root,root) %{_libdir}/imlib2_loaders/image/tga.*
-
-%files loader_tiff
-%attr(755,root,root) %{_libdir}/imlib2_loaders/image/tiff.*
-
-%files loader_xpm
-%attr(755,root,root) %{_libdir}/imlib2_loaders/image/xpm.*
-
-%files loader_bz2
-%attr(755,root,root) %{_libdir}/imlib2_loaders/image/bz2.*
-
-%files loader_gz
-%attr(755,root,root) %{_libdir}/imlib2_loaders/image/zlib.*
-
-%changelog
diff --git a/loaders/.cvsignore b/loaders/.cvsignore
deleted file mode 100644
index 7c82077..0000000
--- a/loaders/.cvsignore
+++ /dev/null
@@ -1,22 +0,0 @@
-config.guess
-config.h.in
-config.sub
-ltconfig
-ltmain.sh
-aclocal.m4
-stamp-h.in
-Makefile.in
-configure
-config.log
-config.h
-config.cache
-libtool
-config.status
-stamp-h
-Makefile
-.deps
-.libs
-*.lo
-*.la
-imlib2
-loaderpath.h
diff --git a/loaders/Makefile.am b/loaders/Makefile.am
deleted file mode 100644
index adf626a..0000000
--- a/loaders/Makefile.am
+++ /dev/null
@@ -1,90 +0,0 @@
-## Process this file with automake to produce Makefile.in
-
-AUTOMAKE_OPTIONS = 1.4 foreign
-
-# A list of all the files in the current directory which can be regenerated
-MAINTAINERCLEANFILES = Makefile.in
-
-LDFLAGS = -L$(top_builddir)/src -L$(top_builddir)/src/.libs -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)
-
-pkgdir = $(libdir)/imlib2_loaders/image
-
-if JPEG_LOADER
-JPEG_L = jpeg.la
-endif
-if PNG_LOADER
-PNG_L = png.la
-endif
-if TIFF_LOADER
-TIFF_L = tiff.la
-endif
-if GIF_LOADER
-GIF_L = gif.la
-endif
-if ZLIB_LOADER
-ZLIB_L = zlib.la
-endif
-if BZ2_LOADER
-BZ2_L = bz2.la
-endif
-
-pkg_LTLIBRARIES = \
-$(JPEG_L) \
-$(PNG_L) \
-$(TIFF_L) \
-$(GIF_L) \
-$(ZLIB_L) \
-$(BZ2_L) \
-pnm.la argb.la bmp.la xpm.la tga.la lbm.la
-
-jpeg_la_SOURCES = loader_jpeg.c
-jpeg_la_LDFLAGS = -no-undefined -module -avoid-version -L$(top_builddir)/src -L$(top_builddir)/src/.libs
-jpeg_la_LIBADD = @JPEGLIBS@ -lImlib2
-
-png_la_SOURCES = loader_png.c
-png_la_LDFLAGS = -no-undefined -module -avoid-version -L$(top_builddir)/src -L$(top_builddir)/src/.libs
-png_la_LIBADD = @PNGLIBS@ -lImlib2
-
-tiff_la_SOURCES = loader_tiff.c
-tiff_la_LDFLAGS = -no-undefined -module -avoid-version -L$(top_builddir)/src -L$(top_builddir)/src/.libs
-tiff_la_LIBADD = @TIFFLIBS@ -lImlib2
-
-gif_la_SOURCES = loader_gif.c
-gif_la_LDFLAGS = -no-undefined -module -avoid-version -L$(top_builddir)/src -L$(top_builddir)/src/.libs
-gif_la_LIBADD = @GIFLIBS@ -lImlib2
-
-pnm_la_SOURCES = loader_pnm.c
-pnm_la_LDFLAGS = -no-undefined -module -avoid-version -L$(top_builddir)/src -L$(top_builddir)/src/.libs
-pnm_la_LIBADD = -lImlib2
-
-argb_la_SOURCES = loader_argb.c
-argb_la_LDFLAGS = -no-undefined -module -avoid-version -L$(top_builddir)/src -L$(top_builddir)/src/.libs
-argb_la_LIBADD = -lImlib2
-
-bmp_la_SOURCES = loader_bmp.c
-bmp_la_LDFLAGS = -no-undefined -module -avoid-version -L$(top_builddir)/src -L$(top_builddir)/src/.libs
-bmp_la_LIBADD = -lImlib2
-
-xpm_la_SOURCES = loader_xpm.c
-xpm_la_LDFLAGS = -no-undefined -module -avoid-version -L$(top_builddir)/src -L$(top_builddir)/src/.libs
-xpm_la_LIBADD = -lImlib2
-
-tga_la_SOURCES = loader_tga.c
-tga_la_LDFLAGS = -no-undefined -module -avoid-version -L$(top_builddir)/src -L$(top_builddir)/src/.libs
-tga_la_LIBADD = -lImlib2
-
-zlib_la_SOURCES = loader_zlib.c
-zlib_la_LDFLAGS = -no-undefined -module -avoid-version -L$(top_builddir)/src -L$(top_builddir)/src/.libs
-zlib_la_LIBADD = @ZLIBLIBS@ -lImlib2
-
-bz2_la_SOURCES = loader_bz2.c
-bz2_la_LDFLAGS = -no-undefined -module -avoid-version -L$(top_builddir)/src -L$(top_builddir)/src/.libs
-bz2_la_LIBADD = @BZ2LIBS@ -lImlib2
-
-lbm_la_SOURCES = loader_lbm.c
-lbm_la_LDFLAGS = -no-undefined -module -avoid-version -L$(top_builddir)/src -L$(top_builddir)/src/.libs
-lbm_la_LIBADD = -lImlib2
diff --git a/loaders/loader_argb.c b/loaders/loader_argb.c
deleted file mode 100644
index 20c33aa..0000000
--- a/loaders/loader_argb.c
+++ /dev/null
@@ -1,201 +0,0 @@
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "common.h"
-#include <string.h>
-
-#ifndef X_DISPLAY_MISSING
-# include <X11/Xlib.h>
-# include <X11/extensions/XShm.h>
-# include <X11/Xutil.h>
-#endif
-
-#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);
-
-#define SWAP32(x) (x) = \
-((((x) & 0x000000ff ) << 24) |\
- (((x) & 0x0000ff00 ) << 8) |\
- (((x) & 0x00ff0000 ) >> 8) |\
- (((x) & 0xff000000 ) >> 24))
-
-char
-load(ImlibImage * im, ImlibProgressFunction progress,
- char progress_granularity, char immediate_load)
-{
- int w, h, alpha;
- FILE *f;
-
- if (im->data)
- return 0;
- f = fopen(im->real_file, "rb");
- if (!f)
- 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");
- }
- }
- 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++)
- {
-#ifdef WORDS_BIGENDIAN
- {
- 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;
- }
- }
- }
- }
- fclose(f);
- return 1;
-}
-
-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;
- f = fopen(im->real_file, "wb");
- if (!f)
- return 0;
- if (im->flags & F_HAS_ALPHA)
- alpha = 1;
- 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);
- }
-#else
- 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)))
- {
- l = y - pl;
- if (!progress(im, per, 0, (y - l), im->w, l))
- {
-#ifdef WORDS_BIGENDIAN
- if (buf)
- free(buf);
-#endif
- fclose(f);
- return 2;
- }
- pper = per;
- pl = y;
- }
- }
- }
- /* finish off */
-#ifdef WORDS_BIGENDIAN
- if (buf)
- free(buf);
-#endif
- fclose(f);
- return 1;
-}
-
-void
-formats(ImlibLoader * l)
-{
- char *list_formats[] = { "argb", "arg" };
-
- {
- 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_bmp.c b/loaders/loader_bmp.c
deleted file mode 100644
index 46f445a..0000000
--- a/loaders/loader_bmp.c
+++ /dev/null
@@ -1,739 +0,0 @@
-/*
- * Based off of Peter Alm's BMP loader from xmms, with additions from
- * imlib's old BMP loader
- */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "common.h"
-#include <sys/stat.h>
-#include <string.h>
-
-#ifndef X_DISPLAY_MISSING
-# include <X11/Xlib.h>
-# include <X11/extensions/XShm.h>
-# include <X11/Xutil.h>
-#endif
-
-#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);
-
-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)
-{
- 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)
-{
- 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)
-{
- 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;
- }
- size = statbuf.st_size;
-
- if (fread(type, 1, 2, f) != 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 (offset >= size)
- {
- fclose(f);
- return 0;
- }
- 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
- {
- fclose(f);
- return 0;
- }
-
- if ((w > 8192) || (h > 8192))
- {
- fclose(f);
- return 0;
- }
-
- if (bitcount < 16)
- {
- ncols = (offset - headSize - 14);
- if (headSize == 12)
- {
- ncols /= 3;
- if (ncols > 256) ncols = 256;
- for (i = 0; i < ncols; i++)
- fread(&rgbQuads[i], 3, 1, f);
- }
- else
- {
- ncols /= 4;
- if (ncols > 256) ncols = 256;
- 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;
- }
- }
-
- 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;
- }
- im->data = malloc(w * h * sizeof(DATA32));
- 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;
- }
- }
- }
- }
- free(buffer);
- }
- return 1;
-}
-
-#if 0
-char
-save(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity)
-{
- /* TODO */
- return 0;
-}
-#endif
-
-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_bz2.c b/loaders/loader_bz2.c
deleted file mode 100644
index dcc484d..0000000
--- a/loaders/loader_bz2.c
+++ /dev/null
@@ -1,107 +0,0 @@
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <stdio.h>
-#include <bzlib.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <assert.h>
-
-#include "common.h"
-#include "image.h"
-
-#define OUTBUF_SIZE 16384
-#define INBUF_SIZE 1024
-
-static int uncompress_file (FILE *fp, int dest)
-{
- BZFILE *bf;
- DATA8 outbuf[OUTBUF_SIZE];
- int bytes, error;
-
- bf = BZ2_bzReadOpen (&error, fp, 0, 0, NULL, 0);
-
- if (error != BZ_OK) {
- BZ2_bzReadClose (NULL, bf);
- return 0;
- }
-
- error = BZ_OK;
-
- while (error == BZ_OK) {
- bytes = BZ2_bzRead (&error, bf, &outbuf, OUTBUF_SIZE);
-
- if (error == BZ_OK)
- write (dest, outbuf, bytes);
- }
-
- BZ2_bzReadClose (&error, bf);
-
- return 1;
-}
-
-char load (ImlibImage *im, ImlibProgressFunction progress,
- char progress_granularity, char immediate_load)
-{
- ImlibLoader *loader;
- FILE *fp;
- int dest, res;
- char *file, tmp[] = "/tmp/imlib2_loader_bz2-XXXXXX";
-
- assert (im);
-
- /* we'll need a copy of it later */
- file = im->real_file;
-
- if ((dest = mkstemp (tmp)) < 0)
- return 0;
-
- if (!(fp = fopen (im->real_file, "rb"))) {
- unlink (tmp);
- return 0;
- }
-
- res = uncompress_file (fp, dest);
- fclose (fp);
- close (dest);
-
- if (!res) {
- unlink (tmp);
- return 0;
- }
-
- if (!(loader = __imlib_FindBestLoaderForFile (tmp, 0))) {
- unlink (tmp);
- return 0;
- }
-
- free (im->real_file);
- im->real_file = strdup (tmp);
- loader->load (im, progress, progress_granularity, immediate_load);
-
- free (im->real_file);
- im->real_file = strdup (file);
- unlink (tmp);
-
- return 1;
-}
-
-void formats (ImlibLoader *l)
-{
- /* this is the only bit you have to change... */
- char *list_formats[] = {"bz2"};
- int i;
-
- /* don't bother changing any of this - it just reads this in
- * and sets the struct values and makes copies
- */
- 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
deleted file mode 100644
index b8809fb..0000000
--- a/loaders/loader_gif.c
+++ /dev/null
@@ -1,247 +0,0 @@
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "common.h"
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <string.h>
-
-#ifndef X_DISPLAY_MISSING
-# include <X11/Xlib.h>
-# include <X11/extensions/XShm.h>
-# include <X11/Xutil.h>
-#endif
-
-#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)
-{
- 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;
-
- /* 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);
- 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);
- 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 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" ... */
- 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;
- }
- 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;
-}
-
-/* fills the ImlibLoader struct with a strign array of format file */
-/* extensions this loader can load. eg: */
-/* loader->formats = { "jpeg", "jpg"}; */
-/* giving permutations is a good idea. case sensitivity is irrelevant */
-/* 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)
-{
- /* this is the only bit you have to change... */
- 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]);
- }
-}
diff --git a/loaders/loader_jpeg.c b/loaders/loader_jpeg.c
deleted file mode 100644
index 55693a0..0000000
--- a/loaders/loader_jpeg.c
+++ /dev/null
@@ -1,376 +0,0 @@
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "common.h"
-#include <string.h>
-
-#ifndef X_DISPLAY_MISSING
-# include <X11/Xlib.h>
-# include <X11/extensions/XShm.h>
-# include <X11/Xutil.h>
-#endif
-
-#include "image.h"
-#include <jpeglib.h>
-#include <setjmp.h>
-
-struct ImLib_JPEG_error_mgr {
- struct jpeg_error_mgr pub;
- 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)
-{
- emptr errmgr;
-
- errmgr = (emptr) cinfo->err;
-/* cinfo->err->output_message(cinfo);*/
- siglongjmp(errmgr->setjmp_buffer, 1);
- return;
-}
-
-void
-_JPEGErrorHandler(j_common_ptr cinfo)
-{
- emptr errmgr;
-
- errmgr = (emptr) cinfo->err;
-/* cinfo->err->output_message(cinfo);*/
-/* siglongjmp(errmgr->setjmp_buffer, 1);*/
- return;
-}
-
-void
-_JPEGErrorHandler2(j_common_ptr cinfo, int msg_level)
-{
- emptr errmgr;
-
- errmgr = (emptr) cinfo->err;
-/* cinfo->err->output_message(cinfo);*/
-/* siglongjmp(errmgr->setjmp_buffer, 1);*/
- return;
- msg_level = 0;
-}
-
-char
-load(ImlibImage * im, ImlibProgressFunction progress,
- char progress_granularity, char immediate_load)
-{
- int w, h;
- struct jpeg_decompress_struct cinfo;
- struct ImLib_JPEG_error_mgr jerr;
- FILE *f;
-
- if (im->data)
- return 0;
- f = fopen(im->real_file, "rb");
- if (!f)
- return 0;
- cinfo.err = jpeg_std_error(&(jerr.pub));
- jerr.pub.error_exit = _JPEGFatalErrorHandler;
- 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_create_decompress(&cinfo);
- jpeg_stdio_src(&cinfo, f);
- jpeg_read_header(&cinfo, TRUE);
- cinfo.do_fancy_upsampling = FALSE;
- 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");
- }
- if (((!im->data) && (im->loader)) || (immediate_load) || (progress))
- {
- 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;
-
- 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++)
- {
- *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;
- }
- }
- }
- }
- 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++)
- {
- *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;
- }
- }
- }
- }
- free(data);
- }
- jpeg_finish_decompress(&cinfo);
- jpeg_destroy_decompress(&cinfo);
- fclose(f);
- return 1;
-}
-
-char
-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;
-
- /* no image data? abort */
- if (!im->data)
- return 0;
- /* allocate a small buffer to convert image data */
- buf = malloc(im->w * 3 * sizeof(DATA8));
- if (!buf)
- return 0;
- f = fopen(im->real_file, "wb");
- if (!f)
- {
- 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;
- }
- /* setup compress params */
- jpeg_create_compress(&cinfo);
- jpeg_stdio_dest(&cinfo, f);
- cinfo.image_width = im->w;
- cinfo.image_height = im->h;
- cinfo.input_components = 3;
- cinfo.in_color_space = JCS_RGB;
-
- /* look for tags attached to image to get extra parameters liek quality */
- /* settigns etc. - thsi si the "api" to hint for extra information for */
- /* saver modules */
-
- /* compression */
- tag = __imlib_GetTag(im, "compression");
- if (tag)
- {
- compression = tag->val;
- if (compression < 0)
- compression = 0;
- if (compression > 9)
- compression = 9;
- }
- /* convert to quality */
- quality = (9 - compression) * 10;
- quality = quality * 10 / 9;
- /* quality */
- tag = __imlib_GetTag(im, "quality");
- if (tag)
- quality = tag->val;
- if (quality < 1)
- quality = 1;
- if (quality > 100)
- quality = 100;
-
- /* set up jepg compression parameters */
- jpeg_set_defaults(&cinfo);
- jpeg_set_quality(&cinfo, quality, TRUE);
- jpeg_start_compress(&cinfo, TRUE);
- /* get the start pointer */
- 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;
-
- 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);
- free(buf);
- fclose(f);
- return 1;
- progress = NULL;
-}
-
-void
-formats(ImlibLoader * l)
-{
- char *list_formats[] = { "jpg", "jpeg", "jfif", "jfi" };
-
- {
- 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_lbm.c b/loaders/loader_lbm.c
deleted file mode 100644
index 8542aa0..0000000
--- a/loaders/loader_lbm.c
+++ /dev/null
@@ -1,550 +0,0 @@
-/*------------------------------------------------------------------------------
- * Reads regular Amiga IFF ILBM files.
- *
- * Supports IMLIB2_LBM_NOMASK environment variable. If this is set to "1", then
- * a transparency mask in an image will be ignored. On the Amiga a mask is often
- * applied only when loading a brush rather than a picture, but this loader has
- * no way to tell when the user wants this behaviour from the picture alone.
- *
- * Author: John Bickers <jbickers@ihug.co.nz>
- * Since: 2004-08-21
- * Version: 2004-08-28
- *------------------------------------------------------------------------------*/
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "common.h"
-#include "image.h"
-
-char load(ImlibImage *im, ImlibProgressFunction progress, char progress_granularity, char immediate_load);
-#if 0
-char save(ImlibImage *im, ImlibProgressFunction progress, char progress_granularity);
-#endif
-void formats(ImlibLoader *l);
-
-
-#define L2RLONG(a) ((((long)((a)[0]) & 0xff) << 24) + (((long)((a)[1]) & 0xff) << 16) + (((long)((a)[2]) & 0xff) << 8) + ((long)((a)[3]) & 0xff))
-#define L2RWORD(a) ((((long)((a)[0]) & 0xff) << 8) + ((long)((a)[1]) & 0xff))
-
-typedef struct CHUNK {
- long size;
- unsigned char *data;
-} CHUNK;
-
-typedef struct ILBM {
- CHUNK bmhd;
- CHUNK camg;
- CHUNK cmap;
- CHUNK ctbl;
- CHUNK sham;
- CHUNK body;
-
- int depth;
- int mask;
- int ham;
- int hbrite;
-
- int row;
-
- int offset;
- int count;
- int rle;
-} ILBM;
-
-static void freeilbm(ILBM *);
-static int loadchunks(char *, ILBM *, int);
-static void bodyrow(unsigned char *, int, ILBM *);
-static unsigned char scalegun(unsigned char, int);
-static void scalecmap(ILBM *);
-static void deplane(DATA32 *, int, ILBM *, unsigned char **);
-
-
-/*------------------------------------------------------------------------------
- * Frees memory allocated as part of an ILBM structure.
- *------------------------------------------------------------------------------*/
-static void freeilbm(ILBM *ilbm)
-{
- if (ilbm->bmhd.data) free(ilbm->bmhd.data);
- if (ilbm->camg.data) free(ilbm->camg.data);
- if (ilbm->cmap.data) free(ilbm->cmap.data);
- if (ilbm->ctbl.data) free(ilbm->ctbl.data);
- if (ilbm->sham.data) free(ilbm->sham.data);
- if (ilbm->body.data) free(ilbm->body.data);
-
- memset(ilbm, 0, sizeof(*ilbm));
-}
-
-
-/*------------------------------------------------------------------------------
- * Reads the given chunks out of a file, returns 0 if the file had a problem.
- *
- * Format FORMsizeILBMtag.size....tag.size....tag.size....
- *------------------------------------------------------------------------------*/
-static int loadchunks(char *name, ILBM *ilbm, int full)
-{
-CHUNK *c;
-FILE *f;
-size_t s;
-long formsize, pos, z;
-int ok, seek;
-char buf[12];
-
- ok = 0;
-
- f = fopen(name, "rb");
- if (f) {
- s = fread(buf, 1, 12, f);
- if (s == 12 && !memcmp(buf, "FORM", 4) && !memcmp(buf + 8, "ILBM", 4)) {
- memset(ilbm, 0, sizeof(*ilbm));
- formsize = L2RLONG(buf + 4);
-
- while (1) {
- pos = ftell(f);
- if (pos < 0 || pos >= formsize + 8) break; /* Error or FORM data is finished. */
- seek = 1;
-
- s = fread(buf, 1, 8, f);
- if (s != 8) break; /* Error or short file. */
-
- z = L2RLONG(buf + 4);
- if (z < 0) break; /* Corrupt file. */
-
- c = NULL;
- if (!memcmp(buf, "BMHD", 4)) c = &(ilbm->bmhd);
- else if (full) {
- if (!memcmp(buf, "CAMG", 4)) c = &(ilbm->camg);
- else if (!memcmp(buf, "CMAP", 4)) c = &(ilbm->cmap);
- else if (!memcmp(buf, "CTBL", 4)) c = &(ilbm->ctbl);
- else if (!memcmp(buf, "SHAM", 4)) c = &(ilbm->sham);
- else if (!memcmp(buf, "BODY", 4)) c = &(ilbm->body);
- }
-
- if (c && !c->data) {
- c->size = z;
- c->data = malloc(c->size);
- if (!c->data) break; /* Out of memory. */
-
- s = fread(c->data, 1, c->size, f);
- if (s != c->size) break; /* Error or short file. */
-
- seek = 0;
- if (!full) { /* Only BMHD required. */
- ok = 1;
- break;
- }
- }
-
- if (pos + 8 + z >= formsize + 8) break; /* This was last chunk. */
-
- if (seek && fseek(f, z, SEEK_CUR) != 0) break;
- }
-
- /* File may end strangely, especially if body size is uneven, but it's
- * ok if we have the chunks we want. !full check is already done. */
- if (ilbm->bmhd.data && ilbm->body.data) ok = 1;
- if (!ok) freeilbm(ilbm);
- }
- fclose(f);
- }
-
- return ok;
-}
-
-
-/*------------------------------------------------------------------------------
- * Unpacks a row of possibly RLE data at a time.
- *
- * RLE compression depends on a count byte, followed by data bytes.
- *
- * 0x80 means skip.
- * 0xff to 0x81 means repeat one data byte (256 - count) + 1 times.
- * 0x00 to 0x7f means copy count + 1 data bytes.
- *
- * In theory RLE compression is not supposed to create runs across scanlines.
- *------------------------------------------------------------------------------*/
-static void bodyrow(unsigned char *p, int z, ILBM *ilbm)
-{
-int i, x, w;
-unsigned char b;
-
- if (ilbm->offset >= ilbm->body.size) {
- memset(p, 0, z);
- return;
- }
-
- if (!ilbm->rle) {
- w = ilbm->body.size - ilbm->offset;
- if (w > z) w = z;
- memcpy(p, ilbm->body.data + ilbm->offset, w);
- if (w < z) memset(p + w, 0, z - w);
- ilbm->offset += w;
- return;
- }
-
- for (i = 0; i < z; ) {
- b = ilbm->body.data[ilbm->offset++];
- while (b == 0x80 && ilbm->offset < ilbm->body.size) b = ilbm->body.data[ilbm->offset++];
- if (ilbm->offset >= ilbm->body.size) break;
-
- if (b & 0x80) {
- w = (0x100 - b) + 1;
- if (w > z - i) w = z - i;
-
- b = ilbm->body.data[ilbm->offset++];
- memset(p + i, b, w);
- i += w;
- }
- else {
- w = (b & 0x7f) + 1;
- if (w > ilbm->body.size - ilbm->offset) w = ilbm->body.size - ilbm->offset;
- x = (w <= z - i)? w: z - i;
- memcpy(p + i, ilbm->body.data + ilbm->offset, x);
- i += x;
- ilbm->offset += w;
- }
- }
-
- if (i < z) memset(p, 0, z - i);
-}
-
-
-/*------------------------------------------------------------------------------
- * Shifts a value to produce an 8-bit colour gun, and fills in the lower bits
- * from the high bits of the value so that, for example, 4-bit 0x0f scales to
- * 0xff, or 1-bit 0x01 scales to 0xff.
- *------------------------------------------------------------------------------*/
-static unsigned char scalegun(unsigned char v, int sl)
-{
-int sr;
-
- switch (sl) {
- case 1:
- case 2:
- case 3:
- sr = 8 - sl;
- return (v << sl) | (v >> sr);
-
- case 4:
- return (v << 4) | v;
-
- case 5:
- return v * 0x24;
-
- case 6:
- return v * 0x55;
-
- case 7:
- return v * 0xff;
- }
- return v;
-}
-
-
-/*------------------------------------------------------------------------------
- * Scales the colours in a CMAP chunk if they all look like 4-bit colour, so
- * that they use all 8-bits. This is done by copying the high nybble into the
- * low nybble, so for example 0xf0 becomes 0xff.
- *------------------------------------------------------------------------------*/
-static void scalecmap(ILBM *ilbm)
-{
-int i;
-
- if (!ilbm->cmap.data) return;
-
- for (i = 0; i < ilbm->cmap.size; i++)
- if (ilbm->cmap.data[i] & 0x0f) return;
-
- for (i = 0; i < ilbm->cmap.size; i++)
- ilbm->cmap.data[i] |= ilbm->cmap.data[i] >> 4;
-}
-
-
-/*------------------------------------------------------------------------------
- * Deplanes and converts an array of bitplanes to a single scanline of DATA32
- * (unsigned int) values. DATA32 is ARGB.
- *------------------------------------------------------------------------------*/
-static void deplane(DATA32 *row, int w, ILBM *ilbm, unsigned char *plane[])
-{
-unsigned long l;
-int i, o, sl, x;
-unsigned char bit, r, g, b, a, v, h, *pal;
-
- pal = NULL;
- if (ilbm->sham.data && ilbm->sham.size >= 2 + (ilbm->row + 1) * 2 * 16)
- pal = ilbm->sham.data + 2 + ilbm->row * 2 * 16;
- if (ilbm->ctbl.data && ilbm->ctbl.size >= (ilbm->row + 1) * 2 * 16)
- pal = ilbm->ctbl.data + ilbm->row * 2 * 16;
-
- if (ilbm->ham) r = g = b = 0;
-
- bit = 0x80;
- o = 0;
- for (x = 0; x < w; x++) {
- l = 0;
- for (i = ilbm->depth - 1; i >= 0; i--) {
- l = l << 1;
- if (plane[i][o] & bit) l = l | 1;
- }
- a = (ilbm->mask == 0 || (ilbm->mask == 1 && (plane[ilbm->depth][o] & bit)) || ilbm->mask == 2)? 0xff: 0x00;
-
- if (ilbm->depth == 32) {
- a = (l >> 24) & 0xff;
- b = (l >> 16) & 0xff;
- g = (l >> 8) & 0xff;
- r = l & 0xff;
- }
- else if (ilbm->depth == 24) {
- b = (l >> 16) & 0xff;
- g = (l >> 8) & 0xff;
- r = l & 0xff;
- }
- else if (ilbm->ham) {
- v = l & ((1 << (ilbm->depth - 2)) - 1);
- h = (l & ~v) >> (ilbm->depth - 2);
-
- if (h == 0x00) {
- if (!pal) {
- if ((v + 1) * 3 <= ilbm->cmap.size) {
- r = ilbm->cmap.data[v * 3];
- g = ilbm->cmap.data[v * 3 + 1];
- b = ilbm->cmap.data[v * 3 + 2];
- }
- else r = g = b = 0;
- }
- else {
- r = scalegun(pal[v * 2] & 0x0f, 4);
- g = scalegun((pal[v * 2 + 1] & 0xf0) >> 4, 4);
- b = scalegun((pal[v * 2 + 1] & 0x0f), 4);
- }
- }
- else if (h == 0x01) b = scalegun(v, 8 - (ilbm->depth - 2));
- else if (h == 0x02) r = scalegun(v, 8 - (ilbm->depth - 2));
- else g = scalegun(v, 8 - (ilbm->depth - 2));
- }
- else if (ilbm->hbrite) {
- v = l & ((1 << (ilbm->depth - 1)) - 1);
- h = (l & ~v) >> (ilbm->depth - 1);
-
- if (!pal) {
- if ((v + 1) * 3 <= ilbm->cmap.size) {
- r = ilbm->cmap.data[v * 3];
- g = ilbm->cmap.data[v * 3 + 1];
- b = ilbm->cmap.data[v * 3 + 2];
- }
- else r = g = b = 0;
- }
- else {
- r = scalegun(pal[v * 2] & 0x0f, 4);
- g = scalegun((pal[v * 2 + 1] & 0xf0) >> 4, 4);
- b = scalegun((pal[v * 2 + 1] & 0x0f), 4);
- }
-
- if (h) {
- r = r >> 1;
- g = g >> 1;
- b = b >> 1;
- }
-
- if (ilbm->mask == 2 && v == L2RWORD(ilbm->bmhd.data + 12)) a = 0x00;
- }
- else if (ilbm->cmap.size == 0 && !pal) {
- v = l & ((1 << ilbm->depth) - 1);
- r = scalegun(v, ilbm->depth);
- g = r;
- b = r;
- }
- else {
- v = l & 0xff;
- if (!pal) {
- if ((v + 1) * 3 <= ilbm->cmap.size) {
- r = ilbm->cmap.data[v * 3];
- g = ilbm->cmap.data[v * 3 + 1];
- b = ilbm->cmap.data[v * 3 + 2];
- }
- else r = g = b = 0;
- }
- else {
- r = scalegun(pal[v * 2] & 0x0f, 4);
- g = scalegun((pal[v * 2 + 1] & 0xf0) >> 4, 4);
- b = scalegun((pal[v * 2 + 1] & 0x0f), 4);
- }
-
- if (ilbm->mask == 2 && v == L2RWORD(ilbm->bmhd.data + 12)) a = 0x00;
- }
-
- row[x] = ((unsigned long)a << 24) | ((unsigned long)r << 16) | ((unsigned long)g << 8) | (unsigned long)b;
-
- bit = bit >> 1;
- if (bit == 0) {
- o++;
- bit = 0x80;
- }
- }
-}
-
-
-/*------------------------------------------------------------------------------
- * Loads an image. If im->loader is non-zero, or immediate_load is non-zero, or
- * progress is non-zero, then the file is fully loaded, otherwise only the width
- * and height are read.
- *
- * Imlib2 doesn't support reading comment chunks like ANNO.
- *------------------------------------------------------------------------------*/
-char load(ImlibImage *im, ImlibProgressFunction progress, char progress_granularity, char immediate_load)
-{
-char *env;
-int cancel, full, i, j, k, n, ok, y, z, gran, nexty, prevy;
-unsigned char *plane[40];
-ILBM ilbm;
-
- /*----------
- * Do nothing if the data is already loaded.
- *----------*/
- if (im->data) return 0;
-
- /*----------
- * Load the chunk(s) we're interested in. If full is not true, then we only
- * want the image size and format.
- *----------*/
- full = (im->loader || immediate_load || progress);
- ok = loadchunks(im->real_file, &ilbm, full);
- if (!ok) return 0;
-
- /*----------
- * Use and check header.
- *----------*/
- ok = 0;
- if (ilbm.bmhd.size >= 20) {
- ok = 1;
-
- im->w = L2RWORD(ilbm.bmhd.data);
- im->h = L2RWORD(ilbm.bmhd.data + 2);
- if (im->w <= 0 || im->h <= 0) ok = 0;
-
- ilbm.depth = ilbm.bmhd.data[8];
- if (ilbm.depth < 1 || (ilbm.depth > 8 && ilbm.depth != 24 && ilbm.depth != 32)) ok = 0; /* Only 1 to 8, 24, or 32 planes. */
-
- ilbm.rle = ilbm.bmhd.data[10];
- if (ilbm.rle < 0 || ilbm.rle > 1) ok = 0; /* Only NONE or RLE compression. */
-
- ilbm.mask = ilbm.bmhd.data[9];
-
- if (ilbm.mask || ilbm.depth == 32) SET_FLAG(im->flags, F_HAS_ALPHA);
- else UNSET_FLAG(im->flags, F_HAS_ALPHA);
-
- env = getenv("IMLIB2_LBM_NOMASK");
- if (env && (!strcmp(env, "true") || !strcmp(env, "1") || !strcmp(env, "yes") || !strcmp(env, "on"))) UNSET_FLAG(im->flags, F_HAS_ALPHA);
-
- if (!im->format) im->format = strdup("lbm");
-
- ilbm.ham = 0;
- ilbm.hbrite = 0;
- if (ilbm.depth <= 8) {
- if (ilbm.camg.size == 4) {
- if (ilbm.camg.data[2] & 0x08) ilbm.ham = 1;
- if (ilbm.camg.data[3] & 0x80) ilbm.hbrite = 1;
- }
- else { /* Only guess at ham and hbrite if CMAP is present. */
- if (ilbm.depth == 6 && full && ilbm.cmap.size >= 3 * 16) ilbm.ham = 1;
- if (full && !ilbm.ham && ilbm.depth > 1 && ilbm.cmap.size == 3 * (1 << (ilbm.depth - 1))) ilbm.hbrite = 1;
- }
- }
- }
- if (!full || !ok) {
- freeilbm(&ilbm);
- return ok;
- }
-
- /*----------
- * The source data is planar. Each plane is an even number of bytes wide. If
- * masking type is 1, there is an extra plane that defines the mask. Scanlines
- * from each plane are interleaved, from top to bottom. The first plane is the
- * 0 bit.
- *----------*/
- ok = 0;
- cancel = 0;
- plane[0] = NULL;
-
- im->data = malloc(im->w * im->h * sizeof(DATA32));
- if (im->data) {
- n = ilbm.depth;
- if (ilbm.mask == 1) n++;
-
- plane[0] = malloc(((im->w + 15) / 16) * 2 * n);
- for (i = 1; i < n; i++) plane[i] = plane[i - 1] + ((im->w + 15) / 16) * 2;
-
- z = ((im->w + 15) / 16) * 2 * n;
-
- if (progress) {
- prevy = 0;
- if (progress_granularity <= 0) progress_granularity = 1;
- gran = progress_granularity;
- nexty = ((im->h * gran) / 100);
- }
-
- scalecmap(&ilbm);
-
- for (y = 0; y < im->h; y++) {
- bodyrow(plane[0], z, &ilbm);
-
- deplane(im->data + im->w * y, im->w, &ilbm, plane);
- ilbm.row++;
-
- if (progress && (y >= nexty || y == im->h - 1)) {
- if (!progress(im, (char)((100 * (y + 1)) / im->h), 0, prevy, im->w, y + 1)) {
- cancel = 1;
- break;
- }
- prevy = y;
- gran += progress_granularity;
- nexty = ((im->h * gran) / 100);
- }
- }
-
- ok = !cancel;
- }
-
- /*----------
- * We either had a successful decode, the user cancelled, or we couldn't get
- * the memory for im->data.
- *----------*/
- if (!ok) {
- if (im->data) free(im->data);
- im->data = NULL;
- }
-
- if (plane[0]) free(plane[0]);
-
- freeilbm(&ilbm);
-
- return (cancel)? 2: ok;
-}
-
-
-/*------------------------------------------------------------------------------
- * Perhaps save only in 32-bit format? The IFF ILBM format has pretty much gone
- * the way of the Amiga, who saves in this format any more?
- *------------------------------------------------------------------------------*/
-#if 0
-char save(ImlibImage *im, ImlibProgressFunction progress, char progress_granularity)
-{
- return 0;
-}
-#endif
-
-
-/*------------------------------------------------------------------------------
- * Identifies the file extensions this loader handles. Standard code from other
- * loaders.
- *------------------------------------------------------------------------------*/
-void formats(ImlibLoader *l)
-{
-char *list_formats[] = { "iff", "ilbm", "lbm" };
-int i;
-
- l->num_formats = sizeof(list_formats) / sizeof(list_formats[0]);
- l->formats = malloc(l->num_formats * sizeof(list_formats[0]));
- for (i = 0; i < l->num_formats; i++) l->formats[i] = strdup(list_formats[i]);
-}
diff --git a/loaders/loader_png.c b/loaders/loader_png.c
deleted file mode 100644
index ca2f4b4..0000000
--- a/loaders/loader_png.c
+++ /dev/null
@@ -1,440 +0,0 @@
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "common.h"
-#include <string.h>
-
-#ifndef X_DISPLAY_MISSING
-# include <X11/Xlib.h>
-# include <X11/extensions/XShm.h>
-# include <X11/Xutil.h>
-#endif
-
-#include "image.h"
-#include <png.h>
-
-/* this is a quick sample png loader module... nice and small isnt it? */
-
-/* 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 progress_granularity);
-void formats(ImlibLoader * l);
-
-static void comment_free(ImlibImage * im, void *data);
-static void
-comment_free(ImlibImage * im, void *data)
-{
- free(data);
-}
-
-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;
-
- /* 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;
- f = fopen(im->real_file, "rb");
- if (!f)
- return 0;
- /* read header */
- if (!im->data)
- {
- 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 (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
- hasa = 1;
- }
- 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;
-
- 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);
-#else
- 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 *));
-
- 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;
- }
- }
- }
- 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);
- }
- }
-#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)
-{
- 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, num_passes = 1, pass;
-
- if (!im->data)
- return 0;
-
- 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;
- }
- 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;
- }
- 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;
- }
-
- /* check whether we should use interlacing */
- if ((tag = __imlib_GetTag(im, "interlacing")) && tag->val)
- {
-#ifdef PNG_WRITE_INTERLACING_SUPPORTED
- png_ptr->interlaced = PNG_INTERLACE_ADAM7;
- num_passes = png_set_interlace_handling(png_ptr);
-#endif
- }
-
- 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_ptr->interlaced,
- PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
-#ifdef WORDS_BIGENDIAN
- png_set_swap_alpha(png_ptr);
-#else
- png_set_bgr(png_ptr);
-#endif
- }
- else
- {
- png_set_IHDR(png_ptr, info_ptr, im->w, im->h, 8, PNG_COLOR_TYPE_RGB,
- png_ptr->interlaced, 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;
- sig_bit.alpha = 8;
- png_set_sBIT(png_ptr, info_ptr, &sig_bit);
- /* quality */
- tag = __imlib_GetTag(im, "quality");
- if (tag)
- {
- quality = tag->val;
- if (quality < 1)
- quality = 1;
- if (quality > 99)
- quality = 99;
- }
- /* convert to compression */
- quality = quality / 10;
- compression = 9 - quality;
- /* compression */
- tag = __imlib_GetTag(im, "compression");
- if (tag)
- compression = tag->val;
- if (compression < 0)
- compression = 0;
- if (compression > 9)
- compression = 9;
- tag = __imlib_GetTag(im, "comment");
- 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_set_compression_level(png_ptr, compression);
- png_write_info(png_ptr, info_ptr);
- png_set_shift(png_ptr, &sig_bit);
- png_set_packing(png_ptr);
-
- for (pass = 0; pass < num_passes; pass++)
- {
- 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;
-
- per = 100 * (pass + y / (float) im->h) / num_passes;
- 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);
-
- fclose(f);
- return 1;
-}
-
-/* fills the ImlibLoader struct with a strign array of format file */
-/* extensions this loader can load. eg: */
-/* loader->formats = { "jpeg", "jpg"}; */
-/* giving permutations is a good idea. case sensitivity is irrelevant */
-/* your loader 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)
-{
- /* this is the only bit you have to change... */
- 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;
-
- 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_pnm.c b/loaders/loader_pnm.c
deleted file mode 100644
index a7e16c9..0000000
--- a/loaders/loader_pnm.c
+++ /dev/null
@@ -1,832 +0,0 @@
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "common.h"
-#include <string.h>
-
-#ifndef X_DISPLAY_MISSING
-# include <X11/Xlib.h>
-# include <X11/extensions/XShm.h>
-# include <X11/Xutil.h>
-#endif
-
-#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 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;
- f = fopen(im->real_file, "rb");
- if (!f)
- return 0;
-
- /* can't use fgets(), because there might be
- * binary data after the header and there
- * needn't be a newline before the data, so
- * no chance to distinguish between end of buffer
- * and a binary 0.
- */
-
- /* read the header info */
-
- c = fgetc(f);
- if (c != 'P')
- {
- fclose(f);
- return 0;
- }
-
- p = fgetc(f);
- if (p == '1' || p == '4')
- numbers = 2; /* bitimages don't have max value */
-
- if ((p < '1') || (p > '8'))
- {
- 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;
- }
-
- 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 (((!im->data) && (im->loader)) || (immediate_load) || (progress))
- {
- DATA8 *data = NULL; /* for the binary versions */
- DATA8 *ptr = NULL;
- 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 */
- {
- 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;
- }
- }
- }
- 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 */
- {
- 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;
- }
- }
- }
- 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))
- {
- if (data[0] & (1 << i))
- *ptr2 = 0xff000000;
- 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++;
- }
- }
- 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 '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;
- }
- }
- 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 = 0;
-
- 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;
- 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 =
- (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 = 0;
-
- 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);
- }
- fclose(f);
- return 1;
-}
-
-char
-save(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity)
-{
- FILE *f;
- DATA8 *buf, *bptr;
- DATA32 *ptr;
- int x, y, pl = 0;
- char pper = 0;
-
- /* no image data? abort */
- if (!im->data)
- return 0;
- f = fopen(im->real_file, "wb");
- if (!f)
- 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))
- {
- 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))
- {
- free(buf);
- fclose(f);
- return 2;
- }
- pper = per;
- pl = y;
- }
- }
- }
- }
- /* finish off */
- free(buf);
- fclose(f);
- return 1;
- progress = NULL;
-}
-
-void
-formats(ImlibLoader * l)
-{
- char *list_formats[] = { "pnm", "ppm", "pgm", "pbm", "pam" };
-
- {
- 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_tga.c b/loaders/loader_tga.c
deleted file mode 100644
index 4addbf3..0000000
--- a/loaders/loader_tga.c
+++ /dev/null
@@ -1,584 +0,0 @@
-/*
- * loader_tga.c - Loader for Truevision Targa images
- * for Imlib2
- *
- * by Dan Maas <dmaas@dcine.com> May 15, 2000
- *
- * based on TGA specifications available at:
- * http://www.wotsit.org/cgi-bin/search.cgi?TGA
- *
- * header/footer structures courtesy of the GIMP Targa plugin
- */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "common.h"
-#include <stdio.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-
-#ifndef X_DISPLAY_MISSING
-# include <X11/Xlib.h>
-# include <X11/extensions/XShm.h>
-# include <X11/Xutil.h>
-#endif
-
-#include "image.h"
-#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);
-
-/* flip an inverted image - see RLE reading below */
-static void tgaflip(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
-
-/* 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;
-
-/*
- * 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)
-{
- 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)
- return 0;
-
- /* assemble the TGA header information */
-
- /* most entries are zero... */
- memset(&header, 0x0, sizeof(header));
-
- /* uncompressed RGB Targa identifier */
- header.imageType = TGA_TYPE_COLOR;
-
- /* image width, low byte */
- header.widthLo = im->w & 0xFF;
- /* image width, high byte */
- 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;
- /* number of extra (alpha) bits per pixel */
- 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;
- }
-
- /* now we have to read from im->data into buf, swapping RGBA to BGRA */
- 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)))
- {
- 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;
- }
- }
- }
-
- /* write the header */
- 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)
- free(buf);
- fclose(f);
- return 1;
-}
-
-/* Load up a TGA file
- *
- * As written this function only recognizes the following types of Targas:
- * Type 02 - Uncompressed RGB, 24 or 32 bits
- * Type 03 - Uncompressed grayscale, 8 bits
- * Type 10 - RLE-compressed RGB, 24 or 32 bits
- * Type 11 - RLE-compressed grayscale, 8 bits
- * 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)
-{
- int fd;
- void *seg, *filedata;
- struct stat ss;
- int bpp, vinverted = 0;
- int rle = 0, footer_present = 0;
-
- tga_header *header;
- tga_footer *footer;
-
- if (im->data)
- return 0;
-
- fd = open(im->real_file, O_RDONLY);
- if (fd < 0)
- return 0;
-
- if (fstat(fd, &ss) < 0)
- {
- close(fd);
- return 0;
- }
-
- if (ss.st_size < sizeof(tga_header) + sizeof(tga_footer))
- {
- close(fd);
- return 0;
- }
- seg = mmap(0, ss.st_size, PROT_READ, MAP_SHARED, fd, 0);
- if (seg == MAP_FAILED)
- {
- close(fd);
- return 0;
- }
-
- filedata = seg;
- header = (tga_header *) filedata;
- footer = (tga_footer *) ((char *)filedata + ss.st_size - sizeof(tga_footer));
-
- /* check the footer to see if we have a v2.0 TGA file */
- if (memcmp(footer->signature, TGA_SIGNATURE, sizeof(footer->signature)) == 0)
- footer_present = 1;
-
- if (!footer_present)
- {
- }
-
- /* skip over header */
- filedata = (char *)filedata + sizeof(tga_header);
-
- /* skip over alphanumeric ID field */
- if (header->idLength)
- filedata = (char *)filedata + header->idLength;
-
- /* 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:
- munmap(seg, ss.st_size);
- close(fd);
- return 0;
- }
-
- /* bits per pixel */
- bpp = header->bpp;
-
- if (!((bpp == 32) || (bpp == 24) || (bpp == 8)))
- {
- munmap(seg, ss.st_size);
- close(fd);
- return 0;
- }
-
- /* endian-safe loading of 16-bit sizes */
- 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;
- munmap(seg, ss.st_size);
- close(fd);
- return 0;
- }
-
- 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 we need to actually read the pixel data... */
- if (((!im->data) && (im->loader)) || (immediate_load) || (progress))
- {
- unsigned long datasize;
- unsigned char *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;
- munmap(seg, ss.st_size);
- close(fd);
- 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) */
-
- datasize = ss.st_size - sizeof(tga_header) - header->idLength -
- (footer_present ? sizeof(tga_footer) : 0);
-
- /* buffer is ready for parsing */
-
- /* bufptr is the next byte to be read from the buffer */
- bufptr = filedata;
-
- /* 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, /* grayscale */
- *bufptr,
- *bufptr,
- *bufptr, (char)0xff);
- dataptr++;
- bufptr += 1;
- break;
- }
-
- } /* end for (each pixel) */
- }
- if (progress)
- {
- char per;
- int l;
-
- progress(im, 100, 0, 0, im->w, im->h);
- } /* 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) */
- } /* end for (each packet) */
- /* must now flip a bottom-up image */
- if (vinverted) tgaflip(im->data, im->w, im->h);
- if (progress)
- {
- char per;
- int l;
-
- progress(im, 100, 0, 0, im->w, im->h);
- } /* end for (each row) */
- }
- /* end if (image is RLE) */
- }
- /* end if (loading pixel data) */
-
- munmap(seg, ss.st_size);
- close(fd);
- 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]);
- }
-}
-
-/**********************/
-
-/* flip a DATA32 image block vertically in place */
-
-static void
-tgaflip (DATA32 * in, int w, int h)
-{
- DATA32 *adv, *adv2;
- int x, y;
-
- adv = in;
- adv2 = in + (w * (h - 1));
-
- for (y = 0; y < (h / 2); y++)
- {
- DATA32 tmp;
- for (x = 0; x < w; x++)
- {
- tmp = adv[x];
- adv[x] = adv2[x];
- adv2[x] = tmp;
- }
- adv2 -= w;
- adv += w;
- }
-}
diff --git a/loaders/loader_tiff.c b/loaders/loader_tiff.c
deleted file mode 100644
index b779bef..0000000
--- a/loaders/loader_tiff.c
+++ /dev/null
@@ -1,494 +0,0 @@
-/* To do: */
-/* o Need code to handle tiff with different orientations */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "common.h"
-#include <string.h>
-
-#ifndef X_DISPLAY_MISSING
-# include <X11/Xlib.h>
-# include <X11/extensions/XShm.h>
-# include <X11/Xutil.h>
-#endif
-
-#include <setjmp.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include "image.h"
-#include <tiffio.h>
-
-/* 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;
-};
-
-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);
-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)
-{
- (*(((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)
-{
- (*(((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,
- 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;
-
- image_width = img->image->w;
- image_height = img->image->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);
- }
- }
-
- 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
-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;
- char txt[1024];
-
- 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;
- }
-
- 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;
-
- strcpy(txt, "Cannot be processed by libtiff");
- if (!TIFFRGBAImageOK(tif, txt))
- {
- TIFFClose(tif);
- return 0;
- }
- strcpy(txt, "Cannot begin reading tiff");
- if (!TIFFRGBAImageBegin((TIFFRGBAImage *) & rgba_image, tif, 0,
- txt))
- {
- TIFFClose(tif);
- return 0;
- }
-
- rgba_image.image = im;
- im->w = width = rgba_image.rgba.width;
- im->h = height = rgba_image.rgba.height;
- rgba_image.num_pixels = num_pixels = width * height;
- if (rgba_image.rgba.alpha != EXTRASAMPLE_UNSPECIFIED)
- SET_FLAG(im->flags, F_HAS_ALPHA);
- else
- 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 (rgba_image.rgba.samplesperpixel == 8)*/
- if (rgba_image.rgba.bitspersample == 8)
- {
- if (!TIFFRGBAImageGet((TIFFRGBAImage *) & rgba_image,
- rast, width, height))
- {
- _TIFFfree(rast);
- free(im->data);
- im->data = NULL;
- TIFFRGBAImageEnd((TIFFRGBAImage *) & rgba_image);
- TIFFClose(tif);
-
- return 0;
- }
- }
- else
- {
- printf("channel bits == %i\n", (int)rgba_image.rgba.samplesperpixel);
- }
-
- _TIFFfree(rast);
- }
-
- TIFFRGBAImageEnd((TIFFRGBAImage *) & rgba_image);
- TIFFClose(tif);
-
- return 1;
-}
-
-/* this seems to work, except the magic number isn't written. I'm guessing */
-/* this is a problem in libtiff */
-
-char
-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 = 0;
- 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;
-
- 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);
- TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
- TIFFSetField(tif, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
- TIFFSetField(tif, TIFFTAG_RESOLUTIONUNIT, RESUNIT_NONE);
-
- /* look for tags attached to image to get extra parameters like quality */
- /* settings etc. - this is the "api" to hint for extra information for */
- /* saver modules */
-
- /* 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;
- }
-
- }
- TIFFSetField(tif, TIFFTAG_COMPRESSION, compression_type);
-
- if (has_alpha)
- {
- TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 4);
- TIFFSetField(tif, TIFFTAG_EXTRASAMPLES, EXTRASAMPLE_ASSOCALPHA);
- }
- else
- {
- 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;
- }
-
- 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;
- }
- }
- }
-
- _TIFFfree(buf);
- TIFFClose(tif);
-
- return 1;
-}
-
-/* fills the ImlibLoader struct with a strign array of format file */
-/* extensions this loader can load. eg: */
-/* loader->formats = { "jpeg", "jpg"}; */
-/* giving permutations is a good idea. case sensitivity is irrelevant */
-/* 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)
-{
- /* this is the only bit you have to change... */
- 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]);
- }
-}
diff --git a/loaders/loader_xpm.c b/loaders/loader_xpm.c
deleted file mode 100644
index 221d7df..0000000
--- a/loaders/loader_xpm.c
+++ /dev/null
@@ -1,691 +0,0 @@
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "common.h"
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <string.h>
-
-#ifndef X_DISPLAY_MISSING
-# include <X11/Xlib.h>
-# include <X11/extensions/XShm.h>
-# include <X11/Xutil.h>
-#endif
-
-#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);
-
-static FILE *rgb_txt = NULL;
-
-static void
-xpm_parse_color(char *color, int *r, int *g, int *b)
-{
- 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;
- }
- /* look in rgb txt database */
- if (!rgb_txt)
-#ifndef __EMX__
- rgb_txt = fopen("/usr/X11R6/lib/X11/rgb.txt", "r");
-#else
- rgb_txt = fopen(__XOS2RedirRoot("/XFree86/lib/X11/rgb.txt"), "rt");
-#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;
- }
- }
- }
-}
-
-static void
-xpm_parse_done(void)
-{
- if (rgb_txt)
- fclose(rgb_txt);
- rgb_txt = NULL;
-}
-
-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 lsz = 256;
- 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;
- }
- f = fopen(im->real_file, "rb");
- if (!f)
- {
- 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;
- }
-
- i = 0;
- j = 0;
- cmap = NULL;
- w = 10;
- h = 10;
- ptr = NULL;
- end = NULL;
- c = ' ';
- comment = 0;
- quote = 0;
- context = 0;
- pixels = 0;
- count = 0;
- line = malloc(lsz);
- 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;
- }
-
- if (progress)
- {
- progress(im, 100, 0, last_y, w, h);
- }
-
- fclose(f);
- free(cmap);
- free(line);
-
- xpm_parse_done();
-
- return 1;
-}
-
-/* fills the ImlibLoader struct with a strign array of format file */
-/* extensions this loader can load. eg: */
-/* loader->formats = { "jpeg", "jpg"}; */
-/* giving permutations is a good idea. case sensitivity is irrelevant */
-/* 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)
-{
- /* this is the only bit you have to change... */
- 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]);
- }
-}
diff --git a/loaders/loader_zlib.c b/loaders/loader_zlib.c
deleted file mode 100644
index 924b925..0000000
--- a/loaders/loader_zlib.c
+++ /dev/null
@@ -1,124 +0,0 @@
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <zlib.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <assert.h>
-
-#include "common.h"
-#include "image.h"
-
-#define OUTBUF_SIZE 16484
-#define INBUF_SIZE 1024
-
-static int handle_buffer (DATA8 *src, unsigned long src_len,
- DATA8 **dest, unsigned long *dest_len)
-{
- static DATA8 outbuf[OUTBUF_SIZE];
- uLongf outbuf_len = OUTBUF_SIZE;
- int res;
-
- assert (src);
- assert (src_len);
- assert (dest);
- assert (dest_len);
-
- res = uncompress (outbuf, &outbuf_len, src, src_len);
-
- switch (res) {
- case Z_OK:
- *dest = outbuf;
- *dest_len = (unsigned long) outbuf_len;
- return 1;
- case Z_BUF_ERROR:
- return 0;
- default:
- *dest = NULL;
- *dest_len = 0;
- return 0;
- }
-}
-
-static void uncompress_file (int src, int dest, off_t size)
-{
- DATA8 inbuf[INBUF_SIZE], *outbuf;
- off_t left;
- ssize_t inlen;
- unsigned long outlen = 0;
-
- for (left = size; left; left -= inlen) {
- inlen = read (src, inbuf, MIN (left, INBUF_SIZE));
-
- if (inlen <= 0)
- break;
-
- if (handle_buffer (inbuf, inlen, &outbuf, &outlen))
- write (dest, outbuf, outlen);
- }
-}
-
-char load (ImlibImage *im, ImlibProgressFunction progress,
- char progress_granularity, char immediate_load)
-{
- ImlibLoader *loader;
- int src, dest;
- char *file, tmp[] = "/tmp/imlib2_loader_zlib-XXXXXX";
- struct stat st;
-
- assert (im);
-
- /* we'll need a copy of it later */
- file = im->real_file;
-
- if (stat (im->real_file, &st) < 0)
- return 0;
-
- if ((dest = mkstemp (tmp)) < 0)
- return 0;
-
- if ((src = open (im->real_file, O_RDONLY)) < 0) {
- unlink (tmp);
- return 0;
- }
-
- uncompress_file (src, dest, st.st_size);
-
- close (src);
- close (dest);
-
- if (!(loader = __imlib_FindBestLoaderForFile (tmp, 0))) {
- unlink (tmp);
- return 0;
- }
-
- free (im->real_file);
- im->real_file = strdup (tmp);
- loader->load (im, progress, progress_granularity, immediate_load);
-
- free (im->real_file);
- im->real_file = strdup (file);
- unlink (tmp);
-
- return 1;
-}
-
-void formats (ImlibLoader *l)
-{
- /* this is the only bit you have to change... */
- char *list_formats[] = {"gz"};
- int i;
-
- /* don't bother changing any of this - it just reads this in
- * and sets the struct values and makes copies
- */
- 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/m4/ac_expand_dir.m4 b/m4/ac_expand_dir.m4
deleted file mode 100644
index b5599a0..0000000
--- a/m4/ac_expand_dir.m4
+++ /dev/null
@@ -1,14 +0,0 @@
-dnl AC_EXPAND_DIR(VARNAME, DIR)
-dnl expands occurrences of ${prefix} and ${exec_prefix} in the given DIR,
-dnl and assigns the resulting string to VARNAME
-dnl example: AC_DEFINE_DIR(DATADIR, "$datadir")
-dnl by Alexandre Oliva <oliva@dcc.unicamp.br>
-AC_DEFUN([AC_EXPAND_DIR], [
- $1=$2
- $1=`(
- test "x$prefix" = xNONE && prefix="$ac_default_prefix"
- test "x$exec_prefix" = xNONE && exec_prefix="${prefix}"
- eval echo \""[$]$1"\"
- )`
-])
-
diff --git a/m4/ac_path_generic.m4 b/m4/ac_path_generic.m4
deleted file mode 100644
index 27b55b3..0000000
--- a/m4/ac_path_generic.m4
+++ /dev/null
@@ -1,136 +0,0 @@
-dnl @synopsis AC_PATH_GENERIC(LIBRARY [, MINIMUM-VERSION [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
-dnl
-dnl Runs a LIBRARY-config script and defines LIBRARY_CFLAGS and LIBRARY_LIBS
-dnl
-dnl The script must support `--cflags' and `--libs' args.
-dnl If MINIMUM-VERSION is specified, the script must also support the
-dnl `--version' arg.
-dnl If the `--with-library-[exec-]prefix' arguments to ./configure are given,
-dnl it must also support `--prefix' and `--exec-prefix'.
-dnl (In other words, it must be like gtk-config.)
-dnl
-dnl For example:
-dnl
-dnl AC_PATH_GENERIC(Foo, 1.0.0)
-dnl
-dnl would run `foo-config --version' and check that it is at least 1.0.0
-dnl
-dnl If so, the following would then be defined:
-dnl
-dnl FOO_CFLAGS to `foo-config --cflags`
-dnl FOO_LIBS to `foo-config --libs`
-dnl
-dnl At present there is no support for additional "MODULES" (see AM_PATH_GTK)
-dnl (shamelessly stolen from gtk.m4 and then hacked around a fair amount)
-dnl
-dnl @author Angus Lees <gusl@cse.unsw.edu.au>
-
-AC_DEFUN([AC_PATH_GENERIC],
-[dnl
-dnl we're going to need uppercase, lowercase and user-friendly versions of the
-dnl string `LIBRARY'
-pushdef([UP], translit([$1], [a-z], [A-Z]))dnl
-pushdef([DOWN], translit([$1], [A-Z], [a-z]))dnl
-
-dnl
-dnl Get the cflags and libraries from the LIBRARY-config script
-dnl
-AC_ARG_WITH(DOWN-prefix,[ --with-]DOWN[-prefix=PFX Prefix where $1 is installed (optional)],
- DOWN[]_config_prefix="$withval", DOWN[]_config_prefix="")
-AC_ARG_WITH(DOWN-exec-prefix,[ --with-]DOWN[-exec-prefix=PFX Exec prefix where $1 is installed (optional)],
- DOWN[]_config_exec_prefix="$withval", DOWN[]_config_exec_prefix="")
-
- if test x$DOWN[]_config_exec_prefix != x ; then
- DOWN[]_config_args="$DOWN[]_config_args --exec-prefix=$DOWN[]_config_exec_prefix"
- if test x${UP[]_CONFIG+set} != xset ; then
- UP[]_CONFIG=$DOWN[]_config_exec_prefix/bin/DOWN-config
- fi
- fi
- if test x$DOWN[]_config_prefix != x ; then
- DOWN[]_config_args="$DOWN[]_config_args --prefix=$DOWN[]_config_prefix"
- if test x${UP[]_CONFIG+set} != xset ; then
- UP[]_CONFIG=$DOWN[]_config_prefix/bin/DOWN-config
- fi
- fi
-
- AC_PATH_PROG(UP[]_CONFIG, DOWN-config, no)
- ifelse([$2], ,
- AC_MSG_CHECKING(for $1),
- AC_MSG_CHECKING(for $1 - version >= $2)
- )
- no_[]DOWN=""
- if test "$UP[]_CONFIG" = "no" ; then
- no_[]DOWN=yes
- else
- UP[]_CFLAGS="`$UP[]_CONFIG $DOWN[]_config_args --cflags`"
- UP[]_LIBS="`$UP[]_CONFIG $DOWN[]_config_args --libs`"
- ifelse([$2], , ,[
- DOWN[]_config_major_version=`$UP[]_CONFIG $DOWN[]_config_args \
- --version | sed 's/[[^0-9]]*\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
- DOWN[]_config_minor_version=`$UP[]_CONFIG $DOWN[]_config_args \
- --version | sed 's/[[^0-9]]*\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
- DOWN[]_config_micro_version=`$UP[]_CONFIG $DOWN[]_config_args \
- --version | sed 's/[[^0-9]]*\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
- DOWN[]_wanted_major_version="regexp($2, [\<\([0-9]*\)], [\1])"
- DOWN[]_wanted_minor_version="regexp($2, [\<\([0-9]*\)\.\([0-9]*\)], [\2])"
- DOWN[]_wanted_micro_version="regexp($2, [\<\([0-9]*\).\([0-9]*\).\([0-9]*\)], [\3])"
-
- # Compare wanted version to what config script returned.
- # If I knew what library was being run, i'd probably also compile
- # a test program at this point (which also extracted and tested
- # the version in some library-specific way)
- if test "$DOWN[]_config_major_version" -lt \
- "$DOWN[]_wanted_major_version" \
- -o \( "$DOWN[]_config_major_version" -eq \
- "$DOWN[]_wanted_major_version" \
- -a "$DOWN[]_config_minor_version" -lt \
- "$DOWN[]_wanted_minor_version" \) \
- -o \( "$DOWN[]_config_major_version" -eq \
- "$DOWN[]_wanted_major_version" \
- -a "$DOWN[]_config_minor_version" -eq \
- "$DOWN[]_wanted_minor_version" \
- -a "$DOWN[]_config_micro_version" -lt \
- "$DOWN[]_wanted_micro_version" \) ; then
- # older version found
- no_[]DOWN=yes
- echo -n "*** An old version of $1 "
- echo -n "($DOWN[]_config_major_version"
- echo -n ".$DOWN[]_config_minor_version"
- echo ".$DOWN[]_config_micro_version) was found."
- echo -n "*** You need a version of $1 newer than "
- echo -n "$DOWN[]_wanted_major_version"
- echo -n ".$DOWN[]_wanted_minor_version"
- echo ".$DOWN[]_wanted_micro_version."
- echo "***"
- echo "*** If you have already installed a sufficiently new version, this error"
- echo "*** probably means that the wrong copy of the DOWN-config shell script is"
- echo "*** being found. The easiest way to fix this is to remove the old version"
- echo "*** of $1, but you can also set the UP[]_CONFIG environment to point to the"
- echo "*** correct copy of DOWN-config. (In this case, you will have to"
- echo "*** modify your LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf"
- echo "*** so that the correct libraries are found at run-time)"
- fi
- ])
- fi
- if test "x$no_[]DOWN" = x ; then
- AC_MSG_RESULT(yes)
- ifelse([$3], , :, [$3])
- else
- AC_MSG_RESULT(no)
- if test "$UP[]_CONFIG" = "no" ; then
- echo "*** The DOWN-config script installed by $1 could not be found"
- echo "*** If $1 was installed in PREFIX, make sure PREFIX/bin is in"
- echo "*** your path, or set the UP[]_CONFIG environment variable to the"
- echo "*** full path to DOWN-config."
- fi
- UP[]_CFLAGS=""
- UP[]_LIBS=""
- ifelse([$4], , :, [$4])
- fi
- AC_SUBST(UP[]_CFLAGS)
- AC_SUBST(UP[]_LIBS)
-
- popdef([UP])
- popdef([DOWN])
-])
-
diff --git a/src/.cvsignore b/src/.cvsignore
deleted file mode 100644
index a33eb24..0000000
--- a/src/.cvsignore
+++ /dev/null
@@ -1,23 +0,0 @@
-config.guess
-config.h.in
-config.sub
-ltconfig
-ltmain.sh
-aclocal.m4
-stamp-h.in
-Makefile.in
-configure
-config.log
-config.h
-config.cache
-libtool
-config.status
-stamp-h
-Makefile
-.deps
-.libs
-*.lo
-*.la
-imlib2
-loaderpath.h
-.icons
diff --git a/src/Imlib2.h b/src/Imlib2.h
deleted file mode 100644
index 6480db0..0000000
--- a/src/Imlib2.h
+++ /dev/null
@@ -1,481 +0,0 @@
-#ifndef __IMLIB_API_H
-# define __IMLIB_API_H 1
-
-/* Data types to use */
-# ifndef DATA64
-# define DATA64 unsigned long long
-# define DATA32 unsigned int
-# define DATA16 unsigned short
-# define DATA8 unsigned char
-# endif
-
-/* opaque data types */
-typedef void *Imlib_Context;
-typedef void *Imlib_Image;
-typedef void *Imlib_Color_Modifier;
-typedef void *Imlib_Updates;
-typedef void *Imlib_Font;
-typedef void *Imlib_Color_Range;
-typedef void *Imlib_Filter;
-typedef struct _imlib_border Imlib_Border;
-typedef struct _imlib_color Imlib_Color;
-typedef void *ImlibPolygon;
-
-/* blending operations */
-enum _imlib_operation
-{
- IMLIB_OP_COPY,
- IMLIB_OP_ADD,
- IMLIB_OP_SUBTRACT,
- IMLIB_OP_RESHADE
-};
-
-enum _imlib_text_direction
-{
- IMLIB_TEXT_TO_RIGHT = 0,
- IMLIB_TEXT_TO_LEFT = 1,
- IMLIB_TEXT_TO_DOWN = 2,
- IMLIB_TEXT_TO_UP = 3,
- IMLIB_TEXT_TO_ANGLE = 4
-};
-
-enum _imlib_load_error
-{
- IMLIB_LOAD_ERROR_NONE,
- IMLIB_LOAD_ERROR_FILE_DOES_NOT_EXIST,
- IMLIB_LOAD_ERROR_FILE_IS_DIRECTORY,
- IMLIB_LOAD_ERROR_PERMISSION_DENIED_TO_READ,
- IMLIB_LOAD_ERROR_NO_LOADER_FOR_FILE_FORMAT,
- IMLIB_LOAD_ERROR_PATH_TOO_LONG,
- IMLIB_LOAD_ERROR_PATH_COMPONENT_NON_EXISTANT,
- IMLIB_LOAD_ERROR_PATH_COMPONENT_NOT_DIRECTORY,
- IMLIB_LOAD_ERROR_PATH_POINTS_OUTSIDE_ADDRESS_SPACE,
- IMLIB_LOAD_ERROR_TOO_MANY_SYMBOLIC_LINKS,
- IMLIB_LOAD_ERROR_OUT_OF_MEMORY,
- IMLIB_LOAD_ERROR_OUT_OF_FILE_DESCRIPTORS,
- IMLIB_LOAD_ERROR_PERMISSION_DENIED_TO_WRITE,
- IMLIB_LOAD_ERROR_OUT_OF_DISK_SPACE,
- IMLIB_LOAD_ERROR_UNKNOWN
-};
-
-/* Encodings known to Imlib2 (so far) */
-enum _imlib_TTF_encoding
-{
- IMLIB_TTF_ENCODING_ISO_8859_1,
- IMLIB_TTF_ENCODING_ISO_8859_2,
- IMLIB_TTF_ENCODING_ISO_8859_3,
- IMLIB_TTF_ENCODING_ISO_8859_4,
- IMLIB_TTF_ENCODING_ISO_8859_5
-};
-
-typedef enum _imlib_operation Imlib_Operation;
-typedef enum _imlib_load_error Imlib_Load_Error;
-typedef enum _imlib_text_direction Imlib_Text_Direction;
-typedef enum _imlib_TTF_encoding Imlib_TTF_Encoding;
-
-struct _imlib_border
-{
- int left, right, top, bottom;
-};
-
-struct _imlib_color
-{
- int alpha, red, green, blue;
-};
-
-/* Progressive loading callbacks */
-typedef int (*Imlib_Progress_Function) (Imlib_Image im, char percent,
- int update_x, int update_y,
- int update_w, int update_h);
-typedef void (*Imlib_Data_Destructor_Function) (Imlib_Image im, void *data);
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-/* context handling */
- Imlib_Context imlib_context_new(void);
- void imlib_context_free(Imlib_Context context);
-
- void imlib_context_push(Imlib_Context context);
- void imlib_context_pop(void);
- Imlib_Context imlib_context_get(void);
-
-/* context setting */
-#ifndef X_DISPLAY_MISSING
- void imlib_context_set_display(Display * display);
- void imlib_context_set_visual(Visual * visual);
- void imlib_context_set_colormap(Colormap colormap);
- void imlib_context_set_drawable(Drawable drawable);
- void imlib_context_set_mask(Pixmap mask);
-#endif
- void imlib_context_set_dither_mask(char dither_mask);
- void imlib_context_set_anti_alias(char anti_alias);
- void imlib_context_set_dither(char dither);
- void imlib_context_set_blend(char blend);
- void imlib_context_set_color_modifier(Imlib_Color_Modifier color_modifier);
- void imlib_context_set_operation(Imlib_Operation operation);
- void imlib_context_set_font(Imlib_Font font);
- void imlib_context_set_direction(Imlib_Text_Direction direction);
- void imlib_context_set_angle(double angle);
- void imlib_context_set_color(int red, int green, int blue, int alpha);
- void imlib_context_set_color_hsva(float hue, float saturation, float value, int alpha);
- void imlib_context_set_color_hlsa(float hue, float lightness, float saturation, int alpha);
- void imlib_context_set_color_cmya(int cyan, int magenta, int yellow, int alpha);
- void imlib_context_set_color_range(Imlib_Color_Range color_range);
- void imlib_context_set_progress_function(Imlib_Progress_Function
- progress_function);
- void imlib_context_set_progress_granularity(char progress_granularity);
- void imlib_context_set_image(Imlib_Image image);
- void imlib_context_set_cliprect(int x, int y, int w, int h);
- void imlib_context_set_TTF_encoding(Imlib_TTF_Encoding encoding);
-
-/* context getting */
-#ifndef X_DISPLAY_MISSING
- Display *imlib_context_get_display(void);
- Visual *imlib_context_get_visual(void);
- Colormap imlib_context_get_colormap(void);
- Drawable imlib_context_get_drawable(void);
- Pixmap imlib_context_get_mask(void);
-#endif
- char imlib_context_get_dither_mask(void);
- char imlib_context_get_anti_alias(void);
- char imlib_context_get_dither(void);
- char imlib_context_get_blend(void);
- Imlib_Color_Modifier imlib_context_get_color_modifier(void);
- Imlib_Operation imlib_context_get_operation(void);
- Imlib_Font imlib_context_get_font(void);
- double imlib_context_get_angle(void);
- Imlib_Text_Direction imlib_context_get_direction(void);
- void imlib_context_get_color(int *red, int *green, int *blue, int *alpha);
- void imlib_context_get_color_hsva(float *hue, float *saturation, float *value, int *alpha);
- void imlib_context_get_color_hlsa(float *hue, float *lightness, float *saturation, int *alpha);
- void imlib_context_get_color_cmya(int *cyan, int *magenta, int *yellow, int *alpha);
- Imlib_Color *imlib_context_get_imlib_color(void);
- Imlib_Color_Range imlib_context_get_color_range(void);
- Imlib_Progress_Function imlib_context_get_progress_function(void);
- char imlib_context_get_progress_granularity(void);
- Imlib_Image imlib_context_get_image(void);
- void imlib_context_get_cliprect(int *x, int *y, int *w, int *h);
- Imlib_TTF_Encoding imlib_context_get_TTF_encoding(void);
-
- int imlib_get_cache_size(void);
- void imlib_set_cache_size(int bytes);
- int imlib_get_color_usage(void);
- void imlib_set_color_usage(int max);
- void imlib_flush_loaders(void);
-#ifndef X_DISPLAY_MISSING
- int imlib_get_visual_depth(Display * display, Visual * visual);
- Visual *imlib_get_best_visual(Display * display, int screen,
- int *depth_return);
-#endif
-
- Imlib_Image imlib_load_image(const char *file);
- Imlib_Image imlib_load_image_immediately(const char *file);
- Imlib_Image imlib_load_image_without_cache(const char *file);
- Imlib_Image imlib_load_image_immediately_without_cache(const char *file);
- Imlib_Image imlib_load_image_with_error_return(const char *file,
- Imlib_Load_Error *
- error_return);
- void imlib_free_image(void);
- void imlib_free_image_and_decache(void);
-
-/* query/modify image parameters */
- int imlib_image_get_width(void);
- int imlib_image_get_height(void);
- const char *imlib_image_get_filename(void);
- DATA32 *imlib_image_get_data(void);
- DATA32 *imlib_image_get_data_for_reading_only(void);
- void imlib_image_put_back_data(DATA32 * data);
- char imlib_image_has_alpha(void);
- void imlib_image_set_changes_on_disk(void);
- void imlib_image_get_border(Imlib_Border * border);
- void imlib_image_set_border(Imlib_Border * border);
- void imlib_image_set_format(const char *format);
- void imlib_image_set_irrelevant_format(char irrelevant);
- void imlib_image_set_irrelevant_border(char irrelevant);
- void imlib_image_set_irrelevant_alpha(char irrelevant);
- char *imlib_image_format(void);
- void imlib_image_set_has_alpha(char has_alpha);
- void 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);
- void imlib_image_query_pixel_hlsa(int x, int y, float *hue, float *lightness, float *saturation, int *alpha);
- void imlib_image_query_pixel_cmya(int x, int y, int *cyan, int *magenta, int *yellow, int *alpha);
-
-/* rendering functions */
-#ifndef X_DISPLAY_MISSING
- void imlib_render_pixmaps_for_whole_image(Pixmap * pixmap_return,
- Pixmap * mask_return);
- void imlib_render_pixmaps_for_whole_image_at_size(Pixmap * pixmap_return,
- Pixmap * mask_return,
- int width, int height);
- void imlib_free_pixmap_and_mask(Pixmap pixmap);
- void 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);
- void imlib_render_image_part_on_drawable_at_size(int source_x,
- int source_y,
- int source_width,
- int source_height, int x,
- int y, int width,
- int height);
- DATA32 imlib_render_get_pixel_color(void);
-#endif
- void imlib_blend_image_onto_image(Imlib_Image source_image,
- char merge_alpha, int source_x,
- int source_y, int source_width,
- int source_height, int destination_x,
- int destination_y, int destination_width,
- int destination_height);
-
-/* creation functions */
- Imlib_Image imlib_create_image(int width, int height);
- Imlib_Image 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);
-#ifndef X_DISPLAY_MISSING
- Imlib_Image imlib_create_image_from_drawable(Pixmap mask, int x, int y,
- int width, int height,
- char need_to_grab_x);
- 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_Image imlib_create_scaled_image_from_drawable(Pixmap mask,
- int source_x,
- int source_y,
- int source_width,
- int source_height,
- int destination_width,
- int destination_height,
- char need_to_grab_x,
- char
- get_mask_from_shape);
- char 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);
-#endif
- Imlib_Image imlib_clone_image(void);
- Imlib_Image imlib_create_cropped_image(int x, int y, int width,
- int height);
- 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);
-
-/* imlib updates. lists of rectangles for storing required update draws */
- Imlib_Updates imlib_updates_clone(Imlib_Updates updates);
- Imlib_Updates 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);
- Imlib_Updates imlib_updates_merge_for_rendering(Imlib_Updates updates,
- int w, int h);
- void imlib_updates_free(Imlib_Updates updates);
- Imlib_Updates imlib_updates_get_next(Imlib_Updates updates);
- void imlib_updates_get_coordinates(Imlib_Updates updates, int *x_return,
- int *y_return, int *width_return,
- int *height_return);
- void imlib_updates_set_coordinates(Imlib_Updates updates, int x, int y,
- int width, int height);
- void imlib_render_image_updates_on_drawable(Imlib_Updates updates, int x,
- int y);
- Imlib_Updates imlib_updates_init(void);
- Imlib_Updates imlib_updates_append_updates(Imlib_Updates updates,
- Imlib_Updates appended_updates);
-
-/* image modification */
- void imlib_image_flip_horizontal(void);
- void imlib_image_flip_vertical(void);
- void imlib_image_flip_diagonal(void);
- void imlib_image_orientate(int orientation);
- void imlib_image_blur(int radius);
- void imlib_image_sharpen(int radius);
- void imlib_image_tile_horizontal(void);
- void imlib_image_tile_vertical(void);
- void imlib_image_tile(void);
-
-/* fonts and text */
- Imlib_Font imlib_load_font(const char *font_name);
- void imlib_free_font(void);
- void imlib_text_draw(int x, int y, const char *text);
- void imlib_text_draw_with_return_metrics(int x, int y, const char *text,
- int *width_return,
- int *height_return,
- int *horizontal_advance_return,
- int *vertical_advance_return);
- void imlib_get_text_size(const char *text, int *width_return,
- int *height_return);
- void imlib_get_text_advance(const char *text,
- int *horizontal_advance_return,
- int *vertical_advance_return);
- int imlib_get_text_inset(const char *text);
- void imlib_add_path_to_font_path(const char *path);
- void imlib_remove_path_from_font_path(const char *path);
- char **imlib_list_font_path(int *number_return);
- int imlib_text_get_index_and_location(const char *text, int x, int y,
- int *char_x_return,
- int *char_y_return,
- int *char_width_return,
- int *char_height_return);
- void imlib_text_get_location_at_index(const char *text, int index,
- int *char_x_return,
- int *char_y_return,
- int *char_width_return,
- int *char_height_return);
- char **imlib_list_fonts(int *number_return);
- void imlib_free_font_list(char **font_list, int number);
- int imlib_get_font_cache_size(void);
- void imlib_set_font_cache_size(int bytes);
- void imlib_flush_font_cache(void);
- int imlib_get_font_ascent(void);
- int imlib_get_font_descent(void);
- int imlib_get_maximum_font_ascent(void);
- int imlib_get_maximum_font_descent(void);
-
-/* color modifiers */
- Imlib_Color_Modifier imlib_create_color_modifier(void);
- void imlib_free_color_modifier(void);
- void imlib_modify_color_modifier_gamma(double gamma_value);
- void imlib_modify_color_modifier_brightness(double brightness_value);
- void imlib_modify_color_modifier_contrast(double contrast_value);
- void imlib_set_color_modifier_tables(DATA8 * red_table,
- DATA8 * green_table,
- DATA8 * blue_table,
- DATA8 * alpha_table);
- void imlib_get_color_modifier_tables(DATA8 * red_table,
- DATA8 * green_table,
- DATA8 * blue_table,
- DATA8 * alpha_table);
- void imlib_reset_color_modifier(void);
- void imlib_apply_color_modifier(void);
- void imlib_apply_color_modifier_to_rectangle(int x, int y, int width,
- int height);
-
-/* drawing on images */
- Imlib_Updates imlib_image_draw_pixel(int x, int y, char make_updates);
- Imlib_Updates imlib_image_draw_line(int x1, int y1, int x2, int y2,
- char make_updates);
- int 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);
- void imlib_image_draw_rectangle(int x, int y, int width, int height);
- void imlib_image_fill_rectangle(int x, int y, int width, int height);
- void 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);
- void imlib_image_scroll_rect(int x, int y, int width, int height,
- int delta_x, int delta_y);
- void imlib_image_copy_rect(int x, int y, int width, int height, int new_x,
- int new_y);
-
-/* polygons */
- ImlibPolygon imlib_polygon_new(void);
- void imlib_polygon_free(ImlibPolygon poly);
- void imlib_polygon_add_point(ImlibPolygon poly, int x, int y);
- void imlib_image_draw_polygon(ImlibPolygon poly, unsigned char closed);
- void imlib_image_fill_polygon(ImlibPolygon poly);
- void imlib_polygon_get_bounds(ImlibPolygon poly, int *px1, int *py1,
- int *px2, int *py2);
- unsigned char imlib_polygon_contains_point(ImlibPolygon poly, int x,
- int y);
-
-/* ellipses */
- void imlib_image_draw_ellipse(int xc, int yc, int a, int b);
- void imlib_image_fill_ellipse(int xc, int yc, int a, int b);
-
-/* color ranges */
- Imlib_Color_Range imlib_create_color_range(void);
- void imlib_free_color_range(void);
- void imlib_add_color_to_color_range(int distance_away);
- void imlib_image_fill_color_range_rectangle(int x, int y, int width,
- int height, double angle);
- void imlib_image_fill_hsva_color_range_rectangle(int x, int y, int width,
- int height, double angle);
-
-/* image data */
- void imlib_image_attach_data_value(const char *key, void *data, int value,
- Imlib_Data_Destructor_Function
- destructor_function);
- void *imlib_image_get_attached_data(const char *key);
- int imlib_image_get_attached_value(const char *key);
- void imlib_image_remove_attached_data_value(const char *key);
- void imlib_image_remove_and_free_attached_data_value(const char *key);
-
-/* saving */
- void imlib_save_image(const char *filename);
- void imlib_save_image_with_error_return(const char *filename,
- Imlib_Load_Error * error_return);
-
-/* FIXME: */
-/* need to add arbitary rotation routines */
-
-/* rotation/skewing */
- Imlib_Image imlib_create_rotated_image(double angle);
-
-/* rotation from buffer to context (without copying)*/
- void imlib_rotate_image_from_buffer(double angle,
- Imlib_Image source_image);
-
- void imlib_blend_image_onto_image_at_angle(Imlib_Image source_image,
- char merge_alpha, int source_x,
- int source_y, int source_width,
- int source_height,
- int destination_x,
- int destination_y, int angle_x,
- int angle_y);
- void imlib_blend_image_onto_image_skewed(Imlib_Image source_image,
- char merge_alpha, int source_x,
- 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);
-#ifndef X_DISPLAY_MISSING
- void imlib_render_image_on_drawable_skewed(int source_x, 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);
- void imlib_render_image_on_drawable_at_angle(int source_x, int source_y,
- int source_width,
- int source_height,
- int destination_x,
- int destination_y,
- int angle_x, int angle_y);
-#endif
-
-/* image filters */
- void imlib_image_filter(void);
- Imlib_Filter imlib_create_filter(int initsize);
- void imlib_context_set_filter(Imlib_Filter filter);
- Imlib_Filter imlib_context_get_filter(void);
- void imlib_free_filter(void);
- void 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);
- void 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);
- void 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);
- void imlib_filter_divisors(int a, int r, int g, int b);
-
- void imlib_apply_filter(char *script, ...);
-
- void imlib_image_clear(void);
- void imlib_image_clear_color(int r, int g, int b, int a);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/src/Makefile.am b/src/Makefile.am
deleted file mode 100644
index a1916b9..0000000
--- a/src/Makefile.am
+++ /dev/null
@@ -1,44 +0,0 @@
-## Process this file with automake to produce Makefile.in
-
-AUTOMAKE_OPTIONS = 1.4 foreign
-
-# A list of all the files in the current directory which can be regenerated
-MAINTAINERCLEANFILES = Makefile.in
-
-INCLUDES = -I. -I$(top_srcdir) -I$(top_srcdir)/src \
- -I$(top_builddir)/src \
- -I$(top_srcdir)/loaders \
- $(freetype_cflags) -I/usr/X11R6/include $(X_CFLAGS) \
- -I$(prefix)/include -I$(includedir) @XMISS@
-MMX_SRCS = asm_blend.S asm_rgba.S asm_scale.S asm_rotate.S \
- asm_blend_cmod.S
-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 format.c grad.c rotate.c \
- span.c line.c rectangle.c ellipse.c polygon.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 span.h rgbadraw.h font.h format.h \
- rotate.h grad.h filter.h script.h dynamic_filters.h \
- color_helpers.h loaderpath.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 \
- rgba.h ximage.h $(MMX_SRCS)
-libImlib2_la_LDFLAGS = $(LDFLAGS) -L/usr/X11R6/lib -version-info 2:2:1
-
-if HAVE_MMX
-libImlib2_la_LIBADD = $(X_OBJS) @DLLDFLAGS@ $(MMX_OBJS) \
- -lltdl \
- $(x_libs) $(freetype_libs) -lm
-libImlib2_la_DEPENDENCIES = $(top_builddir)/config.h $(X_OBJS) $(MMX_OBJS)
-else
-libImlib2_la_LIBADD = $(X_OBJS) @DLLDFLAGS@ \
- -lltdl \
- $(x_libs) $(freetype_libs) -lm
-libImlib2_la_DEPENDENCIES = $(top_builddir)/config.h $(X_OBJS)
-endif
diff --git a/src/api.c b/src/api.c
deleted file mode 100644
index de56ce8..0000000
--- a/src/api.c
+++ /dev/null
@@ -1,5454 +0,0 @@
-#include "config.h"
-#ifndef X_DISPLAY_MISSING
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-#include <X11/extensions/shape.h>
-#endif
-#include <string.h>
-#include <stdarg.h>
-#include "common.h"
-#include "colormod.h"
-#include "image.h"
-#include "scale.h"
-#include "blend.h"
-#include "span.h"
-#ifndef X_DISPLAY_MISSING
-#include "context.h"
-#include "color.h"
-#include "grab.h"
-#include "rend.h"
-#include "rgba.h"
-#include "ximage.h"
-#include "draw.h"
-#endif
-#include "file.h"
-#include "updates.h"
-#include "rgbadraw.h"
-#include "Imlib2.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"
-#include "filter.h"
-#include "dynamic_filters.h"
-#include "script.h"
-#include <math.h>
-#include "color_helpers.h"
-
-/* convenience macros */
-#define CAST_IMAGE(im, image) (im) = (ImlibImage *)(image)
-#define CHECK_PARAM_POINTER_RETURN(func, sparam, param, ret) \
-if (!(param)) \
-{ \
- fprintf(stderr, "***** Imlib2 Developer Warning ***** :\n" \
- "\tThis program is calling the Imlib call:\n\n" \
- "\t%s();\n\n" \
- "\tWith the parameter:\n\n" \
- "\t%s\n\n" \
- "\tbeing NULL. Please fix your program.\n", func, sparam); \
- return ret; \
-}
-
-#define CHECK_PARAM_POINTER(func, sparam, param) \
-if (!(param)) \
-{ \
- fprintf(stderr, "***** Imlib2 Developer Warning ***** :\n" \
- "\tThis program is calling the Imlib call:\n\n" \
- "\t%s();\n\n" \
- "\tWith the parameter:\n\n" \
- "\t%s\n\n" \
- "\tbeing NULL. Please fix your program.\n", func, sparam); \
- return; \
-}
-
-#define MAX(a, b) (((a) > (b)) ? (a) : (b))
-#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 *);
-
-struct _imlibcontext;
-typedef struct _imlibcontext ImlibContext;
-
-struct _imlibcontext {
-#ifndef X_DISPLAY_MISSING
- 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;
-};
-
-struct _imlibcontextitem;
-typedef struct _imlibcontextitem ImlibContextItem;
-struct _imlibcontextitem {
- ImlibContext *context;
- ImlibContextItem *below;
-};
-
-/* a stack of contexts -- only used by context-handling functions. */
-static ImlibContextItem *contexts = NULL; /* (ImlibContext*) imlib_context_new(); */
-
-/* this is the context all functions use rely on */
-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;
-}
-
-Imlib_Context
-imlib_context_new(void)
-{
- 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;
-#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.alpha = 255;
- context->color.red = 255;
- context->color.green = 255;
- context->color.blue = 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.x = 0;
- context->cliprect.y = 0;
- context->cliprect.w = 0;
- context->cliprect.h = 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
- last (default) context can never be freed.
- If context is the current context, the context below will be made the
- current context.
-*/
-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
-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++;
-}
-
-void
-imlib_context_pop(void)
-{
- ImlibContextItem *item = contexts;
- ImlibContext *current_ctx = item->context;
-
- 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);
-
- free(item);
-}
-
-Imlib_Context
-imlib_context_get(void)
-{
- return (Imlib_Context) ctx;
-}
-
-/* context setting/getting functions */
-
-/**
- * @param x The top left x coordinate of the rectangle.
- * @param y The top left y coordinate of the rectangle.
- * @param w The width of the rectangle.
- * @param h The height of the rectangle.
- *
- * Sets the rectangle of the current context.
- **/
-void
-imlib_context_set_cliprect(int x, int y, int w, int h)
-{
- if (!ctx)
- ctx = imlib_context_new();
- ctx->cliprect.x = x;
- ctx->cliprect.y = y;
- ctx->cliprect.w = w;
- ctx->cliprect.h = h;
-}
-
-void
-imlib_context_get_cliprect(int *x, int *y, int *w, int *h)
-{
- if (!ctx)
- ctx = imlib_context_new();
- *x = ctx->cliprect.x;
- *y = ctx->cliprect.y;
- *w = ctx->cliprect.w;
- *h = ctx->cliprect.h;
-}
-
-#ifndef X_DISPLAY_MISSING
-/**
- * @param display Current display to bu used.
- *
- * Sets the current X display to be used for rendering of images to
- * drawables. You do not need to set this if you do not intend to
- * render an image to an X drawable. If you do you will need to set
- * this. If you change displays just set this to the new display
- * pointer. Do not use a Display pointer if you have closed that
- * display already - also note that if you close a display connection
- * and continue to render using Imlib2 without setting the display
- * pointer to NULL or something new, crashes may occur.
- */
-void
-imlib_context_set_display(Display * display)
-{
- if (!ctx)
- ctx = imlib_context_new();
- ctx->display = display;
-}
-
-/**
- * @return The current display.
- *
- * Returns the current display used for Imlib2's display context.
- */
-Display *
-imlib_context_get_display(void)
-{
- if (!ctx)
- ctx = imlib_context_new();
- return ctx->display;
-}
-
-/**
- * @param visual Current visual to use.
- *
- * Sets the current visual to use when rendering images to
- * drawables or producing pixmaps. You need to set this for anything to
- * render to a drawable or produce any pixmaps (this can be the default
- * visual).
- */
-void
-imlib_context_set_visual(Visual * visual)
-{
- if (!ctx)
- ctx = imlib_context_new();
- ctx->visual = visual;
- ctx->depth = imlib_get_visual_depth(ctx->display, ctx->visual);
-}
-
-/**
- * @return The current visual.
- *
- * Returns the current visual used for Imlib2's context.
- */
-Visual *
-imlib_context_get_visual(void)
-{
- if (!ctx)
- ctx = imlib_context_new();
- return ctx->visual;
-}
-
-/**
- * @param colormap Colormap to use.
- *
- * Sets the colormap to use when rendering to drawables and allocating
- * colors. You must set this to the colormap you are using to render any
- * images or produce any pixmaps (this can be the default colormap).
- */
-void
-imlib_context_set_colormap(Colormap colormap)
-{
- if (!ctx)
- ctx = imlib_context_new();
- ctx->colormap = colormap;
-}
-
-/**
- * @return The current colormap.
- *
- * Returns the current Colormap used for Imlib2's context.
- */
-Colormap
-imlib_context_get_colormap(void)
-{
- if (!ctx)
- ctx = imlib_context_new();
- return ctx->colormap;
-}
-
-/**
- * @param drawable An X drawable.
- *
- * Sets the X drawable to which images will be rendered when you call
- * a render call in Imlib2. This may be either a pixmap or a
- * window. You must set this to render anything.
- */
-void
-imlib_context_set_drawable(Drawable drawable)
-{
- if (!ctx)
- ctx = imlib_context_new();
- ctx->drawable = drawable;
-}
-
-/**
- * @return The current drawable.
- *
- * Returns the current Drawable used for Imlib2's context.
- */
-Drawable
-imlib_context_get_drawable(void)
-{
- if (!ctx)
- ctx = imlib_context_new();
- return ctx->drawable;
-}
-
-/**
- * @param mask An 1-bit deep pixmap.
- *
- * Sets the 1-bit deep pixmap to be drawn to when rendering to generate
- * a mask pixmap. This is only useful if the image you are rendering
- * has alpha. Set this to 0 to not render a pixmap mask.
- */
-void
-imlib_context_set_mask(Pixmap mask)
-{
- if (!ctx)
- ctx = imlib_context_new();
- ctx->mask = mask;
-}
-
-/**
- * @return The current pixmap.
- *
- * Returns the current pixmap destination to be used to render a mask into.
- */
-Pixmap
-imlib_context_get_mask(void)
-{
- if (!ctx)
- ctx = imlib_context_new();
- return ctx->mask;
-}
-#endif
-
-/**
- * @param dither_mask The dither mask flag.
- *
- * Selects if, you are rendering to a mask, or producing pixmap masks
- * from images, if the mask is to be dithered or not. passing in 1 for
- * dither_mask means the mask pixmap will be dithered, 0 means it will
- * not be dithered.
- */
-void
-imlib_context_set_dither_mask(char dither_mask)
-{
- if (!ctx)
- ctx = imlib_context_new();
- ctx->dither_mask = dither_mask;
-}
-
-/**
- * @return The current dither mask flag.
- *
- * Returns the current mode for dithering pixmap masks. 1 means
- * dithering is enabled and 0 means it is not.
- */
-char
-imlib_context_get_dither_mask(void)
-{
- if (!ctx)
- ctx = imlib_context_new();
- return ctx->dither_mask;
-}
-
-/**
- * @param anti_alias The anti alias flag.
- *
- * Toggles "anti-aliased" scaling of images. This
- * isn't quite correct since it's actually super and sub pixel
- * sampling that it turns on and off, but anti-aliasing is used for
- * having "smooth" edges to lines and shapes and this means when
- * images are scaled they will keep their smooth appearance. Passing
- * in 1 turns this on and 0 turns it off.
- */
-void
-imlib_context_set_anti_alias(char anti_alias)
-{
- if (!ctx)
- ctx = imlib_context_new();
- ctx->anti_alias = anti_alias;
-}
-
-/**
- * @return The current anti alias flag.
- *
- * Returns if Imlib2 currently will smoothly scale images. 1 means it
- * will and 0 means it will not.
- */
-char
-imlib_context_get_anti_alias(void)
-{
- if (!ctx)
- ctx = imlib_context_new();
- return ctx->anti_alias;
-}
-
-/**
- * @param dither The dithering flag.
- *
- * Sets the dithering flag for rendering to a drawable or when pixmaps
- * are produced. This affects the color image appearance by enabling
- * dithering. Dithering slows down rendering but produces considerably
- * better results. this option has no effect foe rendering in 24 bit
- * and up, but in 16 bit and lower it will dither, producing smooth
- * gradients and much better quality images. setting dither to 1
- * enables it and 0 disables it.
- */
-void
-imlib_context_set_dither(char dither)
-{
- if (!ctx)
- ctx = imlib_context_new();
- ctx->dither = dither;
-}
-
-/**
- * @return The current dithering flag.
- *
- * Returns if image data is rendered with dithering currently. 1 means
- * yes and 0 means no.
- */
-char
-imlib_context_get_dither(void)
-{
- if (!ctx)
- ctx = imlib_context_new();
- return ctx->dither;
-}
-
-/**
- * @param blend The blending flag.
- *
- * When rendering an image to a drawable, Imlib2 is able to blend the
- * image directly onto the drawable during rendering. Setting this to 1
- * will enable this. If the image has no alpha channel this has no
- * effect. Setting it to 0 will disable this.
- */
-void
-imlib_context_set_blend(char blend)
-{
- if (!ctx)
- ctx = imlib_context_new();
- ctx->blend = blend;
-}
-
-/**
- * @return The current blending flag.
- *
- * Returns if Imlib2 will blend images onto a drawable whilst
- * rendering to that drawable. 1 means yes and 0 means no.
- */
-char
-imlib_context_get_blend(void)
-{
- if (!ctx)
- ctx = imlib_context_new();
- return ctx->blend;
-}
-
-/**
- * @param color_modifier Current color modifier.
- *
- * Sets the current color modifier used for rendering pixmaps or
- * images to a drawable or images onto other images. Color modifiers
- * are lookup tables that map the values in the red, green, blue and
- * alpha channels to other values in the same channel when rendering,
- * allowing for fades, color correction etc. to be done whilst
- * rendering. pass in NULL as the color_modifier to disable the color
- * modifier for rendering.
- */
-void
-imlib_context_set_color_modifier(Imlib_Color_Modifier color_modifier)
-{
- if (!ctx)
- ctx = imlib_context_new();
- ctx->color_modifier = color_modifier;
-}
-
-/**
- * @return The current color modifier.
- *
- * Returns the current color modifier being used.
- */
-Imlib_Color_Modifier
-imlib_context_get_color_modifier(void)
-{
- if (!ctx)
- ctx = imlib_context_new();
- return ctx->color_modifier;
-}
-
-/**
- * @param operation
- *
- * When Imlib2 draws an image onto another or an image onto a drawable
- * it is able to do more than just blend the result on using the given
- * alpha channel of the image. It is also able to do saturating
- * additive, subtractive and a combination of the both (called reshade)
- * rendering. The default mode is IMLIB_OP_COPY. you can also set it to
- * IMLIB_OP_ADD, IMLIB_OP_SUBTRACT or IMLIB_OP_RESHADE. Use this
- * function to set the rendering operation. IMLIB_OP_COPY performs
- * basic alpha blending: DST = (SRC * A) + (DST * (1 -
- * A)). IMLIB_OP_ADD does DST = DST + (SRC * A). IMLIB_OP_SUBTRACT does
- * DST = DST - (SRC * A) and IMLIB_OP_RESHADE does DST = DST + (((SRC -
- * 0.5) / 2) * A).
- */
-void
-imlib_context_set_operation(Imlib_Operation operation)
-{
- if (!ctx)
- ctx = imlib_context_new();
- ctx->operation = operation;
-}
-
-/**
- * @return The current operation mode.
- *
- * Returns the current operation mode.
- */
-Imlib_Operation
-imlib_context_get_operation(void)
-{
- if (!ctx)
- ctx = imlib_context_new();
- return ctx->operation;
-}
-
-/**
- * @param font Current font.
- *
- * Sets the current font to use when rendering text. you should load
- * the font first with imlib_load_font().
- */
-void
-imlib_context_set_font(Imlib_Font font)
-{
- if (!ctx)
- ctx = imlib_context_new();
- ctx->font = font;
-}
-
-/**
- * @return The current font.
- *
- * Returns the current font.
- */
-Imlib_Font
-imlib_context_get_font(void)
-{
- if (!ctx)
- ctx = imlib_context_new();
- return ctx->font;
-}
-
-/**
- * @param direction Text direction.
- *
- * Sets the direction in which to draw text in terms of simple 90
- * degree orientations or an arbitrary angle. The direction can be one
- * of IMLIB_TEXT_TO_RIGHT, IMLIB_TEXT_TO_LEFT, IMLIB_TEXT_TO_DOWN,
- * IMLIB_TEXT_TO_UP or IMLIB_TEXT_TO_ANGLE. The default is
- * IMLIB_TEXT_TO_RIGHT. If you use IMLIB_TEXT_TO_ANGLE, you will also
- * have to set the angle with imlib_context_set_angle().
- */
-void
-imlib_context_set_direction(Imlib_Text_Direction direction)
-{
- if (!ctx)
- ctx = imlib_context_new();
- ctx->direction = direction;
-}
-
-/**
- * @param angle Angle of the text strings.
- *
- * Sets the angle at which text strings will be drawn if the text
- * direction has been set to IMLIB_TEXT_TO_ANGLE with
- * imlib_context_set_direction().
- */
-void
-imlib_context_set_angle(double angle)
-{
- if (!ctx)
- ctx = imlib_context_new();
- ctx->angle = angle;
-}
-
-/**
- * @return The current angle of the text strings.
- *
- * Returns the current angle used to render text at if the direction
- * is IMLIB_TEXT_TO_ANGLE.
- */
-double
-imlib_context_get_angle(void)
-{
- if (!ctx)
- ctx = imlib_context_new();
- return ctx->angle;
-}
-
-/**
- * @return The current direction of the text.
- *
- * Returns the current direction to render text in.
- */
-Imlib_Text_Direction
-imlib_context_get_direction(void)
-{
- if (!ctx)
- ctx = imlib_context_new();
- return ctx->direction;
-}
-
-/**
- * @param red Red channel of the current color.
- * @param green Green channel of the current color.
- * @param blue Blue channel of the current color.
- * @param alpha Alpha channel of the current color.
- *
- * Sets the color with which text, lines and rectangles are drawn when
- * being rendered onto an image. Values for @p red, @p green, @p blue
- * and @p alpha are between 0 and 255 - any other values have
- * undefined results.
- */
-void
-imlib_context_set_color(int red, int green, int blue, int alpha)
-{
- if (!ctx)
- ctx = imlib_context_new();
- ctx->color.red = red;
- ctx->color.green = green;
- ctx->color.blue = blue;
- ctx->color.alpha = alpha;
-}
-
-/**
- * @param red Red channel of the current color.
- * @param green Green channel of the current color.
- * @param blue Blue channel of the current color.
- * @param alpha Alpha channel of the current color.
- *
- * Returns the current color for rendering text, rectangles and lines.
- */
-void
-imlib_context_get_color(int *red, int *green, int *blue, int *alpha)
-{
- if (!ctx)
- ctx = imlib_context_new();
- *red = ctx->color.red;
- *green = ctx->color.green;
- *blue = ctx->color.blue;
- *alpha = ctx->color.alpha;
-}
-
-/**
- * @return The current color.
- *
- * Returns the current color as a color struct. Do NOT free this
- * pointer.
- */
-Imlib_Color *
-imlib_context_get_imlib_color(void)
-{
- if (!ctx)
- ctx = imlib_context_new();
- return &ctx->color;
-}
-
-/**
- * @param hue Hue channel of the current color.
- * @param saturation Saturation channel of the current color.
- * @param value Value channel of the current color.
- * @param alpha Alpha channel of the current color.
- *
- * Sets the color in HSVA space. Values for @p hue are between 0 and 360,
- * values for @p saturation and @p value between 0 and 1, and values for
- * @p alpha are between 0 and 255 - any other values have undefined
- * results.
- */
-void
-imlib_context_set_color_hsva(float hue, float saturation, float value,
- int alpha)
-{
- int r, g, b;
-
- __imlib_hsv_to_rgb(hue, saturation, value, &r, &g, &b);
- imlib_context_set_color(r, g, b, alpha);
-}
-
-/**
- * @param hue Hue channel of the current color.
- * @param saturation Saturation channel of the current color.
- * @param value Value channel of the current color.
- * @param alpha Alpha channel of the current color.
- *
- * Returns the current color for rendering text, rectangles and lines
- * in HSVA space.
- */
-void
-imlib_context_get_color_hsva(float *hue, float *saturation, float *value,
- int *alpha)
-{
- int r, g, b;
-
- imlib_context_get_color(&r, &g, &b, alpha);
- __imlib_rgb_to_hsv(r, g, b, hue, saturation, value);
-}
-
-/**
- * @param hue Hue channel of the current color.
- * @param lightness Lightness channel of the current color.
- * @param saturation Saturation channel of the current color.
- * @param alpha Alpha channel of the current color.
- *
- * Sets the color in HLSA space. Values for @p hue are between 0 and 360,
- * values for @p lightness and @p saturation between 0 and 1, and values for
- * @p alpha are between 0 and 255 - any other values have undefined
- * results.
- */
-void
-imlib_context_set_color_hlsa(float hue, float lightness, float saturation,
- int alpha)
-{
- int r, g, b;
-
- __imlib_hls_to_rgb(hue, lightness, saturation, &r, &g, &b);
- imlib_context_set_color(r, g, b, alpha);
-}
-
-/**
- * @param hue Hue channel of the current color.
- * @param lightness Lightness channel of the current color.
- * @param saturation Saturation channel of the current color.
- * @param alpha Alpha channel of the current color.
- *
- * Returns the current color for rendering text, rectangles and lines
- * in HLSA space.
- */
-void
-imlib_context_get_color_hlsa(float *hue, float *lightness, float *saturation,
- int *alpha)
-{
- int r, g, b;
-
- imlib_context_get_color(&r, &g, &b, alpha);
- __imlib_rgb_to_hls(r, g, b, hue, lightness, saturation);
-}
-
-/**
- * @param cyan Cyan channel of the current color.
- * @param magenta Magenta channel of the current color.
- * @param yellow Yellow channel of the current color.
- * @param alpha Alpha channel of the current color.
- *
- * Sets the color in CMYA space. Values for @p cyan, @p magenta, @p yellow and
- * @p alpha are between 0 and 255 - any other values have undefined
- * results.
- */
-void
-imlib_context_set_color_cmya(int cyan, int magenta, int yellow, int alpha)
-{
- if (!ctx)
- ctx = imlib_context_new();
- ctx->color.red = 255 - cyan;
- ctx->color.green = 255 - magenta;
- ctx->color.blue = 255 - yellow;
- ctx->color.alpha = alpha;
-}
-
-/**
- * @param cyan Cyan channel of the current color.
- * @param magenta Magenta channel of the current color.
- * @param yellow Yellow channel of the current color.
- * @param alpha Alpha channel of the current color.
- *
- * Returns the current color for rendering text, rectangles and lines
- * in CMYA space.
- */
-void
-imlib_context_get_color_cmya(int *cyan, int *magenta, int *yellow, int *alpha)
-{
- if (!ctx)
- ctx = imlib_context_new();
- *cyan = 255 - ctx->color.red;
- *magenta = 255 - ctx->color.green;
- *yellow = 255 - ctx->color.blue;
- *alpha = ctx->color.alpha;
-}
-
-/**
- * @param color_range Color range.
- *
- * Sets the current color range to use for rendering gradients.
- */
-void
-imlib_context_set_color_range(Imlib_Color_Range color_range)
-{
- if (!ctx)
- ctx = imlib_context_new();
- ctx->color_range = color_range;
-}
-
-/**
- * @return The current color range.
- *
- * Returns the current color range being used for gradients.
- */
-Imlib_Color_Range
-imlib_context_get_color_range(void)
-{
- if (!ctx)
- ctx = imlib_context_new();
- return ctx->color_range;
-}
-
-/**
- * @param progress_function A progress function.
- *
- * Sets the progress function to be called back whilst loading
- * images. Set this to the function to be called, or set it to NULL to
- * disable progress callbacks whilst loading.
- */
-void
-imlib_context_set_progress_function(Imlib_Progress_Function progress_function)
-{
- if (!ctx)
- ctx = imlib_context_new();
- ctx->progress_func = progress_function;
-}
-
-/**
- * @return The current progress function.
- *
- * Returns the current progress function being used.
- */
-Imlib_Progress_Function
-imlib_context_get_progress_function(void)
-{
- if (!ctx)
- ctx = imlib_context_new();
- return ctx->progress_func;
-}
-
-/**
- * @param progress_granularity A char.
- *
- * This hints as to how often to call the progress callback. 0 means
- * as often as possible. 1 means whenever 15 more of the image has been
- * decoded, 10 means every 10% of the image decoding, 50 means every
- * 50% and 100 means only call at the end. Values outside of the range
- * 0-100 are undefined.
- */
-void
-imlib_context_set_progress_granularity(char progress_granularity)
-{
- if (!ctx)
- ctx = imlib_context_new();
- ctx->progress_granularity = progress_granularity;
-}
-
-/**
- * @return The current progress granularity
- *
- * Returns the current progress granularity being used.
- */
-char
-imlib_context_get_progress_granularity(void)
-{
- if (!ctx)
- ctx = imlib_context_new();
- return ctx->progress_granularity;
-}
-
-/**
- * @param image Current image.
- *
- * Sets the current image Imlib2 will be using with its function calls.
- */
-void
-imlib_context_set_image(Imlib_Image image)
-{
- if (!ctx)
- ctx = imlib_context_new();
- ctx->image = image;
-}
-
-/**
- * @return The current image.
- *
- * Returns the current context image.
- */
-Imlib_Image
-imlib_context_get_image(void)
-{
- if (!ctx)
- ctx = imlib_context_new();
- return ctx->image;
-}
-
-void
-imlib_context_set_TTF_encoding(Imlib_TTF_Encoding encoding)
-{
- if (!ctx)
- ctx = imlib_context_new();
- ctx->encoding = encoding;
-}
-
-Imlib_TTF_Encoding
-imlib_context_get_TTF_encoding(void)
-{
- if (!ctx)
- ctx = imlib_context_new();
- return ctx->encoding;
-}
-
-/* imlib api */
-
-/**
- * @return The current image size.
- *
- * Returns the current size of the image cache in bytes. The cache is
- * a unified cache used for image data AND pixmaps.
- */
-int
-imlib_get_cache_size(void)
-{
- if (!ctx)
- ctx = imlib_context_new();
- return __imlib_GetCacheSize();
-}
-
-/**
- * @param bytes Cache size.
- *
- * Sets the cache size. The size is in bytes. Setting the cache size to
- * 0 effectively flushes the cache and keeps the cache size at 0 until
- * set to another value. Whenever you set the cache size Imlib2 will
- * flush as many old images and pixmap from the cache as needed until
- * the current cache usage is less than or equal to the cache size.
- */
-void
-imlib_set_cache_size(int bytes)
-{
- if (!ctx)
- ctx = imlib_context_new();
- __imlib_SetCacheSize(bytes);
-}
-
-/**
- * @return The current number of colors.
- *
- * Gets the number of colors Imlib2 currently at a maximum is allowed
- * to allocate for rendering. The default is 256.
- */
-int
-imlib_get_color_usage(void)
-{
- if (!ctx)
- ctx = imlib_context_new();
-#ifndef X_DISPLAY_MISSING
- return (int)_max_colors;
-#else
- return 256;
-#endif
-}
-
-/**
- * @param max Maximum number of colors.
- *
- * Sets the maximum number of colors you would like Imlib2 to allocate
- * for you when rendering. The default is 256. This has no effect in
- * depths greater than 8 bit.
- */
-void
-imlib_set_color_usage(int max)
-{
- if (!ctx)
- ctx = imlib_context_new();
-#ifndef X_DISPLAY_MISSING
- if (max < 2)
- max = 2;
- else if (max > 256)
- max = 256;
- _max_colors = max;
-#endif
-}
-
-/**
- * If you want Imlib2 to forcibly flush any cached loaders it has and
- * re-load them from disk (this is useful if the program just
- * installed a new loader and does not want to wait till Imlib2 deems
- * it an optimal time to rescan the loaders)
- */
-void
-imlib_flush_loaders(void)
-{
- if (!ctx)
- ctx = imlib_context_new();
- __imlib_RemoveAllLoaders();
- LTDL_Exit();
-}
-
-#ifndef X_DISPLAY_MISSING
-/**
- * @param display The current display
- * @param visual The current visual
- * @return
- *
- * Convenience function that returns the depth of a visual for that
- * display.
- */
-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);
- CHECK_PARAM_POINTER_RETURN("imlib_get_visual_depth", "visual", visual, 0);
- return __imlib_XActualDepth(display, visual);
-}
-
-/**
- * @param display The current display
- * @param screen The screen
- * @param depth_return The depth of the returned visual.
- * @return The best visual.
- *
- * Returns the visual for the display @p display and the screen @p
- * screen that Imlib2 thinks
- * will give you the best quality output. @p depth_return should point to
- * an int that will be filled with the depth of that visual too.
- */
-Visual *
-imlib_get_best_visual(Display * display, int screen, int *depth_return)
-{
- 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",
- depth_return, NULL);
- return __imlib_BestVisual(display, screen, depth_return);
-}
-#endif
-
-/**
- * @param file Image file.
- * @return An image handle.
- *
- * Loads an image from disk located at the path specified by
- * @p file. Please see the section \ref loading for more
- * detail. Returns an image handle on success or NULL on failure.
- */
-Imlib_Image
-imlib_load_image(const char *file)
-{
- Imlib_Image im = NULL;
- Imlib_Image prev_ctxt_image;
-
- 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);
- ctx->image = prev_ctxt_image;
- return (Imlib_Image) im;
-}
-
-/**
- * @param file Image file.
- * @return An image handle.
- *
- * Loads an image from disk located at the path specified by
- * @p file. This forces the image data to be decoded at load time too,
- * instead of decoding being deferred until it is needed. Returns an
- * image handle on success or NULL on failure.
- */
-Imlib_Image
-imlib_load_image_immediately(const char *file)
-{
- Imlib_Image im = NULL;
- Imlib_Image prev_ctxt_image;
-
- 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);
- ctx->image = prev_ctxt_image;
- return (Imlib_Image) im;
-}
-
-/**
- * @param file Image file.
- * @return An image handle.
- *
- * Loads the image without looking in the cache first. Returns an
- * image handle on success or NULL on failure.
- */
-Imlib_Image
-imlib_load_image_without_cache(const char *file)
-{
- 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);
- prev_ctxt_image = ctx->image;
- im = __imlib_LoadImage(file, (ImlibProgressFunction) ctx->progress_func,
- ctx->progress_granularity, 0, 1, NULL);
- ctx->image = prev_ctxt_image;
- return (Imlib_Image) im;
-}
-
-/**
- * @param file Image file.
- * @return An image handle.
- *
- * Loads the image without deferred image data decoding (i.e. it is
- * decoded straight away) and without looking in the cache. Returns an
- * image handle on success or NULL on failure.
- */
-Imlib_Image
-imlib_load_image_immediately_without_cache(const char *file)
-{
- Imlib_Image im = NULL;
- Imlib_Image prev_ctxt_image;
-
- 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);
- ctx->image = prev_ctxt_image;
- return (Imlib_Image) im;
-}
-
-/**
- * @param file Image file.
- * @param error_return The returned error.
- * @return An image handle.
- *
- * Loads an image at the path @p file on disk. If it succeeds it returns
- * a valid image handle, if not NULL is returned and @p error_return
- * is set to the detail of the error.
- */
-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;
-
- 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;
- }
- if (__imlib_FileIsDir(file))
- {
- *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;
- }
- prev_ctxt_image = ctx->image;
- 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;
- }
- return im;
-}
-
-/**
- * Frees the image that is set as the current image in Imlib2's context.
- */
-void
-imlib_free_image(void)
-{
- if (!ctx)
- ctx = imlib_context_new();
- CHECK_PARAM_POINTER("imlib_free_image", "image", ctx->image);
- __imlib_FreeImage(ctx->image);
- ctx->image = NULL;
-}
-
-/**
- * Frees the current image in Imlib2's context AND removes it from the
- * cache.
- */
-void
-imlib_free_image_and_decache(void)
-{
- ImlibImage *im;
-
- 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);
- __imlib_FreeImage(im);
- ctx->image = NULL;
-}
-
-/**
- * Returns the width in pixels of the current image in Imlib2's context.
- */
-int
-imlib_image_get_width(void)
-{
- ImlibImage *im;
-
- 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;
-}
-
-/**
- * Returns the height in pixels of the current image in Imlib2's context.
- */
-int
-imlib_image_get_height(void)
-{
- ImlibImage *im;
-
- 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;
-}
-
-/**
- * @return The current filename.
- *
- * Returns the filename for the file that is set as the current
- * context. The pointer returned is only valid as long as no operations
- * cause the filename of the image to change. Saving the file with a
- * different name would cause this. It is suggested you duplicate the
- * string if you wish to continue to use the string for later
- * processing. Do not free the string pointer returned by this
- * function.
- */
-const char *
-imlib_image_get_filename(void)
-{
- ImlibImage *im;
-
- 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 A pointer to the image data.
- *
- * Returns a pointer to the image data in the image set as the image
- * for the current context. When you get this pointer it is assumed you
- * are planning on writing to the data, thus once you do this the image
- * can no longer be used for caching - in fact all images cached from
- * this one will also be affected when you put the data back. If this
- * matters it is suggested you clone the image first before playing
- * with the image data. The image data is returned in the format of a
- * DATA32 (32 bits) per pixel in a linear array ordered from the top
- * left of the image to the bottom right going from left to right each
- * line. Each pixel has the upper 8 bits as the alpha channel and the
- * lower 8 bits are the blue channel - so a pixel's bits are ARGB (from
- * most to least significant, 8 bits per channel). You must put the
- * data back at some point.
- */
-DATA32 *
-imlib_image_get_data(void)
-{
- ImlibImage *im;
-
- if (!ctx)
- ctx = imlib_context_new();
- CHECK_PARAM_POINTER_RETURN("imlib_image_get_data", "image", ctx->image,
- NULL);
- CAST_IMAGE(im, ctx->image);
- if ((!(im->data)) && (im->loader) && (im->loader->load))
- im->loader->load(im, NULL, 0, 1);
- if (!im->data)
- return NULL;
- __imlib_DirtyImage(im);
- return im->data;
-}
-
-/**
- * @return A pointer to the image data.
- *
- * Functions the same way as imlib_image_get_data(), but returns a
- * pointer expecting the program to NOT write to the data returned (it
- * is for inspection purposes only). Writing to this data has undefined
- * results. The data does not need to be put back.
- */
-DATA32 *
-imlib_image_get_data_for_reading_only(void)
-{
- ImlibImage *im;
-
- 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);
- if ((!(im->data)) && (im->loader) && (im->loader->load))
- im->loader->load(im, NULL, 0, 1);
- if (!im->data)
- return NULL;
- return im->data;
-}
-
-/**
- * @param data The pointer to the image data.
- *
- * Puts back @p data when it was obtained by
- * imlib_image_get_data(). @p data must be the same pointer returned
- * by imlib_image_get_data(). This operated on the current context
- * image.
- */
-void
-imlib_image_put_back_data(DATA32 * data)
-{
- ImlibImage *im;
-
- 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);
- __imlib_DirtyImage(im);
- data = NULL;
-}
-
-/**
- * @return Current alpha channel flag.
- *
- * Returns 1 if the current context image has an alpha channel, or 0
- * if it does not (the alpha data space is still there and available -
- * just "unused").
- */
-char
-imlib_image_has_alpha(void)
-{
- ImlibImage *im;
-
- 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;
- return 0;
-}
-
-/**
- * By default Imlib2 will not check the timestamp of an image on disk
- * and compare it with the image in its cache - this is to minimize
- * disk activity when using the cache. Call this function and it will
- * flag the current context image as being liable to change on disk
- * and Imlib2 will check the timestamp of the image file on disk and
- * compare it with the cached image when it next needs to use this
- * image in the cache.
- */
-void
-imlib_image_set_changes_on_disk(void)
-{
- ImlibImage *im;
-
- if (!ctx)
- ctx = imlib_context_new();
- CHECK_PARAM_POINTER("imlib_image_set_never_changes_on_disk", "image",
- ctx->image);
- CAST_IMAGE(im, ctx->image);
- SET_FLAG(im->flags, F_ALWAYS_CHECK_DISK);
-}
-
-/**
- * @param border The border of the image.
- *
- * Fills the Imlib_Border structure to which @p border points to with the
- * values of the border of the current context image. The border is the
- * area at the edge of the image that does not scale with the rest of
- * the image when resized - the borders remain constant in size. This
- * is useful for scaling bevels at the edge of images differently to
- * the image center.
- */
-void
-imlib_image_get_border(Imlib_Border * border)
-{
- ImlibImage *im;
-
- 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);
- border->left = im->border.left;
- border->right = im->border.right;
- border->top = im->border.top;
- border->bottom = im->border.bottom;
-}
-
-/**
- * @param border The border of the image.
- *
- * Sets the border of the current context image to the values contained
- * in the Imlib_Border structure @p border points to.
- */
-void
-imlib_image_set_border(Imlib_Border * border)
-{
- ImlibImage *im;
-
- 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);
- if ((im->border.left == border->left)
- && (im->border.right == border->right)
- && (im->border.top == border->top)
- && (im->border.bottom == border->bottom))
- return;
- im->border.left = border->left;
- im->border.right = border->right;
- im->border.top = border->top;
- im->border.bottom = border->bottom;
- __imlib_DirtyPixmapsForImage(im);
-}
-
-/**
- * @param format Format of the image.
- *
- * Sets the format of the current image. This is used for when you
- * wish to save an image in a different format that it was loaded in,
- * or if the image currently has no file format associated with it.
- */
-void
-imlib_image_set_format(const char *format)
-{
- ImlibImage *im;
-
- 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);
- if (im->format)
- free(im->format);
- if (format)
- im->format = strdup(format);
- else
- im->format = NULL;
- if (!(im->flags & F_FORMAT_IRRELEVANT))
- {
- __imlib_DirtyImage(im);
- }
-}
-
-/**
- * @param irrelevant Irrelevant format flag.
- *
- * Sets if the format value of the current image is irrelevant for
- * caching purposes - by default it is. pass irrelevant as 1 to make it
- * irrelevant and 0 to make it relevant for caching.
- */
-void
-imlib_image_set_irrelevant_format(char irrelevant)
-{
- ImlibImage *im;
-
- 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);
- }
- else
- {
- UNSET_FLAG(im->flags, F_FORMAT_IRRELEVANT);
- }
-}
-
-/**
- * @param irrelevant Irrelevant border flag.
- *
- * Sets if the border of the current image is irrelevant for caching
- * purposes. By default it is. Set irrelevant to 1 to make it
- * irrelevant, and 0 to make it relevant.
- */
-void
-imlib_image_set_irrelevant_border(char irrelevant)
-{
- ImlibImage *im;
-
- 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);
- }
- else
- {
- UNSET_FLAG(im->flags, F_BORDER_IRRELEVANT);
- }
-}
-
-/**
- * @param irrelevant Irrelevant alpha flag.
- *
- * Sets if the alpha channel status of the current image (i.e. if
- * there is or is not one) is important for caching purposes. By
- * default it is not. Set irrelevant to 1 to make it irrelevant and 0
- * to make it relevant.
- */
-void
-imlib_image_set_irrelevant_alpha(char irrelevant)
-{
- ImlibImage *im;
-
- 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);
- }
- else
- {
- UNSET_FLAG(im->flags, F_ALPHA_IRRELEVANT);
- }
-}
-
-/**
- * @return Current image format.
- *
- * Returns the current image's format. Do not free this
- * string. Duplicate it if you need it for later use.
- */
-char *
-imlib_image_format(void)
-{
- ImlibImage *im;
-
- 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;
-}
-
-/**
- * @param has_alpha Alpha flag.
- *
- * Sets the alpha flag for the current image. Set @p has_alpha to 1 to
- * enable the alpha channel in the current image, or 0 to disable it.
- */
-void
-imlib_image_set_has_alpha(char has_alpha)
-{
- ImlibImage *im;
-
- 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)
- SET_FLAG(im->flags, F_HAS_ALPHA);
- else
- UNSET_FLAG(im->flags, F_HAS_ALPHA);
-}
-
-#ifndef X_DISPLAY_MISSING
-/**
- * @param pixmap_return The returned pixmap.
- * @param mask_return The returned mask.
- *
- * Creates a pixmap of the current image (and a mask if the image has
- * an alpha value) and return the id's of the pixmap and mask to
- * @p pixmap_return and @p mask_return pixmap id's. You must free these
- * pixmaps using Imlib2's free function imlib_free_pixmap_and_mask();.
- */
-void
-imlib_render_pixmaps_for_whole_image(Pixmap * pixmap_return,
- Pixmap * mask_return)
-{
- ImlibImage *im;
-
- 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",
- "pixmap_return", pixmap_return);
- CHECK_PARAM_POINTER("imlib_render_pixmaps_for_whole_image", "mask_return",
- mask_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;
- __imlib_CreatePixmapsForImage(ctx->display, ctx->drawable, ctx->visual,
- ctx->depth, ctx->colormap, im, pixmap_return,
- mask_return, 0, 0, im->w, im->h, im->w,
- im->h, 0, ctx->dither, ctx->dither_mask,
- ctx->color_modifier);
-}
-
-/**
- * @param pixmap_return The returned pixmap.
- * @param mask_return The returned mask.
- * @param width Width of the pixmap.
- * @param height Height of the pixmap.
- *
- * Works just like imlib_render_pixmaps_for_whole_image(), but will
- * scale the output result to the width @p width and height @p height
- * specified. Scaling
- * is done before depth conversion so pixels used for dithering don't
- * grow large.
- */
-void
-imlib_render_pixmaps_for_whole_image_at_size(Pixmap * pixmap_return,
- Pixmap * mask_return, int width,
- int height)
-{
- ImlibImage *im;
-
- 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",
- "pixmap_return", pixmap_return);
- CHECK_PARAM_POINTER("imlib_render_pixmaps_for_whole_image_at_size",
- "mask_return", mask_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;
- __imlib_CreatePixmapsForImage(ctx->display, ctx->drawable, ctx->visual,
- ctx->depth, ctx->colormap, im, pixmap_return,
- mask_return, 0, 0, im->w, im->h, width,
- height, ctx->anti_alias, ctx->dither,
- ctx->dither_mask, ctx->color_modifier);
-}
-
-/**
- * @param pixmap The pixmap.
- *
- * Frees @p pixmap (and any mask generated in association with that
- * pixmap). The pixmap will remain cached until the image the pixmap
- * was generated from is dirtied or decached, or the cache is flushed.
- */
-void
-imlib_free_pixmap_and_mask(Pixmap pixmap)
-{
- if (!ctx)
- ctx = imlib_context_new();
- __imlib_FreePixmap(ctx->display, pixmap);
-}
-
-/**
- * @param x X coordinate of the pixel.
- * @param y Y coordinate of the pixel.
- *
- * Renders the current image onto the current drawable at the (@p x, @p y)
- * pixel location specified without scaling.
- */
-void
-imlib_render_image_on_drawable(int x, int y)
-{
- ImlibImage *im;
-
- 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))
- im->loader->load(im, NULL, 0, 1);
- if (!(im->data))
- return;
- __imlib_RenderImage(ctx->display, im, ctx->drawable, ctx->mask,
- ctx->visual, ctx->colormap, ctx->depth, 0, 0, im->w,
- im->h, x, y, im->w, im->h, 0, ctx->dither, ctx->blend,
- ctx->dither_mask, ctx->color_modifier, ctx->operation);
-}
-
-/**
- * @param x X coordinate of the pixel.
- * @param y Y coordinate of the pixel.
- * @param width Width of the rendered image.
- * @param height Height of the rendered image.
- *
- * Renders the current image onto the current drawable at the (@p x, @p y)
- * location specified AND scale the image to the width @p width and height
- * @p height.
- */
-void
-imlib_render_image_on_drawable_at_size(int x, int y, int width, int height)
-{
- ImlibImage *im;
-
- if (!ctx)
- ctx = imlib_context_new();
- CHECK_PARAM_POINTER("imlib_render_image_on_drawable_at_size", "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;
- __imlib_RenderImage(ctx->display, im, ctx->drawable, ctx->mask,
- ctx->visual, ctx->colormap, ctx->depth, 0, 0, im->w,
- im->h, x, y, width, height, ctx->anti_alias,
- ctx->dither, ctx->blend, ctx->dither_mask,
- ctx->color_modifier, ctx->operation);
-}
-
-/**
- * @param source_x X coordinate of the source image.
- * @param source_y Y coordinate of the source image.
- * @param source_width Width of the source image.
- * @param source_height Height of the source image.
- * @param x X coordinate of the destination image.
- * @param y Y coordinate of the destination image.
- * @param width Width of the destination image.
- * @param height Height of the destination image.
- *
- * Renders the source (@p source_x, @p source_y, @p source_width, @p source_height) pixel
- * rectangle from the
- * current image onto the current drawable at the (@p x, @p y) location scaled
- * to the width @p width and height @p height.
- */
-void
-imlib_render_image_part_on_drawable_at_size(int source_x, int source_y,
- int source_width,
- int source_height, int x, int y,
- int width, int height)
-{
- ImlibImage *im;
-
- 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);
- if ((!(im->data)) && (im->loader) && (im->loader->load))
- im->loader->load(im, NULL, 0, 1);
- if (!(im->data))
- return;
- __imlib_RenderImage(ctx->display, im, ctx->drawable, 0, ctx->visual,
- ctx->colormap, ctx->depth, source_x, source_y,
- source_width, source_height, x, y, width, height,
- ctx->anti_alias, ctx->dither, ctx->blend, 0,
- ctx->color_modifier, ctx->operation);
-}
-
-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);
-}
-
-#endif
-
-/**
- * @param source_image The source image.
- * @param merge_alpha Alpha flag.
- * @param source_x X coordinate of the source image.
- * @param source_y Y coordinate of the source image.
- * @param source_width Width of the source image.
- * @param source_height Height of the source image.
- * @param destination_x X coordinate of the destination image.
- * @param destination_y Y coordinate of the destination image.
- * @param destination_width Width of the destination image.
- * @param destination_height Height of the destination image.
- *
- * Blends the source rectangle (@p source_x, @p source_y, @p
- * source_width, @p source_height) from
- * @p source_image onto the current image at the destination (@p
- * destination_x, @p destination_y) location
- * scaled to the width @p destination_width and height @p
- * destination_height. If @p merge_alpha is set to 1
- * it will also modify the destination image alpha channel, otherwise
- * the destination alpha channel is left untouched.
- */
-void
-imlib_blend_image_onto_image(Imlib_Image source_image, char merge_alpha,
- int source_x, int source_y, int source_width,
- int source_height, int destination_x,
- int destination_y, int destination_width,
- int destination_height)
-{
- 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);
- CAST_IMAGE(im_src, source_image);
- CAST_IMAGE(im_dst, ctx->image);
- if ((!(im_src->data)) && (im_src->loader) && (im_src->loader->load))
- im_src->loader->load(im_src, NULL, 0, 1);
- if (!(im_src->data))
- return;
- if ((!(im_dst->data)) && (im_dst->loader) && (im_dst->loader->load))
- im_dst->loader->load(im_dst, NULL, 0, 1);
- if (!(im_dst->data))
- return;
- __imlib_DirtyImage(im_dst);
- /* 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;
- __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);
-}
-
-/**
- * @param width The width of the image.
- * @param height The height of the image.
- * @return A new blank image.
- *
- * Creates a new blank image of size @p width and @p height. The contents of
- * this image at creation time are undefined (they could be garbage
- * memory). You are free to do whatever you like with this image. It
- * is not cached. On success an image handle is returned - on failure
- * NULL is returned.
- **/
-Imlib_Image
-imlib_create_image(int width, int height)
-{
- DATA32 *data;
-
- if (!ctx)
- ctx = imlib_context_new();
- if ((width <= 0) || (height <= 0))
- return NULL;
- data = malloc(width * height * sizeof(DATA32));
- if (data)
- return (Imlib_Image) __imlib_CreateImage(width, height, data);
- return NULL;
-}
-
-/**
- * @param width The width of the image.
- * @param height The height of the image.
- * @param data The data.
- * @return A valid image, otherwise NULL.
- *
- * Creates an image from the image data specified with the width @p width and
- * the height @p height specified. The image data @p data must be in the same format as
- * imlib_image_get_data() would return. You are responsible for
- * freeing this image data once the image is freed - Imlib2 will not
- * do that for you. This is useful for when you already have static
- * buffers of the same format Imlib2 uses (many video grabbing devices
- * use such a format) and wish to use Imlib2 to render the results
- * onto another image, or X drawable. You should free the image when
- * you are done with it. Imlib2 returns a valid image handle on
- * success or NULL on failure
- *
- **/
-Imlib_Image
-imlib_create_image_using_data(int width, int height, DATA32 * data)
-{
- ImlibImage *im;
-
- if (!ctx)
- ctx = imlib_context_new();
- CHECK_PARAM_POINTER_RETURN("imlib_create_image_using_data", "data", data,
- NULL);
- if ((width <= 0) || (height <= 0))
- return NULL;
- im = __imlib_CreateImage(width, height, data);
- if (im)
- SET_FLAG(im->flags, F_DONT_FREE_DATA);
- return (Imlib_Image) im;
-}
-
-/**
- * @param width The width of the image.
- * @param height The height of the image.
- * @param data The data.
- * @return A valid image, otherwise NULL.
- *
- * Works the same way as imlib_create_image_using_data() but Imlib2
- * copies the image data to the image structure. You may now do
- * whatever you wish with the original data as it will not be needed
- * anymore. Imlib2 returns a valid image handle on success or NULL on
- * failure.
- *
- **/
-Imlib_Image
-imlib_create_image_using_copied_data(int width, int height, DATA32 * data)
-{
- ImlibImage *im;
-
- if (!ctx)
- ctx = imlib_context_new();
- CHECK_PARAM_POINTER_RETURN("imlib_create_image_using_copied_data", "data",
- data, NULL);
- if ((width <= 0) || (height <= 0))
- return NULL;
- im = __imlib_CreateImage(width, height, NULL);
- if (!im)
- return NULL;
- im->data = malloc(width * height * sizeof(DATA32));
- if (data)
- {
- memcpy(im->data, data, width * height * sizeof(DATA32));
- return (Imlib_Image) im;
- }
- else
- __imlib_FreeImage(im);
- return NULL;
-}
-
-#ifndef X_DISPLAY_MISSING
-/**
- * @param mask A mask.
- * @param x The top left x coordinate of the rectangle.
- * @param y The top left y coordinate of the rectangle.
- * @param width The width of the rectangle.
- * @param height The height of the rectangle.
- * @param need_to_grab_x Grab flag.
- * @return a valid image, otherwise NULL.
- *
- * Return an image (using the mask @p mask to determine the alpha channel)
- * from the current drawable. If the mask is 0 it will not create a
- * useful alpha channel in the image. It will create an image from the
- * (@p x, @p y, @p width , @p height) rectangle in the drawable. If @p
- * need_to_grab_x
- * is 1 it will also grab the X Server to avoid possible race
- * conditions in grabbing. If you have not already grabbed the server
- * you MUST set this to 1. Imlib2 returns a valid image handle on
- * success or NULL on failure.
- *
- **/
-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;
-
- if (!ctx)
- ctx = imlib_context_new();
- if (mask)
- domask = 1;
- im = __imlib_CreateImage(width, height, NULL);
- im->data = malloc(width * height * sizeof(DATA32));
- __imlib_GrabDrawableToRGBA(im->data, 0, 0, width, height, ctx->display,
- ctx->drawable, mask, ctx->visual, ctx->colormap,
- ctx->depth, x, y, width, height, domask,
- need_to_grab_x);
- return (Imlib_Image) im;
-}
-
-/**
- * @param image An image.
- * @param mask A mask.
- * @param x The top left x coordinate of the rectangle.
- * @param y The top left y coordinate of the rectangle.
- * @param width The width of the rectangle.
- * @param height The height of the rectangle.
- * @param need_to_grab_x Grab flag.
- * @return a valid image, otherwise NULL.
- *
- *
- **/
-Imlib_Image
-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;
-
- 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);
- return (Imlib_Image) im;
-}
-
-/**
- * @param mask A mask.
- * @param source_x The top left x coordinate of the rectangle.
- * @param source_y The top left y coordinate of the rectangle.
- * @param source_width The width of the rectangle.
- * @param source_height The height of the rectangle.
- * @param destination_width The width of the returned image.
- * @param destination_height The height of the returned image.
- * @param need_to_grab_x Grab flag.
- * @param get_mask_from_shape A char.
- * @return A valid image, otherwise NULL.
- *
- * Creates an image from the current drawable (optionally using the
- * @p mask pixmap specified to determine alpha transparency) and scale
- * the grabbed data first before converting to an actual image (to
- * minimize reads from the frame buffer which can be slow). The source
- * (@p source_x, @p source_y, @p source_width, @p source_height) rectangle will be grabbed, scaled to the
- * destination @p destination_width and @p destination_height, then converted to an image. If
- * @p need_to_grab_x is set to 1, X is grabbed (set this to 1 unless you
- * have already grabbed the server) and if @p get_mask_from_shape and the
- * current drawable is a window its shape is used for determining the
- * alpha channel. If successful this function will return a valid
- * image handle, otherwise NULL is returned.
- *
- **/
-Imlib_Image
-imlib_create_scaled_image_from_drawable(Pixmap mask, int source_x,
- int source_y, int source_width,
- int source_height,
- int destination_width,
- int destination_height,
- 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;
-
- 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);
- 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);
- }
- 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 */
- }
- 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, x, 0);
- if (m != None)
- XCopyArea(ctx->display, mask, m, mgc, xx, 0, 1, source_height, x,
- 0);
- }
- for (x = 0; x < destination_height; x++)
- {
- xx = (source_height * x) / destination_height;
- XCopyArea(ctx->display, p, p, gc, 0, source_y + xx,
- destination_width, 1, 0, x);
- if (m != None)
- XCopyArea(ctx->display, m, m, mgc, 0, source_y + xx,
- destination_width, 1, 0, x);
- }
- 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,
- source_height, ctx->display, p, m,
- ctx->visual, ctx->colormap, ctx->depth, 0, 0,
- destination_width, destination_height, domask,
- 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, gc);
- return (Imlib_Image) im;
-}
-
-/**
- * @param mask A mask.
- * @param x The top left x coordinate of the rectangle.
- * @param y The top left y coordinate of the rectangle.
- * @param width The width of the rectangle.
- * @param height The height of the rectangle.
- * @param destination_x The x coordinate of the new location.
- * @param destination_y The x coordinate of the new location.
- * @param need_to_grab_x Grab flag.
- * @return A char.
- *
- * Grabs a section of the current drawable (optionally using the
- * pixmap @p mask
- * provided as a corresponding mask for that drawable - if @p mask is 0
- * this is not used). It grabs the (@p x, @p y, @p width, @p height) rectangle and
- * places it at the destination (@p destination_x, @p destination_y) location in the current image. If
- * @p need_to_grab_x is 1 it will grab and ungrab the server whilst doing
- * this - you need to do this if you have not already grabbed the
- * server.
- *
- **/
-char
-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;
-
- if (!ctx)
- ctx = imlib_context_new();
- CHECK_PARAM_POINTER_RETURN("imlib_copy_drawable_to_image", "image",
- ctx->image, 0);
- if (mask)
- domask = 1;
- CAST_IMAGE(im, ctx->image);
-
- if ((!(im->data)) && (im->loader) && (im->loader->load))
- im->loader->load(im, NULL, 0, 1);
- if (!(im->data))
- return 0;
-
- pre_adj = 0;
- if (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;
- }
- if ((destination_x + width) >= im->w)
- width = im->w - destination_x;
-
- pre_adj = 0;
- if (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;
- }
- if ((destination_y + height) >= im->h)
- height = im->h - destination_y;
-
- if ((width <= 0) || (height <= 0))
- return 0;
- __imlib_DirtyImage(im);
- return __imlib_GrabDrawableToRGBA(im->data, destination_x, destination_y,
- im->w, im->h, ctx->display,
- ctx->drawable, mask, ctx->visual,
- ctx->colormap, ctx->depth, x, y, width,
- height, domask, need_to_grab_x);
-}
-#endif
-
-/**
- * @return A valid image, otherwise NULL.
- *
- * Creates an exact duplicate of the current image and returns a valid
- * image handle on success, or NULL on failure.
- *
- **/
-Imlib_Image
-imlib_clone_image(void)
-{
- ImlibImage *im, *im_old;
-
- 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))
- im_old->loader->load(im_old, NULL, 0, 1);
- if (!(im_old->data))
- return NULL;
- im = __imlib_CreateImage(im_old->w, im_old->h, NULL);
- if (!(im))
- return NULL;
- im->data = malloc(im->w * im->h * sizeof(DATA32));
- if (!(im->data))
- {
- __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);
- im->moddate = im_old->moddate;
- 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);
- }
- if (im_old->file)
- {
- im->file = malloc(strlen(im_old->file) + 1);
- strcpy(im->file, im_old->file);
- }
- return (Imlib_Image) im;
-}
-
-/**
- * @param x The top left x coordinate of the rectangle.
- * @param y The top left y coordinate of the rectangle.
- * @param width The width of the rectangle.
- * @param height The height of the rectangle.
- * @return A valid image, otherwise NULL.
- *
- * Creates a duplicate of a (@p x, @p y, @p width, @p height) rectangle in the
- * current image and returns a valid image handle on success, or NULL
- * on failure.
- *
- **/
-Imlib_Image
-imlib_create_cropped_image(int x, int y, int width, int height)
-{
- ImlibImage *im, *im_old;
-
- if (!ctx)
- ctx = imlib_context_new();
- CHECK_PARAM_POINTER_RETURN("imlib_create_cropped_image", "image",
- ctx->image, NULL);
- CAST_IMAGE(im_old, ctx->image);
- if ((!(im_old->data)) && (im_old->loader) && (im_old->loader->load))
- im_old->loader->load(im_old, NULL, 0, 1);
- if (!(im_old->data))
- return NULL;
- im = __imlib_CreateImage(abs(width), abs(height), NULL);
- im->data = malloc(abs(width * height) * sizeof(DATA32));
- if (!(im->data))
- {
- __imlib_FreeImage(im);
- return NULL;
- }
- if (IMAGE_HAS_ALPHA(im_old))
- {
- SET_FLAG(im->flags, F_HAS_ALPHA);
- __imlib_BlendImageToImage(im_old, im, 0, 0, 1, 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);
- }
- else
- {
- __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);
- }
- return (Imlib_Image) im;
-}
-
-/**
- * @param source_x The top left x coordinate of the source rectangle.
- * @param source_y The top left y coordinate of the source rectangle.
- * @param source_width The width of the source rectangle.
- * @param source_height The height of the source rectangle.
- * @param destination_width The width of the destination image.
- * @param destination_height The height of the destination image.
- * @return A valid image, otherwise NULL.
- *
- * Works the same as imlib_create_cropped_image() but will scale the
- * new image to the new destination @p destination_width and
- * @p destination_height whilst cropping.
- *
- **/
-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)
-{
- ImlibImage *im, *im_old;
-
- 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);
- if ((!(im_old->data)) && (im_old->loader) && (im_old->loader->load))
- 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->data =
- malloc(abs(destination_width * destination_height) * sizeof(DATA32));
- if (!(im->data))
- {
- __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);
- }
- 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);
- }
- return (Imlib_Image) im;
-}
-
-/**
- * @param updates An updates list.
- * @return Duplicate of @p updates.
- *
- * Creates a duplicate of the updates list passed into the function.
- **/
-Imlib_Updates
-imlib_updates_clone(Imlib_Updates updates)
-{
- ImlibUpdate *u;
-
- if (!ctx)
- ctx = imlib_context_new();
- u = (ImlibUpdate *) updates;
- return (Imlib_Updates) __imlib_DupUpdates(u);
-}
-
-/**
- * @param updates An updates list.
- * @param x The top left x coordinate of the rectangle.
- * @param y The top left y coordinate of the rectangle.
- * @param w The width of the rectangle.
- * @param h The height of the rectangle.
- * @return The updates handle.
- *
- * Appends an update rectangle to the updates list passed in (if the
- * updates is NULL it will create a new updates list) and returns a
- * handle to the modified updates list (the handle may be modified so
- * only use the new updates handle returned).
- **/
-Imlib_Updates
-imlib_update_append_rect(Imlib_Updates updates, int x, int y, int w, int h)
-{
- ImlibUpdate *u;
-
- if (!ctx)
- ctx = imlib_context_new();
- u = (ImlibUpdate *) updates;
- return (Imlib_Updates) __imlib_AddUpdate(u, x, y, w, h);
-}
-
-/**
- * @param updates An updates list.
- * @param w The width of the rectangle.
- * @param h The height of the rectangle.
- * @return The updates handle.
- *
- * Takes an updates list, and modifies it by merging overlapped
- * rectangles and lots of tiny rectangles into larger rectangles to
- * minimize the number of rectangles in the list for optimized
- * redrawing. The new updates handle is now valid and the old one
- * passed in is not.
- **/
-Imlib_Updates
-imlib_updates_merge(Imlib_Updates updates, int w, int h)
-{
- ImlibUpdate *u;
-
- if (!ctx)
- ctx = imlib_context_new();
- u = (ImlibUpdate *) updates;
- return (Imlib_Updates) __imlib_MergeUpdate(u, w, h, 0);
-}
-
-/**
- * @param updates An updates list.
- * @param w The width of the rectangle.
- * @param h The height of the rectangle.
- * @return The updates handle.
- *
- * Works almost exactly as imlib_updates_merge() but is more lenient
- * on the spacing between update rectangles - if they are very close it
- * amalgamates 2 smaller rectangles into 1 larger one.
- **/
-Imlib_Updates
-imlib_updates_merge_for_rendering(Imlib_Updates updates, int w, int h)
-{
- ImlibUpdate *u;
-
- if (!ctx)
- ctx = imlib_context_new();
- u = (ImlibUpdate *) updates;
- return (Imlib_Updates) __imlib_MergeUpdate(u, w, h, 3);
-}
-
-/**
- * @param updates An updates list.
- *
- * Frees an updates list.
- **/
-void
-imlib_updates_free(Imlib_Updates updates)
-{
- ImlibUpdate *u;
-
- if (!ctx)
- ctx = imlib_context_new();
- u = (ImlibUpdate *) updates;
- __imlib_FreeUpdates(u);
-}
-
-/**
- * @param updates An updates list.
- * @return The next updates.
- *
- * Gets the next update in the updates list relative to the one passed
- * in.
- **/
-Imlib_Updates
-imlib_updates_get_next(Imlib_Updates updates)
-{
- ImlibUpdate *u;
-
- if (!ctx)
- ctx = imlib_context_new();
- u = (ImlibUpdate *) updates;
- return (Imlib_Updates) (u->next);
-}
-
-/**
- * @param updates An updates list.
- * @param x_return The top left x coordinate of the update.
- * @param y_return The top left y coordinate of the update.
- * @param width_return The width of the update.
- * @param height_return The height of the update.
- *
- * Returns the coordinates of an update.
- **/
-void
-imlib_updates_get_coordinates(Imlib_Updates updates, int *x_return,
- int *y_return, int *width_return,
- int *height_return)
-{
- ImlibUpdate *u;
-
- if (!ctx)
- ctx = imlib_context_new();
- CHECK_PARAM_POINTER("imlib_updates_get_coordinates", "updates", updates);
- u = (ImlibUpdate *) updates;
- if (x_return)
- *x_return = u->x;
- if (y_return)
- *y_return = u->y;
- if (width_return)
- *width_return = u->w;
- if (height_return)
- *height_return = u->h;
-}
-
-/**
- * @param updates An updates list.
- * @param x The top left x coordinate of the update.
- * @param y The top left y coordinate of the update.
- * @param width The width of the update.
- * @param height The height of the update.
- *
- * Modifies the coordinates of an update in @p update.
- **/
-void
-imlib_updates_set_coordinates(Imlib_Updates updates, int x, int y, int width,
- int height)
-{
- ImlibUpdate *u;
-
- if (!ctx)
- ctx = imlib_context_new();
- CHECK_PARAM_POINTER("imlib_updates_set_coordinates", "updates", updates);
- u = (ImlibUpdate *) updates;
- u->x = x;
- u->y = y;
- u->w = width;
- u->h = height;
-}
-
-#ifndef X_DISPLAY_MISSING
-/**
- * @param updates An updates list.
- * @param x The top left x coordinate of the update.
- * @param y The top left y coordinate of the update.
- *
- * Given an updates list (preferable already merged for rendering)
- * this will render the corresponding parts of the image to the current
- * drawable at an offset of @p x, @p y in the drawable.
- **/
-void
-imlib_render_image_updates_on_drawable(Imlib_Updates updates, int x, int y)
-{
- ImlibUpdate *u;
- ImlibImage *im;
-
- if (!ctx)
- ctx = imlib_context_new();
- CHECK_PARAM_POINTER("imlib_render_image_updates_on_drawable", "image",
- ctx->image);
- CAST_IMAGE(im, ctx->image);
- u = (ImlibUpdate *) updates;
- if (!updates)
- return;
- if ((!(im->data)) && (im->loader) && (im->loader->load))
- im->loader->load(im, NULL, 0, 1);
- if (!(im->data))
- 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_SetMaxXImageCount(ctx->display, 0);
-}
-#endif
-
-/**
- * @return The initialized updates list.
- *
- * Initializes an updates list before you add any updates to it or
- * merge it for rendering etc.
- **/
-Imlib_Updates
-imlib_updates_init(void)
-{
- if (!ctx)
- ctx = imlib_context_new();
- return (Imlib_Updates) NULL;
-}
-
-/**
- * @param updates An updates list.
- * @param appended_updates The updates list to append.
- * @return The new updates list.
- *
- * Appends @p appended_updates to the updates list @p updates and
- * returns the new list.
- **/
-Imlib_Updates
-imlib_updates_append_updates(Imlib_Updates updates,
- Imlib_Updates appended_updates)
-{
- ImlibUpdate *u, *uu;
-
- if (!ctx)
- ctx = imlib_context_new();
- u = (ImlibUpdate *) updates;
- uu = (ImlibUpdate *) appended_updates;
- if (!uu)
- return (Imlib_Updates) u;
- if (!u)
- return (Imlib_Updates) uu;
- while (u)
- {
- if (!(u->next))
- {
- u->next = uu;
- return updates;
- }
- u = u->next;
- }
- return (Imlib_Updates) u;
-}
-
-/**
- * Flips/mirrors the current image horizontally.
- **/
-void
-imlib_image_flip_horizontal(void)
-{
- ImlibImage *im;
-
- 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))
- im->loader->load(im, NULL, 0, 1);
- if (!(im->data))
- return;
- __imlib_DirtyImage(im);
- __imlib_FlipImageHoriz(im);
-}
-
-/**
- * Flips/mirrors the current image vertically.
- **/
-void
-imlib_image_flip_vertical(void)
-{
- ImlibImage *im;
-
- 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))
- im->loader->load(im, NULL, 0, 1);
- if (!(im->data))
- return;
- __imlib_DirtyImage(im);
- __imlib_FlipImageVert(im);
-}
-
-/**
- * Flips/mirrors the current image diagonally (good for quick and dirty
- * 90 degree rotations if used before to after a horizontal or vertical
- * flip).
- **/
-void
-imlib_image_flip_diagonal(void)
-{
- ImlibImage *im;
-
- 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))
- im->loader->load(im, NULL, 0, 1);
- if (!(im->data))
- return;
- __imlib_DirtyImage(im);
- __imlib_FlipImageDiagonal(im, 0);
-}
-
-/**
- * @param orientation The orientation.
- *
- * Performs 90 degree rotations on the current image. Passing in
- * @p orientation does not rotate, 1 rotates clockwise by 90 degree, 2,
- * rotates clockwise by 180 degrees, 3 rotates clockwise by 270
- * degrees.
- **/
-void
-imlib_image_orientate(int orientation)
-{
- ImlibImage *im;
-
- 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))
- im->loader->load(im, NULL, 0, 1);
- if (!(im->data))
- return;
- __imlib_DirtyImage(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;
- }
-}
-
-/**
- * @param radius The radius.
- *
- * Blurs the current image. A @p radius value of 0 has no effect, 1 and above
- * determine the blur matrix radius that determine how much to blur the
- * image.
- **/
-void
-imlib_image_blur(int radius)
-{
- ImlibImage *im;
-
- 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))
- im->loader->load(im, NULL, 0, 1);
- if (!(im->data))
- return;
- __imlib_DirtyImage(im);
- __imlib_BlurImage(im, radius);
-}
-
-/**
- * @param radius The radius.
- *
- * Sharpens the current image. The @p radius value affects how much to sharpen
- * by.
- **/
-void
-imlib_image_sharpen(int radius)
-{
- ImlibImage *im;
-
- 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))
- im->loader->load(im, NULL, 0, 1);
- if (!(im->data))
- return;
- __imlib_DirtyImage(im);
- __imlib_SharpenImage(im, radius);
-}
-
-/**
- * Modifies an image so it will tile seamlessly horizontally if used
- * as a tile (i.e. drawn multiple times horizontally).
- **/
-void
-imlib_image_tile_horizontal(void)
-{
- ImlibImage *im;
-
- 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))
- im->loader->load(im, NULL, 0, 1);
- if (!(im->data))
- return;
- __imlib_DirtyImage(im);
- __imlib_TileImageHoriz(im);
-}
-
-/**
- * Modifies an image so it will tile seamlessly vertically if used as
- * a tile (i.e. drawn multiple times vertically).
- **/
-void
-imlib_image_tile_vertical(void)
-{
- ImlibImage *im;
-
- 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))
- im->loader->load(im, NULL, 0, 1);
- if (!(im->data))
- return;
- __imlib_DirtyImage(im);
- __imlib_TileImageVert(im);
-}
-
-/**
- * Modifies an image so it will tile seamlessly horizontally and
- * vertically if used as a tile (i.e. drawn multiple times horizontally
- * and vertically).
- **/
-void
-imlib_image_tile(void)
-{
- ImlibImage *im;
-
- 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))
- im->loader->load(im, NULL, 0, 1);
- if (!(im->data))
- return;
- __imlib_DirtyImage(im);
- __imlib_TileImageHoriz(im);
- __imlib_TileImageVert(im);
-}
-
-/**
- * @param font_name The font name with the size.
- * @return NULL if no font found.
- *
- * Loads a truetype font from the first directory in the font path that
- * contains that font. The font name @p font_name format is "font_name/size". For
- * example. If there is a font file called blum.ttf somewhere in the
- * font path you might use "blum/20" to load a 20 pixel sized font of
- * blum. If the font cannot be found NULL is returned.
- *
- **/
-Imlib_Font
-imlib_load_font(const char *font_name)
-{
- return imlib_font_load_joined(font_name);
-}
-
-/**
- * Frees the current font.
- **/
-void
-imlib_free_font(void)
-{
- if (!ctx)
- ctx = imlib_context_new();
- CHECK_PARAM_POINTER("imlib_free_font", "font", ctx->font);
- imlib_font_free(ctx->font);
- ctx->font = NULL;
-}
-
-/**
- * @param x The x coordinate of the top left corner.
- * @param y The y coordinate of the top left corner.
- * @param text A null-byte terminated string.
- *
- * Draws the null-byte terminated string @p text using the current font on
- * the current image at the (@p x, @p y) location (@p x, @p y denoting the top left
- * corner of the font string)
- **/
-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);
-}
-
-/**
- * @param x The x coordinate of the top left corner.
- * @param y The y coordinate of the top left corner.
- * @param text A null-byte terminated string.
- * @param width_return The width of the string.
- * @param height_return The height of the string.
- * @param horizontal_advance_return Horizontal offset.
- * @param vertical_advance_return Vertical offset.
- *
- * Works just like imlib_text_draw() but also returns the width and
- * height of the string drawn, and @p horizontal_advance_return returns
- * the number of pixels you should advance horizontally to draw another
- * string (useful if you are drawing a line of text word by word) and
- * @p vertical_advance_return does the same for the vertical direction
- * (i.e. drawing text line by line).
- **/
-void
-imlib_text_draw_with_return_metrics(int x, int y, const char *text,
- int *width_return, int *height_return,
- int *horizontal_advance_return,
- int *vertical_advance_return)
-{
- ImlibImage *im;
- ImlibFont *fn;
- int dir;
-
- 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",
- ctx->image);
- CHECK_PARAM_POINTER("imlib_text_draw_with_return_metrics", "text", text);
- CAST_IMAGE(im, ctx->image);
- if ((!(im->data)) && (im->loader) && (im->loader->load))
- im->loader->load(im, NULL, 0, 1);
- if (!(im->data))
- return;
- fn = (ImlibFont *) ctx->font;
- __imlib_DirtyImage(im);
-
- dir = ctx->direction;
- if (ctx->direction == IMLIB_TEXT_TO_ANGLE && ctx->angle == 0.0)
- dir = IMLIB_TEXT_TO_RIGHT;
-
- 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);
-}
-
-/**
- * @param text A string.
- * @param width_return The width of the text.
- * @param height_return The height of the text.
- *
- * Gets the width and height in pixels the @p text string would use up
- * if drawn with the current font.
- **/
-void
-imlib_get_text_size(const char *text, int *width_return, int *height_return)
-{
- ImlibFont *fn;
- int w, h;
- int dir;
-
- 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;
-
- imlib_font_query_size(fn, text, &w, &h);
-
- 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;
- }
-}
-
-/**
- * @param text A string.
- * @param horizontal_advance_return Horizontal offset.
- * @param vertical_advance_return Vertical offset.
- *
- * Gets the advance horizontally and vertically in pixels the next
- * text string would need to be placed at for the current font. The
- * advances are not adjusted for rotation so you will have to translate
- * the advances (which are calculated as if the text was drawn
- * horizontally from left to right) depending on the text orientation.
- **/
-void
-imlib_get_text_advance(const char *text, int *horizontal_advance_return,
- int *vertical_advance_return)
-{
- ImlibFont *fn;
- int w, h;
-
- 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_font_query_advance(fn, text, &w, &h);
- if (horizontal_advance_return)
- *horizontal_advance_return = w;
- if (vertical_advance_return)
- *vertical_advance_return = h;
-}
-
-/**
- * @param text A string.
- * @return The inset value of @text.
- *
- * Returns the inset of the first character of @p text
- * in using the current font and returns that value in pixels.
- *
- **/
-int
-imlib_get_text_inset(const char *text)
-{
- ImlibFont *fn;
-
- 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_font_query_inset(fn, text);
-}
-
-/**
- * @param path A directory path.
- *
- * Adds the directory @p path to the end of the current list of
- * directories to scan for fonts.
- **/
-void
-imlib_add_path_to_font_path(const char *path)
-{
- if (!ctx)
- ctx = imlib_context_new();
- CHECK_PARAM_POINTER("imlib_add_path_to_font_path", "path", path);
- if (!imlib_font_path_exists(path))
- imlib_font_add_font_path(path);
-}
-
-/**
- * @param path A directory path.
- *
- * Removes all directories in the font path that match @p path.
- **/
-void
-imlib_remove_path_from_font_path(const char *path)
-{
- if (!ctx)
- ctx = imlib_context_new();
- CHECK_PARAM_POINTER("imlib_remove_path_from_font_path", "path", path);
- imlib_font_del_font_path(path);
-}
-
-/**
- * @param number_return Number of paths in the list.
- * @return A list of strings.
- *
- * Returns a list of strings that are the directories in the font
- * path. Do not free this list or change it in any way. If you add or
- * delete members of the font path this list will be invalid. If you
- * intend to use this list later duplicate it for your own use. The
- * number of elements in the array of strings is put into
- * @p number_return.
- *
- **/
-char **
-imlib_list_font_path(int *number_return)
-{
- if (!ctx)
- ctx = imlib_context_new();
- CHECK_PARAM_POINTER_RETURN("imlib_list_font_path", "number_return",
- number_return, NULL);
- return imlib_font_list_font_path(number_return);
-}
-
-/**
- * @param text A string.
- * @param x The x offset.
- * @param y The y offset.
- * @param char_x_return The x coordinate of the character.
- * @param char_y_return The x coordinate of the character.
- * @param char_width_return The width of the character.
- * @param char_height_return The height of the character.
- * @return -1 if no character found.
- *
- * Returns the character number in the string @p text using the current
- * font at the (@p x, @p y) pixel location which is an offset relative to the
- * top left of that string. -1 is returned if there is no character
- * there. If there is a character, @p char_x_return, @p char_y_return,
- * @p char_width_return and @p char_height_return (respectively the
- * character x, y, width and height) are also filled in.
- *
- **/
-int
-imlib_text_get_index_and_location(const char *text, int x, int y,
- int *char_x_return, int *char_y_return,
- int *char_width_return,
- int *char_height_return)
-{
- ImlibFont *fn;
- int w, h, cx, cy, cw, ch, cp, xx, yy;
- int dir;
-
- 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",
- text, -1);
- fn = (ImlibFont *) ctx->font;
-
- dir = ctx->direction;
- 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)
- {
- 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;
- }
-
- cp = imlib_font_query_text_at_pos(fn, text, xx, yy, &cx, &cy, &cw, &ch);
-
- 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;
-}
-
-/**
- * @param text A string.
- * @param index The index of @text.
- * @param char_x_return The x coordinate of the character.
- * @param char_y_return The y coordinate of the character.
- * @param char_width_return The width of the character.
- * @param char_height_return The height of the character.
- *
- * Gets the geometry of the character at index @p index in the @p text
- * string using the current font.
- **/
-void
-imlib_text_get_location_at_index(const char *text, int index,
- int *char_x_return, int *char_y_return,
- int *char_width_return,
- int *char_height_return)
-{
- 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);
- CHECK_PARAM_POINTER("imlib_text_get_index_and_location", "text", text);
- fn = (ImlibFont *) ctx->font;
-
- 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;
- }
-}
-
-/**
- * @param number_return Number of fonts in the list.
- * @return A list of fonts.
- *
- * Returns a list of fonts imlib2 can find in its font path.
- *
- **/
-char **
-imlib_list_fonts(int *number_return)
-{
- if (!ctx)
- ctx = imlib_context_new();
- CHECK_PARAM_POINTER_RETURN("imlib_list_fonts", "number_return",
- number_return, NULL);
- return imlib_font_list_fonts(number_return);
-}
-
-/**
- * @param font_list The font list.
- * @param number Number of fonts in the list.
- *
- * Frees the font list returned by imlib_list_fonts().
- *
- **/
-void
-imlib_free_font_list(char **font_list, int number)
-{
- __imlib_FileFreeDirList(font_list, number);
-}
-
-/**
- * @return The font cache size.
- *
- * Returns the font cache size in bytes.
- *
- **/
-int
-imlib_get_font_cache_size(void)
-{
- if (!ctx)
- ctx = imlib_context_new();
- return imlib_font_cache_get();
-}
-
-/**
- * @param bytes The font cache size.
- *
- * Sets the font cache in bytes. Whenever you set the font cache size
- * Imlib2 will flush fonts from the cache until the memory used by
- * fonts is less than or equal to the font cache size. Setting the size
- * to 0 effectively frees all speculatively cached fonts.
- **/
-void
-imlib_set_font_cache_size(int bytes)
-{
- if (!ctx)
- ctx = imlib_context_new();
- imlib_font_cache_set(bytes);
-}
-
-/**
- * Causes a flush of all speculatively cached fonts from the font
- * cache.
- **/
-void
-imlib_flush_font_cache(void)
-{
- if (!ctx)
- ctx = imlib_context_new();
- imlib_font_flush();
-}
-
-/**
- * @return The font's ascent.
- *
- * Returns the current font's ascent value in pixels.
- *
- **/
-int
-imlib_get_font_ascent(void)
-{
- if (!ctx)
- ctx = imlib_context_new();
- CHECK_PARAM_POINTER_RETURN("imlib_get_font_ascent", "font", ctx->font, 0);
- return imlib_font_ascent_get(ctx->font);
-}
-
-/**
- * @return The font's descent.
- *
- * Returns the current font's descent value in pixels.
- *
- **/
-int
-imlib_get_font_descent(void)
-{
- 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);
-}
-
-/**
- * @return The font's maximum ascent.
- *
- * Returns the current font's maximum ascent extent.
- *
- **/
-int
-imlib_get_maximum_font_ascent(void)
-{
- 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);
-}
-
-/**
- * @return The font's maximum descent.
- *
- * Returns the current font's maximum descent extent.
- *
- **/
-int
-imlib_get_maximum_font_descent(void)
-{
- 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);
-}
-
-/**
- * @return Valid handle.
- *
- * Creates a new empty color modifier and returns a
- * valid handle on success. NULL is returned on failure.
- *
- **/
-Imlib_Color_Modifier
-imlib_create_color_modifier(void)
-{
- if (!ctx)
- ctx = imlib_context_new();
- return (Imlib_Color_Modifier) __imlib_CreateCmod();
-}
-
-/**
- * Frees the current color modifier.
- **/
-void
-imlib_free_color_modifier(void)
-{
- if (!ctx)
- ctx = imlib_context_new();
- CHECK_PARAM_POINTER("imlib_free_color_modifier", "color_modifier",
- ctx->color_modifier);
- __imlib_FreeCmod((ImlibColorModifier *) ctx->color_modifier);
- ctx->color_modifier = NULL;
-}
-
-/**
- * @param gamma_value Value of gamma.
- *
- * Modifies the current color modifier by adjusting the gamma by the
- * value specified @p gamma_value. The color modifier is modified not set, so calling
- * this repeatedly has cumulative effects. A gamma of 1.0 is normal
- * linear, 2.0 brightens and 0.5 darkens etc. Negative values are not
- * allowed.
- **/
-void
-imlib_modify_color_modifier_gamma(double gamma_value)
-{
- 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,
- gamma_value);
-}
-
-/**
- * @param brightness_value Value of brightness.
- *
- * Modifies the current color modifier by adjusting the brightness by
- * the value @p brightness_value. The color modifier is modified not set, so
- * calling this repeatedly has cumulative effects. brightness values
- * of 0 do not affect anything. -1.0 will make things completely black
- * and 1.0 will make things all white. Values in-between vary
- * brightness linearly.
- **/
-void
-imlib_modify_color_modifier_brightness(double brightness_value)
-{
- 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,
- brightness_value);
-}
-
-/**
- * @param contrast_value Value of contrast.
- *
- * Modifies the current color modifier by adjusting the contrast by
- * the value @p contrast_value. The color modifier is modified not set, so
- * calling this repeatedly has cumulative effects. Contrast of 1.0 does
- * nothing. 0.0 will merge to gray, 2.0 will double contrast etc.
- **/
-void
-imlib_modify_color_modifier_contrast(double contrast_value)
-{
- 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,
- contrast_value);
-}
-
-/**
- * @param red_table An array of #DATA8.
- * @param green_table An array of #DATA8.
- * @param blue_table An array of #DATA8.
- * @param alpha_table An array of #DATA8.
- *
- * Explicitly copies the mapping tables from the table pointers passed
- * into this function into those of the current color modifier. Tables
- * are 256 entry arrays of DATA8 which are a mapping of that channel
- * value to a new channel value. A normal mapping would be linear (v[0]
- * = 0, v[10] = 10, v[50] = 50, v[200] = 200, v[255] = 255).
- **/
-void
-imlib_set_color_modifier_tables(DATA8 * red_table, DATA8 * green_table,
- DATA8 * blue_table, DATA8 * alpha_table)
-{
- 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,
- red_table, green_table, blue_table, alpha_table);
-}
-
-/**
- * @param red_table: an array of #DATA8.
- * @param green_table: an array of #DATA8.
- * @param blue_table: an array of #DATA8.
- * @param alpha_table: an array of #DATA8.
- *
- * Copies the table values from the current color modifier into the
- * pointers to mapping tables specified. They must have 256 entries and
- * be DATA8 format.
- **/
-void
-imlib_get_color_modifier_tables(DATA8 * red_table, DATA8 * green_table,
- DATA8 * blue_table, DATA8 * alpha_table)
-{
- 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,
- red_table, green_table, blue_table, alpha_table);
-}
-
-/**
- * Resets the current color modifier to have linear mapping tables.
- **/
-void
-imlib_reset_color_modifier(void)
-{
- if (!ctx)
- ctx = imlib_context_new();
- CHECK_PARAM_POINTER("imlib_rset_color_modifier", "color_modifier",
- ctx->color_modifier);
- __imlib_CmodReset((ImlibColorModifier *) ctx->color_modifier);
-}
-
-/**
- * Uses the current color modifier and modifies the current image using
- * the mapping tables in the current color modifier.
- **/
-void
-imlib_apply_color_modifier(void)
-{
- ImlibImage *im;
-
- 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);
- CAST_IMAGE(im, ctx->image);
- if ((!(im->data)) && (im->loader) && (im->loader->load))
- im->loader->load(im, NULL, 0, 1);
- if (!(im->data))
- return;
- __imlib_DirtyImage(im);
- __imlib_DataCmodApply(im->data, im->w, im->h, 0, &(im->flags),
- (ImlibColorModifier *) ctx->color_modifier);
-}
-
-/**
- * @param x The x coordinate of the left edge of the rectangle.
- * @param y The y coordinate of the top edge of the rectangle.
- * @param width The width of the rectangle.
- * @param height The height of the rectangle.
- *
- * Works the same way as imlib_apply_color_modifier() but only modifies
- * a selected rectangle in the current image.
- **/
-void
-imlib_apply_color_modifier_to_rectangle(int x, int y, int width, int height)
-{
- ImlibImage *im;
-
- 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;
- }
- if (width <= 0)
- return;
- if ((x + width) > im->w)
- width = (im->w - x);
- if (width <= 0)
- return;
- if (y < 0)
- {
- height += y;
- y = 0;
- }
- if (height <= 0)
- return;
- if ((y + height) > im->h)
- height = (im->h - y);
- if (height <= 0)
- return;
- if ((!(im->data)) && (im->loader) && (im->loader->load))
- im->loader->load(im, NULL, 0, 1);
- if (!(im->data))
- return;
- __imlib_DirtyImage(im);
- __imlib_DataCmodApply(im->data + (y * im->w) + x, width, height,
- im->w - width, &(im->flags),
- (ImlibColorModifier *) ctx->color_modifier);
-}
-
-Imlib_Updates
-imlib_image_draw_pixel(int x, int y, char make_updates)
-{
- ImlibImage *im;
- DATA32 color;
-
- if (!ctx)
- ctx = imlib_context_new();
- CHECK_PARAM_POINTER_RETURN("imlib_image_draw_pixel", "image", ctx->image,
- NULL);
- CAST_IMAGE(im, ctx->image);
- if ((!(im->data)) && (im->loader) && (im->loader->load))
- im->loader->load(im, NULL, 0, 1);
- if (!(im->data))
- return NULL;
- __imlib_DirtyImage(im);
- A_VAL(&color) = (DATA8) ctx->color.alpha;
- R_VAL(&color) = (DATA8) ctx->color.red;
- G_VAL(&color) = (DATA8) ctx->color.green;
- B_VAL(&color) = (DATA8) ctx->color.blue;
- return (Imlib_Updates) __imlib_Point_DrawToImage(x, y, color, im,
- ctx->cliprect.x, ctx->cliprect.y,
- ctx->cliprect.w, ctx->cliprect.h,
- ctx->operation, ctx->blend,
- make_updates);
-}
-
-/**
- * @param x1 The x coordinate of the first point.
- * @param y1 The y coordinate of the first point.
- * @param x2 The x coordinate of the second point.
- * @param y2 The y coordinate of the second point.
- * @param make_updates: a char.
- * @return An updates list.
- *
- * Draws a line using the current color on the current image from
- * coordinates (@p x1, @p y1) to (@p x2, @p y2). If @p make_updates is 1 it will also
- * return an update you can use for an updates list, otherwise it
- * returns NULL.
- *
- **/
-Imlib_Updates
-imlib_image_draw_line(int x1, int y1, int x2, int y2, char make_updates)
-{
- ImlibImage *im;
- DATA32 color;
-
- if (!ctx)
- ctx = imlib_context_new();
- CHECK_PARAM_POINTER_RETURN("imlib_image_draw_line", "image", ctx->image,
- NULL);
- CAST_IMAGE(im, ctx->image);
- if ((!(im->data)) && (im->loader) && (im->loader->load))
- im->loader->load(im, NULL, 0, 1);
- if (!(im->data))
- return NULL;
- __imlib_DirtyImage(im);
- A_VAL(&color) = (DATA8) ctx->color.alpha;
- R_VAL(&color) = (DATA8) ctx->color.red;
- G_VAL(&color) = (DATA8) ctx->color.green;
- B_VAL(&color) = (DATA8) ctx->color.blue;
- return (Imlib_Updates) __imlib_Line_DrawToImage(x1, y1, x2, y2, color, im,
- ctx->cliprect.x, ctx->cliprect.y,
- ctx->cliprect.w, ctx->cliprect.h,
- ctx->operation, ctx->blend,
- ctx->anti_alias, make_updates);
-}
-
-/**
- * @param x The top left x coordinate of the rectangle.
- * @param y The top left y coordinate of the rectangle.
- * @param width The width of the rectangle.
- * @param height The height of the rectangle.
- *
- * Draws the outline of a rectangle on the current image at the (@p x,
- * @p y)
- * coordinates with a size of @p width and @p height pixels, using the
- * current color.
- **/
-void
-imlib_image_draw_rectangle(int x, int y, int width, int height)
-{
- ImlibImage *im;
- DATA32 color;
-
- 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))
- im->loader->load(im, NULL, 0, 1);
- if (!(im->data))
- return;
- __imlib_DirtyImage(im);
- A_VAL(&color) = (DATA8) ctx->color.alpha;
- R_VAL(&color) = (DATA8) ctx->color.red;
- G_VAL(&color) = (DATA8) ctx->color.green;
- B_VAL(&color) = (DATA8) ctx->color.blue;
- __imlib_Rectangle_DrawToImage(x, y, width, height, color,
- im, ctx->cliprect.x, ctx->cliprect.y,
- ctx->cliprect.w, ctx->cliprect.h,
- ctx->operation, ctx->blend);
-}
-
-/**
- * @param x The top left x coordinate of the rectangle.
- * @param y The top left y coordinate of the rectangle.
- * @param width The width of the rectangle.
- * @param height The height of the rectangle.
- *
- * Draws a filled rectangle on the current image at the (@p x, @p y)
- * coordinates with a size of @p width and @p height pixels, using the
- * current color.
- **/
-void
-imlib_image_fill_rectangle(int x, int y, int width, int height)
-{
- ImlibImage *im;
- DATA32 color;
-
- 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))
- im->loader->load(im, NULL, 0, 1);
- if (!(im->data))
- return;
- __imlib_DirtyImage(im);
- A_VAL(&color) = (DATA8) ctx->color.alpha;
- R_VAL(&color) = (DATA8) ctx->color.red;
- G_VAL(&color) = (DATA8) ctx->color.green;
- B_VAL(&color) = (DATA8) ctx->color.blue;
- __imlib_Rectangle_FillToImage(x, y, width, height, color,
- im, ctx->cliprect.x, ctx->cliprect.y,
- ctx->cliprect.w, ctx->cliprect.h,
- ctx->operation, ctx->blend);
-}
-
-/**
- * @param image_source An image.
- * @param x The x coordinate.
- * @param y The y coordinate.
- *
- * Copies the alpha channel of the source image @p image_source to the
- * (@p x, @p y) coordinates
- * of the current image, replacing the alpha channel there.
- **/
-void
-imlib_image_copy_alpha_to_image(Imlib_Image image_source, int x, int y)
-{
- ImlibImage *im, *im2;
-
- 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",
- ctx->image);
- CAST_IMAGE(im, image_source);
- CAST_IMAGE(im2, ctx->image);
- if ((!(im->data)) && (im->loader) && (im->loader->load))
- im->loader->load(im, NULL, 0, 1);
- if ((!(im2->data)) && (im2->loader) && (im2->loader->load))
- im2->loader->load(im, NULL, 0, 1);
- if (!(im->data))
- return;
- if (!(im2->data))
- return;
- __imlib_DirtyImage(im);
- __imlib_copy_alpha_data(im, im2, 0, 0, im->w, im->h, x, y);
-}
-
-/**
- * @param image_source An image.
- * @param x The top left x coordinate of the rectangle.
- * @param y The top left y coordinate of the rectangle.
- * @param width The width of the rectangle.
- * @param height The height of the rectangle.
- * @param destination_x The top left x coordinate of the destination rectangle.
- * @param destination_y The top left x coordinate of the destination rectangle.
- *
- * Copies the source (@p x, @p y, @p width, @p height) rectangle alpha channel from
- * the source image @p image_source and replaces the alpha channel on the destination
- * image at the (@p destination_x, @p destination_y) coordinates.
- **/
-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)
-{
- ImlibImage *im, *im2;
-
- 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",
- "image_destination", ctx->image);
- CAST_IMAGE(im, image_source);
- CAST_IMAGE(im2, ctx->image);
- if ((!(im->data)) && (im->loader) && (im->loader->load))
- im->loader->load(im, NULL, 0, 1);
- if ((!(im2->data)) && (im2->loader) && (im2->loader->load))
- im2->loader->load(im2, NULL, 0, 1);
- if (!(im->data))
- return;
- if (!(im2->data))
- return;
- __imlib_DirtyImage(im);
- __imlib_copy_alpha_data(im, im2, x, y, width, height, destination_x,
- destination_y);
-}
-
-/**
- * @param x The top left x coordinate of the rectangle.
- * @param y The top left y coordinate of the rectangle.
- * @param width The width of the rectangle.
- * @param height The height of the rectangle.
- * @param delta_x Distance along the x coordinates.
- * @param delta_y Distance along the y coordinates.
- *
- * Scrolls a rectangle of size @p width, @p height at the (@p x, @p y)
- * location within the current image
- * by the @p delta_x, @p delta_y distance (in pixels).
- **/
-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;
-
- 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))
- im->loader->load(im, NULL, 0, 1);
- if (!(im->data))
- return;
- if (delta_x > 0)
- {
- xx = x;
- nx = x + delta_x;
- w = width - delta_x;
- }
- else
- {
- xx = x - delta_x;
- nx = x;
- w = width + delta_x;
- }
- if (delta_y > 0)
- {
- yy = y;
- ny = y + delta_y;
- h = height - delta_y;
- }
- else
- {
- yy = y - delta_y;
- ny = y;
- h = height + delta_y;
- }
- __imlib_DirtyImage(im);
- __imlib_copy_image_data(im, xx, yy, w, h, nx, ny);
-}
-
-/**
- * @param x The top left x coordinate of the rectangle.
- * @param y The top left y coordinate of the rectangle.
- * @param width The width of the rectangle.
- * @param height The height of the rectangle.
- * @param new_x The top left x coordinate of the new location.
- * @param new_y The top left y coordinate of the new location.
- *
- * Copies a rectangle of size @p width, @p height at the (@p x, @p y) location
- * specified in the current image to a new location (@p new_x, @p new_y) in the same
- * image.
- **/
-void
-imlib_image_copy_rect(int x, int y, int width, int height, int new_x, int new_y)
-{
- ImlibImage *im;
-
- 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))
- im->loader->load(im, NULL, 0, 1);
- if (!(im->data))
- return;
- __imlib_DirtyImage(im);
- __imlib_copy_image_data(im, x, y, width, height, new_x, new_y);
-}
-
-/**
- * @return valid handle.
- *
- * Creates a new empty color range and returns a valid handle to that
- * color range.
- **/
-Imlib_Color_Range
-imlib_create_color_range(void)
-{
- if (!ctx)
- ctx = imlib_context_new();
- return (Imlib_Color_Range) __imlib_CreateRange();
-}
-
-/**
- * Frees the current color range.
- **/
-void
-imlib_free_color_range(void)
-{
- if (!ctx)
- ctx = imlib_context_new();
- CHECK_PARAM_POINTER("imlib_free_color_range", "color_range",
- ctx->color_range);
- __imlib_FreeRange((ImlibRange *) ctx->color_range);
- ctx->color_range = NULL;
-}
-
-/**
- * @param distance_away Distance from the previous color.
- *
- * Adds the current color to the current color range at a @p distance_away
- * distance from the previous color in the range (if it's the first
- * color in the range this is irrelevant).
- **/
-void
-imlib_add_color_to_color_range(int distance_away)
-{
- 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,
- ctx->color.green, ctx->color.blue, ctx->color.alpha,
- distance_away);
-}
-
-/**
- * @param x The x coordinate of the left edge of the rectangle.
- * @param y The y coordinate of the top edge of the rectangle.
- * @param width The width of the rectangle.
- * @param height The height of the rectangle.
- * @param angle Angle of gradient.
- *
- * Fills a rectangle of width @p width and height @p height at the (@p x, @p y) location
- * specified in the current image with a linear gradient of the
- * current color range at an angle of @p angle degrees with 0 degrees
- * being vertical from top to bottom going clockwise from there.
- **/
-void
-imlib_image_fill_color_range_rectangle(int x, int y, int width, int height,
- double angle)
-{
- ImlibImage *im;
-
- 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",
- "color_range", ctx->color_range);
- CAST_IMAGE(im, ctx->image);
- if ((!(im->data)) && (im->loader) && (im->loader->load))
- im->loader->load(im, NULL, 0, 1);
- if (!(im->data))
- return;
- __imlib_DirtyImage(im);
- __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);
-}
-
-/**
- * @param x The x coordinate of the left edge of the rectangle.
- * @param y The y coordinate of the top edge of the rectangle.
- * @param width The width of the rectangle.
- * @param height The height of the rectangle.
- * @param angle Angle of gradient.
- *
- * Fills a rectangle of width @p width and height @p height at the (@p
- * x, @p y) location
- * specified in the current image with a linear gradient in HSVA color
- * space of the current color range at an angle of @p angle degrees with
- * 0 degrees being vertical from top to bottom going clockwise from
- * there.
- **/
-void
-imlib_image_fill_hsva_color_range_rectangle(int x, int y, int width, int height,
- double angle)
-{
- ImlibImage *im;
-
- 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",
- "color_range", ctx->color_range);
- CAST_IMAGE(im, ctx->image);
- if ((!(im->data)) && (im->loader) && (im->loader->load))
- im->loader->load(im, NULL, 0, 1);
- if (!(im->data))
- return;
- __imlib_DirtyImage(im);
- __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);
-}
-
-/**
- * @param x The x coordinate of the pixel.
- * @param y The y coordinate of the pixel.
- * @param color_return The returned color.
- *
- * Fills the @p color_return color structure with the color of the pixel
- * in the current image that is at the (@p x, @p y) location specified.
- **/
-void
-imlib_image_query_pixel(int x, int y, Imlib_Color * color_return)
-{
- ImlibImage *im;
- DATA32 *p;
-
- 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);
- 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;
- }
- p = im->data + (im->w * y) + x;
- color_return->red = ((*p) >> 16) & 0xff;
- color_return->green = ((*p) >> 8) & 0xff;
- color_return->blue = (*p) & 0xff;
- color_return->alpha = ((*p) >> 24) & 0xff;
-}
-
-/**
- * @param x The x coordinate of the pixel.
- * @param y The y coordinate of the pixel.
- * @param hue The returned hue channel.
- * @param saturation The returned saturation channel.
- * @param value The returned value channel.
- * @param alpha The returned alpha channel.
- *
- * Gets the HSVA color of the pixel from the current image that is at
- * the (@p x, @p y) location specified.
- **/
-void
-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;
-
- 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;
- *saturation = 0;
- *value = 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_hsv(r, g, b, hue, saturation, value);
-}
-
-/**
- * @param x The x coordinate of the pixel.
- * @param y The y coordinate of the pixel.
- * @param hue The returned hue channel.
- * @param lightness The returned lightness channel.
- * @param saturation The returned saturation channel.
- * @param alpha The returned alpha channel.
- *
- * Gets the HLSA color of the pixel from the current image that is at
- * the (@p x, @p y) location specified.
- **/
-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;
-
- 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);
-}
-
-/**
- * @param x Tthe x coordinate of the pixel.
- * @param y The y coordinate of the pixel.
- * @param cyan The returned cyan channel.
- * @param magenta The returned magenta channel.
- * @param yellow The returned yellow channel.
- * @param alpha The returned alpha channel.
- *
- * Gets the CMYA color of the pixel from the current image that is at
- * the (@p x, @p y) location specified.
- *
- **/
-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;
-}
-
-/**
- * @param key A string.
- * @param data A pointer.
- * @param value A value.
- * @param destructor_function An Imlib internal function.
- *
- * Attaches data to the current image with the string key of @p key, and
- * the data of @p data and an integer of @p value. The
- * @p destructor_function function, if not NULL is called when this
- * image is freed so the destructor can free @p data, if this is needed.
- **/
-void
-imlib_image_attach_data_value(const char *key, void *data, int value,
- Imlib_Internal_Data_Destructor_Function
- destructor_function)
-{
- ImlibImage *im;
-
- 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);
- __imlib_AttachTag(im, key, value, data,
- (ImlibDataDestructorFunction) destructor_function);
-}
-
-/**
- * @param key A string.
- * @return The attached data as a pointer, or NULL if none.
- *
- * Gets the data attached to the current image with the key @p key
- * specified. NULL is returned if no data could be found with that key
- * on the current image.
- *
- **/
-void *
-imlib_image_get_attached_data(const char *key)
-{
- ImlibImageTag *t;
- ImlibImage *im;
-
- 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,
- NULL);
- CAST_IMAGE(im, ctx->image);
- t = __imlib_GetTag(im, key);
- if (t)
- return t->data;
- return NULL;
-}
-
-/**
- * @param key A string.
- * @return The attached value as an integer, or 0 if none.
- *
- * Returns the value attached to the current image with the specified
- * key @p key. If none could be found 0 is returned.
- *
- **/
-int
-imlib_image_get_attached_value(const char *key)
-{
- ImlibImageTag *t;
- ImlibImage *im;
-
- 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);
- CAST_IMAGE(im, ctx->image);
- t = __imlib_GetTag(im, key);
- if (t)
- return t->val;
- return 0;
-}
-
-/**
- * @param key A string.
- *
- * Detaches the data & value attached with the specified key @p key from the
- * current image.
- **/
-void
-imlib_image_remove_attached_data_value(const char *key)
-{
- ImlibImage *im;
-
- 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);
- CAST_IMAGE(im, ctx->image);
- __imlib_RemoveTag(im, key);
-}
-
-/**
- * @param key A string.
- *
- * Removes the data and value attached to the current image with the
- * specified key @p key and also calls the destructor function that was
- * supplied when attaching it (see imlib_image_attach_data_value()).
- **/
-void
-imlib_image_remove_and_free_attached_data_value(const char *key)
-{
- ImlibImageTag *t;
- ImlibImage *im;
-
- 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",
- "key", key);
- CAST_IMAGE(im, ctx->image);
- t = __imlib_RemoveTag(im, key);
- __imlib_FreeTag(im, t);
-}
-
-/**
- * @param filename The file name.
- *
- * Saves the current image in the format specified by the current
- * image's format settings to the filename @p filename.
- **/
-void
-imlib_save_image(const char *filename)
-{
- ImlibImage *im;
- Imlib_Image prev_ctxt_image;
-
- 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);
- if ((!(im->data)) && (im->loader) && (im->loader->load))
- im->loader->load(im, NULL, 0, 1);
- if (!im->data)
- return;
- prev_ctxt_image = ctx->image;
- __imlib_SaveImage(im, filename, (ImlibProgressFunction) ctx->progress_func,
- ctx->progress_granularity, NULL);
- ctx->image = prev_ctxt_image;
-}
-
-/**
- * @param filename The file name.
- * @param error_return The returned error.
- *
- * Works the same way imlib_save_image() works, but will set the
- * @p error_return to an error value if the save fails.
- **/
-void
-imlib_save_image_with_error_return(const char *filename,
- Imlib_Load_Error * error_return)
-{
- ImlibImage *im;
- Imlib_Image prev_ctxt_image;
-
- 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",
- filename);
- CHECK_PARAM_POINTER("imlib_save_image_with_error_return", "error_return",
- error_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;
- prev_ctxt_image = ctx->image;
- __imlib_SaveImage(im, filename, (ImlibProgressFunction) ctx->progress_func,
- ctx->progress_granularity, error_return);
- ctx->image = prev_ctxt_image;
-}
-
-/**
- * @param angle An angle in radians.
- * @return A new image, or NULL.
- *
- * Creates an new copy of the current image, but rotated by @p angle
- * radians. On success it returns a valid image handle, otherwise
- * NULL.
- **/
-Imlib_Image
-imlib_create_rotated_image(double angle)
-{
- ImlibImage *im, *im_old;
- int x, y, dx, dy, sz;
- double x1, y1, d;
-
- if (!ctx)
- ctx = imlib_context_new();
- CHECK_PARAM_POINTER_RETURN("imlib_create_rotated_image", "image",
- ctx->image, NULL);
- CAST_IMAGE(im_old, ctx->image);
- if ((!(im_old->data)) && (im_old->loader) && (im_old->loader->load))
- im_old->loader->load(im_old, NULL, 0, 1);
- if (!(im_old->data))
- return NULL;
-
- 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;
-
- 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;
- }
-
- 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
-#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);
- }
- 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);
- }
- SET_FLAG(im->flags, F_HAS_ALPHA);
-
- return (Imlib_Image) im;
-}
-
-void imlib_rotate_image_from_buffer(double angle,
- Imlib_Image source_image)
-{
- ImlibImage *im, *im_old;
- int x, y, dx, dy, sz;
- double x1, y1, d;
-
- if (!ctx)
- ctx = imlib_context_new();
- // source image (to rotate)
- CHECK_PARAM_POINTER("imlib_rotate_image_from_buffer", "source_image",
- source_image);
- CAST_IMAGE(im_old, source_image);
-
- // current context image
- CHECK_PARAM_POINTER("imlib_rotate_image_from_buffer", "image",
- ctx->image);
- CAST_IMAGE(im, ctx->image);
-
- if ((!(im_old->data)) && (im_old->loader) && (im_old->loader->load))
- im_old->loader->load(im_old, NULL, 0, 1);
-
- if (!(im_old->data)) return;
-
- 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;
-
- 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);
-
- if ( (im->w != im->h) || ((im->w < sz) && (im->h < sz)))
- return; // If size is wrong
- else sz = im->w; // update sz with real width
-
- /* Not neccesary 'cause destination is context
- im = __imlib_CreateImage(sz, sz, NULL);
- im->data = calloc(sz * sz, sizeof(DATA32));
- if (!(im->data))
- {
- __imlib_FreeImage(im);
- return;
- }*/
-
- 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
-#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);
- }
- 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);
- }
- SET_FLAG(im->flags, F_HAS_ALPHA);
-
-
- return;
-}
-
-/**
- * @param source_image The image source.
- * @param merge_alpha A char.
- * @param source_x The source x coordinate.
- * @param source_y The source y coordinate.
- * @param source_width The source width.
- * @param source_height The source height.
- * @param destination_x The destination x coordinate.
- * @param destination_y The destination y coordinate.
- * @param angle_x An angle.
- * @param angle_y An angle.
- *
- * Works just like imlib_blend_image_onto_image_skewed() except you
- * cannot skew an image (@p v_angle_x and @p v_angle_y are 0).
- **/
-void
-imlib_blend_image_onto_image_at_angle(Imlib_Image source_image,
- char merge_alpha, int source_x,
- int source_y, int source_width,
- int source_height, int destination_x,
- int destination_y, int angle_x,
- int angle_y)
-{
- ImlibImage *im_src, *im_dst;
-
- 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",
- ctx->image);
- CAST_IMAGE(im_src, source_image);
- CAST_IMAGE(im_dst, ctx->image);
- if ((!(im_src->data)) && (im_src->loader) && (im_src->loader->load))
- im_src->loader->load(im_src, NULL, 0, 1);
- if (!(im_src->data))
- return;
- if ((!(im_dst->data)) && (im_dst->loader) && (im_dst->loader->load))
- im_dst->loader->load(im_dst, NULL, 0, 1);
- if (!(im_dst->data))
- return;
- __imlib_DirtyImage(im_dst);
- __imlib_BlendImageToImageSkewed(im_src, im_dst, ctx->anti_alias,
- ctx->blend, merge_alpha, source_x,
- source_y, source_width, source_height,
- 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);
-}
-
-/**
- * @param source_image The source image.
- * @param merge_alpha A char
- * @param source_x The source x coordinate.
- * @param source_y The source y coordinate.
- * @param source_width The source width.
- * @param source_height The source height.
- * @param destination_x The destination x coordinate.
- * @param destination_y The destination y coordinate.
- * @param h_angle_x An angle.
- * @param h_angle_y An angle.
- * @param v_angle_x An angle.
- * @param v_angle_y An angle.
- *
- * Blends the source rectangle (@p source_x, @p source_y, @p source_width,
- * @p source_height) from the
- * @p source_image onto the current image at the destination
- * (@p destination_x, @p destination_y)
- * location. It will be rotated and scaled so that the upper right
- * corner will be positioned @p h_angle_x pixels to the right (or left,
- * if negative) and @p h_angle_y pixels down (from (@p destination_x,
- * @p destination_y). If
- * @p v_angle_x and @p v_angle_y are not 0, the image will also be skewed so
- * that the lower left corner will be positioned @p v_angle_x pixels to
- * the right and @p v_angle_y pixels down. The at_angle versions simply
- * have the @p v_angle_x and @p v_angle_y set to 0 so the rotation doesn't
- * get skewed, and the render_..._on_drawable ones seem obvious
- * enough; they do the same on a drawable.
- *
- * Example:
- * @code
- * imlib_blend_image_onto_image_skewed(..., 0, 0, 100, 0, 0, 100);
- * @endcode
- * will simply scale the image to be 100x100.
- * @code
- * imlib_blend_image_onto_image_skewed(..., 0, 0, 0, 100, 100, 0);
- * @endcode
- * will scale the image to be 100x100, and flip it diagonally.
- * @code
- * imlib_blend_image_onto_image_skewed(..., 100, 0, 0, 100, -100, 0);
- * @endcode
- * will scale the image and rotate it 90 degrees clockwise.
- * @code
- * imlib_blend_image_onto_image_skewed(..., 50, 0, 50, 50, -50, 50);
- * @endcode
- * will rotate the image 45 degrees clockwise, and will scale it so
- * its corners are at (50,0)-(100,50)-(50,100)-(0,50) i.e. it fits
- * into the 100x100 square, so it's scaled down to 70.7% (sqrt(2)/2).
- * @code
- * imlib_blend_image_onto_image_skewed(..., 50, 50, 100 * cos(a), 100 * sin(a), 0);
- * @endcode
- * will rotate the image `a' degrees, with its upper left corner at (50,50).
- **/
-void
-imlib_blend_image_onto_image_skewed(Imlib_Image source_image,
- char merge_alpha, int source_x,
- 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)
-{
- ImlibImage *im_src, *im_dst;
-
- 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",
- ctx->image);
- CAST_IMAGE(im_src, source_image);
- CAST_IMAGE(im_dst, ctx->image);
- if ((!(im_src->data)) && (im_src->loader) && (im_src->loader->load))
- im_src->loader->load(im_src, NULL, 0, 1);
- if (!(im_src->data))
- return;
- if ((!(im_dst->data)) && (im_dst->loader) && (im_dst->loader->load))
- im_dst->loader->load(im_dst, NULL, 0, 1);
- if (!(im_dst->data))
- return;
- __imlib_DirtyImage(im_dst);
- __imlib_BlendImageToImageSkewed(im_src, im_dst, ctx->anti_alias,
- ctx->blend, merge_alpha, source_x,
- source_y, source_width, source_height,
- 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);
-}
-
-#ifndef X_DISPLAY_MISSING
-/**
- * @param source_x The source x coordinate.
- * @param source_y The source y coordinate.
- * @param source_width The source width.
- * @param source_height The source height.
- * @param destination_x The destination x coordinate.
- * @param destination_y The destination y coordinate.
- * @param h_angle_x An angle.
- * @param h_angle_y An angle.
- * @param v_angle_x An angle.
- * @param v_angle_y An angle.
- *
- *
- * Works just like imlib_blend_image_onto_image_skewed(), except it
- * blends the image onto the current drawable instead of the current
- * image.
- **/
-void
-imlib_render_image_on_drawable_skewed(int source_x, 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)
-{
- ImlibImage *im;
-
- if (!ctx)
- ctx = imlib_context_new();
- CHECK_PARAM_POINTER("imlib_render_image_on_drawable_skewed", "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;
- CAST_IMAGE(im, ctx->image);
- __imlib_RenderImageSkewed(ctx->display, im, ctx->drawable, ctx->mask,
- ctx->visual, ctx->colormap, ctx->depth, source_x,
- source_y, source_width, source_height,
- destination_x, destination_y, h_angle_x,
- h_angle_y, v_angle_x, v_angle_y, ctx->anti_alias,
- ctx->dither, ctx->blend, ctx->dither_mask,
- ctx->color_modifier, ctx->operation);
-}
-
-/**
- * @param source_x The source x coordinate.
- * @param source_y The source y coordinate.
- * @param source_width The source width.
- * @param source_height The source height.
- * @param destination_x The destination x coordinate.
- * @param destination_y The destination y coordinate.
- * @param angle_x An angle.
- * @param angle_y An angle.
- *
- *
- * Works just like imlib_render_image_on_drawable_skewed() except you
- * cannot skew an image (@p v_angle_x and @p v_angle_y are 0).
- **/
-void
-imlib_render_image_on_drawable_at_angle(int source_x, int source_y,
- int source_width, int source_height,
- int destination_x, int destination_y,
- int angle_x, int angle_y)
-{
- ImlibImage *im;
-
- if (!ctx)
- ctx = imlib_context_new();
- CHECK_PARAM_POINTER("imlib_render_image_on_drawable_at_angle", "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;
- CAST_IMAGE(im, ctx->image);
- __imlib_RenderImageSkewed(ctx->display, im, ctx->drawable, ctx->mask,
- ctx->visual, ctx->colormap, ctx->depth, source_x,
- source_y, source_width, source_height,
- destination_x, destination_y, angle_x, angle_y,
- 0, 0, ctx->anti_alias, ctx->dither, ctx->blend,
- ctx->dither_mask, ctx->color_modifier,
- ctx->operation);
-}
-#endif
-
-void
-imlib_image_filter(void)
-{
- ImlibImage *im;
-
- 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);
- if ((!(im->data)) && (im->loader) && (im->loader->load))
- im->loader->load(im, NULL, 0, 1);
- if (!(im->data))
- return;
- __imlib_DirtyImage(im);
- __imlib_FilterImage(im, (ImlibFilter *) ctx->filter);
-}
-
-Imlib_Filter
-imlib_create_filter(int initsize)
-{
- if (!ctx)
- ctx = imlib_context_new();
- return (Imlib_Filter) __imlib_CreateFilter(initsize);
-}
-
-void
-imlib_free_filter(void)
-{
- if (!ctx)
- ctx = imlib_context_new();
- CHECK_PARAM_POINTER("imlib_free_filter", "filter", ctx->filter);
- __imlib_FreeFilter((ImlibFilter *) ctx->filter);
- ctx->filter = NULL;
-}
-
-/**
- * @param filter Current filter.
- *
- * Sets the current filter to be used when applying filters to
- * images. Set this to NULL to disable filters.
- */
-void
-imlib_context_set_filter(Imlib_Filter filter)
-{
- if (!ctx)
- ctx = imlib_context_new();
- ctx->filter = filter;
-}
-
-/**
- * @return
- *
- * Gets the current context image filter.
- */
-Imlib_Filter
-imlib_context_get_filter(void)
-{
- 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;
-
- 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);
- __imlib_FilterSetColor(&fil->red, xoff, yoff, 0, r, 0, 0);
- __imlib_FilterSetColor(&fil->green, xoff, yoff, 0, 0, g, 0);
- __imlib_FilterSetColor(&fil->blue, xoff, yoff, 0, 0, 0, b);
-}
-
-void
-imlib_filter_set_alpha(int xoff, int yoff, int a, int r, int g, int b)
-{
- ImlibFilter *fil;
-
- 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);
-}
-
-void
-imlib_filter_set_red(int xoff, int yoff, int a, int r, int g, int b)
-{
- ImlibFilter *fil;
-
- 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);
-}
-
-void
-imlib_filter_set_green(int xoff, int yoff, int a, int r, int g, int b)
-{
- ImlibFilter *fil;
-
- 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);
-}
-
-void
-imlib_filter_set_blue(int xoff, int yoff, int a, int r, int g, int b)
-{
- ImlibFilter *fil;
-
- 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);
-}
-
-void
-imlib_filter_constants(int a, int r, int g, int b)
-{
- if (!ctx)
- ctx = imlib_context_new();
- CHECK_PARAM_POINTER("imlib_filter_constants", "filter", ctx->filter);
- __imlib_FilterConstants((ImlibFilter *) ctx->filter, a, r, g, b);
-}
-
-void
-imlib_filter_divisors(int a, int r, int g, int b)
-{
- if (!ctx)
- ctx = imlib_context_new();
- CHECK_PARAM_POINTER("imlib_filter_divisors", "filter", ctx->filter);
- __imlib_FilterDivisors((ImlibFilter *) ctx->filter, a, r, g, b);
-}
-
-void
-imlib_apply_filter(char *script, ...)
-{
- va_list param_list;
- ImlibImage *im;
-
- if (!ctx)
- ctx = imlib_context_new();
- __imlib_dynamic_filters_init();
- CAST_IMAGE(im, ctx->image);
- if ((!(im->data)) && (im->loader) && (im->loader->load))
- im->loader->load(im, NULL, 0, 1);
- if (!(im->data))
- return;
- __imlib_DirtyImage(im);
- va_start(param_list, script);
- __imlib_script_parse(im, script, param_list);
- va_end(param_list);
-}
-
-/**
- * Returns a new polygon object with no points set.
- **/
-ImlibPolygon
-imlib_polygon_new(void)
-{
- if (!ctx)
- ctx = imlib_context_new();
- return (ImlibPolygon) __imlib_polygon_new();
-}
-
-/**
- * @param poly A polygon
- * @param x The X coordinate.
- * @param y The Y coordinate.
- *
- * Adds the point (@p x, @p y) to the polygon @p poly. The point will be added
- * to the end of the polygon's internal point list. The points are
- * drawn in order, from the first to the last.
- **/
-void
-imlib_polygon_add_point(ImlibPolygon poly, int x, int y)
-{
- if (!ctx)
- ctx = imlib_context_new();
- CHECK_PARAM_POINTER("imlib_polygon_add_point", "polygon", poly);
- __imlib_polygon_add_point((ImlibPoly) poly, x, y);
-}
-
-/**
- * @param poly A polygon.
- *
- * Frees a polygon object.
- **/
-void
-imlib_polygon_free(ImlibPolygon poly)
-{
- if (!ctx)
- ctx = imlib_context_new();
- CHECK_PARAM_POINTER("imlib_polygon_free", "polygon", poly);
- __imlib_polygon_free((ImlibPoly) poly);
-}
-
-/**
- * @param poly A polygon.
- * @param closed Closed polygon flag.
- *
- * Draws the polygon @p poly onto the current context image. Points which have
- * been added to the polygon are drawn in sequence, first to last. The
- * final point will be joined with the first point if @p closed is
- * non-zero.
- **/
-void
-imlib_image_draw_polygon(ImlibPolygon poly, unsigned char closed)
-{
- ImlibImage *im;
- DATA32 color;
-
- 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))
- im->loader->load(im, NULL, 0, 1);
- if (!(im->data))
- return;
- __imlib_DirtyImage(im);
- A_VAL(&color) = (DATA8) ctx->color.alpha;
- R_VAL(&color) = (DATA8) ctx->color.red;
- G_VAL(&color) = (DATA8) ctx->color.green;
- B_VAL(&color) = (DATA8) ctx->color.blue;
- __imlib_Polygon_DrawToImage((ImlibPoly) poly, closed, color,
- im, ctx->cliprect.x, ctx->cliprect.y,
- ctx->cliprect.w, ctx->cliprect.h,
- ctx->operation, ctx->blend, ctx->anti_alias);
-}
-
-/**
- * @param poly A polygon.
- *
- * Fills the area defined by the polygon @p polyon the current context image
- * with the current context color.
- **/
-void
-imlib_image_fill_polygon(ImlibPolygon poly)
-{
- ImlibImage *im;
- DATA32 color;
-
- 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))
- im->loader->load(im, NULL, 0, 1);
- if (!(im->data))
- return;
- __imlib_DirtyImage(im);
- A_VAL(&color) = (DATA8) ctx->color.alpha;
- R_VAL(&color) = (DATA8) ctx->color.red;
- G_VAL(&color) = (DATA8) ctx->color.green;
- B_VAL(&color) = (DATA8) ctx->color.blue;
- __imlib_Polygon_FillToImage((ImlibPoly) poly, color,
- im, ctx->cliprect.x, ctx->cliprect.y,
- ctx->cliprect.w, ctx->cliprect.h,
- ctx->operation, ctx->blend, ctx->anti_alias);
-}
-
-/**
- * @param poly A polygon.
- * @param px1 X coordinate of the upper left corner.
- * @param py1 Y coordinate of the upper left corner.
- * @param px2 X coordinate of the lower right corner.
- * @param py2 Y coordinate of the lower right corner.
- *
- * Calculates the bounding area of the polygon @p poly. (@p px1, @p py1) defines the
- * upper left corner of the bounding box and (@p px2, @p py2) defines it's
- * lower right corner.
- **/
-void
-imlib_polygon_get_bounds(ImlibPolygon poly, int *px1, int *py1, int *px2,
- int *py2)
-{
- if (!ctx)
- ctx = imlib_context_new();
- CHECK_PARAM_POINTER("imlib_polygon_get_bounds", "polygon", poly);
- __imlib_polygon_get_bounds((ImlibPoly) poly, px1, py1, px2, py2);
-}
-
-/**
- * @param xc X coordinate of the center of the ellipse.
- * @param yc Y coordinate of the center of the ellipse.
- * @param a The horizontal amplitude of the ellipse.
- * @param b The vertical amplitude of the ellipse.
- *
- * Draws an ellipse on the current context image. The ellipse is
- * defined as (@p x-@p xc)^2/@p a^2 + (@p y-@p yc)^2/@p b^2 = 1. This means that the
- * point (@p xc, @p yc) marks the center of the ellipse, @p a defines the
- * horizontal amplitude of the ellipse, and @p b defines the vertical
- * amplitude.
- **/
-void
-imlib_image_draw_ellipse(int xc, int yc, int a, int b)
-{
- ImlibImage *im;
- DATA32 color;
-
- 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))
- im->loader->load(im, NULL, 0, 1);
- if (!(im->data))
- return;
- __imlib_DirtyImage(im);
- A_VAL(&color) = (DATA8) ctx->color.alpha;
- R_VAL(&color) = (DATA8) ctx->color.red;
- G_VAL(&color) = (DATA8) ctx->color.green;
- B_VAL(&color) = (DATA8) ctx->color.blue;
- __imlib_Ellipse_DrawToImage(xc, yc, a, b, color,
- im, ctx->cliprect.x, ctx->cliprect.y,
- ctx->cliprect.w, ctx->cliprect.h,
- ctx->operation, ctx->blend, ctx->anti_alias);
-}
-
-/**
- * @param xc X coordinate of the center of the ellipse.
- * @param yc Y coordinate of the center of the ellipse.
- * @param a The horizontal amplitude of the ellipse.
- * @param b The vertical amplitude of the ellipse.
- *
- * Fills an ellipse on the current context image using the current
- * context color. The ellipse is
- * defined as (@p x-@p xc)^2/@p a^2 + (@p y-@p yc)^2/@p b^2 = 1. This means that the
- * point (@p xc, @p yc) marks the center of the ellipse, @p a defines the
- * horizontal amplitude of the ellipse, and @p b defines the vertical
- * amplitude.
- **/
-void
-imlib_image_fill_ellipse(int xc, int yc, int a, int b)
-{
- ImlibImage *im;
- DATA32 color;
-
- 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))
- im->loader->load(im, NULL, 0, 1);
- if (!(im->data))
- return;
- __imlib_DirtyImage(im);
- A_VAL(&color) = (DATA8) ctx->color.alpha;
- R_VAL(&color) = (DATA8) ctx->color.red;
- G_VAL(&color) = (DATA8) ctx->color.green;
- B_VAL(&color) = (DATA8) ctx->color.blue;
- __imlib_Ellipse_FillToImage(xc, yc, a, b, color,
- im, ctx->cliprect.x, ctx->cliprect.y,
- ctx->cliprect.w, ctx->cliprect.h,
- ctx->operation, ctx->blend, ctx->anti_alias);
-}
-
-/**
- * @param poly A polygon
- * @param x The X coordinate.
- * @param y The Y coordinate.
- *
- * Returns non-zero if the point (@p x, @p y) is within the area defined by
- * the polygon @p poly.
- **/
-unsigned char
-imlib_polygon_contains_point(ImlibPolygon poly, int x, int y)
-{
- if (!ctx)
- ctx = imlib_context_new();
- CHECK_PARAM_POINTER_RETURN("imlib_polygon_contains_point", "polygon", poly, 0);
- return __imlib_polygon_contains_point((ImlibPoly) poly, x, y);
-}
-
-void
-imlib_image_clear(void)
-{
- ImlibImage *im;
-
- 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))
- im->loader->load(im, NULL, 0, 1);
- if (!(im->data))
- return;
- __imlib_DirtyImage(im);
- 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;
-
- 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))
- im->loader->load(im, NULL, 0, 1);
- if (!(im->data))
- return;
- __imlib_DirtyImage(im);
- max = im->w * im->h;
- WRITE_RGBA(&col, r, g, b, a);
- for (i = 0; i < max; i++)
- im->data[i] = col;
-}
diff --git a/src/asm_blend.S b/src/asm_blend.S
deleted file mode 100644
index 313e077..0000000
--- a/src/asm_blend.S
+++ /dev/null
@@ -1,1059 +0,0 @@
-#include <config.h>
-
-#ifdef __EMX__
-/* Due to strange behaviour of as.exe we use this macros */
-/* For all OS/2 coders - please use PGCC to compile this code */
-#define PR_(foo) ___##foo
-#define PT_(foo,func) ___##foo,##func
-#define SIZE(sym) \
- .___end_##sym:; \
- .size ___##sym,.___end_##sym-___##sym; \
- .align 8;
-#else
-#define PR_(foo) __##foo
-#define PT_(foo,func) __##foo,##func
-#define SIZE(sym) \
- .__end_##sym:; \
- .size __##sym,.__end_##sym-__##sym; \
- .align 8;
-#endif
-
-#ifdef DO_MMX_ASM
-
-/*\
-|*| MMX assembly blending routines for Imlib2
-|*| Written by Willem Monsuwe <willem@stack.nl>
-|*|
-|*| Special (hairy) constructs are only commented on first use.
-\*/
-
-/*\ All functions have the same calling convention:
-|*| __imlib_mmx_<op>_rgba_to_rgb[A](void *src, int sw, void *dst, int dw,
-|*| int w, int h, ImlibColorModifier *cm)
-\*/
-
-#define src 8(%ebp)
-#define sw 12(%ebp)
-#define dst 16(%ebp)
-#define dw 20(%ebp)
-#define w 24(%ebp)
-#define h 28(%ebp)
-#define cm 32(%ebp)
-
-.text
- .align 8
-.globl PR_(imlib_mmx_blend_rgba_to_rgb)
- .type PT_(imlib_mmx_blend_rgba_to_rgb,@function)
-.globl PR_(imlib_mmx_blend_rgba_to_rgba)
- .type PT_(imlib_mmx_blend_rgba_to_rgba,@function)
-.globl PR_(imlib_mmx_copy_rgba_to_rgb)
- .type PT_(imlib_mmx_copy_rgba_to_rgb,@function)
-.globl PR_(imlib_mmx_copy_rgba_to_rgba)
- .type PT_(imlib_mmx_copy_rgba_to_rgba,@function)
-.globl PR_(imlib_mmx_copy_rgb_to_rgba)
-
- .type PT_(imlib_mmx_copy_rgb_to_rgba,@function)
-.globl PR_(imlib_mmx_add_blend_rgba_to_rgb)
- .type PT_(imlib_mmx_add_blend_rgba_to_rgb,@function)
-.globl PR_(imlib_mmx_add_blend_rgba_to_rgba)
- .type PT_(imlib_mmx_add_blend_rgba_to_rgba,@function)
-.globl PR_(imlib_mmx_add_copy_rgba_to_rgb)
- .type PT_(imlib_mmx_add_copy_rgba_to_rgb,@function)
-.globl PR_(imlib_mmx_add_copy_rgba_to_rgba)
- .type PT_(imlib_mmx_add_copy_rgba_to_rgba,@function)
-.globl PR_(imlib_mmx_add_copy_rgb_to_rgba)
- .type PT_(imlib_mmx_add_copy_rgb_to_rgba,@function)
-
-.globl PR_(imlib_mmx_subtract_blend_rgba_to_rgb)
- .type PT_(imlib_mmx_subtract_blend_rgba_to_rgb,@function)
-.globl PR_(imlib_mmx_subtract_blend_rgba_to_rgba)
- .type PT_(imlib_mmx_subtract_blend_rgba_to_rgba,@function)
-.globl PR_(imlib_mmx_subtract_copy_rgba_to_rgb)
- .type PT_(imlib_mmx_subtract_copy_rgba_to_rgb,@function)
-.globl PR_(imlib_mmx_subtract_copy_rgba_to_rgba)
- .type PT_(imlib_mmx_subtract_copy_rgba_to_rgba,@function)
-.globl PR_(imlib_mmx_subtract_copy_rgb_to_rgba)
- .type PT_(imlib_mmx_subtract_copy_rgb_to_rgba,@function)
-
-.globl PR_(imlib_mmx_reshade_blend_rgba_to_rgb)
- .type PT_(imlib_mmx_reshade_blend_rgba_to_rgb,@function)
-.globl PR_(imlib_mmx_reshade_blend_rgba_to_rgba)
- .type PT_(imlib_mmx_reshade_blend_rgba_to_rgba,@function)
-.globl PR_(imlib_mmx_reshade_copy_rgba_to_rgb)
- .type PT_(imlib_mmx_reshade_copy_rgba_to_rgb,@function)
-.globl PR_(imlib_mmx_reshade_copy_rgba_to_rgba)
- .type PT_(imlib_mmx_reshade_copy_rgba_to_rgba,@function)
-.globl PR_(imlib_mmx_reshade_copy_rgb_to_rgba)
- .type PT_(imlib_mmx_reshade_copy_rgb_to_rgba,@function)
-
-/*\ Some useful masks \*/
-m0X000000: .byte 0, 0, 0, 0, 0, 0, 255, 0
-m10000000: .byte 0, 0, 0, 0, 0, 0, 0, 1
-m00XXXXXX: .byte 255, 255, 255, 255, 255, 255, 0, 0
-mVX000000: .byte 0, 0, 0, 0, 0, 0, 255, 127
-mV0000000: .byte 0, 0, 0, 0, 0, 0, 0, 128
-m0XXX0XXX: .byte 255, 255, 255, 0, 255, 255, 255, 0
-mX000X000: .byte 0, 0, 0, 255, 0, 0, 0, 255
-m10001000: .byte 0, 0, 0, 1, 0, 0, 0, 1
-m000V0V0V: .byte 127, 0, 127, 0, 127, 0, 0, 0
-mI0000000: .byte 0, 0, 0, 0, 0, 0, 0, 64
-m0VVV0VVV: .byte 127, 127, 127, 0, 127, 127, 127, 0
-c1: .word 0x1, 0x1, 0x1, 0x1
-
-/*\ MMX register use:
-|*| %mm1 = Source value
-|*| %mm2 = Destination value
-|*| %mm3 = Alpha value
-|*| %mm4 = 0
-|*| %mm5-%mm6 = masks
-\*/
-
-/*\ Common code \*/
-/*\ Set MMX mode, save registers, load common parameters \*/
-#define ENTER \
- pushl %ebp ;\
- movl %esp, %ebp ;\
- pushl %ebx ;\
- pushl %ecx ;\
- pushl %edx ;\
- pushl %edi ;\
- pushl %esi ;\
- movl h, %edx ;\
- movl w, %ebx ;\
- movl src, %esi ;\
- movl dst, %edi ;\
- leal (%esi, %ebx, 4), %esi ;\
- leal (%edi, %ebx, 4), %edi ;\
- negl %ebx ;\
- jz 9f ;\
- incl %edx ;\
- decl %edx ;\
- jz 9f ;\
- decl %edx ;\
-
-#define LOOP_START \
-8: ;\
- movl %ebx, %ecx
-
-#define LOOP_END \
- movl sw, %ecx ;\
- leal (%esi, %ecx, 4), %esi ;\
- movl dw, %ecx ;\
- leal (%edi, %ecx, 4), %edi ;\
- decl %edx ;\
- jns 8b
-
-
-/*\ Unset MMX mode, reset registers, return \*/
-#define LEAVE \
-9: ;\
- emms ;\
- popl %esi ;\
- popl %edi ;\
- popl %edx ;\
- popl %ecx ;\
- popl %ebx ;\
- movl %ebp, %esp ;\
- popl %ebp ;\
- ret
-
-
-PR_(imlib_mmx_blend_rgba_to_rgb):
- ENTER
-
- pxor %mm4, %mm4
- movq c1, %mm5
-
- LOOP_START
-1:
- /*\ Load source and destination \*/
- movd (%esi, %ecx, 4), %mm1
- movd (%edi, %ecx, 4), %mm2
-
- /*\ Get alpha from source and unpack/copy to eight bytes
- |*| which are treated as four words.
- |*| Result ranges from [0, 0x7fff), and is mapped to
- |*| point value in [0.0, 1.0) by using the high word
- |*| of the 16->32 multiplications.
- |*| (Because we want the unsigned value we shift one bit,
- |*| and also shift the other factor to compensate.)
- |*| Magic to get the fourth byte: lhh
- \*/
- movq %mm1, %mm3
- punpcklbw %mm3, %mm3
- punpckhwd %mm3, %mm3
- punpckhdq %mm3, %mm3
- psrlw $1, %mm3
-
- /*\ Make the alpha value that gets multiplied to the
- |*| alpha channels 0, so the resulting alpha value is
- |*| the destination alpha value.
- \*/
- psrlq $16, %mm3
-
- /*\ Unpack source and destination, bytes to words \*/
- punpcklbw %mm4, %mm1
- punpcklbw %mm4, %mm2
-
- /*\ d = d + (a * ((s - d) + 0.5)) \*/
- psubw %mm2, %mm1
- psllw $1, %mm1
- paddw %mm5, %mm1 /*\ Roundoff \*/
- pmulhw %mm3, %mm1
- paddw %mm1, %mm2
-
- /*\ Pack into lower 4 bytes and save \*/
- packuswb %mm4, %mm2
- movd %mm2, (%edi, %ecx, 4)
-
- incl %ecx
- js 1b
-
- LOOP_END
- LEAVE
-
-SIZE(imlib_mmx_blend_rgba_to_rgb)
-
-PR_(imlib_mmx_blend_rgba_to_rgba):
- ENTER
-
- pxor %mm4, %mm4
- movq m0X000000, %mm5
- movq m00XXXXXX, %mm6
- movq c1, %mm7
-
- LOOP_START
-1:
- /*\ Load source and destination \*/
- movd (%esi, %ecx, 4), %mm1
- movd (%edi, %ecx, 4), %mm2
-
- /*\ Get alpha from source and target, a = src + (255 - dest) \*/
- movq %mm2, %mm3
- pxor %mm6, %mm3
- paddusb %mm1, %mm3
- /*\ Unpack/copy to eight bytes \*/
- punpcklbw %mm3, %mm3
- punpckhwd %mm3, %mm3
- punpckhdq %mm3, %mm3
- psrlw $1, %mm3
-
- /*\ Unpack source and destination, bytes to words \*/
- punpcklbw %mm4, %mm1
- punpcklbw %mm4, %mm2
-
- /*\ Separate alpha channel \*/
- movq %mm1, %mm0
- pand %mm5, %mm0
-
- /*\ d = d + (a * ((s - d) + 0.5)) \*/
- psubw %mm2, %mm1
- psllw $1, %mm1
- paddw %mm7, %mm1 /*\ Roundoff \*/
- pmulhw %mm3, %mm1
-
- /*\ Replace alpha channel with separated out version in mm0 and add \*/
- pand %mm6, %mm1
- por %mm0, %mm1
- paddw %mm1, %mm2
-
- /*\ Pack into lower 4 bytes and save \*/
- packuswb %mm4, %mm2
- movd %mm2, (%edi, %ecx, 4)
-
- incl %ecx
- js 1b
-
- LOOP_END
- LEAVE
-
-SIZE(imlib_mmx_blend_rgba_to_rgba)
-
-PR_(imlib_mmx_copy_rgba_to_rgb):
- ENTER
-
- movq m0XXX0XXX, %mm5
- movq mX000X000, %mm6
-
- /*\ Two at a time: last item is at %ecx = 0 \*/
- subl $4, %esi
- subl $4, %edi
-
- LOOP_START
- incl %ecx
- jz 2f
-1:
- /*\ Load source and destination \*/
- movq (%esi, %ecx, 4), %mm1
- movq (%edi, %ecx, 4), %mm2
-
- /*\ Clear alpha channel of source, get alpha of destination \*/
- pand %mm5, %mm1
- pand %mm6, %mm2
-
- /*\ d = d | s, and save \*/
- por %mm1, %mm2
- movq %mm2, (%edi, %ecx, 4)
-
- addl $2, %ecx
- js 1b
- jnz 3f
-2:
- movd (%esi), %mm1
- movd (%edi), %mm2
-
- pand %mm5, %mm1
- pand %mm6, %mm2
-
- por %mm1, %mm2
- movd %mm2, (%edi)
-3:
- LOOP_END
- LEAVE
-
-SIZE(imlib_mmx_copy_rgba_to_rgb)
-
-PR_(imlib_mmx_copy_rgba_to_rgba):
- ENTER
-
- subl $4, %esi
- subl $4, %edi
-
- LOOP_START
- incl %ecx
- jz 2f
-1:
- /*\ Load source, save destination \*/
- movq (%esi, %ecx, 4), %mm1
- movq %mm1, (%edi, %ecx, 4)
-
- addl $2, %ecx
- js 1b
- jnz 3f
-2:
- movd (%esi), %mm1
- movd %mm1, (%edi)
-3:
- LOOP_END
- LEAVE
-
-SIZE(imlib_mmx_copy_rgba_to_rgba)
-
-PR_(imlib_mmx_copy_rgb_to_rgba):
- ENTER
-
- movq mX000X000, %mm5
-
- subl $4, %esi
- subl $4, %edi
-
- LOOP_START
- incl %ecx
- jz 2f
-1:
- /*\ Load source, save destination \*/
- movq (%esi, %ecx, 4), %mm1
- por %mm5, %mm1
- movq %mm1, (%edi, %ecx, 4)
-
- addl $2, %ecx
- js 1b
- jnz 3f
-2:
- movd (%esi), %mm1
- por %mm5, %mm1
- movd %mm1, (%edi)
-3:
-
- LOOP_END
- LEAVE
-
-SIZE(imlib_mmx_copy_rgb_to_rgba)
-
-PR_(imlib_mmx_add_blend_rgba_to_rgb):
- ENTER
-
- pxor %mm4, %mm4
-
- LOOP_START
-1:
- /*\ Load source and destination \*/
- movd (%esi, %ecx, 4), %mm1
- movd (%edi, %ecx, 4), %mm2
-
- /*\ Get alpha from source and unpack/copy to eight bytes \*/
- movq %mm1, %mm3
- punpcklbw %mm3, %mm3
- punpckhwd %mm3, %mm3
- punpckhdq %mm3, %mm3
- psrlw $1, %mm3
-
- psrlq $16, %mm3
-
- /*\ Unpack source and destination, bytes to words \*/
- punpcklbw %mm4, %mm1
- punpcklbw %mm4, %mm2
-
- /*\ d = d + (a * s) \*/
- psllw $1, %mm1
- pmulhw %mm3, %mm1
- paddw %mm1, %mm2
-
- /*\ Pack into lower 4 bytes and save \*/
- packuswb %mm4, %mm2
- movd %mm2, (%edi, %ecx, 4)
-
- incl %ecx
- js 1b
-
- LOOP_END
- LEAVE
-
-SIZE(imlib_mmx_add_blend_rgba_to_rgb)
-
-PR_(imlib_mmx_add_blend_rgba_to_rgba):
- ENTER
-
- pxor %mm4, %mm4
- movq mVX000000, %mm5
- movq m00XXXXXX, %mm6
-
- LOOP_START
-1:
- /*\ Load source and destination \*/
- movd (%esi, %ecx, 4), %mm1
- movd (%edi, %ecx, 4), %mm2
-
- /*\ Get alpha from source and target and unpack/copy to eight bytes \*/
- movq %mm2, %mm3
- pxor %mm6, %mm3
- paddusb %mm1, %mm3
- punpcklbw %mm3, %mm3
- punpckhwd %mm3, %mm3
- punpckhdq %mm3, %mm3
- psrlw $1, %mm3
-
- /*\ Make the alpha value that gets multiplied to the
- |*| alpha channels 0x7fff, so the resulting alpha value is
- |*| the sum of the source and destination alpha values.
- \*/
- por %mm5, %mm3
-
- /*\ Unpack source and destination, bytes to words \*/
- punpcklbw %mm4, %mm1
- punpcklbw %mm4, %mm2
-
- /*\ d = d + (a * s) \*/
- psllw $1, %mm1
- pmulhw %mm3, %mm1
- paddw %mm1, %mm2
-
- /*\ Pack into lower 4 bytes and save \*/
- packuswb %mm4, %mm2
- movd %mm2, (%edi, %ecx, 4)
-
- incl %ecx
- js 1b
-
- LOOP_END
- LEAVE
-
-SIZE(imlib_mmx_add_blend_rgba_to_rgba)
-
-PR_(imlib_mmx_add_copy_rgba_to_rgb):
- ENTER
-
- movq m0XXX0XXX, %mm5
-
- subl $4, %esi
- subl $4, %edi
-
- LOOP_START
- incl %ecx
- jz 2f
-1:
- /*\ Load source and destination \*/
- movq (%esi, %ecx, 4), %mm1
- movq (%edi, %ecx, 4), %mm2
-
- /*\ Clear alpha channel of source \*/
- pand %mm5, %mm1
-
- /*\ d = d + s, unsigned saturation, and save \*/
- paddusb %mm1, %mm2
- movq %mm2, (%edi, %ecx, 4)
-
- addl $2, %ecx
- js 1b
- jnz 3f
-2:
- movd (%esi), %mm1
- movd (%edi), %mm2
- pand %mm5, %mm1
- paddusb %mm1, %mm2
- movd %mm2, (%edi)
-3:
- LOOP_END
- LEAVE
-
-SIZE(imlib_mmx_add_copy_rgba_to_rgb)
-
-PR_(imlib_mmx_add_copy_rgba_to_rgba):
- ENTER
-
- subl $4, %esi
- subl $4, %edi
-
- LOOP_START
- incl %ecx
- jz 2f
-1:
- /*\ Load source and destination \*/
- movq (%esi, %ecx, 4), %mm1
- movq (%edi, %ecx, 4), %mm2
-
- /*\ d = d + s, unsigned saturation, and save \*/
- paddusb %mm1, %mm2
- movq %mm2, (%edi, %ecx, 4)
-
- addl $2, %ecx
- js 1b
- jnz 3f
-2:
- movd (%esi), %mm1
- movd (%edi), %mm2
- paddusb %mm1, %mm2
- movd %mm2, (%edi)
-3:
- LOOP_END
- LEAVE
-
-SIZE(imlib_mmx_add_copy_rgba_to_rgba)
-
-PR_(imlib_mmx_add_copy_rgb_to_rgba):
- ENTER
-
- movq mX000X000, %mm5
-
- subl $4, %esi
- subl $4, %edi
-
- LOOP_START
- incl %ecx
- jz 2f
-1:
- /*\ Load source and destination \*/
- movq (%esi, %ecx, 4), %mm1
- movq (%edi, %ecx, 4), %mm2
-
- /*\ d = d + s, unsigned saturation, and save \*/
- paddusb %mm1, %mm2
-
- /*\ Make result alpha 0xff \*/
- por %mm5, %mm2
- movq %mm2, (%edi, %ecx, 4)
-
- addl $2, %ecx
- js 1b
- jnz 3f
-2:
- movd (%esi), %mm1
- movd (%edi), %mm2
- paddusb %mm1, %mm2
- por %mm5, %mm2
- movd %mm2, (%edi)
-3:
- LOOP_END
- LEAVE
-
-SIZE(imlib_mmx_add_copy_rgb_to_rgba)
-
-PR_(imlib_mmx_subtract_blend_rgba_to_rgb):
- ENTER
-
- pxor %mm4, %mm4
-
- LOOP_START
-1:
- /*\ Load source and destination \*/
- movd (%esi, %ecx, 4), %mm1
- movd (%edi, %ecx, 4), %mm2
-
- /*\ Get alpha from source and unpack/copy to eight bytes \*/
- movq %mm1, %mm3
- punpcklbw %mm3, %mm3
- punpckhwd %mm3, %mm3
- punpckhdq %mm3, %mm3
- psrlw $1, %mm3
-
- psrlq $16, %mm3
-
- /*\ Unpack source and destination, bytes to words \*/
- punpcklbw %mm4, %mm1
- punpcklbw %mm4, %mm2
-
- /*\ d = d - (a * s) \*/
- psllw $1, %mm1
- pmulhw %mm3, %mm1
- psubw %mm1, %mm2
-
- /*\ Pack into lower 4 bytes and save \*/
- packuswb %mm4, %mm2
- movd %mm2, (%edi, %ecx, 4)
-
- incl %ecx
- js 1b
-
- LOOP_END
- LEAVE
-
-SIZE(imlib_mmx_subtract_blend_rgba_to_rgb)
-
-PR_(imlib_mmx_subtract_blend_rgba_to_rgba):
- ENTER
-
- pxor %mm4, %mm4
- movq mV0000000, %mm5
- movq m00XXXXXX, %mm6
-
- LOOP_START
-1:
- /*\ Load source and destination \*/
- movd (%esi, %ecx, 4), %mm1
- movd (%edi, %ecx, 4), %mm2
-
- /*\ Get alpha from source and target and unpack/copy to eight bytes \*/
- movq %mm2, %mm3
- pxor %mm6, %mm3
- paddusb %mm1, %mm3
- punpcklbw %mm3, %mm3
- punpckhwd %mm3, %mm3
- punpckhdq %mm3, %mm3
- psrlw $1, %mm3
-
- /*\ Make alpha value that gets multiplied with alpha channel
- |*| 0x8000, (-1.0), so that the alpha result is s + d
- \*/
- psrlq $16, %mm3
- por %mm5, %mm3
-
- /*\ Unpack source and destination, bytes to words \*/
- punpcklbw %mm4, %mm1
- punpcklbw %mm4, %mm2
-
- /*\ d = d - (a * s) \*/
- psllw $1, %mm1
- pmulhw %mm3, %mm1
- psubw %mm1, %mm2
-
- /*\ Pack into lower 4 bytes and save \*/
- packuswb %mm4, %mm2
- movd %mm2, (%edi, %ecx, 4)
-
- incl %ecx
- js 1b
-
- LOOP_END
- LEAVE
-
-SIZE(imlib_mmx_subtract_blend_rgba_to_rgba)
-
-PR_(imlib_mmx_subtract_copy_rgba_to_rgb):
- ENTER
-
- movq m0XXX0XXX, %mm5
-
- subl $4, %esi
- subl $4, %edi
-
- LOOP_START
- incl %ecx
- jz 2f
-1:
- /*\ Load source and destination \*/
- movq (%esi, %ecx, 4), %mm1
- movq (%edi, %ecx, 4), %mm2
-
- /*\ Clear alpha channel of source \*/
- pand %mm5, %mm1
-
- /*\ d = d - s, unsigned saturation, and save \*/
- psubusb %mm1, %mm2
- movq %mm2, (%edi, %ecx, 4)
-
- addl $2, %ecx
- js 1b
- jnz 3f
-2:
- movd (%esi), %mm1
- movd (%edi), %mm2
- pand %mm5, %mm1
- psubusb %mm1, %mm2
- movd %mm2, (%edi)
-3:
- LOOP_END
- LEAVE
-
-SIZE(imlib_mmx_subtract_copy_rgba_to_rgb)
-
-PR_(imlib_mmx_subtract_copy_rgba_to_rgba):
- ENTER
-
- movq mX000X000, %mm5
-
- subl $4, %esi
- subl $4, %edi
-
- LOOP_START
- incl %ecx
- jz 2f
-1:
- /*\ Load source and destination \*/
- movq (%esi, %ecx, 4), %mm1
- movq (%edi, %ecx, 4), %mm2
-
- /*\ Negate destination alphas \*/
- pxor %mm5, %mm2
-
- /*\ d = d - s, unsigned saturation, and save \*/
- psubusb %mm1, %mm2
-
- /*\ Negate result alphas \*/
- pxor %mm5, %mm2
- movq %mm2, (%edi, %ecx, 4)
-
- addl $2, %ecx
- js 1b
- jnz 3f
-2:
- movd (%esi), %mm1
- movd (%edi), %mm2
- pxor %mm5, %mm2
- psubusb %mm1, %mm2
- pxor %mm5, %mm2
- movd %mm2, (%edi)
-3:
- LOOP_END
- LEAVE
-
-SIZE(imlib_mmx_subtract_copy_rgba_to_rgba)
-
-PR_(imlib_mmx_subtract_copy_rgb_to_rgba):
- ENTER
-
- movq mX000X000, %mm5
-
- subl $4, %esi
- subl $4, %edi
-
- LOOP_START
- incl %ecx
- jz 2f
-1:
- /*\ Load source and destination \*/
- movq (%esi, %ecx, 4), %mm1
- movq (%edi, %ecx, 4), %mm2
-
- /*\ d = d - s, unsigned saturation, and save \*/
- psubusb %mm1, %mm2
-
- /*\ Make result alpha 0xff \*/
- por %mm5, %mm2
- movq %mm2, (%edi, %ecx, 4)
-
- addl $2, %ecx
- js 1b
- jnz 3f
-2:
- movd (%esi), %mm1
- movd (%edi), %mm2
- psubusb %mm1, %mm2
- por %mm5, %mm2
- movd %mm2, (%edi)
-3:
- LOOP_END
- LEAVE
-
-SIZE(imlib_mmx_subtract_copy_rgb_to_rgba)
-
-PR_(imlib_mmx_reshade_blend_rgba_to_rgb):
- ENTER
-
- pxor %mm4, %mm4
- movq m000V0V0V, %mm6
-
- LOOP_START
-1:
- /*\ Load source and destination \*/
- movd (%esi, %ecx, 4), %mm1
- movd (%edi, %ecx, 4), %mm2
-
- /*\ Get alpha from source and unpack/copy to eight bytes \*/
- movq %mm1, %mm3
- punpcklbw %mm3, %mm3
- punpckhwd %mm3, %mm3
- punpckhdq %mm3, %mm3
- psrlw $1, %mm3
-
- psrlq $16, %mm3
-
- /*\ Unpack source and destination, bytes to words \*/
- punpcklbw %mm4, %mm1
- punpcklbw %mm4, %mm2
-
- /*\ d = d + (2 * a * (s - 127)) \*/
- psubw %mm6, %mm1
- psllw $2, %mm1
- pmulhw %mm3, %mm1
- paddw %mm1, %mm2
-
- /*\ Pack into lower 4 bytes and save \*/
- packuswb %mm4, %mm2
- movd %mm2, (%edi, %ecx, 4)
-
- incl %ecx
- js 1b
-
- LOOP_END
- LEAVE
-
-SIZE(imlib_mmx_reshade_blend_rgba_to_rgb)
-
-PR_(imlib_mmx_reshade_blend_rgba_to_rgba):
- ENTER
-
- pxor %mm4, %mm4
- movq mI0000000, %mm5
- movq m000V0V0V, %mm6
- movq m00XXXXXX, %mm7
-
- LOOP_START
-1:
- /*\ Load source and destination \*/
- movd (%esi, %ecx, 4), %mm1
- movd (%edi, %ecx, 4), %mm2
-
- /*\ Get alpha from source and target and unpack/copy to eight bytes \*/
- movq %mm2, %mm3
- pxor %mm7, %mm3
- paddusb %mm1, %mm3
- punpcklbw %mm3, %mm3
- punpckhwd %mm3, %mm3
- punpckhdq %mm3, %mm3
- psrlw $1, %mm3
-
- /*\ Make the alpha value that gets multiplied to the
- |*| alpha channels 0x4000 (0.5), so the resulting alpha value is
- |*| the sum of the source and destination alpha values.
- \*/
- psrlq $16, %mm3
- por %mm5, %mm3
-
- /*\ Unpack source and destination, bytes to words \*/
- punpcklbw %mm4, %mm1
- punpcklbw %mm4, %mm2
-
- /*\ d = d + (2 * a * (s - 127)), (alpha channel: d = d + (2 * 0.5 * (s - 0)) ) \*/
- psubw %mm6, %mm1
- psllw $2, %mm1
- pmulhw %mm3, %mm1
- paddw %mm1, %mm2
-
- /*\ Pack into lower 4 bytes and save \*/
- packuswb %mm4, %mm2
- movd %mm2, (%edi, %ecx, 4)
-
- incl %ecx
- js 1b
-
- LOOP_END
- LEAVE
-
-SIZE(imlib_mmx_reshade_blend_rgba_to_rgba)
-
-PR_(imlib_mmx_reshade_copy_rgba_to_rgb):
- ENTER
-
- pxor %mm4, %mm4
- movq m0XXX0XXX, %mm5
- movq m0VVV0VVV, %mm6
-
- subl $4, %esi
- subl $4, %edi
-
- LOOP_START
- incl %ecx
- jz 2f
-1:
- /*\ Load source and destination \*/
- movq (%esi, %ecx, 4), %mm1
- movq (%edi, %ecx, 4), %mm2
-
- /*\ To take advantage of saturation and be able to do 8 bytes
- |*| at a time, we divide reshading into two separate steps:
- |*| adding values above 128, and subtracting values below 128
- |*| These values go into %mm1 and %mm3 respectively
- |*| - %mm1 becomes (2 * (s - 127))
- |*| - %mm3 becomes (2 * (255 - (127 + s))) = (2 * (128 - s))
- \*/
- movq %mm1, %mm3
- psubusb %mm6, %mm1
- paddusb %mm1, %mm1
- paddusb %mm6, %mm3
- pxor %mm5, %mm3
- paddusb %mm3, %mm3
-
- /*\ Clear alpha channel of s1 and s2 \*/
- pand %mm5, %mm1
- pand %mm5, %mm3
-
- /*\ d = d + s1 - s2, unsigned saturation, and save \*/
- paddusb %mm1, %mm2
- psubusb %mm3, %mm2
- movq %mm2, (%edi, %ecx, 4)
-
- addl $2, %ecx
- js 1b
- jnz 3f
-2:
- movd (%esi), %mm1
- movd (%edi), %mm2
- movq %mm1, %mm3
- psubusb %mm6, %mm1
- paddusb %mm1, %mm1
- paddusb %mm6, %mm3
- pxor %mm5, %mm3
- paddusb %mm3, %mm3
- pand %mm5, %mm1
- pand %mm5, %mm3
- paddusb %mm1, %mm2
- psubusb %mm3, %mm2
- movd %mm2, (%edi)
-3:
- LOOP_END
- LEAVE
-
-SIZE(imlib_mmx_reshade_copy_rgba_to_rgb)
-
-PR_(imlib_mmx_reshade_copy_rgba_to_rgba):
- ENTER
-
- pxor %mm4, %mm4
- movq m0XXX0XXX, %mm5
- movq m0VVV0VVV, %mm6
-
- subl $4, %esi
- subl $4, %edi
-
- LOOP_START
- incl %ecx
- jz 2f
-1:
- /*\ Load source and destination \*/
- movq (%esi, %ecx, 4), %mm1
- movq (%edi, %ecx, 4), %mm2
-
- /*\ This time, the alpha channels have to be added.
- |*| For that, the alpha channel of %mm1 should remain
- |*| the same. This is done by subtracting 0 from the
- |*| alpha channel, and then doing the *2 via a separate
- |*| register, clearing its alpha channel first.
- \*/
- movq %mm1, %mm3
- psubusb %mm6, %mm1
- movq %mm1, %mm0
- pand %mm5, %mm0
- paddusb %mm0, %mm1
- paddusb %mm6, %mm3
- pxor %mm5, %mm3
- paddusb %mm3, %mm3
-
- /*\ Clear alpha channel of s2 \*/
- pand %mm5, %mm3
-
- /*\ d = d + s1 - s2, unsigned saturation, and save \*/
- paddusb %mm1, %mm2
- psubusb %mm3, %mm2
- movq %mm2, (%edi, %ecx, 4)
-
- addl $2, %ecx
- js 1b
- jnz 3f
-2:
- movd (%esi), %mm1
- movd (%edi), %mm2
- movq %mm1, %mm3
- psubusb %mm6, %mm1
- movq %mm1, %mm0
- pand %mm5, %mm0
- paddusb %mm0, %mm1
- paddusb %mm6, %mm3
- pxor %mm5, %mm3
- paddusb %mm3, %mm3
- pand %mm5, %mm3
- paddusb %mm1, %mm2
- psubusb %mm3, %mm2
- movd %mm2, (%edi)
-3:
- LOOP_END
- LEAVE
-
-SIZE(imlib_mmx_reshade_copy_rgba_to_rgba)
-
-PR_(imlib_mmx_reshade_copy_rgb_to_rgba):
- ENTER
-
- pxor %mm4, %mm4
- movq m0XXX0XXX, %mm5
- movq m0VVV0VVV, %mm6
- movq mX000X000, %mm7
-
- subl $4, %esi
- subl $4, %edi
-
- LOOP_START
- incl %ecx
- jz 2f
-1:
- /*\ Load source and destination \*/
- movq (%esi, %ecx, 4), %mm1
- movq (%edi, %ecx, 4), %mm2
-
- movq %mm1, %mm3
- psubusb %mm6, %mm1
- paddusb %mm1, %mm1
- paddusb %mm6, %mm3
- pxor %mm5, %mm3
- paddusb %mm3, %mm3
-
- /*\ d = d + s1 - s2, unsigned saturation, and save \*/
- paddusb %mm1, %mm2
- psubusb %mm3, %mm2
-
- /*\ Make result alpha 0xff \*/
- por %mm7, %mm2
- movq %mm2, (%edi, %ecx, 4)
-
- addl $2, %ecx
- js 1b
- jnz 3f
-2:
- movd (%esi), %mm1
- movd (%edi), %mm2
- movq %mm1, %mm3
- psubusb %mm6, %mm1
- paddusb %mm1, %mm1
- paddusb %mm6, %mm3
- pxor %mm5, %mm3
- paddusb %mm3, %mm3
- paddusb %mm1, %mm2
- psubusb %mm3, %mm2
- por %mm7, %mm2
- movd %mm2, (%edi)
-3:
- LOOP_END
- LEAVE
-
-SIZE(imlib_mmx_reshade_copy_rgb_to_rgba)
-
-#endif
diff --git a/src/asm_blend_cmod.S b/src/asm_blend_cmod.S
deleted file mode 100644
index a09c7c5..0000000
--- a/src/asm_blend_cmod.S
+++ /dev/null
@@ -1,1604 +0,0 @@
-#include <config.h>
-
-#ifdef __EMX__
-/* Due to strange behaviour of as.exe we use this macros */
-/* For all OS/2 coders - please use PGCC to compile this code */
-#define PR_(foo) ___##foo
-#define PT_(foo,func) ___##foo,##func
-#define SIZE(sym) \
- .___end_##sym:; \
- .size ___##sym,.___end_##sym-___##sym; \
- .align 8;
-#else
-#define PR_(foo) __##foo
-#define PT_(foo,func) __##foo,##func
-#define SIZE(sym) \
- .__end_##sym:; \
- .size __##sym,.__end_##sym-__##sym; \
- .align 8;
-#endif
-
-#ifdef DO_MMX_ASM
-
-/*\
-|*| MMX assembly blending routines, with colour modding, for Imlib2
-|*| Written by Willem Monsuwe <willem@stack.nl>
-|*|
-|*| Special (hairy) constructs are only commented on first use.
-\*/
-
-/*\ All functions have the same calling convention:
-|*| PR_(imlib_mmx_<op>_rgba_to_rgb[A]_cmod(void *src, int sw, void *dst, int dw,
-|*| int w, int h, ImlibColorModifier *cm)
-\*/
-
-#define src 8(%ebp)
-#define sw 12(%ebp)
-#define dst 16(%ebp)
-#define dw 20(%ebp)
-#define w 24(%ebp)
-#define h 28(%ebp)
-#define cm 32(%ebp)
-
-/*\ Cmod tables, from %ebx \*/
-#define rmap(x) (%ebx, x)
-#define gmap(x) 0x100(%ebx, x)
-#define bmap(x) 0x200(%ebx, x)
-#define amap(x) 0x300(%ebx, x)
-#define amap_ff 0x3ff(%ebx)
-
-.text
- .align 8
-.globl PR_(imlib_mmx_blend_rgba_to_rgb_cmod)
- .type PT_(imlib_mmx_blend_rgba_to_rgb_cmod,@function)
-.globl PR_(imlib_mmx_blend_rgba_to_rgba_cmod)
- .type PT_(imlib_mmx_blend_rgba_to_rgba_cmod,@function)
-.globl PR_(imlib_mmx_blend_rgb_to_rgb_cmod)
- .type PT_(imlib_mmx_blend_rgb_to_rgb_cmod,@function)
-.globl PR_(imlib_mmx_blend_rgb_to_rgba_cmod)
- .type PT_(imlib_mmx_blend_rgb_to_rgba_cmod,@function)
-
-.globl PR_(imlib_mmx_copy_rgba_to_rgb_cmod)
- .type PT_(imlib_mmx_copy_rgba_to_rgb_cmod,@function)
-.globl PR_(imlib_mmx_copy_rgba_to_rgba_cmod)
- .type PT_(imlib_mmx_copy_rgba_to_rgba_cmod,@function)
-.globl PR_(imlib_mmx_copy_rgb_to_rgba_cmod)
- .type PT_(imlib_mmx_copy_rgb_to_rgba_cmod,@function)
-
-.globl PR_(imlib_mmx_add_blend_rgba_to_rgb_cmod)
- .type PT_(imlib_mmx_add_blend_rgba_to_rgb_cmod,@function)
-.globl PR_(imlib_mmx_add_blend_rgba_to_rgba_cmod)
- .type PT_(imlib_mmx_add_blend_rgba_to_rgba_cmod,@function)
-.globl PR_(imlib_mmx_add_blend_rgb_to_rgb_cmod)
- .type PT_(imlib_mmx_add_blend_rgb_to_rgb_cmod,@function)
-.globl PR_(imlib_mmx_add_blend_rgb_to_rgba_cmod)
- .type PT_(imlib_mmx_add_blend_rgb_to_rgba_cmod,@function)
-
-.globl PR_(imlib_mmx_add_copy_rgba_to_rgb_cmod)
- .type PT_(imlib_mmx_add_copy_rgba_to_rgb_cmod,@function)
-.globl PR_(imlib_mmx_add_copy_rgba_to_rgba_cmod)
- .type PT_(imlib_mmx_add_copy_rgba_to_rgba_cmod,@function)
-.globl PR_(imlib_mmx_add_copy_rgb_to_rgba_cmod)
- .type PT_(imlib_mmx_add_copy_rgb_to_rgba_cmod,@function)
-
-.globl PR_(imlib_mmx_subtract_blend_rgba_to_rgb_cmod)
- .type PT_(imlib_mmx_subtract_blend_rgba_to_rgb_cmod,@function)
-.globl PR_(imlib_mmx_subtract_blend_rgba_to_rgba_cmod)
- .type PT_(imlib_mmx_subtract_blend_rgba_to_rgba_cmod,@function)
-.globl PR_(imlib_mmx_subtract_blend_rgb_to_rgb_cmod)
- .type PT_(imlib_mmx_subtract_blend_rgb_to_rgb_cmod,@function)
-.globl PR_(imlib_mmx_subtract_blend_rgb_to_rgba_cmod)
- .type PT_(imlib_mmx_subtract_blend_rgb_to_rgba_cmod,@function)
-
-.globl PR_(imlib_mmx_subtract_copy_rgba_to_rgb_cmod)
- .type PT_(imlib_mmx_subtract_copy_rgba_to_rgb_cmod,@function)
-.globl PR_(imlib_mmx_subtract_copy_rgba_to_rgba_cmod)
- .type PT_(imlib_mmx_subtract_copy_rgba_to_rgba_cmod,@function)
-.globl PR_(imlib_mmx_subtract_copy_rgb_to_rgba_cmod)
- .type PT_(imlib_mmx_subtract_copy_rgb_to_rgba_cmod,@function)
-
-.globl PR_(imlib_mmx_reshade_blend_rgba_to_rgb_cmod)
- .type PT_(imlib_mmx_reshade_blend_rgba_to_rgb_cmod,@function)
-.globl PR_(imlib_mmx_reshade_blend_rgba_to_rgba_cmod)
- .type PT_(imlib_mmx_reshade_blend_rgba_to_rgba_cmod,@function)
-.globl PR_(imlib_mmx_reshade_blend_rgb_to_rgb_cmod)
- .type PT_(imlib_mmx_reshade_blend_rgb_to_rgb_cmod,@function)
-.globl PR_(imlib_mmx_reshade_blend_rgb_to_rgba_cmod)
- .type PT_(imlib_mmx_reshade_blend_rgb_to_rgba_cmod,@function)
-
-.globl PR_(imlib_mmx_reshade_copy_rgba_to_rgb_cmod)
- .type PT_(imlib_mmx_reshade_copy_rgba_to_rgb_cmod,@function)
-.globl PR_(imlib_mmx_reshade_copy_rgba_to_rgba_cmod)
- .type PT_(imlib_mmx_reshade_copy_rgba_to_rgba_cmod,@function)
-.globl PR_(imlib_mmx_reshade_copy_rgb_to_rgba_cmod)
- .type PT_(imlib_mmx_reshade_copy_rgb_to_rgba_cmod,@function)
-
-/*\ Some useful masks \*/
-m0X000000: .byte 0, 0, 0, 0, 0, 0, 255, 0
-m10000000: .byte 0, 0, 0, 0, 0, 0, 0, 1
-m00XXXXXX: .byte 255, 255, 255, 255, 255, 255, 0, 0
-mVX000000: .byte 0, 0, 0, 0, 0, 0, 255, 127
-mV0000000: .byte 0, 0, 0, 0, 0, 0, 0, 128
-m0XXX0XXX: .byte 255, 255, 255, 0, 255, 255, 255, 0
-mX000X000: .byte 0, 0, 0, 255, 0, 0, 0, 255
-m10001000: .byte 0, 0, 0, 1, 0, 0, 0, 1
-m000V0V0V: .byte 127, 0, 127, 0, 127, 0, 0, 0
-mI0000000: .byte 0, 0, 0, 0, 0, 0, 0, 64
-m0VVV0VVV: .byte 127, 127, 127, 0, 127, 127, 127, 0
-c1: .word 0x1, 0x1, 0x1, 0x1
-
-/*\ MMX register use:
-|*| %mm1 = Source value
-|*| %mm2 = Destination value
-|*| %mm3 = Alpha value
-|*| %mm4 = 0
-|*| %mm5-%mm6 = masks
-\*/
-
-/*\ Common code \*/
-/*\ Set MMX mode, save registers, load common parameters \*/
-#define ENTER \
- pushl %ebp ;\
- movl %esp, %ebp ;\
- pushl %ebx ;\
- pushl %ecx ;\
- pushl %edx ;\
- pushl %edi ;\
- pushl %esi ;\
- movl cm, %ebx ;\
- movl src, %esi ;\
- movl dst, %edi ;\
- movl w, %ecx ;\
- leal (%esi, %ecx, 4), %esi ;\
- leal (%edi, %ecx, 4), %edi ;\
- negl %ecx ;\
- jz 9f ;\
- movl h, %edx ;\
- decl %edx ;\
- jz 9f ;\
-
-#define LOOP_START \
-8: ;\
- movl w, %ecx ;\
- negl %ecx
-
-#define LOOP_END \
- movl sw, %ecx ;\
- leal (%esi, %ecx, 4), %esi ;\
- movl dw, %ecx ;\
- leal (%edi, %ecx, 4), %edi ;\
- decl %edx ;\
- jns 8b
-
-
-/*\ Unset MMX mode, reset registers, return \*/
-#define LEAVE \
-9: ;\
- emms ;\
- popl %esi ;\
- popl %edi ;\
- popl %edx ;\
- popl %ecx ;\
- popl %ebx ;\
- movl %ebp, %esp ;\
- popl %ebp ;\
- ret
-
-
-/*\ Load one value, colourmod it, and put it in %mm1 \*/
-#define LOAD1_CMOD \
- movzbl 3(%esi, %ecx, 4), %eax ;\
- movzbl amap(%eax), %eax ;\
- movd %eax, %mm1 ;\
- movzbl 2(%esi, %ecx, 4), %eax ;\
- psllq $8, %mm1 ;\
- movzbl rmap(%eax), %eax ;\
- movd %eax, %mm0 ;\
- movzbl 1(%esi, %ecx, 4), %eax ;\
- por %mm0, %mm1 ;\
- movzbl gmap(%eax), %eax ;\
- psllq $8, %mm1 ;\
- movd %eax, %mm0 ;\
- movzbl (%esi, %ecx, 4), %eax ;\
- por %mm0, %mm1 ;\
- movzbl bmap(%eax), %eax ;\
- psllq $8, %mm1 ;\
- movd %eax, %mm0 ;\
- por %mm0, %mm1
-
-
-/*\ Load two values, colourmod them, and put them in %mm1 \*/
-#define LOAD2_CMOD \
- movzbl 7(%esi, %ecx, 4), %eax ;\
- movzbl amap(%eax), %eax ;\
- movd %eax, %mm1 ;\
- movzbl 6(%esi, %ecx, 4), %eax ;\
- psllq $8, %mm1 ;\
- movzbl rmap(%eax), %eax ;\
- movd %eax, %mm0 ;\
- movzbl 5(%esi, %ecx, 4), %eax ;\
- por %mm0, %mm1 ;\
- movzbl gmap(%eax), %eax ;\
- psllq $8, %mm1 ;\
- movd %eax, %mm0 ;\
- movzbl 4(%esi, %ecx, 4), %eax ;\
- por %mm0, %mm1 ;\
- movzbl bmap(%eax), %eax ;\
- psllq $8, %mm1 ;\
- movd %eax, %mm0 ;\
- movzbl 3(%esi, %ecx, 4), %eax ;\
- por %mm0, %mm1 ;\
- movzbl amap(%eax), %eax ;\
- psllq $8, %mm1 ;\
- movd %eax, %mm0 ;\
- movzbl 2(%esi, %ecx, 4), %eax ;\
- por %mm0, %mm1 ;\
- movzbl rmap(%eax), %eax ;\
- psllq $8, %mm1 ;\
- movd %eax, %mm0 ;\
- movzbl 1(%esi, %ecx, 4), %eax ;\
- por %mm0, %mm1 ;\
- movzbl gmap(%eax), %eax ;\
- psllq $8, %mm1 ;\
- movd %eax, %mm0 ;\
- movzbl (%esi, %ecx, 4), %eax ;\
- por %mm0, %mm1 ;\
- movzbl bmap(%eax), %eax ;\
- psllq $8, %mm1 ;\
- movd %eax, %mm0 ;\
- por %mm0, %mm1
-
-
-/*\ Load one value, alpha 0xff, colourmod it, and put it in %mm1 \*/
-#define LOAD1_CMOD_AFF \
- movzbl amap_ff, %eax ;\
- movd %eax, %mm1 ;\
- movzbl 2(%esi, %ecx, 4), %eax ;\
- psllq $8, %mm1 ;\
- movzbl rmap(%eax), %eax ;\
- movd %eax, %mm0 ;\
- movzbl 1(%esi, %ecx, 4), %eax ;\
- por %mm0, %mm1 ;\
- movzbl gmap(%eax), %eax ;\
- psllq $8, %mm1 ;\
- movd %eax, %mm0 ;\
- movzbl (%esi, %ecx, 4), %eax ;\
- por %mm0, %mm1 ;\
- movzbl bmap(%eax), %eax ;\
- psllq $8, %mm1 ;\
- movd %eax, %mm0 ;\
- por %mm0, %mm1
-
-
-/*\ Load two values, alpha 0xff, colourmod them, and put them in %mm1 \*/
-#define LOAD2_CMOD_AFF \
- movzbl amap_ff, %eax ;\
- movd %eax, %mm1 ;\
- movzbl 6(%esi, %ecx, 4), %eax ;\
- psllq $8, %mm1 ;\
- movzbl rmap(%eax), %eax ;\
- movd %eax, %mm0 ;\
- movzbl 5(%esi, %ecx, 4), %eax ;\
- por %mm0, %mm1 ;\
- movzbl gmap(%eax), %eax ;\
- psllq $8, %mm1 ;\
- movd %eax, %mm0 ;\
- movzbl 4(%esi, %ecx, 4), %eax ;\
- por %mm0, %mm1 ;\
- movzbl bmap(%eax), %eax ;\
- psllq $8, %mm1 ;\
- movd %eax, %mm0 ;\
- por %mm0, %mm1 ;\
- movzbl amap_ff, %eax ;\
- psllq $8, %mm1 ;\
- movd %eax, %mm0 ;\
- movzbl 2(%esi, %ecx, 4), %eax ;\
- por %mm0, %mm1 ;\
- movzbl rmap(%eax), %eax ;\
- psllq $8, %mm1 ;\
- movd %eax, %mm0 ;\
- movzbl 1(%esi, %ecx, 4), %eax ;\
- por %mm0, %mm1 ;\
- movzbl gmap(%eax), %eax ;\
- psllq $8, %mm1 ;\
- movd %eax, %mm0 ;\
- movzbl (%esi, %ecx, 4), %eax ;\
- por %mm0, %mm1 ;\
- movzbl bmap(%eax), %eax ;\
- psllq $8, %mm1 ;\
- movd %eax, %mm0 ;\
- por %mm0, %mm1
-
-
-/*\ Load one value, colourmod it, alpha 0, and put it in %mm1 \*/
-#define LOAD1_CMOD_A00 \
- movzbl 2(%esi, %ecx, 4), %eax ;\
- movzbl rmap(%eax), %eax ;\
- movd %eax, %mm1 ;\
- movzbl 1(%esi, %ecx, 4), %eax ;\
- psllq $8, %mm1 ;\
- movzbl gmap(%eax), %eax ;\
- movd %eax, %mm0 ;\
- movzbl (%esi, %ecx, 4), %eax ;\
- por %mm0, %mm1 ;\
- movzbl bmap(%eax), %eax ;\
- psllq $8, %mm1 ;\
- movd %eax, %mm0 ;\
- por %mm0, %mm1
-
-
-/*\ Load two values, colourmod them, alpha 0, and put them in %mm1 \*/
-#define LOAD2_CMOD_A00 \
- movzbl 6(%esi, %ecx, 4), %eax ;\
- movzbl rmap(%eax), %eax ;\
- movd %eax, %mm1 ;\
- movzbl 5(%esi, %ecx, 4), %eax ;\
- psllq $8, %mm1 ;\
- movzbl gmap(%eax), %eax ;\
- movd %eax, %mm0 ;\
- movzbl 4(%esi, %ecx, 4), %eax ;\
- por %mm0, %mm1 ;\
- movzbl bmap(%eax), %eax ;\
- psllq $8, %mm1 ;\
- movd %eax, %mm0 ;\
- movzbl 2(%esi, %ecx, 4), %eax ;\
- por %mm0, %mm1 ;\
- movzbl rmap(%eax), %eax ;\
- psllq $16, %mm1 ;\
- movd %eax, %mm0 ;\
- movzbl 1(%esi, %ecx, 4), %eax ;\
- por %mm0, %mm1 ;\
- movzbl gmap(%eax), %eax ;\
- psllq $8, %mm1 ;\
- movd %eax, %mm0 ;\
- movzbl (%esi, %ecx, 4), %eax ;\
- por %mm0, %mm1 ;\
- movzbl bmap(%eax), %eax ;\
- psllq $8, %mm1 ;\
- movd %eax, %mm0 ;\
- por %mm0, %mm1
-
-
-
-PR_(imlib_mmx_blend_rgba_to_rgb_cmod):
- ENTER
-
- pxor %mm4, %mm4
- movq c1, %mm5
-
- LOOP_START
-1:
- /*\ Load source and destination \*/
- LOAD1_CMOD
- movd (%edi, %ecx, 4), %mm2
-
- /*\ Get alpha from source and unpack/copy to eight bytes
- |*| which are treated as four words.
- |*| Result ranges from [0, 0x7fff), and is mapped to
- |*| point value in [0.0, 1.0) by using the high word
- |*| of the 16->32 multiplications.
- |*| (Because we want the unsigned value we shift one bit,
- |*| and also shift the other factor to compensate.)
- |*| Magic to get the fourth byte: lhh
- \*/
- movq %mm1, %mm3
- punpcklbw %mm3, %mm3
- punpckhwd %mm3, %mm3
- punpckhdq %mm3, %mm3
- psrlw $1, %mm3
-
- /*\ Make the alpha value that gets multiplied to the
- |*| alpha channels 0, so the resulting alpha value is
- |*| the destination alpha value.
- \*/
- psrlq $16, %mm3
-
- /*\ Unpack source and destination, bytes to words \*/
- punpcklbw %mm4, %mm1
- punpcklbw %mm4, %mm2
-
- /*\ d = d + (a * ((s - d) + 0.5)) \*/
- psubw %mm2, %mm1
- psllw $1, %mm1
- paddw %mm5, %mm1 /*\ Roundoff \*/
- pmulhw %mm3, %mm1
- paddw %mm1, %mm2
-
- /*\ Pack into lower 4 bytes and save \*/
- packuswb %mm4, %mm2
- movd %mm2, (%edi, %ecx, 4)
-
- incl %ecx
- js 1b
-
- LOOP_END
- LEAVE
-
-SIZE(imlib_mmx_blend_rgba_to_rgb_cmod)
-
-PR_(imlib_mmx_blend_rgba_to_rgba_cmod):
- ENTER
-
- pxor %mm4, %mm4
- movq m0X000000, %mm5
- movq m00XXXXXX, %mm6
- movq c1, %mm7
-
- LOOP_START
-1:
- /*\ Load source and destination \*/
- LOAD1_CMOD
- movd (%edi, %ecx, 4), %mm2
-
- /*\ Get alpha from source and target, a = src + (255 - dest) \*/
- movq %mm2, %mm3
- pxor %mm6, %mm3
- paddusb %mm1, %mm3
- /*\ Unpack/copy to eight bytes \*/
- punpcklbw %mm3, %mm3
- punpckhwd %mm3, %mm3
- punpckhdq %mm3, %mm3
- psrlw $1, %mm3
-
- /*\ Unpack source and destination, bytes to words \*/
- punpcklbw %mm4, %mm1
- punpcklbw %mm4, %mm2
-
- /*\ Separate alpha channel \*/
- movq %mm1, %mm0
- pand %mm5, %mm0
-
- /*\ d = d + (a * ((s - d) + 0.5)) \*/
- psubw %mm2, %mm1
- psllw $1, %mm1
- paddw %mm7, %mm1 /*\ Roundoff \*/
- pmulhw %mm3, %mm1
-
- /*\ Replace alpha channel with separated out version in mm0 and add \*/
- pand %mm6, %mm1
- por %mm0, %mm1
- paddw %mm1, %mm2
-
- /*\ Pack into lower 4 bytes and save \*/
- packuswb %mm4, %mm2
- movd %mm2, (%edi, %ecx, 4)
-
- incl %ecx
- js 1b
-
- LOOP_END
- LEAVE
-
-SIZE(imlib_mmx_blend_rgba_to_rgba_cmod)
-
-PR_(imlib_mmx_blend_rgb_to_rgb_cmod):
- ENTER
-
- pxor %mm4, %mm4
- movq c1, %mm5
-
- /*\ Load alpha beforehand, as it's always amap(0xff) \*/
- movzbl amap_ff, %eax
- movd %eax, %mm3
- punpcklbw %mm3, %mm3
- punpcklwd %mm3, %mm3
- punpckldq %mm3, %mm3
- psrlw $1, %mm3
- psrlq $16, %mm3
-
- LOOP_START
-1:
- /*\ Load source and destination \*/
- LOAD1_CMOD_A00
- movd (%edi, %ecx, 4), %mm2
-
- /*\ Unpack source and destination, bytes to words \*/
- punpcklbw %mm4, %mm1
- punpcklbw %mm4, %mm2
-
- /*\ d = d + (a * ((s - d) + 0.5)) \*/
- psubw %mm2, %mm1
- psllw $1, %mm1
- paddw %mm5, %mm1 /*\ Roundoff \*/
- pmulhw %mm3, %mm1
- paddw %mm1, %mm2
-
- /*\ Pack into lower 4 bytes and save \*/
- packuswb %mm4, %mm2
- movd %mm2, (%edi, %ecx, 4)
-
- incl %ecx
- js 1b
-
- LOOP_END
- LEAVE
-
-SIZE(imlib_mmx_blend_rgb_to_rgb_cmod)
-
-PR_(imlib_mmx_blend_rgb_to_rgba_cmod):
- ENTER
-
- pxor %mm4, %mm4
- movq m0X000000, %mm5
- movq m00XXXXXX, %mm6
- movq c1, %mm7
-
- LOOP_START
-1:
- /*\ Load source and destination \*/
- LOAD1_CMOD_AFF
- movd (%edi, %ecx, 4), %mm2
-
- /*\ Get alpha from source and target, a = src + (255 - dest) \*/
- movq %mm2, %mm3
- pxor %mm6, %mm3
- paddusb %mm1, %mm3
- /*\ Unpack/copy to eight bytes \*/
- punpcklbw %mm3, %mm3
- punpckhwd %mm3, %mm3
- punpckhdq %mm3, %mm3
- psrlw $1, %mm3
-
- /*\ Unpack source and destination, bytes to words \*/
- punpcklbw %mm4, %mm1
- punpcklbw %mm4, %mm2
-
- /*\ Separate alpha channel \*/
- movq %mm1, %mm0
- pand %mm5, %mm0
-
- /*\ d = d + (a * ((s - d) + 0.5)) \*/
- psubw %mm2, %mm1
- psllw $1, %mm1
- paddw %mm7, %mm1 /*\ Roundoff \*/
- pmulhw %mm3, %mm1
-
- /*\ Replace alpha channel with separated out version in mm0 and add \*/
- pand %mm6, %mm1
- por %mm0, %mm1
- paddw %mm1, %mm2
-
- /*\ Pack into lower 4 bytes and save \*/
- packuswb %mm4, %mm2
- movd %mm2, (%edi, %ecx, 4)
-
- incl %ecx
- js 1b
-
- LOOP_END
- LEAVE
-
-SIZE(imlib_mmx_blend_rgb_to_rgba_cmod)
-
-PR_(imlib_mmx_copy_rgba_to_rgb_cmod):
- ENTER
-
- LOOP_START
-1:
- movzbl (%esi, %ecx, 4), %eax
- movzbl bmap(%eax), %eax
- movb %al, (%edi, %ecx, 4)
- movzbl 1(%esi, %ecx, 4), %eax
- movzbl gmap(%eax), %eax
- movb %al, 1(%edi, %ecx, 4)
- movzbl 2(%esi, %ecx, 4), %eax
- movzbl rmap(%eax), %eax
- movb %al, 2(%edi, %ecx, 4)
-
- incl %ecx
- js 1b
-
- LOOP_END
- LEAVE
-
-SIZE(imlib_mmx_copy_rgba_to_rgb_cmod)
-
-PR_(imlib_mmx_copy_rgba_to_rgba_cmod):
- ENTER
-
- LOOP_START
-1:
- movzbl (%esi, %ecx, 4), %eax
- movzbl bmap(%eax), %eax
- movb %al, (%edi, %ecx, 4)
- movzbl 1(%esi, %ecx, 4), %eax
- movzbl gmap(%eax), %eax
- movb %al, 1(%edi, %ecx, 4)
- movzbl 2(%esi, %ecx, 4), %eax
- movzbl rmap(%eax), %eax
- movb %al, 2(%edi, %ecx, 4)
- movzbl 3(%esi, %ecx, 4), %eax
- movzbl amap(%eax), %eax
- movb %al, 3(%edi, %ecx, 4)
-
- incl %ecx
- js 1b
-
- LOOP_END
- LEAVE
-
-SIZE(imlib_mmx_copy_rgba_to_rgba_cmod)
-
-PR_(imlib_mmx_copy_rgb_to_rgba_cmod):
- ENTER
-
- LOOP_START
-1:
- movzbl (%esi, %ecx, 4), %eax
- movzbl bmap(%eax), %eax
- movb %al, (%edi, %ecx, 4)
- movzbl 1(%esi, %ecx, 4), %eax
- movzbl gmap(%eax), %eax
- movb %al, 1(%edi, %ecx, 4)
- movzbl 2(%esi, %ecx, 4), %eax
- movzbl rmap(%eax), %eax
- movb %al, 2(%edi, %ecx, 4)
- movb $0xff, 3(%edi, %ecx, 4)
-
- incl %ecx
- js 1b
-
- LOOP_END
- LEAVE
-
-SIZE(imlib_mmx_copy_rgb_to_rgba_cmod)
-
-PR_(imlib_mmx_add_blend_rgba_to_rgb_cmod):
- ENTER
-
- pxor %mm4, %mm4
-
- LOOP_START
-1:
- /*\ Load source and destination \*/
- LOAD1_CMOD
- movd (%edi, %ecx, 4), %mm2
-
- /*\ Get alpha from source and unpack/copy to eight bytes \*/
- movq %mm1, %mm3
- punpcklbw %mm3, %mm3
- punpckhwd %mm3, %mm3
- punpckhdq %mm3, %mm3
- psrlw $1, %mm3
-
- psrlq $16, %mm3
-
- /*\ Unpack source and destination, bytes to words \*/
- punpcklbw %mm4, %mm1
- punpcklbw %mm4, %mm2
-
- /*\ d = d + (a * s) \*/
- psllw $1, %mm1
- pmulhw %mm3, %mm1
- paddw %mm1, %mm2
-
- /*\ Pack into lower 4 bytes and save \*/
- packuswb %mm4, %mm2
- movd %mm2, (%edi, %ecx, 4)
-
- incl %ecx
- js 1b
-
- LOOP_END
- LEAVE
-
-SIZE(imlib_mmx_add_blend_rgba_to_rgb_cmod)
-
-PR_(imlib_mmx_add_blend_rgba_to_rgba_cmod):
- ENTER
-
- pxor %mm4, %mm4
- movq mVX000000, %mm5
- movq m00XXXXXX, %mm6
-
- LOOP_START
-1:
- /*\ Load source and destination \*/
- LOAD1_CMOD
- movd (%edi, %ecx, 4), %mm2
-
- /*\ Get alpha from source and target and unpack/copy to eight bytes \*/
- movq %mm2, %mm3
- pxor %mm6, %mm3
- paddusb %mm1, %mm3
- punpcklbw %mm3, %mm3
- punpckhwd %mm3, %mm3
- punpckhdq %mm3, %mm3
- psrlw $1, %mm3
-
- /*\ Make the alpha value that gets multiplied to the
- |*| alpha channels 0x7fff, so the resulting alpha value is
- |*| the sum of the source and destination alpha values.
- \*/
- por %mm5, %mm3
-
- /*\ Unpack source and destination, bytes to words \*/
- punpcklbw %mm4, %mm1
- punpcklbw %mm4, %mm2
-
- /*\ d = d + (a * s) \*/
- psllw $1, %mm1
- pmulhw %mm3, %mm1
- paddw %mm1, %mm2
-
- /*\ Pack into lower 4 bytes and save \*/
- packuswb %mm4, %mm2
- movd %mm2, (%edi, %ecx, 4)
-
- incl %ecx
- js 1b
-
- LOOP_END
- LEAVE
-
-SIZE(imlib_mmx_add_blend_rgba_to_rgba_cmod)
-
-PR_(imlib_mmx_add_blend_rgb_to_rgb_cmod):
- ENTER
-
- pxor %mm4, %mm4
-
- /*\ Load alpha beforehand, as it's always amap(0xff) \*/
- movzbl amap_ff, %eax
- movd %eax, %mm3
- punpcklbw %mm3, %mm3
- punpcklwd %mm3, %mm3
- punpckldq %mm3, %mm3
- psrlw $1, %mm3
- psrlq $16, %mm3
-
- LOOP_START
-1:
- /*\ Load source and destination \*/
- LOAD1_CMOD_A00
- movd (%edi, %ecx, 4), %mm2
-
- /*\ Unpack source and destination, bytes to words \*/
- punpcklbw %mm4, %mm1
- punpcklbw %mm4, %mm2
-
- /*\ d = d + (a * s) \*/
- psllw $1, %mm1
- pmulhw %mm3, %mm1
- paddw %mm1, %mm2
-
- /*\ Pack into lower 4 bytes and save \*/
- packuswb %mm4, %mm2
- movd %mm2, (%edi, %ecx, 4)
-
- incl %ecx
- js 1b
-
- LOOP_END
- LEAVE
-
-SIZE(imlib_mmx_add_blend_rgb_to_rgb_cmod)
-
-PR_(imlib_mmx_add_blend_rgb_to_rgba_cmod):
- ENTER
-
- pxor %mm4, %mm4
- movq mVX000000, %mm5
- movq m00XXXXXX, %mm6
-
- LOOP_START
-1:
- /*\ Load source and destination \*/
- LOAD1_CMOD_AFF
- movd (%edi, %ecx, 4), %mm2
-
- /*\ Get alpha from source and target and unpack/copy to eight bytes \*/
- movq %mm2, %mm3
- pxor %mm6, %mm3
- paddusb %mm1, %mm3
- punpcklbw %mm3, %mm3
- punpckhwd %mm3, %mm3
- punpckhdq %mm3, %mm3
- psrlw $1, %mm3
-
- /*\ Make the alpha value that gets multiplied to the
- |*| alpha channels 0x7fff, so the resulting alpha value is
- |*| the sum of the source and destination alpha values.
- \*/
- por %mm5, %mm3
-
- /*\ Unpack source and destination, bytes to words \*/
- punpcklbw %mm4, %mm1
- punpcklbw %mm4, %mm2
-
- /*\ d = d + (a * s) \*/
- psllw $1, %mm1
- pmulhw %mm3, %mm1
- paddw %mm1, %mm2
-
- /*\ Pack into lower 4 bytes and save \*/
- packuswb %mm4, %mm2
- movd %mm2, (%edi, %ecx, 4)
-
- incl %ecx
- js 1b
-
- LOOP_END
- LEAVE
-
-SIZE(imlib_mmx_add_blend_rgb_to_rgba_cmod)
-
-PR_(imlib_mmx_add_copy_rgba_to_rgb_cmod):
- ENTER
-
- movq m0XXX0XXX, %mm5
-
- subl $4, %esi
- subl $4, %edi
-
- LOOP_START
- incl %ecx
- jz 2f
-1:
- /*\ Load source and destination \*/
- LOAD2_CMOD
- movq (%edi, %ecx, 4), %mm2
-
- /*\ Clear alpha channel of source \*/
- pand %mm5, %mm1
-
- /*\ d = d + s, unsigned saturation, and save \*/
- paddusb %mm1, %mm2
- movq %mm2, (%edi, %ecx, 4)
-
- addl $2, %ecx
- js 1b
- jnz 3f
-2:
- LOAD1_CMOD
- movd (%edi), %mm2
- pand %mm5, %mm1
- paddusb %mm1, %mm2
- movd %mm2, (%edi)
-3:
- LOOP_END
- LEAVE
-
-SIZE(imlib_mmx_add_copy_rgba_to_rgb_cmod)
-
-PR_(imlib_mmx_add_copy_rgba_to_rgba_cmod):
- ENTER
-
- subl $4, %esi
- subl $4, %edi
-
- LOOP_START
- incl %ecx
- jz 2f
-1:
- /*\ Load source and destination \*/
- LOAD2_CMOD
- movq (%edi, %ecx, 4), %mm2
-
- /*\ d = d + s, unsigned saturation, and save \*/
- paddusb %mm1, %mm2
- movq %mm2, (%edi, %ecx, 4)
-
- addl $2, %ecx
- js 1b
- jnz 3f
-2:
- LOAD1_CMOD
- movd (%edi), %mm2
- paddusb %mm1, %mm2
- movd %mm2, (%edi)
-3:
- LOOP_END
- LEAVE
-
-SIZE(imlib_mmx_add_copy_rgba_to_rgba_cmod)
-
-PR_(imlib_mmx_add_copy_rgb_to_rgba_cmod):
- ENTER
-
- subl $4, %esi
- subl $4, %edi
-
- LOOP_START
- incl %ecx
- jz 2f
-1:
- /*\ Load source and destination \*/
- LOAD2_CMOD_AFF
- movq (%edi, %ecx, 4), %mm2
-
- /*\ d = d + s, unsigned saturation, and save \*/
- paddusb %mm1, %mm2
- movq %mm2, (%edi, %ecx, 4)
-
- addl $2, %ecx
- js 1b
- jnz 3f
-2:
- LOAD1_CMOD_AFF
- movd (%edi), %mm2
- paddusb %mm1, %mm2
- movd %mm2, (%edi)
-3:
- LOOP_END
- LEAVE
-
-SIZE(imlib_mmx_add_copy_rgb_to_rgba_cmod)
-
-PR_(imlib_mmx_subtract_blend_rgba_to_rgb_cmod):
- ENTER
-
- pxor %mm4, %mm4
-
- LOOP_START
-1:
- /*\ Load source and destination \*/
- LOAD1_CMOD
- movd (%edi, %ecx, 4), %mm2
-
- /*\ Get alpha from source and unpack/copy to eight bytes \*/
- movq %mm1, %mm3
- punpcklbw %mm3, %mm3
- punpckhwd %mm3, %mm3
- punpckhdq %mm3, %mm3
- psrlw $1, %mm3
-
- psrlq $16, %mm3
-
- /*\ Unpack source and destination, bytes to words \*/
- punpcklbw %mm4, %mm1
- punpcklbw %mm4, %mm2
-
- /*\ d = d - (a * s) \*/
- psllw $1, %mm1
- pmulhw %mm3, %mm1
- psubw %mm1, %mm2
-
- /*\ Pack into lower 4 bytes and save \*/
- packuswb %mm4, %mm2
- movd %mm2, (%edi, %ecx, 4)
-
- incl %ecx
- js 1b
-
- LOOP_END
- LEAVE
-
-SIZE(imlib_mmx_subtract_blend_rgba_to_rgb_cmod)
-
-PR_(imlib_mmx_subtract_blend_rgba_to_rgba_cmod):
- ENTER
-
- pxor %mm4, %mm4
- movq mV0000000, %mm5
- movq m00XXXXXX, %mm6
-
- LOOP_START
-1:
- /*\ Load source and destination \*/
- LOAD1_CMOD
- movd (%edi, %ecx, 4), %mm2
-
- /*\ Get alpha from source and target and unpack/copy to eight bytes \*/
- movq %mm2, %mm3
- pxor %mm6, %mm3
- paddusb %mm1, %mm3
- punpcklbw %mm3, %mm3
- punpckhwd %mm3, %mm3
- punpckhdq %mm3, %mm3
- psrlw $1, %mm3
-
- /*\ Make alpha value that gets multiplied with alpha channel
- |*| 0x8000, (-1.0), so that the alpha result is s + d
- \*/
- psrlq $16, %mm3
- por %mm5, %mm3
-
- /*\ Unpack source and destination, bytes to words \*/
- punpcklbw %mm4, %mm1
- punpcklbw %mm4, %mm2
-
- /*\ d = d - (a * s) \*/
- psllw $1, %mm1
- pmulhw %mm3, %mm1
- psubw %mm1, %mm2
-
- /*\ Pack into lower 4 bytes and save \*/
- packuswb %mm4, %mm2
- movd %mm2, (%edi, %ecx, 4)
-
- incl %ecx
- js 1b
-
- LOOP_END
- LEAVE
-
-SIZE(imlib_mmx_subtract_blend_rgba_to_rgba_cmod)
-
-PR_(imlib_mmx_subtract_blend_rgb_to_rgb_cmod):
- ENTER
-
- pxor %mm4, %mm4
-
- /*\ Load alpha beforehand, as it's always amap(0xff) \*/
- movzbl amap_ff, %eax
- movd %eax, %mm3
- punpcklbw %mm3, %mm3
- punpcklwd %mm3, %mm3
- punpckldq %mm3, %mm3
- psrlw $1, %mm3
- psrlq $16, %mm3
-
- LOOP_START
-1:
- /*\ Load source and destination \*/
- LOAD1_CMOD_A00
- movd (%edi, %ecx, 4), %mm2
-
- /*\ Unpack source and destination, bytes to words \*/
- punpcklbw %mm4, %mm1
- punpcklbw %mm4, %mm2
-
- /*\ d = d - (a * s) \*/
- psllw $1, %mm1
- pmulhw %mm3, %mm1
- psubw %mm1, %mm2
-
- /*\ Pack into lower 4 bytes and save \*/
- packuswb %mm4, %mm2
- movd %mm2, (%edi, %ecx, 4)
-
- incl %ecx
- js 1b
-
- LOOP_END
- LEAVE
-
-SIZE(imlib_mmx_subtract_blend_rgb_to_rgb_cmod)
-
-PR_(imlib_mmx_subtract_blend_rgb_to_rgba_cmod):
- ENTER
-
- pxor %mm4, %mm4
- movq mV0000000, %mm5
- movq m00XXXXXX, %mm6
-
- LOOP_START
-1:
- /*\ Load source and destination \*/
- LOAD1_CMOD_AFF
- movd (%edi, %ecx, 4), %mm2
-
- /*\ Get alpha from source and target and unpack/copy to eight bytes \*/
- movq %mm2, %mm3
- pxor %mm6, %mm3
- paddusb %mm1, %mm3
- punpcklbw %mm3, %mm3
- punpckhwd %mm3, %mm3
- punpckhdq %mm3, %mm3
- psrlw $1, %mm3
-
- /*\ Make alpha value that gets multiplied with alpha channel
- |*| 0x8000, (-1.0), so that the alpha result is s + d
- \*/
- psrlq $16, %mm3
- por %mm5, %mm3
-
- /*\ Unpack source and destination, bytes to words \*/
- punpcklbw %mm4, %mm1
- punpcklbw %mm4, %mm2
-
- /*\ d = d - (a * s) \*/
- psllw $1, %mm1
- pmulhw %mm3, %mm1
- psubw %mm1, %mm2
-
- /*\ Pack into lower 4 bytes and save \*/
- packuswb %mm4, %mm2
- movd %mm2, (%edi, %ecx, 4)
-
- incl %ecx
- js 1b
-
- LOOP_END
- LEAVE
-
-SIZE(imlib_mmx_subtract_blend_rgb_to_rgba_cmod)
-
-PR_(imlib_mmx_subtract_copy_rgba_to_rgb_cmod):
- ENTER
-
- movq m0XXX0XXX, %mm5
-
- subl $4, %esi
- subl $4, %edi
-
- LOOP_START
- incl %ecx
- jz 2f
-1:
- /*\ Load source and destination \*/
- LOAD2_CMOD
- movq (%edi, %ecx, 4), %mm2
-
- /*\ Clear alpha channel of source \*/
- pand %mm5, %mm1
-
- /*\ d = d - s, unsigned saturation, and save \*/
- psubusb %mm1, %mm2
- movq %mm2, (%edi, %ecx, 4)
-
- addl $2, %ecx
- js 1b
- jnz 3f
-2:
- LOAD1_CMOD
- movd (%edi), %mm2
- pand %mm5, %mm1
- psubusb %mm1, %mm2
- movd %mm2, (%edi)
-3:
- LOOP_END
- LEAVE
-
-SIZE(imlib_mmx_subtract_copy_rgba_to_rgb_cmod)
-
-PR_(imlib_mmx_subtract_copy_rgba_to_rgba_cmod):
- ENTER
-
- movq mX000X000, %mm5
-
- subl $4, %esi
- subl $4, %edi
-
- LOOP_START
- incl %ecx
- jz 2f
-1:
- /*\ Load source and destination \*/
- LOAD2_CMOD
- movq (%edi, %ecx, 4), %mm2
-
- /*\ Negate destination alphas \*/
- pxor %mm5, %mm2
-
- /*\ d = d - s, unsigned saturation, and save \*/
- psubusb %mm1, %mm2
-
- /*\ Negate result alphas \*/
- pxor %mm5, %mm2
- movq %mm2, (%edi, %ecx, 4)
-
- addl $2, %ecx
- js 1b
- jnz 3f
-2:
- LOAD1_CMOD
- movd (%edi), %mm2
- pxor %mm5, %mm2
- psubusb %mm1, %mm2
- pxor %mm5, %mm2
- movd %mm2, (%edi)
-3:
- LOOP_END
- LEAVE
-
-SIZE(imlib_mmx_subtract_copy_rgba_to_rgba_cmod)
-
-PR_(imlib_mmx_subtract_copy_rgb_to_rgba_cmod):
- ENTER
-
- movq mX000X000, %mm5
-
- subl $4, %esi
- subl $4, %edi
-
- LOOP_START
- incl %ecx
- jz 2f
-1:
- /*\ Load source and destination \*/
- LOAD2_CMOD_AFF
- movq (%edi, %ecx, 4), %mm2
- pxor %mm5, %mm2
-
- /*\ d = d - s, unsigned saturation, and save \*/
- psubusb %mm1, %mm2
- pxor %mm5, %mm2
- movq %mm2, (%edi, %ecx, 4)
-
- addl $2, %ecx
- js 1b
- jnz 3f
-2:
- LOAD1_CMOD_AFF
- movd (%edi), %mm2
- pxor %mm5, %mm2
- psubusb %mm1, %mm2
- pxor %mm5, %mm2
- movd %mm2, (%edi)
-3:
- LOOP_END
- LEAVE
-
-SIZE(imlib_mmx_subtract_copy_rgb_to_rgba_cmod)
-
-PR_(imlib_mmx_reshade_blend_rgba_to_rgb_cmod):
- ENTER
-
- pxor %mm4, %mm4
- movq m000V0V0V, %mm6
-
- LOOP_START
-1:
- /*\ Load source and destination \*/
- LOAD1_CMOD
- movd (%edi, %ecx, 4), %mm2
-
- /*\ Get alpha from source and unpack/copy to eight bytes \*/
- movq %mm1, %mm3
- punpcklbw %mm3, %mm3
- punpckhwd %mm3, %mm3
- punpckhdq %mm3, %mm3
- psrlw $1, %mm3
-
- psrlq $16, %mm3
-
- /*\ Unpack source and destination, bytes to words \*/
- punpcklbw %mm4, %mm1
- punpcklbw %mm4, %mm2
-
- /*\ d = d + (2 * a * (s - 127)) \*/
- psubw %mm6, %mm1
- psllw $2, %mm1
- pmulhw %mm3, %mm1
- paddw %mm1, %mm2
-
- /*\ Pack into lower 4 bytes and save \*/
- packuswb %mm4, %mm2
- movd %mm2, (%edi, %ecx, 4)
-
- incl %ecx
- js 1b
-
- LOOP_END
- LEAVE
-
-SIZE(imlib_mmx_reshade_blend_rgba_to_rgb_cmod)
-
-PR_(imlib_mmx_reshade_blend_rgba_to_rgba_cmod):
- ENTER
-
- pxor %mm4, %mm4
- movq mI0000000, %mm5
- movq m000V0V0V, %mm6
- movq m00XXXXXX, %mm7
-
- LOOP_START
-1:
- /*\ Load source and destination \*/
- LOAD1_CMOD
- movd (%edi, %ecx, 4), %mm2
-
- /*\ Get alpha from source and target and unpack/copy to eight bytes \*/
- movq %mm2, %mm3
- pxor %mm7, %mm3
- paddusb %mm1, %mm3
- punpcklbw %mm3, %mm3
- punpckhwd %mm3, %mm3
- punpckhdq %mm3, %mm3
- psrlw $1, %mm3
-
- /*\ Make the alpha value that gets multiplied to the
- |*| alpha channels 0x4000 (0.5), so the resulting alpha value is
- |*| the sum of the source and destination alpha values.
- \*/
- psrlq $16, %mm3
- por %mm5, %mm3
-
- /*\ Unpack source and destination, bytes to words \*/
- punpcklbw %mm4, %mm1
- punpcklbw %mm4, %mm2
-
- /*\ d = d + (2 * a * (s - 127)), (alpha channel: d = d + (2 * 0.5 * (s - 0)) ) \*/
- psubw %mm6, %mm1
- psllw $2, %mm1
- pmulhw %mm3, %mm1
- paddw %mm1, %mm2
-
- /*\ Pack into lower 4 bytes and save \*/
- packuswb %mm4, %mm2
- movd %mm2, (%edi, %ecx, 4)
-
- incl %ecx
- js 1b
-
- LOOP_END
- LEAVE
-
-SIZE(imlib_mmx_reshade_blend_rgba_to_rgba_cmod)
-
-PR_(imlib_mmx_reshade_blend_rgb_to_rgb_cmod):
- ENTER
-
- pxor %mm4, %mm4
- movq m000V0V0V, %mm6
-
- /*\ Load alpha beforehand, as it's always amap(0xff) \*/
- movzbl amap_ff, %eax
- movd %eax, %mm3
- punpcklbw %mm3, %mm3
- punpcklwd %mm3, %mm3
- punpckldq %mm3, %mm3
- psrlw $1, %mm3
- psrlq $16, %mm3
-
- LOOP_START
-1:
- /*\ Load source and destination \*/
- LOAD1_CMOD_A00
- movd (%edi, %ecx, 4), %mm2
-
- /*\ Unpack source and destination, bytes to words \*/
- punpcklbw %mm4, %mm1
- punpcklbw %mm4, %mm2
-
- /*\ d = d + (2 * a * (s - 127)) \*/
- psubw %mm6, %mm1
- psllw $2, %mm1
- pmulhw %mm3, %mm1
- paddw %mm1, %mm2
-
- /*\ Pack into lower 4 bytes and save \*/
- packuswb %mm4, %mm2
- movd %mm2, (%edi, %ecx, 4)
-
- incl %ecx
- js 1b
-
- LOOP_END
- LEAVE
-
-SIZE(imlib_mmx_reshade_blend_rgb_to_rgb_cmod)
-
-PR_(imlib_mmx_reshade_blend_rgb_to_rgba_cmod):
- ENTER
-
- pxor %mm4, %mm4
- movq mI0000000, %mm5
- movq m000V0V0V, %mm6
- movq m00XXXXXX, %mm7
-
- LOOP_START
-1:
- /*\ Load source and destination \*/
- LOAD1_CMOD_AFF
- movd (%edi, %ecx, 4), %mm2
-
- /*\ Get alpha from source and target and unpack/copy to eight bytes \*/
- movq %mm2, %mm3
- pxor %mm7, %mm3
- paddusb %mm1, %mm3
- punpcklbw %mm3, %mm3
- punpckhwd %mm3, %mm3
- punpckhdq %mm3, %mm3
- psrlw $1, %mm3
-
- /*\ Make the alpha value that gets multiplied to the
- |*| alpha channels 0x4000 (0.5), so the resulting alpha value is
- |*| the sum of the source and destination alpha values.
- \*/
- psrlq $16, %mm3
- por %mm5, %mm3
-
- /*\ Unpack source and destination, bytes to words \*/
- punpcklbw %mm4, %mm1
- punpcklbw %mm4, %mm2
-
- /*\ d = d + (2 * a * (s - 127)), (alpha channel: d = d + (2 * 0.5 * (s - 0)) ) \*/
- psubw %mm6, %mm1
- psllw $2, %mm1
- pmulhw %mm3, %mm1
- paddw %mm1, %mm2
-
- /*\ Pack into lower 4 bytes and save \*/
- packuswb %mm4, %mm2
- movd %mm2, (%edi, %ecx, 4)
-
- incl %ecx
- js 1b
-
- LOOP_END
- LEAVE
-
-SIZE(imlib_mmx_reshade_blend_rgb_to_rgba_cmod)
-
-PR_(imlib_mmx_reshade_copy_rgba_to_rgb_cmod):
- ENTER
-
- pxor %mm4, %mm4
- movq m0XXX0XXX, %mm5
- movq m0VVV0VVV, %mm6
-
- subl $4, %esi
- subl $4, %edi
-
- LOOP_START
- incl %ecx
- jz 2f
-1:
- /*\ Load source and destination \*/
- LOAD2_CMOD
- movq (%edi, %ecx, 4), %mm2
-
- /*\ To take advantage of saturation and be able to do 8 bytes
- |*| at a time, we divide reshading into two separate steps:
- |*| adding values above 128, and subtracting values below 128
- |*| These values go into %mm1 and %mm3 respectively
- |*| - %mm1 becomes (2 * (s - 127))
- |*| - %mm3 becomes (2 * (255 - (127 + s))) = (2 * (128 - s))
- \*/
- movq %mm1, %mm3
- psubusb %mm6, %mm1
- paddusb %mm1, %mm1
- paddusb %mm6, %mm3
- pxor %mm5, %mm3
- paddusb %mm3, %mm3
-
- /*\ Clear alpha channel of s1 and s2 \*/
- pand %mm5, %mm1
- pand %mm5, %mm3
-
- /*\ d = d + s1 - s2, unsigned saturation, and save \*/
- paddusb %mm1, %mm2
- psubusb %mm3, %mm2
- movq %mm2, (%edi, %ecx, 4)
-
- addl $2, %ecx
- js 1b
- jnz 3f
-2:
- LOAD1_CMOD
- movd (%edi), %mm2
- movq %mm1, %mm3
- psubusb %mm6, %mm1
- paddusb %mm1, %mm1
- paddusb %mm6, %mm3
- pxor %mm5, %mm3
- paddusb %mm3, %mm3
- pand %mm5, %mm1
- pand %mm5, %mm3
- paddusb %mm1, %mm2
- psubusb %mm3, %mm2
- movd %mm2, (%edi)
-3:
- LOOP_END
- LEAVE
-
-SIZE(imlib_mmx_reshade_copy_rgba_to_rgb_cmod)
-
-PR_(imlib_mmx_reshade_copy_rgba_to_rgba_cmod):
- ENTER
-
- pxor %mm4, %mm4
- movq m0XXX0XXX, %mm5
- movq m0VVV0VVV, %mm6
-
- subl $4, %esi
- subl $4, %edi
-
- LOOP_START
- incl %ecx
- jz 2f
-1:
- /*\ Load source and destination \*/
- LOAD2_CMOD
- movq (%edi, %ecx, 4), %mm2
-
- /*\ This time, the alpha channels have to be added.
- |*| For that, the alpha channel of %mm1 should remain
- |*| the same. This is done by subtracting 0 from the
- |*| alpha channel, and then doing the *2 via a separate
- |*| register, clearing its alpha channel first.
- \*/
- movq %mm1, %mm3
- psubusb %mm6, %mm1
- movq %mm1, %mm0
- pand %mm5, %mm0
- paddusb %mm0, %mm1
- paddusb %mm6, %mm3
- pxor %mm5, %mm3
- paddusb %mm3, %mm3
-
- /*\ Clear alpha channel of s2 \*/
- pand %mm5, %mm3
-
- /*\ d = d + s1 - s2, unsigned saturation, and save \*/
- paddusb %mm1, %mm2
- psubusb %mm3, %mm2
- movq %mm2, (%edi, %ecx, 4)
-
- addl $2, %ecx
- js 1b
- jnz 3f
-2:
- LOAD1_CMOD
- movd (%edi), %mm2
- movq %mm1, %mm3
- psubusb %mm6, %mm1
- movq %mm1, %mm0
- pand %mm5, %mm0
- paddusb %mm0, %mm1
- paddusb %mm6, %mm3
- pxor %mm5, %mm3
- paddusb %mm3, %mm3
- pand %mm5, %mm3
- paddusb %mm1, %mm2
- psubusb %mm3, %mm2
- movd %mm2, (%edi)
-3:
- LOOP_END
- LEAVE
-
-SIZE(imlib_mmx_reshade_copy_rgba_to_rgba_cmod)
-
-PR_(imlib_mmx_reshade_copy_rgb_to_rgba_cmod):
- ENTER
-
- pxor %mm4, %mm4
- movq m0XXX0XXX, %mm5
- movq m0VVV0VVV, %mm6
-
- subl $4, %esi
- subl $4, %edi
-
- LOOP_START
- incl %ecx
- jz 2f
-1:
- /*\ Load source and destination \*/
- LOAD2_CMOD_AFF
- movq (%edi, %ecx, 4), %mm2
-
- movq %mm1, %mm3
- psubusb %mm6, %mm1
- movq %mm1, %mm0
- pand %mm5, %mm0
- paddusb %mm0, %mm1
- paddusb %mm6, %mm3
- pxor %mm5, %mm3
- paddusb %mm3, %mm3
-
- /*\ Clear alpha channel of s2 \*/
- pand %mm5, %mm3
-
- /*\ d = d + s1 - s2, unsigned saturation, and save \*/
- paddusb %mm1, %mm2
- psubusb %mm3, %mm2
- movq %mm2, (%edi, %ecx, 4)
-
- addl $2, %ecx
- js 1b
- jnz 3f
-2:
- LOAD1_CMOD_AFF
- movd (%edi), %mm2
- movq %mm1, %mm3
- psubusb %mm6, %mm1
- movq %mm1, %mm0
- pand %mm5, %mm0
- paddusb %mm0, %mm1
- paddusb %mm6, %mm3
- pxor %mm5, %mm3
- paddusb %mm3, %mm3
- pand %mm5, %mm3
- paddusb %mm1, %mm2
- psubusb %mm3, %mm2
- movd %mm2, (%edi)
-3:
- LOOP_END
- LEAVE
-
-SIZE(imlib_mmx_reshade_copy_rgb_to_rgba_cmod)
-
-#endif
diff --git a/src/asm_rgba.S b/src/asm_rgba.S
deleted file mode 100644
index ff122c8..0000000
--- a/src/asm_rgba.S
+++ /dev/null
@@ -1,301 +0,0 @@
-#include <config.h>
-
-#ifdef __EMX__
-/* Due to strange behaviour of as.exe we use this macros */
-/* For all OS/2 coders - please use PGCC to compile this code */
-#define PR_(foo) ___##foo
-#define PT_(foo,func) ___##foo,##func
-#define SIZE(sym) \
- .___end_##sym:; \
- .size ___##sym,.___end_##sym-___##sym; \
- .align 8;
-#else
-#define PR_(foo) __##foo
-#define PT_(foo,func) __##foo,##func
-#define SIZE(sym) \
- .__end_##sym:; \
- .size __##sym,.__end_##sym-__##sym; \
- .align 8;
-#endif
-
-#ifdef DO_MMX_ASM
-
-/*\
-|*| MMX assembly rgba rendering routines for Imlib2
-|*| Written by Willem Monsuwe <willem@stack.nl>
-|*|
-|*| Special (hairy) constructs are only commented on first use.
-\*/
-
-/*\ All functions have the same calling convention:
-|*| __imlib_mmx_rgbXXX(void *src, int sjmp, void *dst, int dw,
-|*| int w, int h, int dx, int dy)
-\*/
-
-#define src 8(%ebp)
-#define sjmp 12(%ebp)
-#define dst 16(%ebp)
-#define dw 20(%ebp)
-#define w 24(%ebp)
-#define h 28(%ebp)
-#define dx 32(%ebp)
-#define dy 36(%ebp)
-
-.text
- .align 8
-.globl PR_(imlib_mmx_rgb565_fast)
- .type PT_(imlib_mmx_rgb565_fast,@function)
-.globl PR_(imlib_mmx_bgr565_fast)
- .type PT_(imlib_mmx_bgr565_fast,@function)
-.globl PR_(imlib_mmx_rgb555_fast)
- .type PT_(imlib_mmx_rgb555_fast,@function)
-.globl PR_(imlib_mmx_bgr555_fast)
- .type PT_(imlib_mmx_bgr555_fast,@function)
-
-.globl PR_(imlib_get_cpuid)
- .type PT_(imlib_get_cpuid,@function)
-
-/*\ Some useful masks \*/
-m_rb: .long 0x00f800f8, 0x00f800f8
-m_r: .long 0xf800f800, 0xf800f800
-m_g6: .long 0x0000fc00, 0x0000fc00
-m_g5: .long 0x0000f800, 0x0000f800
-/*\ Multiply constants to fake two shifts at once \*/
-mul_rgb565: .long 0x20000004, 0x20000004
-mul_bgr565: .long 0x00042000, 0x00042000
-mul_rgb555: .long 0x20000008, 0x20000008
-mul_bgr555: .long 0x00082000, 0x00082000
-
-/*\ Common code \*/
-/*\ Save registers, load common parameters \*/
-#define ENTER \
- pushl %ebp; \
- movl %esp, %ebp; \
- pushl %ebx; \
- pushl %ecx; \
- pushl %edx; \
- pushl %edi; \
- pushl %esi; \
- movl src, %esi; \
- movl dst, %edi; \
- movl w, %ebx; \
- movl h, %edx; \
- addl %ebx, sjmp
-
-#define LOOP_START \
- testl %edx, %edx; \
- jz 4f; \
- testl %ebx, %ebx; \
- jz 4f; \
-0: \
- movl %ebx, %ecx
-
-#define LOOP_END \
-3: \
- movl sjmp, %ecx; \
- leal (%esi, %ecx, 4), %esi; \
- addl dw, %edi; \
- decl %edx; \
- jnz 0b; \
-4:
-
-/*\ Unset MMX mode, reset registers, return \*/
-#define LEAVE \
- emms; \
- popl %esi; \
- popl %edi; \
- popl %edx; \
- popl %ecx; \
- popl %ebx; \
- movl %ebp, %esp; \
- popl %ebp; \
- ret
-
-
-
-PR_(imlib_mmx_bgr565_fast):
- movq mul_bgr565, %mm7 /*\ This constant is the only difference \*/
- jmp .rgb565_fast_entry
-
-SIZE(imlib_mmx_bgr565_fast)
-
-PR_(imlib_mmx_rgb565_fast):
- movq mul_rgb565, %mm7
-.rgb565_fast_entry:
- ENTER
-
- movq m_rb, %mm5
- movq m_g6, %mm6
-
- LOOP_START
-
- test $1, %ecx
- jz 1f
- decl %ecx
- movd (%esi, %ecx, 4), %mm0
- movq %mm0, %mm1
- pand %mm5, %mm0
- pand %mm6, %mm1
- pmaddwd %mm7, %mm0
- por %mm1, %mm0
- psrad $5, %mm0
-
- movd %mm0, %eax
- movw %ax, (%edi, %ecx, 2)
-
- jz 3f
-1:
- test $2, %ecx
- jz 2f
- subl $2, %ecx
- movq (%esi, %ecx, 4), %mm0
- movq %mm0, %mm1
- pand %mm5, %mm0
- pand %mm6, %mm1
- pmaddwd %mm7, %mm0
- por %mm1, %mm0
- pslld $11, %mm0
- psrad $16, %mm0
-
- packssdw %mm0, %mm0
-
- movd %mm0, (%edi, %ecx, 2)
-
- jz 3f
-2:
- subl $4, %ecx
- movq (%esi, %ecx, 4), %mm0
- movq 8(%esi, %ecx, 4), %mm2
- movq %mm0, %mm1 /*\ a r g b (2x) \*/
- movq %mm2, %mm3
- pand %mm5, %mm0 /*\ 0 rrrrr000 0 bbbbb000 (2 x) \*/
- pand %mm5, %mm2
- pand %mm6, %mm1 /*\ 0 0 gggggg00 00000000 (2 x) \*/
- pand %mm6, %mm3
- pmaddwd %mm7, %mm0 /*\ 0 000rrrrr 000000bb bbb00000 (2 x) \*/
- pmaddwd %mm7, %mm2
- por %mm1, %mm0 /*\ 0 000rrrrr ggggggbb bbb00000 (2 x) \*/
- por %mm3, %mm2
- pslld $11, %mm0 /*\ rrrrrggg gggbbbbb 0 0 (2 x) \*/
- pslld $11, %mm2
- psrad $16, %mm0 /*\ x x rrrrrggg gggbbbbb (2 x) \*/
- psrad $16, %mm2
-
- packssdw %mm2, %mm0 /*\ rrrrrggg gggbbbbb (4 x) \*/
-
- movq %mm0, (%edi, %ecx, 2)
-
- jnz 2b
- LOOP_END
- LEAVE
-
-SIZE(imlib_mmx_rgb565_fast)
-
-
-PR_(imlib_mmx_bgr555_fast):
- movq mul_bgr555, %mm7 /*\ This constant is the only difference \*/
- jmp .rgb555_fast_entry
-
-SIZE(imlib_mmx_bgr555_fast)
-
-PR_(imlib_mmx_rgb555_fast):
- movq mul_rgb555, %mm7
-.rgb555_fast_entry:
- ENTER
-
- movq m_rb, %mm5
- movq m_g5, %mm6
-
- LOOP_START
-
- test $1, %ecx
- jz 1f
- decl %ecx
- movd (%esi, %ecx, 4), %mm0
- movq %mm0, %mm1
- pand %mm5, %mm0
- pand %mm6, %mm1
- pmaddwd %mm7, %mm0
- por %mm1, %mm0
- psrad $5, %mm0
-
- movd %mm0, %eax
- movw %ax, (%edi, %ecx, 2)
-
- jz 3f
-1:
- test $2, %ecx
- jz 2f
- subl $2, %ecx
- movq (%esi, %ecx, 4), %mm0
- movq %mm0, %mm1
- pand %mm5, %mm0
- pand %mm6, %mm1
- pmaddwd %mm7, %mm0
- por %mm1, %mm0
- psrld $6, %mm0
-
- packssdw %mm0, %mm0
-
- movd %mm0, (%edi, %ecx, 2)
-
- jz 3f
-2:
- subl $4, %ecx
- movq (%esi, %ecx, 4), %mm0
- movq 8(%esi, %ecx, 4), %mm2
- movq %mm0, %mm1 /*\ a r g b (2x) \*/
- movq %mm2, %mm3
- pand %mm5, %mm0 /*\ 0 rrrrr000 0 bbbbb000 (2 x) \*/
- pand %mm5, %mm2
- pand %mm6, %mm1 /*\ 0 0 ggggg000 00000000 (2 x) \*/
- pand %mm6, %mm3
- pmaddwd %mm7, %mm0 /*\ 0 000rrrrr 00000bbb bb000000 (2 x) \*/
- pmaddwd %mm7, %mm2
- por %mm1, %mm0 /*\ 0 000rrrrr gggggbbb bb000000 (2 x) \*/
- por %mm3, %mm2
- psrld $6, %mm0 /*\ 0 0 0rrrrrgg gggbbbbb (2 x) \*/
- psrld $6, %mm2
-
- packssdw %mm2, %mm0 /*\ 0rrrrrgg gggbbbbb (4 x) \*/
-
- movq %mm0, (%edi, %ecx, 2)
-
- jnz 2b
- LOOP_END
- LEAVE
-
-SIZE(imlib_mmx_rgb555_fast)
-
-PR_(imlib_get_cpuid):
- pushl %ebx
- pushl %edx
-
- pushf
- popl %eax
- movl %eax, %ebx
- xorl $0x200000, %eax
- pushl %eax
- popf
- pushf
- popl %eax
- xorl %ebx, %eax
- andl $0x200000, %eax
- jz 1f
- xorl %eax, %eax
- cpuid
- testl %eax, %eax
- jz 1f
- movl $1, %eax
- cpuid
- and $0x00000f00, %eax
- and $0xfffff0ff, %edx
- orl %edx, %eax
-1:
- popl %edx
- popl %ebx
- ret
-
-SIZE(imlib_get_cpuid)
-
-#endif
diff --git a/src/asm_rotate.S b/src/asm_rotate.S
deleted file mode 100644
index b8f9527..0000000
--- a/src/asm_rotate.S
+++ /dev/null
@@ -1,469 +0,0 @@
-#include <config.h>
-
-#ifdef __EMX__
-/* Due to strange behaviour of as.exe we use this macros */
-/* For all OS/2 coders - please use PGCC to compile this code */
-#define PR_(foo) ___##foo
-#define PT_(foo,func) ___##foo,##func
-#define SIZE(sym) \
- .___end_##sym:; \
- .size ___##sym,.___end_##sym-___##sym; \
- .align 8;
-#else
-#define PR_(foo) __##foo
-#define PT_(foo,func) __##foo,##func
-#define SIZE(sym) \
- .__end_##sym:; \
- .size __##sym,.__end_##sym-__##sym; \
- .align 8;
-#endif
-
-#ifdef DO_MMX_ASM
-
-/*\
-|*| MMX assembly rotation routine for Imlib2
-|*| Written by Willem Monsuwe <willem@stack.nl>
-\*/
-
-.text
- .align 8
-.globl PR_(imlib_mmx_RotateAA)
- .type PT_(imlib_mmx_RotateAA,@function)
-
-
-/*\ Prototype: __imlib_mmx_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)
-\*/
-
-#define src 8(%ebp)
-#define dest 12(%ebp)
-#define sow 16(%ebp)
-#define sw 20(%ebp)
-#define sh 24(%ebp)
-#define dow 28(%ebp)
-#define dw 32(%ebp)
-#define dh 36(%ebp)
-#define x 40(%ebp)
-#define y 44(%ebp)
-#define dxh 48(%ebp)
-#define dyh 52(%ebp)
-#define dxv 56(%ebp)
-#define dyv 60(%ebp)
-
-/*\ Local variables \*/
-#define j -4(%ebp)
-#define dly -8(%ebp)
-#define dlx -12(%ebp)
-#define sht -16(%ebp)
-#define swt -20(%ebp)
-#define m0fffh -24(%ebp)
-#define m0fff -28(%ebp)
-#define mulsow -32(%ebp)
-
-PR_(imlib_mmx_RotateAA):
- pushl %ebp
- movl %esp, %ebp
- subl $40, %esp
- pushl %ebx
- pushl %ecx
- pushl %edx
- pushl %edi
- pushl %esi
-
- /*\ Check (dw > 0) && (dh > 0) \*/
- cmpl $0, dw
- jle .rotate_leave
- cmpl $0, dh
- jle .rotate_leave
-
- pxor %mm7, %mm7
- movl sow, %eax
- sall $16, %eax
- orl $1, %eax
- movl %eax, mulsow
- movl $0x0fff, %eax
- movl %eax, m0fff
- movl %eax, m0fffh
-
- /*\ mm6 = x, y \*/
- movq x, %mm6
-
- /*\ edi = dest + dw \*/
- movl dest, %edi
- movl dw, %eax
- leal (%edi, %eax, 4), %edi
-
- /*\ dlx = dxv - dw * dxh \*/
- movl dw, %eax
- imull dxh, %eax
- negl %eax
- addl dxv, %eax
- movl %eax, dlx
-
- /*\ dly = dyv - dw * dyh \*/
- movl dw, %eax
- imull dyh, %eax
- negl %eax
- addl dyv, %eax
- movl %eax, dly
-
- /*\ j = dh \*/
- movl dh, %eax
- movl %eax, j
-
- /*\ Check if all coordinates will be inside the source \*/
- /*\ x < sw \*/
- movl sw, %edx
- movl x, %ecx
- cmpl %edx, %ecx
- jae .rotate_outside
- /*\ x + dxh * dw < sw \*/
- movl dxh, %ebx
- imull dw, %ebx
- addl %ebx, %ecx
- cmpl %edx, %ecx
- jae .rotate_outside
- /*\ x + dxh * dw + dxv * dh < sw \*/
- movl dxv, %eax
- imull dh, %eax
- subl %eax, %ecx
- cmpl %edx, %ecx
- jae .rotate_outside
- /*\ x + dxv * dh < sw \*/
- subl %ebx, %ecx
- cmpl %edx, %ecx
- jae .rotate_outside
-
- /*\ y < sh \*/
- movl sh, %edx
- movl y, %ecx
- cmpl %edx, %ecx
- jae .rotate_outside
- /*\ y + dyh * dw < sh \*/
- movl dyh, %ebx
- imull dw, %ebx
- addl %ebx, %ecx
- cmpl %edx, %ecx
- jae .rotate_outside
- /*\ y + dyh * dw + dyv * dh < sh \*/
- movl dyv, %eax
- imull dh, %eax
- addl %eax, %ecx
- cmpl %edx, %ecx
- jae .rotate_outside
- /*\ y + dyv * dh < sh \*/
- subl %ebx, %ecx
- cmpl %edx, %ecx
- jae .rotate_outside
-
-.rotate_inside:
- movl sow, %ebx
- movl src, %edx
-.inside_loop_y:
-
- /*\ i = -dw \*/
- movl dw, %ecx
- negl %ecx
-.inside_loop_x:
- /*\ esi = src + x >> 12 + (y >> 12) * sow \*/
- movq %mm6, %mm0
- psrad $12, %mm0
- packssdw %mm0, %mm0
- pmaddwd mulsow, %mm0
- movd %mm0, %eax
- leal (%edx, %eax, 4), %esi
-
- /*\ x and y \*/
- movq %mm6, %mm0
- pand m0fff, %mm0
- movq %mm0, %mm1
- /*\ mm0 = x & 0xfff \*/
- punpcklwd %mm0, %mm0
- punpckldq %mm0, %mm0
- /*\ mm1 = y & 0xfff \*/
- punpckhwd %mm1, %mm1
- punpckldq %mm1, %mm1
-
- /*\ Load and unpack four pixels in parralel
- |*| %mm2 = ptr[0], %mm3 = ptr[1]
- |*| %mm4 = ptr[sow], %mm5 = ptr[sow + 1]
- \*/
- movq (%esi), %mm2
- movq (%esi, %ebx, 4), %mm4
- movq %mm2, %mm3
- movq %mm4, %mm5
- punpcklbw %mm7, %mm2
- punpcklbw %mm7, %mm4
- punpckhbw %mm7, %mm3
- punpckhbw %mm7, %mm5
-
- /*\ X interpolation: r = l + (r - l) * xap \*/
- psubw %mm2, %mm3
- psubw %mm4, %mm5
- psllw $4, %mm3
- psllw $4, %mm5
- pmulhw %mm0, %mm3
- pmulhw %mm0, %mm5
- paddw %mm2, %mm3
- paddw %mm4, %mm5
-
- /*\ Y interpolation: d = u + (d - u) * yap \*/
- psubw %mm3, %mm5
- psllw $4, %mm5
- pmulhw %mm1, %mm5
- paddw %mm3, %mm5
- packuswb %mm5, %mm5
- movd %mm5, (%edi, %ecx, 4)
-
- paddd dxh, %mm6
-
- incl %ecx
- jnz .inside_loop_x
-
- paddd dlx, %mm6
- movl dow, %ecx
- leal (%edi, %ecx, 4), %edi
- decl j
- jnz .inside_loop_y
-
- jmp .rotate_leave
-
-.rotate_outside:
- movl sw, %eax
- decl %eax
- sall $12, %eax
- movl %eax, swt
- movl sh, %eax
- decl %eax
- sall $12, %eax
- movl %eax, sht
-
- movl sow, %ebx
- movl src, %edx
-.outside_loop_y:
-
- /*\ i = -dw \*/
- movl dw, %ecx
- negl %ecx
-.outside_loop_x:
- /*\ esi = src + x >> 12 + (y >> 12) * sow \*/
- movq %mm6, %mm0
- psrad $12, %mm0
- packssdw %mm0, %mm0
- pmaddwd mulsow, %mm0
- movd %mm0, %eax
- leal (%edx, %eax, 4), %esi
-
- /*\ x & 0xfff and y & 0xfff \*/
- movq %mm6, %mm0
- pand m0fff, %mm0
- movq %mm0, %mm1
-
- /*\ x < swt \*/
- movq %mm6, %mm2
- psrlq $32, %mm2
- movd %mm6, %eax
- cmpl swt, %eax
- jae 2f
-
- /*\ y < sht \*/
- movd %mm2, %eax
- cmpl sht, %eax
- jae 1f
- /*\ 1234 \*/
-.interp_argb:
- /*\ Unpack x and y \*/
- punpcklwd %mm0, %mm0
- punpckldq %mm0, %mm0
- punpckhwd %mm1, %mm1
- punpckldq %mm1, %mm1
- /*\ Load and unpack four pixels in parralel
- |*| %mm2 = ptr[0], %mm3 = ptr[1]
- |*| %mm4 = ptr[sow], %mm5 = ptr[sow + 1]
- \*/
- movq (%esi), %mm2
- movq (%esi, %ebx, 4), %mm4
- movq %mm2, %mm3
- movq %mm4, %mm5
- punpcklbw %mm7, %mm2
- punpcklbw %mm7, %mm4
- punpckhbw %mm7, %mm3
- punpckhbw %mm7, %mm5
-
- /*\ X interpolation: r = l + (r - l) * xap \*/
- psubw %mm2, %mm3
- psubw %mm4, %mm5
- psllw $4, %mm3
- psllw $4, %mm5
- pmulhw %mm0, %mm3
- pmulhw %mm0, %mm5
- paddw %mm2, %mm3
- paddw %mm4, %mm5
-
- /*\ Y interpolation: d = u + (d - u) * yap \*/
- psubw %mm3, %mm5
- psllw $4, %mm5
- pmulhw %mm1, %mm5
- paddw %mm3, %mm5
- packuswb %mm5, %mm5
- movd %mm5, (%edi, %ecx, 4)
- jmp .outside_il_end
-1:
- /*\ (-y-1) < 4096 \*/
- notl %eax
- cmpl $4095, %eax
- ja 1f
- /*\ ..34 \*/
- pxor m0fff, %mm1
- movd (%esi, %ebx, 4), %mm2
- movd 4(%esi, %ebx, 4), %mm4
-
-.interp_rgb_a0:
- /*\ Unpack x and y \*/
- punpcklwd %mm0, %mm0
- punpckldq %mm0, %mm0
- punpckhwd %mm1, %mm1
- /*\ Unpack two pixels \*/
- punpcklbw %mm7, %mm2
- punpcklbw %mm7, %mm4
- /*\ Interpolate \*/
- psubw %mm2, %mm4
- psllw $4, %mm4
- pmulhw %mm0, %mm4
- paddw %mm2, %mm4
- /*\ Separate out alpha, multiply with mm1, and subtract \*/
- movq %mm4, %mm2
- psllq $48, %mm1
- psllw $4, %mm4
- pmulhw %mm1, %mm4
- psubw %mm4, %mm2
- packuswb %mm2, %mm2
- movd %mm2, (%edi, %ecx, 4)
- jmp .outside_il_end
-1:
- /*\ (y - sht) < 4096 \*/
- notl %eax
- subl sht, %eax
- cmpl $4095, %eax
- ja .outside_il_0
- /*\ 12.. \*/
- movd (%esi), %mm2
- movd 4(%esi), %mm4
- jmp .interp_rgb_a0
-2:
- /*\ Switch x and y \*/
- psrlq $32, %mm0
- psllq $32, %mm1
- /*\ -x-1 < 4096 \*/
- notl %eax
- cmpl $4095, %eax
- ja 2f
-
- pxor m0fff, %mm1
- /*\ y < sht \*/
- movd %mm2, %eax
- cmpl sht, %eax
- jae 1f
- /*\ .2.4 \*/
- movd 4(%esi), %mm2
- movd 4(%esi, %ebx, 4), %mm4
- jmp .interp_rgb_a0
-1:
- /*\ (-y-1) < 4096 \*/
- notl %eax
- cmpl $4095, %eax
- ja 1f
- /*\ ...4 \*/
- movd 4(%esi, %ebx, 4), %mm2
-.interp_a000:
- /*\ Separate out alpha, multiply with mm0 and mm1 \*/
- pxor m0fff, %mm1
- punpcklbw %mm7, %mm2
- movq %mm2, %mm3
- psllq $2, %mm0
- psrlq $30, %mm1
- pmulhw %mm0, %mm1
- pxor m0fff, %mm1
- psllq $48, %mm1
- psllw $4, %mm3
- pmulhw %mm1, %mm3
- psubw %mm3, %mm2
- packuswb %mm2, %mm2
- movd %mm2, (%edi, %ecx, 4)
- jmp .outside_il_end
-1:
- /*\ (y - sht) < 4096 \*/
- notl %eax
- subl sht, %eax
- cmpl $4095, %eax
- ja .outside_il_0
- /*\ .2.. \*/
- pxor m0fff, %mm0
- movd 4(%esi), %mm2
- jmp .interp_a000
-2:
- /*\ (x - swt) < 4096 \*/
- notl %eax
- subl swt, %eax
- cmpl $4095, %eax
- ja .outside_il_0
-
- /*\ y < sht \*/
- movd %mm2, %eax
- cmpl sht, %eax
- jae 1f
- /*\ 1.3. \*/
- movd (%esi), %mm2
- movd (%esi, %ebx, 4), %mm4
- jmp .interp_rgb_a0
-1:
- /*\ (-y-1) < 4096 \*/
- notl %eax
- cmpl $4095, %eax
- ja 1f
- /*\ ..3. \*/
- movd (%esi, %ebx, 4), %mm2
- jmp .interp_a000
-1:
- /*\ (y - sht) < 4096 \*/
- notl %eax
- subl sht, %eax
- cmpl $4095, %eax
- ja .outside_il_0
- /*\ 1... \*/
- pxor m0fff, %mm0
- movd (%esi), %mm2
- jmp .interp_a000
-
-.outside_il_0:
- movl $0, %eax
- movl %eax, (%edi, %ecx, 4)
-
-.outside_il_end:
- paddd dxh, %mm6
-
- incl %ecx
- jnz .outside_loop_x
-
- paddd dlx, %mm6
- movl dow, %ecx
- leal (%edi, %ecx, 4), %edi
- decl j
- jnz .outside_loop_y
-
-.rotate_leave:
- emms
- popl %esi
- popl %edi
- popl %edx
- popl %ecx
- popl %ebx
- movl %ebp, %esp
- popl %ebp
- ret
-
-SIZE(imlib_mmx_RotateAA)
-
-#endif
-
diff --git a/src/asm_scale.S b/src/asm_scale.S
deleted file mode 100644
index e48c190..0000000
--- a/src/asm_scale.S
+++ /dev/null
@@ -1,809 +0,0 @@
-#include <config.h>
-
-#ifdef __EMX__
-/* Due to strange behaviour of as.exe we use this macros */
-/* For all OS/2 coders - please use PGCC to compile this code */
-#define PR_(foo) ___##foo
-#define PT_(foo,func) ___##foo,##func
-#define SIZE(sym) \
- .___end_##sym:; \
- .size ___##sym,.___end_##sym-___##sym; \
- .align 8;
-#else
-#define PR_(foo) __##foo
-#define PT_(foo,func) __##foo,##func
-#define SIZE(sym) \
- .__end_##sym:; \
- .size __##sym,.__end_##sym-__##sym; \
- .align 8;
-#endif
-
-#ifdef DO_MMX_ASM
-
-/*\
-|*| MMX assembly scaling routine for Imlib2
-|*| Written by Willem Monsuwe <willem@stack.nl>
-\*/
-
-.text
- .align 8
-.globl PR_(imlib_Scale_mmx_AARGBA)
- .type PT_(imlib_Scale_mmx_AARGBA,@function)
-
-/*\ Prototype: __imlib_Scale_mmx_AARGBA(ImlibScaleInfo *isi, DATA32 *dest,
-|*| int dxx, int dyy, int dx, int dy, int dw, int dh, int dow, int sow)
-\*/
-
-#define isi 8(%ebp)
-#define dest 12(%ebp)
-#define dxx 16(%ebp)
-#define dyy 20(%ebp)
-#define dx 24(%ebp)
-#define dy 28(%ebp)
-#define dw 32(%ebp)
-#define dh 36(%ebp)
-#define dow 40(%ebp)
-#define sow 44(%ebp)
-
-/*\ Local variables that didn't fit in registers \*/
-#define y -4(%ebp)
-#define yp -8(%ebp)
-#define yap -12(%ebp)
-#define xp -16(%ebp)
-#define xap -20(%ebp)
-#define Cx -24(%ebp)
-#define Mx -28(%ebp)
-#define Cy -32(%ebp)
-#define My -36(%ebp)
-#define sow_4 -40(%ebp)
-
-/*\ When %edx points to ImlibScaleInfo, these are the members \*/
-#define xpoints (%edx)
-#define ypoints 4(%edx)
-#define xapoints 8(%edx)
-#define yapoints 12(%edx)
-#define xup_yup 16(%edx)
-
-PR_(imlib_Scale_mmx_AARGBA):
- pushl %ebp
- movl %esp, %ebp
- subl $40, %esp
- pushl %ebx
- pushl %ecx
- pushl %edx
- pushl %edi
- pushl %esi
- movl isi, %edx
-
- /*\ Check (dw > 0) && (dh > 0) \*/
- cmpl $0, dw
- jle .scale_leave
- cmpl $0, dh
- jle .scale_leave
-
- /*\ X-based array pointers point to the end; we're looping up to 0 \*/
- /*\ %edi = dest + dow * dy + dx + dw \*/
- movl dow, %eax
- imull dy, %eax
- addl dx, %eax
- addl dw, %eax
- movl dest, %edi
- leal (%edi, %eax, 4), %edi
- /*\ xp = xpoints + dxx + dw \*/
- movl dxx, %ebx
- addl dw, %ebx
- movl xpoints, %eax
- leal (%eax, %ebx, 4), %eax
- movl %eax, xp
- /*\ xap = xapoints + dxx + dw \*/
- movl xapoints, %eax
- leal (%eax, %ebx, 4), %eax
- movl %eax, xap
- /*\ y = dh \*/
- movl dh, %eax
- movl %eax, y
- /*\ yp = ypoints + dyy \*/
- movl dyy, %ebx
- movl ypoints, %eax
- leal (%eax, %ebx, 4), %eax
- movl %eax, yp
- /*\ yap = yapoints + dyy \*/
- movl yapoints, %eax
- leal (%eax, %ebx, 4), %eax
- movl %eax, yap
-
- pxor %mm7, %mm7
-
- /*\ Test xup bit \*/
- movl xup_yup, %eax
- sarl $1, %eax
- jnc .scale_x_down
-
-.scale_x_up:
- /*\ Test yup bit \*/
- sarl $1, %eax
- jnc .scale_x_up_y_down
-
-
-/*\ Scaling up both ways \*/
-
-.scale_x_up_y_up:
- movl sow, %ebx
-
-.up_up_loop_y:
-
- /*\ x = -dw \*/
- movl dw, %ecx
- negl %ecx
-
- /*\ %eax = *yap << 4 \*/
- movl yap, %eax
- movl (%eax), %eax
- sall $4, %eax
- jz .up_up_yap_0
- movd %eax, %mm1
- punpcklwd %mm1, %mm1
- punpckldq %mm1, %mm1
-
-.up_up_loop1_x:
- /*\ %esi = *yp + xp[x] \*/
- movl yp, %eax
- movl (%eax), %esi
- movl xp, %eax
- movl (%eax, %ecx, 4), %eax
- leal (%esi, %eax, 4), %esi
-
- /*\ %eax = xap[x] << 4 \*/
- movl xap, %eax
- movl (%eax, %ecx, 4), %eax
- sall $4, %eax
- jz .up_up_xap_0
-
- /*\ %mm0 = xap[x] << 4 \*/
- movd %eax, %mm0
- punpcklwd %mm0, %mm0
- punpckldq %mm0, %mm0
-
- /*\ Load and unpack four pixels in parralel
- |*| %mm2 = ptr[0], %mm3 = ptr[1]
- |*| %mm4 = ptr[sow], %mm5 = ptr[sow + 1]
- \*/
- movq (%esi), %mm2
- movq (%esi, %ebx, 4), %mm4
- movq %mm2, %mm3
- movq %mm4, %mm5
- punpcklbw %mm7, %mm2
- punpcklbw %mm7, %mm4
- punpckhbw %mm7, %mm3
- punpckhbw %mm7, %mm5
-
- /*\ X interpolation: r = l + (r - l) * xap \*/
- psubw %mm2, %mm3
- psubw %mm4, %mm5
- psllw $4, %mm3
- psllw $4, %mm5
- pmulhw %mm0, %mm3
- pmulhw %mm0, %mm5
- paddw %mm2, %mm3
- paddw %mm4, %mm5
- /*\ Now %mm3 = I(ptr[0], ptr[1]), %mm5 = I(ptr[sow], ptr[sow + 1]) \*/
- jmp .up_up_common
-.up_up_xap_0:
- /*\ Load and unpack two pixels
- |*| %mm3 = ptr[0], %mm5 = ptr[sow]
- \*/
- movd (%esi), %mm3
- movd (%esi, %ebx, 4), %mm5
- punpcklbw %mm7, %mm3
- punpcklbw %mm7, %mm5
-.up_up_common:
- /*\ Y interpolation: d = u + (d - u) * yap \*/
- psubw %mm3, %mm5
- psllw $4, %mm5
- pmulhw %mm1, %mm5
- paddw %mm3, %mm5
- packuswb %mm5, %mm5
- movd %mm5, (%edi, %ecx, 4)
-
- /*\ while (++x) \*/
- incl %ecx
- jnz .up_up_loop1_x
- jmp .up_up_yap_end
-.up_up_yap_0:
-
-.up_up_loop2_x:
- /*\ %esi = *yp + xp[x] \*/
- movl yp, %eax
- movl (%eax), %esi
- movl xp, %eax
- movl (%eax, %ecx, 4), %eax
- leal (%esi, %eax, 4), %esi
-
- /*\ %eax = xap[x] << 4 \*/
- movl xap, %eax
- movl (%eax, %ecx, 4), %eax
- sall $4, %eax
- jz .up_up_0
-
- /*\ %mm0 = xap[x] << 4 \*/
- movd %eax, %mm0
- punpcklwd %mm0, %mm0
- punpckldq %mm0, %mm0
-
- /*\ Load and unpack two pixels in parralel
- |*| %mm2 = ptr[0], %mm3 = ptr[1]
- \*/
- movq (%esi), %mm2
- movq %mm2, %mm3
- punpcklbw %mm7, %mm2
- punpckhbw %mm7, %mm3
-
- /*\ X interpolation: r = l + (r - l) * xap \*/
- psubw %mm2, %mm3
- psllw $4, %mm3
- pmulhw %mm0, %mm3
- paddw %mm2, %mm3
- packuswb %mm3, %mm3
- movd %mm3, (%edi, %ecx, 4)
- jmp .up_up_1
-.up_up_0:
- /*\ dptr[x] = *sptr \*/
- movl (%esi), %eax
- movl %eax, (%edi, %ecx, 4)
-.up_up_1:
- incl %ecx
- jnz .up_up_loop2_x
-
-.up_up_yap_end:
- /*\ dptr += dow \*/
- movl dow, %eax
- leal (%edi, %eax, 4), %edi
- /*\ yap++; yp++ \*/
- addl $4, yap
- addl $4, yp
- /*\ while (y--) \*/
- decl y
- jnz .up_up_loop_y
-
- jmp .scale_leave
-
-
-/*\ Scaling down vertically \*/
-
-.scale_x_up_y_down:
- /*\ sow_4 = sow * 4 \*/
- movl sow, %eax
- sall $2, %eax
- movl %eax, sow_4
-
-.up_down_loop_y:
-
- /*\ Setup My and Cy \*/
- movl yap, %eax
- movzwl (%eax), %ebx
- movl %ebx, My
- movzwl 2(%eax), %eax
- movl %eax, Cy
-
- /*\ mm4 = Cy \*/
- movd %eax, %mm4
- punpcklwd %mm4, %mm4
- punpckldq %mm4, %mm4
- /*\ mm5 = My \*/
- movd %ebx, %mm5
- punpcklwd %mm5, %mm5
- punpckldq %mm5, %mm5
-
- /*\ x = -dw \*/
- movl dw, %ecx
- negl %ecx
-.up_down_loop_x:
- /*\ %esi = *yp + xp[x] \*/
- movl yp, %eax
- movl (%eax), %esi
- movl xp, %eax
- movl (%eax, %ecx, 4), %eax
- leal (%esi, %eax, 4), %esi
-
- movl %esi, %eax
- /*\ v = (*p * My) >> 10 \*/
- movd (%eax), %mm0
- punpcklbw %mm7, %mm0
- psllw $6, %mm0
- pmulhw %mm5, %mm0
-
- /*\ i = 0x4000 - My \*/
- movl $0x4000, %ebx
- subl My, %ebx
- jbe 5f
- jmp 2f
-1:
- /*\ p += sow; v += (*p * Cy) >> 10 \*/
- addl sow_4, %eax
- movd (%eax), %mm1
- punpcklbw %mm7, %mm1
- psllw $6, %mm1
- pmulhw %mm4, %mm1
- paddw %mm1, %mm0
-
- /*\ i -= Cy; while (i > Cy) \*/
- subl Cy, %ebx
-2:
- cmpl Cy, %ebx
- jg 1b
-
- /*\ mm6 = i \*/
- movd %ebx, %mm6
- punpcklwd %mm6, %mm6
- punpckldq %mm6, %mm6
-
- /*\ p += sow; v += (*p * i) >> 10 \*/
- addl sow_4, %eax
- movd (%eax), %mm1
- punpcklbw %mm7, %mm1
- psllw $6, %mm1
- pmulhw %mm6, %mm1
- paddw %mm1, %mm0
-5:
- /*\ %eax = xap[x] << 5 \*/
- movl xap, %eax
- movl (%eax, %ecx, 4), %eax
- sall $5, %eax
- jz 6f
- /*\ mm3 = xap[x] << 5 \*/
- movd %eax, %mm3
- punpcklwd %mm3, %mm3
- punpckldq %mm3, %mm3
-
- /*\ p + 1 \*/
- movl %esi, %eax
- addl $4, %eax
- /*\ vv = (*p * My) >> 10 \*/
- movd (%eax), %mm2
- punpcklbw %mm7, %mm2
- psllw $6, %mm2
- pmulhw %mm5, %mm2
-
- /*\ i = 0x4000 - My \*/
- movl $0x4000, %ebx
- subl My, %ebx
- jbe 5f
- jmp 2f
-1:
- /*\ p += sow; vv += (*p * Cy) >> 10 \*/
- addl sow_4, %eax
- movd (%eax), %mm1
- punpcklbw %mm7, %mm1
- psllw $6, %mm1
- pmulhw %mm4, %mm1
- paddw %mm1, %mm2
-
- /*\ i -= Cy; while (i > Cy) \*/
- subl Cy, %ebx
-2:
- cmpl Cy, %ebx
- jg 1b
-
- /*\ p += sow; v += (*p * i) >> 10 \*/
- addl sow_4, %eax
- movd (%eax), %mm1
- punpcklbw %mm7, %mm1
- psllw $6, %mm1
- pmulhw %mm6, %mm1
- paddw %mm1, %mm2
-5:
- /*\ v = v + (vv - v) * xap \*/
- psubw %mm0, %mm2
- psllw $3, %mm2
- pmulhw %mm3, %mm2
- paddw %mm2, %mm0
-6:
- /*\ dest[x] = v >> 4 \*/
- psrlw $4, %mm0
- packuswb %mm0, %mm0
- movd %mm0, (%edi, %ecx, 4)
-
- /*\ while (++x) \*/
- incl %ecx
- jnz .up_down_loop_x
-
- /*\ dptr += dow \*/
- movl dow, %eax
- leal (%edi, %eax, 4), %edi
- /*\ yap++; yp++ \*/
- addl $4, yap
- addl $4, yp
- /*\ while (y--) \*/
- decl y
- jnz .up_down_loop_y
-
- jmp .scale_leave
-
-.scale_x_down:
- /*\ Test yup bit \*/
- sarl $1, %eax
- jnc .scale_x_down_y_down
-
-
-/*\ Scaling down horizontally \*/
-
-.scale_x_down_y_up:
- /*\ sow_4 = sow * 4 \*/
- movl sow, %eax
- sall $2, %eax
- movl %eax, sow_4
-
-.down_up_loop_y:
-
- /*\ %eax = *yap << 5 \*/
- movl yap, %eax
- movl (%eax), %eax
- sall $5, %eax
- /*\ mm3 = *yap << 5 \*/
- movd %eax, %mm3
- punpcklwd %mm3, %mm3
- punpckldq %mm3, %mm3
-
- /*\ x = -dw \*/
- movl dw, %ecx
- negl %ecx
-.down_up_loop_x:
- /*\ %esi = *yp + xp[x] \*/
- movl yp, %eax
- movl (%eax), %esi
- movl xp, %eax
- movl (%eax, %ecx, 4), %eax
- leal (%esi, %eax, 4), %esi
-
- /*\ Setup Mx and Cx \*/
- movl xap, %eax
- movzwl (%eax, %ecx, 4), %ebx
- movl %ebx, Mx
- movzwl 2(%eax, %ecx, 4), %eax
- movl %eax, Cx
-
- /*\ mm4 = Cx \*/
- movd %eax, %mm4
- punpcklwd %mm4, %mm4
- punpckldq %mm4, %mm4
- /*\ mm5 = Mx \*/
- movd %ebx, %mm5
- punpcklwd %mm5, %mm5
- punpckldq %mm5, %mm5
-
- movl %esi, %eax
- /*\ v = (*p * Mx) >> 10 \*/
- movd (%eax), %mm0
- punpcklbw %mm7, %mm0
- psllw $6, %mm0
- pmulhw %mm5, %mm0
-
- /*\ i = 0x4000 - Mx \*/
- movl $0x4000, %ebx
- subl Mx, %ebx
- jbe 5f
- jmp 2f
-1:
- /*\ p += sow; v += (*p * Cx) >> 10 \*/
- addl $4, %eax
- movd (%eax), %mm1
- punpcklbw %mm7, %mm1
- psllw $6, %mm1
- pmulhw %mm4, %mm1
- paddw %mm1, %mm0
-
- /*\ i -= Cx; while (i > Cx) \*/
- subl Cx, %ebx
-2:
- cmpl Cx, %ebx
- jg 1b
-
- /*\ mm6 = i \*/
- movd %ebx, %mm6
- punpcklwd %mm6, %mm6
- punpckldq %mm6, %mm6
-
- /*\ p += sow; v += (*p * i) >> 10 \*/
- addl $4, %eax
- movd (%eax), %mm1
- punpcklbw %mm7, %mm1
- psllw $6, %mm1
- pmulhw %mm6, %mm1
- paddw %mm1, %mm0
-5:
- movd %mm3, %eax
- testl %eax, %eax
- jz 6f
- /*\ p + sow \*/
- movl %esi, %eax
- addl sow_4, %eax
- /*\ vv = (*p * Mx) >> 10 \*/
- movd (%eax), %mm2
- punpcklbw %mm7, %mm2
- psllw $6, %mm2
- pmulhw %mm5, %mm2
-
- /*\ i = 0x4000 - Mx \*/
- movl $0x4000, %ebx
- subl Mx, %ebx
- jbe 5f
- jmp 2f
-1:
- /*\ p += sow; vv += (*p * Cx) >> 10 \*/
- addl $4, %eax
- movd (%eax), %mm1
- punpcklbw %mm7, %mm1
- psllw $6, %mm1
- pmulhw %mm4, %mm1
- paddw %mm1, %mm2
-
- /*\ i -= Cx; while (i > Cx) \*/
- subl Cx, %ebx
-2:
- cmpl Cx, %ebx
- jg 1b
-
- /*\ p += sow; v += (*p * i) >> 10 \*/
- addl $4, %eax
- movd (%eax), %mm1
- punpcklbw %mm7, %mm1
- psllw $6, %mm1
- pmulhw %mm6, %mm1
- paddw %mm1, %mm2
-5:
- /*\ v = v + (vv - v) * yap \*/
- psubw %mm0, %mm2
- psllw $3, %mm2
- pmulhw %mm3, %mm2
- paddw %mm2, %mm0
-6:
- /*\ dest[x] = v >> 4 \*/
- psrlw $4, %mm0
- packuswb %mm0, %mm0
- movd %mm0, (%edi, %ecx, 4)
-
- /*\ while (++x) \*/
- incl %ecx
- jnz .down_up_loop_x
-
- /*\ dptr += dow \*/
- movl dow, %eax
- leal (%edi, %eax, 4), %edi
- /*\ yap++; yp++ \*/
- addl $4, yap
- addl $4, yp
- /*\ while (y--) \*/
- decl y
- jnz .down_up_loop_y
-
- jmp .scale_leave
-
-
-/*\ Scaling down both ways \*/
-
-.scale_x_down_y_down:
- /*\ sow_4 = sow * 4 \*/
- movl sow, %eax
- sall $2, %eax
- movl %eax, sow_4
-
-.down_down_loop_y:
-
- /*\ Setup My and Cy \*/
- movl yap, %eax
- movzwl (%eax), %ebx
- movl %ebx, My
- movzwl 2(%eax), %eax
- movl %eax, Cy
-
- /*\ x = -dw \*/
- movl dw, %ecx
- negl %ecx
-.down_down_loop_x:
- /*\ %esi = *yp + xp[x] \*/
- movl yp, %eax
- movl (%eax), %esi
- movl xp, %eax
- movl (%eax, %ecx, 4), %eax
- leal (%esi, %eax, 4), %esi
-
- /*\ Setup Mx and Cx \*/
- movl xap, %eax
- movzwl (%eax, %ecx, 4), %ebx
- movl %ebx, Mx
- movzwl 2(%eax, %ecx, 4), %eax
- movl %eax, Cx
-
- /*\ mm3 = Cx \*/
- movd %eax, %mm3
- punpcklwd %mm3, %mm3
- punpckldq %mm3, %mm3
- /*\ mm5 = Mx \*/
- movd %ebx, %mm5
- punpcklwd %mm5, %mm5
- punpckldq %mm5, %mm5
-
- /*\ p = sptr; v = (*p * Mx) >> 9 \*/
- movl %esi, %eax
- movd (%eax), %mm0
- punpcklbw %mm7, %mm0
- psllw $7, %mm0
- pmulhw %mm5, %mm0
-
- /*\ i = 0x4000 - Mx \*/
- movl $0x4000, %ebx
- subl Mx, %ebx
- jbe 5f
- jmp 2f
-1:
- /*\ v += (*++p * Cx) >> 9 \*/
- addl $4, %eax
- movd (%eax), %mm1
- punpcklbw %mm7, %mm1
- psllw $7, %mm1
- pmulhw %mm3, %mm1
- paddw %mm1, %mm0
-
- /*\ i -= Cx; while (i > Cx) \*/
- subl Cx, %ebx
-2:
- cmpl Cx, %ebx
- jg 1b
-
- /*\ mm6 = i \*/
- movd %ebx, %mm6
- punpcklwd %mm6, %mm6
- punpckldq %mm6, %mm6
-
- /*\ v += (*++p * i) >> 9 \*/
- addl $4, %eax
- movd (%eax), %mm1
- punpcklbw %mm7, %mm1
- psllw $7, %mm1
- pmulhw %mm6, %mm1
- paddw %mm1, %mm0
-5:
- /*\ v *= My \*/
- movd My, %mm4
- punpcklwd %mm4, %mm4
- punpckldq %mm4, %mm4
- psllw $2, %mm0
- pmulhw %mm4, %mm0
-
- /*\ j = 0x4000 - My \*/
- movl $0x4000, %edx
- subl My, %edx
- jbe 6f
- jmp 4f
-3:
- /*\ sptr += sow; p = sptr \*/
- addl sow_4, %esi
- movl %esi, %eax
- /*\ vx = (*p * Mx) >> 9 \*/
- movd (%eax), %mm1
- punpcklbw %mm7, %mm1
- psllw $7, %mm1
- pmulhw %mm5, %mm1
-
- /*\ i = 0x4000 - Mx \*/
- movl $0x4000, %ebx
- subl Mx, %ebx
- jbe 5f
- jmp 2f
-1:
- /*\ vx += (*++p * Cx) >> 9 \*/
- addl $4, %eax
- movd (%eax), %mm2
- punpcklbw %mm7, %mm2
- psllw $7, %mm2
- pmulhw %mm3, %mm2
- paddw %mm2, %mm1
-
- /*\ i -= Cx; while (i > Cx) \*/
- subl Cx, %ebx
-2:
- cmpl Cx, %ebx
- jg 1b
-
- /*\ vx += (*++p * i) >> 9 \*/
- addl $4, %eax
- movd (%eax), %mm2
- punpcklbw %mm7, %mm2
- psllw $7, %mm2
- pmulhw %mm6, %mm2
- paddw %mm2, %mm1
-5:
- /*\ v += (vx * Cy) >> 14 \*/
- movd Cy, %mm4
- punpcklwd %mm4, %mm4
- punpckldq %mm4, %mm4
- psllw $2, %mm1
- pmulhw %mm4, %mm1
- paddw %mm1, %mm0
-
- /*\ j -= Cy; while (j > Cy) \*/
- subl Cy, %edx
-4:
- cmpl Cy, %edx
- jg 3b
-
- /*\ sptr += sow; p = sptr \*/
- addl sow_4, %esi
- movl %esi, %eax
- /*\ vx = (*p * Mx) >> 9 \*/
- movd (%eax), %mm1
- punpcklbw %mm7, %mm1
- psllw $7, %mm1
- pmulhw %mm5, %mm1
-
- /*\ i = 0x4000 - Mx \*/
- movl $0x4000, %ebx
- subl Mx, %ebx
- jbe 5f
- jmp 2f
-1:
- /*\ vx += (*++p * Cx) >> 9 \*/
- addl $4, %eax
- movd (%eax), %mm2
- punpcklbw %mm7, %mm2
- psllw $7, %mm2
- pmulhw %mm3, %mm2
- paddw %mm2, %mm1
-
- /*\ i -= Cx; while (i > Cx) \*/
- subl Cx, %ebx
-2:
- cmpl Cx, %ebx
- jg 1b
-
- /*\ vx += (*++p * i) >> 9 \*/
- addl $4, %eax
- movd (%eax), %mm2
- punpcklbw %mm7, %mm2
- psllw $7, %mm2
- pmulhw %mm6, %mm2
- paddw %mm2, %mm1
-5:
- /*\ v += (vx * j) >> 14 \*/
- movd %edx, %mm4
- punpcklwd %mm4, %mm4
- punpckldq %mm4, %mm4
- psllw $2, %mm1
- pmulhw %mm4, %mm1
- paddw %mm1, %mm0
-6:
- /*\ dptr[x] = mm0 >> 5 \*/
- psrlw $5, %mm0
- packuswb %mm0, %mm0
- movd %mm0, (%edi, %ecx, 4)
-
- /*\ while (++x) \*/
- incl %ecx
- jnz .down_down_loop_x
-
- /*\ dptr += dow \*/
- movl dow, %eax
- leal (%edi, %eax, 4), %edi
- /*\ yap++; yp++ \*/
- addl $4, yap
- addl $4, yp
- /*\ while (y--) \*/
- decl y
- jnz .down_down_loop_y
-
- jmp .scale_leave
-
-.scale_leave:
- emms
- popl %esi
- popl %edi
- popl %edx
- popl %ecx
- popl %ebx
- movl %ebp, %esp
- popl %ebp
- ret
-
-SIZE(imlib_Scale_mmx_AARGBA)
-
-#endif
diff --git a/src/blend.c b/src/blend.c
deleted file mode 100644
index 9966f9c..0000000
--- a/src/blend.c
+++ /dev/null
@@ -1,1820 +0,0 @@
-#include "common.h"
-#include "colormod.h"
-#include "image.h"
-#include "blend.h"
-#include "scale.h"
-
-
-#define ADD_COPY(r, g, b, dest) \
- ADD_COLOR(R_VAL(dest), r, R_VAL(dest)); \
- ADD_COLOR(G_VAL(dest), g, G_VAL(dest)); \
- ADD_COLOR(B_VAL(dest), b, B_VAL(dest));
-
-#define SUB_COPY(r, g, b, dest) \
- SUB_COLOR(R_VAL(dest), r, R_VAL(dest)); \
- SUB_COLOR(G_VAL(dest), g, G_VAL(dest)); \
- SUB_COLOR(B_VAL(dest), b, B_VAL(dest));
-
-#define RE_COPY(r, g, b, dest) \
- RESHADE_COLOR(R_VAL(dest), r, R_VAL(dest)); \
- RESHADE_COLOR(G_VAL(dest), g, G_VAL(dest)); \
- RESHADE_COLOR(B_VAL(dest), b, B_VAL(dest));
-
-
-
-int pow_lut_initialized = 0;
-DATA8 pow_lut[256][256];
-
-void
-__imlib_build_pow_lut(void)
-{
- int i, j;
-
- if (pow_lut_initialized)
- return;
- pow_lut_initialized = 1;
- for (i = 0; i < 256; i++)
- {
- 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;
- }
- }
-}
-
-
-/* COPY OPS */
-
-static void
-__imlib_BlendRGBAToRGB(DATA32 * src, int srcw, DATA32 * dst, int dstw,
- int w, int h, ImlibColorModifier * cm)
-{
- int src_step = (srcw - w), dst_step = (dstw - w), ww = w;
-
- while (h--)
- {
- while (w--)
- {
- DATA32 tmp;
- DATA8 a;
-
- a = A_VAL(src);
- switch (a)
- {
- case 0:
- break;
- case 255:
- *dst = (*dst & 0xff000000) | (*src & 0x00ffffff);
- break;
- default:
- BLEND(R_VAL(src), G_VAL(src), B_VAL(src), a, dst);
- break;
- }
- src++; dst++;
- }
- src += src_step;
- dst += dst_step;
- w = ww;
- }
-}
-
-static void
-__imlib_BlendRGBAToRGBA(DATA32 * src, int srcw, DATA32 * dst, int dstw,
- int w, int h, ImlibColorModifier * cm)
-{
- int src_step = (srcw - w), dst_step = (dstw - w), ww = w;
-
- while (h--)
- {
- while (w--)
- {
- DATA32 tmp;
- DATA8 a, aa;
-
- aa = A_VAL(src);
- switch (aa)
- {
- case 0:
- break;
- case 255:
- *dst = *src;
- break;
- default:
- a = pow_lut[aa][A_VAL(dst)];
- BLEND_COLOR(aa, A_VAL(dst), 255, A_VAL(dst));
- BLEND(R_VAL(src), G_VAL(src), B_VAL(src), a, dst);
- break;
- }
- src++; dst++;
- }
- src += src_step;
- dst += dst_step;
- w = ww;
- }
-}
-
-static void
-__imlib_CopyRGBAToRGB(DATA32 * src, int srcw, DATA32 * dst, int dstw,
- int w, int h, ImlibColorModifier * cm)
-{
- int src_step = (srcw - w), dst_step = (dstw - w), ww = w;
-
- while (h--)
- {
- while (w--)
- {
- *dst = (*dst & 0xff000000) | (*src & 0x00ffffff);
- src++; dst++;
- }
- src += src_step;
- dst += dst_step;
- w = ww;
- }
-}
-
-static void
-__imlib_CopyRGBToRGBA(DATA32 * src, int srcw, DATA32 * dst, int dstw,
- int w, int h, ImlibColorModifier * cm)
-{
- int src_step = (srcw - w), dst_step = (dstw - w), ww = w;
-
- while (h--)
- {
- while (w--)
- {
- *dst = 0xff000000 | (*src & 0x00ffffff);
- src++; dst++;
- }
- src += src_step;
- dst += dst_step;
- w = ww;
- }
-}
-
-static void
-__imlib_CopyRGBAToRGBA(DATA32 * src, int srcw, DATA32 * dst, int dstw,
- int w, int h, ImlibColorModifier * cm)
-{
- int src_step = (srcw - w), dst_step = (dstw - w), ww = w;
-
- while (h--)
- {
- while (w--)
- {
- *dst = *src;
- src++; dst++;
- }
- src += src_step;
- dst += dst_step;
- w = ww;
- }
-}
-
-
-/* ADD OPS */
-
-static void
-__imlib_AddBlendRGBAToRGB(DATA32 * src, int srcw, DATA32 * dst, int dstw,
- int w, int h, ImlibColorModifier * cm)
-{
- int src_step = (srcw - w), dst_step = (dstw - w), ww = w;
-
- while (h--)
- {
- while (w--)
- {
- DATA32 tmp;
- DATA8 a;
-
- a = A_VAL(src);
- switch (a)
- {
- case 0:
- break;
- case 255:
- ADD_COPY(R_VAL(src), G_VAL(src), B_VAL(src), dst);
- break;
- default:
- BLEND_ADD(R_VAL(src), G_VAL(src), B_VAL(src), a, dst);
- break;
- }
- src++; dst++;
- }
- src += src_step;
- dst += dst_step;
- w = ww;
- }
-}
-
-static void
-__imlib_AddBlendRGBAToRGBA(DATA32 * src, int srcw, DATA32 * dst, int dstw,
- int w, int h, ImlibColorModifier * cm)
-{
- int src_step = (srcw - w), dst_step = (dstw - w), ww = w;
-
- while (h--)
- {
- while (w--)
- {
- DATA32 tmp;
- DATA8 a, aa;
-
- aa = A_VAL(src);
- switch (aa)
- {
- case 0:
- break;
- case 255:
- A_VAL(dst) = 0xff;
- ADD_COPY(R_VAL(src), G_VAL(src), B_VAL(src), dst);
- break;
- default:
- a = pow_lut[aa][A_VAL(dst)];
- BLEND_COLOR(aa, A_VAL(dst), 255, A_VAL(dst));
- BLEND_ADD(R_VAL(src), G_VAL(src), B_VAL(src), a, dst);
- break;
- }
- src++; dst++;
- }
- src += src_step;
- dst += dst_step;
- w = ww;
- }
-}
-
-static void
-__imlib_AddCopyRGBAToRGB(DATA32 * src, int srcw, DATA32 * dst, int dstw,
- int w, int h, ImlibColorModifier * cm)
-{
- int src_step = (srcw - w), dst_step = (dstw - w), ww = w;
-
- while (h--)
- {
- while (w--)
- {
- DATA32 tmp;
-
- ADD_COPY(R_VAL(src), G_VAL(src), B_VAL(src), dst);
- src++; dst++;
- }
- src += src_step;
- dst += dst_step;
- w = ww;
- }
-}
-
-static void
-__imlib_AddCopyRGBAToRGBA(DATA32 * src, int srcw, DATA32 * dst, int dstw,
- int w, int h, ImlibColorModifier * cm)
-{
- int src_step = (srcw - w), dst_step = (dstw - w), ww = w;
-
- while (h--)
- {
- while (w--)
- {
- DATA32 tmp;
-
- A_VAL(dst) = A_VAL(src);
- ADD_COPY(R_VAL(src), G_VAL(src), B_VAL(src), dst);
- src++; dst++;
- }
- src += src_step;
- dst += dst_step;
- w = ww;
- }
-}
-
-static void
-__imlib_AddCopyRGBToRGBA(DATA32 * src, int srcw, DATA32 * dst, int dstw,
- int w, int h, ImlibColorModifier * cm)
-{
- int src_step = (srcw - w), dst_step = (dstw - w), ww = w;
-
- while (h--)
- {
- while (w--)
- {
- DATA32 tmp;
-
- A_VAL(dst) = 0xff;
- ADD_COPY(R_VAL(src), G_VAL(src), B_VAL(src), dst);
- src++; dst++;
- }
- src += src_step;
- dst += dst_step;
- w = ww;
- }
-}
-
-
-/* SUBTRACT OPS */
-
-static void
-__imlib_SubBlendRGBAToRGB(DATA32 * src, int srcw, DATA32 * dst, int dstw,
- int w, int h, ImlibColorModifier * cm)
-{
- int src_step = (srcw - w), dst_step = (dstw - w), ww = w;
-
- while (h--)
- {
- while (w--)
- {
- DATA32 tmp;
- DATA8 a;
-
- a = A_VAL(src);
- switch (a)
- {
- case 0:
- break;
- case 255:
- SUB_COPY(R_VAL(src), G_VAL(src), B_VAL(src), dst);
- break;
- default:
- BLEND_SUB(R_VAL(src), G_VAL(src), B_VAL(src), a, dst);
- break;
- }
- src++; dst++;
- }
- src += src_step;
- dst += dst_step;
- w = ww;
- }
-}
-
-static void
-__imlib_SubBlendRGBAToRGBA(DATA32 * src, int srcw, DATA32 * dst, int dstw,
- int w, int h, ImlibColorModifier * cm)
-{
- int src_step = (srcw - w), dst_step = (dstw - w), ww = w;
-
- while (h--)
- {
- while (w--)
- {
- DATA32 tmp;
- DATA8 a, aa;
-
- aa = A_VAL(src);
- switch (aa)
- {
- case 0:
- break;
- case 255:
- A_VAL(dst) = 0xff;
- SUB_COPY(R_VAL(src), G_VAL(src), B_VAL(src), dst);
- break;
- default:
- a = pow_lut[aa][A_VAL(dst)];
- BLEND_COLOR(aa, A_VAL(dst), 255, A_VAL(dst));
- BLEND_SUB(R_VAL(src), G_VAL(src), B_VAL(src), a, dst);
- break;
- }
- src++; dst++;
- }
- src += src_step;
- dst += dst_step;
- w = ww;
- }
-}
-
-static void
-__imlib_SubCopyRGBAToRGB(DATA32 * src, int srcw, DATA32 * dst, int dstw,
- int w, int h, ImlibColorModifier * cm)
-{
- int src_step = (srcw - w), dst_step = (dstw - w), ww = w;
-
- while (h--)
- {
- while (w--)
- {
- DATA32 tmp;
-
- SUB_COPY(R_VAL(src), G_VAL(src), B_VAL(src), dst);
- src++; dst++;
- }
- src += src_step;
- dst += dst_step;
- w = ww;
- }
-}
-
-static void
-__imlib_SubCopyRGBAToRGBA(DATA32 * src, int srcw, DATA32 * dst, int dstw,
- int w, int h, ImlibColorModifier * cm)
-{
- int src_step = (srcw - w), dst_step = (dstw - w), ww = w;
-
- while (h--)
- {
- while (w--)
- {
- DATA32 tmp;
-
- A_VAL(dst) = A_VAL(src);
- SUB_COPY(R_VAL(src), G_VAL(src), B_VAL(src), dst);
- src++; dst++;
- }
- src += src_step;
- dst += dst_step;
- w = ww;
- }
-}
-
-static void
-__imlib_SubCopyRGBToRGBA(DATA32 * src, int srcw, DATA32 * dst, int dstw,
- int w, int h, ImlibColorModifier * cm)
-{
- int src_step = (srcw - w), dst_step = (dstw - w), ww = w;
-
- while (h--)
- {
- while (w--)
- {
- DATA32 tmp;
-
- A_VAL(dst) = 0xff;
- SUB_COPY(R_VAL(src), G_VAL(src), B_VAL(src), dst);
- src++; dst++;
- }
- src += src_step;
- dst += dst_step;
- w = ww;
- }
-}
-
-/* RESHADE OPS */
-
-static void
-__imlib_ReBlendRGBAToRGB(DATA32 * src, int srcw, DATA32 * dst, int dstw,
- int w, int h, ImlibColorModifier * cm)
-{
- int src_step = (srcw - w), dst_step = (dstw - w), ww = w;
-
- while (h--)
- {
- while (w--)
- {
- DATA32 tmp;
- DATA8 a;
-
- a = A_VAL(src);
- switch (a)
- {
- case 0:
- break;
- case 255:
- RE_COPY(R_VAL(src), G_VAL(src), B_VAL(src), dst);
- break;
- default:
- BLEND_RE(R_VAL(src), G_VAL(src), B_VAL(src), a, dst);
- break;
- }
- src++; dst++;
- }
- src += src_step;
- dst += dst_step;
- w = ww;
- }
-}
-
-static void
-__imlib_ReBlendRGBAToRGBA(DATA32 * src, int srcw, DATA32 * dst, int dstw,
- int w, int h, ImlibColorModifier * cm)
-{
- int src_step = (srcw - w), dst_step = (dstw - w), ww = w;
-
- while (h--)
- {
- while (w--)
- {
- DATA32 tmp;
- DATA8 a, aa;
-
- aa = A_VAL(src);
- switch (aa)
- {
- case 0:
- break;
- case 255:
- A_VAL(dst) = 0xff;
- RE_COPY(R_VAL(src), G_VAL(src), B_VAL(src), dst);
- break;
- default:
- a = pow_lut[aa][A_VAL(dst)];
- BLEND_COLOR(aa, A_VAL(dst), 255, A_VAL(dst));
- BLEND_RE(R_VAL(src), G_VAL(src), B_VAL(src), a, dst);
- break;
- }
- src++; dst++;
- }
- src += src_step;
- dst += dst_step;
- w = ww;
- }
-}
-
-static void
-__imlib_ReCopyRGBAToRGB(DATA32 * src, int srcw, DATA32 * dst, int dstw,
- int w, int h, ImlibColorModifier * cm)
-{
- int src_step = (srcw - w), dst_step = (dstw - w), ww = w;
-
- while (h--)
- {
- while (w--)
- {
- DATA32 tmp;
-
- RE_COPY(R_VAL(src), G_VAL(src), B_VAL(src), dst);
- src++; dst++;
- }
- src += src_step;
- dst += dst_step;
- w = ww;
- }
-}
-
-
-static void
-__imlib_ReCopyRGBAToRGBA(DATA32 * src, int srcw, DATA32 * dst, int dstw,
- int w, int h, ImlibColorModifier * cm)
-{
- int src_step = (srcw - w), dst_step = (dstw - w), ww = w;
-
- while (h--)
- {
- while (w--)
- {
- DATA32 tmp;
-
- A_VAL(dst) = A_VAL(src);
- RE_COPY(R_VAL(src), G_VAL(src), B_VAL(src), dst);
- src++; dst++;
- }
- src += src_step;
- dst += dst_step;
- w = ww;
- }
-}
-
-static void
-__imlib_ReCopyRGBToRGBA(DATA32 * src, int srcw, DATA32 * dst, int dstw,
- int w, int h, ImlibColorModifier * cm)
-{
- int src_step = (srcw - w), dst_step = (dstw - w), ww = w;
-
- while (h--)
- {
- while (w--)
- {
- DATA32 tmp;
-
- A_VAL(dst) = 0xff;
- RE_COPY(R_VAL(src), G_VAL(src), B_VAL(src), dst);
- src++; dst++;
- }
- src += src_step;
- dst += dst_step;
- w = ww;
- }
-}
-
-
-/* WITH COLOMOD */
-/* COPY OPS */
-
-static void
-__imlib_BlendRGBAToRGBCmod(DATA32 * src, int srcw, DATA32 * dst, int dstw,
- int w, int h, ImlibColorModifier * cm)
-{
- int src_step = (srcw - w), dst_step = (dstw - w), ww = w;
- DATA8 *amod = cm->alpha_mapping, *rmod = cm->red_mapping,
- *gmod = cm->green_mapping, *bmod = cm->blue_mapping;
-
- while (h--)
- {
- while (w--)
- {
- DATA32 tmp;
- DATA8 a;
-
- a = amod[A_VAL(src)];
- switch (a)
- {
- case 0:
- break;
- case 255:
- R_VAL(dst) = rmod[R_VAL(src)];
- G_VAL(dst) = gmod[G_VAL(src)];
- B_VAL(dst) = bmod[B_VAL(src)];
- break;
- default:
- BLEND(rmod[R_VAL(src)], gmod[G_VAL(src)], bmod[B_VAL(src)], a, dst);
- break;
- }
- src++; dst++;
- }
- src += src_step;
- dst += dst_step;
- w = ww;
- }
-}
-
-static void
-__imlib_BlendRGBAToRGBACmod(DATA32 * src, int srcw, DATA32 * dst, int dstw,
- int w, int h, ImlibColorModifier * cm)
-{
- int src_step = (srcw - w), dst_step = (dstw - w), ww = w;
- DATA8 *amod = cm->alpha_mapping, *rmod = cm->red_mapping,
- *gmod = cm->green_mapping, *bmod = cm->blue_mapping;
-
- while (h--)
- {
- while (w--)
- {
- DATA32 tmp;
- DATA8 a, aa;
-
- aa = amod[A_VAL(src)];
- switch (aa)
- {
- case 0:
- break;
- case 255:
- A_VAL(dst) = 0xff;
- R_VAL(dst) = rmod[R_VAL(src)];
- G_VAL(dst) = gmod[G_VAL(src)];
- B_VAL(dst) = bmod[B_VAL(src)];
- break;
- default:
- a = pow_lut[aa][A_VAL(dst)];
- BLEND_COLOR(aa, A_VAL(dst), 255, A_VAL(dst));
- BLEND(rmod[R_VAL(src)], gmod[G_VAL(src)], bmod[B_VAL(src)], a, dst);
- break;
- }
- src++; dst++;
- }
- src += src_step;
- dst += dst_step;
- w = ww;
- }
-}
-
-static void
-__imlib_BlendRGBToRGBACmod(DATA32 * src, int srcw, DATA32 * dst, int dstw,
- int w, int h, ImlibColorModifier * cm)
-{
- int src_step = (srcw - w), dst_step = (dstw - w), ww = w;
- DATA8 *amod = cm->alpha_mapping, *rmod = cm->red_mapping,
- *gmod = cm->green_mapping, *bmod = cm->blue_mapping;
- DATA8 am = amod[255];
-
- while (h--)
- {
- while (w--)
- {
- DATA32 tmp;
- DATA8 a;
-
- a = pow_lut[am][A_VAL(dst)];
- BLEND_COLOR(am, A_VAL(dst), 255, A_VAL(dst))
- BLEND(rmod[R_VAL(src)], gmod[G_VAL(src)], bmod[B_VAL(src)], a, dst);
- src++; dst++;
- }
- src += src_step;
- dst += dst_step;
- w = ww;
- }
-}
-
-static void
-__imlib_BlendRGBToRGBCmod(DATA32 * src, int srcw, DATA32 * dst, int dstw,
- int w, int h, ImlibColorModifier * cm)
-{
- int src_step = (srcw - w), dst_step = (dstw - w), ww = w;
- DATA8 *amod = cm->alpha_mapping, *rmod = cm->red_mapping,
- *gmod = cm->green_mapping, *bmod = cm->blue_mapping;
- DATA8 am = amod[255];
-
- while (h--)
- {
- while (w--)
- {
- DATA32 tmp;
-
- BLEND(rmod[R_VAL(src)], gmod[G_VAL(src)], bmod[B_VAL(src)], am, dst);
- src++; dst++;
- }
- src += src_step;
- dst += dst_step;
- w = ww;
- }
-}
-
-static void
-__imlib_CopyRGBAToRGBCmod(DATA32 * src, int srcw, DATA32 * dst, int dstw,
- int w, int h, ImlibColorModifier * cm)
-{
- int src_step = (srcw - w), dst_step = (dstw - w), ww = w;
- DATA8 *amod = cm->alpha_mapping, *rmod = cm->red_mapping,
- *gmod = cm->green_mapping, *bmod = cm->blue_mapping;
-
- while (h--)
- {
- while (w--)
- {
- R_VAL(dst) = rmod[R_VAL(src)];
- G_VAL(dst) = gmod[G_VAL(src)];
- B_VAL(dst) = bmod[B_VAL(src)];
- src++; dst++;
- }
- src += src_step;
- dst += dst_step;
- w = ww;
- }
-}
-
-static void
-__imlib_CopyRGBToRGBACmod(DATA32 * src, int srcw, DATA32 * dst, int dstw,
- int w, int h, ImlibColorModifier * cm)
-{
- int src_step = (srcw - w), dst_step = (dstw - w), ww = w;
- DATA8 *amod = cm->alpha_mapping, *rmod = cm->red_mapping,
- *gmod = cm->green_mapping, *bmod = cm->blue_mapping;
- DATA8 am = amod[255];
-
- while (h--)
- {
- while (w--)
- {
- A_VAL(dst) = am;
- R_VAL(dst) = rmod[R_VAL(src)];
- G_VAL(dst) = gmod[G_VAL(src)];
- B_VAL(dst) = bmod[B_VAL(src)];
- src++; dst++;
- }
- src += src_step;
- dst += dst_step;
- w = ww;
- }
-}
-
-static void
-__imlib_CopyRGBAToRGBACmod(DATA32 * src, int srcw, DATA32 * dst, int dstw,
- int w, int h, ImlibColorModifier * cm)
-{
- int src_step = (srcw - w), dst_step = (dstw - w), ww = w;
- DATA8 *amod = cm->alpha_mapping, *rmod = cm->red_mapping,
- *gmod = cm->green_mapping, *bmod = cm->blue_mapping;
-
- while (h--)
- {
- while (w--)
- {
- A_VAL(dst) = amod[A_VAL(src)];
- R_VAL(dst) = rmod[R_VAL(src)];
- G_VAL(dst) = gmod[G_VAL(src)];
- B_VAL(dst) = bmod[B_VAL(src)];
- src++; dst++;
- }
- src += src_step;
- dst += dst_step;
- w = ww;
- }
-}
-
-
-/* ADD OPS */
-
-static void
-__imlib_AddBlendRGBAToRGBCmod(DATA32 * src, int srcw, DATA32 * dst, int dstw,
- int w, int h, ImlibColorModifier * cm)
-{
- int src_step = (srcw - w), dst_step = (dstw - w), ww = w;
- DATA8 *amod = cm->alpha_mapping, *rmod = cm->red_mapping,
- *gmod = cm->green_mapping, *bmod = cm->blue_mapping;
-
- while (h--)
- {
- while (w--)
- {
- DATA32 tmp;
- DATA8 a;
-
- a = amod[A_VAL(src)];
- switch (a)
- {
- case 0:
- break;
- case 255:
- ADD_COPY(rmod[R_VAL(src)], gmod[G_VAL(src)], bmod[B_VAL(src)], dst);
- break;
- default:
- BLEND_ADD(rmod[R_VAL(src)], gmod[G_VAL(src)], bmod[B_VAL(src)], a, dst);
- break;
- }
- src++; dst++;
- }
- src += src_step;
- dst += dst_step;
- w = ww;
- }
-}
-
-static void
-__imlib_AddBlendRGBAToRGBACmod(DATA32 * src, int srcw, DATA32 * dst, int dstw,
- int w, int h, ImlibColorModifier * cm)
-{
- int src_step = (srcw - w), dst_step = (dstw - w), ww = w;
- DATA8 *amod = cm->alpha_mapping, *rmod = cm->red_mapping,
- *gmod = cm->green_mapping, *bmod = cm->blue_mapping;
-
- while (h--)
- {
- while (w--)
- {
- DATA32 tmp;
- DATA8 a, aa;
-
- aa = amod[A_VAL(src)];
- switch (aa)
- {
- case 0:
- break;
- case 255:
- A_VAL(dst) = 0xff;
- ADD_COPY(rmod[R_VAL(src)], gmod[G_VAL(src)], bmod[B_VAL(src)], dst);
- break;
- default:
- a = pow_lut[aa][A_VAL(dst)];
- BLEND_COLOR(aa, A_VAL(dst), 255, A_VAL(dst));
- BLEND_ADD(rmod[R_VAL(src)], gmod[G_VAL(src)], bmod[B_VAL(src)], a, dst);
- break;
- }
- src++; dst++;
- }
- src += src_step;
- dst += dst_step;
- w = ww;
- }
-}
-
-static void
-__imlib_AddBlendRGBToRGBCmod(DATA32 * src, int srcw, DATA32 * dst, int dstw,
- int w, int h, ImlibColorModifier * cm)
-{
- int src_step = (srcw - w), dst_step = (dstw - w), ww = w;
- DATA8 *amod = cm->alpha_mapping, *rmod = cm->red_mapping,
- *gmod = cm->green_mapping, *bmod = cm->blue_mapping;
- DATA8 am = amod[255];
-
- while (h--)
- {
- while (w--)
- {
- DATA32 tmp;
-
- BLEND_ADD(rmod[R_VAL(src)], gmod[G_VAL(src)], bmod[B_VAL(src)], am, dst);
- src++; dst++;
- }
- src += src_step;
- dst += dst_step;
- w = ww;
- }
-}
-
-static void
-__imlib_AddBlendRGBToRGBACmod(DATA32 * src, int srcw, DATA32 * dst, int dstw,
- int w, int h, ImlibColorModifier * cm)
-{
- int src_step = (srcw - w), dst_step = (dstw - w), ww = w;
- DATA8 *amod = cm->alpha_mapping, *rmod = cm->red_mapping,
- *gmod = cm->green_mapping, *bmod = cm->blue_mapping;
- DATA8 am = amod[255];
-
- while (h--)
- {
- while (w--)
- {
- DATA32 tmp;
- DATA8 a;
-
- a = pow_lut[am][A_VAL(dst)];
- BLEND_COLOR(am, A_VAL(dst), 255, A_VAL(dst));
- BLEND_ADD(rmod[R_VAL(src)], gmod[G_VAL(src)], bmod[B_VAL(src)], a, dst);
- src++; dst++;
- }
- src += src_step;
- dst += dst_step;
- w = ww;
- }
-}
-
-static void
-__imlib_AddCopyRGBAToRGBCmod(DATA32 * src, int srcw, DATA32 * dst, int dstw,
- int w, int h, ImlibColorModifier * cm)
-{
- int src_step = (srcw - w), dst_step = (dstw - w), ww = w;
- DATA8 *amod = cm->alpha_mapping, *rmod = cm->red_mapping,
- *gmod = cm->green_mapping, *bmod = cm->blue_mapping;
-
- while (h--)
- {
- while (w--)
- {
- DATA32 tmp;
-
- ADD_COPY(rmod[R_VAL(src)], gmod[G_VAL(src)], bmod[B_VAL(src)], dst);
- src++; dst++;
- }
- src += src_step;
- dst += dst_step;
- w = ww;
- }
-}
-
-static void
-__imlib_AddCopyRGBAToRGBACmod(DATA32 * src, int srcw, DATA32 * dst, int dstw,
- int w, int h, ImlibColorModifier * cm)
-{
- int src_step = (srcw - w), dst_step = (dstw - w), ww = w;
- DATA8 *amod = cm->alpha_mapping, *rmod = cm->red_mapping,
- *gmod = cm->green_mapping, *bmod = cm->blue_mapping;
-
- while (h--)
- {
- while (w--)
- {
- DATA32 tmp;
-
- A_VAL(dst) = amod[A_VAL(src)];
- ADD_COPY(rmod[R_VAL(src)], gmod[G_VAL(src)], bmod[B_VAL(src)], dst);
- src++; dst++;
- }
- src += src_step;
- dst += dst_step;
- w = ww;
- }
-}
-
-static void
-__imlib_AddCopyRGBToRGBACmod(DATA32 * src, int srcw, DATA32 * dst, int dstw,
- int w, int h, ImlibColorModifier * cm)
-{
- int src_step = (srcw - w), dst_step = (dstw - w), ww = w;
- DATA8 *amod = cm->alpha_mapping, *rmod = cm->red_mapping,
- *gmod = cm->green_mapping, *bmod = cm->blue_mapping;
- DATA8 am = amod[255];
-
- while (h--)
- {
- while (w--)
- {
- DATA32 tmp;
-
- A_VAL(dst) = am;
- ADD_COPY(rmod[R_VAL(src)], gmod[G_VAL(src)], bmod[B_VAL(src)], dst);
- src++; dst++;
- }
- src += src_step;
- dst += dst_step;
- w = ww;
- }
-}
-
-
-/* SUBTRACT OPS */
-
-static void
-__imlib_SubBlendRGBAToRGBCmod(DATA32 * src, int srcw, DATA32 * dst, int dstw,
- int w, int h, ImlibColorModifier * cm)
-{
- int src_step = (srcw - w), dst_step = (dstw - w), ww = w;
- DATA8 *amod = cm->alpha_mapping, *rmod = cm->red_mapping,
- *gmod = cm->green_mapping, *bmod = cm->blue_mapping;
-
- while (h--)
- {
- while (w--)
- {
- DATA32 tmp;
- DATA8 a;
-
- a = amod[A_VAL(src)];
- switch (a)
- {
- case 0:
- break;
- case 255:
- SUB_COPY(rmod[R_VAL(src)], gmod[G_VAL(src)], bmod[B_VAL(src)], dst);
- break;
- default:
- BLEND_SUB(rmod[R_VAL(src)], gmod[G_VAL(src)], bmod[B_VAL(src)], a, dst);
- break;
- }
- src++; dst++;
- }
- src += src_step;
- dst += dst_step;
- w = ww;
- }
-}
-
-static void
-__imlib_SubBlendRGBAToRGBACmod(DATA32 * src, int srcw, DATA32 * dst, int dstw,
- int w, int h, ImlibColorModifier * cm)
-{
- int src_step = (srcw - w), dst_step = (dstw - w), ww = w;
- DATA8 *amod = cm->alpha_mapping, *rmod = cm->red_mapping,
- *gmod = cm->green_mapping, *bmod = cm->blue_mapping;
-
- while (h--)
- {
- while (w--)
- {
- DATA32 tmp;
- DATA8 a, aa;
-
- aa = amod[A_VAL(src)];
- switch (aa)
- {
- case 0:
- break;
- case 255:
- A_VAL(dst) = 0xff;
- SUB_COPY(rmod[R_VAL(src)], gmod[G_VAL(src)], bmod[B_VAL(src)], dst);
- break;
- default:
- a = pow_lut[aa][A_VAL(dst)];
- BLEND_COLOR(aa, A_VAL(dst), 255, A_VAL(dst));
- BLEND_SUB(rmod[R_VAL(src)], gmod[G_VAL(src)], bmod[B_VAL(src)], a, dst);
- break;
- }
- src++; dst++;
- }
- src += src_step;
- dst += dst_step;
- w = ww;
- }
-}
-
-static void
-__imlib_SubBlendRGBToRGBCmod(DATA32 * src, int srcw, DATA32 * dst, int dstw,
- int w, int h, ImlibColorModifier * cm)
-{
- int src_step = (srcw - w), dst_step = (dstw - w), ww = w;
- DATA8 *amod = cm->alpha_mapping, *rmod = cm->red_mapping,
- *gmod = cm->green_mapping, *bmod = cm->blue_mapping;
- DATA8 am = amod[255];
-
- while (h--)
- {
- while (w--)
- {
- DATA32 tmp;
-
- BLEND_SUB(rmod[R_VAL(src)], gmod[G_VAL(src)], bmod[B_VAL(src)], am, dst);
- src++; dst++;
- }
- src += src_step;
- dst += dst_step;
- w = ww;
- }
-}
-
-static void
-__imlib_SubBlendRGBToRGBACmod(DATA32 * src, int srcw, DATA32 * dst, int dstw,
- int w, int h, ImlibColorModifier * cm)
-{
- int src_step = (srcw - w), dst_step = (dstw - w), ww = w;
- DATA8 *amod = cm->alpha_mapping, *rmod = cm->red_mapping,
- *gmod = cm->green_mapping, *bmod = cm->blue_mapping;
- DATA8 am = amod[255];
-
- while (h--)
- {
- while (w--)
- {
- DATA32 tmp;
- DATA8 a;
-
- a = pow_lut[am][A_VAL(dst)];
- BLEND_COLOR(am, A_VAL(dst), 255, A_VAL(dst));
- BLEND_SUB(rmod[R_VAL(src)], gmod[G_VAL(src)], bmod[B_VAL(src)], a, dst);
- src++; dst++;
- }
- src += src_step;
- dst += dst_step;
- w = ww;
- }
-}
-
-static void
-__imlib_SubCopyRGBAToRGBCmod(DATA32 * src, int srcw, DATA32 * dst, int dstw,
- int w, int h, ImlibColorModifier * cm)
-{
- int src_step = (srcw - w), dst_step = (dstw - w), ww = w;
- DATA8 *amod = cm->alpha_mapping, *rmod = cm->red_mapping,
- *gmod = cm->green_mapping, *bmod = cm->blue_mapping;
-
- while (h--)
- {
- while (w--)
- {
- DATA32 tmp;
-
- SUB_COPY(rmod[R_VAL(src)], gmod[G_VAL(src)], bmod[B_VAL(src)], dst);
- src++; dst++;
- }
- src += src_step;
- dst += dst_step;
- w = ww;
- }
-}
-
-static void
-__imlib_SubCopyRGBAToRGBACmod(DATA32 * src, int srcw, DATA32 * dst, int dstw,
- int w, int h, ImlibColorModifier * cm)
-{
- int src_step = (srcw - w), dst_step = (dstw - w), ww = w;
- DATA8 *amod = cm->alpha_mapping, *rmod = cm->red_mapping,
- *gmod = cm->green_mapping, *bmod = cm->blue_mapping;
-
- while (h--)
- {
- while (w--)
- {
- DATA32 tmp;
-
- A_VAL(dst) = amod[A_VAL(src)];
- SUB_COPY(rmod[R_VAL(src)], gmod[G_VAL(src)], bmod[B_VAL(src)], dst);
- src++; dst++;
- }
- src += src_step;
- dst += dst_step;
- w = ww;
- }
-}
-
-static void
-__imlib_SubCopyRGBToRGBACmod(DATA32 * src, int srcw, DATA32 * dst, int dstw,
- int w, int h, ImlibColorModifier * cm)
-{
- int src_step = (srcw - w), dst_step = (dstw - w), ww = w;
- DATA8 *amod = cm->alpha_mapping, *rmod = cm->red_mapping,
- *gmod = cm->green_mapping, *bmod = cm->blue_mapping;
- DATA8 am = amod[255];
-
- while (h--)
- {
- while (w--)
- {
- DATA32 tmp;
-
- A_VAL(dst) = am;
- SUB_COPY(rmod[R_VAL(src)], gmod[G_VAL(src)], bmod[B_VAL(src)], dst);
- src++; dst++;
- }
- src += src_step;
- dst += dst_step;
- w = ww;
- }
-}
-
-
-/* RESHADE OPS */
-
-static void
-__imlib_ReBlendRGBAToRGBCmod(DATA32 * src, int srcw, DATA32 * dst, int dstw,
- int w, int h, ImlibColorModifier * cm)
-{
- int src_step = (srcw - w), dst_step = (dstw - w), ww = w;
- DATA8 *amod = cm->alpha_mapping, *rmod = cm->red_mapping,
- *gmod = cm->green_mapping, *bmod = cm->blue_mapping;
-
- while (h--)
- {
- while (w--)
- {
- DATA32 tmp;
- DATA8 a;
-
- a = amod[A_VAL(src)];
- switch (a)
- {
- case 0:
- break;
- case 255:
- RE_COPY(rmod[R_VAL(src)], gmod[G_VAL(src)], bmod[B_VAL(src)], dst);
- break;
- default:
- BLEND_RE(rmod[R_VAL(src)], gmod[G_VAL(src)], bmod[B_VAL(src)], a, dst);
- break;
- }
- src++; dst++;
- }
- src += src_step;
- dst += dst_step;
- w = ww;
- }
-}
-
-static void
-__imlib_ReBlendRGBAToRGBACmod(DATA32 * src, int srcw, DATA32 * dst, int dstw,
- int w, int h, ImlibColorModifier * cm)
-{
- int src_step = (srcw - w), dst_step = (dstw - w), ww = w;
- DATA8 *amod = cm->alpha_mapping, *rmod = cm->red_mapping,
- *gmod = cm->green_mapping, *bmod = cm->blue_mapping;
-
- while (h--)
- {
- while (w--)
- {
- DATA32 tmp;
- DATA8 a, aa;
-
- aa = amod[A_VAL(src)];
- switch (aa)
- {
- case 0:
- break;
- case 255:
- A_VAL(dst) = 0xff;
- RE_COPY(rmod[R_VAL(src)], gmod[G_VAL(src)], bmod[B_VAL(src)], dst);
- break;
- default:
- a = pow_lut[aa][A_VAL(dst)];
- BLEND_COLOR(aa, A_VAL(dst), 255, A_VAL(dst));
- BLEND_RE(rmod[R_VAL(src)], gmod[G_VAL(src)], bmod[B_VAL(src)], a, dst);
- }
- src++; dst++;
- }
- src += src_step;
- dst += dst_step;
- w = ww;
- }
-}
-
-static void
-__imlib_ReBlendRGBToRGBCmod(DATA32 * src, int srcw, DATA32 * dst, int dstw,
- int w, int h, ImlibColorModifier * cm)
-{
- int src_step = (srcw - w), dst_step = (dstw - w), ww = w;
- DATA8 *amod = cm->alpha_mapping, *rmod = cm->red_mapping,
- *gmod = cm->green_mapping, *bmod = cm->blue_mapping;
- DATA8 am = amod[255];
-
- while (h--)
- {
- while (w--)
- {
- DATA32 tmp;
-
- BLEND_RE(rmod[R_VAL(src)], gmod[G_VAL(src)], bmod[B_VAL(src)], am, dst);
- src++; dst++;
- }
- src += src_step;
- dst += dst_step;
- w = ww;
- }
-}
-
-static void
-__imlib_ReBlendRGBToRGBACmod(DATA32 * src, int srcw, DATA32 * dst, int dstw,
- int w, int h, ImlibColorModifier * cm)
-{
- int src_step = (srcw - w), dst_step = (dstw - w), ww = w;
- DATA8 *amod = cm->alpha_mapping, *rmod = cm->red_mapping,
- *gmod = cm->green_mapping, *bmod = cm->blue_mapping;
- DATA8 am = amod[255];
-
- while (h--)
- {
- while (w--)
- {
- DATA32 tmp;
- DATA8 a;
-
- a = pow_lut[am][A_VAL(dst)];
- BLEND_COLOR(am, A_VAL(dst), 255, A_VAL(dst));
- BLEND_RE(rmod[R_VAL(src)], gmod[G_VAL(src)], bmod[B_VAL(src)], a, dst);
- src++; dst++;
- }
- src += src_step;
- dst += dst_step;
- w = ww;
- }
-}
-
-static void
-__imlib_ReCopyRGBAToRGBCmod(DATA32 * src, int srcw, DATA32 * dst, int dstw,
- int w, int h, ImlibColorModifier * cm)
-{
- int src_step = (srcw - w), dst_step = (dstw - w), ww = w;
- DATA8 *amod = cm->alpha_mapping, *rmod = cm->red_mapping,
- *gmod = cm->green_mapping, *bmod = cm->blue_mapping;
-
- while (h--)
- {
- while (w--)
- {
- DATA32 tmp;
-
- RE_COPY(rmod[R_VAL(src)], gmod[G_VAL(src)], bmod[B_VAL(src)], dst);
- src++; dst++;
- }
- src += src_step;
- dst += dst_step;
- w = ww;
- }
-}
-
-static void
-__imlib_ReCopyRGBAToRGBACmod(DATA32 * src, int srcw, DATA32 * dst, int dstw,
- int w, int h, ImlibColorModifier * cm)
-{
- int src_step = (srcw - w), dst_step = (dstw - w), ww = w;
- DATA8 *amod = cm->alpha_mapping, *rmod = cm->red_mapping,
- *gmod = cm->green_mapping, *bmod = cm->blue_mapping;
-
- while (h--)
- {
- while (w--)
- {
- DATA32 tmp;
-
- A_VAL(dst) = amod[A_VAL(src)];
- RE_COPY(rmod[R_VAL(src)], gmod[G_VAL(src)], bmod[B_VAL(src)], dst);
- src++; dst++;
- }
- src += src_step;
- dst += dst_step;
- w = ww;
- }
-}
-
-static void
-__imlib_ReCopyRGBToRGBACmod(DATA32 * src, int srcw, DATA32 * dst, int dstw,
- int w, int h, ImlibColorModifier * cm)
-{
- int src_step = (srcw - w), dst_step = (dstw - w), ww = w;
- DATA8 *amod = cm->alpha_mapping, *rmod = cm->red_mapping,
- *gmod = cm->green_mapping, *bmod = cm->blue_mapping;
- DATA8 am = amod[255];
-
- while (h--)
- {
- while (w--)
- {
- DATA32 tmp;
-
- A_VAL(dst) = am;
- RE_COPY(rmod[R_VAL(src)], gmod[G_VAL(src)], bmod[B_VAL(src)], dst);
- src++; dst++;
- }
- src += src_step;
- dst += dst_step;
- w = ww;
- }
-}
-
-
-/*\ Equivalent functions \*/
-
-#define __imlib_CopyRGBToRGB __imlib_CopyRGBToRGBA
-#define __imlib_BlendRGBToRGB __imlib_CopyRGBToRGB
-#define __imlib_BlendRGBToRGBA __imlib_CopyRGBToRGBA
-#define __imlib_mmx_copy_rgb_to_rgb __imlib_mmx_copy_rgb_to_rgba
-#define __imlib_mmx_blend_rgb_to_rgb __imlib_mmx_copy_rgb_to_rgb
-#define __imlib_mmx_blend_rgb_to_rgba __imlib_mmx_copy_rgb_to_rgba
-#define __imlib_CopyRGBToRGBCmod __imlib_CopyRGBAToRGBCmod
-#define __imlib_mmx_copy_rgb_to_rgb_cmod __imlib_mmx_copy_rgba_to_rgb_cmod
-
-#define __imlib_AddCopyRGBToRGB __imlib_AddCopyRGBAToRGB
-#define __imlib_AddBlendRGBToRGB __imlib_AddCopyRGBToRGB
-#define __imlib_AddBlendRGBToRGBA __imlib_AddCopyRGBToRGBA
-#define __imlib_mmx_add_copy_rgb_to_rgb __imlib_mmx_add_copy_rgba_to_rgb
-#define __imlib_mmx_add_blend_rgb_to_rgb __imlib_mmx_add_copy_rgb_to_rgb
-#define __imlib_mmx_add_blend_rgb_to_rgba __imlib_mmx_add_copy_rgb_to_rgba
-#define __imlib_AddCopyRGBToRGBCmod __imlib_AddCopyRGBAToRGBCmod
-#define __imlib_mmx_add_copy_rgb_to_rgb_cmod __imlib_mmx_add_copy_rgb_to_rgba_cmod
-
-#define __imlib_SubCopyRGBToRGB __imlib_SubCopyRGBAToRGB
-#define __imlib_SubBlendRGBToRGB __imlib_SubCopyRGBToRGB
-#define __imlib_SubBlendRGBToRGBA __imlib_SubCopyRGBToRGBA
-#define __imlib_mmx_subtract_copy_rgb_to_rgba __imlib_mmx_subtract_copy_rgba_to_rgba
-#define __imlib_mmx_subtract_copy_rgb_to_rgb __imlib_mmx_subtract_copy_rgba_to_rgb
-#define __imlib_mmx_subtract_blend_rgb_to_rgb __imlib_mmx_subtract_copy_rgb_to_rgb
-#define __imlib_mmx_subtract_blend_rgb_to_rgba __imlib_mmx_subtract_copy_rgb_to_rgba
-#define __imlib_SubCopyRGBToRGBCmod __imlib_SubCopyRGBAToRGBCmod
-#define __imlib_mmx_subtract_copy_rgb_to_rgb_cmod __imlib_mmx_subtract_copy_rgb_to_rgba_cmod
-
-#define __imlib_ReCopyRGBToRGB __imlib_ReCopyRGBAToRGB
-#define __imlib_ReBlendRGBToRGB __imlib_ReCopyRGBToRGB
-#define __imlib_ReBlendRGBToRGBA __imlib_ReCopyRGBToRGBA
-#define __imlib_mmx_reshade_copy_rgb_to_rgba __imlib_mmx_reshade_copy_rgba_to_rgba
-#define __imlib_mmx_reshade_copy_rgb_to_rgb __imlib_mmx_reshade_copy_rgba_to_rgb
-#define __imlib_mmx_reshade_blend_rgb_to_rgb __imlib_mmx_reshade_copy_rgb_to_rgb
-#define __imlib_mmx_reshade_blend_rgb_to_rgba __imlib_mmx_reshade_copy_rgb_to_rgba
-#define __imlib_ReCopyRGBToRGBCmod __imlib_ReCopyRGBAToRGBCmod
-#define __imlib_mmx_reshade_copy_rgb_to_rgb_cmod __imlib_mmx_reshade_copy_rgb_to_rgba_cmod
-
-
-ImlibBlendFunction
-__imlib_GetBlendFunction(ImlibOp op, char blend, char merge_alpha, char rgb_src,
- ImlibColorModifier * cm)
-{
- /*\ [ 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}}}}},
-
-#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_BlendRGBToRGBACmod /*__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_AddCopyRGBAToRGBA /*__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_AddCopyRGBAToRGBACmod /*__imlib_mmx_add_copy_rgba_to_rgba_cmod*/,
- __imlib_AddBlendRGBAToRGBACmod
- /*__imlib_mmx_add_blend_rgba_to_rgba_cmod*/ },
- {__imlib_AddCopyRGBToRGBACmod /*__imlib_mmx_add_copy_rgb_to_rgba_cmod*/,
- __imlib_AddBlendRGBToRGBACmod /*__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_SubCopyRGBAToRGBA /*__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_SubCopyRGBAToRGBACmod /*__imlib_mmx_subtract_copy_rgba_to_rgba_cmod*/,
- __imlib_SubBlendRGBAToRGBACmod
- /*__imlib_mmx_subtract_blend_rgba_to_rgba_cmod*/ },
- {__imlib_SubCopyRGBToRGBACmod /*__imlib_mmx_subtract_copy_rgb_to_rgba_cmod*/,
- __imlib_SubBlendRGBToRGBACmod /*__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_ReCopyRGBAToRGBA /*__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_ReCopyRGBAToRGBACmod /*__imlib_mmx_reshade_copy_rgba_to_rgba_cmod*/,
- __imlib_ReBlendRGBAToRGBACmod
- /*__imlib_mmx_reshade_blend_rgba_to_rgba_cmod*/ },
- {__imlib_ReCopyRGBToRGBACmod /*__imlib_mmx_reshade_copy_rgb_to_rgba_cmod*/,
- __imlib_ReBlendRGBToRGBACmod /*__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;
-
- if (opi == -1)
- return NULL;
-
-#ifdef DO_MMX_ASM
- do_mmx = !!(__imlib_get_cpuid() & CPUID_MMX);
-#endif
- if (cm && rgb_src && (A_CMOD(cm, 0xff) == 0xff))
- blend = 0;
- if (blend && cm && rgb_src && (A_CMOD(cm, 0xff) == 0))
- return NULL;
- return ibfuncs[!!do_mmx][opi][!!cm][!!merge_alpha][!!rgb_src][!!blend];
-}
-
-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)
-{
- ImlibBlendFunction blender;
-
- if (sx < 0)
- {
- w += sx;
- dx -= sx;
- sx = 0;
- }
- if (sy < 0)
- {
- h += sy;
- dy -= sy;
- sy = 0;
- }
- if (dx < 0)
- {
- w += dx;
- sx -= dx;
- dx = 0;
- }
- if (dy < 0)
- {
- h += dy;
- sy -= dy;
- dy = 0;
- }
- if ((w <= 0) || (h <= 0))
- return;
- if ((sx + w) > src_w)
- w = src_w - sx;
- if ((sy + h) > src_h)
- h = src_h - sy;
- if ((dx + w) > dst_w)
- w = dst_w - dx;
- if ((dy + h) > dst_h)
- 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);
-}
-
-#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)
-{
- 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))
- im_dst->loader->load(im_dst, NULL, 0, 1);
- if (!im_src->data)
- return;
- if (!im_dst->data)
- return;
-
- 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);
- }
- 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 */
-#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;
- /* 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
-#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);
- }
-}
diff --git a/src/blend.h b/src/blend.h
deleted file mode 100644
index 77f4696..0000000
--- a/src/blend.h
+++ /dev/null
@@ -1,556 +0,0 @@
-#ifndef __BLEND
-#define __BLEND 1
-
-#ifndef WORDS_BIGENDIAN
-
-#define A_VAL(p) ((DATA8 *)(p))[3]
-#define R_VAL(p) ((DATA8 *)(p))[2]
-#define G_VAL(p) ((DATA8 *)(p))[1]
-#define B_VAL(p) ((DATA8 *)(p))[0]
-
-#else
-
-#define A_VAL(p) ((DATA8 *)(p))[0]
-#define R_VAL(p) ((DATA8 *)(p))[1]
-#define G_VAL(p) ((DATA8 *)(p))[2]
-#define B_VAL(p) ((DATA8 *)(p))[3]
-
-#endif
-
-/* FIXME: endian dependant */
-#define READ_RGB(p, r, g, b) \
- (r) = R_VAL(p); \
- (g) = G_VAL(p); \
- (b) = B_VAL(p);
-
-#define READ_ALPHA(p, a) \
- (a) = A_VAL(p);
-
-#define READ_RGBA(p, r, g, b, a) \
- (r) = R_VAL(p); \
- (g) = G_VAL(p); \
- (b) = B_VAL(p); \
- (a) = A_VAL(p);
-
-#define WRITE_RGB(p, r, g, b) \
- R_VAL(p) = (r); \
- G_VAL(p) = (g); \
- B_VAL(p) = (b);
-
-#define WRITE_RGB_PRESERVE_ALPHA(p, r, g, b) \
- WRITE_RGB(p, r, g, b)
-
-#define WRITE_RGBA(p, r, g, b, a) \
- R_VAL(p) = (r); \
- G_VAL(p) = (g); \
- B_VAL(p) = (b); \
- A_VAL(p) = (a);
-
-#define INTERSECTS(x, y, w, h, xx, yy, ww, hh) \
- ((x < (xx + ww)) && \
- (y < (yy + hh)) && \
- ((x + w) > xx) && \
- ((y + h) > yy))
-
-#define CLIP_TO(_x, _y, _w, _h, _cx, _cy, _cw, _ch) \
-{ \
-if (INTERSECTS(_x, _y, _w, _h, _cx, _cy, _cw, _ch)) \
- { \
- if (_x < _cx) \
- { \
- _w += _x - _cx; \
- _x = _cx; \
- if (_w < 0) _w = 0; \
- } \
- if ((_x + _w) > (_cx + _cw)) \
- _w = _cx + _cw - _x; \
- if (_y < _cy) \
- { \
- _h += _y - _cy; \
- _y = _cy; \
- if (_h < 0) _h = 0; \
- } \
- if ((_y + _h) > (_cy + _ch)) \
- _h = _cy + _ch - _y; \
- } \
-else \
- { \
- _w = 0; _h = 0; \
- } \
-}
-
-/*
- * 1) Basic Saturation - 8 bit unsigned
- *
- * The add, subtract, and reshade operations generate new color values that may
- * be out of range for an unsigned 8 bit quantity. Therefore, we will want to
- * saturate the values into the range [0, 255]. Any value < 0 will become 0,
- * and any value > 255 will become 255. Or simply:
- *
- * saturated = (value < 0) ? 0 : ((value > 255) ? 255 : value)
- *
- * Of course the above isn't the most efficient means of saturating. Sometimes
- * due to the nature of a calculation, we know we only need to saturate from
- * above (> 255) or just from below (< 0). Or simply:
- *
- * saturated = (value < 0) ? 0 : value
- * saturated = (value > 255) ? 255 : value
- *
- * 2) Alternate Forms of Saturation
- *
- * The methods of saturation described above use testing/branching operations,
- * which are not necessarily efficient on all platforms. There are other means
- * of performing saturation using just simple arithmetic operations
- * (+, -, >>, <<, ~). A discussion of these saturation techniques follows.
- *
- * A) Saturation in the range [0, 512), or "from above".
- *
- * Assuming we have an integral value in the range [0, 512), the following
- * formula evaluates to either 0, or 255:
- *
- * (value & 255) - ((value & 256) >> 8)
- *
- * This is easy to show. Notice that if the value is in the range [0, 256)
- * the 9th bit is 0, and we get (0 - 0), which is 0. And if the value is in
- * the range [256, 512) the 9th bit is 1, and we get (256 - 1), which is 255.
- *
- * Now, using the above information and the fact that assigning an integer to
- * an 8 bit unsigned value will truncate to the lower 8 bits of the integer,
- * the following properly saturates:
- *
- * 8bit_value = value | (value & 256) - ((value & 256) >> 8)
- *
- * To prove this to yourself, just think about what the lower 8 bits look like
- * in the ranges [0, 256) and [256, 512). In particular, notice that the value
- * in the range [0, 256) are unchanged, and values in the range [256, 512)
- * always give you 255. Just what we want!
- *
- * B) Saturation in the range (-256, 256), or "from below".
- *
- * Assuming we have an integral value in the range (-256, 256), the following
- * formula evaluates to either 0, or -1:
- *
- * ~(value >> 8)
- *
- * Here's why. If the value is in the range [0, 256), then shifting right by
- * 8 bits gives us all 0 bits, or 0. And thus inverting the bits gives all
- * 1 bits, which is -1. If the value is in the range (-256, 0), then the 9th
- * bit and higher bits are all 1. So, when we shift right by 8 bits (with
- * signed extension), we get a value with all 1 bits. Which when inverted is
- * all 0 bits, or 0.
- *
- * Now, using the above information the following properly saturates:
- *
- * 8bit_value = value & (~(value >> 8))
- *
- * To prove this to yourself, noticed that values in the range (-256, 0) will
- * always be AND'd with 0, and thus map to 0. Further, values in the range
- * [0, 256) will always be AND'd with a value that is all 1 bits, and thus
- * be unchanged. Just what we want!
- *
- * C) Saturation in the range (-256, 512), or "from above and below".
- *
- * The short of it is the following works:
- *
- * 8bit_value = (tmp | ((tmp & 256) - ((tmp & 256) >> 8))) & (~(tmp >> 9))
- *
- * We leave it to the reader to prove. Looks very similar to the techniques
- * used above, eh? :)
- */
-
-/* Saturate values in the range [0, 512) */
-#define SATURATE_UPPER(nc, v) \
- tmp = (v); \
- nc = (tmp | (-(tmp >> 8)));
-
-/* Saturate values in the range (-256, 256) */
-#define SATURATE_LOWER(nc, v) \
- tmp = (v); \
- nc = tmp & (~(tmp >> 8));
-
-/* Saturate values in the range (-256, 512) */
-#define SATURATE_BOTH(nc, v) \
- tmp = (v); \
- nc = (tmp | (-(tmp >> 8))) & (~(tmp >> 9));
-
-/*
- * 1) Operations
- *
- * There are 4 operations supported:
- *
- * Copy, Add, Subtract, and Reshade
- *
- * For each operation there are 3 different variations that can be made:
- *
- * a) Use "blend" or "copy" in the calculations? A "blend" uses the alpha
- * value of the source pixel to lighten the source pixel values. Where
- * as "copy" ignores the alpha value and uses the raw source pixel values.
- * b) Include source alpha in the calculation for new destination alpha?
- * If source alpha is not used, then destination alpha is preserved.
- * If source alpha is used, a "copy" sets the new alpha to the source
- * alpha, and a "blend" increases it by a factor given by the product
- * of the source alpha with one minus the destination alpha.
- * c) Should the source pixels be passed through a color modifier before the
- * calculations are performed?
- *
- * All together we have 4*2*2*2 = 32 combinations.
- *
- * 2) Copy operation
- *
- * The "copy" version of this operation copies the source image onto the
- * destination image.
- *
- * The "blend" version of this operation blends the source image color 'c' with
- * the destination image color 'cc' using 'a' (in the range [0, 1]) according
- * to the following formula. Also notice that saturation is not needed for
- * this calculation, the output is in the range [0, 255]:
- *
- * nc = c * alpha + (1 - alpha) * cc
- * = c * alpha - cc * alpha + cc
- * = (c - cc) * alpha + cc;
- *
- * A discussion of how we're calculating this value follows:
- *
- * We're using 'a', an integer, in the range [0, 255] for alpha (and for 'c'
- * and 'cc', BTW). Therefore, we need to slightly modify the equation to take
- * that into account. To get into the range [0, 255] we need to divide 'a'
- * by 255:
- *
- * nc = ((c - cc) * a) / 255 + cc
- *
- * Notice that it is faster to divide by 256 (bit shifting), however without a
- * fudge factor 'x' to balance things this isn't horribly accurate. So, let's
- * solve for 'x'. The equality is:
- *
- * ((c - cc) * a) / 256 + cc + x = ((c - cc) * a) / 255 + cc
- *
- * The 'cc' terms cancel, and multiply both sides by 255*256 to remove the
- * fractions:
- *
- * ((c - cc) * a) * 255 + 255 * 256 * x = ((c - cc) * a) * 256
- *
- * Get the 'x' term alone:
- *
- * 255 * 256 * x = ((c - cc) * a)
- *
- * Divide both sides by 255 * 256 to solve for 'x':
- *
- * x = ((c - cc) * a) / (255 * 256)
- *
- * And putting 'x' back into the equation we get:
- *
- * nc = ((c - cc) * a) / 256 + cc + ((c - cc) * a) / (255 * 256)
- *
- * And if we let 'tmp' represent the value '(c - cc) * a', and do a little
- * regrouping we get:
- *
- * nc = tmp / 256 + tmp / (255 * 256) + cc
- * = (tmp + tmp / 255) / 256 + cc
- *
- * We'll be using integer arithmetic, and over the range of values tmp takes
- * (in [-255*255, 255*255]) the term tmp/(255*256) is pretty much the same as
- * tmp/(256*256). So we get:
- *
- * nc = (tmp + tmp / 256) / 256 + cc
- *
- * And because the division of the sum uses integer arithmetic, it always
- * rounds up/down even if that isn't the "best" choice. If we add .5 to the
- * sum, we can get standard rounding: Like so:
- *
- * nc = (tmp + tmp / 256 + 128) / 256 + cc
- *
- * 3) Add operation
- *
- * The "copy" version of this operation sums the source image pixel values
- * with the destination image pixel values, saturating at 255 (from above).
- *
- * The "blend" version of this operation sums the source image pixel values,
- * after taking into account alpha transparency (e.g. a percentage), with the
- * destination image pixel values, saturating at 255 (from above).
- *
- * 4) Subtract operation
- *
- * This operation is the same as the Add operation, except the source values
- * are subtracted from the destination values (instead of added). Further,
- * the result must be saturated at 0 (from below).
- *
- * 5) Reshade operation
- *
- * This operation uses the source image color values to lighten/darken color
- * values in the destination image using the following formula:
- *
- * nc = cc + ((c - middle_value) * 2 * alpha)
- *
- * Recall our pixel color and alpha values are in the range [0, 255]. So, the
- * "blend" version of this operation can be calculated as:
- *
- * nc = cc + ((c - 127) * 2 * (a / 255))
- *
- * And in an integer arithmetic friendly form is:
- *
- * nc = cc + (((c - 127) * a) >> 7)
- *
- * The "copy" version of this operation treats alpha as 1.0 (or a/255), and in
- * integer arithmetic friendly form is:
- *
- * nc = cc + ((c - 127) << 1)
- *
- * Notice the color values created by this operation are in the range
- * (-256, 512), and thus must be saturated at 0 and 255 (from above and below).
- *
- * For all the operations, when the "blend" version involves computing new
- * destination alpha values via the use of some source alpha, we have that:
- *
- * nalpha = alpha + ((255 - alpha) * (a / 255))
- *
- * We can use the previous argument for approximating division by 255, and
- * calculate this by:
- *
- * tmp = (255 - alpha) * a;
- * nalpha = alpha + ((tmp + (tmp >> 8) + 0x80) >> 8);
- *
- * This is again in the range [0, 255], so no saturation is needed.
- */
-
-#define BLEND_COLOR(a, nc, c, cc) \
-tmp = ((c) - (cc)) * (a); \
-nc = (cc) + ((tmp + (tmp >> 8) + 0x80) >> 8);
-
-#define ADD_COLOR_WITH_ALPHA(a, nc, c, cc) \
-tmp = (c) * (a); \
-tmp = (cc) + ((tmp + (tmp >> 8) + 0x80) >> 8); \
-nc = (tmp | (-(tmp >> 8)));
-
-#define ADD_COLOR(nc, c, cc) \
-tmp = (cc) + (c); \
-nc = (tmp | (-(tmp >> 8)));
-
-#define SUB_COLOR_WITH_ALPHA(a, nc, c, cc) \
-tmp = (c) * (a); \
-tmp = (cc) - ((tmp + (tmp >> 8) + 0x80) >> 8); \
-nc = (tmp & (~(tmp >> 8)));
-
-#define SUB_COLOR(nc, c, cc) \
-tmp = (cc) - (c); \
-nc = (tmp & (~(tmp >> 8)));
-
-#define RESHADE_COLOR_WITH_ALPHA(a, nc, c, cc) \
-tmp = (cc) + ((((c) - 127) * (a)) >> 7); \
-nc = (tmp | (-(tmp >> 8))) & (~(tmp >> 9));
-
-#define RESHADE_COLOR(nc, c, cc) \
-tmp = (cc) + (((c) - 127) << 1); \
-nc = (tmp | (-(tmp >> 8))) & (~(tmp >> 9));
-
-extern int pow_lut_initialized;
-extern DATA8 pow_lut[256][256];
-
-#define BLEND_DST_ALPHA(r1, g1, b1, a1, dest) \
-{ DATA8 _aa; \
-_aa = pow_lut[a1][A_VAL(dest)]; \
-BLEND_COLOR(a1, A_VAL(dest), 255, A_VAL(dest)); \
-BLEND_COLOR(_aa, R_VAL(dest), r1, R_VAL(dest)); \
-BLEND_COLOR(_aa, G_VAL(dest), g1, G_VAL(dest)); \
-BLEND_COLOR(_aa, B_VAL(dest), b1, B_VAL(dest)); \
-}
-
-#define BLEND(r1, g1, b1, a1, dest) \
-BLEND_COLOR(a1, R_VAL(dest), r1, R_VAL(dest)); \
-BLEND_COLOR(a1, G_VAL(dest), g1, G_VAL(dest)); \
-BLEND_COLOR(a1, B_VAL(dest), b1, B_VAL(dest));
-
-#define BLEND_ADD(r1, g1, b1, a1, dest) \
-ADD_COLOR_WITH_ALPHA(a1, R_VAL(dest), r1, R_VAL(dest)); \
-ADD_COLOR_WITH_ALPHA(a1, G_VAL(dest), g1, G_VAL(dest)); \
-ADD_COLOR_WITH_ALPHA(a1, B_VAL(dest), b1, B_VAL(dest));
-
-#define BLEND_SUB(r1, g1, b1, a1, dest) \
-SUB_COLOR_WITH_ALPHA(a1, R_VAL(dest), r1, R_VAL(dest)); \
-SUB_COLOR_WITH_ALPHA(a1, G_VAL(dest), g1, G_VAL(dest)); \
-SUB_COLOR_WITH_ALPHA(a1, B_VAL(dest), b1, B_VAL(dest));
-
-#define BLEND_RE(r1, g1, b1, a1, dest) \
-RESHADE_COLOR_WITH_ALPHA(a1, R_VAL(dest), r1, R_VAL(dest)); \
-RESHADE_COLOR_WITH_ALPHA(a1, G_VAL(dest), g1, G_VAL(dest)); \
-RESHADE_COLOR_WITH_ALPHA(a1, B_VAL(dest), b1, B_VAL(dest));
-
-enum _imlibop
-{
- OP_COPY,
- OP_ADD,
- OP_SUBTRACT,
- OP_RESHADE
-};
-
-typedef enum _imlibop ImlibOp;
-
-typedef void (*ImlibBlendFunction)(DATA32*, int, DATA32*, int, int, int,
- ImlibColorModifier *);
-
-ImlibBlendFunction
-__imlib_GetBlendFunction(ImlibOp op, char merge_alpha, char blend, char rgb_src,
- ImlibColorModifier * cm);
-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);
-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);
-void
-__imlib_build_pow_lut(void);
-
-#ifdef DO_MMX_ASM
-void
-__imlib_mmx_blend_rgba_to_rgb(DATA32 *src, int sw, DATA32 *dst,
- int dw, int w, int h, ImlibColorModifier *cm);
-void
-__imlib_mmx_blend_rgba_to_rgba(DATA32 *src, int sw, DATA32 *dst,
- int dw, int w, int h, ImlibColorModifier *cm);
-void
-__imlib_mmx_copy_rgba_to_rgb(DATA32 *src, int sw, DATA32 *dst,
- int dw, int w, int h, ImlibColorModifier *cm);
-void
-__imlib_mmx_copy_rgba_to_rgba(DATA32 *src, int sw, DATA32 *dst,
- int dw, int w, int h, ImlibColorModifier *cm);
-void
-__imlib_mmx_copy_rgb_to_rgba(DATA32 *src, int sw, DATA32 *dst,
- int dw, int w, int h, ImlibColorModifier *cm);
-void
-__imlib_mmx_add_blend_rgba_to_rgb(DATA32 *src, int sw, DATA32 *dst,
- int dw, int w, int h, ImlibColorModifier *cm);
-void
-__imlib_mmx_add_blend_rgba_to_rgba(DATA32 *src, int sw, DATA32 *dst,
- int dw, int w, int h, ImlibColorModifier *cm);
-void
-__imlib_mmx_add_copy_rgba_to_rgb(DATA32 *src, int sw, DATA32 *dst,
- int dw, int w, int h, ImlibColorModifier *cm);
-void
-__imlib_mmx_add_copy_rgba_to_rgba(DATA32 *src, int sw, DATA32 *dst,
- int dw, int w, int h, ImlibColorModifier *cm);
-void
-__imlib_mmx_add_copy_rgb_to_rgba(DATA32 *src, int sw, DATA32 *dst,
- int dw, int w, int h, ImlibColorModifier *cm);
-void
-__imlib_mmx_subtract_blend_rgba_to_rgb(DATA32 *src, int sw, DATA32 *dst,
- int dw, int w, int h, ImlibColorModifier *cm);
-void
-__imlib_mmx_subtract_blend_rgba_to_rgba(DATA32 *src, int sw, DATA32 *dst,
- int dw, int w, int h, ImlibColorModifier *cm);
-void
-__imlib_mmx_subtract_copy_rgba_to_rgb(DATA32 *src, int sw, DATA32 *dst,
- int dw, int w, int h, ImlibColorModifier *cm);
-void
-__imlib_mmx_subtract_copy_rgba_to_rgba(DATA32 *src, int sw, DATA32 *dst,
- int dw, int w, int h, ImlibColorModifier *cm);
-void
-__imlib_mmx_subtract_copy_rgb_to_rgba(DATA32 *src, int sw, DATA32 *dst,
- int dw, int w, int h, ImlibColorModifier *cm);
-void
-__imlib_mmx_reshade_blend_rgba_to_rgb(DATA32 *src, int sw, DATA32 *dst,
- int dw, int w, int h, ImlibColorModifier *cm);
-void
-__imlib_mmx_reshade_blend_rgba_to_rgba(DATA32 *src, int sw, DATA32 *dst,
- int dw, int w, int h, ImlibColorModifier *cm);
-void
-__imlib_mmx_reshade_copy_rgba_to_rgb(DATA32 *src, int sw, DATA32 *dst,
- int dw, int w, int h, ImlibColorModifier *cm);
-void
-__imlib_mmx_reshade_copy_rgba_to_rgba(DATA32 *src, int sw, DATA32 *dst,
- int dw, int w, int h, ImlibColorModifier *cm);
-void
-__imlib_mmx_reshade_copy_rgb_to_rgba(DATA32 *src, int sw, DATA32 *dst,
- int dw, int w, int h, ImlibColorModifier *cm);
-
-void
-__imlib_mmx_blend_rgba_to_rgb_cmod(DATA32 *src, int sw, DATA32 *dst,
- int dw, int w, int h, ImlibColorModifier *cm);
-void
-__imlib_mmx_blend_rgba_to_rgba_cmod(DATA32 *src, int sw, DATA32 *dst,
- int dw, int w, int h, ImlibColorModifier *cm);
-void
-__imlib_mmx_blend_rgb_to_rgb_cmod(DATA32 *src, int sw, DATA32 *dst,
- int dw, int w, int h, ImlibColorModifier *cm);
-void
-__imlib_mmx_blend_rgb_to_rgba_cmod(DATA32 *src, int sw, DATA32 *dst,
- int dw, int w, int h, ImlibColorModifier *cm);
-void
-__imlib_mmx_copy_rgba_to_rgb_cmod(DATA32 *src, int sw, DATA32 *dst,
- int dw, int w, int h, ImlibColorModifier *cm);
-void
-__imlib_mmx_copy_rgba_to_rgba_cmod(DATA32 *src, int sw, DATA32 *dst,
- int dw, int w, int h, ImlibColorModifier *cm);
-void
-__imlib_mmx_copy_rgb_to_rgba_cmod(DATA32 *src, int sw, DATA32 *dst,
- int dw, int w, int h, ImlibColorModifier *cm);
-void
-__imlib_mmx_add_blend_rgba_to_rgb_cmod(DATA32 *src, int sw, DATA32 *dst,
- int dw, int w, int h, ImlibColorModifier *cm);
-void
-__imlib_mmx_add_blend_rgba_to_rgba_cmod(DATA32 *src, int sw, DATA32 *dst,
- int dw, int w, int h, ImlibColorModifier *cm);
-void
-__imlib_mmx_add_blend_rgb_to_rgb_cmod(DATA32 *src, int sw, DATA32 *dst,
- int dw, int w, int h, ImlibColorModifier *cm);
-void
-__imlib_mmx_add_blend_rgb_to_rgba_cmod(DATA32 *src, int sw, DATA32 *dst,
- int dw, int w, int h, ImlibColorModifier *cm);
-void
-__imlib_mmx_add_copy_rgba_to_rgb_cmod(DATA32 *src, int sw, DATA32 *dst,
- int dw, int w, int h, ImlibColorModifier *cm);
-void
-__imlib_mmx_add_copy_rgba_to_rgba_cmod(DATA32 *src, int sw, DATA32 *dst,
- int dw, int w, int h, ImlibColorModifier *cm);
-void
-__imlib_mmx_add_copy_rgb_to_rgba_cmod(DATA32 *src, int sw, DATA32 *dst,
- int dw, int w, int h, ImlibColorModifier *cm);
-void
-__imlib_mmx_subtract_blend_rgba_to_rgb_cmod(DATA32 *src, int sw, DATA32 *dst,
- int dw, int w, int h, ImlibColorModifier *cm);
-void
-__imlib_mmx_subtract_blend_rgba_to_rgba_cmod(DATA32 *src, int sw, DATA32 *dst,
- int dw, int w, int h, ImlibColorModifier *cm);
-void
-__imlib_mmx_subtract_blend_rgb_to_rgb_cmod(DATA32 *src, int sw, DATA32 *dst,
- int dw, int w, int h, ImlibColorModifier *cm);
-void
-__imlib_mmx_subtract_blend_rgb_to_rgba_cmod(DATA32 *src, int sw, DATA32 *dst,
- int dw, int w, int h, ImlibColorModifier *cm);
-void
-__imlib_mmx_subtract_copy_rgba_to_rgb_cmod(DATA32 *src, int sw, DATA32 *dst,
- int dw, int w, int h, ImlibColorModifier *cm);
-void
-__imlib_mmx_subtract_copy_rgba_to_rgba_cmod(DATA32 *src, int sw, DATA32 *dst,
- int dw, int w, int h, ImlibColorModifier *cm);
-void
-__imlib_mmx_subtract_copy_rgb_to_rgba_cmod(DATA32 *src, int sw, DATA32 *dst,
- int dw, int w, int h, ImlibColorModifier *cm);
-void
-__imlib_mmx_reshade_blend_rgba_to_rgb_cmod(DATA32 *src, int sw, DATA32 *dst,
- int dw, int w, int h, ImlibColorModifier *cm);
-void
-__imlib_mmx_reshade_blend_rgba_to_rgba_cmod(DATA32 *src, int sw, DATA32 *dst,
- int dw, int w, int h, ImlibColorModifier *cm);
-void
-__imlib_mmx_reshade_blend_rgb_to_rgb_cmod(DATA32 *src, int sw, DATA32 *dst,
- int dw, int w, int h, ImlibColorModifier *cm);
-void
-__imlib_mmx_reshade_blend_rgb_to_rgba_cmod(DATA32 *src, int sw, DATA32 *dst,
- int dw, int w, int h, ImlibColorModifier *cm);
-void
-__imlib_mmx_reshade_copy_rgba_to_rgb_cmod(DATA32 *src, int sw, DATA32 *dst,
- int dw, int w, int h, ImlibColorModifier *cm);
-void
-__imlib_mmx_reshade_copy_rgba_to_rgba_cmod(DATA32 *src, int sw, DATA32 *dst,
- int dw, int w, int h, ImlibColorModifier *cm);
-void
-__imlib_mmx_reshade_copy_rgb_to_rgba_cmod(DATA32 *src, int sw, DATA32 *dst,
- int dw, int w, int h, ImlibColorModifier *cm);
-
-#endif
-#endif
diff --git a/src/color.c b/src/color.c
deleted file mode 100644
index 80da09c..0000000
--- a/src/color.c
+++ /dev/null
@@ -1,569 +0,0 @@
-#include "common.h"
-#ifndef X_DISPLAY_MISSING
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-#include "color.h"
-#endif
-
-DATA8 _pal_type = 0;
-DATA16 _max_colors = 256;
-
-int
-__imlib_XActualDepth(Display * d, Visual * v)
-{
- 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);
- }
- return depth;
-}
-
-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 };
-
- 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);
- }
- }
- if (depth_return)
- *depth_return = maxd;
- return v;
-}
-
-DATA8 *
-__imlib_AllocColorTable(Display * d, Colormap cmap, DATA8 * type_return,
- Visual * v)
-{
- 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 >= 8) && (color_lut = __imlib_AllocColors111(d, cmap, v)))
- {
- *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)
-{
- 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++;
- }
- }
- }
- _pal_type = 0;
- return color_lut;
-}
-
-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);
- 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++;
- }
- }
- }
- _pal_type = 7;
- return color_lut;
-}
-
-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);
- sig_mask <<= (16 - v->bits_per_rgb);
- i = 0;
- 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++;
- }
- }
- }
- _pal_type = 1;
- return color_lut;
-}
-
-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);
- sig_mask <<= (16 - v->bits_per_rgb);
- i = 0;
- 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++;
- }
- }
- }
- _pal_type = 2;
- return color_lut;
-}
-
-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);
- sig_mask <<= (16 - v->bits_per_rgb);
- i = 0;
- 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++;
- }
- }
- }
- _pal_type = 3;
- return color_lut;
-}
-
-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);
- sig_mask <<= (16 - v->bits_per_rgb);
- i = 0;
- 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++;
- }
- }
- }
- _pal_type = 4;
- return color_lut;
-}
-
-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);
- sig_mask <<= (16 - v->bits_per_rgb);
- i = 0;
- 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++;
- }
- }
- }
- _pal_type = 5;
- return color_lut;
-}
-
-DATA8 *
-__imlib_AllocColors1(Display * d, Colormap cmap, Visual * v)
-{
- XColor xcl;
- DATA8 *color_lut;
-
- color_lut = malloc(2 * sizeof(DATA8));
- xcl.red = (unsigned short)(0x0000);
- xcl.green = (unsigned short)(0x0000);
- xcl.blue = (unsigned short)(0x0000);
- XAllocColor(d, cmap, &xcl);
- color_lut[0] = xcl.pixel;
- xcl.red = (unsigned short)(0xffff);
- xcl.green = (unsigned short)(0xffff);
- xcl.blue = (unsigned short)(0xffff);
- XAllocColor(d, cmap, &xcl);
- color_lut[1] = xcl.pixel;
- _pal_type = 6;
- return color_lut;
-}
diff --git a/src/color.h b/src/color.h
deleted file mode 100644
index c9123c7..0000000
--- a/src/color.h
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef __COLOR
-#define __COLOR 1
-extern DATA16 _max_colors;
-
-int __imlib_XActualDepth(Display *d, Visual *v);
-Visual *__imlib_BestVisual(Display *d, int screen, int *depth_return);
-DATA8 * __imlib_AllocColorTable(Display *d, Colormap cmap, DATA8 *type_return, Visual *v);
-DATA8 * __imlib_AllocColors332(Display *d, Colormap cmap, Visual *v);
-DATA8 * __imlib_AllocColors666(Display *d, Colormap cmap, Visual *v);
-DATA8 * __imlib_AllocColors232(Display *d, Colormap cmap, Visual *v);
-DATA8 * __imlib_AllocColors222(Display *d, Colormap cmap, Visual *v);
-DATA8 * __imlib_AllocColors221(Display *d, Colormap cmap, Visual *v);
-DATA8 * __imlib_AllocColors121(Display *d, Colormap cmap, Visual *v);
-DATA8 * __imlib_AllocColors111(Display *d, Colormap cmap, Visual *v);
-DATA8 * __imlib_AllocColors1(Display *d, Colormap cmap, Visual *v);
-#endif
diff --git a/src/color_helpers.c b/src/color_helpers.c
deleted file mode 100644
index 69dc2d5..0000000
--- a/src/color_helpers.c
+++ /dev/null
@@ -1,235 +0,0 @@
-#include "color_helpers.h"
-/*
- * 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)
-{
- int f;
- float i, j, k, max, min, d;
-
- 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;
- d = max - min;
-
- *value = max;
- 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;
- }
-}
-
-void
-__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;
-
- 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;
- }
- }
-}
-
-void
-__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;
-
- 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;
- d = max - min;
-
- *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;
- }
-}
-
-void
-__imlib_hls_to_rgb(float hue, float lightness, float saturation, int *r, int *g,
- int *b)
-{
- float m1, m2, m21, h;
-
- 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);
- }
-}
diff --git a/src/color_helpers.h b/src/color_helpers.h
deleted file mode 100644
index 0ed1999..0000000
--- a/src/color_helpers.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef __COLOR_HELPERS
-#define __COLOR_HELPERS 1
-
-void __imlib_rgb_to_hsv(int r, int g, int b, float *hue, float *saturation, float *value);
-void __imlib_hsv_to_rgb(float hue, float saturation, float value, int *r, int *g, int *b);
-void __imlib_rgb_to_hls(int r, int g, int b, float *hue, float *lightness, float *saturation);
-void __imlib_hls_to_rgb(float hue, float lightness, float saturation, int *r, int *g, int *b);
-
-#endif
diff --git a/src/colormod.c b/src/colormod.c
deleted file mode 100644
index 7940989..0000000
--- a/src/colormod.c
+++ /dev/null
@@ -1,254 +0,0 @@
-#include "common.h"
-#include "colormod.h"
-#include "file.h"
-#include "loaderpath.h"
-#include <math.h>
-#include "image.h"
-#include "blend.h"
-
-static DATABIG mod_count = 0;
-
-ImlibColorModifier *
-__imlib_CreateCmod(void)
-{
- ImlibColorModifier *cm;
- 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;
- }
- return cm;
-}
-
-void
-__imlib_FreeCmod(ImlibColorModifier * cm)
-{
- free(cm);
-}
-
-void
-__imlib_CmodChanged(ImlibColorModifier * cm)
-{
- mod_count++;
- cm->modification_count = mod_count;
-}
-
-void
-__imlib_CmodSetTables(ImlibColorModifier * cm,
- DATA8 * r, DATA8 * g, DATA8 * b, DATA8 * a)
-{
- 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];
- }
- __imlib_CmodChanged(cm);
-}
-
-void
-__imlib_CmodReset(ImlibColorModifier * cm)
-{
- 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;
- }
- __imlib_CmodChanged(cm);
-}
-
-void
-__imlib_DataCmodApply(DATA32 * data, int w, int h, int jump,
- ImlibImageFlags * fl, ImlibColorModifier * cm)
-{
- int x, y;
- DATA32 *p;
-
- /* 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, A_VAL(p));
- p++;
- }
- p += jump;
- }
-}
-
-void
-__imlib_CmodGetTables(ImlibColorModifier * cm, DATA8 * r, DATA8 * g,
- DATA8 * b, DATA8 * a)
-{
- if (r)
- memcpy(r, cm->red_mapping, (256 * sizeof(DATA8)));
- if (g)
- memcpy(g, cm->green_mapping, (256 * sizeof(DATA8)));
- if (b)
- memcpy(b, cm->blue_mapping, (256 * sizeof(DATA8)));
- if (a)
- memcpy(a, cm->alpha_mapping, (256 * sizeof(DATA8)));
-}
-
-void
-__imlib_CmodModBrightness(ImlibColorModifier * cm, double v)
-{
- 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;
- }
-}
-
-void
-__imlib_CmodModContrast(ImlibColorModifier * cm, double v)
-{
- 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;
- }
-}
-
-void
-__imlib_CmodModGamma(ImlibColorModifier * cm, double v)
-{
- 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;
- }
-}
-
-#if 0
-void
-__imlib_ImageCmodApply(ImlibImage * im, ImlibColorModifier * cm)
-{
- __imlib_DataCmodApply(im->data, im->w, im->h, 0, cm);
-}
-#endif
diff --git a/src/colormod.h b/src/colormod.h
deleted file mode 100644
index 4ac25a4..0000000
--- a/src/colormod.h
+++ /dev/null
@@ -1,72 +0,0 @@
-#ifndef __COLORMOD
-#define __COLORMOD 1
-
-#include "common.h"
-#include <time.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <ctype.h>
-#include <errno.h>
-#include "image.h"
-
-typedef struct _imlib_color_modifier ImlibColorModifier;
-
-struct _imlib_color_modifier
-{
- DATA8 red_mapping[256];
- DATA8 green_mapping[256];
- DATA8 blue_mapping[256];
- DATA8 alpha_mapping[256];
- DATABIG modification_count;
-};
-
-#define CMOD_APPLY_RGB(cm, r, g, b) \
-(r) = (cm)->red_mapping[(int)(r)]; \
-(g) = (cm)->green_mapping[(int)(g)]; \
-(b) = (cm)->blue_mapping[(int)(b)];
-
-#define CMOD_APPLY_RGBA(cm, r, g, b, a) \
-(r) = (cm)->red_mapping[(int)(r)]; \
-(g) = (cm)->green_mapping[(int)(g)]; \
-(b) = (cm)->blue_mapping[(int)(b)]; \
-(a) = (cm)->alpha_mapping[(int)(a)];
-
-#define CMOD_APPLY_R(cm, r) \
-(r) = (cm)->red_mapping[(int)(r)];
-#define CMOD_APPLY_G(cm, g) \
-(g) = (cm)->green_mapping[(int)(g)];
-#define CMOD_APPLY_B(cm, b) \
-(b) = (cm)->blue_mapping[(int)(b)];
-#define CMOD_APPLY_A(cm, a) \
-(a) = (cm)->alpha_mapping[(int)(a)];
-
-#define R_CMOD(cm, r) \
-(cm)->red_mapping[(int)(r)]
-#define G_CMOD(cm, g) \
-(cm)->green_mapping[(int)(g)]
-#define B_CMOD(cm, b) \
-(cm)->blue_mapping[(int)(b)]
-#define A_CMOD(cm, a) \
-(cm)->alpha_mapping[(int)(a)]
-
-ImlibColorModifier * __imlib_CreateCmod(void);
-void __imlib_FreeCmod(ImlibColorModifier *cm);
-void __imlib_CmodChanged(ImlibColorModifier *cm);
-void __imlib_CmodSetTables(ImlibColorModifier *cm, DATA8 *r,
- DATA8 *g, DATA8 *b, DATA8 *a);
-void __imlib_CmodReset(ImlibColorModifier *cm);
-void __imlib_DataCmodApply(DATA32 *data, int w, int h,
- int jump, ImlibImageFlags *fl,
- ImlibColorModifier *cm);
-
-void __imlib_CmodGetTables(ImlibColorModifier *cm, DATA8 *r,
- DATA8 *g, DATA8 *b, DATA8 *a);
-void __imlib_CmodModBrightness(ImlibColorModifier *cm,
- double v);
-void __imlib_CmodModContrast(ImlibColorModifier *cm,
- double v);
-void __imlib_CmodModGamma(ImlibColorModifier *cm,
- double v);
-#endif
diff --git a/src/common.h b/src/common.h
deleted file mode 100644
index 3a99628..0000000
--- a/src/common.h
+++ /dev/null
@@ -1,42 +0,0 @@
-#ifndef __COMMON
-#define __COMMON 1
-
-#include "config.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <config.h>
-#include <string.h>
-#ifdef WITH_DMALLOC
-# include <dmalloc.h>
-#endif
-#ifdef __EMX__
-#include <sys/types.h>
-#endif
-
-#define DATABIG unsigned long long
-#define DATA64 unsigned long long
-#define DATA32 unsigned int
-#define DATA16 unsigned short
-#define DATA8 unsigned char
-
-#ifdef DO_MMX_ASM
-int __imlib_get_cpuid(void);
-#define CPUID_MMX (1 << 23)
-#define CPUID_XMM (1 << 25)
-#endif
-
-#define CLIP(x, y, w, h, xx, yy, ww, hh) \
-if (x < (xx)) {w += (x - (xx)); x = (xx);} \
-if (y < (yy)) {h += (y - (yy)); y = (yy);} \
-if ((x + w) > ((xx) + (ww))) {w = (ww) - (x - xx);} \
-if ((y + h) > ((yy) + (hh))) {h = (hh) - (y - yy);}
-#define MIN(a, b) (((a) < (b)) ? (a) : (b))
-#define MAX(a, b) (((a) > (b)) ? (a) : (b))
-
-#ifdef __EMX__
-extern char *__XOS2RedirRoot(const char *);
-#endif
-
-#endif
diff --git a/src/context.c b/src/context.c
deleted file mode 100644
index e84aeae..0000000
--- a/src/context.c
+++ /dev/null
@@ -1,208 +0,0 @@
-#include "common.h"
-#ifndef X_DISPLAY_MISSING
-#include <X11/Xlib.h>
-#endif
-# include "image.h"
-#include "context.h"
-#include "color.h"
-#include "rgba.h"
-
-static Context *context = NULL;
-static int max_context_count = 128;
-static int context_counter = 0;
-
-void
-__imlib_SetMaxContexts(int num)
-{
- max_context_count = num;
- __imlib_FlushContexts();
-}
-
-int
-__imlib_GetMaxContexts(void)
-{
- return max_context_count;
-}
-
-void
-__imlib_FlushContexts(void)
-{
- 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;
- }
-}
-
-void
-__imlib_FreeContextForDisplay(Display * d)
-{
- Context *ct;
-
- ct = context;
- while (ct)
- {
- if (ct->display == d)
- ct->last_use = -(max_context_count * 2);
- ct = ct->next;
- }
- __imlib_FlushContexts();
-}
-
-void
-__imlib_FreeContextForColormap(Display * d, Colormap cm)
-{
- Context *ct;
-
- ct = context;
- while (ct)
- {
- 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)
-{
- Context *ct;
-
- ct = context;
- while (ct)
- {
- 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 *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;
- }
- return NULL;
-}
-
-Context *
-__imlib_NewContext(Display * d, Visual * v, Colormap c, int depth)
-{
- Context *ct;
-
- context_counter++;
- ct = malloc(sizeof(Context));
- ct->last_use = context_counter;
- ct->display = d;
- ct->visual = v;
- ct->colormap = c;
- ct->depth = depth;
- ct->next = NULL;
-
- 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);
- }
- 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;
- __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 *ct;
-
- ct = __imlib_FindContext(d, v, c, depth);
- if (ct)
- {
- ct->last_use = context_counter;
- return ct;
- }
- ct = __imlib_NewContext(d, v, c, depth);
- ct->next = context;
- context = ct;
- __imlib_FlushContexts();
- return ct;
-}
diff --git a/src/context.h b/src/context.h
deleted file mode 100644
index b662adb..0000000
--- a/src/context.h
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef __CONTEXT
-#define __CONTEXT 1
-
-typedef struct _context Context;
-
-struct _context
-{
- int last_use;
- Display *display;
- Visual *visual;
- Colormap colormap;
- int depth;
- Context *next;
-
- DATA8 *palette;
- DATA8 palette_type;
- void *r_dither;
- void *g_dither;
- void *b_dither;
-};
-
-void __imlib_SetMaxContexts(int num);
-int __imlib_GetMaxContexts(void);
-void __imlib_FlushContexts(void);
-void __imlib_FreeContextForDisplay(Display *d);
-void __imlib_FreeContextForColormap(Display *d, Colormap cm);
-void __imlib_FreeContextForVisual(Display *d, Visual *v);
-Context *__imlib_FindContext(Display *d, Visual *v, Colormap c, int depth);
-Context *__imlib_NewContext(Display *d, Visual *v, Colormap c, int depth);
-Context *__imlib_GetContext(Display *d, Visual *v, Colormap c, int depth);
-
-#endif
diff --git a/src/draw.c b/src/draw.c
deleted file mode 100644
index 4c43b7e..0000000
--- a/src/draw.c
+++ /dev/null
@@ -1,88 +0,0 @@
-#include "common.h"
-#ifndef X_DISPLAY_MISSING
-#include <X11/Xlib.h>
-#include <X11/extensions/XShm.h>
-#endif
-#include "colormod.h"
-#include "image.h"
-#include "blend.h"
-#include "rend.h"
-#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)
-{
- 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);
- if (ip)
- {
- 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);
-#endif
- return 2;
- }
- if (p)
- {
- 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;
- }
- __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;
- ip->image = im;
- if (im->file)
- ip->file = strdup(im->file);
- ip->border.left = im->border.left;
- ip->border.right = im->border.right;
- ip->border.top = im->border.top;
- ip->border.bottom = im->border.bottom;
- ip->colormap = cm;
- ip->display = d;
- ip->w = dw;
- ip->h = dh;
- ip->source_x = sx;
- ip->source_y = sy;
- ip->source_w = sw;
- ip->source_h = sh;
- ip->antialias = antialias;
- ip->modification_count = mod_count;
- ip->dither_mask = dither_mask;
- ip->hi_quality = hiq;
- ip->references = 1;
- ip->pixmap = pmap;
- 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);
-#endif
- return 1;
-}
diff --git a/src/draw.h b/src/draw.h
deleted file mode 100644
index 196519b..0000000
--- a/src/draw.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef __DRAW
-#define __DRAW 1
-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 anitalias, char hiq, char dither_mask,
- ImlibColorModifier *cmod);
-#endif
diff --git a/src/dynamic_filters.c b/src/dynamic_filters.c
deleted file mode 100644
index 6c82862..0000000
--- a/src/dynamic_filters.c
+++ /dev/null
@@ -1,193 +0,0 @@
-#include "common.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <time.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <ctype.h>
-#include <errno.h>
-#include "image.h"
-#include "file.h"
-#include "dynamic_filters.h"
-#include "script.h"
-#include "loaderpath.h"
-
-pImlibExternalFilter filters = NULL;
-int dyn_initialised = 0;
-
-#define MALLOCSHOW
-#define FREESHOW
-/*
-#define FDEBUG
-*/
-
-pImlibExternalFilter
-__imlib_LoadFilter(char *file)
-{
- ImlibExternalFilter *ptr;
- struct imlib_filter_info *info;
-
- /* printf( "Loading filter %s\n", file ); */
- MALLOCSHOW;
- 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);
- 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]);
-#endif
-
- ptr->next = NULL;
- return ptr;
-}
-
-void
-__imlib_dynamic_filters_init()
-{
- 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;
-#ifdef FDEBUG
- printf("DEBUG: Dynamic filters Initisialising\n");
-#endif
- dyn_initialised = 1;
-#ifdef FDEBUG
- 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);
- }
-}
-
-void
-__imlib_dynamic_filters_deinit()
-{
-}
-
-pImlibExternalFilter
-__imlib_get_dynamic_filter(char *name)
-{
- pImlibExternalFilter f_ptr;
- 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)
- {
-#ifdef FDEBUG
- printf("DEBUG: Found filter \"%s\"\n", name);
-#endif
- return f_ptr;
- }
- }
- }
- return NULL;
-}
-
-/* loader dir */
-char **
-__imlib_ListFilters(int *num_ret)
-{
- 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);
- sprintf(s, SYS_LOADERS_PATH "/filter");
-#ifndef __EMX__
- l = __imlib_FileDir(s, &num);
-#else
- l = __imlib_FileDir(__XOS2RedirRoot(s), &num);
-#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);
- }
- free(s);
-
- /* List currently contains *everything in there* we need to weed out
- * the .so, .la, .a versions of the same loader or whatever else.
- * 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/dynamic_filters.h b/src/dynamic_filters.h
deleted file mode 100644
index 93eae42..0000000
--- a/src/dynamic_filters.h
+++ /dev/null
@@ -1,43 +0,0 @@
-#ifndef _DYNAMIC_FILTERS_H_
-#define _DYNAMIC_FILTERS_H_
-
-#include "script.h"
-
-struct imlib_filter_info
-{
- char *name;
- char *author;
- char *description;
- char **filters;
- int num_filters;
-};
-
-typedef struct _imlib_external_filter ImlibExternalFilter;
-typedef struct _imlib_external_filter *pImlibExternalFilter;
-struct _imlib_external_filter
-{
- char *name;
- char *author;
- char *description;
- int num_filters;
- char *filename;
- void *handle;
- char **filters;
- void (*init_filter)( struct imlib_filter_info *info );
- void (*deinit_filter)();
- void *(*exec_filter)( char *filter, void *im, pIFunctionParam params );
- pImlibExternalFilter next;
-};
-
-void __imlib_dynamic_filters_init();
-void __imlib_dynamic_filters_deinit();
-pImlibExternalFilter __imlib_get_dynamic_filter( char *name );
-char **__imlib_ListFilters(int *num_ret);
-pImlibExternalFilter __imlib_LoadFilter( char *file );
-
-
-
-#endif
-
-
-
diff --git a/src/ellipse.c b/src/ellipse.c
deleted file mode 100644
index 8ddf5b1..0000000
--- a/src/ellipse.c
+++ /dev/null
@@ -1,737 +0,0 @@
-#include "common.h"
-#include "colormod.h"
-#include "image.h"
-#include "blend.h"
-#include "span.h"
-#include "updates.h"
-#include "rgbadraw.h"
-
-
-static void
-__imlib_Ellipse_DrawToData(int xc, int yc, int a, int b, DATA32 color,
- DATA32 *dst, int dstw, int clx, int cly, int clw, int clh,
- ImlibOp op, char dst_alpha, char blend)
-{
- ImlibPointDrawFunction pfunc;
- int xx, yy, x, y, prev_x, prev_y, ty, by, lx, rx;
- DATA32 a2, b2, *tp, *bp;
- DATA64 dx, dy;
-
- if (A_VAL(&color) == 0xff)
- blend = 0;
- pfunc = __imlib_GetPointDrawFunction(op, dst_alpha, blend);
- if (!pfunc)
- return;
-
- xc -= clx;
- yc -= cly;
- dst += (dstw * cly) + clx;
-
- a2 = a*a; b2 = b*b;
-
- yy = b << 16;
- prev_y = b;
-
- dx = a2 * b;
- dy = 0;
-
- ty = yc - b - 1;
- by = yc + b;
- lx = xc - 1;
- rx = xc;
-
- tp = dst + (dstw * ty) + lx;
- bp = dst + (dstw * by) + lx;
-
- while (dy < dx)
- {
- int len;
-
- y = yy >> 16;
- y += ((yy - (y << 16)) >> 15);
-
- if (prev_y != y)
- {
- prev_y = y;
- dx -= a2;
- ty++; by--;
- tp += dstw;
- bp -= dstw;
- }
-
- len = rx - lx;
-
- if (IN_RANGE(lx, ty, clw, clh))
- pfunc(color, tp);
- if (IN_RANGE(rx, ty, clw, clh))
- pfunc(color, tp + len);
- if (IN_RANGE(lx, by, clw, clh))
- pfunc(color, bp);
- if (IN_RANGE(rx, by, clw, clh))
- pfunc(color, bp + len);
-
- dy += b2;
- yy -= ((dy << 16) / dx);
- lx--; rx++;
- tp--; bp--;
-
- if ( (lx < 0) && (rx > clw) )
- return;
- if ( (ty > clh) || (by < 0) )
- return;
- }
-
- xx = yy;
- prev_x = xx >> 16;
-
- dx = dy;
-
- ty++;
- by--;
-
- tp += dstw;
- bp -= dstw;
-
- while (ty < yc)
- {
- int len;
-
- x = xx >> 16;
- x += ((xx - (x << 16)) >> 15);
-
- if (prev_x != x)
- {
- prev_x = x;
- dy += b2;
- lx--; rx++;
- tp--; bp--;
- }
-
- len = rx - lx;
-
- if (IN_RANGE(lx, ty, clw, clh))
- pfunc(color, tp);
- if (IN_RANGE(rx, ty, clw, clh))
- pfunc(color, tp + len);
- if (IN_RANGE(lx, by, clw, clh))
- pfunc(color, bp);
- if (IN_RANGE(rx, by, clw, clh))
- pfunc(color, bp + len);
-
- dx -= a2;
- xx += ((dx << 16) / dy);
- ty++; by--;
- tp += dstw;
- bp -= dstw;
-
- if ( (lx < 0) && (rx > clw) )
- return;
- if ( (ty > clh) || (by < 0) )
- return;
- }
-}
-
-static void
-__imlib_Ellipse_DrawToData_AA(int xc, int yc, int a, int b, DATA32 color,
- DATA32 *dst, int dstw, int clx, int cly, int clw, int clh,
- ImlibOp op, char dst_alpha, char blend)
-{
- ImlibPointDrawFunction pfunc;
- int xx, yy, x, y, prev_x, prev_y, ty, by, lx, rx;
- DATA32 a2, b2, col0, col1, *tp, *bp;
- DATA64 dx, dy;
- DATA8 ca = A_VAL(&color);
-
- pfunc = __imlib_GetPointDrawFunction(op, dst_alpha, blend);
- if (!pfunc)
- return;
-
- xc -= clx;
- yc -= cly;
- dst += (dstw * cly) + clx;
-
- col0 = col1 = color;
- a2 = a*a; b2 = b*b;
-
- yy = b << 16;
- prev_y = b;
-
- dx = a2 * b;
- dy = 0;
-
- ty = yc - b - 2;
- by = yc + b + 1;
- lx = xc - 1;
- rx = xc;
-
- tp = dst + (dstw * ty) + lx;
- bp = dst + (dstw * by) + lx;
-
- while (dy < dx)
- {
- int len;
- DATA32 tmp;
-
- y = yy >> 16;
-
- if (prev_y != y)
- {
- prev_y = y;
- dx -= a2;
- ty++; by--;
- tp += dstw;
- bp -= dstw;
- }
-
- A_VAL(&col1) = (yy - (y << 16)) >> 8;
- A_VAL(&col0) = 255 - A_VAL(&col1);
-
- if (ca < 255)
- {
- MULT(A_VAL(&col0), ca, A_VAL(&col0), tmp)
- MULT(A_VAL(&col1), ca, A_VAL(&col1), tmp)
- }
-
- len = rx - lx;
-
- if (IN_RANGE(lx, ty, clw, clh))
- pfunc(col1, tp);
- if (IN_RANGE(lx, ty + 1, clw, clh))
- pfunc(col0, tp + dstw);
-
- if (IN_RANGE(rx, ty + 1, clw, clh))
- pfunc(col0, tp + dstw + len);
- if (IN_RANGE(rx, ty, clw, clh))
- pfunc(col1, tp + len);
-
- if (IN_RANGE(lx, by, clw, clh))
- pfunc(col1, bp);
- if (IN_RANGE(lx, by - 1, clw, clh))
- pfunc(col0, bp - dstw);
-
- if (IN_RANGE(rx, by - 1, clw, clh))
- pfunc(col0, bp - dstw + len);
- if (IN_RANGE(rx, by, clw, clh))
- pfunc(col1, bp + len);
-
- dy += b2;
- yy -= ((dy << 16) / dx);
- lx--; rx++;
- tp--; bp--;
-
- if ( (lx < 0) && (rx > clw) )
- return;
- if ( (ty > clh) || (by < 0) )
- return;
- }
-
- y = yy >> 16;
- xx = yy;
- prev_x = y;
-
- dx = dy;
-
- ty++;
- by--;
-
- tp += dstw;
- bp -= dstw;
-
- while (ty < yc)
- {
- int len;
- DATA32 tmp;
-
- x = xx >> 16;
-
- if (prev_x != x)
- {
- prev_x = x;
- dy += b2;
- lx--; rx++;
- tp--; bp--;
- }
-
- A_VAL(&col1) = (xx - (x << 16)) >> 8;
- A_VAL(&col0) = 255 - A_VAL(&col1);
-
- if (ca < 255)
- {
- MULT(A_VAL(&col0), ca, A_VAL(&col0), tmp)
- MULT(A_VAL(&col1), ca, A_VAL(&col1), tmp)
- }
-
- len = rx - lx;
-
- if (IN_RANGE(lx, ty, clw, clh))
- pfunc(col1, tp);
- if (IN_RANGE(lx + 1, ty, clw, clh) && (x != y))
- pfunc(col0, tp + 1);
-
- if (IN_RANGE(rx - 1, ty, clw, clh) && (x != y))
- pfunc(col0, tp + len - 1);
- if (IN_RANGE(rx, ty, clw, clh))
- pfunc(col1, tp + len);
-
- if (IN_RANGE(lx, by, clw, clh))
- pfunc(col1, bp);
- if (IN_RANGE(lx + 1, by, clw, clh) && (x != y))
- pfunc(col0, bp + 1);
-
- if (IN_RANGE(rx - 1, by, clw, clh) && (x != y))
- pfunc(col0, bp + len - 1);
- if (IN_RANGE(rx, by, clw, clh))
- pfunc(col1, bp + len);
-
- dx -= a2;
- xx += ((dx << 16) / dy);
- ty++; by--;
- tp += dstw;
- bp -= dstw;
-
- if ( (lx < 0) && (rx > clw) )
- return;
- if ( (ty > clh) || (by < 0) )
- return;
- }
-}
-
-static void
-__imlib_Ellipse_FillToData(int xc, int yc, int a, int b, DATA32 color,
- DATA32 *dst, int dstw, int clx, int cly, int clw, int clh,
- ImlibOp op, char dst_alpha, char blend)
-{
- ImlibPointDrawFunction pfunc;
- ImlibSpanDrawFunction sfunc;
- int xx, yy, x, y, prev_x, prev_y, ty, by, lx, rx;
- DATA32 a2, b2, *tp, *bp;
- DATA64 dx, dy;
-
- if (A_VAL(&color) == 0xff)
- blend = 0;
- pfunc = __imlib_GetPointDrawFunction(op, dst_alpha, blend);
- sfunc = __imlib_GetSpanDrawFunction(op, dst_alpha, blend);
- if ((!sfunc) || (!pfunc))
- return;
-
- xc -= clx;
- yc -= cly;
- dst += (dstw * cly) + clx;
-
- a2 = a*a; b2 = b*b;
-
- yy = b << 16;
- prev_y = b;
-
- dx = a2 * b;
- dy = 0;
-
- ty = yc - b - 1;
- by = yc + b;
- lx = xc - 1;
- rx = xc;
-
- tp = dst + (dstw * ty) + lx;
- bp = dst + (dstw * by) + lx;
-
- while (dy < dx)
- {
- int len;
- DATA32 *tpp, *bpp;
-
- y = yy >> 16;
- y += ((yy - (y << 16)) >> 15);
-
- if (prev_y != y)
- {
- prev_y = y;
- dx -= a2;
- ty++; by--;
- tp += dstw;
- bp -= dstw;
-
- tpp = tp + 1;
- bpp = bp + 1;
- len = rx;
- if (len > clw) len = clw;
- len -= (lx + 1);
- if (lx < -1)
- {
- len += (lx + 1);
- tpp -= (lx + 1);
- bpp -= (lx + 1);
- }
-
- if ( ((unsigned)(ty) < clh) && (len > 0) )
- sfunc(color, tpp, len);
- if ( ((unsigned)(by) < clh) && (len > 0) )
- sfunc(color, bpp, len);
- }
-
- len = rx - lx;
-
- if (IN_RANGE(lx, ty, clw, clh))
- pfunc(color, tp);
- if (IN_RANGE(rx, ty, clw, clh))
- pfunc(color, tp + len);
- if (IN_RANGE(lx, by, clw, clh))
- pfunc(color, bp);
- if (IN_RANGE(rx, by, clw, clh))
- pfunc(color, bp + len);
-
- dy += b2;
- yy -= ((dy << 16) / dx);
- lx--; rx++;
- tp--; bp--;
-
- if ( (ty > clh) || (by < 0) )
- return;
- }
-
- xx = yy;
- prev_x = xx >> 16;
-
- dx = dy;
-
- ty++;
- by--;
-
- tp += dstw;
- bp -= dstw;
-
- while (ty < yc)
- {
- int len;
- DATA32 *tpp, *bpp;
-
- x = xx >> 16;
- x += ((xx - (x << 16)) >> 15);
-
- if (prev_x != x)
- {
- prev_x = x;
- dy += b2;
- lx--; rx++;
- tp--; bp--;
- }
-
- tpp = tp;
- bpp = bp;
- len = rx + 1;
- if (len > clw) len = clw;
- len -= lx;
- if (lx < 0)
- {
- len += lx;
- tpp -= lx;
- bpp -= lx;
- }
-
- if ( ((unsigned)(ty) < clh) && (len > 0) )
- sfunc(color, tpp, len);
- if ( ((unsigned)(by) < clh) && (len > 0) )
- sfunc(color, bpp, len);
-
- dx -= a2;
- xx += ((dx << 16) / dy);
- ty++; by--;
- tp += dstw;
- bp -= dstw;
-
- if ( (ty > clh) || (by < 0) )
- return;
- }
-}
-
-static void
-__imlib_Ellipse_FillToData_AA(int xc, int yc, int a, int b, DATA32 color,
- DATA32 *dst, int dstw, int clx, int cly, int clw, int clh,
- ImlibOp op, char dst_alpha, char blend)
-{
- ImlibPointDrawFunction pfunc;
- ImlibSpanDrawFunction sfunc;
- int xx, yy, x, y, prev_x, prev_y, ty, by, lx, rx;
- DATA32 a2, b2, col1, *tp, *bp;
- DATA64 dx, dy;
- DATA8 ca = A_VAL(&color);
-
- pfunc = __imlib_GetPointDrawFunction(op, dst_alpha, blend);
- if (ca == 0xff)
- blend = 0;
- sfunc = __imlib_GetSpanDrawFunction(op, dst_alpha, blend);
- if ((!pfunc) || (!sfunc))
- return;
-
- xc -= clx;
- yc -= cly;
- dst += (dstw * cly) + clx;
-
- col1 = color;
- a2 = a*a; b2 = b*b;
-
- yy = b << 16;
- prev_y = b;
-
- dx = a2 * b;
- dy = 0;
-
- ty = yc - b - 2;
- by = yc + b + 1;
- lx = xc - 1;
- rx = xc;
-
- tp = dst + (dstw * ty) + lx;
- bp = dst + (dstw * by) + lx;
-
- while (dy < dx)
- {
- int len;
- DATA32 tmp, *tpp, *bpp;
-
- y = yy >> 16;
-
- if (prev_y != y)
- {
- prev_y = y;
- dx -= a2;
- ty++; by--;
- tp += dstw;
- bp -= dstw;
-
- tpp = tp + 1;
- bpp = bp + 1;
- len = rx;
- if (len > clw) len = clw;
- len -= (lx + 1);
- if (lx < -1)
- {
- len += (lx + 1);
- tpp -= (lx + 1);
- bpp -= (lx + 1);
- }
-
- if ( ((unsigned)(ty) < clh) && (len > 0) )
- sfunc(color, tpp, len);
- if ( ((unsigned)(by) < clh) && (len > 0) )
- sfunc(color, bpp, len);
- }
-
- A_VAL(&col1) = ((yy - (y << 16)) >> 8);
- if (ca < 255)
- MULT(A_VAL(&col1), ca, A_VAL(&col1), tmp)
-
- len = rx - lx;
-
- if (IN_RANGE(lx, ty, clw, clh))
- pfunc(col1, tp);
- if (IN_RANGE(rx, ty, clw, clh))
- pfunc(col1, tp + len);
- if (IN_RANGE(lx, by, clw, clh))
- pfunc(col1, bp);
- if (IN_RANGE(rx, by, clw, clh))
- pfunc(col1, bp + len);
-
- dy += b2;
- yy -= ((dy << 16) / dx);
- lx--; rx++;
- tp--; bp--;
-
- if ( (ty > clh) || (by < 0) )
- return;
- }
-
- y = yy >> 16;
- xx = yy;
- prev_x = y;
-
- dx = dy;
-
- ty++;
- by--;
-
- tp += dstw;
- bp -= dstw;
-
- while (ty < yc)
- {
- int len;
- DATA32 tmp, *tpp, *bpp;
-
- x = xx >> 16;
-
- if (prev_x != x)
- {
- prev_x = x;
- dy += b2;
- lx--; rx++;
- tp--; bp--;
- }
-
- tpp = tp + 1;
- bpp = bp + 1;
- len = rx;
- if (len > clw) len = clw;
- len -= (lx + 1);
- if (lx < -1)
- {
- len += (lx + 1);
- tpp -= (lx + 1);
- bpp -= (lx + 1);
- }
-
- if ( ((unsigned)(ty) < clh) && (len > 0) )
- sfunc(color, tpp, len);
- if ( ((unsigned)(by) < clh) && (len > 0) )
- sfunc(color, bpp, len);
-
- A_VAL(&col1) = ((xx - (x << 16)) >> 8);
- if (ca < 255)
- MULT(A_VAL(&col1), ca, A_VAL(&col1), tmp)
-
- len = rx - lx;
-
- if (IN_RANGE(lx, ty, clw, clh))
- pfunc(col1, tp);
- if (IN_RANGE(rx, ty, clw, clh))
- pfunc(col1, tp + len);
- if (IN_RANGE(lx, by, clw, clh))
- pfunc(col1, bp);
- if (IN_RANGE(rx, by, clw, clh))
- pfunc(col1, bp + len);
-
- dx -= a2;
- xx += ((dx << 16) / dy);
- ty++; by--;
- tp += dstw;
- bp -= dstw;
-
- if ( (ty > clh) || (by < 0) )
- return;
- }
-}
-
-
-void
-__imlib_Ellipse_DrawToImage(int xc, int yc, int a, int b, DATA32 color,
- ImlibImage *im, int clx, int cly, int clw, int clh,
- ImlibOp op, char blend, char anti_alias)
-{
- int x, y, w, h;
-
- if ((a == 0) || (b == 0))
- {
- (void) __imlib_Line_DrawToImage(xc - a, yc - b, xc + a, yc + b, color,
- im, clx, cly, clw, clh,
- op, blend, anti_alias, 0);
- return;
- }
- if (blend && (!A_VAL(&color)))
- return;
- if (clw < 0)
- return;
- if (clw == 0)
- {
- clw = im->w;
- clx = 0;
- clh = im->h;
- cly = 0;
- }
-
- CLIP_RECT_TO_RECT(clx, cly, clw, clh, 0, 0, im->w, im->h);
- if ((clw < 1) || (clh < 1))
- return;
-
- if (a < 0) a = -a;
- if (b < 0) b = -b;
- if (a > 65535) a = 65535;
- if (b > 65535) b = 65535;
-
- w = 2 * (a + 1);
- h = 2 * (b + 1);
- x = xc - a - 1;
- y = yc - b - 1;
- if (anti_alias)
- {
- w += 2; h += 2;
- x--; y--;
- }
-
- CLIP_RECT_TO_RECT(x, y, w, h, clx, cly, clw, clh);
- if ((w < 1) || (h < 1))
- return;
-
- if (blend && IMAGE_HAS_ALPHA(im))
- __imlib_build_pow_lut();
-
- if (anti_alias)
- __imlib_Ellipse_DrawToData_AA(xc, yc, a, b, color,
- im->data, im->w, clx, cly, clw, clh,
- op, IMAGE_HAS_ALPHA(im), blend);
- else
- __imlib_Ellipse_DrawToData(xc, yc, a, b, color,
- im->data, im->w, clx, cly, clw, clh,
- op, IMAGE_HAS_ALPHA(im), blend);
-}
-
-
-void
-__imlib_Ellipse_FillToImage(int xc, int yc, int a, int b, DATA32 color,
- ImlibImage *im, int clx, int cly, int clw, int clh,
- ImlibOp op, char blend, char anti_alias)
-{
- int x, y, w, h;
-
- if ((a == 0) || (b == 0))
- {
- (void) __imlib_Line_DrawToImage(xc - a, yc - b, xc + a, yc + b, color,
- im, clx, cly, clw, clh,
- op, blend, anti_alias, 0);
- return;
- }
- if (blend && (!A_VAL(&color)))
- return;
- if (clw < 0)
- return;
- if (clw == 0)
- {
- clw = im->w;
- clx = 0;
- clh = im->h;
- cly = 0;
- }
-
- CLIP_RECT_TO_RECT(clx, cly, clw, clh, 0, 0, im->w, im->h);
- if ((clw < 1) || (clh < 1))
- return;
-
- if (a < 0) a = -a;
- if (b < 0) b = -b;
- if (a > 65535) a = 65535;
- if (b > 65535) b = 65535;
-
- w = 2 * (a + 1);
- h = 2 * (b + 1);
- x = xc - a - 1;
- y = yc - b - 1;
- if (anti_alias)
- {
- w += 2; h += 2;
- x--; y--;
- }
-
- CLIP_RECT_TO_RECT(x, y, w, h, clx, cly, clw, clh);
- if ((w < 1) || (h < 1))
- return;
-
- if (blend && IMAGE_HAS_ALPHA(im))
- __imlib_build_pow_lut();
-
- if (anti_alias)
- __imlib_Ellipse_FillToData_AA(xc, yc, a, b, color,
- im->data, im->w, clx, cly, clw, clh,
- op, IMAGE_HAS_ALPHA(im), blend);
- else
- __imlib_Ellipse_FillToData(xc, yc, a, b, color,
- im->data, im->w, clx, cly, clw, clh,
- op, IMAGE_HAS_ALPHA(im), blend);
-}
diff --git a/src/file.c b/src/file.c
deleted file mode 100644
index d693048..0000000
--- a/src/file.c
+++ /dev/null
@@ -1,506 +0,0 @@
-#include "common.h"
-#include <stdio.h>
-#include <ctype.h>
-#ifdef __EMX__
-#include <sys/types.h>
-#endif
-#include <sys/stat.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <dirent.h>
-#include <string.h>
-#include <stdlib.h>
-#include <pwd.h>
-#include "file.h"
-
-static void __imlib_FileFieldWord(char *s, int num, char *wd);
-
-char *
-__imlib_FileKey(const char *file)
-{
- char *newfile;
-
- newfile = malloc(strlen(file) + 1);
- 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);
- return NULL;
-}
-
-char *
-__imlib_FileRealFile(const char *file)
-{
- char *newfile;
-
- newfile = malloc(strlen(file) + 1);
- 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];
- }
- return newfile;
-}
-
-char *
-__imlib_FileExtension(const char *file)
-{
- char *p;
- char *fl;
-
- fl = __imlib_FileRealFile(file);
- if (!fl)
- return strdup("");
- p = strrchr(file, '.');
- if (p)
- {
- char *ret;
-
- ret = strdup(p + 1);
- free(fl);
- return ret;
- }
- free(fl);
- return strdup("");
-}
-
-int
-__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 (stat(fl, &st) < 0)
- {
- free(fl);
- return 0;
- }
- free(fl);
- return 1;
-}
-
-int
-__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 (stat(fl, &st) < 0)
- {
- free(fl);
- return 0;
- }
- if (S_ISREG(st.st_mode))
- {
- free(fl);
- return 1;
- }
- free(fl);
- return 0;
-}
-
-int
-__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 (stat(fl, &st) < 0)
- {
- free(fl);
- return 0;
- }
- if (S_ISDIR(st.st_mode))
- {
- free(fl);
- return 1;
- }
- free(fl);
- return 0;
-}
-
-int
-__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 (stat(fl, &st) < 0)
- {
- free(fl);
- return 0;
- }
- free(fl);
- return st.st_mode;
-}
-
-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_FilePermissions(fl) & (S_IRUSR | S_IRGRP | S_IROTH)))
- {
- free(fl);
- return 0;
- }
-
- val = (1 + access(fl, R_OK));
- free(fl);
- return val;
-}
-
-char **
-__imlib_FileDir(char *dir, int *num)
-{
- int i, dirlen;
- int done = 0;
- DIR *dirp;
- char **names;
- struct dirent *dp;
-
- if ((!dir) || (!*dir))
- return (0);
- dirp = opendir(dir);
- if (!dirp)
- {
- *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);
- }
- names = (char **)malloc(dirlen * sizeof(char *));
-
- if (!names)
- 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++;
- }
- }
-
- if (i < dirlen)
- 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;
- }
- }
- }
- return (names);
-}
-
-void
-__imlib_FileFreeDirList(char **l, int num)
-{
- if (!l)
- return;
- while (num--)
- if (l[num])
- free(l[num]);
- free(l);
- return;
-}
-
-void
-__imlib_FileDel(char *s)
-{
- if ((!s) || (!*s))
- return;
- unlink(s);
- return;
-}
-
-int
-__imlib_IsRealFile(const char *s)
-{
- struct stat st;
-
- return ((stat(s, &st) != -1) && (S_ISREG(st.st_mode)));
-}
-
-time_t
-__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 (stat(fl, &st) < 0)
- {
- free(fl);
- return 0;
- }
- if (st.st_mtime > st.st_ctime)
- {
- free(fl);
- return st.st_mtime;
- }
- free(fl);
- return st.st_ctime;
-}
-
-char *
-__imlib_FileHomeDir(int uid)
-{
- static int usr_uid = -1;
- static char *usr_s = NULL;
- char *s;
- struct passwd *pwd;
-
-#ifndef __EMX__
- s = getenv("HOME");
- if (s)
- return strdup(s);
- if (usr_uid < 0)
- usr_uid = getuid();
- if ((uid == usr_uid) && (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);
- }
-#else
- if ((s = getenv("HOME")) != NULL)
- return strdup(s);
- else if ((s = getenv("TMP")) != NULL)
- return strdup(s);
-#endif
- 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: */
-/* Hello to "Welcome sir - may I Help" Shub Foo */
-/* Word 1 = Hello */
-/* Word 2 = to */
-/* Word 3 = Welcome sir - may I Help */
-/* Word 4 = Shub */
-/* word 5 = Foo */
-
-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));
- }
- 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)
- return;
- *wd = 0;
- if (num <= 0)
- return;
- cur = s;
- count = 0;
- inword = 0;
- inquote = 0;
- start = NULL;
- 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 (!start)
- return;
- if (!end)
- end = cur;
- if (end <= start)
- return;
- len = (int)(end - start);
- if (len > 4000)
- len = 4000;
- if (len > 0)
- {
- strncpy(wd, start, len);
- wd[len] = 0;
- }
- return;
-}
diff --git a/src/file.h b/src/file.h
deleted file mode 100644
index 5544175..0000000
--- a/src/file.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef __FILE
-#define __FILE 1
-char *__imlib_FileKey(const char *file);
-char *__imlib_FileRealFile(const char *file);
-char *__imlib_FileExtension(const char *file);
-int __imlib_FileExists(const char *s);
-int __imlib_FileIsFile(const char *s);
-int __imlib_FileIsDir(const char *s);
-char **__imlib_FileDir(char *dir, int *num);
-void __imlib_FileFreeDirList(char **l, int num);
-void __imlib_FileDel(char *s);
-time_t __imlib_FileModDate(const char *s);
-char *__imlib_FileHomeDir(int uid);
-char *__imlib_FileField(char *s, int field);
-int __imlib_FilePermissions(const char *s);
-int __imlib_FileCanRead(const char *s);
-int __imlib_IsRealFile(const char *s);
-
-
-#endif
diff --git a/src/filter.c b/src/filter.c
deleted file mode 100644
index 6436dee..0000000
--- a/src/filter.c
+++ /dev/null
@@ -1,241 +0,0 @@
-#include "common.h"
-#include "colormod.h"
-#include "image.h"
-#include "blend.h"
-#include "filter.h"
-
-/*\ Create and return an empty filter struct \*/
-ImlibFilter *
-__imlib_CreateFilter(int size)
-{
- 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;
- }
- fil->alpha.entries = 0;
- fil->red.entries = 0;
- fil->green.entries = 0;
- fil->blue.entries = 0;
- fil->alpha.div = 0;
- fil->red.div = 0;
- fil->green.div = 0;
- fil->blue.div = 0;
- fil->alpha.cons = 0;
- fil->red.cons = 0;
- fil->green.cons = 0;
- fil->blue.cons = 0;
- return fil;
-}
-
-/*\ Free a filter struct \*/
-void
-__imlib_FreeFilter(ImlibFilter * fil)
-{
- free(fil->alpha.pixels);
- free(fil->red.pixels);
- free(fil->green.pixels);
- free(fil->blue.pixels);
- free(fil);
-}
-
-void
-__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;
- pix[i].xoff = x;
- pix[i].yoff = y;
- pix[i].a = a;
- pix[i].r = r;
- pix[i].g = g;
- pix[i].b = b;
-}
-
-/*\ Set the divisors manually \*/
-void
-__imlib_FilterDivisors(ImlibFilter * fil, int a, int r, int g, int b)
-{
- fil->alpha.div = a;
- fil->red.div = r;
- fil->green.div = g;
- fil->blue.div = b;
-}
-
-/*\ Set the constants \*/
-void
-__imlib_FilterConstants(ImlibFilter * fil, int a, int r, int g, int b)
-{
- fil->alpha.cons = a;
- fil->red.cons = r;
- fil->green.cons = g;
- fil->blue.cons = b;
-}
-
-static int
-__imlib_FilterCalcDiv(ImlibFilterColor * fil)
-{
- int i, ret;
- ImlibFilterPixel *pix;
-
- 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++;
- }
- return ret;
-}
-
-static int
-__imlib_FilterGet(ImlibFilterColor * fil, DATA32 * data,
- int w, int h, int x, int y)
-{
- 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++;
- }
- return ret;
-}
-
-/*\ Correct saturation from [-32768, 32767] to [0, 255] \*/
-#define SATURATE(x) ((((x) | (!((x) >> 8) - 1)) & (~((x) >> 31))) & 0xff)
-
-/*\ Filter an image with the a, r, g, b filters in fil
-|*| NB: This is currently not very optimal, and could probably be improved
-\*/
-void
-__imlib_FilterImage(ImlibImage * im, ImlibFilter * fil)
-{
- 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;
-
- ad = __imlib_FilterCalcDiv(&fil->alpha);
- rd = __imlib_FilterCalcDiv(&fil->red);
- gd = __imlib_FilterCalcDiv(&fil->green);
- bd = __imlib_FilterCalcDiv(&fil->blue);
-
- 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++;
- }
- }
- free(im->data);
- im->data = data;
-}
diff --git a/src/filter.h b/src/filter.h
deleted file mode 100644
index 0c504b0..0000000
--- a/src/filter.h
+++ /dev/null
@@ -1,42 +0,0 @@
-#ifndef __FILTER
-#define __FILTER 1
-
-typedef struct _imlib_filter ImlibFilter;
-typedef struct _imlib_filter_color ImlibFilterColor;
-typedef struct _imlib_filter_pixel ImlibFilterPixel;
-
-struct _imlib_filter_pixel
-{
- int xoff, yoff;
- int a, r, g, b;
-};
-
-struct _imlib_filter_color
-{
- int size, entries;
- int div, cons;
- ImlibFilterPixel *pixels;
-};
-
-struct _imlib_filter
-{
- ImlibFilterColor alpha, red, green, blue;
-};
-
-ImlibFilter *
-__imlib_CreateFilter(int size);
-void
-__imlib_FreeFilter(ImlibFilter *fil);
-void
-__imlib_FilterSet(ImlibFilterColor *fil, int x, int y,
- int a, int r, int g, int b);
-void
-__imlib_FilterSetColor(ImlibFilterColor * fil, int x, int y,
- int a, int r, int g, int b);
-void
-__imlib_FilterDivisors(ImlibFilter *fil, int a, int r, int g, int b);
-void
-__imlib_FilterConstants(ImlibFilter *fil, int a, int r, int g, int b);
-void
-__imlib_FilterImage(ImlibImage *im, ImlibFilter *fil);
-#endif
diff --git a/src/font.h b/src/font.h
deleted file mode 100644
index 526acb3..0000000
--- a/src/font.h
+++ /dev/null
@@ -1,126 +0,0 @@
-
-#include <ft2build.h>
-#include FT_FREETYPE_H
-#include FT_GLYPH_H
-
-/* TODO separate fonts and data stuff */
-
-typedef struct _Imlib_Font ImlibFont;
-typedef struct _Imlib_Font_Glyph Imlib_Font_Glyph;
-
-typedef struct _Imlib_Object_List Imlib_Object_List;
-typedef struct _Imlib_Hash Imlib_Hash;
-typedef struct _Imlib_Hash_El Imlib_Hash_El;
-
-struct _Imlib_Object_List
-{
- Imlib_Object_List *next, *prev;
- Imlib_Object_List *last;
-};
-
-struct _Imlib_Hash
-{
- int population;
- Imlib_Object_List *buckets[256];
-};
-
-struct _Imlib_Hash_El
-{
- Imlib_Object_List _list_data;
- char *key;
- void *data;
-};
-
-struct _Imlib_Font
-{
- Imlib_Object_List _list_data;
- char *name;
- char *file;
- int size;
-
- struct
- {
- FT_Face face;
- }
- ft;
-
- Imlib_Hash *glyphs;
-
- int usage;
-
- int references;
-
-};
-
-struct _Imlib_Font_Glyph
-{
- FT_Glyph glyph;
- FT_BitmapGlyph glyph_out;
-};
-
-/* 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);
-int imlib_font_cache_get(void);
-void imlib_font_cache_set(int size);
-void imlib_font_flush(void);
-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/font_draw.c b/src/font_draw.c
deleted file mode 100644
index 69985ff..0000000
--- a/src/font_draw.c
+++ /dev/null
@@ -1,421 +0,0 @@
-#include "config.h"
-#include "common.h"
-#include "colormod.h"
-#include "image.h"
-#include "blend.h"
-#include <ft2build.h>
-#include FT_FREETYPE_H
-#include FT_GLYPH_H
-#include "font.h"
-#include <sys/types.h>
-#include <string.h>
-#include <math.h>
-#include "file.h"
-#include "updates.h"
-#include "rgbadraw.h"
-#include "rotate.h"
-
-extern FT_Library ft_lib;
-
-Imlib_Font_Glyph *
-imlib_font_cache_glyph_get(ImlibFont * fn, FT_UInt index)
-{
- Imlib_Font_Glyph *fg;
- char key[6];
- FT_Error error;
-
- key[0] = ((index) & 0x7f) + 1;
- key[1] = ((index >> 7) & 0x7f) + 1;
- key[2] = ((index >> 14) & 0x7f) + 1;
- key[3] = ((index >> 21) & 0x7f) + 1;
- key[4] = ((index >> 28) & 0x0f) + 1;
- key[5] = 0;
-
- fg = imlib_hash_find(fn->glyphs, key);
- if (fg)
- return fg;
-
- error = FT_Load_Glyph(fn->ft.face, index, FT_LOAD_NO_BITMAP);
- if (error)
- return NULL;
-
- fg = malloc(sizeof(struct _Imlib_Font_Glyph));
- if (!fg)
- return NULL;
- memset(fg, 0, (sizeof(struct _Imlib_Font_Glyph)));
-
- error = FT_Get_Glyph(fn->ft.face->glyph, &(fg->glyph));
- if (error)
- {
- free(fg);
- return NULL;
- }
- if (fg->glyph->format != ft_glyph_format_bitmap)
- {
- error = FT_Glyph_To_Bitmap(&(fg->glyph), ft_render_mode_normal, 0, 1);
- if (error)
- {
- FT_Done_Glyph(fg->glyph);
- free(fg);
- return NULL;
- }
- }
- fg->glyph_out = (FT_BitmapGlyph) fg->glyph;
-
- fn->glyphs = imlib_hash_add(fn->glyphs, key, fg);
- return fg;
-}
-
-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 clx, int cly,
- int clw, int clh)
-{
- int w, h, ascent;
- ImlibImage *im2;
- DATA32 *data, col;
- int nx, ny, tmp;
-
- imlib_font_query_advance(fn, text, &w, &h);
-
- data = malloc(w * h * sizeof(DATA32));
- if (!data)
- return;
- memset(data, 0, w * h * sizeof(DATA32));
- /* TODO check if this is the right way of rendering. Esp for huge sizes */
- im2 = __imlib_CreateImage(w, h, data);
- if (!im2)
- {
- free(data);
- return;
- }
- SET_FLAG(im2->flags, F_HAS_ALPHA);
-
- /* TODO check for endianess */
- col = (a << 24) | (r << 16) | (g << 8) | b;
-
- ascent = imlib_font_max_ascent_get(fn);
-
- imlib_font_draw(im2, col, fn, 0, ascent, text, &nx, &ny, clx, cly, clw, clh);
-
- /* OK, now we have small ImlibImage with text rendered,
- * have to blend it on im */
-
- if (blur > 0)
- __imlib_BlurImage(im2, blur);
-
- switch (dir)
- {
- case 0: /* to right */
- angle = 0.0;
- break;
- case 1: /* to left */
- angle = 0.0;
- __imlib_FlipImageBoth(im2);
- break;
- case 2: /* to down */
- angle = 0.0;
- __imlib_FlipImageDiagonal(im2, 1);
- break;
- case 3: /* to up */
- angle = 0.0;
- __imlib_FlipImageDiagonal(im2, 2);
- break;
- default:
- break;
- }
- if (angle == 0.0)
- {
- __imlib_BlendImageToImage(im2, im, 0, 1, IMAGE_HAS_ALPHA(im), 0, 0,
- im2->w, im2->h, drx, dry, im2->w, im2->h,
- NULL, op, clx, cly, clw, clh);
- }
- else
- {
- int xx, yy;
- double sa, ca;
-
- sa = sin(angle);
- ca = cos(angle);
- xx = drx;
- yy = dry;
- if (sa > 0.0)
- xx += sa * im2->h;
- else
- yy -= sa * im2->w;
- if (ca < 0.0)
- {
- xx -= ca * im2->w;
- yy -= ca * im2->h;
- }
- __imlib_BlendImageToImageSkewed(im2, im, 1, 1, IMAGE_HAS_ALPHA(im), 0,
- 0, im2->w, im2->h, xx, yy, (w * ca),
- (w * sa), 0, 0, NULL, op, clx, cly, clw,
- clh);
- }
-
- __imlib_FreeImage(im2);
-
- /* finally deal with return values */
- switch (dir)
- {
- case 0:
- case 1:
- if (retw)
- *retw = w;
- if (reth)
- *reth = h;
- if (nextx)
- *nextx = nx;
- if (nexty)
- *nexty = ny;
- break;
- case 2:
- case 3:
- if (retw)
- *retw = h;
- if (reth)
- *reth = w;
- if (nextx)
- *nextx = ny;
- if (nexty)
- *nexty = nx;
- break;
- case 4:
- {
- double sa, ca;
- double x1, x2, xt;
- double y1, y2, yt;
-
- sa = sin(angle);
- ca = cos(angle);
-
- 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;
- w = (int)(x2 - x1);
-
- 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;
- h = (int)(y2 - y1);
- }
- if (retw)
- *retw = w;
- if (reth)
- *reth = h;
- if (nextx)
- *nextx = nx;
- if (nexty)
- *nexty = ny;
- break;
- default:
- break;
- }
-
- /* TODO this function is purely my art -- check once more */
-}
-
-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)
-{
- int use_kerning;
- int pen_x, pen_y;
- int chr;
- FT_UInt prev_index;
- int ext_x, ext_y, ext_w, ext_h;
- DATA32 *im;
- int im_w, im_h;
- int lut[256];
- int ii;
-
- im = dst->data;
- im_w = dst->w;
- im_h = dst->h;
-
- ext_x = 0;
- ext_y = 0;
- ext_w = im_w;
- ext_h = im_h;
-
- if (clw)
- {
- ext_x = clx;
- ext_y = cly;
- ext_w = clw;
- ext_h = clh;
- }
- if (ext_x < 0)
- {
- ext_w += ext_x;
- ext_x = 0;
- }
- if (ext_y < 0)
- {
- ext_h += ext_y;
- ext_y = 0;
- }
- if ((ext_x + ext_w) > im_w)
- ext_w = im_w - ext_x;
- if ((ext_y + ext_h) > im_h)
- ext_h = im_h - ext_y;
-
- if (ext_w <= 0)
- return;
- if (ext_h <= 0)
- return;
-
- for (ii = 0; ii < 256; ii++)
- {
- lut[ii] = (col & 0x00ffffff); /* TODO check endianess */
- lut[ii] |= ((((ii + 1) * (col >> 24)) >> 8) << 24);
- }
-
- pen_x = x << 8;
- pen_y = y << 8;
- use_kerning = FT_HAS_KERNING(fn->ft.face);
- prev_index = 0;
- for (chr = 0; text[chr];)
- {
- FT_UInt index;
- Imlib_Font_Glyph *fg;
- int chr_x, chr_y;
- int gl;
-
- gl = imlib_font_utf8_get_next((unsigned char *)text, &chr);
- if (gl == 0)
- break;
- index = FT_Get_Char_Index(fn->ft.face, gl);
- if ((use_kerning) && (prev_index) && (index))
- {
- FT_Vector delta;
-
- FT_Get_Kerning(fn->ft.face, prev_index, index, ft_kerning_default,
- &delta);
- pen_x += delta.x << 2;
- }
- fg = imlib_font_cache_glyph_get(fn, index);
- if (!fg)
- continue;
-
- chr_x = (pen_x + (fg->glyph_out->left << 8)) >> 8;
- chr_y = (pen_y + (fg->glyph_out->top << 8)) >> 8;
-
- if (chr_x < (ext_x + ext_w))
- {
- DATA8 *data;
- int i, j, w, h;
-
- data = fg->glyph_out->bitmap.buffer;
- j = fg->glyph_out->bitmap.pitch;
- w = fg->glyph_out->bitmap.width;
- if (j < w)
- j = w;
- h = fg->glyph_out->bitmap.rows;
- if ((fg->glyph_out->bitmap.pixel_mode == ft_pixel_mode_grays)
- && (fg->glyph_out->bitmap.num_grays == 256))
- {
- if ((j > 0) && (chr_x + w > ext_x))
- {
- for (i = 0; i < h; i++)
- {
- int dx, dy;
- int in_x, in_w;
-
- in_x = 0;
- in_w = 0;
- dx = chr_x;
- dy = y - (chr_y - i - y);
- if ((dx < (ext_x + ext_w)) && (dy >= (ext_y))
- && (dy < (ext_y + ext_h)))
- {
- if (dx + w > (ext_x + ext_w))
- in_w += (dx + w) - (ext_x + ext_w);
- if (dx < ext_x)
- {
- in_w += ext_x - dx;
- in_x = ext_x - dx;
- dx = ext_x;
- }
- if (in_w < w)
- {
- DATA8 *src_ptr;
- DATA32 *dst_ptr;
- DATA32 *dst_end_ptr;
-
- src_ptr = data + (i * j) + in_x;
- dst_ptr = im + (dy * im_w) + dx;
- dst_end_ptr = dst_ptr + w - in_w;
-
- while (dst_ptr < dst_end_ptr)
- {
- /* FIXME Oops! change this op */
- if (!*dst_ptr)
- *dst_ptr =
- lut[(unsigned char)*src_ptr];
- else if (*src_ptr)
- {
- /* very rare case - I've never seen symbols
- * overlapped by kerning */
- int tmp;
-
- tmp =
- (*dst_ptr >> 24) +
- (lut
- [(unsigned char)*src_ptr]
- >> 24);
- tmp = (tmp > 256) ? 256 : tmp;
- *dst_ptr &= 0x00ffffff;
- *dst_ptr |= (tmp << 24);
- }
-
- dst_ptr++;
- src_ptr++;
- }
- }
- }
- }
- }
- }
- }
- else
- break;
- pen_x += fg->glyph->advance.x >> 8;
- prev_index = index;
- }
-
- if (nextx)
- *nextx = (pen_x >> 8) - x;
- if (nexty)
- *nexty = imlib_font_get_line_advance(fn);
-}
diff --git a/src/font_load.c b/src/font_load.c
deleted file mode 100644
index c86f3c3..0000000
--- a/src/font_load.c
+++ /dev/null
@@ -1,431 +0,0 @@
-#include "config.h"
-#include "common.h"
-#include "colormod.h"
-#include "image.h"
-#include "blend.h"
-#include <ft2build.h>
-#include FT_FREETYPE_H
-#include FT_GLYPH_H
-#include "font.h"
-#include <sys/types.h>
-#include <string.h>
-#include <math.h>
-#include "file.h"
-#include "updates.h"
-#include "rgbadraw.h"
-#include "rotate.h"
-
-extern FT_Library ft_lib;
-
-static int font_cache_usage = 0;
-static int font_cache = 0;
-static char **fpath = NULL;
-static int fpath_num = 0;
-static Imlib_Object_List *fonts = NULL;
-
-static int font_modify_cache_cb(Imlib_Hash * hash, const char *key,
- void *data, void *fdata);
-static int font_flush_free_glyph_cb(Imlib_Hash * hash, const char *key,
- void *data, void *fdata);
-
-/* FIXME now! listdir() from evas_object_text.c */
-
-/* separate fontname and size, find font file, start imlib_font_load() then */
-ImlibFont *
-imlib_font_load_joined(const char *fontname)
-{
- int j, size;
- char *name = NULL, *file = NULL, *tmp = NULL;
- ImlibFont *fn;
-
- /* split font name (in format name/size) */
- for (j = strlen(fontname) - 1; (j >= 0) && (fontname[j] != '/'); j--);
- /* no "/" in font after the first char */
- if (j <= 0)
- return NULL;
- /* get size */
- size = atoi(&(fontname[j + 1]));
- /* split name in front off */
- name = malloc((j + 1) * sizeof(char));
- memcpy(name, fontname, j);
- name[j] = 0;
- /* find file if it exists */
- tmp = malloc(strlen(name) + 4 + 1);
- if (!tmp)
- {
- free(name);
- return NULL;
- }
- sprintf(tmp, "%s.ttf", name);
- if (__imlib_FileIsFile(tmp))
- file = strdup(tmp);
- else
- {
- sprintf(tmp, "%s.TTF", name);
- if (__imlib_FileIsFile(tmp))
- file = strdup(tmp);
- else
- {
- sprintf(tmp, "%s", name);
- if (__imlib_FileIsFile(tmp))
- file = strdup(tmp);
- }
- }
- free(tmp);
- if (!file)
- {
- for (j = 0; (j < fpath_num) && (!file); j++)
- {
- tmp = malloc(strlen(fpath[j]) + 1 + strlen(name) + 4 + 1);
- if (!tmp)
- {
- free(name);
- return NULL;
- }
- else
- {
- sprintf(tmp, "%s/%s.ttf", fpath[j], name);
- if (__imlib_FileIsFile(tmp))
- file = strdup(tmp);
- else
- {
- sprintf(tmp, "%s/%s.TTF", fpath[j], name);
- if (__imlib_FileIsFile(tmp))
- file = strdup(tmp);
- else
- {
- sprintf(tmp, "%s/%s", fpath[j], name);
- if (__imlib_FileIsFile(tmp))
- file = strdup(tmp);
- }
- }
- }
- free(tmp);
- }
- }
- free(name);
- /* didnt find a file? abort */
- if (!file)
- return NULL;
- fn = imlib_font_load(file, size);
- free(file);
- return fn;
-}
-
-ImlibFont *
-imlib_font_load(const char *name, int size)
-{
- int error;
- ImlibFont *fn;
- char *file;
-
- fn = imlib_font_find(name, size);
- if (fn)
- return fn;
-
- imlib_font_init();
-
- fn = malloc(sizeof(ImlibFont));
- file = (char *)name;
-
- error = FT_New_Face(ft_lib, file, 0, &(fn->ft.face));
- if (error)
- {
- free(fn);
- return NULL;
- }
- error = FT_Set_Char_Size(fn->ft.face, 0, (size * 64), 96, 96);
- if (error)
- error = FT_Set_Pixel_Sizes(fn->ft.face, 0, size);
- if (error)
- {
- int i;
- int chosen_size = 0;
- int chosen_width = 0;
-
- for (i = 0; i < fn->ft.face->num_fixed_sizes; i++)
- {
- int s;
- int d, cd;
-
- s = fn->ft.face->available_sizes[i].height;
- cd = chosen_size - size;
- if (cd < 0)
- cd = -cd;
- d = s - size;
- if (d < 0)
- d = -d;
- if (d < cd)
- {
- chosen_width = fn->ft.face->available_sizes[i].width;
- chosen_size = s;
- }
- if (d == 0)
- break;
- }
- error = FT_Set_Pixel_Sizes(fn->ft.face, chosen_width, chosen_size);
- if (error)
- {
- /* couldn't choose the size anyway... what now? */
- }
- }
-
- error = FT_Select_Charmap(fn->ft.face, ft_encoding_unicode);
- if (error)
- {
- }
-
- fn->file = strdup(file);
- fn->name = strdup(file);
- fn->size = size;
-
- fn->glyphs = NULL;
-
- fn->usage = 0;
-
- fn->references = 1;
-
- fonts = imlib_object_list_prepend(fonts, fn);
- return fn;
-}
-
-void
-imlib_font_free(ImlibFont * fn)
-{
- fn->references--;
- if (fn->references == 0)
- {
- imlib_font_modify_cache_by(fn, 1);
- imlib_font_flush();
- }
-}
-
-static int
-font_modify_cache_cb(Imlib_Hash * hash, const char *key, void *data,
- void *fdata)
-{
- int *dir;
- Imlib_Font_Glyph *fg;
-
- fg = data;
- dir = fdata;
- font_cache_usage += (*dir) * ((fg->glyph_out->bitmap.width * fg->glyph_out->bitmap.rows) + sizeof(Imlib_Font_Glyph) + sizeof(Imlib_Object_List) + 400); /* fudge values */
- return 1;
- hash = 0;
- key = 0;
-}
-
-void
-imlib_font_modify_cache_by(ImlibFont * fn, int dir)
-{
- int sz_name = 0, sz_file = 0, sz_hash = 0;
-
- if (fn->name)
- sz_name = strlen(fn->name);
- if (fn->file)
- sz_file = strlen(fn->file);
- if (fn->glyphs)
- sz_hash = sizeof(Imlib_Hash);
- imlib_hash_foreach(fn->glyphs, font_modify_cache_cb, &dir);
- font_cache_usage += dir * (sizeof(ImlibFont) + sz_name + sz_file + sz_hash + sizeof(FT_FaceRec) + 16384); /* fudge values */
-}
-
-int
-imlib_font_cache_get(void)
-{
- return font_cache;
-}
-
-void
-imlib_font_cache_set(int size)
-{
- font_cache = size;
- imlib_font_flush();
-}
-
-void
-imlib_font_flush(void)
-{
- if (font_cache_usage < font_cache)
- return;
- while (font_cache_usage > font_cache)
- imlib_font_flush_last();
-}
-
-static int
-font_flush_free_glyph_cb(Imlib_Hash * hash, const char *key, void *data,
- void *fdata)
-{
- Imlib_Font_Glyph *fg;
-
- fg = data;
- FT_Done_Glyph(fg->glyph);
- free(fg);
- return 1;
- hash = 0;
- key = 0;
- fdata = 0;
-}
-
-void
-imlib_font_flush_last(void)
-{
- Imlib_Object_List *l;
- ImlibFont *fn = NULL;
-
- for (l = fonts; l; l = l->next)
- {
- ImlibFont *fn_tmp;
-
- fn_tmp = (ImlibFont *) l;
- if (fn_tmp->references == 0)
- fn = fn_tmp;
- }
- if (!fn)
- return;
-
- fonts = imlib_object_list_remove(fonts, fn);
- imlib_font_modify_cache_by(fn, -1);
-
- imlib_hash_foreach(fn->glyphs, font_flush_free_glyph_cb, NULL);
- imlib_hash_free(fn->glyphs);
-
- if (fn->file)
- free(fn->file);
- if (fn->name)
- free(fn->name);
- FT_Done_Face(fn->ft.face);
- free(fn);
-}
-
-ImlibFont *
-imlib_font_find(const char *name, int size)
-{
- Imlib_Object_List *l;
-
- for (l = fonts; l; l = l->next)
- {
- ImlibFont *fn;
-
- fn = (ImlibFont *) l;
- if ((fn->size == size) && (!strcmp(name, fn->name)))
- {
- if (fn->references == 0)
- imlib_font_modify_cache_by(fn, -1);
- fn->references++;
- fonts = imlib_object_list_remove(fonts, fn);
- fonts = imlib_object_list_prepend(fonts, fn);
- return fn;
- }
- }
- return NULL;
-}
-
-/* font pathes */
-void
-imlib_font_add_font_path(const char *path)
-{
- fpath_num++;
- if (!fpath)
- fpath = malloc(sizeof(char *));
- else
- fpath = realloc(fpath, (fpath_num * sizeof(char *)));
- fpath[fpath_num - 1] = strdup(path);
-}
-
-void
-imlib_font_del_font_path(const char *path)
-{
- int i, j;
-
- for (i = 0; i < fpath_num; i++)
- {
- if (!strcmp(path, fpath[i]))
- {
- if (fpath[i])
- free(fpath[i]);
- fpath_num--;
- for (j = i; j < fpath_num; j++)
- fpath[j] = fpath[j + 1];
- if (fpath_num > 0)
- fpath = realloc(fpath, fpath_num * sizeof(char *));
- else
- {
- free(fpath);
- fpath = NULL;
- }
- }
- }
-}
-
-int
-imlib_font_path_exists(const char *path)
-{
- int i;
-
- for (i = 0; i < fpath_num; i++)
- {
- if (!strcmp(path, fpath[i]))
- return 1;
- }
- return 0;
-}
-
-char **
-imlib_font_list_font_path(int *num_ret)
-{
- *num_ret = fpath_num;
- return fpath;
-}
-
-/* fonts list */
-char **
-imlib_font_list_fonts(int *num_ret)
-{
- int i, j, d, l = 0;
- char **list = NULL, **dir, *path;
- FT_Error error;
- char *p;
-
- imlib_font_init();
-
- for (i = 0; i < fpath_num; i++)
- {
- dir = __imlib_FileDir(fpath[i], &d);
- if (dir)
- {
- for (j = 0; j < d; j++)
- {
- path = malloc(strlen(fpath[i]) + strlen(dir[j]) + 2);
- sprintf(path, "%s/%s", fpath[i], dir[j]);
- /* trim .ttf if it is there */
- if ((p = strrchr(dir[j], '.')))
- *p = '\0';
- if (!__imlib_ItemInList(list, l, dir[j]))
- {
- if (__imlib_FileIsFile(path))
- {
- FT_Face f;
-
- error = FT_New_Face(ft_lib, path, 0, &f);
- if (!error)
- {
- FT_Done_Face(f);
- l++;
- if (list)
- list = realloc(list, sizeof(char *) * l);
- else
- list = malloc(sizeof(char *));
- list[l - 1] = strdup(dir[j]);
- }
- free(dir[j]);
- }
- }
- free(path);
- }
- free(dir);
- }
- }
- *num_ret = l;
- return list;
-}
diff --git a/src/font_main.c b/src/font_main.c
deleted file mode 100644
index e266cc6..0000000
--- a/src/font_main.c
+++ /dev/null
@@ -1,418 +0,0 @@
-#include "config.h"
-#include "common.h"
-#include "colormod.h"
-#include "image.h"
-#include "blend.h"
-#include <ft2build.h>
-#include FT_FREETYPE_H
-#include FT_GLYPH_H
-#include "font.h"
-#include <sys/types.h>
-#include <string.h>
-#include <math.h>
-#include "file.h"
-#include "updates.h"
-#include "rgbadraw.h"
-#include "rotate.h"
-
-FT_Library ft_lib;
-
-static int imlib_hash_gen(const char *key);
-static int imlib_list_alloc_error(void);
-
-static int _imlib_hash_alloc_error = 0;
-static int _imlib_list_alloc_error = 0;
-
-void
-imlib_font_init(void)
-{
- static int initialised = 0;
- int error;
-
- if (initialised)
- return;
- error = FT_Init_FreeType(&ft_lib);
- if (error)
- return;
- initialised = 1;
-}
-
-int
-imlib_font_ascent_get(ImlibFont * fn)
-{
- int val;
- int ret;
-
- val = (int)fn->ft.face->ascender;
- fn->ft.face->units_per_EM = 2048; /* nasy hack - need to have correct
- * val */
- ret =
- (val * fn->ft.face->size->metrics.y_scale) /
- (fn->ft.face->units_per_EM * fn->ft.face->units_per_EM);
- return ret;
-}
-
-int
-imlib_font_descent_get(ImlibFont * fn)
-{
- int val;
- int ret;
-
- val = -(int)fn->ft.face->descender;
- fn->ft.face->units_per_EM = 2048; /* nasy hack - need to have correct
- * val */
- ret =
- (val * fn->ft.face->size->metrics.y_scale) /
- (fn->ft.face->units_per_EM * fn->ft.face->units_per_EM);
- return ret;
-}
-
-int
-imlib_font_max_ascent_get(ImlibFont * fn)
-{
- int val;
- int ret;
-
- val = (int)fn->ft.face->bbox.yMax;
- fn->ft.face->units_per_EM = 2048; /* nasy hack - need to have correct
- * val */
- ret =
- (val * fn->ft.face->size->metrics.y_scale) /
- (fn->ft.face->units_per_EM * fn->ft.face->units_per_EM);
- return ret;
-}
-
-int
-imlib_font_max_descent_get(ImlibFont * fn)
-{
- int val;
- int ret;
-
- val = (int)fn->ft.face->bbox.yMin;
- fn->ft.face->units_per_EM = 2048; /* nasy hack - need to have correct
- * val */
- ret =
- (val * fn->ft.face->size->metrics.y_scale) /
- (fn->ft.face->units_per_EM * fn->ft.face->units_per_EM);
- return ret;
-}
-
-int
-imlib_font_get_line_advance(ImlibFont * fn)
-{
- int val;
- int ret;
-
- val = (int)fn->ft.face->height;
- fn->ft.face->units_per_EM = 2048; /* nasy hack - need to have correct
- * val */
- ret =
- (val * fn->ft.face->size->metrics.y_scale) /
- (fn->ft.face->units_per_EM * fn->ft.face->units_per_EM);
- return ret;
-}
-
-int
-imlib_font_utf8_get_next(unsigned char *buf, int *iindex)
-{
- /* Reads UTF8 bytes from @buf, starting at *@index and returns the code
- * point of the next valid code point. @index is updated ready for the
- * next call.
- *
- * * Returns 0 to indicate an error (e.g. invalid UTF8) */
-
- int index = *iindex, r;
- unsigned char d = buf[index++], d2, d3, d4;
-
- if (!d)
- return 0;
- if (d < 0x80)
- {
- *iindex = index;
- return d;
- }
- if ((d & 0xe0) == 0xc0)
- {
- /* 2 byte */
- d2 = buf[index++];
- if ((d2 & 0xc0) != 0x80)
- return 0;
- r = d & 0x1f; /* copy lower 5 */
- r <<= 6;
- r |= (d2 & 0x3f); /* copy lower 6 */
- }
- else if ((d & 0xf0) == 0xe0)
- {
- /* 3 byte */
- d2 = buf[index++];
- d3 = buf[index++];
- if ((d2 & 0xc0) != 0x80 || (d3 & 0xc0) != 0x80)
- return 0;
- r = d & 0x0f; /* copy lower 4 */
- r <<= 6;
- r |= (d2 & 0x3f);
- r <<= 6;
- r |= (d3 & 0x3f);
- }
- else
- {
- /* 4 byte */
- d2 = buf[index++];
- d3 = buf[index++];
- d4 = buf[index++];
- if ((d2 & 0xc0) != 0x80 || (d3 & 0xc0) != 0x80 || (d4 & 0xc0) != 0x80)
- return 0;
- r = d & 0x0f; /* copy lower 4 */
- r <<= 6;
- r |= (d2 & 0x3f);
- r <<= 6;
- r |= (d3 & 0x3f);
- r <<= 6;
- r |= (d4 & 0x3f);
-
- }
- if (r < 0xdfff && d > 0xd800)
- {
- /* ill-formed says Table 3.1B in the */
- /* Unicode 3.2 std */
- return 0;
- }
- *iindex = index;
- return r;
-}
-
-/* TODO put this somewhere else */
-
-void *
-imlib_object_list_prepend(void *in_list, void *in_item)
-{
- Imlib_Object_List *new_l;
- Imlib_Object_List *list, *item;
-
- list = in_list;
- item = in_item;
- new_l = item;
- new_l->prev = NULL;
- if (!list)
- {
- new_l->next = NULL;
- new_l->last = new_l;
- return new_l;
- }
- new_l->next = list;
- list->prev = new_l;
- new_l->last = list->last;
- list->last = NULL;
- return new_l;
-}
-
-void *
-imlib_object_list_remove(void *in_list, void *in_item)
-{
- Imlib_Object_List *return_l;
- Imlib_Object_List *list, *item;
-
- /* checkme */
- if (!in_list)
- return in_list;
-
- list = in_list;
- item = in_item;
- if (!item)
- return list;
- if (item->next)
- item->next->prev = item->prev;
- if (item->prev)
- {
- item->prev->next = item->next;
- return_l = list;
- }
- else
- {
- return_l = item->next;
- if (return_l)
- return_l->last = list->last;
- }
- if (item == list->last)
- list->last = item->prev;
- item->next = NULL;
- item->prev = NULL;
- return return_l;
-}
-
-static int
-imlib_hash_gen(const char *key)
-{
- unsigned int hash_num = 0;
- const unsigned char *ptr;
-
- if (!key)
- return 0;
-
- for (ptr = (unsigned char *)key; *ptr; ptr++)
- hash_num ^= (int)(*ptr);
-
- hash_num &= 0xff;
- return (int)hash_num;
-}
-
-Imlib_Hash *
-imlib_hash_add(Imlib_Hash * hash, const char *key, const void *data)
-{
- int hash_num;
- Imlib_Hash_El *el;
-
- _imlib_hash_alloc_error = 0;
- if (!hash)
- {
- hash = calloc(1, sizeof(struct _Imlib_Hash));
- if (!hash)
- {
- _imlib_hash_alloc_error = 1;
- return NULL;
- }
- }
- if (!(el = malloc(sizeof(struct _Imlib_Hash_El))))
- {
- if (hash->population <= 0)
- {
- free(hash);
- hash = NULL;
- }
- _imlib_hash_alloc_error = 1;
- return hash;
- };
- if (key)
- {
- el->key = strdup(key);
- if (!el->key)
- {
- free(el);
- _imlib_hash_alloc_error = 1;
- return hash;
- }
- hash_num = imlib_hash_gen(key);
- }
- else
- {
- el->key = NULL;
- hash_num = 0;
- }
- el->data = (void *)data;
-
- hash->buckets[hash_num] =
- imlib_object_list_prepend(hash->buckets[hash_num], el);
-
- if (imlib_list_alloc_error())
- {
- _imlib_hash_alloc_error = 1;
- if (el->key)
- free(el->key);
- free(el);
- return hash;
- }
- hash->population++;
- return hash;
-}
-
-void *
-imlib_hash_find(Imlib_Hash * hash, const char *key)
-{
- int hash_num;
- Imlib_Hash_El *el;
- Imlib_Object_List *l;
-
- _imlib_hash_alloc_error = 0;
- if (!hash)
- return NULL;
- hash_num = imlib_hash_gen(key);
- for (l = hash->buckets[hash_num]; l; l = l->next)
- {
- el = (Imlib_Hash_El *) l;
- if (((el->key) && (key) && (!strcmp(el->key, key)))
- || ((!el->key) && (!key)))
- {
- if (l != hash->buckets[hash_num])
- {
- /* FIXME: move to front of list without alloc */
- hash->buckets[hash_num] =
- imlib_object_list_remove(hash->buckets[hash_num], el);
- hash->buckets[hash_num] =
- imlib_object_list_prepend(hash->buckets[hash_num], el);
- if (imlib_list_alloc_error())
- {
- _imlib_hash_alloc_error = 1;
- return el->data;
- }
- }
- return el->data;
- }
- }
- return NULL;
-}
-
-void
-imlib_hash_free(Imlib_Hash * hash)
-{
- int i, size;
-
- if (!hash)
- return;
- size = imlib_hash_size(hash);
- for (i = 0; i < size; i++)
- {
- while (hash->buckets[i])
- {
- Imlib_Hash_El *el;
-
- el = (Imlib_Hash_El *) hash->buckets[i];
- if (el->key)
- free(el->key);
- hash->buckets[i] = imlib_object_list_remove(hash->buckets[i], el);
- free(el);
- }
- }
- free(hash);
-}
-
-void
-imlib_hash_foreach(Imlib_Hash * hash, int (*func) (Imlib_Hash * hash,
- const char *key, void *data,
- void *fdata),
- const void *fdata)
-{
- int i, size;
-
- if (!hash)
- return;
- size = imlib_hash_size(hash);
- for (i = 0; i < size; i++)
- {
- Imlib_Object_List *l, *next_l;
-
- for (l = hash->buckets[i]; l;)
- {
- Imlib_Hash_El *el;
-
- next_l = l->next;
- el = (Imlib_Hash_El *) l;
- if (!func(hash, el->key, el->data, (void *)fdata))
- return;
- l = next_l;
- }
- }
-}
-
-int
-imlib_hash_size(Imlib_Hash * hash)
-{
- if (!hash)
- return 0;
- return 256;
-}
-
-int
-imlib_list_alloc_error(void)
-{
- return _imlib_list_alloc_error;
-}
diff --git a/src/font_query.c b/src/font_query.c
deleted file mode 100644
index b7cf837..0000000
--- a/src/font_query.c
+++ /dev/null
@@ -1,313 +0,0 @@
-#include "config.h"
-#include "common.h"
-#include "colormod.h"
-#include "image.h"
-#include "blend.h"
-#include <ft2build.h>
-#include FT_FREETYPE_H
-#include FT_GLYPH_H
-#include "font.h"
-#include <sys/types.h>
-#include <string.h>
-#include <math.h>
-#include "file.h"
-#include "updates.h"
-#include "rgbadraw.h"
-#include "rotate.h"
-
-extern FT_Library ft_lib;
-
-/* string extents */
-void
-imlib_font_query_size(ImlibFont * fn, const char *text, int *w, int *h)
-{
- int use_kerning;
- int pen_x, pen_y;
- int start_x, end_x;
- int chr;
- FT_UInt prev_index;
-
- start_x = 0;
- end_x = 0;
- pen_x = 0;
- pen_y = 0;
- use_kerning = FT_HAS_KERNING(fn->ft.face);
- prev_index = 0;
- for (chr = 0; text[chr];)
- {
- FT_UInt index;
- Imlib_Font_Glyph *fg;
- int chr_x, chr_y, chr_w;
- int gl;
-
- gl = imlib_font_utf8_get_next((unsigned char *)text, &chr);
- if (gl == 0)
- break;
- index = FT_Get_Char_Index(fn->ft.face, gl);
- if ((use_kerning) && (prev_index) && (index))
- {
- FT_Vector delta;
-
- FT_Get_Kerning(fn->ft.face, prev_index, index, ft_kerning_default,
- &delta);
- pen_x += delta.x << 2;
- }
- fg = imlib_font_cache_glyph_get(fn, index);
- if (!fg)
- continue;
-
- chr_x = (pen_x >> 8) + fg->glyph_out->left;
- chr_y = (pen_y >> 8) + fg->glyph_out->top;
- chr_w = fg->glyph_out->bitmap.width;
-
- if (!prev_index)
- start_x = chr_x;
- if ((chr_x + chr_w) > end_x)
- end_x = chr_x + chr_w;
-
- pen_x += fg->glyph->advance.x >> 8;
- prev_index = index;
- }
- if (w)
- *w = (pen_x >> 8) - start_x;
- if (h)
- *h = imlib_font_max_ascent_get(fn) - imlib_font_max_descent_get(fn);
-}
-
-/* text x inset */
-int
-imlib_font_query_inset(ImlibFont * fn, const char *text)
-{
- FT_UInt index;
- Imlib_Font_Glyph *fg;
- int chr;
- int gl;
-
- chr = 0;
- if (!text[0])
- return 0;
- gl = imlib_font_utf8_get_next((unsigned char *)text, &chr);
- if (gl == 0)
- return 0;
- index = FT_Get_Char_Index(fn->ft.face, gl);
- fg = imlib_font_cache_glyph_get(fn, index);
- if (!fg)
- return 0;
- return -fg->glyph_out->left;
-}
-
-/* h & v advance */
-void
-imlib_font_query_advance(ImlibFont * fn, const char *text, int *h_adv,
- int *v_adv)
-{
- int use_kerning;
- int pen_x, pen_y;
- int start_x;
- int chr;
- FT_UInt prev_index;
-
- start_x = 0;
- pen_x = 0;
- pen_y = 0;
- use_kerning = FT_HAS_KERNING(fn->ft.face);
- prev_index = 0;
- for (chr = 0; text[chr];)
- {
- FT_UInt index;
- Imlib_Font_Glyph *fg;
- int chr_x, chr_y, chr_w;
- int gl;
-
- gl = imlib_font_utf8_get_next((unsigned char *)text, &chr);
- if (gl == 0)
- break;
- index = FT_Get_Char_Index(fn->ft.face, gl);
- if ((use_kerning) && (prev_index) && (index))
- {
- FT_Vector delta;
-
- FT_Get_Kerning(fn->ft.face, prev_index, index, ft_kerning_default,
- &delta);
- pen_x += delta.x << 2;
- }
- fg = imlib_font_cache_glyph_get(fn, index);
- if (!fg)
- continue;
-
- chr_x = (pen_x >> 8) + fg->glyph_out->left;
- chr_y = (pen_y >> 8) + fg->glyph_out->top;
- chr_w = fg->glyph_out->bitmap.width;
-
- pen_x += fg->glyph->advance.x >> 8;
- prev_index = index;
- }
- if (v_adv)
- *v_adv = imlib_font_get_line_advance(fn);
- if (h_adv)
- *h_adv = (pen_x >> 8) - start_x;
-}
-
-/* x y w h for char at char pos */
-int
-imlib_font_query_char_coords(ImlibFont * fn, const char *text, int pos,
- int *cx, int *cy, int *cw, int *ch)
-{
- int use_kerning;
- int pen_x, pen_y;
- int prev_chr_end;
- int chr;
- int asc, desc;
- FT_UInt prev_index;
-
- pen_x = 0;
- pen_y = 0;
- use_kerning = FT_HAS_KERNING(fn->ft.face);
- prev_index = 0;
- prev_chr_end = 0;
- asc = imlib_font_max_ascent_get(fn);
- desc = imlib_font_max_descent_get(fn);
- for (chr = 0; text[chr];)
- {
- int pchr;
- FT_UInt index;
- Imlib_Font_Glyph *fg;
- int chr_x, chr_y, chr_w;
- int gl, kern;
- FT_Vector delta;
-
- pchr = chr;
- gl = imlib_font_utf8_get_next((unsigned char *)text, &chr);
- if (gl == 0)
- break;
- index = FT_Get_Char_Index(fn->ft.face, gl);
- kern = 0;
- if ((use_kerning) && (prev_index) && (index))
- {
- FT_Get_Kerning(fn->ft.face, prev_index, index, ft_kerning_default,
- &delta);
- kern = delta.x << 2;
- pen_x += kern;
- }
- fg = imlib_font_cache_glyph_get(fn, index);
- if (!fg)
- continue;
-
- if (kern < 0)
- kern = 0;
- chr_x = ((pen_x - kern) >> 8) + fg->glyph_out->left;
- chr_y = (pen_y >> 8) + fg->glyph_out->top;
- chr_w = fg->glyph_out->bitmap.width + (kern >> 8);
- if (text[chr])
- {
- int advw;
-
- advw = ((fg->glyph->advance.x + (kern << 8)) >> 16);
- if (chr_w < advw)
- chr_w = advw;
- }
- if (chr_x > prev_chr_end)
- {
- chr_w += (chr_x - prev_chr_end);
- chr_x = prev_chr_end;
- }
- if (pchr == pos)
- {
- if (cx)
- *cx = chr_x;
- if (cy)
- *cy = -asc;
- if (cw)
- *cw = chr_w;
- if (ch)
- *ch = asc + desc;
- return 1;
- }
- prev_chr_end = chr_x + chr_w;
- pen_x += fg->glyph->advance.x >> 8;
- prev_index = index;
- }
- return 0;
-}
-
-/* char pos of text at xy pos */
-int
-imlib_font_query_text_at_pos(ImlibFont * fn, const char *text, int x, int y,
- int *cx, int *cy, int *cw, int *ch)
-{
- int use_kerning;
- int pen_x, pen_y;
- int prev_chr_end;
- int chr;
- int asc, desc;
- FT_UInt prev_index;
-
- pen_x = 0;
- pen_y = 0;
- use_kerning = FT_HAS_KERNING(fn->ft.face);
- prev_index = 0;
- prev_chr_end = 0;
- asc = imlib_font_max_ascent_get(fn);
- desc = imlib_font_max_descent_get(fn);
- for (chr = 0; text[chr];)
- {
- int pchr;
- FT_UInt index;
- Imlib_Font_Glyph *fg;
- int chr_x, chr_y, chr_w;
- int gl, kern;
- FT_Vector delta;
-
- pchr = chr;
- gl = imlib_font_utf8_get_next((unsigned char *)text, &chr);
- if (gl == 0)
- break;
- index = FT_Get_Char_Index(fn->ft.face, gl);
- kern = 0;
- if ((use_kerning) && (prev_index) && (index))
- {
- FT_Get_Kerning(fn->ft.face, prev_index, index, ft_kerning_default,
- &delta);
- kern = delta.x << 2;
- pen_x += kern;
- }
- fg = imlib_font_cache_glyph_get(fn, index);
- if (!fg)
- continue;
-
- if (kern < 0)
- kern = 0;
- chr_x = ((pen_x - kern) >> 8) + fg->glyph_out->left;
- chr_y = (pen_y >> 8) + fg->glyph_out->top;
- chr_w = fg->glyph_out->bitmap.width + (kern >> 8);
- if (text[chr])
- {
- int advw;
-
- advw = ((fg->glyph->advance.x + (kern << 8)) >> 16);
- if (chr_w < advw)
- chr_w = advw;
- }
- if (chr_x > prev_chr_end)
- {
- chr_w += (chr_x - prev_chr_end);
- chr_x = prev_chr_end;
- }
- if ((x >= chr_x) && (x <= (chr_x + chr_w)) && (y > -asc) && (y < desc))
- {
- if (cx)
- *cx = chr_x;
- if (cy)
- *cy = -asc;
- if (cw)
- *cw = chr_w;
- if (ch)
- *ch = asc + desc;
- return pchr;
- }
- prev_chr_end = chr_x + chr_w;
- pen_x += fg->glyph->advance.x >> 8;
- prev_index = index;
- }
- return -1;
-}
diff --git a/src/format.c b/src/format.c
deleted file mode 100644
index b0d6a10..0000000
--- a/src/format.c
+++ /dev/null
@@ -1 +0,0 @@
-#include "format.h"
diff --git a/src/format.h b/src/format.h
deleted file mode 100644
index 94137af..0000000
--- a/src/format.h
+++ /dev/null
@@ -1,3 +0,0 @@
-#ifndef __FORMAT
-#define __FORMAT 1
-#endif
diff --git a/src/grab.c b/src/grab.c
deleted file mode 100644
index ce57523..0000000
--- a/src/grab.c
+++ /dev/null
@@ -1,725 +0,0 @@
-#include "common.h"
-#ifndef X_DISPLAY_MISSING
-# include <X11/Xlib.h>
-#include <X11/extensions/XShm.h>
-#include <X11/Xutil.h>
-#include <X11/extensions/shape.h>
-#include <sys/ipc.h>
-#include <sys/shm.h>
-#endif
-#include "grab.h"
-
-static char _x_err = 0;
-static DATA8 rtab[256], gtab[256], btab[256];
-
-static void
-Tmp_HandleXError(Display * d, XErrorEvent * ev)
-{
- 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)
-{
- int inx, iny;
- DATA32 *src, *ptr;
- int pixel;
- int origx, origy;
- int bgr = 0;
-
- if (!data)
- return;
-
- 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 (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);
- pixel = (btab[pixel & 0xff]) |
- (gtab[pixel & 0xff] << 8) |
- (rtab[pixel & 0xff] << 16);
- if (XGetPixel(mxim, x, y))
- pixel |= 0xff000000;
- *ptr++ = pixel;
- }
- }
- }
- 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
-#undef G1SH
-#undef B1SH
-#undef R2SH
-#undef G2SH
-#undef B2SH
-#undef P1
-#undef P2
-#define MP(x, y) ((XGetPixel(mxim, (x), (y))) ? 0xff000000 : 0)
-#define RMSK 0xf80000
-#define GMSK 0x00fc00
-#define BMSK 0x0000f8
-#define R1SH(p) ((p) << 8)
-#define G1SH(p) ((p) << 5)
-#define B1SH(p) ((p) << 3)
-#define R2SH(p) ((p) >> 8)
-#define G2SH(p) ((p) >> 11)
-#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)
- {
-#ifdef WORDS_BIGENDIAN
- *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);
-#endif
- 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)
- {
-#ifdef WORDS_BIGENDIAN
- *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);
-#endif
- 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
-#undef G1SH
-#undef B1SH
-#undef R2SH
-#undef G2SH
-#undef B2SH
-#undef P1
-#undef P2
-#define MP(x, y) ((XGetPixel(mxim, (x), (y))) ? 0xff000000 : 0)
-#define RMSK 0xf80000
-#define GMSK 0x00f800
-#define BMSK 0x0000f8
-#define R1SH(p) ((p) << 9)
-#define G1SH(p) ((p) << 6)
-#define B1SH(p) ((p) << 3)
-#define R2SH(p) ((p) >> 7)
-#define G2SH(p) ((p) >> 10)
-#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)
- {
-#ifdef WORDS_BIGENDIAN
- *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);
-#endif
- 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)
- {
-#ifdef WORDS_BIGENDIAN
- *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);
-#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);
- if (XGetPixel(mxim, x, y))
- pixel |= 0xff000000;
- *ptr++ = pixel;
- }
- }
- }
- 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) & 0x00ffffff;
- if (XGetPixel(mxim, x, y))
- pixel |= 0xff000000;
- *ptr++ = pixel;
- }
- }
- }
- 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++)
- {
- pixel = ((*src << 16) & 0xff0000) |
- ((*src) & 0x00ff00) |
- ((*src >> 16) & 0x0000ff);
- if (XGetPixel(mxim, x, y))
- pixel |= 0xff000000;
- *ptr++ = pixel;
- 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++)
- {
- pixel = (*src) & 0x00ffffff;
- if (XGetPixel(mxim, x, y))
- pixel |= 0xff000000;
- *ptr++ = pixel;
- 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;
- }
-
- if (grab)
- 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)
-{
- XErrorHandler prev_erh = NULL;
- XWindowAttributes xatt, ratt;
- char is_pixmap = 0, created_mask = 0, is_shm = 0, is_mshm = 0;
- int i;
- int src_x, src_y, src_w, src_h, origw, origh;
- int width, height, clipx, clipy;
- XShmSegmentInfo shminfo, mshminfo;
- XImage *xim = NULL, *mxim = NULL;
- static signed char x_does_shm = -1;
- XColor cols[256];
-
- /* FIXME: oh isnt used - i wonder if there's a bug looming... */
- oh = 0;
- origw = w;
- origh = h;
- if (grab)
- XGrabServer(d);
- XSync(d, False);
- prev_erh = XSetErrorHandler((XErrorHandler) Tmp_HandleXError);
- _x_err = 0;
- /* lets see if its a pixmap or not */
- XGetWindowAttributes(d, p, &xatt);
- XSync(d, False);
- if (_x_err)
- is_pixmap = 1;
- /* reset our error handler */
- 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;
- }
- 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;
- }
- }
-
- /* clip to the drawable tree and screen */
- clipx = 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 (x < 0)
- {
- clipx = -x;
- width += x;
- x = 0;
- }
- if (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 ((width <= 0) || (height <= 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);
- }
- }
-
- /* Create an Ximage (shared or not) */
- if (x_does_shm < 0)
- {
- if (XShmQueryExtension(d))
- x_does_shm = 1;
- else
- x_does_shm = 0;
- }
-
- prev_erh = XSetErrorHandler((XErrorHandler) Tmp_HandleXError);
-
- if (x_does_shm)
- {
- _x_err = 0;
- xim = XShmCreateImage(d, v, xatt.depth, ZPixmap, NULL, &shminfo, w, h);
- if (xim)
- {
- XSync(d, False);
- if (_x_err)
- {
- XDestroyImage(xim);
- }
- else
- {
- shminfo.shmid = shmget(IPC_PRIVATE, xim->bytes_per_line *
- xim->height, IPC_CREAT | 0666);
- if (shminfo.shmid < 0)
- {
- XDestroyImage(xim);
- }
- else
- {
- shminfo.shmaddr = xim->data = shmat(shminfo.shmid, 0, 0);
- if (xim->data != (char *)-1)
- {
- shminfo.readOnly = False;
- XShmAttach(d, &shminfo);
- is_shm = 1;
- XShmGetImage(d, p, xim, x, y, 0xffffffff);
- XSync(d, False);
- if (_x_err)
- {
- shmdt(shminfo.shmaddr);
- shmctl(shminfo.shmid, IPC_RMID, 0);
- XDestroyImage(xim);
- is_shm = 0;
- }
- }
- else
- {
- shmctl(shminfo.shmid, IPC_RMID, 0);
- XDestroyImage(xim);
- }
- }
- }
- }
- }
- if (!is_shm)
- xim = XGetImage(d, p, x, y, w, h, 0xffffffff, ZPixmap);
-
- if ((m) && (domask))
- {
- _x_err = 0;
- if (x_does_shm)
- {
- mxim = XShmCreateImage(d, v, 1, ZPixmap, NULL, &mshminfo, w, h);
- if (mxim)
- {
- XSync(d, False);
- if (_x_err)
- {
- XDestroyImage(mxim);
- }
- else
- {
- mshminfo.shmid = shmget(IPC_PRIVATE,
- mxim->bytes_per_line *
- mxim->height, IPC_CREAT | 0666);
- if (mshminfo.shmid < 0)
- {
- XDestroyImage(mxim);
- }
- else
- {
- mshminfo.shmaddr = mxim->data =
- shmat(mshminfo.shmid, 0, 0);
- if (mxim->data != (char *)-1)
- {
- mshminfo.readOnly = False;
- XShmAttach(d, &mshminfo);
- is_mshm = 1;
- XShmGetImage(d, m, mxim, 0, 0, 0xffffffff);
- XSync(d, False);
- if (_x_err)
- {
- shmdt(mshminfo.shmaddr);
- shmctl(mshminfo.shmid, IPC_RMID, 0);
- XDestroyImage(mxim);
- is_mshm = 0;
- }
- }
- else
- {
- shmctl(mshminfo.shmid, IPC_RMID, 0);
- XDestroyImage(mxim);
- }
- }
- }
- }
- }
- if (!is_mshm)
- mxim = XGetImage(d, m, 0, 0, w, h, 0xffffffff, ZPixmap);
- }
-
- XSetErrorHandler((XErrorHandler) prev_erh);
-
- if ((is_shm) || (is_mshm))
- {
- XSync(d, False);
- if (grab)
- XUngrabServer(d);
- XSync(d, False);
- }
- else if (grab)
- XUngrabServer(d);
-
- if ((xatt.depth == 1) && (!cm) && (is_pixmap))
- {
- rtab[0] = 255;
- gtab[0] = 255;
- btab[0] = 255;
- rtab[1] = 0;
- gtab[1] = 0;
- btab[1] = 0;
- }
- 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;
- }
- }
- __imlib_GrabXImageToRGBA(data, ox + clipx, oy + clipy, ow, oh,
- d, xim, mxim, v, xatt.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);
- }
- if ((is_mshm) && (mxim))
- {
- XShmDetach(d, &mshminfo);
- shmdt(mshminfo.shmaddr);
- shmctl(mshminfo.shmid, IPC_RMID, 0);
- }
- XDestroyImage(xim);
- if (created_mask)
- XFreePixmap(d, m);
- if (mxim)
- XDestroyImage(mxim);
- return 1;
-}
diff --git a/src/grab.h b/src/grab.h
deleted file mode 100644
index b5c9ae6..0000000
--- a/src/grab.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef __GRAB
-#define __GRAB 1
-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);
-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);
-#endif
diff --git a/src/grad.c b/src/grad.c
deleted file mode 100644
index 9f53d10..0000000
--- a/src/grad.c
+++ /dev/null
@@ -1,614 +0,0 @@
-#include "common.h"
-#include "colormod.h"
-#include "file.h"
-#include "loaderpath.h"
-#include <math.h>
-#include "image.h"
-#include "blend.h"
-#include "grad.h"
-#include "color_helpers.h"
-
-ImlibRange *
-__imlib_CreateRange(void)
-{
- ImlibRange *rg = NULL;
-
- rg = malloc(sizeof(ImlibRange));
- rg->color = NULL;
- return rg;
-}
-
-void
-__imlib_FreeRange(ImlibRange * rg)
-{
- ImlibRangeColor *p, *pp;
-
- p = rg->color;
- while (p)
- {
- pp = p;
- p = p->next;
- free(pp);
- }
- free(rg);
-}
-
-void
-__imlib_AddRangeColor(ImlibRange * rg, DATA8 r, DATA8 g, DATA8 b, DATA8 a,
- int dist)
-{
- ImlibRangeColor *p, *rc;
-
- if (dist < 1)
- dist = 1;
- if (!rg->color)
- dist = 0;
-
- rc = malloc(sizeof(ImlibRangeColor));
- rc->red = r;
- rc->green = g;
- rc->blue = b;
- 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;
- }
- }
- else
- rg->color = rc;
-}
-
-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;
-
- 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++)
- {
- 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;
- }
- free(pmap);
- return map;
-}
-
-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;
-}
-
-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)
-{
- 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;
- }
- if (w <= 0)
- return;
- if ((x + w) > im->w)
- w = (im->w - x);
- if (w <= 0)
- return;
- if (y < 0)
- {
- h += y;
- yoff = -y;
- y = 0;
- }
- if (h <= 0)
- return;
- if ((y + h) > im->h)
- h = (im->h - y);
- if (h <= 0)
- 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);
- }
-
- hlut = malloc(sizeof(int) * ww);
- vlut = malloc(sizeof(int) * hh);
- if (ww > hh)
- len = ww * 16;
- else
- len = hh * 16;
- map = __imlib_MapRange(rg, len);
- 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 (xx < 0)
- {
- 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;
- }
- if (yy < 0)
- {
- 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;
- }
- 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;
- }
-
- 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)
-{
- 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;
- }
- if (w <= 0)
- return;
- if ((x + w) > im->w)
- w = (im->w - x);
- if (w <= 0)
- return;
- if (y < 0)
- {
- h += y;
- yoff = -y;
- y = 0;
- }
- if (h <= 0)
- return;
- if ((y + h) > im->h)
- h = (im->h - y);
- if (h <= 0)
- 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);
- }
-
- hlut = malloc(sizeof(int) * ww);
- vlut = malloc(sizeof(int) * hh);
- if (ww > hh)
- len = ww * 16;
- else
- len = hh * 16;
- map = __imlib_MapHsvaRange(rg, len);
- 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 (xx < 0)
- {
- 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;
- }
- if (yy < 0)
- {
- 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;
- }
- 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;
- }
-
- free(vlut);
- free(hlut);
- free(map);
-}
diff --git a/src/grad.h b/src/grad.h
deleted file mode 100644
index 616394b..0000000
--- a/src/grad.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef __GRAD
-#define __GRAD 1
-
-typedef struct _imlib_range ImlibRange;
-typedef struct _imlib_range_color ImlibRangeColor;
-
-struct _imlib_range_color
-{
- DATA8 red, green, blue, alpha;
- int distance;
- ImlibRangeColor *next;
-};
-
-struct _imlib_range
-{
- ImlibRangeColor *color;
-};
-
-ImlibRange *__imlib_CreateRange(void);
-void __imlib_FreeRange(ImlibRange *rg);
-void __imlib_AddRangeColor(ImlibRange *rg, DATA8 r, DATA8 g, DATA8 b,
- DATA8 a, int dist);
-DATA32 *__imlib_MapRange(ImlibRange *rg, int len);
-DATA32 *__imlib_MapHsvaRange(ImlibRange *rg, int len);
-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);
-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);
-
-#endif
diff --git a/src/image.c b/src/image.c
deleted file mode 100644
index 237a474..0000000
--- a/src/image.c
+++ /dev/null
@@ -1,1352 +0,0 @@
-#include "common.h"
-#include <time.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <ctype.h>
-#include <errno.h>
-#ifndef X_DISPLAY_MISSING
-#include <X11/Xlib.h>
-#endif
-#include "image.h"
-#include "file.h"
-#include "loaderpath.h"
-
-static ImlibImage *images = NULL;
-
-#ifndef X_DISPLAY_MISSING
-static ImlibImagePixmap *pixmaps = NULL;
-#endif
-static ImlibLoader *loaders = NULL;
-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 */
-void
-__imlib_AttachTag(ImlibImage * im, const char *key, int val, void *data,
- ImlibDataDestructorFunction destructor)
-{
- ImlibImageTag *t;
-
- /* no string key? abort */
- if (!key)
- return;
-
- /* if a tag of that name alreayd exists - remove it and free it */
- if ((t = __imlib_RemoveTag(im, key)))
- __imlib_FreeTag(im, t);
- /* allocate the struct */
- t = malloc(sizeof(ImlibImageTag));
- /* fill it int */
- t->key = strdup(key);
- t->val = val;
- t->data = data;
- t->destructor = destructor;
- t->next = im->tags;
- /* prepend it to the list of tags */
- im->tags = t;
-}
-
-/* look up a tage by its key on the image it was attached to */
-ImlibImageTag *
-__imlib_GetTag(ImlibImage * im, const char *key)
-{
- ImlibImageTag *t;
-
- t = im->tags;
- while (t)
- {
- 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 *
-__imlib_RemoveTag(ImlibImage * im, const char *key)
-{
- 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;
- }
- /* no tag found - NULL */
- return NULL;
-}
-
-/* free the data struct for the tag and if a destructor function was */
-/* provided call it on the data member */
-void
-__imlib_FreeTag(ImlibImage * im, ImlibImageTag * t)
-{
- free(t->key);
- if (t->destructor)
- t->destructor(im, t->data);
- free(t);
-}
-
-/* free all the tags attached to an image */
-void
-__imlib_FreeAllTags(ImlibImage * im)
-{
- ImlibImageTag *t, *tt;
-
- t = im->tags;
- while (t)
- {
- tt = t;
- t = t->next;
- __imlib_FreeTag(im, tt);
- }
-}
-
-/* set the cache size */
-void
-__imlib_SetCacheSize(int size)
-{
- cache_size = size;
- __imlib_CleanupImageCache();
-#ifndef X_DISPLAY_MISSING
- __imlib_CleanupImagePixmapCache();
-#endif
-}
-
-/* return the cache size */
-int
-__imlib_GetCacheSize(void)
-{
- return cache_size;
-}
-
-/* create an image data struct and fill it in */
-ImlibImage *
-__imlib_ProduceImage(void)
-{
- ImlibImage *im;
-
- im = malloc(sizeof(ImlibImage));
- memset(im, 0, sizeof(ImlibImage));
- im->data = NULL;
- im->file = NULL;
- im->real_file = NULL;
- im->key = NULL;
- im->flags = F_FORMAT_IRRELEVANT | F_BORDER_IRRELEVANT | F_ALPHA_IRRELEVANT;
- im->loader = NULL;
- im->next = NULL;
- im->tags = NULL;
- return im;
-}
-
-/* free an image struct */
-void
-__imlib_ConsumeImage(ImlibImage * im)
-{
-#ifndef X_DISPLAY_MISSING
- ImlibImagePixmap *ip;
-#endif
-
- __imlib_FreeAllTags(im);
- if (im->file)
- free(im->file);
- if (im->real_file)
- free(im->real_file);
- if (im->key)
- free(im->key);
- if ((IMAGE_FREE_DATA(im)) && (im->data))
- free(im->data);
- if (im->format)
- free(im->format);
- free(im);
-#ifndef X_DISPLAY_MISSING
- ip = pixmaps;
- while (ip)
- {
- if (ip->image == im)
- {
- ip->image = NULL;
- ip->dirty = 1;
- }
- ip = ip->next;
- }
-#endif
-}
-
-ImlibImage *
-__imlib_FindCachedImage(const char *file)
-{
- 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;
- }
- return NULL;
-}
-
-/* add an image to the cache of images (at the start) */
-void
-__imlib_AddImageToCache(ImlibImage * im)
-{
- im->next = images;
- images = im;
-}
-
-/* remove (unlink) an image from the cache of images */
-void
-__imlib_RemoveImageFromCache(ImlibImage * 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;
- }
-}
-
-/* work out how much we have floaitng aroudn in our speculative cache */
-/* (images and pixmaps that have 0 reference counts) */
-int
-__imlib_CurrentCacheSize(void)
-{
- ImlibImage *im;
-
-#ifndef X_DISPLAY_MISSING
- ImlibImagePixmap *ip;
-#endif
- 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);
-#ifndef X_DISPLAY_MISSING
- 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;
- }
-#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;
- }
-#endif
- return current_cache;
-}
-
-/* clean out images fromthe cache if the cache is overgrown */
-void
-__imlib_CleanupImageCache(void)
-{
- 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);
- }
- }
- /* 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();
- }
-}
-
-#ifndef X_DISPLAY_MISSING
-/* create a pixmap cache data struct */
-ImlibImagePixmap *
-__imlib_ProduceImagePixmap(void)
-{
- ImlibImagePixmap *ip;
-
- ip = malloc(sizeof(ImlibImagePixmap));
- memset(ip, 0, sizeof(ImlibImagePixmap));
- ip->display = NULL;
- ip->visual = NULL;
- ip->image = NULL;
- ip->next = NULL;
- ip->file = NULL;
- return ip;
-}
-
-/* free a pixmap cache data struct and the pixmaps in it */
-void
-__imlib_ConsumeImagePixmap(ImlibImagePixmap * ip)
-{
-#ifdef DEBUG_CACHE
- fprintf(stderr,
- "[Imlib2] Deleting pixmap. Reference count is %d, pixmap 0x%08x, mask 0x%08x\n",
- ip->references, ip->pixmap, ip->mask);
-#endif
- if (ip->pixmap)
- XFreePixmap(ip->display, ip->pixmap);
- if (ip->mask)
- XFreePixmap(ip->display, ip->mask);
- if (ip->file)
- free(ip->file);
- free(ip);
-}
-
-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;
-
- 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;
- }
- return NULL;
-}
-
-ImlibImagePixmap *
-__imlib_FindCachedImagePixmapByID(Display * d, Pixmap p)
-{
- 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;
- }
- return NULL;
-}
-
-/* add a pixmap cahce struct to the pixmap cache (at the start of course */
-void
-__imlib_AddImagePixmapToCache(ImlibImagePixmap * ip)
-{
- ip->next = pixmaps;
- pixmaps = ip;
-}
-
-/* remove a pixmap cache struct fromt he pixmap cache */
-void
-__imlib_RemoveImagePixmapFromCache(ImlibImagePixmap * 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;
- }
-}
-
-/* clean out 0 reference count & dirty pixmaps from the cache */
-void
-__imlib_CleanupImagePixmapCache(void)
-{
- 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);
- }
- }
- 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();
- }
-}
-#endif
-
-#define LOADERS_UNINITIALISED -4444
-
-static int errors = LOADERS_UNINITIALISED;
-
-static void
-LTDL_Init(void)
-{
- /* Do this only once! */
-
- if ((errors == LOADERS_UNINITIALISED))
- {
- errors = lt_dlinit();
-
- /* 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();
-
- fprintf(stderr, "ERROR: failed to initialise ltdl: %s\n", dlerror);
- exit(1);
- }
-}
-
-void
-LTDL_Exit(void)
-{
- errors = LOADERS_UNINITIALISED;
- lt_dlexit();
-}
-
-/* try dlopen()ing the file if we succeed finish filling out the malloced */
-/* loader struct and return it */
-ImlibLoader *
-__imlib_ProduceLoader(char *file)
-{
- ImlibLoader *l;
- void (*l_formats) (ImlibLoader * l);
-
- LTDL_Init();
-
- l = malloc(sizeof(ImlibLoader));
- l->num_formats = 0;
- l->formats = NULL;
- l->handle = lt_dlopenext(file);
- if (!l->handle)
- {
- 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");
-
- /* each loader must provide formats() and at least load() or save() */
- if (!l_formats || (!l->load && !l->save))
- {
- lt_dlclose(l->handle);
- free(l);
- return NULL;
- }
- l_formats(l);
- l->file = strdup(file);
- l->next = NULL;
- return l;
-}
-
-/* list all the filenames of loaders int he system loaders dir and the user */
-/* loader dir */
-char **
-__imlib_ListLoaders(int *num_ret)
-{
- 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);
- sprintf(s, SYS_LOADERS_PATH "/image");
-#ifndef __EMX__
- l = __imlib_FileDir(s, &num);
-#else
- l = __imlib_FileDir(__XOS2RedirRoot(s), &num);
-#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]);
-#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
- * the .so, .la, .a versions of the same loader or whatever else.
- * 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;
-}
-
-char **
-__imlib_TrimLoaderList(char **list, int *num)
-{
- int i, n, size = 0;
-
- char **ret = NULL;
-
- if (!list)
- return NULL;
- if (*num == 0)
- return list;
-
- 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]);
- }
- if (list)
- free(list);
- *num = size;
- return ret;
-}
-
-int
-__imlib_ItemInList(char **list, int size, char *item)
-{
- int i;
-
- if (!size)
- return 0;
- if (!list)
- return 0;
- if (!item)
- return 0;
-
- for (i = 0; i < size; i++)
- {
- if (!strcmp(list[i], item))
- return 1;
- }
- return 0;
-}
-
-/* fre the struct for a loader and close its dlopen'd handle */
-void
-__imlib_ConsumeLoader(ImlibLoader * l)
-{
- if (l->file)
- free(l->file);
- if (l->handle)
- lt_dlclose(l->handle);
- if (l->formats)
- {
- int i;
-
- 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_system_time = 0;
- time_t current_time;
- char do_reload = 0;
-
- /* dont stat the dir and rescan if we checked in the last 5 seconds */
- current_time = time(NULL);
- if ((current_time - last_scan_time) < 5)
- return;
- /* ok - was the system loaders dir contents modified ? */
- last_scan_time = current_time;
-#ifndef __EMX__
- if (__imlib_FileIsDir(SYS_LOADERS_PATH "/image/"))
-#else
- if (__imlib_FileIsDir(__XOS2RedirRoot(SYS_LOADERS_PATH "/image/")))
-#endif
- {
-#ifndef __EMX__
- current_time = __imlib_FileModDate(SYS_LOADERS_PATH "/image/");
-#else
- 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 we dont ned to reload the loaders - get out now */
- if (!do_reload)
- return;
- __imlib_RemoveAllLoaders();
- __imlib_LoadAllLoaders();
-}
-
-/* remove all loaders int eh list we have cached so we can re-load them */
-void
-__imlib_RemoveAllLoaders(void)
-{
- ImlibLoader *l, *il;
-
- l = loaders;
- while (l)
- {
- il = l;
- l = l->next;
- __imlib_ConsumeLoader(il);
- }
- loaders = NULL;
-}
-
-/* find all the loaders we can find and load them up to see what they can */
-/* load / save */
-void
-__imlib_LoadAllLoaders(void)
-{
- int i, num;
- char **list;
-
- /* list all the loaders imlib can find */
- list = __imlib_ListLoaders(&num);
- /* no loaders? well don't load anything */
- if (!list)
- return;
-
- /* 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]);
- }
- free(list);
-}
-
-ImlibLoader *
-__imlib_FindBestLoaderForFile(const char *file, int for_save)
-{
- 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);
- /* change the extensiont o 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 */
- lower = extension;
- while (*lower)
- {
- *lower = tolower(*lower);
- lower++;
- }
- if (!extension)
- return NULL;
- /* go through the loaders - first loader that claims to handle that */
- /* image type (extension wise) wins as a first guess to use - NOTE */
- /* this is an OPTIMISATION - it is possible the file has no extension */
- /* or has an unrecognised one but still is loadable by a loader. */
- /* if thkis initial loader failes to load the load mechanism will */
- /* systematically go from most recently used to least recently used */
- /* loader until one succeeds - or none are left and all have failed */
- /* and only if all fail does the laod fail. the lao9der that does */
- /* succeed gets it way tot he head of the list so it's going */
- /* to be used first next time in this search mechanims - this */
- /* assumes you tend to laod a few image types and ones generally */
- /* 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))
- {
- /* does it provide the function we need? */
- if ((for_save && l->save) || (!for_save && l->load))
- {
- /* 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 *
-__imlib_FindBestLoaderForFileFormat(const char *file, char *format,
- int for_save)
-{
- 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++;
- }
- }
- }
- 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))
- {
- /* does it provide the function we need? */
- if ((for_save && l->save) || (!for_save && l->load))
- {
- /* 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;
-}
-
-/* set or unset the alpha flag on the umage (alpha = 1 / 0 ) */
-void
-__imlib_SetImageAlphaFlag(ImlibImage * im, char alpha)
-{
- if (alpha)
- SET_FLAG(im->flags, F_HAS_ALPHA);
- else
- UNSET_FLAG(im->flags, F_HAS_ALPHA);
-}
-
-/* create a new image struct from data passed that is wize w x h then return */
-/* a pointer to that image sturct */
-ImlibImage *
-__imlib_CreateImage(int w, int h, DATA32 * data)
-{
- ImlibImage *im;
-
- im = __imlib_ProduceImage();
- im->w = w;
- im->h = h;
- im->data = data;
- im->references = 1;
- SET_FLAG(im->flags, F_UNCACHEABLE);
- return im;
-}
-
-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;
-
- 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;
- }
- }
- /* 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))
- {
- im->real_file = strdup(im->file);
- im->key = NULL;
- }
- else
- {
- 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 */
- __imlib_RescanLoaders();
- /* take a guess by extension on the best loader to use */
- best_loader = __imlib_FindBestLoaderForFile(im->real_file, 0);
- errno = 0;
- if (best_loader)
- loader_ret =
- 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;
- }
- 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;
- }
-
- /* the load succeeded - make sure the image is referenced then add */
- /* it to our cache if dont_cache isn't set */
- im->references = 1;
- if (loader_ret == 2)
- dont_cache = 1;
- if (!dont_cache)
- __imlib_AddImageToCache(im);
- else
- SET_FLAG(im->flags, F_UNCACHEABLE);
- return im;
-}
-
-#ifndef X_DISPLAY_MISSING
-/* find an imagepixmap cache entry by the display and pixmap id */
-ImlibImagePixmap *
-__imlib_FindImlibImagePixmapByID(Display * d, Pixmap p)
-{
- 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))
- {
-#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);
-#endif
- return ip;
- }
- ip = ip->next;
- }
- return NULL;
-}
-#endif
-
-/* free and image - if its uncachable and refcoutn is 0 - free it in reality */
-void
-__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();
- }
-}
-
-#ifndef X_DISPLAY_MISSING
-/* free a cached pixmap */
-void
-__imlib_FreePixmap(Display * d, Pixmap p)
-{
- 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--;
-#ifdef DEBUG_CACHE
- 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();
- }
- }
- else
- {
-#ifdef DEBUG_CACHE
- fprintf(stderr, "[Imlib2] Pixmap 0x%08x not found. Freeing.\n", p);
-#endif
- XFreePixmap(d, p);
- }
-}
-
-/* mark all pixmaps generated from this image as dirty so the cache code */
-/* wont pick up on them again since they are now invalid since the original */
-/* data they were generated from has changed */
-void
-__imlib_DirtyPixmapsForImage(ImlibImage * im)
-{
- ImlibImagePixmap *ip;
-
- ip = pixmaps;
- /* go through the pixmap list */
- while (ip)
- {
- /* if image matches */
- if (ip->image == im)
- ip->dirty = 1;
- ip = ip->next;
- }
- __imlib_CleanupImagePixmapCache();
-}
-#endif
-
-/* dirty and image by settings its invalid flag */
-void
-__imlib_DirtyImage(ImlibImage * im)
-{
- SET_FLAG(im->flags, F_INVALID);
- /* and dirty all pixmaps generated from it */
- __imlib_DirtyPixmapsForImage(im);
-}
-
-void
-__imlib_SaveImage(ImlibImage * im, const char *file,
- ImlibProgressFunction progress, char progress_granularity,
- ImlibLoadError * er)
-{
- ImlibLoader *l;
- char e, *pfile;
-
- if (!file)
- {
- 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 */
- pfile = im->file;
- im->file = strdup(file);
-
- if (im->real_file)
- free(im->real_file);
-
- im->real_file = strdup(im->file);
-
- /* find the laoder for the format - if its null use the extension */
- l = __imlib_FindBestLoaderForFileFormat(im->real_file, im->format, 1);
- /* 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 they want an error returned - assume none by default */
- if (er)
- *er = LOAD_ERROR_NONE;
-
- /* call the saver */
- e = l->save(im, progress, progress_granularity);
- /* set the filename back to the laoder image filename */
- free(im->file);
- im->file = pfile;
-
- /* 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;
- }
-}
diff --git a/src/image.h b/src/image.h
deleted file mode 100644
index d8f9598..0000000
--- a/src/image.h
+++ /dev/null
@@ -1,202 +0,0 @@
-#ifndef __IMAGE
-# define __IMAGE 1
-
-#include "common.h"
-#ifndef X_DISPLAY_MISSING
-#include <X11/Xlib.h>
-#endif
-
-#include <ltdl.h> /* for lt_dlhandle definition */
-
-typedef struct _imlibimage ImlibImage;
-#ifndef X_DISPLAY_MISSING
-typedef struct _imlibimagepixmap ImlibImagePixmap;
-#endif
-typedef struct _imlibborder ImlibBorder;
-typedef struct _imlibloader ImlibLoader;
-typedef struct _imlibimagetag ImlibImageTag;
-
-typedef int (*ImlibProgressFunction)(ImlibImage *im, char percent,
- int update_x, int update_y,
- int update_w, int update_h);
-typedef void (*ImlibDataDestructorFunction)(ImlibImage *im, void *data);
-
-enum _load_error
-{
- LOAD_ERROR_NONE,
- LOAD_ERROR_FILE_DOES_NOT_EXIST,
- LOAD_ERROR_FILE_IS_DIRECTORY,
- LOAD_ERROR_PERMISSION_DENIED_TO_READ,
- LOAD_ERROR_NO_LOADER_FOR_FILE_FORMAT,
- LOAD_ERROR_PATH_TOO_LONG,
- LOAD_ERROR_PATH_COMPONENT_NON_EXISTANT,
- LOAD_ERROR_PATH_COMPONENT_NOT_DIRECTORY,
- LOAD_ERROR_PATH_POINTS_OUTSIDE_ADDRESS_SPACE,
- LOAD_ERROR_TOO_MANY_SYMBOLIC_LINKS,
- LOAD_ERROR_OUT_OF_MEMORY,
- LOAD_ERROR_OUT_OF_FILE_DESCRIPTORS,
- LOAD_ERROR_PERMISSION_DENIED_TO_WRITE,
- LOAD_ERROR_OUT_OF_DISK_SPACE,
- LOAD_ERROR_UNKNOWN
-};
-
-enum _iflags
-{
- F_NONE = 0,
- F_HAS_ALPHA = (1 << 0),
- F_UNLOADED = (1 << 1),
- F_UNCACHEABLE = (1 << 2),
- F_ALWAYS_CHECK_DISK = (1 << 3),
- F_INVALID = (1 << 4),
- F_DONT_FREE_DATA = (1 << 5),
- F_FORMAT_IRRELEVANT = (1 << 6),
- F_BORDER_IRRELEVANT = (1 << 7),
- F_ALPHA_IRRELEVANT = (1 << 8)
-};
-
-typedef enum _iflags ImlibImageFlags;
-typedef enum _load_error ImlibLoadError;
-
-struct _imlibborder
-{
- int left, right, top, bottom;
-};
-
-struct _imlibimagetag
-{
- char *key;
- int val;
- void *data;
- void (*destructor)(ImlibImage *im, void *data);
- ImlibImageTag *next;
-};
-
-struct _imlibimage
-{
- char *file;
- int w, h;
- DATA32 *data;
- ImlibImageFlags flags;
- time_t moddate;
- ImlibBorder border;
- int references;
- ImlibLoader *loader;
- char *format;
- ImlibImage *next;
- ImlibImageTag *tags;
- char *real_file;
- char *key;
-};
-
-#ifndef X_DISPLAY_MISSING
-struct _imlibimagepixmap
-{
- int w, h;
- Pixmap pixmap, mask;
- Display *display;
- Visual *visual;
- int depth;
- int source_x, source_y, source_w, source_h;
- Colormap colormap;
- char antialias, hi_quality, dither_mask;
- ImlibBorder border;
- ImlibImage *image;
- char *file;
- char dirty;
- int references;
- DATABIG modification_count;
- ImlibImagePixmap *next;
-};
-#endif
-
-struct _imlibloader
-{
- char *file;
- int num_formats;
- char **formats;
- lt_dlhandle handle;
- char (*load)(ImlibImage *im,
- ImlibProgressFunction progress,
- char progress_granularity, char immediate_load);
- char (*save)(ImlibImage *im,
- ImlibProgressFunction progress,
- char progress_granularity);
- ImlibLoader *next;
-};
-
-void __imlib_AttachTag(ImlibImage *im, const char *key, int val, void *data,
- ImlibDataDestructorFunction destructor);
-ImlibImageTag *__imlib_GetTag(ImlibImage *im, const char *key);
-ImlibImageTag *__imlib_RemoveTag(ImlibImage *im, const char *key);
-void __imlib_FreeTag(ImlibImage *im, ImlibImageTag *t);
-void __imlib_FreeAllTags(ImlibImage *im);
-
-void __imlib_SetCacheSize(int size);
-int __imlib_GetCacheSize(void);
-ImlibImage *__imlib_ProduceImage(void);
-void __imlib_ConsumeImage(ImlibImage *im);
-ImlibImage *__imlib_FindCachedImage(const char *file);
-void __imlib_AddImageToCache(ImlibImage *im);
-void __imlib_RemoveImageFromCache(ImlibImage *im);
-int __imlib_CurrentCacheSize(void);
-void __imlib_CleanupImageCache(void);
-#ifndef X_DISPLAY_MISSING
-ImlibImagePixmap *__imlib_ProduceImagePixmap(void);
-void __imlib_ConsumeImagePixmap(ImlibImagePixmap *ip);
-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 *__imlib_FindCachedImagePixmapByID(Display *d, Pixmap p);
-void __imlib_AddImagePixmapToCache(ImlibImagePixmap *ip);
-void __imlib_RemoveImagePixmapFromCache(ImlibImagePixmap *ip);
-void __imlib_CleanupImagePixmapCache(void);
-#endif
-ImlibLoader *__imlib_ProduceLoader(char *file);
-char **__imlib_ListLoaders(int *num_ret);
-char **__imlib_TrimLoaderList(char **list, int *num);
-int __imlib_ItemInList(char **list, int size, char *item);
-void __imlib_ConsumeLoader(ImlibLoader *l);
-void __imlib_RescanLoaders(void);
-void __imlib_RemoveAllLoaders(void);
-void __imlib_LoadAllLoaders(void);
-ImlibLoader *__imlib_FindBestLoaderForFile(const char *file, int for_save);
-ImlibLoader *__imlib_FindBestLoaderForFileFormat(const char *file, char *format, int for_save);
-void __imlib_SetImageAlphaFlag(ImlibImage *im, char alpha);
-ImlibImage *__imlib_CreateImage(int w, int h, DATA32 *data);
-ImlibImage *__imlib_LoadImage(const char *file,
- ImlibProgressFunction progress,
- char progress_granularity, char immediate_load,
- char dont_cache, ImlibLoadError *er);
-#ifndef X_DISPLAY_MISSING
-ImlibImagePixmap *__imlib_FindImlibImagePixmapByID(Display *d, Pixmap p);
-#endif
-void __imlib_FreeImage(ImlibImage *im);
-#ifndef X_DISPLAY_MISSING
-void __imlib_FreePixmap(Display *d, Pixmap p);
-#endif
-void __imlib_FlushCache(void);
-#ifndef X_DISPLAY_MISSING
-void __imlib_DirtyPixmapsForImage(ImlibImage *im);
-#else
-#define __imlib_DirtyPixmapsForImage(x) /* x */
-#endif
-void __imlib_DirtyImage(ImlibImage *im);
-void __imlib_SaveImage(ImlibImage *im, const char *file,
- ImlibProgressFunction progress,
- char progress_granularity,
- ImlibLoadError *er);
-
-# define IMAGE_HAS_ALPHA(im) ((im)->flags & F_HAS_ALPHA)
-# define IMAGE_IS_UNLOADED(im) ((im)->flags & F_UNLOADED)
-# define IMAGE_IS_UNCACHEABLE(im) ((im)->flags & F_UNCACHEABLE)
-# define IMAGE_ALWAYS_CHECK_DISK(im) ((im)->flags & F_ALWAYS_CHECK_DISK)
-# define IMAGE_IS_VALID(im) (!((im)->flags & F_INVALID))
-# define IMAGE_FREE_DATA(im) (!((im)->flags & F_DONT_FREE_DATA))
-
-# define SET_FLAG(flags, f) ((flags) |= (f))
-# define UNSET_FLAG(flags, f) ((flags) &= (~f))
-
-#endif
diff --git a/src/line.c b/src/line.c
deleted file mode 100644
index 9675327..0000000
--- a/src/line.c
+++ /dev/null
@@ -1,711 +0,0 @@
-#include "common.h"
-#include "colormod.h"
-#include "image.h"
-#include "blend.h"
-#include "span.h"
-#include "updates.h"
-#include "rgbadraw.h"
-
-
-#define EXCHANGE_POINTS(x0, y0, x1, y1) \
-{ \
- int _tmp = y0; \
- \
- y0 = y1; \
- y1 = _tmp; \
- \
- _tmp = x0; \
- x0 = x1; \
- x1 = _tmp; \
-}
-
-
-ImlibUpdate *
-__imlib_Point_DrawToImage(int x, int y, DATA32 color,
- ImlibImage *im, int clx, int cly, int clw, int clh,
- ImlibOp op, char blend, char make_updates)
-{
- ImlibPointDrawFunction pfunc;
-
- if (blend && (!A_VAL(&color)))
- return NULL;
- if (!IN_RANGE(x, y, im->w, im->h))
- return NULL;
- if (clw == 0)
- {
- clw = im->w;
- clx = 0;
- clh = im->h;
- cly = 0;
- }
- if (!IN_RECT(x,y,clx,cly,clw,clh))
- return NULL;
-
- if (A_VAL(&color) == 0xff)
- blend = 0;
- if (blend && IMAGE_HAS_ALPHA(im))
- __imlib_build_pow_lut();
-
- pfunc = __imlib_GetPointDrawFunction(op, IMAGE_HAS_ALPHA(im), blend);
- if (pfunc)
- pfunc(color, im->data + (im->w * y) + x);
- if (make_updates)
- return __imlib_AddUpdate(NULL, x, y, 1, 1);
- return NULL;
-}
-
-
-static int
-__imlib_SimpleLine_DrawToData(int x0, int y0, int x1, int y1, DATA32 color,
- DATA32 *dst, int dstw, int clx, int cly, int clw, int clh,
- int *cl_x0, int *cl_y0, int *cl_x1, int *cl_y1,
- ImlibOp op, char dst_alpha, char blend)
-{
- ImlibPointDrawFunction pfunc;
- ImlibSpanDrawFunction sfunc;
- int dx, dy, len, lx, ty, rx, by;
- DATA32 *p;
-
- if (A_VAL(&color) == 0xff) blend = 0;
-
- if (y0 > y1)
- EXCHANGE_POINTS(x0, y0, x1, y1)
-
- dx = x1 - x0;
- dy = y1 - y0;
-
- lx = clx;
- rx = clx + clw - 1;
- ty = cly;
- by = cly + clh - 1;
-
- if ((x0 < lx) && (x1 < lx)) return 0;
- if ((x0 > rx) && (x1 > rx)) return 0;
- if ((y0 > by) || (y1 < ty)) return 0;
-
- if (dy == 0)
- {
- sfunc = __imlib_GetSpanDrawFunction(op, dst_alpha, blend);
- if (!sfunc) return 0;
-
- if (dx < 0)
- {
- int tmp = x1;
-
- x1 = x0;
- x0 = tmp;
- }
-
- if (x0 < lx) x0 = lx;
- if (x1 > rx) x1 = rx;
-
- len = x1 - x0 + 1;
-
- p = dst + (dstw * y0) + x0;
-
- sfunc(color, p, len);
-
- *cl_x0 = x0;
- *cl_y0 = y0;
- *cl_x1 = x1;
- *cl_y1 = y1;
-
- return 1;
- }
-
- pfunc = __imlib_GetPointDrawFunction(op, dst_alpha, blend);
- if (!pfunc) return 0;
-
- if (dx == 0)
- {
- if (y0 < ty) y0 = ty;
- if (y1 > by) y1 = by;
-
- len = y1 - y0 + 1;
-
- p = dst + (dstw * y0) + x0;
-
- while (len--)
- {
- pfunc(color, p);
- p += dstw;
- }
-
- *cl_x0 = x0;
- *cl_y0 = y0;
- *cl_x1 = x1;
- *cl_y1 = y1;
-
- return 1;
- }
-
- if ((dy == dx) || (dy == -dx))
- {
- int p0_in, p1_in;
-
- p0_in = (IN_RECT(x0, y0, clx, cly, clw, clh) ? 1 : 0);
- p1_in = (IN_RECT(x1, y1, clx, cly, clw, clh) ? 1 : 0);
-
- if (dx > 0)
- {
- if (!p0_in)
- {
- x0 = x0 + (ty - y0);
- y0 = ty;
- if (x0 > rx) return 0;
- if (x0 < lx)
- {
- y0 = y0 + (lx - x0);
- x0 = lx;
- if ((y0 < ty) || (y0 > by)) return 0;
- }
- }
- if (!p1_in)
- {
- x1 = x0 + (by - y0);
- y1 = by;
- if (x1 < lx) return 0;
- if (x1 > rx)
- {
- y1 = y0 + (rx - x0);
- x1 = rx;
- if ((y1 < ty) || (y1 > by)) return 0;
- }
- }
- }
- else
- {
- if (!p0_in)
- {
- x0 = x0 - (ty - y0);
- y0 = ty;
- if (x0 < lx) return 0;
- if (x0 > rx)
- {
- y0 = y0 - (rx - x0);
- x0 = rx;
- if ((y0 < ty) || (y0 > by)) return 0;
- }
- }
- if (!p1_in)
- {
- x1 = x0 - (by - y0);
- y1 = by;
- if (x1 > rx) return 0;
- if (x1 < lx)
- {
- y1 = y0 - (lx - x0);
- x1 = lx;
- if ((y1 < ty) || (y1 > by)) return 0;
- }
- }
- }
-
- len = y1 - y0 + 1;
-
- p = dst + (dstw * y0) + x0;
- if (dx > 0) dstw++;
- else dstw--;
-
- while (len--)
- {
- pfunc(color, p);
- p += dstw;
- }
- }
-
- *cl_x0 = x0;
- *cl_y0 = y0;
- *cl_x1 = x1;
- *cl_y1 = y1;
-
- return 1;
-}
-
-
-#define SETUP_LINE_SHALLOW \
- if (x0 > x1) \
- { \
- EXCHANGE_POINTS(x0, y0, x1, y1) \
- dx = -dx; \
- dy = -dy; \
- } \
- \
- px = x0; \
- py = y0; \
- \
- p0_in = (IN_RANGE(x0 ,y0 , clw, clh) ? 1 : 0); \
- p1_in = (IN_RANGE(x1 ,y1 , clw, clh) ? 1 : 0); \
- \
- dely = 1; \
- dh = dstw; \
- if (dy < 0) \
- { \
- dely = -1; \
- dh = -dstw; \
- } \
- \
- dyy = (dy << 16) / dx; \
- \
- if (!p0_in) \
- { \
- dxx = (dx << 16) / dy; \
- if (px < 0) \
- { \
- x = -px; px = 0; \
- yy = x * dyy; \
- y = yy >> 16; \
- if (!a_a) \
- y += (yy - (y << 16)) >> 15; \
- py += y; \
- if ((dely > 0) && (py >= clh)) \
- return 0; \
- else if ((dely < 0) && (py < -1)) \
- return 0; \
- } \
- \
- y = 0; \
- if ((dely > 0) && (py < -1)) \
- y = (-1 - py); \
- else if ((dely < 0) && (py >= clh)) \
- y = (clh - 1 - py); \
- \
- xx = y * dxx; \
- x = xx >> 16; \
- if (!a_a) \
- x += (xx - (x << 16)) >> 15; \
- px += x; \
- if (px >= clw) return 0; \
- \
- yy = x * dyy; \
- y = yy >> 16; \
- if (!a_a) \
- y += (yy - (y << 16)) >> 15; \
- py += y; \
- if ((dely > 0) && (py >= clh)) \
- return 0; \
- else if ((dely < 0) && (py < -1)) \
- return 0; \
- } \
- \
- p = dst + (dstw * py) + px; \
- \
- x = px - x0; \
- yy = x * dyy; \
- prev_y = (yy >> 16); \
- \
- rx = MIN(x1 + 1, clw); \
- by = clh - 1;
-
-
-#define SETUP_LINE_STEEP \
- if (y0 > y1) \
- { \
- EXCHANGE_POINTS(x0, y0, x1, y1) \
- dx = -dx; \
- dy = -dy; \
- } \
- \
- px = x0; \
- py = y0; \
- \
- p0_in = (IN_RANGE(x0 ,y0 , clw, clh) ? 1 : 0); \
- p1_in = (IN_RANGE(x1 ,y1 , clw, clh) ? 1 : 0); \
- \
- delx = 1; \
- if (dx < 0) \
- delx = -1; \
- \
- dxx = (dx << 16) / dy; \
- \
- if (!p0_in) \
- { \
- dyy = (dy << 16) / dx; \
- \
- if (py < 0) \
- { \
- y = -py; py = 0; \
- xx = y * dxx; \
- x = xx >> 16; \
- if (!a_a) \
- x += (xx - (x << 16)) >> 15; \
- px += x; \
- if ((delx > 0) && (px >= clw)) \
- return 0; \
- else if ((delx < 0) && (px < -1)) \
- return 0; \
- } \
- \
- x = 0; \
- if ((delx > 0) && (px < -1)) \
- x = (-1 - px); \
- else if ((delx < 0) && (px >= clw)) \
- x = (clw - 1 - px); \
- \
- yy = x * dyy; \
- y = yy >> 16; \
- if (!a_a) \
- y += (yy - (y << 16)) >> 15; \
- py += y; \
- if (py >= clh) return 0; \
- \
- xx = y * dxx; \
- x = xx >> 16; \
- if (!a_a) \
- x += (xx - (x << 16)) >> 15; \
- px += x; \
- if ((delx > 0) && (px >= clw)) \
- return 0; \
- else if ((delx < 0) && (px < -1)) \
- return 0; \
- } \
- \
- p = dst + (dstw * py) + px; \
- \
- y = py - y0; \
- xx = y * dxx; \
- prev_x = (xx >> 16); \
- \
- by = MIN(y1 + 1, clh); \
- rx = clw - 1;
-
-
-
-static int
-__imlib_Line_DrawToData(int x0, int y0, int x1, int y1, DATA32 color,
- DATA32 *dst, int dstw, int clx, int cly, int clw, int clh,
- int *cl_x0, int *cl_y0, int *cl_x1, int *cl_y1,
- ImlibOp op, char dst_alpha, char blend)
-{
- ImlibPointDrawFunction pfunc;
- int px, py, x, y, prev_x, prev_y;
- int dx, dy, rx, by, p0_in, p1_in, dh, a_a = 0;
- int delx, dely, xx, yy, dxx, dyy;
- DATA32 *p;
-
- dx = x1 - x0;
- dy = y1 - y0;
-
- if ( (dx == 0) || (dy == 0) || (dx == dy) || (dx == -dy) )
- return __imlib_SimpleLine_DrawToData(x0, y0, x1, y1, color,
- dst, dstw, clx, cly, clw, clh,
- cl_x0, cl_y0, cl_x1, cl_y1,
- op, dst_alpha, blend);
-
- if (A_VAL(&color) == 0xff) blend = 0;
-
- pfunc = __imlib_GetPointDrawFunction(op, dst_alpha, blend);
- if (!pfunc) return 0;
-
- dst += (dstw * cly) + clx;
- x0 -= clx;
- y0 -= cly;
- x1 -= clx;
- y1 -= cly;
-
- /* shallow: x-parametric */
- if ((dy < dx) || (dy < -dx))
- {
- SETUP_LINE_SHALLOW
-
- *cl_x0 = px + clx;
- *cl_y0 = py + cly;
-
- while (px < rx)
- {
- y = (yy >> 16);
- y += ((yy - (y << 16)) >> 15);
- if (prev_y != y)
- {
- prev_y = y;
- p += dh;
- py += dely;
- }
-
- if (!p1_in)
- {
- if ((py < 0) && (dely < 0)) break;
- if ((py > by) && (dely > 0)) break;
- }
-
- if (IN_RANGE(px, py, clw, clh))
- pfunc(color, p);
-
- yy += dyy;
- px++;
- p++;
- }
-
- *cl_x1 = px + clx;
- *cl_y1 = py + cly;
-
- return 1;
- }
-
- /* steep: y-parametric */
-
- SETUP_LINE_STEEP
-
- *cl_x0 = px + clx;
- *cl_y0 = py + cly;
-
- while (py < by)
- {
- x = (xx >> 16);
- x += ((xx - (x << 16)) >> 15);
- if (prev_x != x)
- {
- prev_x = x;
- px += delx;
- p += delx;
- }
-
- if (!p1_in)
- {
- if ((px < 0) && (delx < 0)) break;
- if ((px > rx) && (delx > 0)) break;
- }
-
- if (IN_RANGE(px, py, clw, clh))
- pfunc(color, p);
-
- xx += dxx;
- py++;
- p += dstw;
- }
-
- *cl_x1 = px + clx;
- *cl_y1 = py + cly;
-
- return 1;
-}
-
-
-static int
-__imlib_Line_DrawToData_AA(int x0, int y0, int x1, int y1, DATA32 color,
- DATA32 *dst, int dstw, int clx, int cly, int clw, int clh,
- int *cl_x0, int *cl_y0, int *cl_x1, int *cl_y1,
- ImlibOp op, char dst_alpha, char blend)
-{
- ImlibPointDrawFunction pfunc;
- int px, py, x, y, prev_x, prev_y;
- int dx, dy, rx, by, p0_in, p1_in, dh, a_a = 1;
- int delx, dely, xx, yy, dxx, dyy;
- DATA32 *p;
- DATA8 ca = A_VAL(&color);
-
- dx = x1 - x0;
- dy = y1 - y0;
-
- if ( (dx == 0) || (dy == 0) || (dx == dy) || (dx == -dy) )
- return __imlib_SimpleLine_DrawToData(x0, y0, x1, y1, color,
- dst, dstw, clx, cly, clw, clh,
- cl_x0, cl_y0, cl_x1, cl_y1,
- op, dst_alpha, blend);
-
- pfunc = __imlib_GetPointDrawFunction(op, dst_alpha, blend);
- if (!pfunc) return 0;
-
- dst += (dstw * cly) + clx;
- x0 -= clx;
- y0 -= cly;
- x1 -= clx;
- y1 -= cly;
-
- /* shallow: x-parametric */
- if ((dy < dx) || (dy < -dx))
- {
- SETUP_LINE_SHALLOW
-
- *cl_x0 = px + clx;
- *cl_y0 = py + cly;
-
- while (px < rx)
- {
- DATA32 tmp;
- DATA8 aa;
-
- y = (yy >> 16);
- if (prev_y != y)
- {
- prev_y = y;
- p += dh;
- py += dely;
- }
-
- if (!p1_in)
- {
- if ((py < -1) && (dely < 0)) break;
- if ((py > by) && (dely > 0)) break;
- }
-
- if ((unsigned)(px) < clw)
- {
- aa = (yy - (y << 16)) >> 8;
-
- A_VAL(&color) = 255 - aa;
- if (ca < 255)
- MULT(A_VAL(&color), ca, A_VAL(&color), tmp)
-
- if ((unsigned)(py) < clh)
- pfunc(color, p);
-
- if ((unsigned)(py + 1) < clh)
- {
- A_VAL(&color) = aa;
- if (ca < 255)
- MULT(A_VAL(&color), ca, A_VAL(&color), tmp)
- pfunc(color, p + dstw);
- }
- }
-
- yy += dyy;
- px++;
- p++;
- }
-
- *cl_x1 = px + clx;
- *cl_y1 = py + cly;
-
- return 1;
- }
-
- /* steep: y-parametric */
-
- SETUP_LINE_STEEP
-
- *cl_x0 = px + clx;
- *cl_y0 = py + cly;
-
- while (py < by)
- {
- DATA32 tmp;
- DATA8 aa;
-
- x = (xx >> 16);
- if (prev_x != x)
- {
- prev_x = x;
- px += delx;
- p += delx;
- }
-
- if (!p1_in)
- {
- if ((px < -1) && (delx < 0)) break;
- if ((px > rx) && (delx > 0)) break;
- }
-
- if ((unsigned)(py) < clh)
- {
- aa = (xx - (x << 16)) >> 8;
-
- A_VAL(&color) = 255 - aa;
- if (ca < 255)
- MULT(A_VAL(&color), ca, A_VAL(&color), tmp)
-
- if ((unsigned)(px) < clw)
- pfunc(color, p);
-
- if ((unsigned)(px + 1) < clw)
- {
- A_VAL(&color) = aa;
- if (ca < 255)
- MULT(A_VAL(&color), ca, A_VAL(&color), tmp)
- pfunc(color, p + 1);
- }
- }
-
- xx += dxx;
- py++;
- p += dstw;
- }
-
- *cl_x1 = px + clx;
- *cl_y1 = py + cly;
-
- return 1;
-}
-
-
-ImlibUpdate *
-__imlib_Line_DrawToImage(int x0, int y0, int x1, int y1, DATA32 color,
- ImlibImage *im, int clx, int cly, int clw, int clh,
- ImlibOp op, char blend, char anti_alias,
- char make_updates)
-{
- int cl_x0, cl_y0, cl_x1, cl_y1, drew;
-
- if ((x0 == x1) && (y0 == y1))
- return __imlib_Point_DrawToImage(x0, y0, color,
- im, clx, cly, clw, clh,
- op, blend, make_updates);
-
- if (blend && (!A_VAL(&color))) return NULL;
- if (clw < 0) return NULL;
-
- if (clw == 0)
- {
- clw = im->w;
- clx = 0;
- clh = im->h;
- cly = 0;
- }
-
- CLIP_RECT_TO_RECT(clx, cly, clw, clh, 0, 0, im->w, im->h);
- if ((clw < 1) || (clh < 1))
- return NULL;
-
- if ((x0 < clx) && (x1 < clx)) return NULL;
- if ((x0 >= (clx + clw)) && (x1 >= (clx + clw))) return NULL;
- if ((y0 < cly) && (y1 < cly)) return NULL;
- if ((y0 >= (cly + clh)) && (y1 >= (cly + clh))) return NULL;
-
- if (blend && IMAGE_HAS_ALPHA(im))
- __imlib_build_pow_lut();
-
- if (anti_alias)
- drew = __imlib_Line_DrawToData_AA(x0, y0, x1, y1, color,
- im->data, im->w, clx, cly, clw, clh,
- &cl_x0, &cl_y0, &cl_x1, &cl_y1,
- op, IMAGE_HAS_ALPHA(im), blend);
- else
- drew = __imlib_Line_DrawToData(x0, y0, x1, y1, color,
- im->data, im->w, clx, cly, clw, clh,
- &cl_x0, &cl_y0, &cl_x1, &cl_y1,
- op, IMAGE_HAS_ALPHA(im), blend);
-
- if (drew && make_updates)
- {
- int mi, ma, dx, dy, w, h;
-
- mi = MIN(cl_x0, cl_x1);
- ma = MAX(cl_x0, cl_x1);
- cl_x0 = mi;
- cl_x1 = ma;
- dx = cl_x1 - cl_x0;
-
- mi = MIN(cl_y0, cl_y1);
- ma = MAX(cl_y0, cl_y1);
- cl_y0 = mi;
- cl_y1 = ma;
- dy = cl_y1 - cl_y0;
-
- w = dx + 1;
- h = dy + 1;
-
- if (anti_alias)
- {
- if ( ((cl_x1 + 1) < (clx + clw)) && (dy > dx) ) w++;
- if ( ((cl_y1 + 1) < (cly + clh)) && (dx > dy) ) h++;
- }
-
- CLIP_RECT_TO_RECT(cl_x0, cl_y0, w, h, clx, cly, clw, clh);
- if ((w < 1) || (h < 1))
- return NULL;
-
- return __imlib_AddUpdate(NULL, cl_x0, cl_y0, w, h);
- }
-
- return NULL;
-}
diff --git a/src/loaderpath.h b/src/loaderpath.h
deleted file mode 100644
index ec6875b..0000000
--- a/src/loaderpath.h
+++ /dev/null
@@ -1,3 +0,0 @@
-#include "config.h"
-
-#define SYS_LOADERS_PATH PACKAGE_LIB_DIR"/imlib2_loaders"
diff --git a/src/loaderpath.h.in b/src/loaderpath.h.in
deleted file mode 100644
index 87fd6a8..0000000
--- a/src/loaderpath.h.in
+++ /dev/null
@@ -1,2 +0,0 @@
-#define SYS_LOADERS_PATH "@pkglibdir@"
-#define USER_LOADERS_PATH ".loaders"
diff --git a/src/polygon.c b/src/polygon.c
deleted file mode 100644
index 3219265..0000000
--- a/src/polygon.c
+++ /dev/null
@@ -1,1733 +0,0 @@
-#include "common.h"
-#include "colormod.h"
-#include "image.h"
-#include "blend.h"
-#include "span.h"
-#include "updates.h"
-#include "rgbadraw.h"
-
-
-ImlibPoly
-__imlib_polygon_new()
-{
- ImlibPoly poly;
-
- poly = malloc(sizeof(_ImlibPoly));
- if (!poly)
- return NULL;
- memset(poly, 0, sizeof(_ImlibPoly));
- return poly;
-}
-
-void
-__imlib_polygon_add_point(ImlibPoly poly, int x, int y)
-{
- if (!poly->points)
- {
- poly->points = (ImlibPoint *)malloc(sizeof(ImlibPoint));
- if (!poly->points) return;
-
- poly->pointcount++;
- poly->lx = poly->rx = x;
- poly->ty = poly->by = y;
- }
- else
- {
- poly->pointcount++;
- poly->points =
- (ImlibPoint *)realloc(poly->points, (poly->pointcount * sizeof(ImlibPoint)));
-
- if (!poly->points) { poly->pointcount = 0; return; }
-
- if (x < poly->lx) poly->lx = x;
- if (poly->rx < x) poly->rx = x;
- if (y < poly->ty) poly->ty = y;
- if (poly->by < y) poly->by = y;
- }
-
- poly->points[poly->pointcount - 1].x = x;
- poly->points[poly->pointcount - 1].y = y;
-}
-
-void
-__imlib_polygon_free(ImlibPoly poly)
-{
- if (poly->points)
- free(poly->points);
- free(poly);
-}
-
-
-#define TRUE 1
-#define FALSE 0
-
-/* Check if p lies on segment [ s1, s2 ] given that
- it lies on the line defined by s1 and s2. */
-#define __imlib_point_inside_segment(p_x, p_y, s1_x, s1_y, s2_x,s2_y) \
-(s1_y != s2_y) ? (p_y <= MAX(s1_y, s2_y) && p_y >= MIN(s1_y, s2_y)) : (p_x <= MAX(s1_x, s2_x) && p_x >= MIN(s1_x, s2_x))
-
-#define __imlib_point_on_segment(p_x, p_y, s1_x, s1_y, s2_x, s2_y) \
-__imlib_segments_intersect(p_x, p_y, p_x, p_y, s1_x, s1_y, s2_x, s2_y)
-
-
-void
-__imlib_polygon_get_bounds(ImlibPoly poly, int *px1, int *py1, int *px2, int *py2)
-{
- if (!poly || !poly->points || (poly->pointcount < 1))
- return;
-
- if (px1) *px1 = poly->lx;
- if (py1) *py1 = poly->ty;
- if (px2) *px2 = poly->rx;
- if (py2) *py2 = poly->by;
-}
-
-static double
-__imlib_point_delta_from_line(int p_x, int p_y, int s1_x, int s1_y, int s2_x,
- int s2_y)
-{
- 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);
-
- return (p_y - s1_y - (double)(p_x - s1_x) * m);
- }
-}
-
-static 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);
-
- /* 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 (testS1R * testS2R <= 0.0 && testR1S * testR2S <= 0.0)
- return TRUE;
- else
- return FALSE;
-}
-
-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;
-
- /* 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 */
- 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 */
-
- 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;
- }
- return (count % 2 == 1);
-}
-
-
-
-/** Polygon Drawing and Filling **/
-
-#define STEEP_EDGE 0
-#define SHALLOW_EDGE 1
-#define HORZ_EDGE 2
-
-typedef struct _PolyEdge PolyEdge;
-typedef struct _IndexedValue IndexedValue;
-
-struct _PolyEdge
-{
- int type;
- int xx;
- int dxx, dyy;
- ImlibPoint *v0, *v1;
- int index;
-};
-
-struct _IndexedValue
-{
- int val;
- int index;
-};
-
-static int
-poly_value_sorter(const void *a, const void *b)
-{
- IndexedValue *p, *q;
-
- p = (IndexedValue *)a;
- q = (IndexedValue *)b;
- if (p->val <= q->val) return -1;
- return 1;
-}
-
-static int
-poly_edge_sorter(const void *a, const void *b)
-{
- PolyEdge *p, *q;
-
- p = (PolyEdge *)a;
- q = (PolyEdge *)b;
- if (p->xx < q->xx) return -1;
- if (p->xx > q->xx) return 1;
- if (p->dxx <= q->dxx) return -1;
- return 1;
-}
-
-
-/* general macros */
-
-#define DEL_EDGE(j) \
-{ \
- int m; \
- for (m = 0; (m < nactive_edges) && (edge[m].index != (j)); m++); \
- \
- if (m < nactive_edges) \
- { \
- if (edge[m].type == HORZ_EDGE) nactive_horz_edges--; \
- nactive_edges--; \
- memmove(edge + m, edge + m + 1, \
- (nactive_edges - m) * sizeof(PolyEdge)); \
- } \
-}
-
-#define DEL_HORZ_EDGES \
-{ \
- int m = 0; \
- \
- while (m < nactive_edges) \
- { \
- if (edge[m].type == HORZ_EDGE) \
- { \
- nactive_edges--; \
- memmove(edge + m, edge + m + 1, \
- (nactive_edges - m) * sizeof(PolyEdge)); \
- m--; \
- } \
- m++; \
- } \
- nactive_horz_edges = 0; \
-}
-
-
-#define ADD_EDGE(i) \
-{ \
- int m; \
- \
- for (m = 0; (m < nactive_edges) && (edge[m].index != i); m++); \
- \
- if ((m == nactive_edges) && (i < nvertices) && \
- (nactive_edges < (nvertices - 1))) \
- { \
- ImlibPoint *v0, *v1, *w; \
- PolyEdge *ne; \
- int dx, dy; \
- \
- if (i < (nvertices - 1)) m = i + 1; \
- else m = 0; \
- \
- v0 = (poly->points) + i; \
- v1 = (poly->points) + m; \
- if ((v1->y) < (v0->y)) \
- { \
- w = v0; \
- v0 = v1; \
- v1 = w; \
- } \
- \
- dx = (v1->x) - (v0->x); \
- dy = (v1->y) - (v0->y); \
- ne = edge + nactive_edges; \
- ne->index = i; \
- if (dy == 0) \
- { \
- ne->type = HORZ_EDGE; \
- ne->dxx = 0; \
- if ((v1->x) < (v0->x)) \
- { \
- w = v0; \
- v0 = v1; \
- v1 = w; \
- } \
- ne->xx = (v0->x) << 16; \
- nactive_horz_edges++; \
- } \
- else \
- { \
- ne->type = STEEP_EDGE; \
- ne->dxx = ((dx << 16) / dy); \
- ne->xx = ((ne->dxx) * (y - (v0->y))) + ((v0->x) << 16); \
- if ((dy < dx) || (dy < (-dx))) \
- { \
- ne->type = SHALLOW_EDGE; \
- ne->dyy = ((dy << 16) / dx); \
- } \
- } \
- ne->v0 = v0; \
- ne->v1 = v1; \
- nactive_edges++; \
- } \
-}
-
-
-#define GET_EDGE_RANGE(e, elx, erx) \
- switch(e->type) \
- { \
- case SHALLOW_EDGE: \
- { \
- elx = (e->xx - (2 * e->dxx)) >> 16; \
- erx = (e->xx + (2 * e->dxx)) >> 16; \
- if (e->dxx < 0) \
- { lx = elx; elx = erx; erx = lx; } \
- break; \
- } \
- case STEEP_EDGE: \
- { \
- lx = (e->xx >> 16); \
- elx = erx = lx; \
- break; \
- } \
- case HORZ_EDGE: \
- { \
- elx = e->v0->x; \
- erx = e->v1->x; \
- break; \
- } \
- default: \
- break; \
- }
-
-
-#define CLIP_SPAN(lx, rx, clx, clrx) \
- if (lx < (clx)) lx = (clx); \
- if (rx > (clrx)) rx = (clrx);
-
-
-#define BLEND_ALPHA(dst, a, tmp) \
- if (*dst) \
- { \
- tmp = ((a) * (255 - (*(dst)))) + 0x80; \
- *(dst) += ((tmp + (tmp >> 8)) >> 8); \
- } \
- else \
- *(dst) = (a);
-
-
-/* initializing macro used in drawing/filling functions */
-
-#define INIT_POLY \
- sfunc = __imlib_GetShapedSpanDrawFunction(op, dst_alpha, blend); \
- if (!sfunc) return; \
- \
- nvertices = poly->pointcount; \
- if (nvertices < 1) return; \
- \
- clrx = clx + clw - 1; \
- clby = cly + clh - 1; \
- \
- CLIP_SPAN(clx, clrx, poly->lx, a_a + poly->rx) \
- if (clrx < clx) return; \
- \
- CLIP_SPAN(cly, clby, poly->ty, poly->by) \
- if (clby < cly) return; \
- \
- clw = clrx - clx + 1; \
- clh = clby - cly + 1; \
- \
- edge = (PolyEdge *)malloc(nvertices * sizeof(PolyEdge)); \
- if (!edge) return; \
- \
- ysort = (IndexedValue *)malloc(nvertices * sizeof(IndexedValue)); \
- if (!ysort) { free(edge); return; } \
- \
- s0 = (DATA8 *)malloc(clw * sizeof(DATA8)); \
- if (!s0) { free(edge); free(ysort); return; } \
- \
- s1 = (DATA8 *)malloc(clw * sizeof(DATA8)); \
- if (!s1) { free(edge); free(ysort); free(s0); return; } \
- \
- memset(s0,0,clw); \
- \
- k = 0; \
- while (k < nvertices) \
- { \
- ysort[k].val = poly->points[k].y; \
- ysort[k].index = k; \
- k++; \
- } \
- \
- qsort(ysort, nvertices, sizeof(IndexedValue), poly_value_sorter); \
- \
- s0 -= clx; \
- s1 -= clx; \
- \
- x0 = clx; \
- x1 = clrx; \
- \
- nx0 = clrx + 1; \
- nx1 = clx - 1; \
- \
- if (cly > poly->ty) \
- ty = cly - 1; \
- else \
- ty = cly; \
- by = clby; \
- \
- p = dst + (dstw * ty); \
- k = 0; \
- nactive_edges = 0; \
- nactive_horz_edges = 0; \
- y = ty;
-
-
-#define DE_INIT_POLY \
- free(edge); \
- free(ysort); \
- s0 += clx; \
- free(s0); \
- s1 += clx; \
- free(s1);
-
-
-
-/** Polygon Drawing **/
-
-
-/* aliased drawing */
-/* draws the poly-line defined by the sequence of vertices */
-
-static void
-__imlib_Polygon_DrawToData(ImlibPoly poly, char close, DATA32 color,
- DATA32 *dst, int dstw,
- int clx, int cly, int clw, int clh,
- ImlibOp op, char dst_alpha, char blend)
-{
- ImlibShapedSpanDrawFunction sfunc;
- IndexedValue *ysort;
- PolyEdge *edge;
- int k, a_a = 0;
- int nactive_edges, nactive_horz_edges, nvertices;
- int clrx, clby, ty, by, y;
- int x0, x1, nx0, nx1;
- DATA32 *p;
- DATA8 *s0, *s1, *ps;
-
- INIT_POLY
-
- while (y <= by)
- {
- int j;
-
- while ((k < nvertices) && (poly->points[ysort[k].index].y <= y))
- {
- int i = ysort[k].index;
-
- j = i - 1;
- if (close && (i == 0))
- j = nvertices - 1;
-
- if (j >= 0)
- {
- if (poly->points[j].y < y)
- DEL_EDGE(j)
- else
- ADD_EDGE(j)
- }
-
- j = i + 1;
- if (close && (i == (nvertices - 1)))
- j = 0;
-
- if (j < nvertices)
- {
- if (poly->points[j].y < y)
- DEL_EDGE(i)
- else
- ADD_EDGE(i)
- }
-
- k++;
- }
-
- /* not really needed, but... */
- qsort(edge, nactive_edges, sizeof(PolyEdge), poly_edge_sorter);
-
- /* clear alpha buffer */
- if (x0 <= x1)
- memset(s1 + x0, 0, x1 - x0 + 1);
-
- x0 = nx0; x1 = nx1;
- nx0 = clrx + 1; nx1 = clx - 1;
-
- /* draw to alpha buffer */
- j = 0;
- while (j < nactive_edges)
- {
- int lx, rx;
- int e_lx, e_rx;
- PolyEdge *e;
-
- e = edge + j;
-
- GET_EDGE_RANGE(e, e_lx, e_rx)
- if ((e_lx < e->v0->x) && (e->dxx > 0))
- e_lx = e->v0->x;
- if ((e_rx > e->v0->x) && (e->dxx < 0))
- e_rx = e->v0->x;
-
- /* draw edge */
- switch (e->type)
- {
- case STEEP_EDGE:
- {
- lx = e_lx;
- lx += (e->xx - (lx << 16)) >> 15;
- if (IN_SEGMENT(lx, clx, clw))
- {
- *(s0 + lx) = 255;
- if (lx < x0) x0 = lx;
- if (lx > x1) x1 = lx;
- }
-
- if ((e->v1->y == (y + 1)) && (y < clby))
- {
- lx = e->v1->x;
- if (IN_SEGMENT(lx, clx, clw))
- {
- *(s1 + lx) = 255;
- if (lx < nx0) nx0 = lx;
- if (lx > nx1) nx1 = lx;
- }
- }
- break;
- }
- case SHALLOW_EDGE:
- {
- int x, ey, eyy;
-
- if (e->dyy > 0) x = e_lx;
- else x = e_rx;
-
- eyy = ((e->v0->y) << 16) + (x - (e->v0->x)) * (e->dyy);
- ey = eyy >> 16;
- ey += (eyy - (ey << 16)) >> 15;
-
- if (e->dyy > 0)
- {
- if (x < x0) x0 = x;
- while (ey <= y)
- {
- if ((ey == y) && IN_SEGMENT(x, clx, clw))
- *(s0 + x) = 255;
- eyy += e->dyy;
- ey = eyy >> 16;
- ey += (eyy - (ey << 16)) >> 15;
- x++;
- }
- if (x > x1) x1 = x;
-
- if (((y + 1) == e->v1->y) && (y < clby))
- {
- if (x < nx0) nx0 = x;
- rx = e->v1->x;
- while ((ey == (y + 1)) && (x <= rx))
- {
- if (IN_SEGMENT(x, clx, clw))
- *(s1 + x) = 255;
- eyy += e->dyy;
- ey = eyy >> 16;
- ey += (eyy - (ey << 16)) >> 15;
- x++;
- }
- if (x > nx1) nx1 = x;
- }
- break;
- }
-
- if (x > x1) x1 = x;
- while (ey <= y)
- {
- if ((ey == y) && IN_SEGMENT(x, clx, clw))
- *(s0 + x) = 255;
- eyy -= e->dyy;
- ey = eyy >> 16;
- ey += (eyy - (ey << 16)) >> 15;
- x--;
- }
- if (x < x0) x0 = x;
-
- if (((y + 1) == e->v1->y) && (y < clby))
- {
- if (x > nx1) nx1 = x;
- lx = e->v1->x;
- while ((ey == (y + 1)) && (x >= lx))
- {
- if (IN_SEGMENT(x, clx, clw))
- *(s1 + x) = 255;
- eyy -= e->dyy;
- ey = eyy >> 16;
- ey += (eyy - (ey << 16)) >> 15;
- x--;
- }
- if (x < nx0) nx0 = x;
- }
- break;
- }
- case HORZ_EDGE:
- {
- lx = e_lx;
- rx = e_rx;
- CLIP_SPAN(lx, rx, clx, clrx);
- if (lx <= rx)
- {
- memset(s0 + lx, 255, rx - lx + 1);
- if (lx < x0) x0 = lx;
- if (rx > x1) x1 = rx;
- }
- break;
- }
-
- default:
- break;
- }
-
- e->xx += e->dxx;
- j++;
- }
-
- if (nactive_horz_edges > 0)
- DEL_HORZ_EDGES
-
- /* draw alpha buffer to dst */
- CLIP_SPAN(x0, x1, clx, clrx)
- if ((x0 <= x1) && (y >= cly))
- sfunc(s0 + x0, color, p + x0, x1 - x0 + 1);
-
- /* exchange alpha buffers */
- ps = s0; s0 = s1; s1 = ps;
-
- y++;
- p += dstw;
- }
-
- DE_INIT_POLY
-}
-
-
-/* anti-aliased drawing */
-
-static void
-__imlib_Polygon_DrawToData_AA(ImlibPoly poly, char close, DATA32 color,
- DATA32 *dst, int dstw,
- int clx, int cly, int clw, int clh,
- ImlibOp op, char dst_alpha, char blend)
-{
- ImlibShapedSpanDrawFunction sfunc;
- IndexedValue *ysort;
- PolyEdge *edge;
- int k, a_a = 1;
- int nactive_edges, nactive_horz_edges, nvertices;
- int clrx, clby, ty, by, y, yy, prev_y, prev_yy;
- int x0, x1, nx0, nx1;
- DATA32 *p;
- DATA8 *s0, *s1, *ps;
-
- INIT_POLY
-
- yy = y << 16;
- prev_y = y - 1;
- prev_yy = prev_y << 16;
-
- while (y <= by)
- {
- int j;
-
- while ((k < nvertices) && (poly->points[ysort[k].index].y <= y))
- {
- int i = ysort[k].index;
-
- j = i - 1;
- if (close && (i == 0))
- j = nvertices - 1;
-
- if (j >= 0)
- {
- if (poly->points[j].y < y)
- DEL_EDGE(j)
- else
- ADD_EDGE(j)
- }
-
- j = i + 1;
- if (close && (i == (nvertices - 1)))
- j = 0;
-
- if (j < nvertices)
- {
- if (poly->points[j].y <= y)
- DEL_EDGE(i)
- else
- ADD_EDGE(i)
- }
-
- k++;
- }
-
- /* not really needed, but... */
- qsort(edge, nactive_edges, sizeof(PolyEdge), poly_edge_sorter);
-
- /* clear alpha buffer */
- if (x0 <= x1)
- memset(s1 + x0, 0, x1 - x0 + 1);
-
- x0 = nx0; x1 = nx1;
- nx0 = clrx + 1; nx1 = clx - 1;
-
- /* draw to alpha buffer */
- j = 0;
- while (j < nactive_edges)
- {
- int lx, rx;
- int e_lx, e_rx;
- PolyEdge *e;
-
- e = edge + j;
-
- GET_EDGE_RANGE(e, e_lx, e_rx)
- if ((e_lx < e->v0->x) && (e->dxx > 0))
- e_lx = e->v0->x;
- if ((e_rx > e->v0->x) && (e->dxx < 0))
- e_rx = e->v0->x;
-
- /* draw aa edge */
- switch (e->type)
- {
- case STEEP_EDGE:
- {
- DATA32 tmp; DATA8 aa;
-
- aa = (e->xx - (e_lx << 16)) >> 8;
- rx = e_lx + 1;
- if (IN_SEGMENT(rx, clx, clw))
- {
- ps = s0 + rx;
- BLEND_ALPHA(ps, aa, tmp)
- if (rx > x1) x1 = rx;
- }
- if (IN_SEGMENT(e_lx, clx, clw))
- {
- aa = 255 - aa;
- ps = s0 + e_lx;
- BLEND_ALPHA(ps, aa, tmp)
- if (e_lx < x0) x0 = e_lx;
- }
-
- if ((e->v1->y == (y + 1)) && (y < clby))
- {
- lx = (e->xx + e->dxx) >> 16;
- aa = ((e->xx + e->dxx - (lx << 16)) >> 8);
- rx = lx + 1;
- if (IN_SEGMENT(rx, clx, clw))
- {
- ps = s1 + rx;
- BLEND_ALPHA(ps, aa, tmp)
- if (rx > nx1) nx1 = rx;
- }
- if (IN_SEGMENT(lx, clx, clw))
- {
- aa = 255 - aa;
- ps = s1 + lx;
- BLEND_ALPHA(ps, aa, tmp)
- if (lx < nx0) nx0 = lx;
- }
- }
- break;
- }
- case SHALLOW_EDGE:
- {
- int x, ey, eyy;
-
- if (e->dyy > 0) x = e_lx;
- else x = e_rx;
-
- eyy = ((e->v0->y) << 16) + (x - (e->v0->x)) * (e->dyy);
- ey = eyy >> 16;
-
- if (e->dyy > 0)
- {
- if (x < x0) x0 = x;
- while (ey < y)
- {
- DATA32 tmp; DATA8 aa;
-
- if ((ey == prev_y) && IN_SEGMENT(x, clx, clw))
- {
- aa = ((eyy - prev_yy) >> 8);
- ps = s0 + x;
- BLEND_ALPHA(ps, aa, tmp)
- }
- eyy += e->dyy;
- ey = eyy >> 16;
- x++;
- }
- lx = x;
- while (ey == y)
- {
- DATA32 tmp; DATA8 aa;
-
- if (IN_SEGMENT(x, clx, clw))
- {
- aa = 255 - ((eyy - yy) >> 8);
- ps = s0 + x;
- BLEND_ALPHA(ps, aa, tmp)
- }
- eyy += e->dyy;
- ey = eyy >> 16;
- x++;
- }
- if (x > x1) x1 = x;
-
- if (((y + 1) == e->v1->y) && (y < clby))
- {
- x = lx;
- if (x < nx0) nx0 = x;
- rx = e->v1->x;
- eyy = ((e->v0->y) << 16) + (x - (e->v0->x)) * (e->dyy);
- ey = eyy >> 16;
- while ((ey == y) && (x <= rx))
- {
- DATA32 tmp; DATA8 aa;
-
- if (IN_SEGMENT(x, clx, clw))
- {
- aa = ((eyy - yy) >> 8);
- ps = s1 + x;
- BLEND_ALPHA(ps, aa, tmp)
- }
- eyy += e->dyy;
- ey = eyy >> 16;
- x++;
- }
- if (x > nx1) nx1 = x;
- }
- break;
- }
-
- if (x > x1) x1 = x;
- while (ey < y)
- {
- DATA32 tmp; DATA8 aa;
-
- if ((ey == prev_y) && IN_SEGMENT(x, clx, clw))
- {
- aa = ((eyy - prev_yy) >> 8);
- ps = s0 + x;
- BLEND_ALPHA(ps, aa, tmp)
- }
- eyy -= e->dyy;
- ey = eyy >> 16;
- x--;
- }
- rx = x;
- while (ey == y)
- {
- DATA32 tmp; DATA8 aa;
-
- if (IN_SEGMENT(x, clx, clw))
- {
- aa = 255 - ((eyy - yy) >> 8);
- ps = s0 + x;
- BLEND_ALPHA(ps, aa, tmp)
- }
- eyy -= e->dyy;
- ey = eyy >> 16;
- x--;
- }
- if (x < x0) x0 = x;
-
- if (((y + 1) == e->v1->y) && (y < clby))
- {
- x = rx;
- if (x > nx1) nx1 = x;
- lx = e->v1->x;
- eyy = ((e->v0->y) << 16) + (x - (e->v0->x)) * (e->dyy);
- ey = eyy >> 16;
- while ((ey == y) && (x >= lx))
- {
- DATA32 tmp; DATA8 aa;
-
- if (IN_SEGMENT(x, clx, clw))
- {
- aa = ((eyy - yy) >> 8);
- ps = s1 + x;
- BLEND_ALPHA(ps, aa, tmp)
- }
- eyy -= e->dyy;
- ey = eyy >> 16;
- x--;
- }
- if (x < nx0) nx0 = x;
- }
- break;
- }
- case HORZ_EDGE:
- {
- lx = e_lx;
- rx = e_rx;
- CLIP_SPAN(lx, rx, clx, clrx);
- if (lx <= rx)
- {
- memset(s0 + lx, 255, rx - lx + 1);
- if (lx < x0) x0 = lx;
- if (rx > x1) x1 = rx;
- }
- break;
- }
-
- default:
- break;
- }
-
- e->xx += e->dxx;
- j++;
- }
-
- if (nactive_horz_edges > 0)
- DEL_HORZ_EDGES
-
- /* draw alpha buffer to dst */
- CLIP_SPAN(x0, x1, clx, clrx)
- if ((x0 <= x1) && (y >= cly))
- sfunc(s0 + x0, color, p + x0, x1 - x0 + 1);
-
- /* exchange alpha buffers */
- ps = s0; s0 = s1; s1 = ps;
-
- prev_yy = yy;
- prev_y = y;
-
- y++;
- yy = y << 16;
-
- p += dstw;
- }
-
- DE_INIT_POLY
-}
-
-
-
-void
-__imlib_Polygon_DrawToImage(ImlibPoly poly, char close, DATA32 color,
- ImlibImage *im, int clx, int cly, int clw, int clh,
- ImlibOp op, char blend, char anti_alias)
-{
- if ((!poly) || (!poly->points) || (poly->pointcount < 1) || (clw < 0))
- return;
- if (blend && (!A_VAL(&color)))
- return;
- if (poly->pointcount == 1)
- {
- (void)__imlib_Point_DrawToImage(poly->points[0].x, poly->points[0].y, color,
- im, clx, cly, clw, clh,
- op, blend, 0);
- return;
- }
- if (poly->pointcount == 2)
- {
- (void)__imlib_Line_DrawToImage(poly->points[0].x, poly->points[0].y,
- poly->points[1].x, poly->points[1].y, color,
- im, clx, cly, clw, clh,
- op, blend, anti_alias, 0);
- return;
- }
-
- if (clw == 0)
- {
- clw = im->w;
- clx = 0;
- clh = im->h;
- cly = 0;
- }
-
- CLIP_RECT_TO_RECT(clx, cly, clw, clh, 0, 0, im->w, im->h);
- if ((clw < 1) || (clh < 1))
- return;
-
- if (blend && IMAGE_HAS_ALPHA(im))
- __imlib_build_pow_lut();
-
- if (anti_alias)
- __imlib_Polygon_DrawToData_AA(poly, close, color,
- im->data, im->w,
- clx, cly, clw, clh,
- op, IMAGE_HAS_ALPHA(im), blend);
- else
- __imlib_Polygon_DrawToData(poly, close, color,
- im->data, im->w,
- clx, cly, clw, clh,
- op, IMAGE_HAS_ALPHA(im), blend);
-}
-
-
-
-/** Polygon Filling **/
-
-
-/* aliased filling */
-
-static void
-__imlib_Polygon_FillToData(ImlibPoly poly, DATA32 color,
- DATA32 *dst, int dstw,
- int clx, int cly, int clw, int clh,
- ImlibOp op, char dst_alpha, char blend)
-{
- ImlibShapedSpanDrawFunction sfunc;
- IndexedValue *ysort;
- PolyEdge *edge;
- int k, a_a = 0;
- int nactive_edges, nactive_horz_edges, nvertices;
- int clrx, clby, ty, by, y;
- int x0, x1, nx0, nx1;
- DATA32 *p;
- DATA8 *s0, *s1, *ps;
-
- INIT_POLY
-
- while (y <= by)
- {
- int j;
-
- while ((k < nvertices) && (poly->points[ysort[k].index].y <= y))
- {
- int i = ysort[k].index;
-
- if (i > 0) j = i - 1;
- else j = nvertices - 1;
-
- if (poly->points[j].y < y)
- DEL_EDGE(j)
- else
- ADD_EDGE(j)
-
- if (i < (nvertices - 1)) j = i + 1;
- else j = 0;
-
- if (poly->points[j].y < y)
- DEL_EDGE(i)
- else
- ADD_EDGE(i)
-
- k++;
- }
-
- qsort(edge, nactive_edges, sizeof(PolyEdge), poly_edge_sorter);
-
- /* clear alpha buffer */
- if (x0 <= x1)
- memset(s1 + x0, 0, x1 - x0 + 1);
-
- x0 = nx0; x1 = nx1;
- nx0 = clrx + 1; nx1 = clx - 1;
-
- /* draw to alpha buffer */
- j = 0;
- while (j < nactive_edges)
- {
- int lx, rx;
- int le_lx, le_rx;
- int re_lx, re_rx;
- PolyEdge *le, *re;
-
- if (j < (nactive_edges - 1))
- { le = edge + j; re = le + 1; }
- else if (j > 0)
- { le = edge + (j - 1); le->xx -= le->dxx; re = le + 1; }
- else
- { re = le = edge; }
-
- GET_EDGE_RANGE(le, le_lx, le_rx)
- if ((le_lx < le->v0->x) && (le->dxx > 0))
- le_lx = le->v0->x;
- GET_EDGE_RANGE(re, re_lx, re_rx)
- if ((re_rx > re->v0->x) && (re->dxx < 0))
- re_rx = re->v0->x;
-
- /* draw left edge */
- switch (le->type)
- {
- case STEEP_EDGE:
- {
- le_rx += (le->xx - (le_rx << 16)) >> 15;
- if (le_rx < x0) x0 = le_rx;
-
- if ((le->v1->y == (y + 1)) && (y < clby))
- {
- lx = le->v1->x;
- if (IN_SEGMENT(lx, clx, clw))
- {
- *(s1 + lx) = 255;
- if (lx < nx0) nx0 = lx;
- }
- }
- break;
- }
- case SHALLOW_EDGE:
- {
- int x, ey, eyy;
-
- x = le_lx;
- eyy = ((le->v0->y) << 16) + (x - (le->v0->x)) * (le->dyy);
- ey = eyy >> 16;
- ey += (eyy - (ey << 16)) >> 15;
-
- if (le->dyy > 0)
- {
- while (ey < y)
- {
- eyy += le->dyy;
- ey = eyy >> 16;
- ey += (eyy - (ey << 16)) >> 15;
- x++;
- }
- le_rx = x;
- if (x < x0) x0 = x;
-
- if (((y + 1) == le->v1->y) && (y < clby))
- {
- if (x < nx0) nx0 = x;
- rx = le->v1->x;
- while ((ey <= (y + 1)) && (x <= rx))
- {
- if ((ey == (y + 1)) && IN_SEGMENT(x, clx, clw))
- *(s1 + x) = 255;
- eyy += le->dyy;
- ey = eyy >> 16;
- ey += (eyy - (ey << 16)) >> 15;
- x++;
- }
- if (x > nx1) nx1 = x;
- }
- break;
- }
-
- while (ey > y)
- {
- eyy += le->dyy;
- ey = eyy >> 16;
- ey += (eyy - (ey << 16)) >> 15;
- x++;
- }
- le_rx = x;
- if (x < x0) x0 = x;
- break;
- }
- case HORZ_EDGE:
- {
- lx = le_lx;
- rx = le_rx;
- CLIP_SPAN(lx, rx, clx, clrx);
- if (lx <= rx)
- {
- memset(s0 + lx, 255, rx - lx + 1);
- if (lx < x0) x0 = lx;
- }
- le_rx++;
- break;
- }
-
- default:
- break;
- }
-
- /* draw right edge */
- switch (re->type)
- {
- case STEEP_EDGE:
- {
- re_lx += (re->xx - (re_lx << 16)) >> 15;
- if (re_lx > x1) x1 = re_lx;
-
- if ((re->v1->y == (y + 1)) && (y < clby))
- {
- rx = re->v1->x;
- if (IN_SEGMENT(rx, clx, clw))
- {
- *(s1 + rx) = 255;
- if (rx > nx1) nx1 = rx;
- }
- }
- break;
- }
- case SHALLOW_EDGE:
- {
- int x, ey, eyy;
-
- x = re_rx;
- eyy = ((re->v0->y) << 16) + (x - (re->v0->x)) * (re->dyy);
- ey = eyy >> 16;
- ey += (eyy - (ey << 16)) >> 15;
-
- if (re->dyy > 0)
- {
- while (ey > y)
- {
- eyy -= re->dyy;
- ey = eyy >> 16;
- ey += (eyy - (ey << 16)) >> 15;
- x--;
- }
- re_lx = x;
- if (x > x1) x1 = x;
- break;
- }
-
- while (ey < y)
- {
- eyy -= re->dyy;
- ey = eyy >> 16;
- ey += (eyy - (ey << 16)) >> 15;
- x--;
- }
- re_lx = x;
- if (x > x1) x1 = x;
-
- if (((y + 1) == re->v1->y) && (y < clby))
- {
- if (x > nx1) nx1 = x;
- lx = re->v1->x;
- while ((ey <= (y + 1)) && (x >= lx))
- {
- if ((ey == (y + 1)) && IN_SEGMENT(x, clx, clw))
- *(s1 + x) = 255;
- eyy -= re->dyy;
- ey = eyy >> 16;
- ey += (eyy - (ey << 16)) >> 15;
- x--;
- }
- if (x < nx0) nx0 = x;
- }
- break;
- }
- case HORZ_EDGE:
- {
- lx = re_lx;
- rx = re_rx;
- CLIP_SPAN(lx, rx, clx, clrx);
- if (lx <= rx)
- {
- memset(s0 + lx, 255, rx - lx + 1);
- if (rx > x1) x1 = rx;
- }
- re_lx--;
- break;
- }
-
- default:
- break;
- }
-
- /* draw span between edges */
- lx = le_rx; rx = re_lx;
- CLIP_SPAN(lx, rx, clx, clrx)
- if ((lx <= rx) && (y >= cly))
- memset(s0 + lx, 255, rx - lx + 1);
-
- le->xx += le->dxx;
- if (le != re)
- re->xx += re->dxx;
-
- j += 2;
- }
-
- if (nactive_horz_edges > 0)
- DEL_HORZ_EDGES
-
- /* draw alpha buffer to dst */
- CLIP_SPAN(x0, x1, clx, clrx)
- if ((x0 <= x1) && (y >= cly))
- sfunc(s0 + x0, color, p + x0, x1 - x0 + 1);
-
- /* exchange alpha buffers */
- ps = s0; s0 = s1; s1 = ps;
-
- y++;
- p += dstw;
- }
-
- DE_INIT_POLY
-}
-
-
-/* anti-aliased filling */
-
-static void
-__imlib_Polygon_FillToData_AA(ImlibPoly poly, DATA32 color,
- DATA32 *dst, int dstw,
- int clx, int cly, int clw, int clh,
- ImlibOp op, char dst_alpha, char blend)
-{
- ImlibShapedSpanDrawFunction sfunc;
- IndexedValue *ysort;
- PolyEdge *edge;
- int k, a_a = 1;
- int nactive_edges, nactive_horz_edges, nvertices;
- int clrx, clby, ty, by, y, yy, prev_y, prev_yy;
- int x0, x1, nx0, nx1;
- DATA32 *p;
- DATA8 *s0, *s1, *ps;
-
- INIT_POLY
-
- yy = y << 16;
- prev_y = y - 1;
- prev_yy = prev_y << 16;
-
- while (y <= by)
- {
- int j;
-
- while ((k < nvertices) && (poly->points[ysort[k].index].y <= y))
- {
- int i = ysort[k].index;
-
- if (i > 0) j = i - 1;
- else j = nvertices - 1;
-
- if (poly->points[j].y < y)
- DEL_EDGE(j)
- else
- ADD_EDGE(j)
-
- if (i < (nvertices - 1)) j = i + 1;
- else j = 0;
-
- if (poly->points[j].y < y)
- DEL_EDGE(i)
- else
- ADD_EDGE(i)
-
- k++;
- }
-
- qsort(edge, nactive_edges, sizeof(PolyEdge), poly_edge_sorter);
-
- /* clear alpha buffer */
- if (x0 <= x1)
- memset(s1 + x0, 0, x1 - x0 + 1);
-
- x0 = nx0; x1 = nx1;
- nx0 = clrx + 1; nx1 = clx - 1;
- /* draw to alpha buffer */
- j = 0;
- while (j < nactive_edges)
- {
- int lx, rx;
- int le_lx, le_rx;
- int re_lx, re_rx;
- PolyEdge *le, *re;
-
- if (j < (nactive_edges - 1))
- { le = edge + j; re = le + 1; }
- else if (j > 0)
- { le = edge + (j - 1); le->xx -= le->dxx; re = le + 1; }
- else
- { re = le = edge; }
-
- GET_EDGE_RANGE(le, le_lx, le_rx)
- if ((le_lx < le->v0->x) && (le->dxx > 0))
- le_lx = le->v0->x;
- GET_EDGE_RANGE(re, re_lx, re_rx)
- if ((re_rx > re->v0->x) && (re->dxx < 0))
- re_rx = re->v0->x;
-
- /* draw left aa edge */
- switch (le->type)
- {
- case STEEP_EDGE:
- {
- DATA32 tmp; DATA8 aa;
-
- if (le_lx < x0) x0 = le_lx;
- le_rx = le_lx + 1;
-
- if (IN_SEGMENT(le_lx, clx, clw))
- {
- aa = 255 - ((le->xx - (le_lx << 16)) >> 8);
- ps = s0 + le_lx;
- BLEND_ALPHA(ps, aa, tmp)
- }
-
- if ((le->v1->y == (y + 1)) && (y < clby))
- {
- lx = (le->xx + le->dxx) >> 16;
- if (IN_SEGMENT(lx, clx, clw))
- {
- aa = 255 - ((le->xx + le->dxx - (lx << 16)) >> 8);
- ps = s1 + lx;
- BLEND_ALPHA(ps, aa, tmp)
- if (lx < nx0) nx0 = lx;
- }
- }
- break;
- }
- case SHALLOW_EDGE:
- {
- int x, ey, eyy;
-
- if (le_lx < x0) x0 = le_lx;
- x = le_lx;
- eyy = ((le->v0->y) << 16) + (x - (le->v0->x)) * (le->dyy);
- ey = eyy >> 16;
-
- if (le->dyy > 0)
- {
- while (ey < y)
- {
- DATA32 tmp; DATA8 aa;
-
- if ((ey == prev_y) && IN_SEGMENT(x, clx, clw))
- {
- aa = ((eyy - prev_yy) >> 8);
- ps = s0 + x;
- BLEND_ALPHA(ps, aa, tmp)
- }
- eyy += le->dyy;
- ey = eyy >> 16;
- x++;
- }
- le_rx = x;
-
- if (((y + 1) == le->v1->y) && (y < clby))
- {
- if (x < nx0) nx0 = x;
- rx = le->v1->x;
- while ((ey == y) && (x <= rx))
- {
- DATA32 tmp; DATA8 aa;
-
- if (IN_SEGMENT(x, clx, clw))
- {
- aa = ((eyy - yy) >> 8);
- ps = s1 + x;
- BLEND_ALPHA(ps, aa, tmp)
- }
- eyy += le->dyy;
- ey = eyy >> 16;
- x++;
- }
- }
- break;
- }
-
- while (ey >= y)
- {
- DATA32 tmp; DATA8 aa;
-
- if ((ey == y) && IN_SEGMENT(x, clx, clw))
- {
- aa = 255 - ((eyy - yy) >> 8);
- ps = s0 + x;
- BLEND_ALPHA(ps, aa, tmp)
- }
- eyy += le->dyy;
- ey = eyy >> 16;
- x++;
- }
- le_rx = x;
- break;
- }
- case HORZ_EDGE:
- {
- lx = le_lx;
- rx = le_rx;
- CLIP_SPAN(lx, rx, clx, clrx);
- if (lx <= rx)
- {
- memset(s0 + lx, 255, rx - lx + 1);
- if (lx < x0) x0 = lx;
- }
- le_rx++;
- break;
- }
-
- default:
- break;
- }
-
- /* draw right aa edge */
- switch (re->type)
- {
- case STEEP_EDGE:
- {
- DATA32 tmp; DATA8 aa;
-
- rx = re_lx + 1;
- if (rx > x1) x1 = rx;
-
- if (IN_SEGMENT(rx, clx, clw))
- {
- aa = (re->xx - (re_lx << 16)) >> 8;
- ps = s0 + rx;
- BLEND_ALPHA(ps, aa, tmp)
- }
-
- if ((re->v1->y == (y + 1)) && (y < clby))
- {
- lx = (re->xx + re->dxx) >> 16; rx = lx + 1;
- if (IN_SEGMENT(rx, clx, clw))
- {
- aa = ((re->xx + re->dxx - (lx << 16)) >> 8);
- ps = s1 + rx;
- BLEND_ALPHA(ps, aa, tmp)
- if (rx > nx1) nx1 = rx;
- }
- }
- break;
- }
- case SHALLOW_EDGE:
- {
- int x, ey, eyy;
-
- if (re_rx > x1) x1 = re_rx;
- x = re_rx;
- eyy = ((re->v0->y) << 16) + (x - (re->v0->x)) * (re->dyy);
- ey = eyy >> 16;
-
- if (re->dyy > 0)
- {
- while (ey >= y)
- {
- DATA32 tmp; DATA8 aa;
-
- if ((ey == y) && IN_SEGMENT(x, clx, clw))
- {
- aa = 255 - ((eyy - yy) >> 8);
- ps = s0 + x;
- BLEND_ALPHA(ps, aa, tmp)
- }
- eyy -= re->dyy;
- ey = eyy >> 16;
- x--;
- }
- re_lx = x;
- break;
- }
-
- while (ey < y)
- {
- DATA32 tmp; DATA8 aa;
-
- if ((ey == prev_y) && IN_SEGMENT(x, clx, clw))
- {
- aa = ((eyy - prev_yy) >> 8);
- ps = s0 + x;
- BLEND_ALPHA(ps, aa, tmp)
- }
- eyy -= re->dyy;
- ey = eyy >> 16;
- x--;
- }
- re_lx = x;
-
- if (((y + 1) == re->v1->y) && (y < clby))
- {
- if (x > nx1) nx1 = x;
- lx = re->v1->x;
- while ((ey == y) && (x >= lx))
- {
- DATA32 tmp; DATA8 aa;
-
- if (IN_SEGMENT(x, clx, clw))
- {
- aa = ((eyy - yy) >> 8);
- ps = s1 + x;
- BLEND_ALPHA(ps, aa, tmp)
- }
- eyy -= re->dyy;
- ey = eyy >> 16;
- x--;
- }
- }
- break;
- }
- case HORZ_EDGE:
- {
- lx = re_lx;
- rx = re_rx;
- CLIP_SPAN(lx, rx, clx, clrx);
- if (lx <= rx)
- {
- memset(s0 + lx, 255, rx - lx + 1);
- if (rx > x1) x1 = rx;
- }
- re_lx--;
- break;
- }
-
- default:
- break;
- }
-
- /* draw span between edges */
- lx = le_rx; rx = re_lx;
- CLIP_SPAN(lx, rx, clx, clrx)
- if ((lx <= rx) && (y >= cly))
- memset(s0 + lx, 255, rx - lx + 1);
-
- le->xx += le->dxx;
- if (le != re)
- re->xx += re->dxx;
-
- j += 2;
- }
-
- if (nactive_horz_edges > 0)
- DEL_HORZ_EDGES
-
- /* draw alpha buffer to dst */
- CLIP_SPAN(x0, x1, clx, clrx)
- if ((x0 <= x1) && (y >= cly))
- sfunc(s0 + x0, color, p + x0, x1 - x0 + 1);
-
- /* exchange alpha buffers */
- ps = s0; s0 = s1; s1 = ps;
-
- prev_yy = yy;
- prev_y = y;
-
- y++;
- yy = y << 16;
-
- p += dstw;
- }
-
- DE_INIT_POLY
-}
-
-
-
-void
-__imlib_Polygon_FillToImage(ImlibPoly poly, DATA32 color,
- ImlibImage *im, int clx, int cly, int clw, int clh,
- ImlibOp op, char blend, char anti_alias)
-{
- if ((!poly) || (!poly->points) || (poly->pointcount < 1) || (clw < 0))
- return;
- if (blend && (!A_VAL(&color)))
- return;
- if (poly->pointcount == 1)
- {
- (void)__imlib_Point_DrawToImage(poly->points[0].x, poly->points[0].y, color,
- im, clx, cly, clw, clh,
- op, blend, 0);
- return;
- }
- if (poly->pointcount == 2)
- {
- (void)__imlib_Line_DrawToImage(poly->points[0].x, poly->points[0].y,
- poly->points[1].x, poly->points[1].y, color,
- im, clx, cly, clw, clh,
- op, blend, anti_alias, 0);
- return;
- }
-
- if (clw == 0)
- {
- clw = im->w;
- clx = 0;
- clh = im->h;
- cly = 0;
- }
-
- CLIP_RECT_TO_RECT(clx, cly, clw, clh, 0, 0, im->w, im->h);
- if ((clw < 1) || (clh < 1))
- return;
-
- if (blend && IMAGE_HAS_ALPHA(im))
- __imlib_build_pow_lut();
-
- if (anti_alias)
- __imlib_Polygon_FillToData_AA(poly, color,
- im->data, im->w,
- clx, cly, clw, clh,
- op, IMAGE_HAS_ALPHA(im), blend);
- else
- __imlib_Polygon_FillToData(poly, color,
- im->data, im->w,
- clx, cly, clw, clh,
- op, IMAGE_HAS_ALPHA(im), blend);
-}
-
diff --git a/src/rectangle.c b/src/rectangle.c
deleted file mode 100644
index 9be13fe..0000000
--- a/src/rectangle.c
+++ /dev/null
@@ -1,192 +0,0 @@
-#include "common.h"
-#include "colormod.h"
-#include "image.h"
-#include "blend.h"
-#include "span.h"
-#include "updates.h"
-#include "rgbadraw.h"
-
-
-static void
-__imlib_Rectangle_DrawToData(int x, int y, int rw, int rh, DATA32 color,
- DATA32 *dst, int dstw, int clx, int cly, int clw, int clh,
- ImlibOp op, char dst_alpha, char blend)
-{
- ImlibPointDrawFunction pfunc;
- ImlibSpanDrawFunction sfunc;
- int x0, y0, x1, y1, len;
- DATA32 *p, *pp;
-
- if (A_VAL(&color) == 0xff) blend = 0;
-
- sfunc = __imlib_GetSpanDrawFunction(op, dst_alpha, blend);
- pfunc = __imlib_GetPointDrawFunction(op, dst_alpha, blend);
- if (!pfunc || !sfunc)
- return;
-
- dst += (dstw * cly) + clx;
- x -= clx;
- y -= cly;
-
- x0 = x;
- x1 = x + rw - 1;
-
- if (x0 < 0) x0 = 0;
- if (x1 >= clw) x1 = clw - 1;
-
- if (y >= 0)
- {
- p = dst + (dstw * y) + x0;
- len = x1 - x0 + 1;
- sfunc(color, p, len);
- }
- if ((y + rh) <= clh)
- {
- p = dst + (dstw * (y + rh - 1)) + x0;
- len = x1 - x0 + 1;
- sfunc(color, p, len);
- }
-
- y0 = y + 1;
- y1 = y + rh - 2;
-
- if (y0 < 0) y0 = 0;
- if (y1 >= clh) y1 = clh - 1;
-
- len = y1 - y0 + 1;
- if (len <= 0) return;
- y1 = len;
-
- if (x >= 0)
- {
- p = dst + (dstw * y0) + x;
- while (len--)
- {
- pfunc(color, p);
- p += dstw;
- }
- }
- if ((x + rw) <= clw)
- {
- len = y1;
- p = dst + (dstw * y0) + x + rw - 1;
- while (len--)
- {
- pfunc(color, p);
- p += dstw;
- }
- }
-}
-
-static void
-__imlib_Rectangle_FillToData(int x, int y, int rw, int rh, DATA32 color,
- DATA32 *dst, int dstw, int clx, int cly, int clw, int clh,
- ImlibOp op, char dst_alpha, char blend)
-{
- ImlibSpanDrawFunction sfunc;
- DATA32 *p;
-
- if (A_VAL(&color) == 0xff)
- blend = 0;
- sfunc = __imlib_GetSpanDrawFunction(op, dst_alpha, blend);
- if (!sfunc) return;
-
- dst += (dstw * cly) + clx;
- x -= clx;
- y -= cly;
-
- CLIP_RECT_TO_RECT(x, y, rw, rh, 0, 0, clw, clh);
- if ((rw < 1) || (rh < 1))
- return;
-
- p = dst + (dstw * y) + x;
- while (rh--)
- {
- sfunc(color, p, rw);
- p += dstw;
- }
-}
-
-
-void
-__imlib_Rectangle_DrawToImage(int x, int y, int w, int h, DATA32 color,
- ImlibImage *im, int clx, int cly, int clw, int clh,
- ImlibOp op, char blend)
-{
- if ((w < 1) || (h < 1) || (clw < 0))
- return;
- if ((w == 1) || (h == 1))
- {
- (void) __imlib_Line_DrawToImage(x, y, x + w - 1, y + h - 1, color,
- im, clx, cly, clw, clh,
- op, blend, 0, 0);
- return;
- }
- if (blend && (!A_VAL(&color)))
- return;
-
- if (clw == 0)
- {
- clw = im->w;
- clx = 0;
- clh = im->h;
- cly = 0;
- }
-
- CLIP_RECT_TO_RECT(clx, cly, clw, clh, 0, 0, im->w, im->h);
- if ((clw < 1) || (clh < 1))
- return;
-
- CLIP_RECT_TO_RECT(clx, cly, clw, clh, x, y, w, h);
- if ((clw < 1) || (clh < 1))
- return;
-
- if (blend && IMAGE_HAS_ALPHA(im))
- __imlib_build_pow_lut();
-
- __imlib_Rectangle_DrawToData(x, y, w, h, color,
- im->data, im->w, clx, cly, clw, clh,
- op, IMAGE_HAS_ALPHA(im), blend);
-}
-
-
-void
-__imlib_Rectangle_FillToImage(int x, int y, int w, int h, DATA32 color,
- ImlibImage *im, int clx, int cly, int clw, int clh,
- ImlibOp op, char blend)
-{
- if ((w < 1) || (h < 1) || (clw < 0))
- return;
- if ((w == 1) || (h == 1))
- {
- (void) __imlib_Line_DrawToImage(x, y, x + w - 1, y + h - 1, color,
- im, clx, cly, clw, clh,
- op, blend, 0, 0);
- return;
- }
- if (blend && (!A_VAL(&color)))
- return;
-
- if (clw == 0)
- {
- clw = im->w;
- clx = 0;
- clh = im->h;
- cly = 0;
- }
-
- CLIP_RECT_TO_RECT(clx, cly, clw, clh, 0, 0, im->w, im->h);
- if ((clw < 1) || (clh < 1))
- return;
-
- CLIP_RECT_TO_RECT(clx, cly, clw, clh, x, y, w, h);
- if ((clw < 1) || (clh < 1))
- return;
-
- if (blend && IMAGE_HAS_ALPHA(im))
- __imlib_build_pow_lut();
-
- __imlib_Rectangle_FillToData(x, y, w, h, color,
- im->data, im->w, clx, cly, clw, clh,
- op, IMAGE_HAS_ALPHA(im), blend);
-}
diff --git a/src/rend.c b/src/rend.c
deleted file mode 100644
index 8159d46..0000000
--- a/src/rend.c
+++ /dev/null
@@ -1,594 +0,0 @@
-#include "common.h"
-#ifndef X_DISPLAY_MISSING
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-#include <X11/extensions/XShm.h>
-#endif
-#include "colormod.h"
-#include "image.h"
-#include "scale.h"
-#include "ximage.h"
-#include "context.h"
-#include "rgba.h"
-#include "color.h"
-#include "grab.h"
-#include "blend.h"
-#include "rend.h"
-#include "rotate.h"
-
-/* size of the lines per segment we scale / render at a time */
-#define LINESIZE 16
-
-DATA32
-__imlib_RenderGetPixel(Display * d, Drawable w, Visual * v, Colormap cm,
- int depth, DATA8 r, DATA8 g, DATA8 b)
-{
- 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 (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;
- }
- }
- else
- {
- unsigned int rm, gm, bm;
- int i, rshift = 0, gshift = 0, bshift = 0;
- 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);
-
-void
-__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}
- };
-
- 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;
- }
- rmask = xim->red_mask;
- gmask = xim->green_mask;
- bmask = xim->blue_mask;
- rshift = 0;
- gshift = 0;
- bshift = 0;
- for (i = 31; i >= 0; i--)
- {
- if (rmask >= (1 << i))
- {
- rshift = i - 7;
- break;
- }
- }
- for (i = 31; i >= 0; i--)
- {
- if (gmask >= (1 << i))
- {
- gshift = i - 7;
- break;
- }
- }
- for (i = 31; i >= 0; i--)
- {
- 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++;
- }
- }
-}
-
-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)
-{
- 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);
-
- /* dont do anything if we have a 0 widht or height image to render */
- if ((dw == 0) || (dh == 0))
- return;
- /* if the input rect size < 0 dont render either */
- if ((sw <= 0) || (sh <= 0))
- return;
- /* if the output is too big (8k arbitary limit here) dont bother */
- if ((abs(dw) > 8192) || (abs(dh) > 8192))
- 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->w, im->h);
- /* clip output coords to clipped input coords */
- if (psx != sx)
- dx = (dx * sx) / psx;
- if (psy != sy)
- dy = (dy * sy) / psy;
- if (psw != sw)
- dw = (dw * sw) / psw;
- if (psh != sh)
- dh = (dh * sh) / psh;
- /* do a second check to see if we now have invalid coords */
- /* dont do anything if we have a 0 widht or height image to render */
- if ((dw == 0) || (dh == 0))
- return;
- /* if the input rect size < 0 dont render either */
- if ((sw <= 0) || (sh <= 0))
- return;
- /* if the output is too big (8k arbitary limit here) dont bother */
- if ((abs(dw) > 8192) || (abs(dh) > 8192))
- return;
- /* 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;
- }
- /* Sign not needed anymore */
- 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);
- 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;
- }
- }
- /* 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;
- }
- /* 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);
- }
- /* 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;
- }
- }
- /* setup h */
- h = dh;
- /* 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);
-#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)
- {
-#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
-#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;
- }
- /* free up our buffers and poit tables */
- 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 we didnt have a gc... create it */
- if (!gc)
- {
- 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);
- }
- /* write the image */
- if (shm)
- /* write shm XImage */
- XShmPutImage(d, w, gc, xim, 0, 0, dx, dy, dw, dh, False);
- /* write regular XImage */
- else
- XPutImage(d, w, gc, xim, 0, 0, dx, dy, dw, dh);
- /* free the XImage and put onto our free list */
- /* wait for the write to be done */
- if (shm)
- XSync(d, False);
- __imlib_ConsumeXImage(d, xim);
- if (m)
- __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)
-{
- 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 ((dx2 < 0) || (dy2 < 0))
- return;
-
- dw = dx2 - dx1;
- dh = dy2 - dy1;
-
- if ((dw <= 0) || (dh <= 0))
- return;
-
- if (dx1 < 0)
- {
- dw += dx1;
- dx1 = 0;
- }
- if (dy1 < 0)
- {
- dh += dy1;
- dy1 = 0;
- }
-
- ct = __imlib_GetContext(d, v, cm, depth);
-
- back = __imlib_CreateImage(dw, dh, NULL);
- 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);
-
- __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);
-
- __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);
- __imlib_FreeImage(back);
-}
diff --git a/src/rend.h b/src/rend.h
deleted file mode 100644
index 734400f..0000000
--- a/src/rend.h
+++ /dev/null
@@ -1,25 +0,0 @@
-#ifndef __REND
-#define __REND 1
-
-DATA32
-__imlib_RenderGetPixel(Display *d, Drawable w, Visual *v, Colormap cm, int depth, DATA8 r, DATA8 g, DATA8 b);
-
-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 anitalias, char hiq, char blend, char dither_mask,
- ImlibColorModifier *cmod, ImlibOp op);
-
-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);
-
-#endif
diff --git a/src/rgba.c b/src/rgba.c
deleted file mode 100644
index 7fb651b..0000000
--- a/src/rgba.c
+++ /dev/null
@@ -1,4966 +0,0 @@
-
-#include "common.h"
-#ifndef X_DISPLAY_MISSING
-#include <X11/Xlib.h>
-#include "context.h"
-#endif
-#include "rgba.h"
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#define IS_ALIGNED_64(val) (!((val) & 0x7))
-#define IS_ALIGNED_32(val) (!((val) & 0x3))
-#define IS_ALIGNED_16(val) (!((val) & 0x1))
-
-#define IS_MULTIPLE_2(val) (!((val) & 0x1))
-#define IS_MULTIPLE_4(val) (!((val) & 0x3))
-
-/* for PPC / Motorola / SPARC, not x86, ALPHA */
-/* dont uncomment this - i have this here for my own testing */
-/*#define WORDS_BIGENDIAN*/
-/* for data in ABGR memory model */
-
-/* NOTES: */
-/* 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;
-
-/* 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];
-
-/* 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_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}
-};
-
-/*****************************************************************************/
-/* Actual rendering routines */
-/* RGBA -> RGB565 */
-/*****************************************************************************/
-
-/*****************************************************************************/
-/* MACROS for plain RGBA -> RGB565 conversion */
-#define WRITE1_RGBA_RGB565(src, dest) \
-*dest = ((*src >> 8) & 0xf800) | \
- ((*src >> 5) & 0x7e0) | \
- ((*src >> 3) & 0x1f); dest++; src++
-#ifdef WORDS_BIGENDIAN
-#define WRITE2_RGBA_RGB565(src, dest) \
-{ \
- *((DATA32 *)dest) = ((src[1] >> 8) & 0xf800) | \
- ((src[1] >> 5) & 0x7e0) | \
- ((src[1] >> 3) & 0x1f) | \
- ((src[0] << 8) & 0xf8000000) | \
- ((src[0] << 11) & 0x7e00000) | \
- ((src[0] << 13) & 0x1f0000); \
- dest += 2; src += 2; \
-}
-#else
-#define WRITE2_RGBA_RGB565(src, dest) \
-{ \
- *((DATA32 *)dest) = ((src[0] >> 8) & 0xf800) | \
- ((src[0] >> 5) & 0x7e0) | \
- ((src[0] >> 3) & 0x1f) | \
- ((src[1] << 8) & 0xf8000000) | \
- ((src[1] << 11) & 0x7e00000) | \
- ((src[1] << 13) & 0x1f0000); \
- dest += 2; src += 2; \
-}
-#endif
-/*****************************************************************************/
-/* MACROS for dithered RGBA -> RGB565 conversion */
-#define DITHER_RGBA_565_LUT_R(num) \
-(_dither_r16[(((x + num) & 0x3) << 10) | ((y & 0x3) << 8) | ((src[num] >> 16 ) & 0xff)])
-#define DITHER_RGBA_565_LUT_G(num) \
-(_dither_g16[(((x + num) & 0x3) << 10) | ((y & 0x3) << 8) | ((src[num] >> 8 ) & 0xff)])
-#define DITHER_RGBA_565_LUT_B(num) \
-(_dither_b16[(((x + num) & 0x3) << 10) | ((y & 0x3) << 8) | ((src[num] >> 0 ) & 0xff)])
-
-#define WRITE1_RGBA_RGB565_DITHER(src, dest) \
-*dest = (DITHER_RGBA_565_LUT_R(0)) | \
- (DITHER_RGBA_565_LUT_G(0)) | \
- (DITHER_RGBA_565_LUT_B(0)); dest++; src++
-#ifdef WORDS_BIGENDIAN
-#define WRITE2_RGBA_RGB565_DITHER(src, dest) \
-{ \
- *((DATA32 *)dest) = ((DITHER_RGBA_565_LUT_R(1))) | \
- ((DITHER_RGBA_565_LUT_G(1))) | \
- ((DITHER_RGBA_565_LUT_B(1))) | \
- ((DITHER_RGBA_565_LUT_R(0) << 16)) | \
- ((DITHER_RGBA_565_LUT_G(0) << 16)) | \
- ((DITHER_RGBA_565_LUT_B(0) << 16)); \
- dest += 2; src += 2; \
-}
-#else
-#define WRITE2_RGBA_RGB565_DITHER(src, dest) \
-{ \
- *((DATA32 *)dest) = ((DITHER_RGBA_565_LUT_R(0))) | \
- ((DITHER_RGBA_565_LUT_G(0))) | \
- ((DITHER_RGBA_565_LUT_B(0))) | \
- ((DITHER_RGBA_565_LUT_R(1) << 16)) | \
- ((DITHER_RGBA_565_LUT_G(1) << 16)) | \
- ((DITHER_RGBA_565_LUT_B(1) << 16)); \
- dest += 2; src += 2; \
-}
-#endif
-/*****************************************************************************/
-/* MACROS for plain RGBA -> BGR565 conversion */
-#define WRITE1_RGBA_BGR565(src, dest) \
-*dest = ((*src << 8) & 0xf800) | \
- ((*src >> 5) & 0x7e0) | \
- ((*src >> 19)& 0x1f); dest++; src++
-#ifdef WORDS_BIGENDIAN
-#define WRITE2_RGBA_BGR565(src, dest) \
-{ \
- *((DATA32 *)dest) = ((src[1] << 8) & 0xf800) | \
- ((src[1] >> 5) & 0x7e0) | \
- ((src[1] >> 19)& 0x1f) | \
- ((src[0] << 24) & 0xf8000000) | \
- ((src[0] << 11) & 0x7e00000) | \
- ((src[0] >> 3) & 0x1f0000); \
- dest += 2; src += 2; \
-}
-#else
-#define WRITE2_RGBA_BGR565(src, dest) \
-{ \
- *((DATA32 *)dest) = ((src[0] << 8) & 0xf800) | \
- ((src[0] >> 5) & 0x7e0) | \
- ((src[0] >> 19)& 0x1f) | \
- ((src[1] << 24) & 0xf8000000) | \
- ((src[1] << 11) & 0x7e00000) | \
- ((src[1] >> 3) & 0x1f0000); \
- dest += 2; src += 2; \
-}
-#endif
-/*****************************************************************************/
-/* MACROS for dithered RGBA -> BGR565 conversion */
-#define DITHER_RGBA_BGR565_LUT_R(num) \
-(_dither_r16[(((x + num) & 0x3) << 10) | ((y & 0x3) << 8) | ((src[num] >> 0 ) & 0xff)])
-#define DITHER_RGBA_BGR565_LUT_G(num) \
-(_dither_g16[(((x + num) & 0x3) << 10) | ((y & 0x3) << 8) | ((src[num] >> 8 ) & 0xff)])
-#define DITHER_RGBA_BGR565_LUT_B(num) \
-(_dither_b16[(((x + num) & 0x3) << 10) | ((y & 0x3) << 8) | ((src[num] >> 16) & 0xff)])
-
-#define WRITE1_RGBA_BGR565_DITHER(src, dest) \
-*dest = (DITHER_RGBA_BGR565_LUT_R(0)) | \
- (DITHER_RGBA_BGR565_LUT_G(0)) | \
- (DITHER_RGBA_BGR565_LUT_B(0)); dest++; src++
-#ifdef WORDS_BIGENDIAN
-#define WRITE2_RGBA_BGR565_DITHER(src, dest) \
-{ \
- *((DATA32 *)dest) = ((DITHER_RGBA_BGR565_LUT_R(1))) | \
- ((DITHER_RGBA_BGR565_LUT_G(1))) | \
- ((DITHER_RGBA_BGR565_LUT_B(1))) | \
- ((DITHER_RGBA_BGR565_LUT_R(0) << 16)) | \
- ((DITHER_RGBA_BGR565_LUT_G(0) << 16)) | \
- ((DITHER_RGBA_BGR565_LUT_B(0) << 16)); \
- dest += 2; src += 2; \
-}
-#else
-#define WRITE2_RGBA_BGR565_DITHER(src, dest) \
-{ \
- *((DATA32 *)dest) = ((DITHER_RGBA_BGR565_LUT_R(0))) | \
- ((DITHER_RGBA_BGR565_LUT_G(0))) | \
- ((DITHER_RGBA_BGR565_LUT_B(0))) | \
- ((DITHER_RGBA_BGR565_LUT_R(1) << 16)) | \
- ((DITHER_RGBA_BGR565_LUT_G(1) << 16)) | \
- ((DITHER_RGBA_BGR565_LUT_B(1) << 16)); \
- dest += 2; src += 2; \
-}
-#endif
-
-/*****************************************************************************/
-/* Actual rendering routines */
-/* RGBA -> RGB555 */
-/*****************************************************************************/
-
-/*****************************************************************************/
-/* MACROS for plain RGBA -> RGB555 conversion */
-#define WRITE1_RGBA_RGB555(src, dest) \
-*dest = ((*src >> 9) & 0x7c00) | \
- ((*src >> 6) & 0x3e0) | \
- ((*src >> 3) & 0x1f); dest++; src++
-#ifdef WORDS_BIGENDIAN
-#define WRITE2_RGBA_RGB555(src, dest) \
-{ \
- *((DATA32 *)dest) = ((src[1] >> 9) & 0x7c00) | \
- ((src[1] >> 6) & 0x3e0) | \
- ((src[1] >> 3) & 0x1f) | \
- ((src[0] << 7) & 0x7c000000) | \
- ((src[0] << 10) & 0x3e00000) | \
- ((src[0] << 13) & 0x1f0000); \
- dest += 2; src += 2; \
-}
-#else
-#define WRITE2_RGBA_RGB555(src, dest) \
-{ \
- *((DATA32 *)dest) = ((src[0] >> 9) & 0x7c00) | \
- ((src[0] >> 6) & 0x3e0) | \
- ((src[0] >> 3) & 0x1f) | \
- ((src[1] << 7) & 0x7c000000) | \
- ((src[1] << 10) & 0x3e00000) | \
- ((src[1] << 13) & 0x1f0000); \
- dest += 2; src += 2; \
-}
-#endif
-/*****************************************************************************/
-/* MACROS for dithered RGBA -> RGB555 conversion */
-#define DITHER_RGBA_555_LUT_R(num) \
-(_dither_r16[(((x + num) & 0x3) << 10) | ((y & 0x3) << 8) | ((src[num] >> 16 ) & 0xff)])
-#define DITHER_RGBA_555_LUT_G(num) \
-(_dither_g16[(((x + num) & 0x3) << 10) | ((y & 0x3) << 8) | ((src[num] >> 8 ) & 0xff)])
-#define DITHER_RGBA_555_LUT_B(num) \
-(_dither_b16[(((x + num) & 0x3) << 10) | ((y & 0x3) << 8) | ((src[num] >> 0 ) & 0xff)])
-
-#define WRITE1_RGBA_RGB555_DITHER(src, dest) \
-*dest = (DITHER_RGBA_555_LUT_R(0)) | \
- (DITHER_RGBA_555_LUT_G(0)) | \
- (DITHER_RGBA_555_LUT_B(0)); dest++; src++
-#ifdef WORDS_BIGENDIAN
-#define WRITE2_RGBA_RGB555_DITHER(src, dest) \
-{ \
- *((DATA32 *)dest) = ((DITHER_RGBA_555_LUT_R(1))) | \
- ((DITHER_RGBA_555_LUT_G(1))) | \
- ((DITHER_RGBA_555_LUT_B(1))) | \
- ((DITHER_RGBA_555_LUT_R(0) << 16)) | \
- ((DITHER_RGBA_555_LUT_G(0) << 16)) | \
- ((DITHER_RGBA_555_LUT_B(0) << 16)); \
- dest += 2; src += 2; \
-}
-#else
-#define WRITE2_RGBA_RGB555_DITHER(src, dest) \
-{ \
- *((DATA32 *)dest) = ((DITHER_RGBA_555_LUT_R(0))) | \
- ((DITHER_RGBA_555_LUT_G(0))) | \
- ((DITHER_RGBA_555_LUT_B(0))) | \
- ((DITHER_RGBA_555_LUT_R(1) << 16)) | \
- ((DITHER_RGBA_555_LUT_G(1) << 16)) | \
- ((DITHER_RGBA_555_LUT_B(1) << 16)); \
- dest += 2; src += 2; \
-}
-#endif
-
-/*****************************************************************************/
-/* MACROS for plain RGBA -> BGR555 conversion */
-#define WRITE1_RGBA_BGR555(src, dest) \
-*dest = ((*src << 7) & 0x7c00) | \
- ((*src >> 6) & 0x3e0) | \
- ((*src >> 19)& 0x1f); dest++; src++
-#ifdef WORDS_BIGENDIAN
-#define WRITE2_RGBA_BGR555(src, dest) \
-{ \
- *((DATA32 *)dest) = ((src[1] << 7) & 0x7c00) | \
- ((src[1] >> 6) & 0x3e0) | \
- ((src[1] >> 19)& 0x1f) | \
- ((src[0] << 23) & 0x7c000000) | \
- ((src[0] << 10) & 0x3e00000) | \
- ((src[0] >> 3) & 0x1f0000); \
- dest += 2; src += 2; \
-}
-#else
-#define WRITE2_RGBA_BGR555(src, dest) \
-{ \
- *((DATA32 *)dest) = ((src[0] << 7) & 0x7c00) | \
- ((src[0] >> 6) & 0x3e0) | \
- ((src[0] >> 19)& 0x1f) | \
- ((src[1] << 23) & 0x7c000000) | \
- ((src[1] << 10) & 0x3e00000) | \
- ((src[1] >> 3) & 0x1f0000); \
- dest += 2; src += 2; \
-}
-#endif
-/*****************************************************************************/
-/* MACROS for dithered RGBA -> BGR555 conversion */
-#define DITHER_RGBA_BGR555_LUT_R(num) \
-(_dither_r16[(((x + num) & 0x3) << 10) | ((y & 0x3) << 8) | ((src[num] >> 0 ) & 0xff)])
-#define DITHER_RGBA_BGR555_LUT_G(num) \
-(_dither_g16[(((x + num) & 0x3) << 10) | ((y & 0x3) << 8) | ((src[num] >> 8 ) & 0xff)])
-#define DITHER_RGBA_BGR555_LUT_B(num) \
-(_dither_b16[(((x + num) & 0x3) << 10) | ((y & 0x3) << 8) | ((src[num] >> 16 ) & 0xff)])
-
-#define WRITE1_RGBA_BGR555_DITHER(src, dest) \
-*dest = (DITHER_RGBA_BGR555_LUT_R(0)) | \
- (DITHER_RGBA_BGR555_LUT_G(0)) | \
- (DITHER_RGBA_BGR555_LUT_B(0)); dest++; src++
-#ifdef WORDS_BIGENDIAN
-#define WRITE2_RGBA_BGR555_DITHER(src, dest) \
-{ \
- *((DATA32 *)dest) = ((DITHER_RGBA_BGR555_LUT_R(1))) | \
- ((DITHER_RGBA_BGR555_LUT_G(1))) | \
- ((DITHER_RGBA_BGR555_LUT_B(1))) | \
- ((DITHER_RGBA_BGR555_LUT_R(0) << 16)) | \
- ((DITHER_RGBA_BGR555_LUT_G(0) << 16)) | \
- ((DITHER_RGBA_BGR555_LUT_B(0) << 16)); \
- dest += 2; src += 2; \
-}
-#else
-#define WRITE2_RGBA_BGR555_DITHER(src, dest) \
-{ \
- *((DATA32 *)dest) = ((DITHER_RGBA_BGR555_LUT_R(0))) | \
- ((DITHER_RGBA_BGR555_LUT_G(0))) | \
- ((DITHER_RGBA_BGR555_LUT_B(0))) | \
- ((DITHER_RGBA_BGR555_LUT_R(1) << 16)) | \
- ((DITHER_RGBA_BGR555_LUT_G(1) << 16)) | \
- ((DITHER_RGBA_BGR555_LUT_B(1) << 16)); \
- dest += 2; src += 2; \
-}
-#endif
-
-/*****************************************************************************/
-/* Actual rendering routines */
-/* RGBA -> RGB332 */
-/*****************************************************************************/
-
-/*****************************************************************************/
-/* MACROS for plain RGBA -> RGB332 conversion */
-#define WRITE1_RGBA_RGB332(src, dest) \
-*dest = _dither_color_lut[((*src >> 6) & 0x03) | \
- ((*src >> 11) & 0x1c) | \
- ((*src >> 16) & 0xe0)]; dest++; src++
-#ifdef WORDS_BIGENDIAN
-#define WRITE2_RGBA_RGB332(src, dest) \
-{ \
- *((DATA16 *)dest) = (_dither_color_lut[((src[1] >> 6) & 0x03) | \
- ((src[1] >> 11) & 0x1c) | \
- ((src[1] >> 16) & 0xe0)]) | \
- (_dither_color_lut[((src[0] >> 6) & 0x03) | \
- ((src[0] >> 11) & 0x1c) | \
- ((src[0] >> 16) & 0xe0)] << 8); \
- dest += 2; src += 2; \
-}
-#define WRITE4_RGBA_RGB332(src, dest) \
-{ \
- *((DATA32 *)dest) = (_dither_color_lut[((src[3] >> 6) & 0x03) | \
- ((src[3] >> 11) & 0x1c) | \
- ((src[3] >> 16) & 0xe0)]) | \
- (_dither_color_lut[((src[2] >> 6) & 0x03) | \
- ((src[2] >> 11) & 0x1c) | \
- ((src[2] >> 16) & 0xe0)] << 8) | \
- (_dither_color_lut[((src[1] >> 6) & 0x03) | \
- ((src[1] >> 11) & 0x1c) | \
- ((src[1] >> 16) & 0xe0)] << 16) | \
- (_dither_color_lut[((src[0] >> 6) & 0x03) | \
- ((src[0] >> 11) & 0x1c) | \
- ((src[0] >> 16) & 0xe0)] << 24); \
- dest += 4; src += 4; \
-}
-#else
-#define WRITE2_RGBA_RGB332(src, dest) \
-{ \
- *((DATA16 *)dest) = (_dither_color_lut[((src[0] >> 6) & 0x03) | \
- ((src[0] >> 11) & 0x1c) | \
- ((src[0] >> 16) & 0xe0)]) | \
- (_dither_color_lut[((src[1] >> 6) & 0x03) | \
- ((src[1] >> 11) & 0x1c) | \
- ((src[1] >> 16) & 0xe0)] << 8); \
- dest += 2; src += 2; \
-}
-#define WRITE4_RGBA_RGB332(src, dest) \
-{ \
- *((DATA32 *)dest) = (_dither_color_lut[((src[0] >> 6) & 0x03) | \
- ((src[0] >> 11) & 0x1c) | \
- ((src[0] >> 16) & 0xe0)]) | \
- (_dither_color_lut[((src[1] >> 6) & 0x03) | \
- ((src[1] >> 11) & 0x1c) | \
- ((src[1] >> 16) & 0xe0)] << 8) | \
- (_dither_color_lut[((src[2] >> 6) & 0x03) | \
- ((src[2] >> 11) & 0x1c) | \
- ((src[2] >> 16) & 0xe0)] << 16) | \
- (_dither_color_lut[((src[3] >> 6) & 0x03) | \
- ((src[3] >> 11) & 0x1c) | \
- ((src[3] >> 16) & 0xe0)] << 24); \
- dest += 4; src += 4; \
-}
-#endif
-/*****************************************************************************/
-/* MACROS for dithered RGBA -> RGB332 conversion */
-#define DITHER_RGBA_332_LUT_R(num) \
-(_dither_r8[(((x + num) & 0x7) << DM_BS1) | ((y & 0x7) << DM_BS2) | ((src[num] >> 16) & 0xff)])
-#define DITHER_RGBA_332_LUT_G(num) \
-(_dither_g8[(((x + num) & 0x7) << DM_BS1) | ((y & 0x7) << DM_BS2) | ((src[num] >> 8) & 0xff)])
-#define DITHER_RGBA_332_LUT_B(num) \
-(_dither_b8[(((x + num) & 0x7) << DM_BS1) | ((y & 0x7) << DM_BS2) | ((src[num] >> 0) & 0xff)])
-
-#define WRITE1_RGBA_RGB332_DITHER(src, dest) \
-*dest = _dither_color_lut[(DITHER_RGBA_332_LUT_R(0)) | \
- (DITHER_RGBA_332_LUT_G(0)) | \
- (DITHER_RGBA_332_LUT_B(0))]; dest++; src++
-#ifdef WORDS_BIGENDIAN
-#define WRITE4_RGBA_RGB332_DITHER(src, dest) \
-{ \
- *((DATA32 *)dest) = (_dither_color_lut[((DITHER_RGBA_332_LUT_R(3))) | \
- ((DITHER_RGBA_332_LUT_G(3))) | \
- ((DITHER_RGBA_332_LUT_B(3)))]) | \
- (_dither_color_lut[((DITHER_RGBA_332_LUT_R(2))) | \
- ((DITHER_RGBA_332_LUT_G(2))) | \
- ((DITHER_RGBA_332_LUT_B(2)))] << 8) | \
- (_dither_color_lut[((DITHER_RGBA_332_LUT_R(1))) | \
- ((DITHER_RGBA_332_LUT_G(1))) | \
- ((DITHER_RGBA_332_LUT_B(1)))] << 16) | \
- (_dither_color_lut[((DITHER_RGBA_332_LUT_R(0))) | \
- ((DITHER_RGBA_332_LUT_G(0))) | \
- ((DITHER_RGBA_332_LUT_B(0)))] << 24); \
- dest += 4; src += 4; \
-}
-#define WRITE2_RGBA_RGB332_DITHER(src, dest) \
-{ \
- *((DATA32 *)dest) = (_dither_color_lut[((DITHER_RGBA_332_LUT_R(1))) | \
- ((DITHER_RGBA_332_LUT_G(1))) | \
- ((DITHER_RGBA_332_LUT_B(1)))]) | \
- (_dither_color_lut[((DITHER_RGBA_332_LUT_R(0))) | \
- ((DITHER_RGBA_332_LUT_G(0))) | \
- ((DITHER_RGBA_332_LUT_B(0)))] << 8); \
- dest += 2; src += 2; \
-}
-#else
-#define WRITE4_RGBA_RGB332_DITHER(src, dest) \
-{ \
- *((DATA32 *)dest) = (_dither_color_lut[((DITHER_RGBA_332_LUT_R(0))) | \
- ((DITHER_RGBA_332_LUT_G(0))) | \
- ((DITHER_RGBA_332_LUT_B(0)))]) | \
- (_dither_color_lut[((DITHER_RGBA_332_LUT_R(1))) | \
- ((DITHER_RGBA_332_LUT_G(1))) | \
- ((DITHER_RGBA_332_LUT_B(1)))] << 8) | \
- (_dither_color_lut[((DITHER_RGBA_332_LUT_R(2))) | \
- ((DITHER_RGBA_332_LUT_G(2))) | \
- ((DITHER_RGBA_332_LUT_B(2)))] << 16) | \
- (_dither_color_lut[((DITHER_RGBA_332_LUT_R(3))) | \
- ((DITHER_RGBA_332_LUT_G(3))) | \
- ((DITHER_RGBA_332_LUT_B(3)))] << 24); \
- dest += 4; src += 4; \
-}
-#define WRITE2_RGBA_RGB332_DITHER(src, dest) \
-{ \
- *((DATA32 *)dest) = (_dither_color_lut[((DITHER_RGBA_332_LUT_R(0))) | \
- ((DITHER_RGBA_332_LUT_G(0))) | \
- ((DITHER_RGBA_332_LUT_B(0)))]) | \
- (_dither_color_lut[((DITHER_RGBA_332_LUT_R(1))) | \
- ((DITHER_RGBA_332_LUT_G(1))) | \
- ((DITHER_RGBA_332_LUT_B(1)))] << 8); \
- dest += 2; src += 2; \
-}
-#endif
-
-/*****************************************************************************/
-/* Actual rendering routines */
-/* RGBA -> RGB666 */
-/*****************************************************************************/
-
-/*****************************************************************************/
-/* MACROS for plain RGBA -> RGB666 conversion */
-#define WRITE1_RGBA_RGB666(src, dest) \
-{ \
-*dest = _dither_color_lut[(_dither_666r[(*src >> 16) & 0xff] ) + \
- (_dither_666g[(*src >> 8 ) & 0xff] ) + \
- (_dither_666b[(*src ) & 0xff] )]; dest++; src++; \
-}
-#ifdef WORDS_BIGENDIAN
-#define WRITE2_RGBA_RGB666(src, dest) \
-{ \
- *((DATA32 *)dest) = (_dither_color_lut[(_dither_666r[(src[1] >> 16) & 0xff] ) + \
- (_dither_666g[(src[1] >> 8 ) & 0xff] ) + \
- (_dither_666b[(src[1] ) & 0xff] )]) | \
- (_dither_color_lut[(_dither_666r[(src[0] >> 16) & 0xff] ) + \
- (_dither_666g[(src[0] >> 8 ) & 0xff] ) + \
- (_dither_666b[(src[0] ) & 0xff] )] << 8); \
- dest += 2; src += 2; \
-}
-#define WRITE4_RGBA_RGB666(src, dest) \
-{ \
- *((DATA32 *)dest) = (_dither_color_lut[(_dither_666r[(src[3] >> 16) & 0xff] ) + \
- (_dither_666g[(src[3] >> 8 ) & 0xff] ) + \
- (_dither_666b[(src[3] ) & 0xff] )]) | \
- (_dither_color_lut[(_dither_666r[(src[2] >> 16) & 0xff] ) + \
- (_dither_666g[(src[2] >> 8 ) & 0xff] ) + \
- (_dither_666b[(src[2] ) & 0xff] )] << 8) | \
- (_dither_color_lut[(_dither_666r[(src[1] >> 16) & 0xff] ) + \
- (_dither_666g[(src[1] >> 8 ) & 0xff] ) + \
- (_dither_666b[(src[1] ) & 0xff] )] << 16) | \
- (_dither_color_lut[(_dither_666r[(src[0] >> 16) & 0xff] ) + \
- (_dither_666g[(src[0] >> 8 ) & 0xff] ) + \
- (_dither_666b[(src[0] ) & 0xff] )] << 24); \
- dest += 4; src += 4; \
-}
-#else
-#define WRITE2_RGBA_RGB666(src, dest) \
-{ \
- *((DATA32 *)dest) = (_dither_color_lut[(_dither_666r[(src[0] >> 16) & 0xff] ) + \
- (_dither_666g[(src[0] >> 8 ) & 0xff] ) + \
- (_dither_666b[(src[0] ) & 0xff] )]) | \
- (_dither_color_lut[(_dither_666r[(src[1] >> 16) & 0xff] ) + \
- (_dither_666g[(src[1] >> 8 ) & 0xff] ) + \
- (_dither_666b[(src[1] ) & 0xff] )] << 8); \
- dest += 2; src += 2; \
-}
-#define WRITE4_RGBA_RGB666(src, dest) \
-{ \
- *((DATA32 *)dest) = (_dither_color_lut[(_dither_666r[(src[0] >> 16) & 0xff] ) + \
- (_dither_666g[(src[0] >> 8 ) & 0xff] ) + \
- (_dither_666b[(src[0] ) & 0xff] )]) | \
- (_dither_color_lut[(_dither_666r[(src[1] >> 16) & 0xff] ) + \
- (_dither_666g[(src[1] >> 8 ) & 0xff] ) + \
- (_dither_666b[(src[1] ) & 0xff] )] << 8) | \
- (_dither_color_lut[(_dither_666r[(src[2] >> 16) & 0xff] ) + \
- (_dither_666g[(src[2] >> 8 ) & 0xff] ) + \
- (_dither_666b[(src[2] ) & 0xff] )] << 16) | \
- (_dither_color_lut[(_dither_666r[(src[3] >> 16) & 0xff] ) + \
- (_dither_666g[(src[3] >> 8 ) & 0xff] ) + \
- (_dither_666b[(src[3] ) & 0xff] )] << 24); \
- dest += 4; src += 4; \
-}
-#endif
-/*****************************************************************************/
-/* MACROS for dithered RGBA -> RGB666 conversion */
-#define DITHER_RGBA_666_LUT_R(num) \
-(_dither_r8[(((x + num) & 0x7) << DM_BS1) | ((y & 0x7) << DM_BS2) | ((src[num] >> 16) & 0xff)])
-#define DITHER_RGBA_666_LUT_G(num) \
-(_dither_g8[(((x + num) & 0x7) << DM_BS1) | ((y & 0x7) << DM_BS2) | ((src[num] >> 8) & 0xff)])
-#define DITHER_RGBA_666_LUT_B(num) \
-(_dither_b8[(((x + num) & 0x7) << DM_BS1) | ((y & 0x7) << DM_BS2) | ((src[num] >> 0) & 0xff)])
-
-#define WRITE1_RGBA_RGB666_DITHER(src, dest) \
-{ \
-int _dith; \
-int _r[1], _g[1], _b[1]; \
-_dith = (_dither_128128[(x + 0) & 0x7f][y & 0x7f] << 2) | 7; \
-_r[0] = ((((src[0] >> 16) & 0xff) * 5) + _dith) >> 8; \
-_g[0] = ((((src[0] >> 8 ) & 0xff) * 5) + (262 - _dith)) >> 8; \
-_b[0] = ((((src[0] ) & 0xff) * 5) + _dith) >> 8; \
- *((DATA8 *)dest) = \
-(_dither_color_lut[(_r[0] * 36) + (_g[0] * 6) + _b[0]]) \
-; \
-dest += 1; src += 1; \
-}
-#ifdef WORDS_BIGENDIAN
-#define WRITE4_RGBA_RGB666_DITHER(src, dest) \
-{ \
-int _dith; \
-int _r[4], _g[4], _b[4]; \
-_dith = (_dither_128128[(x + 0) & 0x7f][y & 0x7f] << 2) | 7; \
-_r[0] = ((((src[0] >> 16) & 0xff) * 5) + _dith) >> 8; \
-_g[0] = ((((src[0] >> 8 ) & 0xff) * 5) + (262 - _dith)) >> 8; \
-_b[0] = ((((src[0] ) & 0xff) * 5) + _dith) >> 8; \
-_dith = (_dither_128128[(x + 1) & 0x7f][y & 0x7f] << 2) | 7; \
-_r[1] = ((((src[1] >> 16) & 0xff) * 5) + _dith) >> 8; \
-_g[1] = ((((src[1] >> 8 ) & 0xff) * 5) + (262 - _dith)) >> 8; \
-_b[1] = ((((src[1] ) & 0xff) * 5) + _dith) >> 8; \
-_dith = (_dither_128128[(x + 2) & 0x7f][y & 0x7f] << 2) | 7; \
-_r[2] = ((((src[2] >> 16) & 0xff) * 5) + _dith) >> 8; \
-_g[2] = ((((src[2] >> 8 ) & 0xff) * 5) + (262 - _dith)) >> 8; \
-_b[2] = ((((src[2] ) & 0xff) * 5) + _dith) >> 8; \
-_dith = (_dither_128128[(x + 3) & 0x7f][y & 0x7f] << 2) | 7; \
-_r[3] = ((((src[3] >> 16) & 0xff) * 5) + _dith) >> 8; \
-_g[3] = ((((src[3] >> 8 ) & 0xff) * 5) + (262 - _dith)) >> 8; \
-_b[3] = ((((src[3] ) & 0xff) * 5) + _dith) >> 8; \
- *((DATA32 *)dest) = \
-(_dither_color_lut[(_r[3] * 36) + (_g[3] * 6) + _b[3]]) | \
-(_dither_color_lut[(_r[2] * 36) + (_g[2] * 6) + _b[2]] << 8) | \
-(_dither_color_lut[(_r[1] * 36) + (_g[1] * 6) + _b[1]] << 16) | \
-(_dither_color_lut[(_r[0] * 36) + (_g[0] * 6) + _b[0]] << 24) \
-; \
-dest += 4; src += 4; \
-}
-#define WRITE2_RGBA_RGB666_DITHER(src, dest) \
-{ \
-int _dith; \
-int _r[2], _g[2], _b[2]; \
-_dith = (_dither_128128[(x + 0) & 0x7f][y & 0x7f] << 2) | 7; \
-_r[0] = ((((src[0] >> 16) & 0xff) * 5) + _dith) >> 8; \
-_g[0] = ((((src[0] >> 8 ) & 0xff) * 5) + (262 - _dith)) >> 8; \
-_b[0] = ((((src[0] ) & 0xff) * 5) + _dith) >> 8; \
-_dith = (_dither_128128[(x + 1) & 0x7f][y & 0x7f] << 2) | 7; \
-_r[1] = ((((src[1] >> 16) & 0xff) * 5) + _dith) >> 8; \
-_g[1] = ((((src[1] >> 8 ) & 0xff) * 5) + (262 - _dith)) >> 8; \
-_b[1] = ((((src[1] ) & 0xff) * 5) + _dith) >> 8; \
- *((DATA16 *)dest) = \
-(_dither_color_lut[(_r[1] * 36) + (_g[1] * 6) + _b[1]]) | \
-(_dither_color_lut[(_r[0] * 36) + (_g[0] * 6) + _b[0]] << 8) \
-; \
-dest += 2; src += 2; \
-}
-#else
-#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))) + \
- ((DITHER_RGBA_666_LUT_G(0))) + \
- ((DITHER_RGBA_666_LUT_B(0)))]) | \
- (_dither_color_lut[((DITHER_RGBA_666_LUT_R(1))) + \
- ((DITHER_RGBA_666_LUT_G(1))) + \
- ((DITHER_RGBA_666_LUT_B(1)))] << 8) | \
- (_dither_color_lut[((DITHER_RGBA_666_LUT_R(2))) + \
- ((DITHER_RGBA_666_LUT_G(2))) + \
- ((DITHER_RGBA_666_LUT_B(2)))] << 16) | \
- (_dither_color_lut[((DITHER_RGBA_666_LUT_R(3))) + \
- ((DITHER_RGBA_666_LUT_G(3))) + \
- ((DITHER_RGBA_666_LUT_B(3)))] << 24); \
- dest += 4; src += 4; \
-}
-#define WRITE2_RGBA_RGB666_DITHER(src, dest) \
-{ \
- *((DATA16 *)dest) = (_dither_color_lut[((DITHER_RGBA_666_LUT_R(0))) + \
- ((DITHER_RGBA_666_LUT_G(0))) + \
- ((DITHER_RGBA_666_LUT_B(0)))]) | \
- (_dither_color_lut[((DITHER_RGBA_666_LUT_R(1))) + \
- ((DITHER_RGBA_666_LUT_G(1))) + \
- ((DITHER_RGBA_666_LUT_B(1)))] << 8); \
- dest += 2; src += 2; \
-}
-#else
-#define WRITE4_RGBA_RGB666_DITHER(src, dest) \
-{ \
-int _dith; \
-int _r[4], _g[4], _b[4]; \
-_dith = (_dither_128128[(x + 0) & 0x7f][y & 0x7f] << 2) | 7; \
-_r[0] = ((((src[0] >> 16) & 0xff) * 5) + _dith) >> 8; \
-_g[0] = ((((src[0] >> 8 ) & 0xff) * 5) + (262 - _dith)) >> 8; \
-_b[0] = ((((src[0] ) & 0xff) * 5) + _dith) >> 8; \
-_dith = (_dither_128128[(x + 1) & 0x7f][y & 0x7f] << 2) | 7; \
-_r[1] = ((((src[1] >> 16) & 0xff) * 5) + _dith) >> 8; \
-_g[1] = ((((src[1] >> 8 ) & 0xff) * 5) + (262 - _dith)) >> 8; \
-_b[1] = ((((src[1] ) & 0xff) * 5) + _dith) >> 8; \
-_dith = (_dither_128128[(x + 2) & 0x7f][y & 0x7f] << 2) | 7; \
-_r[2] = ((((src[2] >> 16) & 0xff) * 5) + _dith) >> 8; \
-_g[2] = ((((src[2] >> 8 ) & 0xff) * 5) + (262 - _dith)) >> 8; \
-_b[2] = ((((src[2] ) & 0xff) * 5) + _dith) >> 8; \
-_dith = (_dither_128128[(x + 3) & 0x7f][y & 0x7f] << 2) | 7; \
-_r[3] = ((((src[3] >> 16) & 0xff) * 5) + _dith) >> 8; \
-_g[3] = ((((src[3] >> 8 ) & 0xff) * 5) + (262 - _dith)) >> 8; \
-_b[3] = ((((src[3] ) & 0xff) * 5) + _dith) >> 8; \
- *((DATA32 *)dest) = \
-(_dither_color_lut[(_r[0] * 36) + (_g[0] * 6) + _b[0]]) | \
-(_dither_color_lut[(_r[1] * 36) + (_g[1] * 6) + _b[1]] << 8) | \
-(_dither_color_lut[(_r[2] * 36) + (_g[2] * 6) + _b[2]] << 16) | \
-(_dither_color_lut[(_r[3] * 36) + (_g[3] * 6) + _b[3]] << 24) \
-; \
-dest += 4; src += 4; \
-}
-#define WRITE2_RGBA_RGB666_DITHER(src, dest) \
-{ \
-int _dith; \
-int _r[2], _g[2], _b[2]; \
-_dith = (_dither_128128[(x + 0) & 0x7f][y & 0x7f] << 2) | 7; \
-_r[0] = ((((src[0] >> 16) & 0xff) * 5) + _dith) >> 8; \
-_g[0] = ((((src[0] >> 8 ) & 0xff) * 5) + (262 - _dith)) >> 8; \
-_b[0] = ((((src[0] ) & 0xff) * 5) + _dith) >> 8; \
-_dith = (_dither_128128[(x + 1) & 0x7f][y & 0x7f] << 2) | 7; \
-_r[1] = ((((src[1] >> 16) & 0xff) * 5) + _dith) >> 8; \
-_g[1] = ((((src[1] >> 8 ) & 0xff) * 5) + (262 - _dith)) >> 8; \
-_b[1] = ((((src[1] ) & 0xff) * 5) + _dith) >> 8; \
- *((DATA16 *)dest) = \
-(_dither_color_lut[(_r[0] * 36) + (_g[0] * 6) + _b[0]]) | \
-(_dither_color_lut[(_r[1] * 36) + (_g[1] * 6) + _b[1]] << 8) \
-; \
-dest += 2; src += 2; \
-}
-#endif
-#endif
-
-/*****************************************************************************/
-/* Actual rendering routines */
-/* RGBA -> RGB232 */
-/*****************************************************************************/
-
-/*****************************************************************************/
-/* MACROS for plain RGBA -> RGB232 conversion */
-#define RGB232_BSHIFT >> 6
-#define RGB232_GSHIFT >> 11
-#define RGB232_RSHIFT >> 17
-#define RGB232_BMASK & 0x03
-#define RGB232_GMASK & 0x1c
-#define RGB232_RMASK & 0x60
-
-#define WRITE1_RGBA_RGB232(src, dest) \
-*dest = _dither_color_lut[((*src RGB232_BSHIFT) RGB232_BMASK) | \
- ((*src RGB232_GSHIFT) RGB232_GMASK) | \
- ((*src RGB232_RSHIFT) RGB232_RMASK)]; dest++; src++
-#ifdef WORDS_BIGENDIAN
-#define WRITE2_RGBA_RGB232(src, dest) \
-{ \
- *((DATA16 *)dest) = (_dither_color_lut[((src[1] RGB232_BSHIFT) RGB232_BMASK) | \
- ((src[1] RGB232_GSHIFT) RGB232_GMASK) | \
- ((src[1] RGB232_RSHIFT) RGB232_RMASK)]) | \
- (_dither_color_lut[((src[0] RGB232_BSHIFT) RGB232_BMASK) | \
- ((src[0] RGB232_GSHIFT) RGB232_GMASK) | \
- ((src[0] RGB232_RSHIFT) RGB232_RMASK)] << 8); \
- dest += 2; src += 2; \
-}
-#define WRITE4_RGBA_RGB232(src, dest) \
-{ \
- *((DATA32 *)dest) = (_dither_color_lut[((src[3] RGB232_BSHIFT) RGB232_BMASK) | \
- ((src[3] RGB232_GSHIFT) RGB232_GMASK) | \
- ((src[3] RGB232_RSHIFT) RGB232_RMASK)]) | \
- (_dither_color_lut[((src[2] RGB232_BSHIFT) RGB232_BMASK) | \
- ((src[2] RGB232_GSHIFT) RGB232_GMASK) | \
- ((src[2] RGB232_RSHIFT) RGB232_RMASK)] << 8) | \
- (_dither_color_lut[((src[1] RGB232_BSHIFT) RGB232_BMASK) | \
- ((src[1] RGB232_GSHIFT) RGB232_GMASK) | \
- ((src[1] RGB232_RSHIFT) RGB232_RMASK)] << 16) | \
- (_dither_color_lut[((src[0] RGB232_BSHIFT) RGB232_BMASK) | \
- ((src[0] RGB232_GSHIFT) RGB232_GMASK) | \
- ((src[0] RGB232_RSHIFT) RGB232_RMASK)] << 24); \
- dest += 4; src += 4; \
-}
-#else
-#define WRITE2_RGBA_RGB232(src, dest) \
-{ \
- *((DATA16 *)dest) = (_dither_color_lut[((src[0] RGB232_BSHIFT) RGB232_BMASK) | \
- ((src[0] RGB232_GSHIFT) RGB232_GMASK) | \
- ((src[0] RGB232_RSHIFT) RGB232_RMASK)]) | \
- (_dither_color_lut[((src[1] RGB232_BSHIFT) RGB232_BMASK) | \
- ((src[1] RGB232_GSHIFT) RGB232_GMASK) | \
- ((src[1] RGB232_RSHIFT) RGB232_RMASK)] << 8); \
- dest += 2; src += 2; \
-}
-#define WRITE4_RGBA_RGB232(src, dest) \
-{ \
- *((DATA32 *)dest) = (_dither_color_lut[((src[0] RGB232_BSHIFT) RGB232_BMASK) | \
- ((src[0] RGB232_GSHIFT) RGB232_GMASK) | \
- ((src[0] RGB232_RSHIFT) RGB232_RMASK)]) | \
- (_dither_color_lut[((src[1] RGB232_BSHIFT) RGB232_BMASK) | \
- ((src[1] RGB232_GSHIFT) RGB232_GMASK) | \
- ((src[1] RGB232_RSHIFT) RGB232_RMASK)] << 8) | \
- (_dither_color_lut[((src[2] RGB232_BSHIFT) RGB232_BMASK) | \
- ((src[2] RGB232_GSHIFT) RGB232_GMASK) | \
- ((src[2] RGB232_RSHIFT) RGB232_RMASK)] << 16) | \
- (_dither_color_lut[((src[3] RGB232_BSHIFT) RGB232_BMASK) | \
- ((src[3] RGB232_GSHIFT) RGB232_GMASK) | \
- ((src[3] RGB232_RSHIFT) RGB232_RMASK)] << 24); \
- dest += 4; src += 4; \
-}
-#endif
-/*****************************************************************************/
-/* MACROS for dithered RGBA -> RGB232 conversion */
-#define DITHER_RGBA_232_LUT_R(num) \
-(_dither_r8[(((x + num) & 0x7) << DM_BS1) | ((y & 0x7) << DM_BS2) | ((src[num] >> 16) & 0xff)])
-#define DITHER_RGBA_232_LUT_G(num) \
-(_dither_g8[(((x + num) & 0x7) << DM_BS1) | ((y & 0x7) << DM_BS2) | ((src[num] >> 8) & 0xff)])
-#define DITHER_RGBA_232_LUT_B(num) \
-(_dither_b8[(((x + num) & 0x7) << DM_BS1) | ((y & 0x7) << DM_BS2) | ((src[num] >> 0) & 0xff)])
-
-#define WRITE1_RGBA_RGB232_DITHER(src, dest) \
-*dest = _dither_color_lut[(DITHER_RGBA_232_LUT_R(0)) | \
- (DITHER_RGBA_232_LUT_G(0)) | \
- (DITHER_RGBA_232_LUT_B(0))]; dest++; src++
-#ifdef WORDS_BIGENDIAN
-#define WRITE4_RGBA_RGB232_DITHER(src, dest) \
-{ \
- *((DATA32 *)dest) = (_dither_color_lut[((DITHER_RGBA_232_LUT_R(3))) | \
- ((DITHER_RGBA_232_LUT_G(3))) | \
- ((DITHER_RGBA_232_LUT_B(3)))]) | \
- (_dither_color_lut[((DITHER_RGBA_232_LUT_R(2))) | \
- ((DITHER_RGBA_232_LUT_G(2))) | \
- ((DITHER_RGBA_232_LUT_B(2)))] << 8) | \
- (_dither_color_lut[((DITHER_RGBA_232_LUT_R(1))) | \
- ((DITHER_RGBA_232_LUT_G(1))) | \
- ((DITHER_RGBA_232_LUT_B(1)))] << 16) | \
- (_dither_color_lut[((DITHER_RGBA_232_LUT_R(0))) | \
- ((DITHER_RGBA_232_LUT_G(0))) | \
- ((DITHER_RGBA_232_LUT_B(0)))] << 24); \
- dest += 4; src += 4; \
-}
-#define WRITE2_RGBA_RGB232_DITHER(src, dest) \
-{ \
- *((DATA32 *)dest) = (_dither_color_lut[((DITHER_RGBA_232_LUT_R(1))) | \
- ((DITHER_RGBA_232_LUT_G(1))) | \
- ((DITHER_RGBA_232_LUT_B(1)))]) | \
- (_dither_color_lut[((DITHER_RGBA_232_LUT_R(0))) | \
- ((DITHER_RGBA_232_LUT_G(0))) | \
- ((DITHER_RGBA_232_LUT_B(0)))] << 8); \
- dest += 2; src += 2; \
-}
-#else
-#define WRITE4_RGBA_RGB232_DITHER(src, dest) \
-{ \
- *((DATA32 *)dest) = (_dither_color_lut[((DITHER_RGBA_232_LUT_R(0))) | \
- ((DITHER_RGBA_232_LUT_G(0))) | \
- ((DITHER_RGBA_232_LUT_B(0)))]) | \
- (_dither_color_lut[((DITHER_RGBA_232_LUT_R(1))) | \
- ((DITHER_RGBA_232_LUT_G(1))) | \
- ((DITHER_RGBA_232_LUT_B(1)))] << 8) | \
- (_dither_color_lut[((DITHER_RGBA_232_LUT_R(2))) | \
- ((DITHER_RGBA_232_LUT_G(2))) | \
- ((DITHER_RGBA_232_LUT_B(2)))] << 16) | \
- (_dither_color_lut[((DITHER_RGBA_232_LUT_R(3))) | \
- ((DITHER_RGBA_232_LUT_G(3))) | \
- ((DITHER_RGBA_232_LUT_B(3)))] << 24); \
- dest += 4; src += 4; \
-}
-#define WRITE2_RGBA_RGB232_DITHER(src, dest) \
-{ \
- *((DATA32 *)dest) = (_dither_color_lut[((DITHER_RGBA_232_LUT_R(0))) | \
- ((DITHER_RGBA_232_LUT_G(0))) | \
- ((DITHER_RGBA_232_LUT_B(0)))]) | \
- (_dither_color_lut[((DITHER_RGBA_232_LUT_R(1))) | \
- ((DITHER_RGBA_232_LUT_G(1))) | \
- ((DITHER_RGBA_232_LUT_B(1)))] << 8); \
- dest += 2; src += 2; \
-}
-#endif
-
-/*****************************************************************************/
-/* Actual rendering routines */
-/* RGBA -> RGB222 */
-/*****************************************************************************/
-
-/*****************************************************************************/
-/* MACROS for plain RGBA -> RGB222 conversion */
-#define RGB222_BSHIFT >> 6
-#define RGB222_GSHIFT >> 12
-#define RGB222_RSHIFT >> 18
-#define RGB222_BMASK & 0x03
-#define RGB222_GMASK & 0x0c
-#define RGB222_RMASK & 0x30
-
-#define WRITE1_RGBA_RGB222(src, dest) \
-*dest = _dither_color_lut[((*src RGB222_BSHIFT) RGB222_BMASK) | \
- ((*src RGB222_GSHIFT) RGB222_GMASK) | \
- ((*src RGB222_RSHIFT) RGB222_RMASK)]; dest++; src++
-#ifdef WORDS_BIGENDIAN
-#define WRITE2_RGBA_RGB222(src, dest) \
-{ \
- *((DATA16 *)dest) = (_dither_color_lut[((src[1] RGB222_BSHIFT) RGB222_BMASK) | \
- ((src[1] RGB222_GSHIFT) RGB222_GMASK) | \
- ((src[1] RGB222_RSHIFT) RGB222_RMASK)]) | \
- (_dither_color_lut[((src[0] RGB222_BSHIFT) RGB222_BMASK) | \
- ((src[0] RGB222_GSHIFT) RGB222_GMASK) | \
- ((src[0] RGB222_RSHIFT) RGB222_RMASK)] << 8); \
- dest += 2; src += 2; \
-}
-#define WRITE4_RGBA_RGB222(src, dest) \
-{ \
- *((DATA32 *)dest) = (_dither_color_lut[((src[3] RGB222_BSHIFT) RGB222_BMASK) | \
- ((src[3] RGB222_GSHIFT) RGB222_GMASK) | \
- ((src[3] RGB222_RSHIFT) RGB222_RMASK)]) | \
- (_dither_color_lut[((src[2] RGB222_BSHIFT) RGB222_BMASK) | \
- ((src[2] RGB222_GSHIFT) RGB222_GMASK) | \
- ((src[2] RGB222_RSHIFT) RGB222_RMASK)] << 8) | \
- (_dither_color_lut[((src[1] RGB222_BSHIFT) RGB222_BMASK) | \
- ((src[1] RGB222_GSHIFT) RGB222_GMASK) | \
- ((src[1] RGB222_RSHIFT) RGB222_RMASK)] << 16) | \
- (_dither_color_lut[((src[0] RGB222_BSHIFT) RGB222_BMASK) | \
- ((src[0] RGB222_GSHIFT) RGB222_GMASK) | \
- ((src[0] RGB222_RSHIFT) RGB222_RMASK)] << 24); \
- dest += 4; src += 4; \
-}
-#else
-#define WRITE2_RGBA_RGB222(src, dest) \
-{ \
- *((DATA16 *)dest) = (_dither_color_lut[((src[0] RGB222_BSHIFT) RGB222_BMASK) | \
- ((src[0] RGB222_GSHIFT) RGB222_GMASK) | \
- ((src[0] RGB222_RSHIFT) RGB222_RMASK)]) | \
- (_dither_color_lut[((src[1] RGB222_BSHIFT) RGB222_BMASK) | \
- ((src[1] RGB222_GSHIFT) RGB222_GMASK) | \
- ((src[1] RGB222_RSHIFT) RGB222_RMASK)] << 8); \
- dest += 2; src += 2; \
-}
-#define WRITE4_RGBA_RGB222(src, dest) \
-{ \
- *((DATA32 *)dest) = (_dither_color_lut[((src[0] RGB222_BSHIFT) RGB222_BMASK) | \
- ((src[0] RGB222_GSHIFT) RGB222_GMASK) | \
- ((src[0] RGB222_RSHIFT) RGB222_RMASK)]) | \
- (_dither_color_lut[((src[1] RGB222_BSHIFT) RGB222_BMASK) | \
- ((src[1] RGB222_GSHIFT) RGB222_GMASK) | \
- ((src[1] RGB222_RSHIFT) RGB222_RMASK)] << 8) | \
- (_dither_color_lut[((src[2] RGB222_BSHIFT) RGB222_BMASK) | \
- ((src[2] RGB222_GSHIFT) RGB222_GMASK) | \
- ((src[2] RGB222_RSHIFT) RGB222_RMASK)] << 16) | \
- (_dither_color_lut[((src[3] RGB222_BSHIFT) RGB222_BMASK) | \
- ((src[3] RGB222_GSHIFT) RGB222_GMASK) | \
- ((src[3] RGB222_RSHIFT) RGB222_RMASK)] << 24); \
- dest += 4; src += 4; \
-}
-#endif
-/*****************************************************************************/
-/* MACROS for dithered RGBA -> RGB222 conversion */
-#define DITHER_RGBA_222_LUT_R(num) \
-(_dither_r8[(((x + num) & 0x7) << DM_BS1) | ((y & 0x7) << DM_BS2) | ((src[num] >> 16) & 0xff)])
-#define DITHER_RGBA_222_LUT_G(num) \
-(_dither_g8[(((x + num) & 0x7) << DM_BS1) | ((y & 0x7) << DM_BS2) | ((src[num] >> 8) & 0xff)])
-#define DITHER_RGBA_222_LUT_B(num) \
-(_dither_b8[(((x + num) & 0x7) << DM_BS1) | ((y & 0x7) << DM_BS2) | ((src[num] >> 0) & 0xff)])
-
-#define WRITE1_RGBA_RGB222_DITHER(src, dest) \
-*dest = _dither_color_lut[(DITHER_RGBA_222_LUT_R(0)) | \
- (DITHER_RGBA_222_LUT_G(0)) | \
- (DITHER_RGBA_222_LUT_B(0))]; dest++; src++
-#ifdef WORDS_BIGENDIAN
-#define WRITE4_RGBA_RGB222_DITHER(src, dest) \
-{ \
- *((DATA32 *)dest) = (_dither_color_lut[((DITHER_RGBA_222_LUT_R(3))) | \
- ((DITHER_RGBA_222_LUT_G(3))) | \
- ((DITHER_RGBA_222_LUT_B(3)))]) | \
- (_dither_color_lut[((DITHER_RGBA_222_LUT_R(2))) | \
- ((DITHER_RGBA_222_LUT_G(2))) | \
- ((DITHER_RGBA_222_LUT_B(2)))] << 8) | \
- (_dither_color_lut[((DITHER_RGBA_222_LUT_R(1))) | \
- ((DITHER_RGBA_222_LUT_G(1))) | \
- ((DITHER_RGBA_222_LUT_B(1)))] << 16) | \
- (_dither_color_lut[((DITHER_RGBA_222_LUT_R(0))) | \
- ((DITHER_RGBA_222_LUT_G(0))) | \
- ((DITHER_RGBA_222_LUT_B(0)))] << 24); \
- dest += 4; src += 4; \
-}
-#define WRITE2_RGBA_RGB222_DITHER(src, dest) \
-{ \
- *((DATA32 *)dest) = (_dither_color_lut[((DITHER_RGBA_222_LUT_R(1))) | \
- ((DITHER_RGBA_222_LUT_G(1))) | \
- ((DITHER_RGBA_222_LUT_B(1)))]) | \
- (_dither_color_lut[((DITHER_RGBA_222_LUT_R(0))) | \
- ((DITHER_RGBA_222_LUT_G(0))) | \
- ((DITHER_RGBA_222_LUT_B(0)))] << 8); \
- dest += 2; src += 2; \
-}
-#else
-#define WRITE4_RGBA_RGB222_DITHER(src, dest) \
-{ \
- *((DATA32 *)dest) = (_dither_color_lut[((DITHER_RGBA_222_LUT_R(0))) | \
- ((DITHER_RGBA_222_LUT_G(0))) | \
- ((DITHER_RGBA_222_LUT_B(0)))]) | \
- (_dither_color_lut[((DITHER_RGBA_222_LUT_R(1))) | \
- ((DITHER_RGBA_222_LUT_G(1))) | \
- ((DITHER_RGBA_222_LUT_B(1)))] << 8) | \
- (_dither_color_lut[((DITHER_RGBA_222_LUT_R(2))) | \
- ((DITHER_RGBA_222_LUT_G(2))) | \
- ((DITHER_RGBA_222_LUT_B(2)))] << 16) | \
- (_dither_color_lut[((DITHER_RGBA_222_LUT_R(3))) | \
- ((DITHER_RGBA_222_LUT_G(3))) | \
- ((DITHER_RGBA_222_LUT_B(3)))] << 24); \
- dest += 4; src += 4; \
-}
-#define WRITE2_RGBA_RGB222_DITHER(src, dest) \
-{ \
- *((DATA32 *)dest) = (_dither_color_lut[((DITHER_RGBA_222_LUT_R(0))) | \
- ((DITHER_RGBA_222_LUT_G(0))) | \
- ((DITHER_RGBA_222_LUT_B(0)))]) | \
- (_dither_color_lut[((DITHER_RGBA_222_LUT_R(1))) | \
- ((DITHER_RGBA_222_LUT_G(1))) | \
- ((DITHER_RGBA_222_LUT_B(1)))] << 8); \
- dest += 2; src += 2; \
-}
-#endif
-
-/*****************************************************************************/
-/* Actual rendering routines */
-/* RGBA -> RGB221 */
-/*****************************************************************************/
-
-/*****************************************************************************/
-/* MACROS for plain RGBA -> RGB221 conversion */
-#define RGB221_BSHIFT >> 7
-#define RGB221_GSHIFT >> 13
-#define RGB221_RSHIFT >> 19
-#define RGB221_BMASK & 0x01
-#define RGB221_GMASK & 0x06
-#define RGB221_RMASK & 0x18
-
-#define WRITE1_RGBA_RGB221(src, dest) \
-*dest = _dither_color_lut[((*src RGB221_BSHIFT) RGB221_BMASK) | \
- ((*src RGB221_GSHIFT) RGB221_GMASK) | \
- ((*src RGB221_RSHIFT) RGB221_RMASK)]; dest++; src++
-#ifdef WORDS_BIGENDIAN
-#define WRITE2_RGBA_RGB221(src, dest) \
-{ \
- *((DATA16 *)dest) = (_dither_color_lut[((src[1] RGB221_BSHIFT) RGB221_BMASK) | \
- ((src[1] RGB221_GSHIFT) RGB221_GMASK) | \
- ((src[1] RGB221_RSHIFT) RGB221_RMASK)]) | \
- (_dither_color_lut[((src[0] RGB221_BSHIFT) RGB221_BMASK) | \
- ((src[0] RGB221_GSHIFT) RGB221_GMASK) | \
- ((src[0] RGB221_RSHIFT) RGB221_RMASK)] << 8); \
- dest += 2; src += 2; \
-}
-#define WRITE4_RGBA_RGB221(src, dest) \
-{ \
- *((DATA32 *)dest) = (_dither_color_lut[((src[3] RGB221_BSHIFT) RGB221_BMASK) | \
- ((src[3] RGB221_GSHIFT) RGB221_GMASK) | \
- ((src[3] RGB221_RSHIFT) RGB221_RMASK)]) | \
- (_dither_color_lut[((src[2] RGB221_BSHIFT) RGB221_BMASK) | \
- ((src[2] RGB221_GSHIFT) RGB221_GMASK) | \
- ((src[2] RGB221_RSHIFT) RGB221_RMASK)] << 8) | \
- (_dither_color_lut[((src[1] RGB221_BSHIFT) RGB221_BMASK) | \
- ((src[1] RGB221_GSHIFT) RGB221_GMASK) | \
- ((src[1] RGB221_RSHIFT) RGB221_RMASK)] << 16) | \
- (_dither_color_lut[((src[0] RGB221_BSHIFT) RGB221_BMASK) | \
- ((src[0] RGB221_GSHIFT) RGB221_GMASK) | \
- ((src[0] RGB221_RSHIFT) RGB221_RMASK)] << 24); \
- dest += 4; src += 4; \
-}
-#else
-#define WRITE2_RGBA_RGB221(src, dest) \
-{ \
- *((DATA16 *)dest) = (_dither_color_lut[((src[0] RGB221_BSHIFT) RGB221_BMASK) | \
- ((src[0] RGB221_GSHIFT) RGB221_GMASK) | \
- ((src[0] RGB221_RSHIFT) RGB221_RMASK)]) | \
- (_dither_color_lut[((src[1] RGB221_BSHIFT) RGB221_BMASK) | \
- ((src[1] RGB221_GSHIFT) RGB221_GMASK) | \
- ((src[1] RGB221_RSHIFT) RGB221_RMASK)] << 8); \
- dest += 2; src += 2; \
-}
-#define WRITE4_RGBA_RGB221(src, dest) \
-{ \
- *((DATA32 *)dest) = (_dither_color_lut[((src[0] RGB221_BSHIFT) RGB221_BMASK) | \
- ((src[0] RGB221_GSHIFT) RGB221_GMASK) | \
- ((src[0] RGB221_RSHIFT) RGB221_RMASK)]) | \
- (_dither_color_lut[((src[1] RGB221_BSHIFT) RGB221_BMASK) | \
- ((src[1] RGB221_GSHIFT) RGB221_GMASK) | \
- ((src[1] RGB221_RSHIFT) RGB221_RMASK)] << 8) | \
- (_dither_color_lut[((src[2] RGB221_BSHIFT) RGB221_BMASK) | \
- ((src[2] RGB221_GSHIFT) RGB221_GMASK) | \
- ((src[2] RGB221_RSHIFT) RGB221_RMASK)] << 16) | \
- (_dither_color_lut[((src[3] RGB221_BSHIFT) RGB221_BMASK) | \
- ((src[3] RGB221_GSHIFT) RGB221_GMASK) | \
- ((src[3] RGB221_RSHIFT) RGB221_RMASK)] << 24); \
- dest += 4; src += 4; \
-}
-#endif
-/*****************************************************************************/
-/* MACROS for dithered RGBA -> RGB221 conversion */
-#define DITHER_RGBA_221_LUT_R(num) \
-(_dither_r8[(((x + num) & 0x7) << DM_BS1) | ((y & 0x7) << DM_BS2) | ((src[num] >> 16) & 0xff)])
-#define DITHER_RGBA_221_LUT_G(num) \
-(_dither_g8[(((x + num) & 0x7) << DM_BS1) | ((y & 0x7) << DM_BS2) | ((src[num] >> 8) & 0xff)])
-#define DITHER_RGBA_221_LUT_B(num) \
-(_dither_b8[(((x + num) & 0x7) << DM_BS1) | ((y & 0x7) << DM_BS2) | ((src[num] >> 0) & 0xff)])
-
-#define WRITE1_RGBA_RGB221_DITHER(src, dest) \
-*dest = _dither_color_lut[(DITHER_RGBA_221_LUT_R(0)) | \
- (DITHER_RGBA_221_LUT_G(0)) | \
- (DITHER_RGBA_221_LUT_B(0))]; dest++; src++
-#ifdef WORDS_BIGENDIAN
-#define WRITE4_RGBA_RGB221_DITHER(src, dest) \
-{ \
- *((DATA32 *)dest) = (_dither_color_lut[((DITHER_RGBA_221_LUT_R(3))) | \
- ((DITHER_RGBA_221_LUT_G(3))) | \
- ((DITHER_RGBA_221_LUT_B(3)))]) | \
- (_dither_color_lut[((DITHER_RGBA_221_LUT_R(2))) | \
- ((DITHER_RGBA_221_LUT_G(2))) | \
- ((DITHER_RGBA_221_LUT_B(2)))] << 8) | \
- (_dither_color_lut[((DITHER_RGBA_221_LUT_R(1))) | \
- ((DITHER_RGBA_221_LUT_G(1))) | \
- ((DITHER_RGBA_221_LUT_B(1)))] << 16) | \
- (_dither_color_lut[((DITHER_RGBA_221_LUT_R(0))) | \
- ((DITHER_RGBA_221_LUT_G(0))) | \
- ((DITHER_RGBA_221_LUT_B(0)))] << 24); \
- dest += 4; src += 4; \
-}
-#define WRITE2_RGBA_RGB221_DITHER(src, dest) \
-{ \
- *((DATA32 *)dest) = (_dither_color_lut[((DITHER_RGBA_221_LUT_R(1))) | \
- ((DITHER_RGBA_221_LUT_G(1))) | \
- ((DITHER_RGBA_221_LUT_B(1)))]) | \
- (_dither_color_lut[((DITHER_RGBA_221_LUT_R(0))) | \
- ((DITHER_RGBA_221_LUT_G(0))) | \
- ((DITHER_RGBA_221_LUT_B(0)))] << 8); \
- dest += 2; src += 2; \
-}
-#else
-#define WRITE4_RGBA_RGB221_DITHER(src, dest) \
-{ \
- *((DATA32 *)dest) = (_dither_color_lut[((DITHER_RGBA_221_LUT_R(0))) | \
- ((DITHER_RGBA_221_LUT_G(0))) | \
- ((DITHER_RGBA_221_LUT_B(0)))]) | \
- (_dither_color_lut[((DITHER_RGBA_221_LUT_R(1))) | \
- ((DITHER_RGBA_221_LUT_G(1))) | \
- ((DITHER_RGBA_221_LUT_B(1)))] << 8) | \
- (_dither_color_lut[((DITHER_RGBA_221_LUT_R(2))) | \
- ((DITHER_RGBA_221_LUT_G(2))) | \
- ((DITHER_RGBA_221_LUT_B(2)))] << 16) | \
- (_dither_color_lut[((DITHER_RGBA_221_LUT_R(3))) | \
- ((DITHER_RGBA_221_LUT_G(3))) | \
- ((DITHER_RGBA_221_LUT_B(3)))] << 24); \
- dest += 4; src += 4; \
-}
-#define WRITE2_RGBA_RGB221_DITHER(src, dest) \
-{ \
- *((DATA32 *)dest) = (_dither_color_lut[((DITHER_RGBA_221_LUT_R(0))) | \
- ((DITHER_RGBA_221_LUT_G(0))) | \
- ((DITHER_RGBA_221_LUT_B(0)))]) | \
- (_dither_color_lut[((DITHER_RGBA_221_LUT_R(1))) | \
- ((DITHER_RGBA_221_LUT_G(1))) | \
- ((DITHER_RGBA_221_LUT_B(1)))] << 8); \
- dest += 2; src += 2; \
-}
-#endif
-
-/*****************************************************************************/
-/* Actual rendering routines */
-/* RGBA -> RGB121 */
-/*****************************************************************************/
-
-/*****************************************************************************/
-/* MACROS for plain RGBA -> RGB121 conversion */
-#define RGB121_BSHIFT >> 7
-#define RGB121_GSHIFT >> 13
-#define RGB121_RSHIFT >> 20
-#define RGB121_BMASK & 0x01
-#define RGB121_GMASK & 0x06
-#define RGB121_RMASK & 0x08
-
-#define WRITE1_RGBA_RGB121(src, dest) \
-*dest = _dither_color_lut[((*src RGB121_BSHIFT) RGB121_BMASK) | \
- ((*src RGB121_GSHIFT) RGB121_GMASK) | \
- ((*src RGB121_RSHIFT) RGB121_RMASK)]; dest++; src++
-#ifdef WORDS_BIGENDIAN
-#define WRITE2_RGBA_RGB121(src, dest) \
-{ \
- *((DATA16 *)dest) = (_dither_color_lut[((src[1] RGB121_BSHIFT) RGB121_BMASK) | \
- ((src[1] RGB121_GSHIFT) RGB121_GMASK) | \
- ((src[1] RGB121_RSHIFT) RGB121_RMASK)]) | \
- (_dither_color_lut[((src[0] RGB121_BSHIFT) RGB121_BMASK) | \
- ((src[0] RGB121_GSHIFT) RGB121_GMASK) | \
- ((src[0] RGB121_RSHIFT) RGB121_RMASK)] << 8); \
- dest += 2; src += 2; \
-}
-#define WRITE4_RGBA_RGB121(src, dest) \
-{ \
- *((DATA32 *)dest) = (_dither_color_lut[((src[3] RGB121_BSHIFT) RGB121_BMASK) | \
- ((src[3] RGB121_GSHIFT) RGB121_GMASK) | \
- ((src[3] RGB121_RSHIFT) RGB121_RMASK)]) | \
- (_dither_color_lut[((src[2] RGB121_BSHIFT) RGB121_BMASK) | \
- ((src[2] RGB121_GSHIFT) RGB121_GMASK) | \
- ((src[2] RGB121_RSHIFT) RGB121_RMASK)] << 8) | \
- (_dither_color_lut[((src[1] RGB121_BSHIFT) RGB121_BMASK) | \
- ((src[1] RGB121_GSHIFT) RGB121_GMASK) | \
- ((src[1] RGB121_RSHIFT) RGB121_RMASK)] << 16) | \
- (_dither_color_lut[((src[0] RGB121_BSHIFT) RGB121_BMASK) | \
- ((src[0] RGB121_GSHIFT) RGB121_GMASK) | \
- ((src[0] RGB121_RSHIFT) RGB121_RMASK)] << 24); \
- dest += 4; src += 4; \
-}
-#else
-#define WRITE2_RGBA_RGB121(src, dest) \
-{ \
- *((DATA16 *)dest) = (_dither_color_lut[((src[0] RGB121_BSHIFT) RGB121_BMASK) | \
- ((src[0] RGB121_GSHIFT) RGB121_GMASK) | \
- ((src[0] RGB121_RSHIFT) RGB121_RMASK)]) | \
- (_dither_color_lut[((src[1] RGB121_BSHIFT) RGB121_BMASK) | \
- ((src[1] RGB121_GSHIFT) RGB121_GMASK) | \
- ((src[1] RGB121_RSHIFT) RGB121_RMASK)] << 8); \
- dest += 2; src += 2; \
-}
-#define WRITE4_RGBA_RGB121(src, dest) \
-{ \
- *((DATA32 *)dest) = (_dither_color_lut[((src[0] RGB121_BSHIFT) RGB121_BMASK) | \
- ((src[0] RGB121_GSHIFT) RGB121_GMASK) | \
- ((src[0] RGB121_RSHIFT) RGB121_RMASK)]) | \
- (_dither_color_lut[((src[1] RGB121_BSHIFT) RGB121_BMASK) | \
- ((src[1] RGB121_GSHIFT) RGB121_GMASK) | \
- ((src[1] RGB121_RSHIFT) RGB121_RMASK)] << 8) | \
- (_dither_color_lut[((src[2] RGB121_BSHIFT) RGB121_BMASK) | \
- ((src[2] RGB121_GSHIFT) RGB121_GMASK) | \
- ((src[2] RGB121_RSHIFT) RGB121_RMASK)] << 16) | \
- (_dither_color_lut[((src[3] RGB121_BSHIFT) RGB121_BMASK) | \
- ((src[3] RGB121_GSHIFT) RGB121_GMASK) | \
- ((src[3] RGB121_RSHIFT) RGB121_RMASK)] << 24); \
- dest += 4; src += 4; \
-}
-#endif
-/*****************************************************************************/
-/* MACROS for dithered RGBA -> RGB121 conversion */
-#define DITHER_RGBA_121_LUT_R(num) \
-(_dither_r8[(((x + num) & 0x7) << DM_BS1) | ((y & 0x7) << DM_BS2) | ((src[num] >> 16) & 0xff)])
-#define DITHER_RGBA_121_LUT_G(num) \
-(_dither_g8[(((x + num) & 0x7) << DM_BS1) | ((y & 0x7) << DM_BS2) | ((src[num] >> 8) & 0xff)])
-#define DITHER_RGBA_121_LUT_B(num) \
-(_dither_b8[(((x + num) & 0x7) << DM_BS1) | ((y & 0x7) << DM_BS2) | ((src[num] >> 0) & 0xff)])
-
-#define WRITE1_RGBA_RGB121_DITHER(src, dest) \
-*dest = _dither_color_lut[(DITHER_RGBA_121_LUT_R(0)) | \
- (DITHER_RGBA_121_LUT_G(0)) | \
- (DITHER_RGBA_121_LUT_B(0))]; dest++; src++
-#ifdef WORDS_BIGENDIAN
-#define WRITE4_RGBA_RGB121_DITHER(src, dest) \
-{ \
- *((DATA32 *)dest) = (_dither_color_lut[((DITHER_RGBA_121_LUT_R(3))) | \
- ((DITHER_RGBA_121_LUT_G(3))) | \
- ((DITHER_RGBA_121_LUT_B(3)))]) | \
- (_dither_color_lut[((DITHER_RGBA_121_LUT_R(2))) | \
- ((DITHER_RGBA_121_LUT_G(2))) | \
- ((DITHER_RGBA_121_LUT_B(2)))] << 8) | \
- (_dither_color_lut[((DITHER_RGBA_121_LUT_R(1))) | \
- ((DITHER_RGBA_121_LUT_G(1))) | \
- ((DITHER_RGBA_121_LUT_B(1)))] << 16) | \
- (_dither_color_lut[((DITHER_RGBA_121_LUT_R(0))) | \
- ((DITHER_RGBA_121_LUT_G(0))) | \
- ((DITHER_RGBA_121_LUT_B(0)))] << 24); \
- dest += 4; src += 4; \
-}
-#define WRITE2_RGBA_RGB121_DITHER(src, dest) \
-{ \
- *((DATA32 *)dest) = (_dither_color_lut[((DITHER_RGBA_121_LUT_R(1))) | \
- ((DITHER_RGBA_121_LUT_G(1))) | \
- ((DITHER_RGBA_121_LUT_B(1)))]) | \
- (_dither_color_lut[((DITHER_RGBA_121_LUT_R(0))) | \
- ((DITHER_RGBA_121_LUT_G(0))) | \
- ((DITHER_RGBA_121_LUT_B(0)))] << 8); \
- dest += 2; src += 2; \
-}
-#else
-#define WRITE4_RGBA_RGB121_DITHER(src, dest) \
-{ \
- *((DATA32 *)dest) = (_dither_color_lut[((DITHER_RGBA_121_LUT_R(0))) | \
- ((DITHER_RGBA_121_LUT_G(0))) | \
- ((DITHER_RGBA_121_LUT_B(0)))]) | \
- (_dither_color_lut[((DITHER_RGBA_121_LUT_R(1))) | \
- ((DITHER_RGBA_121_LUT_G(1))) | \
- ((DITHER_RGBA_121_LUT_B(1)))] << 8) | \
- (_dither_color_lut[((DITHER_RGBA_121_LUT_R(2))) | \
- ((DITHER_RGBA_121_LUT_G(2))) | \
- ((DITHER_RGBA_121_LUT_B(2)))] << 16) | \
- (_dither_color_lut[((DITHER_RGBA_121_LUT_R(3))) | \
- ((DITHER_RGBA_121_LUT_G(3))) | \
- ((DITHER_RGBA_121_LUT_B(3)))] << 24); \
- dest += 4; src += 4; \
-}
-#define WRITE2_RGBA_RGB121_DITHER(src, dest) \
-{ \
- *((DATA32 *)dest) = (_dither_color_lut[((DITHER_RGBA_121_LUT_R(0))) | \
- ((DITHER_RGBA_121_LUT_G(0))) | \
- ((DITHER_RGBA_121_LUT_B(0)))]) | \
- (_dither_color_lut[((DITHER_RGBA_121_LUT_R(1))) | \
- ((DITHER_RGBA_121_LUT_G(1))) | \
- ((DITHER_RGBA_121_LUT_B(1)))] << 8); \
- dest += 2; src += 2; \
-}
-#endif
-
-/*****************************************************************************/
-/* Actual rendering routines */
-/* RGBA -> RGB111 */
-/*****************************************************************************/
-
-/*****************************************************************************/
-/* MACROS for plain RGBA -> RGB111 conversion */
-#define RGB111_BSHIFT >> 7
-#define RGB111_GSHIFT >> 14
-#define RGB111_RSHIFT >> 21
-#define RGB111_BMASK & 0x01
-#define RGB111_GMASK & 0x02
-#define RGB111_RMASK & 0x04
-
-#define WRITE1_RGBA_RGB111(src, dest) \
-*dest = _dither_color_lut[((*src RGB111_BSHIFT) RGB111_BMASK) | \
- ((*src RGB111_GSHIFT) RGB111_GMASK) | \
- ((*src RGB111_RSHIFT) RGB111_RMASK)]; dest++; src++
-#ifdef WORDS_BIGENDIAN
-#define WRITE2_RGBA_RGB111(src, dest) \
-{ \
- *((DATA16 *)dest) = (_dither_color_lut[((src[1] RGB111_BSHIFT) RGB111_BMASK) | \
- ((src[1] RGB111_GSHIFT) RGB111_GMASK) | \
- ((src[1] RGB111_RSHIFT) RGB111_RMASK)]) | \
- (_dither_color_lut[((src[0] RGB111_BSHIFT) RGB111_BMASK) | \
- ((src[0] RGB111_GSHIFT) RGB111_GMASK) | \
- ((src[0] RGB111_RSHIFT) RGB111_RMASK)] << 8); \
- dest += 2; src += 2; \
-}
-#define WRITE4_RGBA_RGB111(src, dest) \
-{ \
- *((DATA32 *)dest) = (_dither_color_lut[((src[3] RGB111_BSHIFT) RGB111_BMASK) | \
- ((src[3] RGB111_GSHIFT) RGB111_GMASK) | \
- ((src[3] RGB111_RSHIFT) RGB111_RMASK)]) | \
- (_dither_color_lut[((src[2] RGB111_BSHIFT) RGB111_BMASK) | \
- ((src[2] RGB111_GSHIFT) RGB111_GMASK) | \
- ((src[2] RGB111_RSHIFT) RGB111_RMASK)] << 8) | \
- (_dither_color_lut[((src[1] RGB111_BSHIFT) RGB111_BMASK) | \
- ((src[1] RGB111_GSHIFT) RGB111_GMASK) | \
- ((src[1] RGB111_RSHIFT) RGB111_RMASK)] << 16) | \
- (_dither_color_lut[((src[0] RGB111_BSHIFT) RGB111_BMASK) | \
- ((src[0] RGB111_GSHIFT) RGB111_GMASK) | \
- ((src[0] RGB111_RSHIFT) RGB111_RMASK)] << 24); \
- dest += 4; src += 4; \
-}
-#else
-#define WRITE2_RGBA_RGB111(src, dest) \
-{ \
- *((DATA16 *)dest) = (_dither_color_lut[((src[0] RGB111_BSHIFT) RGB111_BMASK) | \
- ((src[0] RGB111_GSHIFT) RGB111_GMASK) | \
- ((src[0] RGB111_RSHIFT) RGB111_RMASK)]) | \
- (_dither_color_lut[((src[1] RGB111_BSHIFT) RGB111_BMASK) | \
- ((src[1] RGB111_GSHIFT) RGB111_GMASK) | \
- ((src[1] RGB111_RSHIFT) RGB111_RMASK)] << 8); \
- dest += 2; src += 2; \
-}
-#define WRITE4_RGBA_RGB111(src, dest) \
-{ \
- *((DATA32 *)dest) = (_dither_color_lut[((src[0] RGB111_BSHIFT) RGB111_BMASK) | \
- ((src[0] RGB111_GSHIFT) RGB111_GMASK) | \
- ((src[0] RGB111_RSHIFT) RGB111_RMASK)]) | \
- (_dither_color_lut[((src[1] RGB111_BSHIFT) RGB111_BMASK) | \
- ((src[1] RGB111_GSHIFT) RGB111_GMASK) | \
- ((src[1] RGB111_RSHIFT) RGB111_RMASK)] << 8) | \
- (_dither_color_lut[((src[2] RGB111_BSHIFT) RGB111_BMASK) | \
- ((src[2] RGB111_GSHIFT) RGB111_GMASK) | \
- ((src[2] RGB111_RSHIFT) RGB111_RMASK)] << 16) | \
- (_dither_color_lut[((src[3] RGB111_BSHIFT) RGB111_BMASK) | \
- ((src[3] RGB111_GSHIFT) RGB111_GMASK) | \
- ((src[3] RGB111_RSHIFT) RGB111_RMASK)] << 24); \
- dest += 4; src += 4; \
-}
-#endif
-/*****************************************************************************/
-/* MACROS for dithered RGBA -> RGB111 conversion */
-#define DITHER_RGBA_111_LUT_R(num) \
-(_dither_r8[(((x + num) & 0x7) << DM_BS1) | ((y & 0x7) << DM_BS2) | ((src[num] >> 16) & 0xff)])
-#define DITHER_RGBA_111_LUT_G(num) \
-(_dither_g8[(((x + num) & 0x7) << DM_BS1) | ((y & 0x7) << DM_BS2) | ((src[num] >> 8) & 0xff)])
-#define DITHER_RGBA_111_LUT_B(num) \
-(_dither_b8[(((x + num) & 0x7) << DM_BS1) | ((y & 0x7) << DM_BS2) | ((src[num] >> 0) & 0xff)])
-
-#define WRITE1_RGBA_RGB111_DITHER(src, dest) \
-*dest = _dither_color_lut[(DITHER_RGBA_111_LUT_R(0)) | \
- (DITHER_RGBA_111_LUT_G(0)) | \
- (DITHER_RGBA_111_LUT_B(0))]; dest++; src++
-#ifdef WORDS_BIGENDIAN
-#define WRITE4_RGBA_RGB111_DITHER(src, dest) \
-{ \
- *((DATA32 *)dest) = (_dither_color_lut[((DITHER_RGBA_111_LUT_R(3))) | \
- ((DITHER_RGBA_111_LUT_G(3))) | \
- ((DITHER_RGBA_111_LUT_B(3)))]) | \
- (_dither_color_lut[((DITHER_RGBA_111_LUT_R(2))) | \
- ((DITHER_RGBA_111_LUT_G(2))) | \
- ((DITHER_RGBA_111_LUT_B(2)))] << 8) | \
- (_dither_color_lut[((DITHER_RGBA_111_LUT_R(1))) | \
- ((DITHER_RGBA_111_LUT_G(1))) | \
- ((DITHER_RGBA_111_LUT_B(1)))] << 16) | \
- (_dither_color_lut[((DITHER_RGBA_111_LUT_R(0))) | \
- ((DITHER_RGBA_111_LUT_G(0))) | \
- ((DITHER_RGBA_111_LUT_B(0)))] << 24); \
- dest += 4; src += 4; \
-}
-#define WRITE2_RGBA_RGB111_DITHER(src, dest) \
-{ \
- *((DATA32 *)dest) = (_dither_color_lut[((DITHER_RGBA_111_LUT_R(1))) | \
- ((DITHER_RGBA_111_LUT_G(1))) | \
- ((DITHER_RGBA_111_LUT_B(1)))]) | \
- (_dither_color_lut[((DITHER_RGBA_111_LUT_R(0))) | \
- ((DITHER_RGBA_111_LUT_G(0))) | \
- ((DITHER_RGBA_111_LUT_B(0)))] << 8); \
- dest += 2; src += 2; \
-}
-#else
-#define WRITE4_RGBA_RGB111_DITHER(src, dest) \
-{ \
- *((DATA32 *)dest) = (_dither_color_lut[((DITHER_RGBA_111_LUT_R(0))) | \
- ((DITHER_RGBA_111_LUT_G(0))) | \
- ((DITHER_RGBA_111_LUT_B(0)))]) | \
- (_dither_color_lut[((DITHER_RGBA_111_LUT_R(1))) | \
- ((DITHER_RGBA_111_LUT_G(1))) | \
- ((DITHER_RGBA_111_LUT_B(1)))] << 8) | \
- (_dither_color_lut[((DITHER_RGBA_111_LUT_R(2))) | \
- ((DITHER_RGBA_111_LUT_G(2))) | \
- ((DITHER_RGBA_111_LUT_B(2)))] << 16) | \
- (_dither_color_lut[((DITHER_RGBA_111_LUT_R(3))) | \
- ((DITHER_RGBA_111_LUT_G(3))) | \
- ((DITHER_RGBA_111_LUT_B(3)))] << 24); \
- dest += 4; src += 4; \
-}
-#define WRITE2_RGBA_RGB111_DITHER(src, dest) \
-{ \
- *((DATA32 *)dest) = (_dither_color_lut[((DITHER_RGBA_111_LUT_R(0))) | \
- ((DITHER_RGBA_111_LUT_G(0))) | \
- ((DITHER_RGBA_111_LUT_B(0)))]) | \
- (_dither_color_lut[((DITHER_RGBA_111_LUT_R(1))) | \
- ((DITHER_RGBA_111_LUT_G(1))) | \
- ((DITHER_RGBA_111_LUT_B(1)))] << 8); \
- dest += 2; src += 2; \
-}
-#endif
-
-/*****************************************************************************/
-/* Actual rendering routines */
-/* RGBA -> RGB1 (mono B&W) */
-/*****************************************************************************/
-
-/*****************************************************************************/
-/* MACROS for plain RGBA -> RGB1 conversion */
-
-#define WRITE1_RGBA_RGB1(src, dest) \
-*dest = _dither_color_lut[((((*src >> 0) & 0xff) + \
- ((*src >> 8) & 0xff) + \
- ((*src >> 16) & 0xff)) / 3) >> 7]; dest++; src++
-/*****************************************************************************/
-/* MACROS for dithered RGBA -> RGB1 conversion */
-#define DITHER_RGBA_1_LUT(num) \
-(_dither_r8[(((x + num) & 0x7) << DM_BS1) | \
- ((y & 0x7) << DM_BS2) | \
- ((((*src >> 0) & 0xff) + \
- ((*src >> 8) & 0xff) + \
- ((*src >> 16) & 0xff)) / 3)])
-
-#define WRITE1_RGBA_RGB1_DITHER(src, dest) \
-*dest = _dither_color_lut[(DITHER_RGBA_1_LUT(0))]; dest++; src++
-
-/*****************************************************************************/
-/* Actual rendering routines */
-/* RGBA -> A1 (mono B&W - alpha mas) */
-/*****************************************************************************/
-
-/*****************************************************************************/
-/* MACROS for plain RGBA -> A1 conversion */
-
-#ifdef WORDS_BIGENDIAN
-# define WRITE1_RGBA_A1(src, dest) \
-*dest |= ((*src & 0x80000000) >> (24 + (x & 0x7))); \
-if ((x & 0x7) == 0x7) dest++; \
-src++
-#else
-# define WRITE1_RGBA_A1(src, dest) \
-*dest |= ((*src & 0x80000000) >> (31 - (x & 0x7))); \
-if ((x & 0x7) == 0x7) dest++; \
-src++
-#endif
-
-/*****************************************************************************/
-/* MACROS for dithered RGBA -> A1 conversion */
-# define DITHER_RGBA_A1_LUT(num) \
-(_dither_a1[(((x + num) & 0x7) << DM_BS1) | ((y & 0x7) << DM_BS2) | ((src[num] >> 24))])
-#ifdef WORDS_BIGENDIAN
-#define WRITE1_RGBA_A1_DITHER(src, dest) \
-*dest |= (DITHER_RGBA_A1_LUT(0)) << (7 - (x & 0x7)); \
-if ((x & 0x7) == 0x7) dest++; \
-src++;
-#else
-#define WRITE1_RGBA_A1_DITHER(src, dest) \
-*dest |= (DITHER_RGBA_A1_LUT(0)) << (0 + (x & 0x7)); \
-if ((x & 0x7) == 0x7) dest++; \
-src++;
-#endif
-
-/*****************************************************************************/
-/* Actual rendering routines */
-/* RGBA -> RGB8888 */
-/*****************************************************************************/
-
-/*****************************************************************************/
-/* MACROS for plain RGBA -> RGB8888 conversion */
-#define WRITE1_RGBA_RGB8888(src, dest) \
-*dest = *src; dest++; src++;
-# define WRITE1_RGBA_BGR8888(src, dest) \
-*dest = (((*src) >> 16) & 0x0000ff) | \
- (((*src) ) & 0x00ff00) | \
- (((*src) << 16) & 0xff0000); dest++; src++;
-
-/*****************************************************************************/
-/* Actual rendering routines */
-/* RGBA -> RGB888 */
-/*****************************************************************************/
-
-/*****************************************************************************/
-/* MACROS for plain RGBA -> RGB888 conversion */
-#define WRITE1_RGBA_RGB888(src, dest) \
-*dest = ((*src >> 0) & 0xff); dest++; \
-*dest = ((*src >> 8) & 0xff); dest++; \
-*dest = ((*src >> 16) & 0xff); dest++; src++;
-#define WRITE1_RGBA_BGR888(src, dest) \
-*dest = ((*src >> 16) & 0xff); dest++; \
-*dest = ((*src >> 8) & 0xff); dest++; \
-*dest = ((*src >> 0) & 0xff); dest++; src++;
-
-void
-__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;
- }
- 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;
- }
- }
- _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;
-
- 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;
- }
- 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;
- }
-}
-
-static void
-__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;
-}
-
-static void
-__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;
-}
-
-static void
-__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;
-}
-
-static void
-__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;
-}
-
-static void
-__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;
-}
-
-static void
-__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;
-}
-
-static void
-__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;
-}
-
-static void
-__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;
-}
-
-static void
-__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;
-}
-
-static void
-__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;
-}
-
-static void
-__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;
-}
-
-static void
-__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;
-
- 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;
- }
- }
- }
- 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;
- }
- }
- }
- return;
- dx = 0;
- dy = 0;
-}
-
-static void
-__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;
-}
-
-static void
-__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;
-}
-
-static void
-__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;
-}
-
-static void
-__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;
-}
-
-static void
-__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;
-}
-
-static void
-__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;
-}
-
-static void
-__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;
-}
-
-static void
-__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;
-}
-
-static void
-__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;
-}
-
-static void
-__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;
-}
-
-static void
-__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;
-}
-
-static void
-__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;
-}
-
-static void
-__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);
-
- 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;
- }
- return;
- dx = 0;
- dy = 0;
-}
-
-static void
-__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);
-
- 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;
- }
- 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)
-{
- 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;
- }
- }
- else
- memcpy(dest, src, h * w * sizeof(DATA32));
- return;
- dx = 0;
- dy = 0;
-}
-
-static void
-__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;
-
- 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;
- }
- return;
- dx = 0;
- dy = 0;
-}
-
-static void
-__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;
-}
-
-static void
-__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;
-}
-
-static void
-__imlib_RGBA_to_Nothing(DATA32 * src, int src_jump,
- DATA8 * dest, int dow,
- int width, int height, int dx, int dy)
-{
- /*\ Nothing: Dummy function \ */
-}
-
-ImlibRGBAFunction
-__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
- {
-#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
-#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;
- }
- else if (depth == 32)
- {
- 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;
- }
- 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;
- }
- }
- return NULL;
-}
-
-ImlibRGBAFunction
-__imlib_GetMaskFunction(char hiq)
-{
- return hiq ? &__imlib_RGBA_to_A1_dither : &__imlib_RGBA_to_A1_fast;
-}
diff --git a/src/rgba.h b/src/rgba.h
deleted file mode 100644
index c72b09b..0000000
--- a/src/rgba.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef __RGBA
-#define __RGBA 1
-
-#define DM_BS1 (8 + 3)
-#define DM_BS2 (8)
-#define DM_X (8)
-#define DM_Y (8)
-
-void __imlib_RGBASetupContext(Context *ct);
-void __imlib_RGBA_init(void *rd, void *gd, void *bd, int depth,
- DATA8 palette_type);
-
-typedef void (*ImlibRGBAFunction)(DATA32*, int, DATA8*,
- int, int, int, int, int);
-ImlibRGBAFunction
-__imlib_GetRGBAFunction(int depth,
- unsigned long rm, unsigned long gm, unsigned long bm,
- char hiq, DATA8 palette_type);
-ImlibRGBAFunction
-__imlib_GetMaskFunction(char hiq);
-
-#ifdef DO_MMX_ASM
-void __imlib_mmx_rgb555_fast(DATA32*, int, DATA8*, int, int, int, int, int);
-void __imlib_mmx_bgr555_fast(DATA32*, int, DATA8*, int, int, int, int, int);
-void __imlib_mmx_rgb565_fast(DATA32*, int, DATA8*, int, int, int, int, int);
-void __imlib_mmx_bgr565_fast(DATA32*, int, DATA8*, int, int, int, int, int);
-#endif
-#endif
diff --git a/src/rgbadraw.c b/src/rgbadraw.c
deleted file mode 100644
index 0653f5e..0000000
--- a/src/rgbadraw.c
+++ /dev/null
@@ -1,624 +0,0 @@
-#include "common.h"
-#include <math.h>
-#include "colormod.h"
-#include "image.h"
-#include "scale.h"
-#include "blend.h"
-#include "updates.h"
-#include "rgbadraw.h"
-
-
-void
-__imlib_FlipImageHoriz(ImlibImage * im)
-{
- 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--;
- }
- }
- x = im->border.left;
- im->border.left = im->border.right;
- im->border.right = x;
-}
-
-void
-__imlib_FlipImageVert(ImlibImage * im)
-{
- 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++;
- }
- }
- x = im->border.top;
- im->border.top = im->border.bottom;
- im->border.bottom = x;
-}
-
-void
-__imlib_FlipImageBoth(ImlibImage * im)
-{
- 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--;
- }
- x = im->border.top;
- im->border.top = im->border.bottom;
- im->border.bottom = x;
- x = im->border.left;
- im->border.left = im->border.right;
- im->border.right = x;
-}
-
-/*\ Directions (source is right/down):
-|*| 0 = down/right (flip over ul-dr diagonal)
-|*| 1 = down/left (rotate 90 degrees clockwise)
-|*| 2 = up/right (rotate 90 degrees counterclockwise)
-|*| 3 = up/left (flip over ur-ll diagonal)
-\*/
-void
-__imlib_FlipImageDiagonal(ImlibImage * im, int direction)
-{
- DATA32 *data, *to, *from;
- int x, y, w, hw, tmp;
-
- data = malloc(im->w * im->h * sizeof(DATA32));
- from = im->data;
- w = im->h;
- im->h = im->w;
- 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;
- }
- from = im->data;
- for (x = im->w; --x >= 0;)
- {
- for (y = im->h; --y >= 0;)
- {
- *to = *from;
- from++;
- to += w;
- }
- to += hw;
- }
- free(im->data);
- im->data = data;
-}
-
-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;
-
- if (rad < 1)
- return;
- data = malloc(im->w * im->h * sizeof(DATA32));
- as = malloc(sizeof(int) * im->w);
- rs = malloc(sizeof(int) * im->w);
- gs = malloc(sizeof(int) * im->w);
- 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
- {
- }
- }
- free(as);
- free(rs);
- free(gs);
- free(bs);
- free(im->data);
- im->data = data;
-}
-
-void
-__imlib_SharpenImage(ImlibImage * im, int rad)
-{
- 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++;
- }
- }
- }
- free(im->data);
- im->data = data;
-}
-
-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;
-
- 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++;
- }
- }
- free(im->data);
- im->data = data;
-}
-
-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;
-
- 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++;
- }
- }
- free(im->data);
- im->data = data;
-}
-
-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;
-
- /* clip horizontal co-ordinates so that both dest and src fit inside */
- /* the image */
- if (x < 0)
- {
- w += x;
- nx -= x;
- x = 0;
- }
- if (w <= 0)
- return;
- if (nx < 0)
- {
- w += nx;
- x -= nx;
- nx = 0;
- }
- if (w <= 0)
- return;
- if ((x + w) > im->w)
- w = (im->w - x);
- if (w <= 0)
- return;
- if ((nx + w) > im->w)
- w = (im->w - nx);
- if (w <= 0)
- return;
- /* clip vertical co-ordinates so that both dest and src fit inside */
- /* the image */
- if (y < 0)
- {
- h += y;
- ny -= y;
- y = 0;
- }
- if (h <= 0)
- return;
- if (ny < 0)
- {
- h += ny;
- y -= ny;
- ny = 0;
- }
- if (h <= 0)
- return;
- if ((y + h) > im->h)
- h = (im->h - y);
- if (h <= 0)
- return;
- if ((ny + h) > im->h)
- h = (im->h - ny);
- if (h <= 0)
- return;
-
- /* figure out what our source and destnation start pointers are */
- p1 = im->data + (y * im->w) + x;
- p2 = im->data + (ny * im->w) + nx;
- /* the pointer jump between lines */
- 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;
- }
- }
- /* 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;
- }
- }
-}
-
-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;
-
- /* clip horizontal co-ordinates so that both dest and src fit inside */
- /* the image */
- if (x < 0)
- {
- w += x;
- nx -= x;
- x = 0;
- }
- if (w <= 0)
- return;
- if (nx < 0)
- {
- w += nx;
- x -= nx;
- nx = 0;
- }
- if (w <= 0)
- return;
- if ((x + w) > src->w)
- w = (src->w - x);
- if (w <= 0)
- return;
- if ((nx + w) > dst->w)
- w = (dst->w - nx);
- if (w <= 0)
- return;
- /* clip vertical co-ordinates so that both dest and src fit inside */
- /* the image */
- if (y < 0)
- {
- h += y;
- ny -= y;
- y = 0;
- }
- if (h <= 0)
- return;
- if (ny < 0)
- {
- h += ny;
- y -= ny;
- ny = 0;
- }
- if (h <= 0)
- return;
- if ((y + h) > src->h)
- h = (src->h - y);
- if (h <= 0)
- return;
- if ((ny + h) > dst->h)
- h = (dst->h - ny);
- if (h <= 0)
- return;
-
- /* figure out what our source and destnation start pointers are */
- p1 = src->data + (y * src->w) + x;
- p2 = dst->data + (ny * dst->w) + nx;
- /* the pointer jump between lines */
- jump = (src->w - w);
- 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;
- }
- }
-}
-
diff --git a/src/rgbadraw.h b/src/rgbadraw.h
deleted file mode 100644
index 7708073..0000000
--- a/src/rgbadraw.h
+++ /dev/null
@@ -1,141 +0,0 @@
-#ifndef __RGBADRAW
-#define __RGBADRAW 1
-
-#define IN_SEGMENT(x, sx, sw) \
-((unsigned)((x) - (sx)) < (sw))
-
-#define IN_RANGE(x, y, w, h) \
-( ((unsigned)(x) < (w)) && ((unsigned)(y) < (h)) )
-
-#define IN_RECT(x, y, rx, ry, rw, rh) \
-( ((unsigned)((x) - (rx)) < (rw)) && ((unsigned)((y) - (ry)) < (rh)) )
-
-#define CLIP_RECT_TO_RECT(x, y, w, h, rx, ry, rw, rh) \
-{ \
- int _t0, _t1; \
- \
- _t0 = MAX(x, (rx)); \
- _t1 = MIN(x + w, (rx) + (rw)); \
- x = _t0; \
- w = _t1 - _t0; \
- _t0 = MAX(y, (ry)); \
- _t1 = MIN(y + h, (ry) + (rh)); \
- y = _t0; \
- h = _t1 - _t0; \
-}
-
-#define DIV_255(a, x, tmp) \
-{ \
- tmp = (x) + 0x80; \
- a = (tmp + (tmp >> 8)) >> 8; \
-}
-
-#define MULT(na, a0, a1, tmp) \
- DIV_255(na, (a0) * (a1), tmp)
-
-
-typedef struct _imlib_point ImlibPoint;
-
-struct _imlib_point
-{
- int x, y;
-};
-
-typedef struct _imlib_rectangle Imlib_Rectangle;
-
-struct _imlib_rectangle
-{
- int x, y, w, h;
-};
-
-typedef struct _imlib_polygon _ImlibPoly;
-typedef _ImlibPoly *ImlibPoly;
-
-struct _imlib_polygon
-{
- ImlibPoint *points;
- int pointcount;
- int lx, rx;
- int ty, by;
-};
-
-/* image related operations: in rgbadraw.c */
-
-void __imlib_FlipImageHoriz(ImlibImage * im);
-void __imlib_FlipImageVert(ImlibImage * im);
-void __imlib_FlipImageBoth(ImlibImage * im);
-void __imlib_FlipImageDiagonal(ImlibImage * im, int direction);
-void __imlib_BlurImage(ImlibImage * im, int rad);
-void __imlib_SharpenImage(ImlibImage * im, int rad);
-void __imlib_TileImageHoriz(ImlibImage * im);
-void __imlib_TileImageVert(ImlibImage * im);
-
-void __imlib_copy_alpha_data(ImlibImage * src, ImlibImage * dst, int x, int y,
- int w, int h, int nx, int ny);
-
-void __imlib_copy_image_data(ImlibImage * im, int x, int y, int w, int h,
- int nx, int ny);
-
-
-/* point and line drawing: in line.c */
-
-ImlibUpdate *
-__imlib_Point_DrawToImage(int x, int y, DATA32 color,
- ImlibImage *im, int clx, int cly, int clw, int clh,
- ImlibOp op, char blend, char make_updates);
-
-ImlibUpdate *
-__imlib_Line_DrawToImage(int x0, int y0, int x1, int y1, DATA32 color,
- ImlibImage *im, int clx, int cly, int clw, int clh,
- ImlibOp op, char blend, char anti_alias,
- char make_updates);
-
-
-/* rectangle drawing and filling: in rectangle.c */
-
-void
-__imlib_Rectangle_DrawToImage(int xc, int yc, int w, int h, DATA32 color,
- ImlibImage *im, int clx, int cly, int clw, int clh,
- ImlibOp op, char blend);
-
-void
-__imlib_Rectangle_FillToImage(int xc, int yc, int w, int h, DATA32 color,
- ImlibImage *im, int clx, int cly, int clw, int clh,
- ImlibOp op, char blend);
-
-
-/* ellipse drawing and filling: in ellipse.c */
-
-void
-__imlib_Ellipse_DrawToImage(int xc, int yc, int a, int b, DATA32 color,
- ImlibImage *im, int clx, int cly, int clw, int clh,
- ImlibOp op, char blend, char anti_alias);
-
-void
-__imlib_Ellipse_FillToImage(int xc, int yc, int a, int b, DATA32 color,
- ImlibImage *im, int clx, int cly, int clw, int clh,
- ImlibOp op, char blend, char anti_alias);
-
-
-/* polygon handling functions: in polygon.c */
-
-ImlibPoly __imlib_polygon_new(void);
-void __imlib_polygon_free(ImlibPoly poly);
-void __imlib_polygon_add_point(ImlibPoly poly, int x, int y);
-unsigned char __imlib_polygon_contains_point(ImlibPoly poly, int x, int y);
-void __imlib_polygon_get_bounds(ImlibPoly poly, int *px1, int *py1, int *px2, int *py2);
-
-
-/* polygon drawing and filling: in polygon.c */
-
-void
-__imlib_Polygon_DrawToImage(ImlibPoly poly, char closed, DATA32 color,
- ImlibImage *im, int clx, int cly, int clw, int clh,
- ImlibOp op, char blend, char anti_alias);
-void
-__imlib_Polygon_FillToImage(ImlibPoly poly, DATA32 color,
- ImlibImage *im, int clx, int cly, int clw, int clh,
- ImlibOp op, char blend, char anti_alias);
-
-
-#endif
diff --git a/src/rotate.c b/src/rotate.c
deleted file mode 100644
index 900a242..0000000
--- a/src/rotate.c
+++ /dev/null
@@ -1,542 +0,0 @@
-#include "common.h"
-#include "rotate.h"
-#include "blend.h"
-
-/*\ Linear interpolation functions \*/
-/*\ Between two values \*/
-#define INTERP(v1, v2, f) \
- (((v1) << _ROTATE_PREC) + (((v2) - (v1)) * (f)))
-
-/*\ Between two colour bytes \*/
-#define INTERP_VAL1(x_VAL, dest, l, r, x) \
- x_VAL(dest) = (INTERP(x_VAL(l), x_VAL(r), (x)) >> _ROTATE_PREC)
-
-/*\ Alpha channel: between two values and two zeroes \*/
-#define INTERP_VAL1_A0(dest, v1, v2, f1, f2) \
- A_VAL(dest) = ((INTERP(A_VAL(v1), A_VAL(v2), (f1)) * \
- (f2)) >> (2 * _ROTATE_PREC))
-
-/*\ Between four values \*/
-#define INTERP_VAL2(x_VAL, dest, ul, ur, ll, lr, x, y) \
- x_VAL(dest) = (INTERP(INTERP(x_VAL(ul), x_VAL(ur), (x)), \
- INTERP(x_VAL(ll), x_VAL(lr), (x)), \
- (y)) >> (2 * _ROTATE_PREC))
-
-/*\ Functions used in rotation routines.
-|*| The do { } while(0) construction is to make it one statement.
-\*/
-/*\ Between four colours \*/
-#define INTERP_ARGB(dest, src, sow, x, y) do { \
- INTERP_VAL2(R_VAL, (dest), (src), (src) + 1, (src) + (sow), (src) + (sow) + 1, (x) & _ROTATE_PREC_BITS, (y) & _ROTATE_PREC_BITS); \
- INTERP_VAL2(G_VAL, (dest), (src), (src) + 1, (src) + (sow), (src) + (sow) + 1, (x) & _ROTATE_PREC_BITS, (y) & _ROTATE_PREC_BITS); \
- INTERP_VAL2(B_VAL, (dest), (src), (src) + 1, (src) + (sow), (src) + (sow) + 1, (x) & _ROTATE_PREC_BITS, (y) & _ROTATE_PREC_BITS); \
- INTERP_VAL2(A_VAL, (dest), (src), (src) + 1, (src) + (sow), (src) + (sow) + 1, (x) & _ROTATE_PREC_BITS, (y) & _ROTATE_PREC_BITS); \
- } while (0)
-
-/*\ Between two colours, alpha between two values and zeroes \*/
-#define INTERP_RGB_A0(dest, v1, v2, f, f2) do { \
- INTERP_VAL1(R_VAL, (dest), (v1), (v2), (f) & _ROTATE_PREC_BITS); \
- INTERP_VAL1(G_VAL, (dest), (v1), (v2), (f) & _ROTATE_PREC_BITS); \
- INTERP_VAL1(B_VAL, (dest), (v1), (v2), (f) & _ROTATE_PREC_BITS); \
- INTERP_VAL1_A0(dest, (v1), (v2), (f) & _ROTATE_PREC_BITS, (f2) & _ROTATE_PREC_BITS); \
- } while (0)
-
-/*\ One colour, alpha between one value and three zeroes \*/
-#define INTERP_A000(dest, v, f1, f2) do { \
- *(dest) = *(v); \
- A_VAL(dest) = (A_VAL(dest) * \
- ((f1) & _ROTATE_PREC_BITS) * ((f2) & _ROTATE_PREC_BITS)) >> (2 * _ROTATE_PREC); \
- } while (0)
-
-/*\ 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)
-{
- 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)
-{
- 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))
-|*| it's quicker to do ((unsigned)(v - b) < (t - b))
-|*| as negative values, cast to unsigned, become large positive
-|*| values, and fall through the compare.
-|*| v in [0 .. t) is a special case: ((unsigned)v < t)
-|*| v in [-t .. 0) is also special, as its the same as ~v in [0 .. t)
-\*/
-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)
-{
- sw <<= _ROTATE_PREC;
- sh <<= _ROTATE_PREC;
-
- if (((unsigned)x >= sw) || ((unsigned)y >= sh))
- return 0;
- x += dxh * dw;
- y += dyh * dw;
- if (((unsigned)x >= sw) || ((unsigned)y >= sh))
- return 0;
- x += dxv * dh;
- y += dyv * dh;
- if (((unsigned)x >= sw) || ((unsigned)y >= sh))
- return 0;
- 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)
-{
- 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);
-
- }
-}
-
-/*\ With antialiasing.
-|*| NB: The function 'sees' a transparent border around the source,
-|*| with colour channels matching the edge, so there is no need to do
-|*| anything special, but remember to account for this when calculating
-|*| 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)
-{
- 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);
- 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);
-
- }
-}
-
-/*\ 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,
- int clx, int cly, int clw, int clh)
-{
- 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)
- return;
- if ((!(im_dst->data)) && (im_dst->loader) && (im_src->loader->load))
- 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;
-
- 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;
- }
-#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;
-#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
-#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;
-
- }
- free(data);
-}
diff --git a/src/rotate.h b/src/rotate.h
deleted file mode 100644
index 9e69342..0000000
--- a/src/rotate.h
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef __ROTATE
-#define __ROTATE 1
-
-#include "image.h"
-#include "colormod.h"
-#include "blend.h"
-
-/*\ Calc precision \*/
-#define _ROTATE_PREC 12
-#define _ROTATE_PREC_MAX (1 << _ROTATE_PREC)
-#define _ROTATE_PREC_BITS (_ROTATE_PREC_MAX - 1)
-
-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);
-void __imlib_RotateAA(DATA32 *src, DATA32 *dest, int sow, int sw, int sh,
- int dow, int dw, int dh, int x, int y,
- int dx, int dy, int dxv, int dyv);
-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,
- int clx, int cly, int clw, int clh);
-
-
-#ifdef DO_MMX_ASM
-void __imlib_mmx_RotateAA(DATA32 *src, DATA32 *dest, int sow, int sw, int sh,
- int dow, int dw, int dh, int x, int y,
- int dx, int dy, int dxv, int dyv);
-#endif
-#endif
diff --git a/src/scale.c b/src/scale.c
deleted file mode 100644
index 71e523d..0000000
--- a/src/scale.c
+++ /dev/null
@@ -1,1534 +0,0 @@
-#include "common.h"
-#include "colormod.h"
-#include "image.h"
-#include "blend.h"
-#include "scale.h"
-
-#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;
-};
-
-#define RGBA_COMPOSE(r, g, b, a) ((a) << 24) | ((r) << 16) | ((g) << 8) | (b)
-#define INV_XAP (256 - xapoints[x])
-#define XAP (xapoints[x])
-#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)
-{
- 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;
- }
- val = 0;
- inc = 1 << 16;
- for (i = 0; i < b1; i++)
- {
- 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 = (sh - b2) << 16;
- inc = 1 << 16;
- for (i = 0; i <= b2; i++)
- {
- 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;
- }
- return p;
-}
-
-static int *
-__imlib_CalcXPoints(int sw, int dw, int b1, int b2)
-{
- int *p, i, j = 0;
- int val, inc, rv = 0;
-
- 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;
- }
- val = 0;
- inc = 1 << 16;
- for (i = 0; i < b1; i++)
- {
- 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 = (sw - b2) << 16;
- inc = 1 << 16;
- for (i = 0; i <= b2; i++)
- {
- 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;
- }
- return p;
-}
-
-static int *
-__imlib_CalcApoints(int s, int d, int b1, int b2, int up)
-{
- int *p, i, j = 0, rv = 0;
-
- 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;
- }
- /* 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;
- }
- /* 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);
- }
- if (rv)
- {
- 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)
-{
- 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 *isi;
- int scw, sch;
-
- scw = dw * im->w / sw;
- sch = dh * im->h / sh;
-
- isi = malloc(sizeof(ImlibScaleInfo));
- if (!isi)
- return NULL;
- memset(isi, 0, sizeof(ImlibScaleInfo));
-
- isi->pix_assert = im->data + im->w * im->h;
-
- isi->xup_yup = (abs(dw) >= sw) + ((abs(dh) >= sh) << 1);
-
- isi->xpoints = __imlib_CalcXPoints(im->w, scw,
- 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);
- 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);
- }
- 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)
-{
- 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]];
- }
-}
-
-/* FIXME: NEED to optimise ScaleAARGBA - currently its "ok" but needs work*/
-
-/* 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)
-{
- 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]];
- }
- }
- }
- }
- /* 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++;
- }
- }
- }
-#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]];
- }
- }
- }
- }
-#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++;
- }
- }
- }
-#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]];
- }
- }
- }
- }
-#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++;
- }
- }
- }
-#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]];
- }
- }
- }
-#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)
-{
- 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]];
- }
- }
- }
- }
- /* 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++;
- }
- }
- }
-#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]];
- }
- }
- }
- }
-#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++;
- }
- }
- }
-#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]];
- }
- }
- }
- }
-#endif
- /* fully optimized (i think) - onyl change of algorithm can help */
- /* if we're scaling down horizontally & vertically */
- 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++;
- }
- }
- }
-#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]];
- }
- }
- }
-#endif
-}
diff --git a/src/scale.h b/src/scale.h
deleted file mode 100644
index f3b0b17..0000000
--- a/src/scale.h
+++ /dev/null
@@ -1,22 +0,0 @@
-#ifndef __SCALE
-#define __SCALE 1
-
-typedef struct _imlib_scale_info ImlibScaleInfo;
-
-ImlibScaleInfo *
-__imlib_CalcScaleInfo(ImlibImage *im, int sw, int sh, int dw, int dh, char aa);
-ImlibScaleInfo *
-__imlib_FreeScaleInfo(ImlibScaleInfo *isi);
-void
-__imlib_ScaleSampleRGBA(ImlibScaleInfo *isi, DATA32 *dest, int dxx, int dyy,
- int dx, int dy, int dw, int dh, int dow);
-void
-__imlib_ScaleAARGBA(ImlibScaleInfo *isi, DATA32 *dest, int dxx, int dyy,
- int dx, int dy, int dw, int dh, int dow, int sow);
-void
-__imlib_ScaleAARGB(ImlibScaleInfo *isi, DATA32 *dest, int dxx, int dyy,
- int dx, int dy, int dw, int dh, int dow, int sow);
-void
-__imlib_Scale_mmx_AARGBA(ImlibScaleInfo *isi, DATA32 *dest, int dxx, int dyy,
- int dx, int dy, int dw, int dh, int dow, int sow);
-#endif
diff --git a/src/script.c b/src/script.c
deleted file mode 100644
index 4359c87..0000000
--- a/src/script.c
+++ /dev/null
@@ -1,297 +0,0 @@
-#include "common.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <time.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <ctype.h>
-#include <errno.h>
-#ifndef X_DISPLAY_MISSING
-#include <X11/Xlib.h>
-#endif
-#include "Imlib2.h"
-#include "image.h"
-#include "file.h"
-#include "dynamic_filters.h"
-#include "script.h"
-#include "loaderpath.h"
-
-/*
-#define FDEBUG 1
-*/
-#ifdef FDEBUG
-# define D( str ) printf( "DEBUG: %s\n", str )
-#else
-#define D( str )
-#endif
-
-IVariable *vars, *current_var, *curtail;
-
-static int
-__imlib_find_string(char *haystack, char *needle)
-{
- if (strstr(haystack, needle) != NULL)
- return (strstr(haystack, needle) - haystack);
- return 0;
-}
-
-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);
- free(tmpstr);
- return str;
-}
-
-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;
- }
- return NULL;
-}
-
-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);
-}
-
-static void
-__imlib_script_delete_variable(IVariable * var)
-{
- if (var->next != NULL)
- __imlib_script_delete_variable(var->next);
- free(var);
-}
-
-void
-__imlib_script_tidyup(void)
-{
- __imlib_script_delete_variable(vars);
-}
-
-void *
-__imlib_script_get_next_var(void)
-{
- if (current_var != NULL)
- current_var = current_var->next;
- if (current_var != NULL)
- return current_var->ptr;
- else
- return NULL;
-}
-
-void
-__imlib_script_add_var(void *ptr)
-{
- curtail->next = malloc(sizeof(IVariable));
- curtail = curtail->next;
- curtail->ptr = ptr;
- curtail->next = NULL;
-}
-
-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");
- rootptr->type = VAR_CHAR;
- 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);
-#ifdef FDEBUG
- 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()");
- return rootptr;
-}
-
-Imlib_Image
-__imlib_script_parse_function(Imlib_Image im, char *function)
-{
- 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);
-#ifdef FDEBUG
- printf("DEBUG: (??) = function <%s>( \"%s\" )\n", funcname, funcparams);
-#endif
- params = __imlib_script_parse_parameters(im, funcparams);
- /* excute the filter */
- filter = __imlib_get_dynamic_filter(funcname);
- if (filter != NULL)
- {
-#ifdef FDEBUG
- printf("DEBUG: (--) Executing Filter \"%s\".\n", funcname);
-#endif
- retval = filter->exec_filter(funcname, im, params);
- }
- else
- {
-#ifdef FDEBUG
- printf
- ("DEBUG: (!!) Can't find filter \"%s\", returning given image.\n",
- funcname);
-#endif
- retval = im;
- }
- D("Get Here");
- /* clean up params */
- 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)
-{
- 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;
- }
-}
diff --git a/src/script.h b/src/script.h
deleted file mode 100644
index 12097e7..0000000
--- a/src/script.h
+++ /dev/null
@@ -1,64 +0,0 @@
-#ifndef _DYN_FUNCTION_H_
-#define _DYN_FUNCTION_H_
-
-#include <ltdl.h>
-#include "Imlib2.h"
-#include <stdarg.h>
-
-#define VAR_CHAR 1
-#define VAR_PTR 2
-
-#define ASSIGN_DATA8( var, v ) if( strcmp( ptr->key, var ) == 0 ) v = (DATA8)atoi( (char *)ptr->data )
-#define ASSIGN_INT(k, v) \
- if (!strcmp((k), ptr->key)) { \
- if (ptr->type == VAR_PTR) { \
- (v) = (*(int *)ptr->data); \
- } else if (ptr->type == VAR_CHAR) { \
- (v) = strtol(ptr->data, 0, 0); \
- } \
- }
-
-#define ASSIGN_IMAGE(k, v) \
- if (!strcmp((k), ptr->key)) { \
- if (ptr->type == VAR_PTR) { \
- (v) = ((Imlib_Image)ptr->data); \
- } else if (ptr->type == VAR_CHAR) { \
- if (!free_map) \
- (v) = imlib_load_image(ptr->data); \
- free_map = 1; \
- } \
- }
-
-typedef struct _imlib_function_param IFunctionParam;
-typedef struct _imlib_function_param *pIFunctionParam;
-struct _imlib_function_param
-{
- char *key;
- int type;
- void *data;
- pIFunctionParam next;
-};
-
-typedef struct _imlib_function IFunction;
-typedef struct _imlib_function *pIFunction;
-struct _imlib_function
-{
- char *name;
- pIFunctionParam params;
- pIFunction next;
-};
-
-typedef struct _imlib_variable
-{
- void *ptr;
- struct _imlib_variable *next;
-} IVariable;
-
-Imlib_Image __imlib_script_parse( Imlib_Image im, char *script, va_list );
-IFunctionParam *__imlib_script_parse_parameters( Imlib_Image im, char *parameters );
-Imlib_Image __imlib_script_parse_function( Imlib_Image im, char *function );
-void __imlib_script_tidyup(void);
-void *__imlib_script_get_next_var(void);
-void __imlib_script_add_var( void *ptr );
-
-#endif /* _FUNCTION_H_ */
diff --git a/src/span.c b/src/span.c
deleted file mode 100644
index fa7233b..0000000
--- a/src/span.c
+++ /dev/null
@@ -1,1160 +0,0 @@
-#include "common.h"
-#include "colormod.h"
-#include "image.h"
-#include "blend.h"
-#include "span.h"
-
-
-#define ADD_COPY(r, g, b, dest) \
- ADD_COLOR(R_VAL(dest), r, R_VAL(dest)); \
- ADD_COLOR(G_VAL(dest), g, G_VAL(dest)); \
- ADD_COLOR(B_VAL(dest), b, B_VAL(dest));
-
-#define SUB_COPY(r, g, b, dest) \
- SUB_COLOR(R_VAL(dest), r, R_VAL(dest)); \
- SUB_COLOR(G_VAL(dest), g, G_VAL(dest)); \
- SUB_COLOR(B_VAL(dest), b, B_VAL(dest));
-
-#define RE_COPY(r, g, b, dest) \
- RESHADE_COLOR(R_VAL(dest), r, R_VAL(dest)); \
- RESHADE_COLOR(G_VAL(dest), g, G_VAL(dest)); \
- RESHADE_COLOR(B_VAL(dest), b, B_VAL(dest));
-
-#define MULT(na, a0, a1, tmp) \
- tmp = ((a0) * (a1)) + 0x80; \
- na = (tmp + (tmp >> 8)) >> 8;
-
-
-extern DATA8 pow_lut[256][256];
-
-
-/* point drawing functions */
-
-/* COPY OPS */
-
-static void
-__imlib_CopyToRGBA(DATA32 color, DATA32 *dst)
-{
- *dst = color;
-}
-
-static void
-__imlib_CopyToRGB(DATA32 color, DATA32 *dst)
-{
- *dst = (*dst & 0xff000000) | (color & 0x00ffffff);
-}
-
-static void
-__imlib_BlendToRGB(DATA32 color, DATA32 *dst)
-{
- DATA32 tmp;
-
- BLEND(R_VAL(&color), G_VAL(&color), B_VAL(&color), A_VAL(&color), dst);
-}
-
-static void
-__imlib_BlendToRGBA(DATA32 color, DATA32 *dst)
-{
- DATA32 tmp;
- DATA8 a;
-
- a = pow_lut[A_VAL(&color)][A_VAL(dst)];
- BLEND_COLOR(A_VAL(&color), A_VAL(dst), 255, A_VAL(dst));
- BLEND(R_VAL(&color), G_VAL(&color), B_VAL(&color), a, dst);
-}
-
-
-/* ADD OPS */
-
-static void
-__imlib_AddCopyToRGBA(DATA32 color, DATA32 *dst)
-{
- DATA32 tmp;
-
- A_VAL(dst) = A_VAL(&color);
- ADD_COPY(R_VAL(&color), G_VAL(&color), B_VAL(&color), dst);
-}
-
-static void
-__imlib_AddCopyToRGB(DATA32 color, DATA32 *dst)
-{
- DATA32 tmp;
-
- ADD_COPY(R_VAL(&color), G_VAL(&color), B_VAL(&color), dst);
-}
-
-static void
-__imlib_AddBlendToRGB(DATA32 color, DATA32 *dst)
-{
- DATA32 tmp;
-
- BLEND_ADD(R_VAL(&color), G_VAL(&color), B_VAL(&color), A_VAL(&color), dst);
-}
-
-static void
-__imlib_AddBlendToRGBA(DATA32 color, DATA32 *dst)
-{
- DATA32 tmp;
- DATA8 a;
-
- a = pow_lut[A_VAL(&color)][A_VAL(dst)];
- BLEND_COLOR(A_VAL(&color), A_VAL(dst), 255, A_VAL(dst));
- BLEND_ADD(R_VAL(&color), G_VAL(&color), B_VAL(&color), a, dst);
-}
-
-
-/* SUBTRACT OPS */
-
-static void
-__imlib_SubCopyToRGBA(DATA32 color, DATA32 *dst)
-{
- DATA32 tmp;
-
- A_VAL(dst) = A_VAL(&color);
- SUB_COPY(R_VAL(&color), G_VAL(&color), B_VAL(&color), dst);
-}
-
-static void
-__imlib_SubCopyToRGB(DATA32 color, DATA32 *dst)
-{
- DATA32 tmp;
-
- SUB_COPY(R_VAL(&color), G_VAL(&color), B_VAL(&color), dst);
-}
-
-static void
-__imlib_SubBlendToRGB(DATA32 color, DATA32 *dst)
-{
- DATA32 tmp;
-
- BLEND_SUB(R_VAL(&color), G_VAL(&color), B_VAL(&color), A_VAL(&color), dst);
-}
-
-static void
-__imlib_SubBlendToRGBA(DATA32 color, DATA32 *dst)
-{
- DATA32 tmp;
- DATA8 a;
-
- a = pow_lut[A_VAL(&color)][A_VAL(dst)];
- BLEND_COLOR(A_VAL(&color), A_VAL(dst), 255, A_VAL(dst));
- BLEND_SUB(R_VAL(&color), G_VAL(&color), B_VAL(&color), a, dst);
-}
-
-
-/* RESHADE OPS */
-
-static void
-__imlib_ReCopyToRGBA(DATA32 color, DATA32 *dst)
-{
- DATA32 tmp;
-
- A_VAL(dst) = A_VAL(&color);
- RE_COPY(R_VAL(&color), G_VAL(&color), B_VAL(&color), dst);
-}
-
-static void
-__imlib_ReCopyToRGB(DATA32 color, DATA32 *dst)
-{
- DATA32 tmp;
-
- RE_COPY(R_VAL(&color), G_VAL(&color), B_VAL(&color), dst);
-}
-
-static void
-__imlib_ReBlendToRGB(DATA32 color, DATA32 *dst)
-{
- DATA32 tmp;
-
- BLEND_RE(R_VAL(&color), G_VAL(&color), B_VAL(&color), A_VAL(&color), dst);
-}
-
-static void
-__imlib_ReBlendToRGBA(DATA32 color, DATA32 *dst)
-{
- DATA32 tmp;
- DATA8 a;
-
- a = pow_lut[A_VAL(&color)][A_VAL(dst)];
- BLEND_COLOR(A_VAL(&color), A_VAL(dst), 255, A_VAL(dst));
- BLEND_RE(R_VAL(&color), G_VAL(&color), B_VAL(&color), a, dst);
-}
-
-
-/* span drawing functions* */
-
-/* COPY OPS */
-
-static void
-__imlib_CopySpanToRGBA(DATA32 color, DATA32 *dst, int len)
-{
- while (len--)
- {
- *dst = color;
- dst++;
- }
-}
-
-static void
-__imlib_CopySpanToRGB(DATA32 color, DATA32 *dst, int len)
-{
- while (len--)
- {
- *dst = (*dst & 0xff000000) | (color & 0x00ffffff);
- dst++;
- }
-}
-
-static void
-__imlib_BlendSpanToRGB(DATA32 color, DATA32 *dst, int len)
-{
- while (len--)
- {
- DATA32 tmp;
-
- BLEND(R_VAL(&color), G_VAL(&color), B_VAL(&color), A_VAL(&color), dst);
- dst++;
- }
-}
-
-static void
-__imlib_BlendSpanToRGBA(DATA32 color, DATA32 *dst, int len)
-{
- while (len--)
- {
- DATA32 tmp;
- DATA8 a;
-
- a = pow_lut[A_VAL(&color)][A_VAL(dst)];
- BLEND_COLOR(A_VAL(&color), A_VAL(dst), 255, A_VAL(dst));
- BLEND(R_VAL(&color), G_VAL(&color), B_VAL(&color), a, dst);
- dst++;
- }
-}
-
-
-/* ADD OPS */
-
-static void
-__imlib_AddCopySpanToRGBA(DATA32 color, DATA32 *dst, int len)
-{
- while (len--)
- {
- DATA32 tmp;
-
- A_VAL(dst) = A_VAL(&color);
- ADD_COPY(R_VAL(&color), G_VAL(&color), B_VAL(&color), dst);
- dst++;
- }
-}
-
-static void
-__imlib_AddCopySpanToRGB(DATA32 color, DATA32 *dst, int len)
-{
- while (len--)
- {
- DATA32 tmp;
-
- ADD_COPY(R_VAL(&color), G_VAL(&color), B_VAL(&color), dst);
- dst++;
- }
-}
-
-static void
-__imlib_AddBlendSpanToRGB(DATA32 color, DATA32 *dst, int len)
-{
- while (len--)
- {
- DATA32 tmp;
-
- BLEND_ADD(R_VAL(&color), G_VAL(&color), B_VAL(&color), A_VAL(&color), dst);
- dst++;
- }
-}
-
-static void
-__imlib_AddBlendSpanToRGBA(DATA32 color, DATA32 *dst, int len)
-{
- while (len--)
- {
- DATA32 tmp;
- DATA8 a;
-
- a = pow_lut[A_VAL(&color)][A_VAL(dst)];
- BLEND_COLOR(A_VAL(&color), A_VAL(dst), 255, A_VAL(dst));
- BLEND_ADD(R_VAL(&color), G_VAL(&color), B_VAL(&color), a, dst);
- dst++;
- }
-}
-
-
-/* SUBTRACT OPS */
-
-static void
-__imlib_SubCopySpanToRGBA(DATA32 color, DATA32 *dst, int len)
-{
- while (len--)
- {
- DATA32 tmp;
-
- A_VAL(dst) = A_VAL(&color);
- SUB_COPY(R_VAL(&color), G_VAL(&color), B_VAL(&color), dst);
- dst++;
- }
-}
-
-static void
-__imlib_SubCopySpanToRGB(DATA32 color, DATA32 *dst, int len)
-{
- while (len--)
- {
- DATA32 tmp;
-
- SUB_COPY(R_VAL(&color), G_VAL(&color), B_VAL(&color), dst);
- dst++;
- }
-}
-
-static void
-__imlib_SubBlendSpanToRGB(DATA32 color, DATA32 *dst, int len)
-{
- while (len--)
- {
- DATA32 tmp;
-
- BLEND_SUB(R_VAL(&color), G_VAL(&color), B_VAL(&color), A_VAL(&color), dst);
- dst++;
- }
-}
-
-static void
-__imlib_SubBlendSpanToRGBA(DATA32 color, DATA32 *dst, int len)
-{
- while (len--)
- {
- DATA32 tmp;
- DATA8 a;
-
- a = pow_lut[A_VAL(&color)][A_VAL(dst)];
- BLEND_COLOR(A_VAL(&color), A_VAL(dst), 255, A_VAL(dst));
- BLEND_SUB(R_VAL(&color), G_VAL(&color), B_VAL(&color), a, dst);
- dst++;
- }
-}
-
-
-/* RESHADE OPS */
-
-static void
-__imlib_ReCopySpanToRGBA(DATA32 color, DATA32 *dst, int len)
-{
- while (len--)
- {
- DATA32 tmp;
-
- A_VAL(dst) = A_VAL(&color);
- RE_COPY(R_VAL(&color), G_VAL(&color), B_VAL(&color), dst);
- dst++;
- }
-}
-
-static void
-__imlib_ReCopySpanToRGB(DATA32 color, DATA32 *dst, int len)
-{
- while (len--)
- {
- DATA32 tmp;
-
- RE_COPY(R_VAL(&color), G_VAL(&color), B_VAL(&color), dst);
- dst++;
- }
-}
-
-static void
-__imlib_ReBlendSpanToRGB(DATA32 color, DATA32 *dst, int len)
-{
- while (len--)
- {
- DATA32 tmp;
-
- BLEND_RE(R_VAL(&color), G_VAL(&color), B_VAL(&color), A_VAL(&color), dst);
- dst++;
- }
-}
-
-static void
-__imlib_ReBlendSpanToRGBA(DATA32 color, DATA32 *dst, int len)
-{
- while (len--)
- {
- DATA32 tmp;
- DATA8 a;
-
- a = pow_lut[A_VAL(&color)][A_VAL(dst)];
- BLEND_COLOR(A_VAL(&color), A_VAL(dst), 255, A_VAL(dst));
- BLEND_RE(R_VAL(&color), G_VAL(&color), B_VAL(&color), a, dst);
- dst++;
- }
-}
-
-
-
-/* shaped span drawing functions* */
-
-/* COPY OPS */
-
-static void
-__imlib_CopyShapedSpanToRGBA(DATA8 *src, DATA32 color, DATA32 *dst, int len)
-{
- DATA32 col = color;
-
- if (A_VAL(&color) < 255)
- {
- while (len--)
- {
- DATA32 tmp;
-
- switch (*src)
- {
- case 0: break;
- case 255: { *dst = color; break; }
- default:
- {
- MULT(A_VAL(&col), *src, A_VAL(&color), tmp);
- *dst = col;
- break;
- }
- }
- src++; dst++;
- }
- return;
- }
-
- while (len--)
- {
- switch (*src)
- {
- case 0: break;
- case 255: { *dst = color; break; }
- default:
- {
- A_VAL(&col) = *src;
- *dst = col;
- break;
- }
- }
- src++; dst++;
- }
-}
-
-static void
-__imlib_CopyShapedSpanToRGB(DATA8 *src, DATA32 color, DATA32 *dst, int len)
-{
- while (len--)
- {
- if (*src)
- *dst = (*dst & 0xff000000) | (color & 0x00ffffff);
-
- src++; dst++;
- }
-}
-
-static void
-__imlib_BlendShapedSpanToRGB(DATA8 *src, DATA32 color, DATA32 *dst, int len)
-{
- if (A_VAL(&color) < 255)
- {
- while (len--)
- {
- DATA32 tmp; DATA8 a;
-
- switch (*src)
- {
- case 0: break;
- case 255:
- {
- BLEND(R_VAL(&color), G_VAL(&color), B_VAL(&color), A_VAL(&color), dst);
- break;
- }
- default:
- {
- MULT(a, *src, A_VAL(&color), tmp);
- BLEND(R_VAL(&color), G_VAL(&color), B_VAL(&color), a, dst);
- break;
- }
- }
- src++; dst++;
- }
- return;
- }
-
- while (len--)
- {
- DATA32 tmp;
-
- switch (*src)
- {
- case 0: break;
- case 255:
- {
- *dst = (*dst & 0xff000000) | (color & 0x00ffffff);
- break;
- }
- default:
- {
- BLEND(R_VAL(&color), G_VAL(&color), B_VAL(&color), *src, dst);
- break;
- }
- }
- src++; dst++;
- }
-}
-
-static void
-__imlib_BlendShapedSpanToRGBA(DATA8 *src, DATA32 color, DATA32 *dst, int len)
-{
- if (A_VAL(&color) < 255)
- {
- while (len--)
- {
- DATA32 tmp; DATA8 a, aa;
-
- switch (*src)
- {
- case 0: break;
- case 255:
- {
- a = pow_lut[A_VAL(&color)][A_VAL(dst)];
- BLEND_COLOR(A_VAL(&color), A_VAL(dst), 255, A_VAL(dst));
- BLEND(R_VAL(&color), G_VAL(&color), B_VAL(&color), a, dst);
- break;
- }
- default:
- {
- MULT(aa, *src, A_VAL(&color), tmp);
- a = pow_lut[aa][A_VAL(dst)];
- BLEND_COLOR(aa, A_VAL(dst), 255, A_VAL(dst));
- BLEND(R_VAL(&color), G_VAL(&color), B_VAL(&color), a, dst);
- break;
- }
- }
- src++; dst++;
- }
- return;
- }
-
- while (len--)
- {
- DATA32 tmp; DATA8 a;
-
- switch (*src)
- {
- case 0: break;
- case 255:
- {
- *dst = color;
- break;
- }
- default:
- {
- a = pow_lut[*src][A_VAL(dst)];
- BLEND_COLOR(*src, A_VAL(dst), 255, A_VAL(dst));
- BLEND(R_VAL(&color), G_VAL(&color), B_VAL(&color), a, dst);
- break;
- }
- }
- src++; dst++;
- }
-}
-
-
-/* ADD OPS */
-
-static void
-__imlib_AddCopyShapedSpanToRGBA(DATA8 *src, DATA32 color, DATA32 *dst, int len)
-{
- if (A_VAL(&color) < 255)
- {
- while (len--)
- {
- DATA32 tmp;
-
- switch (*src)
- {
- case 0: break;
- case 255:
- {
- A_VAL(dst) = A_VAL(&color);
- ADD_COPY(R_VAL(&color), G_VAL(&color), B_VAL(&color), dst);
- break;
- }
- default:
- {
- MULT(A_VAL(dst), *src, A_VAL(&color), tmp);
- ADD_COPY(R_VAL(&color), G_VAL(&color), B_VAL(&color), dst);
- break;
- }
- }
- src++; dst++;
- }
- return;
- }
-
- while (len--)
- {
- DATA32 tmp;
-
- if (*src)
- {
- A_VAL(dst) = *src;
- ADD_COPY(R_VAL(&color), G_VAL(&color), B_VAL(&color), dst);
- }
- src++; dst++;
- }
-}
-
-static void
-__imlib_AddCopyShapedSpanToRGB(DATA8 *src, DATA32 color, DATA32 *dst, int len)
-{
- while (len--)
- {
- DATA32 tmp;
-
- if (*src)
- { ADD_COPY(R_VAL(&color), G_VAL(&color), B_VAL(&color), dst) }
-
- src++; dst++;
- }
-}
-
-static void
-__imlib_AddBlendShapedSpanToRGB(DATA8 *src, DATA32 color, DATA32 *dst, int len)
-{
- if (A_VAL(&color) < 255)
- {
- while (len--)
- {
- DATA32 tmp; DATA8 a;
-
- switch (*src)
- {
- case 0: break;
- case 255:
- {
- BLEND_ADD(R_VAL(&color), G_VAL(&color), B_VAL(&color), A_VAL(&color), dst);
- break;
- }
- default:
- {
- MULT(a, *src, A_VAL(&color), tmp);
- BLEND_ADD(R_VAL(&color), G_VAL(&color), B_VAL(&color), a, dst);
- break;
- }
- }
- src++; dst++;
- }
- return;
- }
-
- while (len--)
- {
- DATA32 tmp;
-
- switch (*src)
- {
- case 0: break;
- case 255:
- {
- ADD_COPY(R_VAL(&color), G_VAL(&color), B_VAL(&color), dst);
- break;
- }
- default:
- {
- BLEND_ADD(R_VAL(&color), G_VAL(&color), B_VAL(&color), *src, dst);
- break;
- }
- }
- src++; dst++;
- }
-}
-
-static void
-__imlib_AddBlendShapedSpanToRGBA(DATA8 *src, DATA32 color, DATA32 *dst, int len)
-{
- if (A_VAL(&color) < 255)
- {
- while (len--)
- {
- DATA32 tmp; DATA8 a, aa;
-
- switch (*src)
- {
- case 0: break;
- case 255:
- {
- a = pow_lut[A_VAL(&color)][A_VAL(dst)];
- BLEND_COLOR(A_VAL(&color), A_VAL(dst), 255, A_VAL(dst));
- BLEND_ADD(R_VAL(&color), G_VAL(&color), B_VAL(&color), a, dst);
- break;
- }
- default:
- {
- MULT(aa, *src, A_VAL(&color), tmp);
- a = pow_lut[aa][A_VAL(dst)];
- BLEND_COLOR(aa, A_VAL(dst), 255, A_VAL(dst));
- BLEND_ADD(R_VAL(&color), G_VAL(&color), B_VAL(&color), a, dst);
- break;
- }
- }
- src++; dst++;
- }
- return;
- }
-
- while (len--)
- {
- DATA32 tmp; DATA8 a;
-
- switch (*src)
- {
- case 0: break;
- case 255:
- {
- A_VAL(dst) = 255;
- ADD_COPY(R_VAL(&color), G_VAL(&color), B_VAL(&color), dst);
- break;
- }
- default:
- {
- a = pow_lut[*src][A_VAL(dst)];
- BLEND_COLOR(*src, A_VAL(dst), 255, A_VAL(dst));
- BLEND_ADD(R_VAL(&color), G_VAL(&color), B_VAL(&color), a, dst);
- break;
- }
- }
- src++; dst++;
- }
-}
-
-
-/* SUBTRACT OPS */
-
-static void
-__imlib_SubCopyShapedSpanToRGBA(DATA8 *src, DATA32 color, DATA32 *dst, int len)
-{
- if (A_VAL(&color) < 255)
- {
- while (len--)
- {
- DATA32 tmp;
-
- switch (*src)
- {
- case 0: break;
- case 255:
- {
- A_VAL(dst) = A_VAL(&color);
- SUB_COPY(R_VAL(&color), G_VAL(&color), B_VAL(&color), dst);
- break;
- }
- default:
- {
- MULT(A_VAL(dst), *src, A_VAL(&color), tmp);
- SUB_COPY(R_VAL(&color), G_VAL(&color), B_VAL(&color), dst);
- break;
- }
- }
- src++; dst++;
- }
- return;
- }
-
- while (len--)
- {
- DATA32 tmp;
-
- if (*src)
- {
- A_VAL(dst) = *src;
- SUB_COPY(R_VAL(&color), G_VAL(&color), B_VAL(&color), dst);
- }
- src++; dst++;
- }
-}
-
-static void
-__imlib_SubCopyShapedSpanToRGB(DATA8 *src, DATA32 color, DATA32 *dst, int len)
-{
- while (len--)
- {
- DATA32 tmp;
-
- if (*src)
- { SUB_COPY(R_VAL(&color), G_VAL(&color), B_VAL(&color), dst) }
-
- src++; dst++;
- }
-}
-
-static void
-__imlib_SubBlendShapedSpanToRGB(DATA8 *src, DATA32 color, DATA32 *dst, int len)
-{
- if (A_VAL(&color) < 255)
- {
- while (len--)
- {
- DATA32 tmp; DATA8 a;
-
- switch (*src)
- {
- case 0: break;
- case 255:
- {
- BLEND_SUB(R_VAL(&color), G_VAL(&color), B_VAL(&color), A_VAL(&color), dst);
- break;
- }
- default:
- {
- MULT(a, *src, A_VAL(&color), tmp);
- BLEND_SUB(R_VAL(&color), G_VAL(&color), B_VAL(&color), a, dst);
- break;
- }
- }
- src++; dst++;
- }
- return;
- }
-
- while (len--)
- {
- DATA32 tmp;
-
- switch (*src)
- {
- case 0: break;
- case 255:
- {
- SUB_COPY(R_VAL(&color), G_VAL(&color), B_VAL(&color), dst);
- break;
- }
- default:
- {
- BLEND_SUB(R_VAL(&color), G_VAL(&color), B_VAL(&color), *src, dst);
- break;
- }
- }
- src++; dst++;
- }
-}
-
-static void
-__imlib_SubBlendShapedSpanToRGBA(DATA8 *src, DATA32 color, DATA32 *dst, int len)
-{
- if (A_VAL(&color) < 255)
- {
- while (len--)
- {
- DATA32 tmp; DATA8 a, aa;
-
- switch (*src)
- {
- case 0: break;
- case 255:
- {
- a = pow_lut[A_VAL(&color)][A_VAL(dst)];
- BLEND_COLOR(A_VAL(&color), A_VAL(dst), 255, A_VAL(dst));
- BLEND_SUB(R_VAL(&color), G_VAL(&color), B_VAL(&color), a, dst);
- break;
- }
- default:
- {
- MULT(aa, *src, A_VAL(&color), tmp);
- a = pow_lut[aa][A_VAL(dst)];
- BLEND_COLOR(aa, A_VAL(dst), 255, A_VAL(dst));
- BLEND_SUB(R_VAL(&color), G_VAL(&color), B_VAL(&color), a, dst);
- break;
- }
- }
- src++; dst++;
- }
- return;
- }
-
- while (len--)
- {
- DATA32 tmp; DATA8 a;
-
- switch (*src)
- {
- case 0: break;
- case 255:
- {
- A_VAL(dst) = 255;
- SUB_COPY(R_VAL(&color), G_VAL(&color), B_VAL(&color), dst);
- break;
- }
- default:
- {
- a = pow_lut[*src][A_VAL(dst)];
- BLEND_COLOR(*src, A_VAL(dst), 255, A_VAL(dst));
- BLEND_SUB(R_VAL(&color), G_VAL(&color), B_VAL(&color), a, dst);
- break;
- }
- }
- src++; dst++;
- }
-}
-
-
-/* RESHADE OPS */
-
-static void
-__imlib_ReCopyShapedSpanToRGBA(DATA8 *src, DATA32 color, DATA32 *dst, int len)
-{
- if (A_VAL(&color) < 255)
- {
- while (len--)
- {
- DATA32 tmp;
-
- switch (*src)
- {
- case 0: break;
- case 255:
- {
- A_VAL(dst) = A_VAL(&color);
- RE_COPY(R_VAL(&color), G_VAL(&color), B_VAL(&color), dst);
- break;
- }
- default:
- {
- MULT(A_VAL(dst), *src, A_VAL(&color), tmp);
- RE_COPY(R_VAL(&color), G_VAL(&color), B_VAL(&color), dst);
- break;
- }
- }
- src++; dst++;
- }
- return;
- }
-
- while (len--)
- {
- DATA32 tmp;
-
- if (*src)
- {
- A_VAL(dst) = *src;
- RE_COPY(R_VAL(&color), G_VAL(&color), B_VAL(&color), dst);
- }
- src++; dst++;
- }
-}
-
-static void
-__imlib_ReCopyShapedSpanToRGB(DATA8 *src, DATA32 color, DATA32 *dst, int len)
-{
- while (len--)
- {
- DATA32 tmp;
-
- if (*src)
- { RE_COPY(R_VAL(&color), G_VAL(&color), B_VAL(&color), dst) }
-
- src++; dst++;
- }
-}
-
-static void
-__imlib_ReBlendShapedSpanToRGB(DATA8 *src, DATA32 color, DATA32 *dst, int len)
-{
- if (A_VAL(&color) < 255)
- {
- while (len--)
- {
- DATA32 tmp; DATA8 a;
-
- switch (*src)
- {
- case 0: break;
- case 255:
- {
- BLEND_RE(R_VAL(&color), G_VAL(&color), B_VAL(&color), A_VAL(&color), dst);
- break;
- }
- default:
- {
- MULT(a, *src, A_VAL(&color), tmp);
- BLEND_RE(R_VAL(&color), G_VAL(&color), B_VAL(&color), a, dst);
- break;
- }
- }
- src++; dst++;
- }
- return;
- }
-
- while (len--)
- {
- DATA32 tmp;
-
- switch (*src)
- {
- case 0: break;
- case 255:
- {
- RE_COPY(R_VAL(&color), G_VAL(&color), B_VAL(&color), dst);
- break;
- }
- default:
- {
- BLEND_RE(R_VAL(&color), G_VAL(&color), B_VAL(&color), *src, dst);
- break;
- }
- }
- src++; dst++;
- }
-}
-
-static void
-__imlib_ReBlendShapedSpanToRGBA(DATA8 *src, DATA32 color, DATA32 *dst, int len)
-{
- if (A_VAL(&color) < 255)
- {
- while (len--)
- {
- DATA32 tmp; DATA8 a, aa;
-
- switch (*src)
- {
- case 0: break;
- case 255:
- {
- a = pow_lut[A_VAL(&color)][A_VAL(dst)];
- BLEND_COLOR(A_VAL(&color), A_VAL(dst), 255, A_VAL(dst));
- BLEND_RE(R_VAL(&color), G_VAL(&color), B_VAL(&color), a, dst);
- break;
- }
- default:
- {
- MULT(aa, *src, A_VAL(&color), tmp);
- a = pow_lut[aa][A_VAL(dst)];
- BLEND_COLOR(aa, A_VAL(dst), 255, A_VAL(dst));
- BLEND_RE(R_VAL(&color), G_VAL(&color), B_VAL(&color), a, dst);
- break;
- }
- }
- src++; dst++;
- }
- return;
- }
-
- while (len--)
- {
- DATA32 tmp; DATA8 a;
-
- switch (*src)
- {
- case 0: break;
- case 255:
- {
- A_VAL(dst) = 255;
- RE_COPY(R_VAL(&color), G_VAL(&color), B_VAL(&color), dst);
- break;
- }
- default:
- {
- a = pow_lut[*src][A_VAL(dst)];
- BLEND_COLOR(*src, A_VAL(dst), 255, A_VAL(dst));
- BLEND_RE(R_VAL(&color), G_VAL(&color), B_VAL(&color), a, dst);
- break;
- }
- }
- src++; dst++;
- }
-}
-
-
-
-ImlibPointDrawFunction
-__imlib_GetPointDrawFunction(ImlibOp op, char dst_alpha, char blend)
-{
- /* [ operation ][ dst_alpha ][ blend ] */
- static ImlibPointDrawFunction ptfuncs[4][2][2] =
- /* OP_COPY */
- { { {__imlib_CopyToRGB, __imlib_BlendToRGB},
- {__imlib_CopyToRGBA, __imlib_BlendToRGBA} },
- /* OP_ADD */
- { {__imlib_AddCopyToRGB, __imlib_AddBlendToRGB},
- {__imlib_AddCopyToRGBA, __imlib_AddBlendToRGBA} },
- /* OP_SUBTRACT */
- { {__imlib_SubCopyToRGB, __imlib_SubBlendToRGB},
- {__imlib_SubCopyToRGBA, __imlib_SubBlendToRGBA} },
- /* OP_RESHADE */
- { {__imlib_ReCopyToRGB, __imlib_ReBlendToRGB},
- {__imlib_ReCopyToRGBA, __imlib_ReBlendToRGBA} }, };
-
- int opi = (op == OP_COPY) ? 0
- : (op == OP_ADD) ? 1
- : (op == OP_SUBTRACT) ? 2 : (op == OP_RESHADE) ? 3 : -1;
-
- if (opi == -1)
- return NULL;
-
- return ptfuncs[opi][!!dst_alpha][!!blend];
-}
-
-ImlibSpanDrawFunction
-__imlib_GetSpanDrawFunction(ImlibOp op, char dst_alpha, char blend)
-{
- static ImlibSpanDrawFunction spanfuncs[4][2][2] =
- /* OP_COPY */
- { { {__imlib_CopySpanToRGB, __imlib_BlendSpanToRGB},
- {__imlib_CopySpanToRGBA, __imlib_BlendSpanToRGBA} },
- /* OP_ADD */
- { {__imlib_AddCopySpanToRGB, __imlib_AddBlendSpanToRGB},
- {__imlib_AddCopySpanToRGBA, __imlib_AddBlendSpanToRGBA} },
- /* OP_SUBTRACT */
- { {__imlib_SubCopySpanToRGB, __imlib_SubBlendSpanToRGB},
- {__imlib_SubCopySpanToRGBA, __imlib_SubBlendSpanToRGBA} },
- /* OP_RESHADE */
- { {__imlib_ReCopySpanToRGB, __imlib_ReBlendSpanToRGB},
- {__imlib_ReCopySpanToRGBA, __imlib_ReBlendSpanToRGBA} }, };
-
- int opi = (op == OP_COPY) ? 0
- : (op == OP_ADD) ? 1
- : (op == OP_SUBTRACT) ? 2 : (op == OP_RESHADE) ? 3 : -1;
-
- if (opi == -1)
- return NULL;
-
- return spanfuncs[opi][!!dst_alpha][!!blend];
-}
-
-ImlibShapedSpanDrawFunction
-__imlib_GetShapedSpanDrawFunction(ImlibOp op, char dst_alpha, char blend)
-{
- static ImlibShapedSpanDrawFunction shapedspanfuncs[4][2][2] =
- /* OP_COPY */
- { { {__imlib_CopyShapedSpanToRGB, __imlib_BlendShapedSpanToRGB},
- {__imlib_CopyShapedSpanToRGBA, __imlib_BlendShapedSpanToRGBA} },
- /* OP_ADD */
- { {__imlib_AddCopyShapedSpanToRGB, __imlib_AddBlendShapedSpanToRGB},
- {__imlib_AddCopyShapedSpanToRGBA, __imlib_AddBlendShapedSpanToRGBA} },
- /* OP_SUBTRACT */
- { {__imlib_SubCopyShapedSpanToRGB, __imlib_SubBlendShapedSpanToRGB},
- {__imlib_SubCopyShapedSpanToRGBA, __imlib_SubBlendShapedSpanToRGBA} },
- /* OP_RESHADE */
- { {__imlib_ReCopyShapedSpanToRGB, __imlib_ReBlendShapedSpanToRGB},
- {__imlib_ReCopyShapedSpanToRGBA, __imlib_ReBlendShapedSpanToRGBA} }, };
-
- int opi = (op == OP_COPY) ? 0
- : (op == OP_ADD) ? 1
- : (op == OP_SUBTRACT) ? 2 : (op == OP_RESHADE) ? 3 : -1;
-
- if (opi == -1)
- return NULL;
-
- return shapedspanfuncs[opi][!!dst_alpha][!!blend];
-}
-
diff --git a/src/span.h b/src/span.h
deleted file mode 100644
index 149aa24..0000000
--- a/src/span.h
+++ /dev/null
@@ -1,24 +0,0 @@
-#ifndef __SPAN
-#define __SPAN 1
-
-
-typedef void (*ImlibPointDrawFunction)(DATA32, DATA32 *);
-
-ImlibPointDrawFunction
-__imlib_GetPointDrawFunction(ImlibOp op, char dst_alpha, char blend);
-
-
-typedef void (*ImlibSpanDrawFunction)(DATA32, DATA32 *, int);
-
-ImlibSpanDrawFunction
-__imlib_GetSpanDrawFunction(ImlibOp op, char dst_alpha, char blend);
-
-
-typedef void (*ImlibShapedSpanDrawFunction)(DATA8 *, DATA32, DATA32 *, int);
-
-ImlibShapedSpanDrawFunction
-__imlib_GetShapedSpanDrawFunction(ImlibOp op, char dst_alpha, char blend);
-
-
-#endif
-
diff --git a/src/updates.c b/src/updates.c
deleted file mode 100644
index c96c2e8..0000000
--- a/src/updates.c
+++ /dev/null
@@ -1,195 +0,0 @@
-#include "common.h"
-#include "updates.h"
-
-enum _t_used {
- T_UNUSED = 0,
- T_USED = 1
-};
-
-struct _tile {
- enum _t_used used;
-};
-
-#define TBITS 5
-#define TB TBITS
-#define TM ((1 << TBITS) - 1)
-#define TS (1 << TBITS)
-
-#define T(x, y) t[((y) * tw) + (x)]
-
-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;
-
- /* if theres no rects to process.. return NULL */
- if (!u)
- return NULL;
- tw = w >> TB;
- if (w & TM)
- tw++;
- th = h >> TB;
- if (h & TM)
- th++;
- t = malloc(tw * th * sizeof(struct _tile));
- /* 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;
- }
- /* 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;
- }
- }
- /* scan each line - if > hgapmax gaps between tiles, then fill smallest */
- 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--;
- }
- }
- }
- 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));
- }
- }
- }
- free(t);
- __imlib_FreeUpdates(u);
- return nu;
-}
-
-ImlibUpdate *
-__imlib_AddUpdate(ImlibUpdate * u, int x, int y, int w, int h)
-{
- ImlibUpdate *nu;
-
- if ((w < 1) || (h < 1) || ((x + w) < 1) || ((y + h) < 1))
- return u;
- nu = malloc(sizeof(ImlibUpdate));
- nu->x = x;
- nu->y = y;
- nu->w = w;
- nu->h = h;
- nu->next = u;
- return nu;
-}
-
-void
-__imlib_FreeUpdates(ImlibUpdate * u)
-{
- ImlibUpdate *uu;
-
- uu = u;
- while (uu)
- {
- u = uu;
- uu = uu->next;
- free(u);
- }
-}
-
-ImlibUpdate *
-__imlib_DupUpdates(ImlibUpdate * u)
-{
- ImlibUpdate *uu, *cu, *pu, *ru;
-
- if (!u)
- return NULL;
-
- uu = malloc(sizeof(ImlibUpdate));
- memcpy(uu, u, sizeof(ImlibUpdate));
- cu = u->next;
- pu = u;
- ru = uu;
- while (cu)
- {
- uu = malloc(sizeof(ImlibUpdate));
- memcpy(uu, u, sizeof(ImlibUpdate));
- pu->next = uu;
- pu = cu;
- cu = cu->next;
- }
- return ru;
-}
diff --git a/src/updates.h b/src/updates.h
deleted file mode 100644
index 4730751..0000000
--- a/src/updates.h
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef __UPDATES
-#define __UPDATES 1
-typedef struct _imlibupdate ImlibUpdate;
-
-struct _imlibupdate
-{
- int x, y, w, h;
- ImlibUpdate *next;
-};
-
-ImlibUpdate *__imlib_AddUpdate(ImlibUpdate *u, int x, int y, int w, int h);
-ImlibUpdate *__imlib_MergeUpdate(ImlibUpdate *u, int w, int h, int hgapmax);
-void __imlib_FreeUpdates(ImlibUpdate *u);
-ImlibUpdate *__imlib_DupUpdates(ImlibUpdate *u);
-
-#endif
diff --git a/src/ximage.c b/src/ximage.c
deleted file mode 100644
index b9c765d..0000000
--- a/src/ximage.c
+++ /dev/null
@@ -1,326 +0,0 @@
-#include "common.h"
-#ifndef X_DISPLAY_MISSING
-#include <X11/Xlib.h>
-#include <X11/extensions/XShm.h>
-#include <X11/Xutil.h>
-#include <sys/ipc.h>
-#include <sys/shm.h>
-#include "ximage.h"
-#endif
-
-/* static private variables */
-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;
-
-/* temporary X error catcher we use later */
-static char _x_err = 0;
-
-/* the fucntion we use for catching the error */
-static void
-TmpXError(Display * d, XErrorEvent * ev)
-{
- _x_err = 1;
- return;
- d = NULL;
- ev = NULL;
-}
-
-void
-__imlib_SetMaxXImageCount(Display * d, int num)
-{
- list_max_count = num;
- __imlib_FlushXImage(d);
-}
-
-int
-__imlib_GetMaxXImageCount(Display * d)
-{
- return list_max_count;
- d = NULL;
-}
-
-void
-__imlib_SetMaxXImageTotalSize(Display * d, int num)
-{
- list_max_mem = num;
- __imlib_FlushXImage(d);
-}
-
-int
-__imlib_GetMaxXImageTotalSize(Display * d)
-{
- return list_max_mem;
- d = NULL;
-}
-
-void
-__imlib_FlushXImage(Display * d)
-{
- int i;
- XImage *xim;
- char did_free = 1;
-
- while (((list_mem_use > list_max_mem) || (list_num > list_max_count)) &&
- (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;
- }
- }
- }
-}
-
-/* free (consume == opposite of produce) the XImage (mark as unused) */
-void
-__imlib_ConsumeXImage(Display * d, XImage * xim)
-{
- 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;
- }
- }
-}
-
-/* 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 *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;
- }
- /* find a cached XImage (to avoid server to & fro) that is big enough */
- /* for our needs and the right depth */
- *shared = 0;
- /* go thru the current image list */
- for (i = 0; i < list_num; i++)
- {
- int depth_ok = 0;
-
- /* 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]->bits_per_pixel == 32) && (depth == 24)) )
- depth_ok = 1;
- if ( depth_ok &&
- (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);
- }
- 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_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;
- }
- }
- }
- /* 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;
- }
- /* flush unused images from the image list */
- __imlib_FlushXImage(d);
- /* return out image */
- return xim;
-}
diff --git a/src/ximage.h b/src/ximage.h
deleted file mode 100644
index 25b339b..0000000
--- a/src/ximage.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef __XIMAGE
-#define __XIMAGE 1
-void __imlib_SetMaxXImageCount(Display *d, int num);
-int __imlib_GetMaxXImageCount(Display *d);
-void __imlib_SetMaxXImageTotalSize(Display *d, int num);
-int __imlib_GetMaxXImageTotalSize(Display *d);
-void __imlib_FlushXImage(Display *d);
-void __imlib_ConsumeXImage(Display *d, XImage *xim);
-XImage *__imlib_ProduceXImage(Display *d, Visual *v, int depth, int w, int h, char *shared);
-#endif
diff --git a/test/.cvsignore b/test/.cvsignore
deleted file mode 100644
index ce9b038..0000000
--- a/test/.cvsignore
+++ /dev/null
@@ -1,27 +0,0 @@
-config.guess
-config.h.in
-config.sub
-ltconfig
-ltmain.sh
-aclocal.m4
-stamp-h.in
-Makefile.in
-configure
-config.log
-config.h
-config.cache
-libtool
-config.status
-stamp-h
-Makefile
-.deps
-.libs
-*.lo
-*.la
-imlib2
-loaderpath.h
-.icons
-bumpmaptest
-imlib2_test
-polytest
-core
diff --git a/test/Makefile.am b/test/Makefile.am
deleted file mode 100644
index fb12766..0000000
--- a/test/Makefile.am
+++ /dev/null
@@ -1,61 +0,0 @@
-## Process this file with automake to produce Makefile.in
-
-AUTOMAKE_OPTIONS = 1.4 foreign
-
-# A list of all the files in the current directory which can be regenerated
-MAINTAINERCLEANFILES = Makefile.in
-
-LDFLAGS = -L/usr/X11R6/lib
-INCLUDES = -I. -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)
-
-if HAVE_X
-
-bin_PROGRAMS = imlib2 bumpmaptest imlib2_test polytest color_spaces
-imlib2_SOURCES = main.c
-imlib2_LDADD = $(top_builddir)/src/libImlib2.la
-
-bumpmaptest_SOURCES = bmtest.c
-bumpmaptest_LDADD = $(top_builddir)/src/libImlib2.la
-
-imlib2_test_SOURCES = imlib2_test.c
-imlib2_test_LDADD = $(top_builddir)/src/libImlib2.la
-
-polytest_SOURCES = polytest.c
-polytest_LDADD = $(top_builddir)/src/libImlib2.la
-
-color_spaces_SOURCES = color_spaces.c
-color_spaces_LDADD = $(top_builddir)/src/libImlib2.la
-
-endif
-
-EXTRA_DIST = \
-test_images/audio.png \
-test_images/bg.png \
-test_images/bulb.png \
-test_images/cal.png \
-test_images/calc.png \
-test_images/folder.png \
-test_images/globe.png \
-test_images/imlib2.png \
-test_images/lock.png \
-test_images/mail.png \
-test_images/menu.png \
-test_images/mush.png \
-test_images/paper.png \
-test_images/sh1.png \
-test_images/sh2.png \
-test_images/sh3.png \
-test_images/stop.png \
-test_images/tnt.png \
-ttfonts/cinema.ttf \
-ttfonts/grunge.ttf \
-ttfonts/morpheus.ttf \
-ttfonts/notepad.ttf \
-bmtest.c \
-color_spaces.c \
-imlib2_test.c \
-main.c \
-polytest.c
diff --git a/test/bmtest.c b/test/bmtest.c
deleted file mode 100644
index 5a48138..0000000
--- a/test/bmtest.c
+++ /dev/null
@@ -1,127 +0,0 @@
-#include <X11/Xlib.h>
-#include <X11/extensions/XShm.h>
-#include <X11/Xutil.h>
-#include <X11/extensions/shape.h>
-#include <X11/Xatom.h>
-#include <X11/Xos.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <math.h>
-
-/*
-#include <sys/time.h>
-#include "common.h"
-#include "image.h"
-#include "rend.h"
-#include "rgba.h"
-#include "ximage.h"
-#include "color.h"
- */
-#include "Imlib2.h"
-
-Display *disp;
-Window win;
-Visual *vis;
-Colormap cm;
-int depth;
-
-int
-main(int argc, char **argv)
-{
- 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);
- XMapWindow(disp, win);
-
- /**
- * Start rendering
- */
- printf("Rendering\n");
- imlib_context_set_display(disp);
- imlib_context_set_visual(vis);
- imlib_context_set_colormap(cm);
- imlib_context_set_drawable(win);
- 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);
- 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);
-
- 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
deleted file mode 100644
index c5cc593..0000000
--- a/test/color_spaces.c
+++ /dev/null
@@ -1,142 +0,0 @@
-#include <X11/Xlib.h>
-#include <X11/extensions/XShm.h>
-#include <X11/Xutil.h>
-#include <X11/extensions/shape.h>
-#include <X11/Xatom.h>
-#include <X11/Xos.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <math.h>
-
-#include "Imlib2.h"
-
-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;
-
- /**
- * 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 | KeyPressMask);
- XMapWindow(disp, win);
-
- /**
- * Start rendering
- */
- imlib_set_font_cache_size(512 * 1024);
- imlib_add_path_to_font_path("./ttfonts");
- imlib_context_set_display(disp);
- imlib_context_set_visual(vis);
- imlib_context_set_colormap(cm);
- imlib_context_set_drawable(win);
- imlib_context_set_blend(0);
- imlib_context_set_color_modifier(NULL);
- imlib_context_set_blend(0);
-
- im_bg = imlib_create_image(600, 400);
- imlib_context_set_image(im_bg);
- w = imlib_image_get_width();
- h = imlib_image_get_height();
- imlib_context_set_color(128, 128, 255, 255);
- imlib_image_fill_rectangle(0, 0, w, h);
- XResizeWindow(disp, win, w, h);
- 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;
-
- }
- }
- 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_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/ 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);
- }
- return 0;
-}
diff --git a/test/imlib2_test.c b/test/imlib2_test.c
deleted file mode 100644
index 68d01aa..0000000
--- a/test/imlib2_test.c
+++ /dev/null
@@ -1,273 +0,0 @@
-/* include X11 stuff */
-#include <X11/Xlib.h>
-/* include Imlib2 stuff */
-#include <Imlib2.h>
-/* sprintf include */
-#include <stdio.h>
-
-/* some globals for our window & X display */
-Display *disp;
-Window win;
-Visual *vis;
-Colormap cm;
-int depth;
-
-/* the program... */
-int
-main(int argc, char **argv)
-{
- /* events we get from X */
- XEvent ev;
-
- /* areas to update */
- Imlib_Updates updates, current_update;
-
- /* our virtual framebuffer image we draw into */
- Imlib_Image buffer;
-
- /* a font */
- Imlib_Font font;
-
- /* our color range */
- Imlib_Color_Range range;
-
- /* our mouse x, y coordinates */
- int mouse_x = 0, mouse_y = 0;
-
- /* connect to X */
- 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));
- depth = DefaultDepth(disp, DefaultScreen(disp));
- cm = DefaultColormap(disp, DefaultScreen(disp));
- /* create a window 640x480 */
- 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);
- /* show the window */
- XMapWindow(disp, win);
- /* set our cache to 2 Mb so it doesnt have to go hit the disk as long as */
- /* the images we use use less than 2Mb of RAM (that is uncompressed) */
- imlib_set_cache_size(2048 * 1024);
- /* set the font cache to 512Kb - again to avoid re-loading */
- imlib_set_font_cache_size(512 * 1024);
- /* add the ./ttfonts dir to our font path - you'll want a notepad.ttf */
- /* in that dir for the text to display */
- imlib_add_path_to_font_path("./ttfonts");
- /* set the maximum number of colors to allocate for 8bpp and less to 128 */
- imlib_set_color_usage(128);
- /* dither for depths < 24bpp */
- imlib_context_set_dither(1);
- /* set the display , visual, colormap and drawable we are using */
- imlib_context_set_display(disp);
- imlib_context_set_visual(vis);
- imlib_context_set_colormap(cm);
- imlib_context_set_drawable(win);
- /* 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;
-
- /* 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 */
- }
- return 0;
-}
diff --git a/test/main.c b/test/main.c
deleted file mode 100644
index 1f5a0e3..0000000
--- a/test/main.c
+++ /dev/null
@@ -1,1377 +0,0 @@
-#include <X11/Xlib.h>
-#include <X11/extensions/XShm.h>
-#include <X11/Xutil.h>
-#include <X11/extensions/shape.h>
-#include <X11/Xatom.h>
-#include <X11/Xos.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <math.h>
-#include <locale.h>
-
-/*
-#include <sys/time.h>
-#include "common.h"
-#include "image.h"
-#include "rend.h"
-#include "rgba.h"
-#include "ximage.h"
-#include "color.h"
- */
-#include "Imlib2.h"
-
-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)
-{
- imlib_context_set_display(disp);
- imlib_context_set_visual(vis);
- imlib_context_set_colormap(cm);
- imlib_context_set_drawable(win);
- imlib_context_set_dither(0);
- imlib_context_set_blend(0);
- 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);
-}
-
-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;
- 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;
-
- /* now we'll set the locale */
- setlocale(LC_ALL, "");
- if (!XSupportsLocale())
- 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;
- }
-
- 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];
- }
-
- /**
- * 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);
- }
- }
-
- 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);
- }
-
- 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);
- }
-
- /**
- * 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_anti_alias(aa);
- imlib_context_set_dither(dith);
- imlib_context_set_blend(blend);
- 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 */
-
- 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);
-
- 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);
-
- 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);
-
-#define A90 (3.141592654 / 2)
- if (pol)
- {
- 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);
- 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;
- }
- }
-
- 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);
- }
- }
- }
-
- // 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 (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_blend_image_onto_image(im, 0, 0, 0, w, h, 0, 0, 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();
- }
- 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();
- }
- 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());
-
- }
-/*
- 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);
- }
- }
- }
-/*
- 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_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;
- }
- }
-
- /**
- * 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 */
- 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);
- printf("%3.3f Mpixels / sec\n", (double)(pixels) / (sec * 1000000));
- return 0;
-}
diff --git a/test/polytest.c b/test/polytest.c
deleted file mode 100644
index c7d5d72..0000000
--- a/test/polytest.c
+++ /dev/null
@@ -1,126 +0,0 @@
-#include <X11/Xlib.h>
-#include <X11/extensions/XShm.h>
-#include <X11/Xutil.h>
-#include <X11/extensions/shape.h>
-#include <X11/Xatom.h>
-#include <X11/Xos.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <math.h>
-
-#include "Imlib2.h"
-
-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;
-
- /**
- * 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 | KeyPressMask);
- XMapWindow(disp, win);
-
- /**
- * Start rendering
- */
- imlib_context_set_display(disp);
- imlib_context_set_visual(vis);
- imlib_context_set_colormap(cm);
- imlib_context_set_drawable(win);
- imlib_context_set_blend(0);
- imlib_context_set_color_modifier(NULL);
- imlib_context_set_blend(0);
-
- im_bg = imlib_create_image(400, 400);
- imlib_context_set_image(im_bg);
- w = imlib_image_get_width();
- h = imlib_image_get_height();
- imlib_context_set_color(0, 0, 0, 255);
- imlib_image_fill_rectangle(0, 0, w, h);
- XResizeWindow(disp, win, w, h);
- XSync(disp, False);
-
- poly = imlib_polygon_new();
- imlib_polygon_add_point(poly, 20, 20);
- imlib_polygon_add_point(poly, 70, 20);
- imlib_polygon_add_point(poly, 70, 70);
- imlib_polygon_add_point(poly, 20, 70);
-
- poly1 = imlib_polygon_new();
- imlib_polygon_add_point(poly1, 100, 20);
- imlib_polygon_add_point(poly1, 190, 100);
- imlib_polygon_add_point(poly1, 120, 70);
-
- poly2 = imlib_polygon_new();
- imlib_polygon_add_point(poly2, 290, 20);
- imlib_polygon_add_point(poly2, 200, 100);
- 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;
-
- }
- }
- 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);
- }
- return 0;
-}
diff --git a/test/test_images/.cvsignore b/test/test_images/.cvsignore
deleted file mode 100644
index e895077..0000000
--- a/test/test_images/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-.icons
diff --git a/test/test_images/audio.png b/test/test_images/audio.png
deleted file mode 100644
index 01c0611..0000000
--- a/test/test_images/audio.png
+++ /dev/null
Binary files differ
diff --git a/test/test_images/bg.png b/test/test_images/bg.png
deleted file mode 100644
index 3ca990a..0000000
--- a/test/test_images/bg.png
+++ /dev/null
Binary files differ
diff --git a/test/test_images/bulb.png b/test/test_images/bulb.png
deleted file mode 100644
index 757e599..0000000
--- a/test/test_images/bulb.png
+++ /dev/null
Binary files differ
diff --git a/test/test_images/cal.png b/test/test_images/cal.png
deleted file mode 100644
index 889f329..0000000
--- a/test/test_images/cal.png
+++ /dev/null
Binary files differ
diff --git a/test/test_images/calc.png b/test/test_images/calc.png
deleted file mode 100644
index 812237b..0000000
--- a/test/test_images/calc.png
+++ /dev/null
Binary files differ
diff --git a/test/test_images/folder.png b/test/test_images/folder.png
deleted file mode 100644
index 9a32d03..0000000
--- a/test/test_images/folder.png
+++ /dev/null
Binary files differ
diff --git a/test/test_images/globe.png b/test/test_images/globe.png
deleted file mode 100644
index b52af4b..0000000
--- a/test/test_images/globe.png
+++ /dev/null
Binary files differ
diff --git a/test/test_images/imlib2.png b/test/test_images/imlib2.png
deleted file mode 100644
index 63fea4f..0000000
--- a/test/test_images/imlib2.png
+++ /dev/null
Binary files differ
diff --git a/test/test_images/lock.png b/test/test_images/lock.png
deleted file mode 100644
index 548b4e9..0000000
--- a/test/test_images/lock.png
+++ /dev/null
Binary files differ
diff --git a/test/test_images/mail.png b/test/test_images/mail.png
deleted file mode 100644
index 5247b3f..0000000
--- a/test/test_images/mail.png
+++ /dev/null
Binary files differ
diff --git a/test/test_images/menu.png b/test/test_images/menu.png
deleted file mode 100644
index ab5d833..0000000
--- a/test/test_images/menu.png
+++ /dev/null
Binary files differ
diff --git a/test/test_images/mush.png b/test/test_images/mush.png
deleted file mode 100644
index 0a4b0d0..0000000
--- a/test/test_images/mush.png
+++ /dev/null
Binary files differ
diff --git a/test/test_images/paper.png b/test/test_images/paper.png
deleted file mode 100644
index f6bbc6d..0000000
--- a/test/test_images/paper.png
+++ /dev/null
Binary files differ
diff --git a/test/test_images/sh1.png b/test/test_images/sh1.png
deleted file mode 100644
index c7dcb66..0000000
--- a/test/test_images/sh1.png
+++ /dev/null
Binary files differ
diff --git a/test/test_images/sh2.png b/test/test_images/sh2.png
deleted file mode 100644
index e4dee7a..0000000
--- a/test/test_images/sh2.png
+++ /dev/null
Binary files differ
diff --git a/test/test_images/sh3.png b/test/test_images/sh3.png
deleted file mode 100644
index f15b892..0000000
--- a/test/test_images/sh3.png
+++ /dev/null
Binary files differ
diff --git a/test/test_images/stop.png b/test/test_images/stop.png
deleted file mode 100644
index cc7830e..0000000
--- a/test/test_images/stop.png
+++ /dev/null
Binary files differ
diff --git a/test/test_images/tnt.png b/test/test_images/tnt.png
deleted file mode 100644
index 14e2266..0000000
--- a/test/test_images/tnt.png
+++ /dev/null
Binary files differ
diff --git a/test/ttfonts/cinema.ttf b/test/ttfonts/cinema.ttf
deleted file mode 100644
index 326a820..0000000
--- a/test/ttfonts/cinema.ttf
+++ /dev/null
Binary files differ
diff --git a/test/ttfonts/grunge.ttf b/test/ttfonts/grunge.ttf
deleted file mode 100644
index deba7da..0000000
--- a/test/ttfonts/grunge.ttf
+++ /dev/null
Binary files differ
diff --git a/test/ttfonts/morpheus.ttf b/test/ttfonts/morpheus.ttf
deleted file mode 100644
index 46e19a2..0000000
--- a/test/ttfonts/morpheus.ttf
+++ /dev/null
Binary files differ
diff --git a/test/ttfonts/notepad.ttf b/test/ttfonts/notepad.ttf
deleted file mode 100644
index 4e165ce..0000000
--- a/test/ttfonts/notepad.ttf
+++ /dev/null
Binary files differ