diff options
-rw-r--r-- | COPYING | 6 | ||||
-rw-r--r-- | ChangeLog | 31 | ||||
-rw-r--r-- | Makefile.in | 47 | ||||
-rw-r--r-- | README | 9 | ||||
-rw-r--r-- | TODO | 2 | ||||
-rw-r--r-- | config.hin | 3 | ||||
-rwxr-xr-x | configure | 67 | ||||
-rw-r--r-- | configure.ac | 17 | ||||
-rw-r--r-- | dist-generated | 2 | ||||
-rw-r--r-- | flatspec.c | 2 | ||||
-rw-r--r-- | flatten.c | 136 | ||||
-rw-r--r-- | flatten.h | 2 | ||||
-rw-r--r-- | io-unix.c | 2 | ||||
-rw-r--r-- | mancombine.pl | 2 | ||||
-rw-r--r-- | mkenumsc.pl | 2 | ||||
-rw-r--r-- | mkenumsh.pl | 2 | ||||
-rw-r--r-- | mkopti.pl | 2 | ||||
-rw-r--r-- | mktablec.pl | 40 | ||||
-rw-r--r-- | options.i | 4 | ||||
-rw-r--r-- | palette.c | 4 | ||||
-rw-r--r-- | palette.h | 2 | ||||
-rw-r--r-- | pixels.c | 7 | ||||
-rw-r--r-- | pixels.h | 12 | ||||
-rw-r--r-- | scaletab.c | 42 | ||||
-rw-r--r-- | test/answer/Addition.png | bin | 1236 -> 1542 bytes | |||
-rw-r--r-- | test/answer/Burn.png | bin | 1501 -> 2120 bytes | |||
-rw-r--r-- | test/answer/Color.png | bin | 0 -> 2172 bytes | |||
-rw-r--r-- | test/answer/DarkenOnly.png | bin | 1056 -> 1341 bytes | |||
-rw-r--r-- | test/answer/Difference.png | bin | 1823 -> 2057 bytes | |||
-rw-r--r-- | test/answer/Divide.png | bin | 1750 -> 2463 bytes | |||
-rw-r--r-- | test/answer/Dodge.png | bin | 2076 -> 2508 bytes | |||
-rw-r--r-- | test/answer/GrainExtract.png | bin | 1523 -> 2013 bytes | |||
-rw-r--r-- | test/answer/GrainMerge.png | bin | 1506 -> 1906 bytes | |||
-rw-r--r-- | test/answer/Hardlight.png | bin | 2142 -> 3042 bytes | |||
-rw-r--r-- | test/answer/Hue.png | bin | 0 -> 1659 bytes | |||
-rw-r--r-- | test/answer/LightenOnly.png | bin | 1035 -> 1353 bytes | |||
-rw-r--r-- | test/answer/Multiply.png | bin | 2255 -> 2964 bytes | |||
-rw-r--r-- | test/answer/Overlay.png | bin | 1364 -> 2090 bytes | |||
-rw-r--r-- | test/answer/Saturation.png | bin | 0 -> 2005 bytes | |||
-rw-r--r-- | test/answer/Screen.png | bin | 2235 -> 2970 bytes | |||
-rw-r--r-- | test/answer/Subtract.png | bin | 1438 -> 1592 bytes | |||
-rw-r--r-- | test/answer/Value.png | bin | 0 -> 1351 bytes | |||
-rw-r--r-- | test/answer/crisp1.png | bin | 248 -> 331 bytes | |||
-rw-r--r-- | test/answer/huetest.png | bin | 0 -> 308 bytes | |||
-rw-r--r-- | test/answer/index4.png | bin | 309 -> 315 bytes | |||
-rw-r--r-- | test/answer/indextest.png | bin | 438 -> 448 bytes | |||
-rw-r--r-- | test/answer/modeA.png | bin | 243 -> 410 bytes | |||
-rw-r--r-- | test/answer/modeB.png | bin | 491 -> 495 bytes | |||
-rwxr-xr-x | test/dotest | 212 | ||||
-rw-r--r-- | test/source/huetest.xcf.gz | bin | 0 -> 635 bytes | |||
-rw-r--r-- | test/source/indextest.xcf.gz | bin | 941 -> 943 bytes | |||
-rw-r--r-- | test/source/mkmodebase.c | 17 | ||||
-rw-r--r-- | test/source/modetest.xcf.gz | bin | 836 -> 792 bytes | |||
-rw-r--r-- | test/source/truncated.xcf | bin | 0 -> 455 bytes | |||
-rw-r--r-- | utils.c | 6 | ||||
-rw-r--r-- | xcf-general.c | 2 | ||||
-rw-r--r-- | xcf2png.10 | 13 | ||||
-rw-r--r-- | xcf2png.c | 4 | ||||
-rw-r--r-- | xcf2pnm.10 | 13 | ||||
-rw-r--r-- | xcf2pnm.c | 4 | ||||
-rw-r--r-- | xcfinfo.10 | 4 | ||||
-rw-r--r-- | xcfinfo.c | 2 | ||||
-rw-r--r-- | xcftools.h | 2 |
63 files changed, 576 insertions, 148 deletions
@@ -2,7 +2,7 @@ Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -305,7 +305,7 @@ the "copyright" line and a pointer to where the full notice is found. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. @@ -313,7 +313,7 @@ Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: - Gnomovision version 69, Copyright (C) year name of author + Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. @@ -1,5 +1,36 @@ +2006-02-12 Henning Makholm <henning@makholm.net> + + * Version 0.9 + * Add layer mode Color. Now all of the Gimp's layer modes are + supported. :-) + * Revamp the test suite inputs once again (they did not cover all + combinations of colored pixels vs fully white or blacK). + + * Version 0.8.1 + * Add layer modes Hue, Value, Saturation and tests for same. + +2006-02-11 Henning Makholm <henning@makholm.net> + + * Version 0.8 + * Add tests of various error diagnostics to the test suite + * Revamp some of the test suite inputs such that HSV space + layer modes can be tested with the same files. + + * Version 0.7.2 + * Do not precompute the big multiplication table by default, + it is quick enough to do it at run-time as needed (which + lets the binaries shrink significantly). + +2006-02-07 Henning Makholm <henning@makholm.net> + + * Respect -A option when generating indexed PNG (that is, + create a tRNS chunk even if it's trivial); add test of + -A in xcf2png to the test suite. + 2006-01-29 Henning Makholm <henning@makholm.net> + * Update FSF address in GPL blurbs + * Version 0.7.1 * A few cosmetic changes done during debianization * The code now passes the testsuite on several Debian diff --git a/Makefile.in b/Makefile.in index 6dc0cef..0967124 100644 --- a/Makefile.in +++ b/Makefile.in @@ -12,12 +12,10 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA all: -@SET_MAKE@ - srcdir = @srcdir@ prefix = @prefix@ exec_prefix = @exec_prefix@ @@ -30,7 +28,7 @@ APPNAME = @PACKAGE_TARNAME@ program_transform_name = @program_transform_name@ CFLAGS = @CFLAGS@ -LDFLAGS = @LDFLAGS@ +LDFLAGS = @LDFLAGS@ @LIBICONV@ LIBS = @LIBS@ INSTALL = @INSTALL@ @@ -44,6 +42,12 @@ PERL = @PERL@ o = @OBJEXT@ e = @EXEEXT@ +# Allow using Makefile.in directly for cleaning and distmaking purposes +ifneq (,$(findstring @,$o)) +e = +srcdir = . +endif + ############################################################################# FILEIO = io-unix @@ -60,11 +64,11 @@ xcfinfo$e: xcfinfo.$o $(FILEIO).$o enums.$o xcf-general.$o utils.$o $(CC) $(LDFLAGS) $(LIBS) $^ -o $@ xcf2pnm$e: xcf2pnm.$o $(FILEIO).$o enums.$o xcf-general.$o utils.$o \ - pixels.$o flatten.$o flatspec.$o table.$o + pixels.$o flatten.$o flatspec.$o scaletab.$o table.$o $(CC) $(LDFLAGS) $(LIBS) $^ -o $@ xcf2png$e: xcf2png.$o $(FILEIO).$o enums.$o xcf-general.$o utils.$o \ - pixels.$o flatten.$o flatspec.$o table.$o palette.$o + pixels.$o flatten.$o flatspec.$o scaletab.$o table.$o palette.$o $(CC) $(LDFLAGS) $(LIBS) -lpng $^ -o $@ testscale$e: testscale.$o @@ -87,7 +91,7 @@ enums.h: mkenumsh.pl $(ENUMSOURCES) $(PERL) $< $(ENUMSOURCES) > $@ enums.c: mkenumsc.pl enums.h $(PERL) $< enums.h > $@ -table.c: mktablec.pl +table.c: mktablec.pl config.h $(PERL) $< > $@ %.oi: options.i mkopti.pl config.h @@ -103,6 +107,7 @@ table.c: mktablec.pl COMMON_HEADERS = xcftools.h config.h enums.h enums.$o: enums.h table.$o: $(COMMON_HEADERS) pixels.h +scaletab.$o: $(COMMON_HEADERS) pixels.h io-unix.$o: $(COMMON_HEADERS) xcf-general.$o: $(COMMON_HEADERS) utils.$o: $(COMMON_HEADERS) @@ -141,6 +146,7 @@ realclean: distclean # # Tarball-making rule +ifeq (,$(findstring @,$o)) dist: ajour distclean noncvs > notcvsfiles || cp dist-generated notcvsfiles diff -u dist-generated notcvsfiles @@ -148,35 +154,44 @@ dist: ajour distclean find . -type f -print | grep -v CVS | grep -v debian | \ sed 's!^\./!$(APPNAME)-$(VERSION)/!' | sort -o tar-manifest ln -s . $(APPNAME)-$(VERSION) - tar cvzf $(APPNAME)-$(VERSION).tar.gz `cat tar-manifest` + GZIP=-9 tar cvzf $(APPNAME)-$(VERSION).tar.gz `cat tar-manifest` rm tar-manifest rm $(APPNAME)-$(VERSION) +else +dist: ajour + $(MAKE) dist +endif + ############################################################################# # # Autofoo rules: -aclocal.m4: configure.ac +aclocal.m4$(SUPPRESS_AUTOFOO): configure.ac aclocal -$(srcdir)/configure: configure.ac aclocal.m4 +$(srcdir)/configure$(SUPPRESS_AUTOFOO): configure.ac aclocal.m4 cd $(srcdir) && autoconf -$(srcdir)/config.hin: configure.ac aclocal.m4 +$(srcdir)/config.hin$(SUPPRESS_AUTOFOO): configure.ac aclocal.m4 cd $(srcdir) && autoheader touch $@ -config.status: $(srcdir)/configure - ./config.status --recheck +config.status: $(srcdir)/configure config.sub config.guess + if [ -f config.status ] ; \ + then ./config.status --recheck ; \ + else ./configure ; fi -Makefile: Makefile.in config.status +Makefile$(SUPPRESS_AUTOFOO): Makefile.in config.status ./config.status $@ config.h: config.hin config.status ./config.status $@ touch $@ -ajour: Makefile config.h config.sub config.guess +ajour: Makefile config.h config.sub config.guess: - -test -r /usr/share/misc/$@ && cp /usr/share/misc/$@ .
\ No newline at end of file + -test -r /usr/share/misc/$@ && cp /usr/share/misc/$@ . + +.PHONY: ajour dist @@ -49,6 +49,13 @@ should compile the tools and install them in /usr/local. The 'configure' script is generated by GNU autoconf, and accepts the arguments that such scripts commonly do. +You can use + ./configure --enable-precomputed-scaletable +to precompute lookup tables for pixel composing at compile time. +Normally these tables are initialized at run time if a layer that +needs them is detected. Precomputing them may improve performance +by a few percent, at the cost of doubling the size of each binary. + License ======= @@ -66,4 +73,4 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA @@ -1,8 +1,6 @@ These are things I want to do before bumping the version number of Xcftools to 1.0: -- Add tests of error reporting to the test suite. - - Finish localization infrastucture (some work has been done but is not completely systematic). @@ -72,6 +72,9 @@ /* Define to the version of this package. */ #undef PACKAGE_VERSION +/* Define to use a precomputed multiplication table (adds 64 KB per binary) */ +#undef PRECOMPUTED_SCALETABLE + /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.59 for Xcftools 0.7.1. +# Generated by GNU Autoconf 2.59 for Xcftools 0.9. # # Report bugs to <henning@makholm.net>. # @@ -273,8 +273,8 @@ SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME='Xcftools' PACKAGE_TARNAME='xcftools' -PACKAGE_VERSION='0.7.1' -PACKAGE_STRING='Xcftools 0.7.1' +PACKAGE_VERSION='0.9' +PACKAGE_STRING='Xcftools 0.9' PACKAGE_BUGREPORT='henning@makholm.net' ac_unique_file="xcfinfo.c" @@ -315,7 +315,7 @@ ac_includes_default="\ # include <unistd.h> #endif" -ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS SET_MAKE INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT build build_cpu build_vendor build_os host host_cpu host_vendor host_os CPP EGREP LIBICONV LTLIBICONV PERL LIBOBJS LTLIBOBJS' +ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT build build_cpu build_vendor build_os host host_cpu host_vendor host_os CPP EGREP LIBICONV LTLIBICONV PERL LIBOBJS LTLIBOBJS' ac_subst_files='' # Initialize some variables set by options. @@ -784,7 +784,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures Xcftools 0.7.1 to adapt to many kinds of systems. +\`configure' configures Xcftools 0.9 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -850,13 +850,16 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of Xcftools 0.7.1:";; + short | recursive ) echo "Configuration of Xcftools 0.9:";; esac cat <<\_ACEOF Optional Features: --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --enable-precomputed-scaletable + Use precomputed multiplication table (adds 64 KB per + binary) --disable-rpath do not hardcode runtime library paths Optional Packages: @@ -974,7 +977,7 @@ fi test -n "$ac_init_help" && exit 0 if $ac_init_version; then cat <<\_ACEOF -Xcftools configure 0.7.1 +Xcftools configure 0.9 generated by GNU Autoconf 2.59 Copyright (C) 2003 Free Software Foundation, Inc. @@ -992,7 +995,7 @@ cat >&5 <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by Xcftools $as_me 0.7.1, which was +It was created by Xcftools $as_me 0.9, which was generated by GNU Autoconf 2.59. Invocation command line was $ $0 $@ @@ -1331,35 +1334,6 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu -echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5 -echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6 -set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,:./+-,___p_,'` -if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.make <<\_ACEOF -all: - @echo 'ac_maketemp="$(MAKE)"' -_ACEOF -# GNU make sometimes prints "make[1]: Entering...", which would confuse us. -eval `${MAKE-make} -f conftest.make 2>/dev/null | grep temp=` -if test -n "$ac_maketemp"; then - eval ac_cv_prog_make_${ac_make}_set=yes -else - eval ac_cv_prog_make_${ac_make}_set=no -fi -rm -f conftest.make -fi -if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then - echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6 - SET_MAKE= -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 - SET_MAKE="MAKE=${MAKE-make}" -fi - ac_aux_dir= for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do if test -f $ac_dir/install-sh; then @@ -1478,6 +1452,16 @@ program_transform_name=`echo $program_transform_name | sed -f conftest.sed` rm conftest.sed +# Check whether --enable-precomputed-scaletable or --disable-precomputed-scaletable was given. +if test "${enable_precomputed_scaletable+set}" = set; then + enableval="$enable_precomputed_scaletable" + +cat >>confdefs.h <<\_ACEOF +#define PRECOMPUTED_SCALETABLE 1 +_ACEOF + +fi; + ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -4760,7 +4744,7 @@ fi ac_config_headers="$ac_config_headers config.h:config.hin" - ac_config_files="$ac_config_files Makefile" + ac_config_files="$ac_config_files Makefile:Makefile.in" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure @@ -5124,7 +5108,7 @@ _ASBOX } >&5 cat >&5 <<_CSEOF -This file was extended by Xcftools $as_me 0.7.1, which was +This file was extended by Xcftools $as_me 0.9, which was generated by GNU Autoconf 2.59. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -5184,7 +5168,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ -Xcftools config.status 0.7.1 +Xcftools config.status 0.9 configured by $0, generated by GNU Autoconf 2.59, with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" @@ -5287,7 +5271,7 @@ for ac_config_target in $ac_config_targets do case "$ac_config_target" in # Handling of arguments. - "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;; + "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile:Makefile.in" ;; "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h:config.hin" ;; *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 echo "$as_me: error: invalid argument: $ac_config_target" >&2;} @@ -5373,7 +5357,6 @@ s,@ECHO_C@,$ECHO_C,;t t s,@ECHO_N@,$ECHO_N,;t t s,@ECHO_T@,$ECHO_T,;t t s,@LIBS@,$LIBS,;t t -s,@SET_MAKE@,$SET_MAKE,;t t s,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t s,@INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t s,@INSTALL_DATA@,$INSTALL_DATA,;t t diff --git a/configure.ac b/configure.ac index 849a5d6..952c429 100644 --- a/configure.ac +++ b/configure.ac @@ -13,20 +13,26 @@ dnl GNU General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, write to the Free Software -dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA dnl dnl ------------------------ dnl The following line is the MASTER SOURCE for the version number -AC_INIT(Xcftools,0.7.1,henning@makholm.net,xcftools) +AC_INIT(Xcftools,0.9,henning@makholm.net,xcftools) AC_COPYRIGHT(General copyright notice for AC_PACKAGE_NAME: [@COPYRIGHT@ Henning Makholm] ) AC_CONFIG_SRCDIR(xcfinfo.c) -AC_PROG_MAKE_SET AC_PROG_INSTALL AC_ARG_PROGRAM +AC_ARG_ENABLE(precomputed-scaletable, + AC_HELP_STRING([--enable-precomputed-scaletable], + [Use precomputed multiplication table (adds 64 KB per binary)]), + [AC_DEFINE(PRECOMPUTED_SCALETABLE,1, + [Define to use a precomputed multiplication table (adds 64 KB per binary)] + )]) + AC_PROG_CC case $GCC::$CFLAGS in yes::*-Wall* ) ;; yes::*) CFLAGS="$CFLAGS -Wall" ;; @@ -46,10 +52,11 @@ AC_CHECK_HEADERS(inttypes.h netinet/in.h arpa/inet.h getopt.h) AC_CHECK_FUNCS(getopt_long strcasecmp) AC_FUNC_MMAP +dnl AM_GNU_GETTEXT(external) AM_ICONV AC_CHECK_PROG(PERL,perl,perl) - + AC_CONFIG_HEADERS(config.h:config.hin) -AC_CONFIG_FILES(Makefile) +AC_CONFIG_FILES(Makefile:Makefile.in) AC_OUTPUT diff --git a/dist-generated b/dist-generated index 2656aed..81650d1 100644 --- a/dist-generated +++ b/dist-generated @@ -1,4 +1,6 @@ aclocal.m4 +config.guess config.hin +config.sub configure notcvsfiles @@ -13,7 +13,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "xcftools.h" @@ -13,7 +13,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "xcftools.h" @@ -96,6 +96,8 @@ merge_normal(struct Tile *bot, struct Tile *top) break ; } + INIT_SCALETABLE_IF( !(top->summary & TILESUMMARY_CRISP) ); + /* Otherwise bot wins, but is forever changed ... */ if( (top->summary & TILESUMMARY_ALLNULL) == 0 ) { unsigned i ; @@ -220,10 +222,39 @@ ucombine_GRAIN_MERGE(uint8_t bot,uint8_t top) return temp < 0 ? 0 : temp >= 256 ? 255 : temp ; } +struct HSV { + enum { HUE_RED_GREEN_BLUE,HUE_RED_BLUE_GREEN,HUE_BLUE_RED_GREEN, + HUE_BLUE_GREEN_RED,HUE_GREEN_BLUE_RED,HUE_GREEN_RED_BLUE } hue; + unsigned ch1, ch2, ch3 ; +}; +static void +RGBtoHSV(rgba rgb,struct HSV *hsv) +{ + unsigned RED = (uint8_t)(rgb >> RED_SHIFT); + unsigned GREEN = (uint8_t)(rgb >> GREEN_SHIFT); + unsigned BLUE = (uint8_t)(rgb >> BLUE_SHIFT) ; + #define HEXTANT(b,m,t) hsv->ch1 = b, hsv->ch2 = m, hsv->ch3 = t, \ + hsv->hue = HUE_ ## b ## _ ## m ## _ ## t + if( GREEN <= RED ) + if( BLUE <= RED ) + if( GREEN <= BLUE ) + HEXTANT(GREEN,BLUE,RED); + else + HEXTANT(BLUE,GREEN,RED); + else + HEXTANT(GREEN,RED,BLUE); + else if( BLUE <= RED ) + HEXTANT(BLUE,RED,GREEN); + else if( BLUE <= GREEN ) + HEXTANT(RED,BLUE,GREEN); + else + HEXTANT(RED,GREEN,BLUE); + #undef HEXTANT +} /* merge_exotic() destructively updates bot. - * merge_exotoc() reads but does not free top. + * merge_exotic() reads but does not free top. */ static void __ATTRIBUTE__((noinline)) merge_exotic(struct Tile *bot, const struct Tile *top, @@ -236,16 +267,18 @@ merge_exotic(struct Tile *bot, const struct Tile *top, assert( bot->refcount == 1 ); /* The transparency status of bot never changes */ + INIT_SCALETABLE_IF(1); + for( i=0; i < top->count ; i++ ) { - uint32_t red, green, blue ; + uint32_t RED, GREEN, BLUE ; if( NULLALPHA(bot->pixels[i]) || NULLALPHA(top->pixels[i]) ) continue ; #define UNIFORM(mode) case GIMP_ ## mode ## _MODE: \ - red = ucombine_ ## mode (bot->pixels[i]>>RED_SHIFT , \ + RED = ucombine_ ## mode (bot->pixels[i]>>RED_SHIFT , \ top->pixels[i]>>RED_SHIFT ); \ - green = ucombine_ ## mode (bot->pixels[i]>>GREEN_SHIFT, \ + GREEN = ucombine_ ## mode (bot->pixels[i]>>GREEN_SHIFT, \ top->pixels[i]>>GREEN_SHIFT); \ - blue = ucombine_ ## mode (bot->pixels[i]>>BLUE_SHIFT , \ + BLUE = ucombine_ ## mode (bot->pixels[i]>>BLUE_SHIFT , \ top->pixels[i]>>BLUE_SHIFT ); \ break ; switch( mode ) { @@ -267,14 +300,92 @@ merge_exotic(struct Tile *bot, const struct Tile *top, UNIFORM(HARDLIGHT); UNIFORM(GRAIN_EXTRACT); UNIFORM(GRAIN_MERGE); + case GIMP_HUE_MODE: + case GIMP_SATURATION_MODE: + case GIMP_VALUE_MODE: + case GIMP_COLOR_MODE: + { + static struct HSV hsvTop, hsvBot ; + RGBtoHSV(top->pixels[i],&hsvTop); + if( mode == GIMP_HUE_MODE && hsvTop.ch1 == hsvTop.ch3 ) + continue ; + RGBtoHSV(bot->pixels[i],&hsvBot); + if( mode == GIMP_VALUE_MODE ) { + if( hsvBot.ch3 ) { + hsvBot.ch1 = (hsvBot.ch1*hsvTop.ch3 + hsvBot.ch3/2) / hsvBot.ch3; + hsvBot.ch2 = (hsvBot.ch2*hsvTop.ch3 + hsvBot.ch3/2) / hsvBot.ch3; + hsvBot.ch3 = hsvTop.ch3 ; + } else { + hsvBot.ch1 = hsvBot.ch2 = hsvBot.ch3 = hsvTop.ch3 ; + } + } else { + unsigned mfNum, mfDenom ; + if( mode == GIMP_HUE_MODE || mode == GIMP_COLOR_MODE ) { + mfNum = hsvTop.ch2-hsvTop.ch1 ; + mfDenom = hsvTop.ch3-hsvTop.ch1 ; + hsvBot.hue = hsvTop.hue ; + } else { + mfNum = hsvBot.ch2-hsvBot.ch1 ; + mfDenom = hsvBot.ch3-hsvBot.ch1 ; + } + if( mode == GIMP_SATURATION_MODE ) { + if( hsvTop.ch3 == 0 ) + hsvBot.ch1 = hsvBot.ch3 ; /* Black has no saturation */ + else + hsvBot.ch1 = (hsvTop.ch1*hsvBot.ch3 + hsvTop.ch3/2) / hsvTop.ch3; + } else if( mode == GIMP_COLOR_MODE ) { + /* GIMP_COLOR_MODE works in HSL space instead of HSV. We must + * transfer H and S, keeping the L = ch1+ch3 of the bottom pixel, + * but the S we transfer works differently from the S in HSV. + */ + unsigned L = hsvTop.ch1 + hsvTop.ch3 ; + unsigned sNum = hsvTop.ch3 - hsvTop.ch1 ; + unsigned sDenom = L < 256 ? L : 510-L ; + if( sDenom == 0 ) sDenom = 1 ; /* sNum will be 0 */ + L = hsvBot.ch1 + hsvBot.ch3 ; + if( L < 256 ) { + /* Ideally we want to compute L/2 * (1-sNum/sDenom) + * But shuffle this a bit so we can use integer arithmetic. + * The "-1" in the rounding prevents us from ending up with + * ch1 > ch3. + */ + hsvBot.ch1 = (L*(sDenom-sNum)+sDenom-1)/(2*sDenom); + hsvBot.ch3 = L - hsvBot.ch1 ; + } else { + /* Here our goal is 255 - (510-L)/2 * (1-sNum/sDenom) */ + hsvBot.ch3 = 255 - ((510-L)*(sDenom-sNum)+sDenom-1)/(2*sDenom); + hsvBot.ch1 = L - hsvBot.ch3 ; + } + assert(hsvBot.ch3 <= 255); + assert(hsvBot.ch3 >= hsvBot.ch1); + } + if( mfDenom == 0 ) + hsvBot.ch2 = hsvBot.ch1 ; + else + hsvBot.ch2 = hsvBot.ch1 + + (mfNum*(hsvBot.ch3-hsvBot.ch1) + mfDenom/2) / mfDenom ; + } + switch( hsvBot.hue ) { + #define HEXTANT(b,m,t) case HUE_ ## b ## _ ## m ## _ ## t : \ + b = hsvBot.ch1; m = hsvBot.ch2; t = hsvBot.ch3; break; + HEXTANT(RED,GREEN,BLUE); + HEXTANT(RED,BLUE,GREEN); + HEXTANT(BLUE,RED,GREEN); + HEXTANT(BLUE,GREEN,RED); + HEXTANT(GREEN,BLUE,RED); + HEXTANT(GREEN,RED,BLUE); + #undef HEXTANT + } + break ; + } default: FatalUnsupportedXCF(_("'%s' layer mode"),showGimpLayerModeEffects(mode)); } if( FULLALPHA(bot->pixels[i] & top->pixels[i]) ) bot->pixels[i] = (bot->pixels[i] & (255 << ALPHA_SHIFT)) + - (red << RED_SHIFT) + - (green << GREEN_SHIFT) + - (blue << BLUE_SHIFT) ; + (RED << RED_SHIFT) + + (GREEN << GREEN_SHIFT) + + (BLUE << BLUE_SHIFT) ; else { rgba bp = bot->pixels[i] ; /* In a sane world, the alpha of the top pixel would simply be @@ -291,9 +402,9 @@ merge_exotic(struct Tile *bot, const struct Tile *top, tfrac = (256*pseudotop - 1) / alpha ; } bot->pixels[i] = (bp & (255 << ALPHA_SHIFT)) + - ((rgba)scaletable[ tfrac ][ red ] << RED_SHIFT ) + - ((rgba)scaletable[ tfrac ][ green ] << GREEN_SHIFT) + - ((rgba)scaletable[ tfrac ][ blue ] << BLUE_SHIFT ) + + ((rgba)scaletable[ tfrac ][ RED ] << RED_SHIFT ) + + ((rgba)scaletable[ tfrac ][ GREEN ] << GREEN_SHIFT) + + ((rgba)scaletable[ tfrac ][ BLUE ] << BLUE_SHIFT ) + ((rgba)scaletable[255^tfrac][255&(bp>>RED_SHIFT )] << RED_SHIFT ) + ((rgba)scaletable[255^tfrac][255&(bp>>GREEN_SHIFT)] << GREEN_SHIFT) + ((rgba)scaletable[255^tfrac][255&(bp>>BLUE_SHIFT )] << BLUE_SHIFT ) ; @@ -461,6 +572,7 @@ addBackground(struct FlattenSpec *spec, struct Tile *tile) if( tileSummary(tile) & TILESUMMARY_ALLNULL ) { fillTile(tile,spec->default_pixel); } else { + INIT_SCALETABLE_IF( !(tile->summary & TILESUMMARY_CRISP) ); for( i=0; i<tile->count; i++ ) if( NULLALPHA(tile->pixels[i]) ) tile->pixels[i] = spec->default_pixel ; @@ -13,7 +13,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef FLATTEN_H @@ -13,7 +13,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "xcftools.h" diff --git a/mancombine.pl b/mancombine.pl index 3de2919..25f377e 100644 --- a/mancombine.pl +++ b/mancombine.pl @@ -13,7 +13,7 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA use strict ; use warnings ; diff --git a/mkenumsc.pl b/mkenumsc.pl index 25542ac..5ea9829 100644 --- a/mkenumsc.pl +++ b/mkenumsc.pl @@ -14,7 +14,7 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA use strict ; use warnings ; diff --git a/mkenumsh.pl b/mkenumsh.pl index 7ac52d3..ac1a8de 100644 --- a/mkenumsh.pl +++ b/mkenumsh.pl @@ -14,7 +14,7 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA use strict ; use warnings ; @@ -14,7 +14,7 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA use strict ; use warnings ; diff --git a/mktablec.pl b/mktablec.pl index 32bb0d0..6467af0 100644 --- a/mktablec.pl +++ b/mktablec.pl @@ -13,7 +13,7 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA use strict ; use warnings ; @@ -35,19 +35,37 @@ sub shipsubarray (@) { print "\n" ; } +my $precompute_it = 1 ; +if( open CONFIGH, "<", "config.h" ) { + $precompute_it = 0 ; + while( <CONFIGH> ) { + if( /\#\s*define\s+PRECOMPUTED_SCALETABLE/ ) { + $precompute_it = 1 ; + last ; + } + } + close CONFIGH ; +} + print "/* Autogenerated by $0 */\n" ; print "#include \"pixels.h\"\n" ; -print "const uint8_t scaletable[256][256] = {\n" ; -for my $p ( 0..255 ) { - shipsubarray( map { int(($p*$_+127)/255) } ( 0 .. 255 ) ); - # This formula has the property that - # scaletable[p][q] + scaletable[255-p][q] == q - # for all uint8_t values of p and q. - # This is important in order that a partially transparent - # pixel does not change the color of the underlying pixel - # unless the two pixels have different colors. +print "#ifdef PRECOMPUTED_SCALETABLE\n" ; +if( $precompute_it ) { + print "const uint8_t scaletable[256][256] = {\n" ; + for my $p ( 0..255 ) { + shipsubarray( map { int(($p*$_+127)/255) } ( 0 .. 255 ) ); + # This formula has the property that + # scaletable[p][q] + scaletable[255-p][q] == q + # for all uint8_t values of p and q. + # This is important in order that a partially transparent + # pixel does not change the color of the underlying pixel + # unless the two pixels have different colors. + } + print "};\n" ; +} else { + print "#error PRECOMPUTED_SCALETABLE was not defined at generation time\n"; } -print "};\n" ; +print "#endif\n" ; if(0) { @@ -13,7 +13,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ OPTIONGROUP(1i,General options); @@ -345,7 +345,7 @@ OPTION(301,--percent,(n) set opacity in percent, int n ; sscanf(optarg,"%u%n",&pct,&n) ; if( n != strlen(optarg) || pct > 100 ) - FatalGeneric(20,_("The argument to --pct is not a percentage")); + FatalGeneric(20,_("The argument to --percent is not a percentage")); lastlayerspec(&flatspec,"--percent")->opacity = pct * 255 / 100 ; break ; } @@ -13,7 +13,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "palette.h" @@ -31,8 +31,8 @@ * 0x00, 0x11, 0x22, ..., 0xDD, 0xEE, 0xFF. */ -rgba palette[MAX_PALETTE] ; unsigned paletteSize ; +rgba palette[MAX_PALETTE] ; static int masterhash[HASH_SIZE]; static int bucketlinks[MAX_PALETTE]; @@ -13,7 +13,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef PALETTE_H @@ -13,7 +13,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #define DEBUG @@ -438,6 +438,7 @@ applyMask(struct Tile *tile, struct Tile *mask) unsigned i ; assertTileCompatibility(tile,mask); assert( tile->count == mask->count ); + INIT_SCALETABLE_IF(1); invalidateSummary(tile,0); for( i=0; i < tile->count ;i++ ) tile->pixels[i] = NEWALPHA(tile->pixels[i], @@ -471,9 +472,11 @@ getLayerTile(struct xcfLayer *layer,const struct rect *where) applyMask(data,mask); } if( layer->opacity < 255 ) { - const uint8_t *ourtable = scaletable[layer->opacity] ; + const uint8_t *ourtable ; int i ; invalidateSummary(data,~(TILESUMMARY_CRISP | TILESUMMARY_ALLFULL)); + INIT_SCALETABLE_IF(1); + ourtable = scaletable[layer->opacity] ; for( i=0; i < data->count; i++ ) data->pixels[i] = NEWALPHA(data->pixels[i],ourtable[ALPHA(data->pixels[i])]) ; @@ -13,7 +13,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef PIXELS_H @@ -53,7 +53,17 @@ typedef uint32_t rgba ; #define NULLALPHA(rgba) ((uint8_t)(rgba) == 0) #define NEWALPHA(rgb,a) (((rgba)(rgb) & 0xFFFFFF00) + (a)) +#ifdef PRECOMPUTED_SCALETABLE extern const uint8_t scaletable[256][256] ; +#define INIT_SCALETABLE_IF(foo) ((void)0) +#else +extern uint8_t scaletable[256][256] ; +extern int ok_scaletable ; +void mk_scaletable(void); +#define INIT_SCALETABLE_IF(foo) \ + (ok_scaletable || !(foo) || (mk_scaletable(),0) ) +#endif + extern const rgba graytable[256] ; extern rgba colormap[256] ; extern unsigned colormapLength ; diff --git a/scaletab.c b/scaletab.c new file mode 100644 index 0000000..c09867e --- /dev/null +++ b/scaletab.c @@ -0,0 +1,42 @@ +/* Run-time scaletable computation for Xcftools + * + * Copyright (C) 2006 Henning Makholm + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "pixels.h" +#ifndef PRECOMPUTED_SCALETABLE + +uint8_t scaletable[256][256] ; +int ok_scaletable = 0 ; + +void +mk_scaletable(void) +{ + unsigned p, q, r ; + if( ok_scaletable ) return ; + for( p = 0 ; p < 128 ; p++ ) + for( q = 0 ; q <= p ; q++ ) { + r = (p*q+127)/255 ; + scaletable[p][q] = scaletable[q][p] = r ; + scaletable[255-p][q] = scaletable[q][255-p] = q-r ; + scaletable[p][255-q] = scaletable[255-q][p] = p-r ; + scaletable[255-p][255-q] = scaletable[255-q][255-p] = (255-q)-(p-r) ; + } + ok_scaletable = 1 ; +} + +#endif + diff --git a/test/answer/Addition.png b/test/answer/Addition.png Binary files differindex 93024de..c974f38 100644 --- a/test/answer/Addition.png +++ b/test/answer/Addition.png diff --git a/test/answer/Burn.png b/test/answer/Burn.png Binary files differindex b6e747e..d4e9907 100644 --- a/test/answer/Burn.png +++ b/test/answer/Burn.png diff --git a/test/answer/Color.png b/test/answer/Color.png Binary files differnew file mode 100644 index 0000000..f419579 --- /dev/null +++ b/test/answer/Color.png diff --git a/test/answer/DarkenOnly.png b/test/answer/DarkenOnly.png Binary files differindex 58f71dd..9248c9b 100644 --- a/test/answer/DarkenOnly.png +++ b/test/answer/DarkenOnly.png diff --git a/test/answer/Difference.png b/test/answer/Difference.png Binary files differindex 9a1c5fb..21e9bea 100644 --- a/test/answer/Difference.png +++ b/test/answer/Difference.png diff --git a/test/answer/Divide.png b/test/answer/Divide.png Binary files differindex a7668ec..d0be2ee 100644 --- a/test/answer/Divide.png +++ b/test/answer/Divide.png diff --git a/test/answer/Dodge.png b/test/answer/Dodge.png Binary files differindex 05d274b..7d76847 100644 --- a/test/answer/Dodge.png +++ b/test/answer/Dodge.png diff --git a/test/answer/GrainExtract.png b/test/answer/GrainExtract.png Binary files differindex c386af2..724bed5 100644 --- a/test/answer/GrainExtract.png +++ b/test/answer/GrainExtract.png diff --git a/test/answer/GrainMerge.png b/test/answer/GrainMerge.png Binary files differindex 616e232..0ca919b 100644 --- a/test/answer/GrainMerge.png +++ b/test/answer/GrainMerge.png diff --git a/test/answer/Hardlight.png b/test/answer/Hardlight.png Binary files differindex 8a4739d..27b6284 100644 --- a/test/answer/Hardlight.png +++ b/test/answer/Hardlight.png diff --git a/test/answer/Hue.png b/test/answer/Hue.png Binary files differnew file mode 100644 index 0000000..8acb1b3 --- /dev/null +++ b/test/answer/Hue.png diff --git a/test/answer/LightenOnly.png b/test/answer/LightenOnly.png Binary files differindex bb2200f..893fbf7 100644 --- a/test/answer/LightenOnly.png +++ b/test/answer/LightenOnly.png diff --git a/test/answer/Multiply.png b/test/answer/Multiply.png Binary files differindex 17e43b1..083165c 100644 --- a/test/answer/Multiply.png +++ b/test/answer/Multiply.png diff --git a/test/answer/Overlay.png b/test/answer/Overlay.png Binary files differindex 628d2b5..ce47807 100644 --- a/test/answer/Overlay.png +++ b/test/answer/Overlay.png diff --git a/test/answer/Saturation.png b/test/answer/Saturation.png Binary files differnew file mode 100644 index 0000000..dd20b06 --- /dev/null +++ b/test/answer/Saturation.png diff --git a/test/answer/Screen.png b/test/answer/Screen.png Binary files differindex 9335e59..438c005 100644 --- a/test/answer/Screen.png +++ b/test/answer/Screen.png diff --git a/test/answer/Subtract.png b/test/answer/Subtract.png Binary files differindex e5f03c5..9b68cbd 100644 --- a/test/answer/Subtract.png +++ b/test/answer/Subtract.png diff --git a/test/answer/Value.png b/test/answer/Value.png Binary files differnew file mode 100644 index 0000000..1b259ca --- /dev/null +++ b/test/answer/Value.png diff --git a/test/answer/crisp1.png b/test/answer/crisp1.png Binary files differindex 927308e..f0e3f1e 100644 --- a/test/answer/crisp1.png +++ b/test/answer/crisp1.png diff --git a/test/answer/huetest.png b/test/answer/huetest.png Binary files differnew file mode 100644 index 0000000..ec38604 --- /dev/null +++ b/test/answer/huetest.png diff --git a/test/answer/index4.png b/test/answer/index4.png Binary files differindex 3de2398..c26cbee 100644 --- a/test/answer/index4.png +++ b/test/answer/index4.png diff --git a/test/answer/indextest.png b/test/answer/indextest.png Binary files differindex c8ff807..e3ea6a7 100644 --- a/test/answer/indextest.png +++ b/test/answer/indextest.png diff --git a/test/answer/modeA.png b/test/answer/modeA.png Binary files differindex 597099b..244c062 100644 --- a/test/answer/modeA.png +++ b/test/answer/modeA.png diff --git a/test/answer/modeB.png b/test/answer/modeB.png Binary files differindex d9836da..947d025 100644 --- a/test/answer/modeB.png +++ b/test/answer/modeB.png diff --git a/test/dotest b/test/dotest index 0bb6115..9074270 100755 --- a/test/dotest +++ b/test/dotest @@ -14,7 +14,7 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA export LC_CTYPE=C export LC_MESSAGES=C @@ -69,6 +69,16 @@ testrun() { fi } +errtest() { + expect=$1 + shift + program=${XCFTOOLS_PREFIX}$1 + shift + [ -f expected:stderr ] && \ + (sed "1s!^!$program: !" expected:stderr > expected.stderr) + testrun --exit $expect $program "$@" +} + testinfo() { testrun ${XCFTOOLS_PREFIX}xcfinfo "$@" } @@ -153,13 +163,160 @@ rm -f pngtype.want S=source +cp /dev/null expected.stdout + +############################################################################# +# +# Test for discovery of error conditions. +# + +echo > expected:stderr \ + "The --mode option must follow a layer name on the command line" +errtest 20 xcf2pnm $S/modetest.xcf.gz --mode Addition A B + +echo > expected:stderr \ + "The --percent option must follow a layer name on the command line" +errtest 20 xcf2png $S/tiletest.xcf.gz --percent 33 Mid + +echo > expected:stderr \ + "The image has no layer called 'MID'" +errtest 22 xcf2pnm $S/tiletest.xcf.gz Background MID -o foo.pnm + +echo > expected:stderr \ + "Layer 'Vert' has no layer mask to enable" +errtest 22 xcf2pnm $S/tiletest.xcf.gz Background Vert --mask Horiz --nomask + +echo > expected:stderr \ + "Grayscale output selected, but colored pixel(s) found" +errtest 103 xcf2pnm -o o.pgm $S/tiletest.xcf.gz Background +errtest 103 xcf2png -o o.png -g $S/tiletest.xcf.gz Background +rm -rf o.pgm o.png +errtest 103 xcf2pnm -o o.pgm $S/tiletest.xcf.gz Background -f +if [ -f o.pgm ] ; then echo o.pgm exists ; failed ; fi +errtest 103 xcf2png -o o.png -g $S/tiletest.xcf.gz Background -f +if [ -f o.png ] ; then echo o.png exists ; failed ; fi + +echo > expected:stderr \ + "Monochrome output selected, but not all pixels are black or white" +errtest 103 xcf2pnm -o o.pbm $S/tiletest.xcf.gz Background +errtest 103 xcf2pnm -o o.pbm $S/tiletest.xcf.gz Background \ + 'Straight loop' 'Long and low' +rm -rf o.pbm +errtest 103 xcf2pnm -o o.pbm $S/tiletest.xcf.gz Background -f +if [ -f o.pbm ] ; then echo o.pbm exists ; failed ; fi +errtest 103 xcf2pnm -o o.pbm $S/tiletest.xcf.gz Background -f \ + 'Straight loop' 'Long and low' +if [ -f o.pbm ] ; then echo o.pbm exists ; failed ; fi + +cat > expected:stderr <<EOF +The image contains features not understood by this program: + 'AntiErase' layer mode +EOF +errtest 123 xcf2pnm $S/modetest.xcf.gz A B --mode AntiErase + +echo > expected:stderr \ + "Flattened image has partially transparent pixels" +errtest 102 xcf2pnm $S/modetest.xcf.gz -G + +cat > expected:stderr <<EOF +Corrupted or malformed XCF file: + Not an XCF file at all (magic not recognized) +EOF +errtest 125 xcfinfo answer/modeA.png + +rm expected:stderr +cat > expected.stderr <<EOF +Warning: XCF version 345 not supported (trying anyway...) +${XCFTOOLS_PREFIX}xcf2png: Corrupted or truncated XCF file + (0x1C7 bytes): Overlong property at 82 +EOF +errtest 125 xcf2png $S/truncated.xcf + +echo > expected:stderr \ + "Transparency found, but -a option not given" +errtest 100 xcf2pnm $S/modetest.xcf.gz -o o.pnm + +echo > expected:stderr \ + "The -a option was given, but the image has no transparency" +errtest 101 xcf2pnm $S/modetest.xcf.gz -b white -a a.pgm +errtest 101 xcf2pnm $S/tiletest.xcf.gz -a a.pgm + +echo > expected:stderr \ + "Only one XCF file per command line, please" +errtest 20 xcfinfo $S/tiletest.xcf.gz Background 'Long and low' + +rm expected:stderr +rgbfile=/usr/lib/X11/rgb.txt +( [ -f $rgbfile ] || echo "Could not open color database file $rgbfile" ) \ + > expected.stderr +echo "${XCFTOOLS_PREFIX}xcf2pnm: Unknown background color 'Plaid'" \ + >> expected.stderr +errtest 20 xcf2pnm $S/tiletext.xcf.gz -b Plaid + +echo > expected:stderr \ + "-S option must have an argument of the form wxh" +errtest 20 xcf2pnm $S/tiletext.xcf.gz -S 10x +errtest 20 xcf2pnm $S/tiletext.xcf.gz -S 10x20x30 + +echo > expected:stderr \ + "-O option must have an argument of the form x,y" +errtest 20 xcf2pnm $S/tiletest.xcf.gz -S 10x10 -O 2x4 + +echo > expected:stderr \ + "Layer mode 'GammaShift' is unknown" +errtest 20 xcf2png $S/modetest.xcf.gz B A --mode GammaShift + +echo > expected:stderr \ + "The argument to --percent is not a percentage" +errtest 20 xcf2pnm $S/tiletest.xcf.gz Background Mid --percent -3 +errtest 20 xcf2pnm $S/tiletest.xcf.gz Background Mid --percent 20.2 +errtest 20 xcf2pnm $S/tiletest.xcf.gz Background Mid --percent 101 + +echo > expected:stderr \ + "The argument to --opacity is not a number between 0 and 255" +errtest 20 xcf2pnm $S/tiletest.xcf.gz Background Mid --opacity -3 +errtest 20 xcf2pnm $S/tiletest.xcf.gz Background Mid --opacity 220.2 +errtest 20 xcf2pnm $S/tiletest.xcf.gz Background Mid --opacity 256 + +####################################################### +# +# Error tests for io-unix.c +# +# XXX: if another I/O module is added later, these tests should +# be conditionally enabled +# + +cat <<EOF > enoent.c +#include <errno.h> +#include <stdio.h> +int main(int argc,char **argv) { errno = ENOENT; + if( argv[1][0] == '!' ) { errno = EACCES; argv++; } + perror(argv[1]); return 0; } +EOF +cp /dev/null expected.stderr +testrun cc enoent.c +./a.out $S/nonexist.xcf 2> expected:stderr +errtest 21 xcfinfo $S/nonexist.xcf + +rm expected:stderr +./a.out "Cannot execute source/nonexist.xcf" 2> expected.stderr +errtest 126 xcf2png -Z $S/nonexist.xcf $S/tiletest.xcf.gz + cp /dev/null expected.stderr +command false +errtest $? xcf2png -Z false $S/tiletest.xcf.gz + +./a.out ! "Cannot execute answer/modeA.png" 2> expected.stderr +errtest 126 xcf2pnm -Z answer/modeA.png $S/comptest.xcf.gz + +rm -f expected:stderr ############################################################################# # # Use all of the example XCF inputs as checks of xcfinfo # +cp /dev/null expected.stderr cat <<EOF > expected.stdout Version 0, 256x256 Grayscale, 2 layers, compressed RLE + 256x256+0+0 Grayscale-alpha Normal Partially transparent @@ -206,6 +363,13 @@ EOF testinfo $S/i256.xcf.gz testinfo $S/i255.xcf.gz +cat <<EOF > expected.stdout +Version 0, 32x40 RGB color, 2 layers, compressed RLE ++ 32x40+0+0 RGB-alpha Hue Hue ++ 32x40+0+0 RGB Normal Background +EOF +testinfo $S/huetest.xcf.gz + cp /dev/null expected.stdout ############################################################################# @@ -231,12 +395,16 @@ testpnm o:Subtract a:modeA modetest testpnm o:Addition a:modeB modetest B A -f for mode in Multiply Screen Overlay Difference DarkenOnly \ LightenOnly Divide Dodge Burn GrainExtract GrainMerge \ - Hardlight + Hardlight Hue Saturation Value Color do testpnm o:$mode a:modeA modetest A B --mode $mode done testpnm o:Overlay a:modeA modetest AE=AE A --mode Normal B --mode Softlight +# huetest.xcf.gz is an auxiliary test that makes sure that all of the +# six hue hexants have matching implementations in RGB->HSV and HSV->RGB + +testpnm o:huetest huetest ############################################################################# # @@ -300,12 +468,16 @@ testpnm o:burmid tiletest Mid -S 27x25 -O 5,5 -b '#963' # Tests of xcf2png # -############################################################################# # # Basic functionality # testpng tiletest tiletest +cat <<EOF > pngtype.want +64x64x8 +color+alpha +z0 f0 i0 +EOF testpng modeA modetest A ############################################################################# @@ -364,11 +536,29 @@ testpng gray tiletest Background 'Straight loop' 'Long and low' -f testpng gray tiletest Background 'Straight loop' 'Long and low' -g testpng comptest comptest -# RGB: many of the layer mode tests test this +# RGB: The tiletest runs above test this # gray+alpha testpng comptestB comptest 'Partially transparent' -f +# RGB+artificial alpha +cat <<EOF > pngtype.want +161x161x8 +color+alpha +z0 f0 i0 +EOF +testpng A:-pgm tiletest tiletest -A + +# RGS+artificial alpha, compressed +cat <<EOF > pngtype.want +161x161x8 +color +z0 f0 i0 +tRNS(6) + 00 06 00 06 00 06 +EOF +testpng tiletest tiletest -A -f + # RGB+alpha cat <<EOF > pngtype.want 16x20x8 @@ -396,7 +586,7 @@ testpng "b:0,0,0" crisp1 modetest -S16x20 -O48,46 -c -f testpng crisp1 modetest -S16x20 -O48,46 -f # index, various transparent colors -testpng modeB modetest B -f +testpng modeA modetest A -f ############################################################################# # @@ -445,6 +635,18 @@ PLTE(12) EOF testpng index4 indextest Background -f +# 4 colors, artificial transparency +cat <<EOF > pngtype.want +64x64x2 +color+index +z0 f0 i0 +PLTE(12) + DC 98 85 FF 00 77 10 36 38 FF B4 23 +tRNS(4) + FF FF FF FF +EOF +testpng index4 indextest Background -f -A + # 16 colors, no transparency testpng mid tiletest -O17,17 -S32x32 -f diff --git a/test/source/huetest.xcf.gz b/test/source/huetest.xcf.gz Binary files differnew file mode 100644 index 0000000..b1f24a3 --- /dev/null +++ b/test/source/huetest.xcf.gz diff --git a/test/source/indextest.xcf.gz b/test/source/indextest.xcf.gz Binary files differindex b782acf..f8675eb 100644 --- a/test/source/indextest.xcf.gz +++ b/test/source/indextest.xcf.gz diff --git a/test/source/mkmodebase.c b/test/source/mkmodebase.c index 3e5c656..376be12 100644 --- a/test/source/mkmodebase.c +++ b/test/source/mkmodebase.c @@ -7,17 +7,14 @@ void makepixel(int x,int y,int *r,int *g,int *b,int *a) { - if( y < 3 || y >= 61 ) { + if( x < 3 || x >= 61 ) { *a = 0 ; return ; } - if( x < 3 || x >= 61 || - y < 6 || y >= 58 ) { - *r=*g=*b=*a=255 ; - return ; - } - if( x < 6 || x >= 58 ) { - *a=0 ; + if( y < 3 || y >= 61 || + x < 6 || x >= 58 ) { + *a = 255 ; + *r=*g=*b= 255*(x>=32) ; return ; } x -= 6 ; @@ -39,8 +36,8 @@ makepixel(int x,int y,int *r,int *g,int *b,int *a) { x -= 17 ; if( x <= 17 ) { *r = (17-x)*15 ; - *g = 255 ; - *b = x*15 ; + *g = (17-x)*15 ; + *b = (x-1)*15 ; return ; } *r=255 ; diff --git a/test/source/modetest.xcf.gz b/test/source/modetest.xcf.gz Binary files differindex c2d7f8a..d4b37c1 100644 --- a/test/source/modetest.xcf.gz +++ b/test/source/modetest.xcf.gz diff --git a/test/source/truncated.xcf b/test/source/truncated.xcf Binary files differnew file mode 100644 index 0000000..0229b3f --- /dev/null +++ b/test/source/truncated.xcf @@ -13,7 +13,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "xcftools.h" @@ -45,7 +45,7 @@ void FatalGeneric(int status,const char* format,...) { va_list v; va_start(v,format); - fprintf(stderr,"%s: ",progname); + if( format ) fprintf(stderr,"%s: ",progname); vFatalGeneric(status,format,v); } @@ -71,7 +71,7 @@ xcfCheckspace(uint32_t addr,int spaceafter,const char *format,...) if( xcf_length < spaceafter || addr > xcf_length - spaceafter ) { va_list v; va_start(v,format); fprintf(stderr,"%s: %s\n ",progname,_("Corrupted or truncated XCF file")); - fprintf(stderr,"(%" PRIXPTR " bytes): ",(uintptr_t)xcf_length); + fprintf(stderr,"(0x%" PRIXPTR " bytes): ",(uintptr_t)xcf_length); vFatalGeneric(125,format,v) ; } } diff --git a/xcf-general.c b/xcf-general.c index c1d7da9..ef03de3 100644 --- a/xcf-general.c +++ b/xcf-general.c @@ -13,7 +13,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "xcftools.h" @@ -12,8 +12,8 @@ \." \." You should have received a copy of the GNU General Public License \." along with this program; if not, write to the Free Software -\." Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -.TH xcf2png 1 2006-01-25 "Xcftools" "" +\." Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +.TH xcf2png 1 2006-02-12 "Xcftools" "" .SH NAME xcf2png \- convert from GIMP xcf files to png format .SH SYNOPSIS @@ -110,8 +110,10 @@ pixels were found. 123 The XCF file contains presumably valid features that .B xcftools -does not support. (Certain layer modes, for example, cause -this return). +does not support. +(As of this writing there is no known way of getting the Gimp to produce +an XCF file that will provoke this return. Please notify the author if you +discover one). .TP 125 The XCF file is malformed. @@ -140,9 +142,6 @@ especially when more than two layers are involved, or in case of some of the more exotic layer modes. These differences are usually not visible to the eye. .P -A few particularly exotic layer modes (which work in HSV space rather -than RGB space) are not currently implemented. -.P There are probably other bugs lurking in corner cases. If you discover one, please notify the author. @@ -13,7 +13,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "xcftools.h" @@ -113,7 +113,7 @@ init_output(void) invert_mono = 1 ; } else { unsigned i ; - int need_trans = 0 ; + int need_trans = flatspec.default_pixel == FORCE_ALPHA_CHANNEL ; color_type = PNG_COLOR_TYPE_PALETTE ; pngpalette = xcfmalloc(paletteSize*sizeof(png_color)) ; ptrans = xcfmalloc(paletteSize); @@ -12,8 +12,8 @@ \." \." You should have received a copy of the GNU General Public License \." along with this program; if not, write to the Free Software -\." Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -.TH xcf2pnm 1 2006-01-22 "Xcftools" "" +\." Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +.TH xcf2pnm 1 2006-02-12 "Xcftools" "" .SH NAME xcf2pnm \- convert from GIMP xcf files to ppm/pgm/pbm format .SH SYNOPSIS @@ -134,8 +134,10 @@ was given, yet colored (or gray) pixels were found. 123 The XCF file contains presumably valid features that .B xcftools -does not support. (Certain layer modes, for example, cause -this return). +does not support. +(As of this writing there is no known way of getting the Gimp to write +an XCF file that will provoke this return. Please notify the author if you +discover one). .TP 125 The XCF file is malformed. @@ -179,9 +181,6 @@ especially when more than two layers are involved, or in case of some of the more exotic layer modes. These differences are usually not visible to the eye. .P -A few particularly exotic layer modes (which work in HSV space rather -than RGB space) are not currently implemented. -.P There are probably other bugs lurking in corner cases. If you discover one, please notify the author. @@ -13,7 +13,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "xcftools.h" @@ -155,7 +155,7 @@ pgm_callback(unsigned num,rgba *pixels) int gray = degrayPixel(pixels[i]) ; if( gray == -1 ) FatalGeneric(103, - _("Grayscale output selected, but colored pixel(s) found %d=%x"),i,pixels[i] /*XXX*/); + _("Grayscale output selected, but colored pixel(s) found")); putc( gray, outfile ); } callback_common(num,pixels); @@ -12,8 +12,8 @@ \." \." You should have received a copy of the GNU General Public License \." along with this program; if not, write to the Free Software -\." Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -.TH xcfinfo 1 2006-01-22 "Xcftools" "" +\." Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +.TH xcfinfo 1 2006-02-12 "Xcftools" "" .SH NAME xcf2pnm \- display information about GIMP xcf files .SH SYNOPSIS @@ -13,7 +13,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "xcftools.h" @@ -13,7 +13,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef XCFTOOLS_H |