diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2014-09-01 13:56:46 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2014-09-01 13:56:46 +0200 |
commit | 22f703cab05b7cd368f4de9e03991b7664dc5022 (patch) | |
tree | 6f4d50beaa42328e24b1c6b56b6ec059e4ef21a5 /tiff/contrib/dbs |
Initial import of argyll version 1.5.1-8debian/1.5.1-8
Diffstat (limited to 'tiff/contrib/dbs')
-rw-r--r-- | tiff/contrib/dbs/Makefile.am | 43 | ||||
-rw-r--r-- | tiff/contrib/dbs/Makefile.in | 737 | ||||
-rw-r--r-- | tiff/contrib/dbs/README | 7 | ||||
-rw-r--r-- | tiff/contrib/dbs/tiff-bi.c | 91 | ||||
-rw-r--r-- | tiff/contrib/dbs/tiff-grayscale.c | 146 | ||||
-rw-r--r-- | tiff/contrib/dbs/tiff-palette.c | 283 | ||||
-rw-r--r-- | tiff/contrib/dbs/tiff-rgb.c | 201 | ||||
-rw-r--r-- | tiff/contrib/dbs/xtiff/Makefile.am | 43 | ||||
-rw-r--r-- | tiff/contrib/dbs/xtiff/Makefile.in | 436 | ||||
-rw-r--r-- | tiff/contrib/dbs/xtiff/README | 6 | ||||
-rw-r--r-- | tiff/contrib/dbs/xtiff/patchlevel.h | 8 | ||||
-rw-r--r-- | tiff/contrib/dbs/xtiff/xtiff.c | 1290 | ||||
-rw-r--r-- | tiff/contrib/dbs/xtiff/xtifficon.h | 21 |
13 files changed, 3312 insertions, 0 deletions
diff --git a/tiff/contrib/dbs/Makefile.am b/tiff/contrib/dbs/Makefile.am new file mode 100644 index 0000000..608a0ad --- /dev/null +++ b/tiff/contrib/dbs/Makefile.am @@ -0,0 +1,43 @@ +# Tag Image File Format (TIFF) Software +# +# Copyright (C) 2004, Andrey Kiselev <dron@ak4719.spb.edu> +# +# Permission to use, copy, modify, distribute, and sell this software and +# its documentation for any purpose is hereby granted without fee, provided +# that (i) the above copyright notices and this permission notice appear in +# all copies of the software and related documentation, and (ii) the names of +# Sam Leffler and Silicon Graphics may not be used in any advertising or +# publicity relating to the software without the specific, prior written +# permission of Sam Leffler and Silicon Graphics. +# +# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +# +# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +# OF THIS SOFTWARE. + +# Process this file with automake to produce Makefile.in. + +SUBDIRS = xtiff + +LIBTIFF = $(top_builddir)/libtiff/libtiff.la + +EXTRA_DIST = README + +noinst_PROGRAMS = tiff-bi tiff-grayscale tiff-palette tiff-rgb + +tiff_bi_SOURCES = tiff-bi.c +tiff_bi_LDADD = $(LIBTIFF) +tiff_grayscale_SOURCES = tiff-grayscale.c +tiff_grayscale_LDADD = $(LIBTIFF) +tiff_palette_SOURCES = tiff-palette.c +tiff_palette_LDADD = $(LIBTIFF) +tiff_rgb_SOURCES = tiff-rgb.c +tiff_rgb_LDADD = $(LIBTIFF) + +INCLUDES = -I../../libtiff -I$(top_srcdir)/libtiff diff --git a/tiff/contrib/dbs/Makefile.in b/tiff/contrib/dbs/Makefile.in new file mode 100644 index 0000000..72eaf43 --- /dev/null +++ b/tiff/contrib/dbs/Makefile.in @@ -0,0 +1,737 @@ +# Makefile.in generated by automake 1.11 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +# Tag Image File Format (TIFF) Software +# +# Copyright (C) 2004, Andrey Kiselev <dron@ak4719.spb.edu> +# +# Permission to use, copy, modify, distribute, and sell this software and +# its documentation for any purpose is hereby granted without fee, provided +# that (i) the above copyright notices and this permission notice appear in +# all copies of the software and related documentation, and (ii) the names of +# Sam Leffler and Silicon Graphics may not be used in any advertising or +# publicity relating to the software without the specific, prior written +# permission of Sam Leffler and Silicon Graphics. +# +# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +# +# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +# OF THIS SOFTWARE. + +# Process this file with automake to produce Makefile.in. + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +noinst_PROGRAMS = tiff-bi$(EXEEXT) tiff-grayscale$(EXEEXT) \ + tiff-palette$(EXEEXT) tiff-rgb$(EXEEXT) +subdir = contrib/dbs +DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/acinclude.m4 \ + $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ + $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ + $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/libtiff/tif_config.h \ + $(top_builddir)/libtiff/tiffconf.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +PROGRAMS = $(noinst_PROGRAMS) +am_tiff_bi_OBJECTS = tiff-bi.$(OBJEXT) +tiff_bi_OBJECTS = $(am_tiff_bi_OBJECTS) +tiff_bi_DEPENDENCIES = $(LIBTIFF) +AM_V_lt = $(am__v_lt_$(V)) +am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) +am__v_lt_0 = --silent +am_tiff_grayscale_OBJECTS = tiff-grayscale.$(OBJEXT) +tiff_grayscale_OBJECTS = $(am_tiff_grayscale_OBJECTS) +tiff_grayscale_DEPENDENCIES = $(LIBTIFF) +am_tiff_palette_OBJECTS = tiff-palette.$(OBJEXT) +tiff_palette_OBJECTS = $(am_tiff_palette_OBJECTS) +tiff_palette_DEPENDENCIES = $(LIBTIFF) +am_tiff_rgb_OBJECTS = tiff-rgb.$(OBJEXT) +tiff_rgb_OBJECTS = $(am_tiff_rgb_OBJECTS) +tiff_rgb_DEPENDENCIES = $(LIBTIFF) +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/libtiff +depcomp = $(SHELL) $(top_srcdir)/config/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_$(V)) +am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY)) +am__v_CC_0 = @echo " CC " $@; +AM_V_at = $(am__v_at_$(V)) +am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) +am__v_at_0 = @ +CCLD = $(CC) +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_$(V)) +am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY)) +am__v_CCLD_0 = @echo " CCLD " $@; +AM_V_GEN = $(am__v_GEN_$(V)) +am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) +am__v_GEN_0 = @echo " GEN " $@; +SOURCES = $(tiff_bi_SOURCES) $(tiff_grayscale_SOURCES) \ + $(tiff_palette_SOURCES) $(tiff_rgb_SOURCES) +DIST_SOURCES = $(tiff_bi_SOURCES) $(tiff_grayscale_SOURCES) \ + $(tiff_palette_SOURCES) $(tiff_rgb_SOURCES) +RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ + html-recursive info-recursive install-data-recursive \ + install-dvi-recursive install-exec-recursive \ + install-html-recursive install-info-recursive \ + install-pdf-recursive install-ps-recursive install-recursive \ + installcheck-recursive installdirs-recursive pdf-recursive \ + ps-recursive uninstall-recursive +RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ + distclean-recursive maintainer-clean-recursive +AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ + $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \ + distdir +ETAGS = etags +CTAGS = ctags +DIST_SUBDIRS = $(SUBDIRS) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +am__relativize = \ + dir0=`pwd`; \ + sed_first='s,^\([^/]*\)/.*$$,\1,'; \ + sed_rest='s,^[^/]*/*,,'; \ + sed_last='s,^.*/\([^/]*\)$$,\1,'; \ + sed_butlast='s,/*[^/]*$$,,'; \ + while test -n "$$dir1"; do \ + first=`echo "$$dir1" | sed -e "$$sed_first"`; \ + if test "$$first" != "."; then \ + if test "$$first" = ".."; then \ + dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ + dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ + else \ + first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ + if test "$$first2" = "$$first"; then \ + dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ + else \ + dir2="../$$dir2"; \ + fi; \ + dir0="$$dir0"/"$$first"; \ + fi; \ + fi; \ + dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ + done; \ + reldir="$$dir2" +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GLUT_CFLAGS = @GLUT_CFLAGS@ +GLUT_LIBS = @GLUT_LIBS@ +GLU_CFLAGS = @GLU_CFLAGS@ +GLU_LIBS = @GLU_LIBS@ +GL_CFLAGS = @GL_CFLAGS@ +GL_LIBS = @GL_LIBS@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBDIR = @LIBDIR@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTIFF_ALPHA_VERSION = @LIBTIFF_ALPHA_VERSION@ +LIBTIFF_DOCDIR = @LIBTIFF_DOCDIR@ +LIBTIFF_MAJOR_VERSION = @LIBTIFF_MAJOR_VERSION@ +LIBTIFF_MICRO_VERSION = @LIBTIFF_MICRO_VERSION@ +LIBTIFF_MINOR_VERSION = @LIBTIFF_MINOR_VERSION@ +LIBTIFF_RELEASE_DATE = @LIBTIFF_RELEASE_DATE@ +LIBTIFF_VERSION = @LIBTIFF_VERSION@ +LIBTIFF_VERSION_INFO = @LIBTIFF_VERSION_INFO@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PTHREAD_CC = @PTHREAD_CC@ +PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ +PTHREAD_LIBS = @PTHREAD_LIBS@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +XMKMF = @XMKMF@ +X_CFLAGS = @X_CFLAGS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_LIBS = @X_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +acx_pthread_config = @acx_pthread_config@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +SUBDIRS = xtiff +LIBTIFF = $(top_builddir)/libtiff/libtiff.la +EXTRA_DIST = README +tiff_bi_SOURCES = tiff-bi.c +tiff_bi_LDADD = $(LIBTIFF) +tiff_grayscale_SOURCES = tiff-grayscale.c +tiff_grayscale_LDADD = $(LIBTIFF) +tiff_palette_SOURCES = tiff-palette.c +tiff_palette_LDADD = $(LIBTIFF) +tiff_rgb_SOURCES = tiff-rgb.c +tiff_rgb_LDADD = $(LIBTIFF) +INCLUDES = -I../../libtiff -I$(top_srcdir)/libtiff +all: all-recursive + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign contrib/dbs/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign contrib/dbs/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +clean-noinstPROGRAMS: + @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list +tiff-bi$(EXEEXT): $(tiff_bi_OBJECTS) $(tiff_bi_DEPENDENCIES) + @rm -f tiff-bi$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(tiff_bi_OBJECTS) $(tiff_bi_LDADD) $(LIBS) +tiff-grayscale$(EXEEXT): $(tiff_grayscale_OBJECTS) $(tiff_grayscale_DEPENDENCIES) + @rm -f tiff-grayscale$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(tiff_grayscale_OBJECTS) $(tiff_grayscale_LDADD) $(LIBS) +tiff-palette$(EXEEXT): $(tiff_palette_OBJECTS) $(tiff_palette_DEPENDENCIES) + @rm -f tiff-palette$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(tiff_palette_OBJECTS) $(tiff_palette_LDADD) $(LIBS) +tiff-rgb$(EXEEXT): $(tiff_rgb_OBJECTS) $(tiff_rgb_DEPENDENCIES) + @rm -f tiff-rgb$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(tiff_rgb_OBJECTS) $(tiff_rgb_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tiff-bi.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tiff-grayscale.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tiff-palette.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tiff-rgb.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. +$(RECURSIVE_TARGETS): + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +$(RECURSIVE_CLEAN_TARGETS): + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + rev=''; for subdir in $$list; do \ + if test "$$subdir" = "."; then :; else \ + rev="$$subdir $$rev"; \ + fi; \ + done; \ + rev="$$rev ."; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done +ctags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + empty_fix=.; \ + else \ + include_option=--include; \ + empty_fix=; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test ! -f $$subdir/TAGS || \ + set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done + @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -d "$(distdir)/$$subdir" \ + || $(MKDIR_P) "$(distdir)/$$subdir" \ + || exit 1; \ + fi; \ + done + @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ + $(am__relativize); \ + new_distdir=$$reldir; \ + dir1=$$subdir; dir2="$(top_distdir)"; \ + $(am__relativize); \ + new_top_distdir=$$reldir; \ + echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ + echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ + ($(am__cd) $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$$new_top_distdir" \ + distdir="$$new_distdir" \ + am__remove_distdir=: \ + am__skip_length_check=: \ + am__skip_mode_fix=: \ + distdir) \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-recursive +all-am: Makefile $(PROGRAMS) +installdirs: installdirs-recursive +installdirs-am: +install: install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-recursive + +clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \ + mostlyclean-am + +distclean: distclean-recursive + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-recursive + +dvi-am: + +html: html-recursive + +html-am: + +info: info-recursive + +info-am: + +install-data-am: + +install-dvi: install-dvi-recursive + +install-dvi-am: + +install-exec-am: + +install-html: install-html-recursive + +install-html-am: + +install-info: install-info-recursive + +install-info-am: + +install-man: + +install-pdf: install-pdf-recursive + +install-pdf-am: + +install-ps: install-ps-recursive + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-recursive + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-recursive + +pdf-am: + +ps: ps-recursive + +ps-am: + +uninstall-am: + +.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \ + install-am install-strip tags-recursive + +.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ + all all-am check check-am clean clean-generic clean-libtool \ + clean-noinstPROGRAMS ctags ctags-recursive distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + installdirs-am maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am tags tags-recursive \ + uninstall uninstall-am + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/tiff/contrib/dbs/README b/tiff/contrib/dbs/README new file mode 100644 index 0000000..e05d0a9 --- /dev/null +++ b/tiff/contrib/dbs/README @@ -0,0 +1,7 @@ +Wed May 9 09:11:35 PDT 1990 + +This directory contains programs from Dan Sears +(dbs@decwrl.dec.com). Contact him directly if +you have questions/problems. + + Sam diff --git a/tiff/contrib/dbs/tiff-bi.c b/tiff/contrib/dbs/tiff-bi.c new file mode 100644 index 0000000..f549209 --- /dev/null +++ b/tiff/contrib/dbs/tiff-bi.c @@ -0,0 +1,91 @@ +/* $Id: tiff-bi.c,v 1.2.2.1 2010-06-08 18:50:40 bfriesen Exp $ */ + +/* + * tiff-bi.c -- create a Class B (bilevel) TIFF file + * + * Copyright 1990 by Digital Equipment Corporation, Maynard, Massachusetts. + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Digital not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR + * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +#include <stdio.h> +#include <stdlib.h> + +#include "tiffio.h" + +#define WIDTH 512 +#define HEIGHT WIDTH + +int main(int argc, char **argv) +{ + int i; + unsigned char * scan_line; + TIFF * tif; + + if (argc != 2) { + fprintf(stderr, "Usage: %s tiff-image\n", argv[0]); + return 0; + } + + if ((tif = TIFFOpen(argv[1], "w")) == NULL) { + fprintf(stderr, "can't open %s as a TIFF file\n", argv[1]); + return 0; + } + + TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, WIDTH); + TIFFSetField(tif, TIFFTAG_IMAGELENGTH, HEIGHT); + TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 1); + TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE); + TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK); + TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1); + TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, 1); + TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); + TIFFSetField(tif, TIFFTAG_RESOLUTIONUNIT, RESUNIT_NONE); + + scan_line = (unsigned char *) malloc(WIDTH / 8); + + for (i = 0; i < (WIDTH / 8) / 2; i++) + scan_line[i] = 0; + + for (i = (WIDTH / 8) / 2; i < (WIDTH / 8); i++) + scan_line[i] = 255; + + for (i = 0; i < HEIGHT / 2; i++) + TIFFWriteScanline(tif, scan_line, i, 0); + + for (i = 0; i < (WIDTH / 8) / 2; i++) + scan_line[i] = 255; + + for (i = (WIDTH / 8) / 2; i < (WIDTH / 8); i++) + scan_line[i] = 0; + + for (i = HEIGHT / 2; i < HEIGHT; i++) + TIFFWriteScanline(tif, scan_line, i, 0); + + free(scan_line); + TIFFClose(tif); + return 0; +} +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/tiff/contrib/dbs/tiff-grayscale.c b/tiff/contrib/dbs/tiff-grayscale.c new file mode 100644 index 0000000..e8f474c --- /dev/null +++ b/tiff/contrib/dbs/tiff-grayscale.c @@ -0,0 +1,146 @@ +/* $Id: tiff-grayscale.c,v 1.4.2.1 2010-06-08 18:50:40 bfriesen Exp $ */ + +/* + * tiff-grayscale.c -- create a Class G (grayscale) TIFF file + * with a gray response curve in linear optical density + * + * Copyright 1990 by Digital Equipment Corporation, Maynard, Massachusetts. + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Digital not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR + * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +#include <math.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "tiffio.h" + +#define WIDTH 512 +#define HEIGHT WIDTH + +char * programName; +void Usage(); + +int main(int argc, char **argv) +{ + int bits_per_pixel = 8, cmsize, i, j, k, + gray_index, chunk_size = 32, nchunks = 16; + unsigned char * scan_line; + uint16 * gray; + float refblackwhite[2*1]; + TIFF * tif; + + programName = argv[0]; + + if (argc != 4) + Usage(); + + if (!strcmp(argv[1], "-depth")) + bits_per_pixel = atoi(argv[2]); + else + Usage(); + + switch (bits_per_pixel) { + case 8: + nchunks = 16; + chunk_size = 32; + break; + case 4: + nchunks = 4; + chunk_size = 128; + break; + case 2: + nchunks = 2; + chunk_size = 256; + break; + default: + Usage(); + } + + cmsize = nchunks * nchunks; + gray = (uint16 *) malloc(cmsize * sizeof(uint16)); + + gray[0] = 3000; + for (i = 1; i < cmsize; i++) + gray[i] = (uint16) (-log10((double) i / (cmsize - 1)) * 1000); + + refblackwhite[0] = 0.0; + refblackwhite[1] = (float)((1L<<bits_per_pixel) - 1); + + if ((tif = TIFFOpen(argv[3], "w")) == NULL) { + fprintf(stderr, "can't open %s as a TIFF file\n", argv[3]); + return 0; + } + + TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, WIDTH); + TIFFSetField(tif, TIFFTAG_IMAGELENGTH, HEIGHT); + TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, bits_per_pixel); + TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE); + TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK); + TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1); + TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, 1); + TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); + TIFFSetField(tif, TIFFTAG_REFERENCEBLACKWHITE, refblackwhite); + TIFFSetField(tif, TIFFTAG_TRANSFERFUNCTION, gray); + TIFFSetField(tif, TIFFTAG_RESOLUTIONUNIT, RESUNIT_NONE); + + scan_line = (unsigned char *) malloc(WIDTH / (8 / bits_per_pixel)); + + for (i = 0; i < HEIGHT; i++) { + for (j = 0, k = 0; j < WIDTH;) { + gray_index = (j / chunk_size) + ((i / chunk_size) * nchunks); + + switch (bits_per_pixel) { + case 8: + scan_line[k++] = gray_index; + j++; + break; + case 4: + scan_line[k++] = (gray_index << 4) + gray_index; + j += 2; + break; + case 2: + scan_line[k++] = (gray_index << 6) + (gray_index << 4) + + (gray_index << 2) + gray_index; + j += 4; + break; + } + } + TIFFWriteScanline(tif, scan_line, i, 0); + } + + free(scan_line); + TIFFClose(tif); + return 0; +} + +void +Usage() +{ + fprintf(stderr, "Usage: %s -depth (8 | 4 | 2) tiff-image\n", programName); + exit(0); +} +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/tiff/contrib/dbs/tiff-palette.c b/tiff/contrib/dbs/tiff-palette.c new file mode 100644 index 0000000..054000b --- /dev/null +++ b/tiff/contrib/dbs/tiff-palette.c @@ -0,0 +1,283 @@ +/* $Id: tiff-palette.c,v 1.3.2.1 2010-06-08 18:50:40 bfriesen Exp $ */ + +/* + * tiff-palette.c -- create a Class P (palette) TIFF file + * + * Copyright 1990 by Digital Equipment Corporation, Maynard, Massachusetts. + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Digital not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR + * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "tiffio.h" + +#define WIDTH 512 +#define HEIGHT WIDTH +#define SCALE(x) ((x) * 257L) + +char * programName; +void Usage(); + +int main(int argc, char **argv) +{ + int bits_per_pixel = 8, cmsize, i, j, k, + cmap_index, chunk_size = 32, nchunks = 16; + unsigned char * scan_line; + uint16 *red, *green, *blue; + TIFF * tif; + + programName = argv[0]; + + if (argc != 4) + Usage(); + + if (!strcmp(argv[1], "-depth")) + bits_per_pixel = atoi(argv[2]); + else + Usage(); + + switch (bits_per_pixel) { + case 8: + nchunks = 16; + chunk_size = 32; + break; + case 4: + nchunks = 4; + chunk_size = 128; + break; + case 2: + nchunks = 2; + chunk_size = 256; + break; + case 1: + nchunks = 2; + chunk_size = 256; + break; + default: + Usage(); + } + + if (bits_per_pixel != 1) { + cmsize = nchunks * nchunks; + } else { + cmsize = 2; + } + red = (uint16 *) malloc(cmsize * sizeof(uint16)); + green = (uint16 *) malloc(cmsize * sizeof(uint16)); + blue = (uint16 *) malloc(cmsize * sizeof(uint16)); + + switch (bits_per_pixel) { + case 8: + for (i = 0; i < cmsize; i++) { + if (i < 32) + red[i] = 0; + else if (i < 64) + red[i] = SCALE(36); + else if (i < 96) + red[i] = SCALE(73); + else if (i < 128) + red[i] = SCALE(109); + else if (i < 160) + red[i] = SCALE(146); + else if (i < 192) + red[i] = SCALE(182); + else if (i < 224) + red[i] = SCALE(219); + else if (i < 256) + red[i] = SCALE(255); + + if ((i % 32) < 4) + green[i] = 0; + else if (i < 8) + green[i] = SCALE(36); + else if ((i % 32) < 12) + green[i] = SCALE(73); + else if ((i % 32) < 16) + green[i] = SCALE(109); + else if ((i % 32) < 20) + green[i] = SCALE(146); + else if ((i % 32) < 24) + green[i] = SCALE(182); + else if ((i % 32) < 28) + green[i] = SCALE(219); + else if ((i % 32) < 32) + green[i] = SCALE(255); + + if ((i % 4) == 0) + blue[i] = SCALE(0); + else if ((i % 4) == 1) + blue[i] = SCALE(85); + else if ((i % 4) == 2) + blue[i] = SCALE(170); + else if ((i % 4) == 3) + blue[i] = SCALE(255); + } + break; + case 4: + red[0] = SCALE(255); + green[0] = 0; + blue[0] = 0; + + red[1] = 0; + green[1] = SCALE(255); + blue[1] = 0; + + red[2] = 0; + green[2] = 0; + blue[2] = SCALE(255); + + red[3] = SCALE(255); + green[3] = SCALE(255); + blue[3] = SCALE(255); + + red[4] = 0; + green[4] = SCALE(255); + blue[4] = SCALE(255); + + red[5] = SCALE(255); + green[5] = 0; + blue[5] = SCALE(255); + + red[6] = SCALE(255); + green[6] = SCALE(255); + blue[6] = 0; + + red[7] = 0; + green[7] = 0; + blue[7] = 0; + + red[8] = SCALE(176); + green[8] = SCALE(224); + blue[8] = SCALE(230); + red[9] = SCALE(100); + green[9] = SCALE(149); + blue[9] = SCALE(237); + red[10] = SCALE(46); + green[10] = SCALE(139); + blue[10] = SCALE(87); + red[11] = SCALE(160); + green[11] = SCALE(82); + blue[11] = SCALE(45); + red[12] = SCALE(238); + green[12] = SCALE(130); + blue[12] = SCALE(238); + red[13] = SCALE(176); + green[13] = SCALE(48); + blue[13] = SCALE(96); + red[14] = SCALE(50); + green[14] = SCALE(205); + blue[14] = SCALE(50); + red[15] = SCALE(240); + green[15] = SCALE(152); + blue[15] = SCALE(35); + break; + case 2: + red[0] = SCALE(255); + green[0] = 0; + blue[0] = 0; + + red[1] = 0; + green[1] = SCALE(255); + blue[1] = 0; + + red[2] = 0; + green[2] = 0; + blue[2] = SCALE(255); + red[3] = SCALE(255); + green[3] = SCALE(255); + blue[3] = SCALE(255); + break; + case 1: + red[0] = 0; + green[0] = 0; + blue[0] = 0; + + red[1] = SCALE(255); + green[1] = SCALE(255); + blue[1] = SCALE(255); + break; + } + + if ((tif = TIFFOpen(argv[3], "w")) == NULL) { + fprintf(stderr, "can't open %s as a TIFF file\n", argv[3]); + return 0; + } + + TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, WIDTH); + TIFFSetField(tif, TIFFTAG_IMAGELENGTH, HEIGHT); + TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, bits_per_pixel); + TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE); + TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_PALETTE); + TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1); + TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, 1); + TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); + TIFFSetField(tif, TIFFTAG_RESOLUTIONUNIT, RESUNIT_NONE); + TIFFSetField(tif, TIFFTAG_COLORMAP, red, green, blue); + + scan_line = (unsigned char *) malloc(WIDTH / (8 / bits_per_pixel)); + + for (i = 0; i < HEIGHT; i++) { + for (j = 0, k = 0; j < WIDTH;) { + cmap_index = (j / chunk_size) + ((i / chunk_size) * nchunks); + + switch (bits_per_pixel) { + case 8: + scan_line[k++] = cmap_index; + j++; + break; + case 4: + scan_line[k++] = (cmap_index << 4) + cmap_index; + j += 2; + break; + case 2: + scan_line[k++] = (cmap_index << 6) + (cmap_index << 4) + + (cmap_index << 2) + cmap_index; + j += 4; + break; + case 1: + scan_line[k++] = + ((j / chunk_size) == (i / chunk_size)) ? 0x00 : 0xff; + j += 8; + break; + } + } + TIFFWriteScanline(tif, scan_line, i, 0); + } + + free(scan_line); + TIFFClose(tif); + return 0; +} + +void +Usage() +{ + fprintf(stderr, "Usage: %s -depth (8 | 4 | 2 | 1) tiff-image\n", programName); + exit(0); +} +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/tiff/contrib/dbs/tiff-rgb.c b/tiff/contrib/dbs/tiff-rgb.c new file mode 100644 index 0000000..dcde673 --- /dev/null +++ b/tiff/contrib/dbs/tiff-rgb.c @@ -0,0 +1,201 @@ +/* $Id: tiff-rgb.c,v 1.3.2.1 2010-06-08 18:50:40 bfriesen Exp $ */ + +/* + * tiff-rgb.c -- create a 24-bit Class R (rgb) TIFF file + * + * Copyright 1990 by Digital Equipment Corporation, Maynard, Massachusetts. + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Digital not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR + * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +#include <math.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "tiffio.h" + +#define ROUND(x) (uint16) ((x) + 0.5) +#define CMSIZE 256 +#define WIDTH 525 +#define HEIGHT 512 +#define TIFF_GAMMA 2.2 + +void Usage(); +char * programName; + +int main(int argc, char **argv) +{ + char * input_file = NULL; + double image_gamma = TIFF_GAMMA; + int i, j; + TIFF * tif; + unsigned char * scan_line; + uint16 red[CMSIZE], green[CMSIZE], blue[CMSIZE]; + float refblackwhite[2*3]; + + programName = argv[0]; + + switch (argc) { + case 2: + image_gamma = TIFF_GAMMA; + input_file = argv[1]; + break; + case 4: + if (!strcmp(argv[1], "-gamma")) { + image_gamma = atof(argv[2]); + input_file = argv[3]; + } else + Usage(); + break; + default: + Usage(); + } + + for (i = 0; i < CMSIZE; i++) { + if (i == 0) + red[i] = green[i] = blue[i] = 0; + else { + red[i] = ROUND((pow(i / 255.0, 1.0 / image_gamma) * 65535.0)); + green[i] = ROUND((pow(i / 255.0, 1.0 / image_gamma) * 65535.0)); + blue[i] = ROUND((pow(i / 255.0, 1.0 / image_gamma) * 65535.0)); + } + } + refblackwhite[0] = 0.0; refblackwhite[1] = 255.0; + refblackwhite[2] = 0.0; refblackwhite[3] = 255.0; + refblackwhite[4] = 0.0; refblackwhite[5] = 255.0; + + if ((tif = TIFFOpen(input_file, "w")) == NULL) { + fprintf(stderr, "can't open %s as a TIFF file\n", input_file); + exit(0); + } + + TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, WIDTH); + TIFFSetField(tif, TIFFTAG_IMAGELENGTH, HEIGHT); + TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8); + TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE); + TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB); + TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 3); + TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, 1); + TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); + TIFFSetField(tif, TIFFTAG_RESOLUTIONUNIT, RESUNIT_NONE); +#ifdef notdef + TIFFSetField(tif, TIFFTAG_WHITEPOINT, whitex, whitey); + TIFFSetField(tif, TIFFTAG_PRIMARYCHROMATICITIES, primaries); +#endif + TIFFSetField(tif, TIFFTAG_REFERENCEBLACKWHITE, refblackwhite); + TIFFSetField(tif, TIFFTAG_TRANSFERFUNCTION, red, green, blue); + + scan_line = (unsigned char *) malloc(WIDTH * 3); + + for (i = 0; i < 255; i++) { + for (j = 0; j < 75; j++) { + scan_line[j * 3] = 255; + scan_line[(j * 3) + 1] = 255 - i; + scan_line[(j * 3) + 2] = 255 - i; + } + for (j = 75; j < 150; j++) { + scan_line[j * 3] = 255 - i; + scan_line[(j * 3) + 1] = 255; + scan_line[(j * 3) + 2] = 255 - i; + } + for (j = 150; j < 225; j++) { + scan_line[j * 3] = 255 - i; + scan_line[(j * 3) + 1] = 255 - i; + scan_line[(j * 3) + 2] = 255; + } + for (j = 225; j < 300; j++) { + scan_line[j * 3] = (i - 1) / 2; + scan_line[(j * 3) + 1] = (i - 1) / 2; + scan_line[(j * 3) + 2] = (i - 1) / 2; + } + for (j = 300; j < 375; j++) { + scan_line[j * 3] = 255 - i; + scan_line[(j * 3) + 1] = 255; + scan_line[(j * 3) + 2] = 255; + } + for (j = 375; j < 450; j++) { + scan_line[j * 3] = 255; + scan_line[(j * 3) + 1] = 255 - i; + scan_line[(j * 3) + 2] = 255; + } + for (j = 450; j < 525; j++) { + scan_line[j * 3] = 255; + scan_line[(j * 3) + 1] = 255; + scan_line[(j * 3) + 2] = 255 - i; + } + TIFFWriteScanline(tif, scan_line, i, 0); + } + for (i = 255; i < 512; i++) { + for (j = 0; j < 75; j++) { + scan_line[j * 3] = i; + scan_line[(j * 3) + 1] = 0; + scan_line[(j * 3) + 2] = 0; + } + for (j = 75; j < 150; j++) { + scan_line[j * 3] = 0; + scan_line[(j * 3) + 1] = i; + scan_line[(j * 3) + 2] = 0; + } + for (j = 150; j < 225; j++) { + scan_line[j * 3] = 0; + scan_line[(j * 3) + 1] = 0; + scan_line[(j * 3) + 2] = i; + } + for (j = 225; j < 300; j++) { + scan_line[j * 3] = (i - 1) / 2; + scan_line[(j * 3) + 1] = (i - 1) / 2; + scan_line[(j * 3) + 2] = (i - 1) / 2; + } + for (j = 300; j < 375; j++) { + scan_line[j * 3] = 0; + scan_line[(j * 3) + 1] = i; + scan_line[(j * 3) + 2] = i; + } + for (j = 375; j < 450; j++) { + scan_line[j * 3] = i; + scan_line[(j * 3) + 1] = 0; + scan_line[(j * 3) + 2] = i; + } + for (j = 450; j < 525; j++) { + scan_line[j * 3] = i; + scan_line[(j * 3) + 1] = i; + scan_line[(j * 3) + 2] = 0; + } + TIFFWriteScanline(tif, scan_line, i, 0); + } + + free(scan_line); + TIFFClose(tif); + exit(0); +} + +void +Usage() +{ + fprintf(stderr, "Usage: %s -gamma gamma tiff-image\n", programName); + exit(0); +} +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/tiff/contrib/dbs/xtiff/Makefile.am b/tiff/contrib/dbs/xtiff/Makefile.am new file mode 100644 index 0000000..84c8a16 --- /dev/null +++ b/tiff/contrib/dbs/xtiff/Makefile.am @@ -0,0 +1,43 @@ +# $Id: Makefile.am,v 1.4 2007/02/24 15:03:49 dron Exp $ +# +# Tag Image File Format (TIFF) Software +# +# Copyright (C) 2004, Andrey Kiselev <dron@ak4719.spb.edu> +# +# Permission to use, copy, modify, distribute, and sell this software and +# its documentation for any purpose is hereby granted without fee, provided +# that (i) the above copyright notices and this permission notice appear in +# all copies of the software and related documentation, and (ii) the names of +# Sam Leffler and Silicon Graphics may not be used in any advertising or +# publicity relating to the software without the specific, prior written +# permission of Sam Leffler and Silicon Graphics. +# +# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +# +# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +# OF THIS SOFTWARE. + +# Process this file with automake to produce Makefile.in. + +#LIBTIFF = $(top_builddir)/libtiff/libtiff.la + +EXTRA_DIST = README patchlevel.h xtiff.c xtifficon.h + +#noinst_PROGRAMS = + +#if HAVE_XAW +#noinst_PROGRAMS += xtiff +#endif + +#xtiff_SOURCES = patchlevel.h xtiff.c xtifficon.h +#xtiff_CFLAGS = $(CFLAGS) $(XAW_CFLAGS) $(AM_CFLAGS) +#xtiff_LDADD = $(LIBTIFF) $(X_LIBS) $(XAW_LIBS) + +#INCLUDES = -I$(top_srcdir)/libtiff + diff --git a/tiff/contrib/dbs/xtiff/Makefile.in b/tiff/contrib/dbs/xtiff/Makefile.in new file mode 100644 index 0000000..65b5259 --- /dev/null +++ b/tiff/contrib/dbs/xtiff/Makefile.in @@ -0,0 +1,436 @@ +# Makefile.in generated by automake 1.11 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +# $Id: Makefile.am,v 1.4 2007/02/24 15:03:49 dron Exp $ +# +# Tag Image File Format (TIFF) Software +# +# Copyright (C) 2004, Andrey Kiselev <dron@ak4719.spb.edu> +# +# Permission to use, copy, modify, distribute, and sell this software and +# its documentation for any purpose is hereby granted without fee, provided +# that (i) the above copyright notices and this permission notice appear in +# all copies of the software and related documentation, and (ii) the names of +# Sam Leffler and Silicon Graphics may not be used in any advertising or +# publicity relating to the software without the specific, prior written +# permission of Sam Leffler and Silicon Graphics. +# +# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +# +# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +# OF THIS SOFTWARE. + +# Process this file with automake to produce Makefile.in. + +#LIBTIFF = $(top_builddir)/libtiff/libtiff.la +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +subdir = contrib/dbs/xtiff +DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/acinclude.m4 \ + $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ + $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ + $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/libtiff/tif_config.h \ + $(top_builddir)/libtiff/tiffconf.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +AM_V_GEN = $(am__v_GEN_$(V)) +am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) +am__v_GEN_0 = @echo " GEN " $@; +AM_V_at = $(am__v_at_$(V)) +am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) +am__v_at_0 = @ +SOURCES = +DIST_SOURCES = +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GLUT_CFLAGS = @GLUT_CFLAGS@ +GLUT_LIBS = @GLUT_LIBS@ +GLU_CFLAGS = @GLU_CFLAGS@ +GLU_LIBS = @GLU_LIBS@ +GL_CFLAGS = @GL_CFLAGS@ +GL_LIBS = @GL_LIBS@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBDIR = @LIBDIR@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTIFF_ALPHA_VERSION = @LIBTIFF_ALPHA_VERSION@ +LIBTIFF_DOCDIR = @LIBTIFF_DOCDIR@ +LIBTIFF_MAJOR_VERSION = @LIBTIFF_MAJOR_VERSION@ +LIBTIFF_MICRO_VERSION = @LIBTIFF_MICRO_VERSION@ +LIBTIFF_MINOR_VERSION = @LIBTIFF_MINOR_VERSION@ +LIBTIFF_RELEASE_DATE = @LIBTIFF_RELEASE_DATE@ +LIBTIFF_VERSION = @LIBTIFF_VERSION@ +LIBTIFF_VERSION_INFO = @LIBTIFF_VERSION_INFO@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PTHREAD_CC = @PTHREAD_CC@ +PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ +PTHREAD_LIBS = @PTHREAD_LIBS@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +XMKMF = @XMKMF@ +X_CFLAGS = @X_CFLAGS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_LIBS = @X_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +acx_pthread_config = @acx_pthread_config@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +EXTRA_DIST = README patchlevel.h xtiff.c xtifficon.h +all: all-am + +.SUFFIXES: +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign contrib/dbs/xtiff/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign contrib/dbs/xtiff/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +tags: TAGS +TAGS: + +ctags: CTAGS +CTAGS: + + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: all all-am check check-am clean clean-generic clean-libtool \ + distclean distclean-generic distclean-libtool distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-data install-data-am install-dvi install-dvi-am \ + install-exec install-exec-am install-html install-html-am \ + install-info install-info-am install-man install-pdf \ + install-pdf-am install-ps install-ps-am install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am uninstall uninstall-am + + +#noinst_PROGRAMS = + +#if HAVE_XAW +#noinst_PROGRAMS += xtiff +#endif + +#xtiff_SOURCES = patchlevel.h xtiff.c xtifficon.h +#xtiff_CFLAGS = $(CFLAGS) $(XAW_CFLAGS) $(AM_CFLAGS) +#xtiff_LDADD = $(LIBTIFF) $(X_LIBS) $(XAW_LIBS) + +#INCLUDES = -I$(top_srcdir)/libtiff + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/tiff/contrib/dbs/xtiff/README b/tiff/contrib/dbs/xtiff/README new file mode 100644 index 0000000..fa15147 --- /dev/null +++ b/tiff/contrib/dbs/xtiff/README @@ -0,0 +1,6 @@ +xtiff 2.0 + +xtiff is a tool for viewing a TIFF file in an X window. It was written to +handle as many different kinds of TIFF files as possible while remaining +simple, portable and efficient. xtiff requires X11 R4, the Athena Widgets +and Sam Leffler's libtiff package (which can be found on ucbvax.berkeley.edu). diff --git a/tiff/contrib/dbs/xtiff/patchlevel.h b/tiff/contrib/dbs/xtiff/patchlevel.h new file mode 100644 index 0000000..538b6d9 --- /dev/null +++ b/tiff/contrib/dbs/xtiff/patchlevel.h @@ -0,0 +1,8 @@ +#define PATCHLEVEL 0 +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/tiff/contrib/dbs/xtiff/xtiff.c b/tiff/contrib/dbs/xtiff/xtiff.c new file mode 100644 index 0000000..7fe3977 --- /dev/null +++ b/tiff/contrib/dbs/xtiff/xtiff.c @@ -0,0 +1,1290 @@ +/* + * $Id: xtiff.c,v 1.2.2.1 2010-06-08 18:50:40 bfriesen Exp $ + * + * xtiff - view a TIFF file in an X window + * + * Dan Sears + * Chris Sears + * + * Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts. + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Digital not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR + * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * + * Revision 1.0 90/05/07 + * Initial release. + * Revision 2.0 90/12/20 + * Converted to use the Athena Widgets and the Xt Intrinsics. + * + * Notes: + * + * According to the TIFF 5.0 Specification, it is possible to have + * both a TIFFTAG_COLORMAP and a TIFFTAG_COLORRESPONSECURVE. This + * doesn't make sense since a TIFFTAG_COLORMAP is 16 bits wide and + * a TIFFTAG_COLORRESPONSECURVE is tfBitsPerSample bits wide for each + * channel. This is probably a bug in the specification. + * In this case, TIFFTAG_COLORRESPONSECURVE is ignored. + * This might make sense if TIFFTAG_COLORMAP was 8 bits wide. + * + * TIFFTAG_COLORMAP is often incorrectly written as ranging from + * 0 to 255 rather than from 0 to 65535. CheckAndCorrectColormap() + * takes care of this. + * + * Only ORIENTATION_TOPLEFT is supported correctly. This is the + * default TIFF and X orientation. Other orientations will be + * displayed incorrectly. + * + * There is no support for or use of 3/3/2 DirectColor visuals. + * TIFFTAG_MINSAMPLEVALUE and TIFFTAG_MAXSAMPLEVALUE are not supported. + * + * Only TIFFTAG_BITSPERSAMPLE values that are 1, 2, 4 or 8 are supported. + */ +#include <math.h> +#include <stdio.h> +#include <stdlib.h> +#include <tiffio.h> +#include <X11/Xatom.h> +#include <X11/Intrinsic.h> +#include <X11/StringDefs.h> +#include <X11/Xproto.h> +#include <X11/Shell.h> +#include <X11/Xaw/Form.h> +#include <X11/Xaw/List.h> +#include <X11/Xaw/Label.h> +#include <X11/cursorfont.h> +#define XK_MISCELLANY +#include <X11/keysymdef.h> +#include "xtifficon.h" + +#define TIFF_GAMMA "2.2" /* default gamma from the TIFF 5.0 spec */ +#define ROUND(x) (uint16) ((x) + 0.5) +#define SCALE(x, s) (((x) * 65535L) / (s)) +#define MCHECK(m) if (!m) { fprintf(stderr, "malloc failed\n"); exit(0); } +#define MIN(a, b) (((a) < (b)) ? (a) : (b)) +#define MAX(a, b) (((a) > (b)) ? (a) : (b)) +#define VIEWPORT_WIDTH 700 +#define VIEWPORT_HEIGHT 500 +#define KEY_TRANSLATE 20 + +#ifdef __STDC__ +#define PP(args) args +#else +#define PP(args) () +#endif + +int main PP((int argc, char **argv)); +void OpenTIFFFile PP((void)); +void GetTIFFHeader PP((void)); +void SetNameLabel PP((void)); +void CheckAndCorrectColormap PP((void)); +void SimpleGammaCorrection PP((void)); +void GetVisual PP((void)); +Boolean SearchVisualList PP((int image_depth, + int visual_class, Visual **visual)); +void GetTIFFImage PP((void)); +void CreateXImage PP((void)); +XtCallbackProc SelectProc PP((Widget w, caddr_t unused_1, caddr_t unused_2)); +void QuitProc PP((void)); +void NextProc PP((void)); +void PreviousProc PP((void)); +void PageProc PP((int direction)); +void EventProc PP((Widget widget, caddr_t unused, XEvent *event)); +void ResizeProc PP((void)); +int XTiffErrorHandler PP((Display *display, XErrorEvent *error_event)); +void Usage PP((void)); + +int xtVersion = XtSpecificationRelease; /* xtiff depends on R4 or higher */ + +/* + * Xt data structures + */ +Widget shellWidget, formWidget, listWidget, labelWidget, imageWidget; + +enum { ButtonQuit = 0, ButtonPreviousPage = 1, ButtonNextPage = 2 }; + +String buttonStrings[] = { "Quit", "Previous", "Next" }; + +static XrmOptionDescRec shellOptions[] = { + { "-help", "*help", XrmoptionNoArg, (caddr_t) "True" }, + { "-gamma", "*gamma", XrmoptionSepArg, NULL }, + { "-usePixmap", "*usePixmap", XrmoptionSepArg, NULL }, + { "-viewportWidth", "*viewportWidth", XrmoptionSepArg, NULL }, + { "-viewportHeight", "*viewportHeight", XrmoptionSepArg, NULL }, + { "-translate", "*translate", XrmoptionSepArg, NULL }, + { "-verbose", "*verbose", XrmoptionSepArg, NULL } +}; + +typedef struct { + Boolean help; + float gamma; + Boolean usePixmap; + uint32 viewportWidth; + uint32 viewportHeight; + int translate; + Boolean verbose; +} AppData, *AppDataPtr; + +AppData appData; + +XtResource clientResources[] = { + { + "help", XtCBoolean, XtRBoolean, sizeof(Boolean), + XtOffset(AppDataPtr, help), XtRImmediate, (XtPointer) False + }, { + "gamma", "Gamma", XtRFloat, sizeof(float), + XtOffset(AppDataPtr, gamma), XtRString, (XtPointer) TIFF_GAMMA + }, { + "usePixmap", "UsePixmap", XtRBoolean, sizeof(Boolean), + XtOffset(AppDataPtr, usePixmap), XtRImmediate, (XtPointer) True + }, { + "viewportWidth", "ViewportWidth", XtRInt, sizeof(int), + XtOffset(AppDataPtr, viewportWidth), XtRImmediate, + (XtPointer) VIEWPORT_WIDTH + }, { + "viewportHeight", "ViewportHeight", XtRInt, sizeof(int), + XtOffset(AppDataPtr, viewportHeight), XtRImmediate, + (XtPointer) VIEWPORT_HEIGHT + }, { + "translate", "Translate", XtRInt, sizeof(int), + XtOffset(AppDataPtr, translate), XtRImmediate, (XtPointer) KEY_TRANSLATE + }, { + "verbose", "Verbose", XtRBoolean, sizeof(Boolean), + XtOffset(AppDataPtr, verbose), XtRImmediate, (XtPointer) True + } +}; + +Arg formArgs[] = { + { XtNresizable, True } +}; + +Arg listArgs[] = { + { XtNresizable, False }, + { XtNborderWidth, 0 }, + { XtNdefaultColumns, 3 }, + { XtNforceColumns, True }, + { XtNlist, (int) buttonStrings }, + { XtNnumberStrings, XtNumber(buttonStrings) }, + { XtNtop, XtChainTop }, + { XtNleft, XtChainLeft }, + { XtNbottom, XtChainTop }, + { XtNright, XtChainLeft } +}; + +Arg labelArgs[] = { + { XtNresizable, False }, + { XtNwidth, 200 }, + { XtNborderWidth, 0 }, + { XtNjustify, XtJustifyLeft }, + { XtNtop, XtChainTop }, + { XtNleft, XtChainLeft }, + { XtNbottom, XtChainTop }, + { XtNright, XtChainLeft } +}; + +Arg imageArgs[] = { + { XtNresizable, True }, + { XtNborderWidth, 0 }, + { XtNtop, XtChainTop }, + { XtNleft, XtChainLeft }, + { XtNbottom, XtChainTop }, + { XtNright, XtChainLeft } +}; + +XtActionsRec actionsTable[] = { + { "quit", QuitProc }, + { "next", NextProc }, + { "previous", PreviousProc }, + { "notifyresize", ResizeProc } +}; + +char translationsTable[] = "<Key>q: quit() \n \ + <Key>Q: quit() \n \ + <Message>WM_PROTOCOLS: quit()\n \ + <Key>p: previous() \n \ + <Key>P: previous() \n \ + <Key>n: next() \n \ + <Key>N: next() \n \ + <Configure>: notifyresize()"; + +/* + * X data structures + */ +Colormap xColormap; +Display * xDisplay; +Pixmap xImagePixmap; +Visual * xVisual; +XImage * xImage; +GC xWinGc; +int xImageDepth, xScreen, xRedMask, xGreenMask, xBlueMask, + xOffset = 0, yOffset = 0, grabX = -1, grabY = -1; +unsigned char basePixel = 0; + +/* + * TIFF data structures + */ +TIFF * tfFile = NULL; +uint32 tfImageWidth, tfImageHeight; +uint16 tfBitsPerSample, tfSamplesPerPixel, tfPlanarConfiguration, + tfPhotometricInterpretation, tfGrayResponseUnit, + tfImageDepth, tfBytesPerRow; +int tfDirectory = 0, tfMultiPage = False; +double tfUnitMap, tfGrayResponseUnitMap[] = { + -1, -10, -100, -1000, -10000, -100000 + }; + +/* + * display data structures + */ +double *dRed, *dGreen, *dBlue; + +/* + * shared data structures + */ +uint16 * redMap = NULL, *greenMap = NULL, *blueMap = NULL, + *grayMap = NULL, colormapSize; +char * imageMemory; +char * fileName; + +int +main(int argc, char **argv) +{ + XSetWindowAttributes window_attributes; + Widget widget_list[3]; + Arg args[5]; + + setbuf(stdout, NULL); setbuf(stderr, NULL); + + shellWidget = XtInitialize(argv[0], "XTiff", shellOptions, + XtNumber(shellOptions), &argc, argv); + + XSetErrorHandler(XTiffErrorHandler); + + XtGetApplicationResources(shellWidget, &appData, + (XtResourceList) clientResources, (Cardinal) XtNumber(clientResources), + (ArgList) NULL, (Cardinal) 0); + + if ((argc <= 1) || (argc > 2) || appData.help) + Usage(); + + if (appData.verbose == False) { + TIFFSetErrorHandler(0); + TIFFSetWarningHandler(0); + } + + fileName = argv[1]; + + xDisplay = XtDisplay(shellWidget); + xScreen = DefaultScreen(xDisplay); + + OpenTIFFFile(); + GetTIFFHeader(); + SimpleGammaCorrection(); + GetVisual(); + GetTIFFImage(); + + /* + * Send visual, colormap, depth and iconPixmap to shellWidget. + * Sending the visual to the shell is only possible with the advent of R4. + */ + XtSetArg(args[0], XtNvisual, xVisual); + XtSetArg(args[1], XtNcolormap, xColormap); + XtSetArg(args[2], XtNdepth, + xImageDepth == 1 ? DefaultDepth(xDisplay, xScreen) : xImageDepth); + XtSetArg(args[3], XtNiconPixmap, + XCreateBitmapFromData(xDisplay, RootWindow(xDisplay, xScreen), + xtifficon_bits, xtifficon_width, xtifficon_height)); + XtSetArg(args[4], XtNallowShellResize, True); + XtSetValues(shellWidget, args, 5); + + /* + * widget instance hierarchy + */ + formWidget = XtCreateManagedWidget("form", formWidgetClass, + shellWidget, formArgs, XtNumber(formArgs)); + + widget_list[0] = listWidget = XtCreateWidget("list", + listWidgetClass, formWidget, listArgs, XtNumber(listArgs)); + + widget_list[1] = labelWidget = XtCreateWidget("label", + labelWidgetClass, formWidget, labelArgs, XtNumber(labelArgs)); + + widget_list[2] = imageWidget = XtCreateWidget("image", + widgetClass, formWidget, imageArgs, XtNumber(imageArgs)); + + XtManageChildren(widget_list, XtNumber(widget_list)); + + /* + * initial widget sizes - for small images let xtiff size itself + */ + if (tfImageWidth >= appData.viewportWidth) { + XtSetArg(args[0], XtNwidth, appData.viewportWidth); + XtSetValues(shellWidget, args, 1); + } + if (tfImageHeight >= appData.viewportHeight) { + XtSetArg(args[0], XtNheight, appData.viewportHeight); + XtSetValues(shellWidget, args, 1); + } + + XtSetArg(args[0], XtNwidth, tfImageWidth); + XtSetArg(args[1], XtNheight, tfImageHeight); + XtSetValues(imageWidget, args, 2); + + /* + * formWidget uses these constraints but they are stored in the children. + */ + XtSetArg(args[0], XtNfromVert, listWidget); + XtSetValues(imageWidget, args, 1); + XtSetArg(args[0], XtNfromHoriz, listWidget); + XtSetValues(labelWidget, args, 1); + + SetNameLabel(); + + XtAddCallback(listWidget, XtNcallback, (XtCallbackProc) SelectProc, + (XtPointer) NULL); + + XtAddActions(actionsTable, XtNumber(actionsTable)); + XtSetArg(args[0], XtNtranslations, + XtParseTranslationTable(translationsTable)); + XtSetValues(formWidget, &args[0], 1); + XtSetValues(imageWidget, &args[0], 1); + + /* + * This is intended to be a little faster than going through + * the translation manager. + */ + XtAddEventHandler(imageWidget, ExposureMask | ButtonPressMask + | ButtonReleaseMask | Button1MotionMask | KeyPressMask, + False, EventProc, NULL); + + XtRealizeWidget(shellWidget); + + window_attributes.cursor = XCreateFontCursor(xDisplay, XC_fleur); + XChangeWindowAttributes(xDisplay, XtWindow(imageWidget), + CWCursor, &window_attributes); + + CreateXImage(); + + XtMainLoop(); + + return 0; +} + +void +OpenTIFFFile() +{ + if (tfFile != NULL) + TIFFClose(tfFile); + + if ((tfFile = TIFFOpen(fileName, "r")) == NULL) { + fprintf(appData.verbose ? stderr : stdout, + "xtiff: can't open %s as a TIFF file\n", fileName); + exit(0); + } + + tfMultiPage = (TIFFLastDirectory(tfFile) ? False : True); +} + +void +GetTIFFHeader() +{ + register int i; + + if (!TIFFSetDirectory(tfFile, tfDirectory)) { + fprintf(stderr, "xtiff: can't seek to directory %d in %s\n", + tfDirectory, fileName); + exit(0); + } + + TIFFGetField(tfFile, TIFFTAG_IMAGEWIDTH, &tfImageWidth); + TIFFGetField(tfFile, TIFFTAG_IMAGELENGTH, &tfImageHeight); + + /* + * If the following tags aren't present then use the TIFF defaults. + */ + TIFFGetFieldDefaulted(tfFile, TIFFTAG_BITSPERSAMPLE, &tfBitsPerSample); + TIFFGetFieldDefaulted(tfFile, TIFFTAG_SAMPLESPERPIXEL, &tfSamplesPerPixel); + TIFFGetFieldDefaulted(tfFile, TIFFTAG_PLANARCONFIG, &tfPlanarConfiguration); + TIFFGetFieldDefaulted(tfFile, TIFFTAG_GRAYRESPONSEUNIT, &tfGrayResponseUnit); + + tfUnitMap = tfGrayResponseUnitMap[tfGrayResponseUnit]; + colormapSize = 1 << tfBitsPerSample; + tfImageDepth = tfBitsPerSample * tfSamplesPerPixel; + + dRed = (double *) malloc(colormapSize * sizeof(double)); + dGreen = (double *) malloc(colormapSize * sizeof(double)); + dBlue = (double *) malloc(colormapSize * sizeof(double)); + MCHECK(dRed); MCHECK(dGreen); MCHECK(dBlue); + + /* + * If TIFFTAG_PHOTOMETRIC is not present then assign a reasonable default. + * The TIFF 5.0 specification doesn't give a default. + */ + if (!TIFFGetField(tfFile, TIFFTAG_PHOTOMETRIC, + &tfPhotometricInterpretation)) { + if (tfSamplesPerPixel != 1) + tfPhotometricInterpretation = PHOTOMETRIC_RGB; + else if (tfBitsPerSample == 1) + tfPhotometricInterpretation = PHOTOMETRIC_MINISBLACK; + else if (TIFFGetField(tfFile, TIFFTAG_COLORMAP, + &redMap, &greenMap, &blueMap)) { + tfPhotometricInterpretation = PHOTOMETRIC_PALETTE; + redMap = greenMap = blueMap = NULL; + } else + tfPhotometricInterpretation = PHOTOMETRIC_MINISBLACK; + } + + /* + * Given TIFFTAG_PHOTOMETRIC extract or create the response curves. + */ + switch (tfPhotometricInterpretation) { + case PHOTOMETRIC_RGB: + redMap = (uint16 *) malloc(colormapSize * sizeof(uint16)); + greenMap = (uint16 *) malloc(colormapSize * sizeof(uint16)); + blueMap = (uint16 *) malloc(colormapSize * sizeof(uint16)); + MCHECK(redMap); MCHECK(greenMap); MCHECK(blueMap); + for (i = 0; i < colormapSize; i++) + dRed[i] = dGreen[i] = dBlue[i] + = (double) SCALE(i, colormapSize - 1); + break; + case PHOTOMETRIC_PALETTE: + if (!TIFFGetField(tfFile, TIFFTAG_COLORMAP, + &redMap, &greenMap, &blueMap)) { + redMap = (uint16 *) malloc(colormapSize * sizeof(uint16)); + greenMap = (uint16 *) malloc(colormapSize * sizeof(uint16)); + blueMap = (uint16 *) malloc(colormapSize * sizeof(uint16)); + MCHECK(redMap); MCHECK(greenMap); MCHECK(blueMap); + for (i = 0; i < colormapSize; i++) + dRed[i] = dGreen[i] = dBlue[i] + = (double) SCALE(i, colormapSize - 1); + } else { + CheckAndCorrectColormap(); + for (i = 0; i < colormapSize; i++) { + dRed[i] = (double) redMap[i]; + dGreen[i] = (double) greenMap[i]; + dBlue[i] = (double) blueMap[i]; + } + } + break; + case PHOTOMETRIC_MINISWHITE: + redMap = (uint16 *) malloc(colormapSize * sizeof(uint16)); + greenMap = (uint16 *) malloc(colormapSize * sizeof(uint16)); + blueMap = (uint16 *) malloc(colormapSize * sizeof(uint16)); + MCHECK(redMap); MCHECK(greenMap); MCHECK(blueMap); + for (i = 0; i < colormapSize; i++) + dRed[i] = dGreen[i] = dBlue[i] = (double) + SCALE(colormapSize-1-i, colormapSize-1); + break; + case PHOTOMETRIC_MINISBLACK: + redMap = (uint16 *) malloc(colormapSize * sizeof(uint16)); + greenMap = (uint16 *) malloc(colormapSize * sizeof(uint16)); + blueMap = (uint16 *) malloc(colormapSize * sizeof(uint16)); + MCHECK(redMap); MCHECK(greenMap); MCHECK(blueMap); + for (i = 0; i < colormapSize; i++) + dRed[i] = dGreen[i] = dBlue[i] = (double) SCALE(i, colormapSize-1); + break; + default: + fprintf(stderr, + "xtiff: can't display photometric interpretation type %d\n", + tfPhotometricInterpretation); + exit(0); + } +} + +void +SetNameLabel() +{ + char buffer[BUFSIZ]; + Arg args[1]; + + if (tfMultiPage) + sprintf(buffer, "%s - page %d", fileName, tfDirectory); + else + strcpy(buffer, fileName); + XtSetArg(args[0], XtNlabel, buffer); + XtSetValues(labelWidget, args, 1); +} + +/* + * Many programs get TIFF colormaps wrong. They use 8-bit colormaps instead of + * 16-bit colormaps. This function is a heuristic to detect and correct this. + */ +void +CheckAndCorrectColormap() +{ + register int i; + + for (i = 0; i < colormapSize; i++) + if ((redMap[i] > 255) || (greenMap[i] > 255) || (blueMap[i] > 255)) + return; + + for (i = 0; i < colormapSize; i++) { + redMap[i] = SCALE(redMap[i], 255); + greenMap[i] = SCALE(greenMap[i], 255); + blueMap[i] = SCALE(blueMap[i], 255); + } + TIFFWarning(fileName, "Assuming 8-bit colormap"); +} + +void +SimpleGammaCorrection() +{ + register int i; + register double i_gamma = 1.0 / appData.gamma; + + for (i = 0; i < colormapSize; i++) { + if (((tfPhotometricInterpretation == PHOTOMETRIC_MINISWHITE) + && (i == colormapSize - 1)) + || ((tfPhotometricInterpretation == PHOTOMETRIC_MINISBLACK) + && (i == 0))) + redMap[i] = greenMap[i] = blueMap[i] = 0; + else { + redMap[i] = ROUND((pow(dRed[i] / 65535.0, i_gamma) * 65535.0)); + greenMap[i] = ROUND((pow(dGreen[i] / 65535.0, i_gamma) * 65535.0)); + blueMap[i] = ROUND((pow(dBlue[i] / 65535.0, i_gamma) * 65535.0)); + } + } + + free(dRed); free(dGreen); free(dBlue); +} + +static char* classNames[] = { + "StaticGray", + "GrayScale", + "StaticColor", + "PseudoColor", + "TrueColor", + "DirectColor" +}; + +/* + * Current limitation: the visual is set initially by the first file. + * It cannot be changed. + */ +void +GetVisual() +{ + XColor *colors = NULL; + unsigned long *pixels = NULL; + unsigned long i; + + switch (tfImageDepth) { + /* + * X really wants a 32-bit image with the fourth channel unused, + * but the visual structure thinks it's 24-bit. bitmap_unit is 32. + */ + case 32: + case 24: + if (SearchVisualList(24, DirectColor, &xVisual) == False) { + fprintf(stderr, "xtiff: 24-bit DirectColor visual not available\n"); + exit(0); + } + + colors = (XColor *) malloc(3 * colormapSize * sizeof(XColor)); + MCHECK(colors); + + for (i = 0; i < colormapSize; i++) { + colors[i].pixel = (i << 16) + (i << 8) + i; + colors[i].red = redMap[i]; + colors[i].green = greenMap[i]; + colors[i].blue = blueMap[i]; + colors[i].flags = DoRed | DoGreen | DoBlue; + } + + xColormap = XCreateColormap(xDisplay, RootWindow(xDisplay, xScreen), + xVisual, AllocAll); + XStoreColors(xDisplay, xColormap, colors, colormapSize); + break; + case 8: + case 4: + case 2: + /* + * We assume that systems with 24-bit visuals also have 8-bit visuals. + * We don't promote from 8-bit PseudoColor to 24/32 bit DirectColor. + */ + switch (tfPhotometricInterpretation) { + case PHOTOMETRIC_MINISWHITE: + case PHOTOMETRIC_MINISBLACK: + if (SearchVisualList((int) tfImageDepth, GrayScale, &xVisual) == True) + break; + case PHOTOMETRIC_PALETTE: + if (SearchVisualList((int) tfImageDepth, PseudoColor, &xVisual) == True) + break; + default: + fprintf(stderr, "xtiff: Unsupported TIFF/X configuration\n"); + exit(0); + } + + colors = (XColor *) malloc(colormapSize * sizeof(XColor)); + MCHECK(colors); + + for (i = 0; i < colormapSize; i++) { + colors[i].pixel = i; + colors[i].red = redMap[i]; + colors[i].green = greenMap[i]; + colors[i].blue = blueMap[i]; + colors[i].flags = DoRed | DoGreen | DoBlue; + } + + /* + * xtiff's colormap allocation is private. It does not attempt + * to detect whether any existing colormap entries are suitable + * for its use. This will cause colormap flashing. Furthermore, + * background and foreground are taken from the environment. + * For example, the foreground color may be red when the visual + * is GrayScale. If the colormap is completely populated, + * Xt will not be able to allocate fg and bg. + */ + if (tfImageDepth == 8) + xColormap = XCreateColormap(xDisplay, RootWindow(xDisplay, xScreen), + xVisual, AllocAll); + else { + xColormap = XCreateColormap(xDisplay, RootWindow(xDisplay, xScreen), + xVisual, AllocNone); + pixels = (unsigned long *) + malloc(colormapSize * sizeof(unsigned long)); + MCHECK(pixels); + (void) XAllocColorCells(xDisplay, xColormap, True, + NULL, 0, pixels, colormapSize); + basePixel = (unsigned char) pixels[0]; + free(pixels); + } + XStoreColors(xDisplay, xColormap, colors, colormapSize); + break; + case 1: + xImageDepth = 1; + xVisual = DefaultVisual(xDisplay, xScreen); + xColormap = DefaultColormap(xDisplay, xScreen); + break; + default: + fprintf(stderr, "xtiff: unsupported image depth %d\n", tfImageDepth); + exit(0); + } + + if (appData.verbose == True) + fprintf(stderr, "%s: Using %d-bit %s visual.\n", + fileName, xImageDepth, classNames[xVisual->class]); + + if (colors != NULL) + free(colors); + if (grayMap != NULL) + free(grayMap); + if (redMap != NULL) + free(redMap); + if (greenMap != NULL) + free(greenMap); + if (blueMap != NULL) + free(blueMap); + + colors = NULL; grayMap = redMap = greenMap = blueMap = NULL; +} + +/* + * Search for an appropriate visual. Promote where necessary. + * Check to make sure that ENOUGH colormap entries are writeable. + * basePixel was determined when XAllocColorCells() contiguously + * allocated enough entries. basePixel is used below in GetTIFFImage. + */ +Boolean +SearchVisualList(image_depth, visual_class, visual) + int image_depth, visual_class; + Visual **visual; +{ + XVisualInfo template_visual, *visual_list, *vl; + int i, n_visuals; + + template_visual.screen = xScreen; + vl = visual_list = XGetVisualInfo(xDisplay, VisualScreenMask, + &template_visual, &n_visuals); + + if (n_visuals == 0) { + fprintf(stderr, "xtiff: visual list not available\n"); + exit(0); + } + + for (i = 0; i < n_visuals; vl++, i++) { + if ((vl->class == visual_class) && (vl->depth >= image_depth) + && (vl->visual->map_entries >= (1 << vl->depth))) { + *visual = vl->visual; + xImageDepth = vl->depth; + xRedMask = vl->red_mask; + xGreenMask = vl->green_mask; + xBlueMask = vl->blue_mask; + XFree((char *) visual_list); + return True; + } + } + + XFree((char *) visual_list); + return False; +} + +void +GetTIFFImage() +{ + int pixel_map[3], red_shift, green_shift, blue_shift; + char *scan_line, *output_p, *input_p; + uint32 i, j; + uint16 s; + + scan_line = (char *) malloc(tfBytesPerRow = TIFFScanlineSize(tfFile)); + MCHECK(scan_line); + + if ((tfImageDepth == 32) || (tfImageDepth == 24)) { + output_p = imageMemory = (char *) + malloc(tfImageWidth * tfImageHeight * 4); + MCHECK(imageMemory); + + /* + * Handle different color masks for different frame buffers. + */ + if (ImageByteOrder(xDisplay) == LSBFirst) { /* DECstation 5000 */ + red_shift = pixel_map[0] = xRedMask == 0xFF000000 ? 3 + : (xRedMask == 0xFF0000 ? 2 : (xRedMask == 0xFF00 ? 1 : 0)); + green_shift = pixel_map[1] = xGreenMask == 0xFF000000 ? 3 + : (xGreenMask == 0xFF0000 ? 2 : (xGreenMask == 0xFF00 ? 1 : 0)); + blue_shift = pixel_map[2] = xBlueMask == 0xFF000000 ? 3 + : (xBlueMask == 0xFF0000 ? 2 : (xBlueMask == 0xFF00 ? 1 : 0)); + } else { /* Ardent */ + red_shift = pixel_map[0] = xRedMask == 0xFF000000 ? 0 + : (xRedMask == 0xFF0000 ? 1 : (xRedMask == 0xFF00 ? 2 : 3)); + green_shift = pixel_map[0] = xGreenMask == 0xFF000000 ? 0 + : (xGreenMask == 0xFF0000 ? 1 : (xGreenMask == 0xFF00 ? 2 : 3)); + blue_shift = pixel_map[0] = xBlueMask == 0xFF000000 ? 0 + : (xBlueMask == 0xFF0000 ? 1 : (xBlueMask == 0xFF00 ? 2 : 3)); + } + + if (tfPlanarConfiguration == PLANARCONFIG_CONTIG) { + for (i = 0; i < tfImageHeight; i++) { + if (TIFFReadScanline(tfFile, scan_line, i, 0) < 0) + break; + for (input_p = scan_line, j = 0; j < tfImageWidth; j++) { + *(output_p + red_shift) = *input_p++; + *(output_p + green_shift) = *input_p++; + *(output_p + blue_shift) = *input_p++; + output_p += 4; + if (tfSamplesPerPixel == 4) /* skip the fourth channel */ + input_p++; + } + } + } else { + for (s = 0; s < tfSamplesPerPixel; s++) { + if (s == 3) /* skip the fourth channel */ + continue; + for (i = 0; i < tfImageHeight; i++) { + if (TIFFReadScanline(tfFile, scan_line, i, s) < 0) + break; + input_p = scan_line; + output_p = imageMemory + (i*tfImageWidth*4) + pixel_map[s]; + for (j = 0; j < tfImageWidth; j++, output_p += 4) + *output_p = *input_p++; + } + } + } + } else { + if (xImageDepth == tfImageDepth) { + output_p = imageMemory = (char *) + malloc(tfBytesPerRow * tfImageHeight); + MCHECK(imageMemory); + + for (i = 0; i < tfImageHeight; i++, output_p += tfBytesPerRow) + if (TIFFReadScanline(tfFile, output_p, i, 0) < 0) + break; + } else if ((xImageDepth == 8) && (tfImageDepth == 4)) { + output_p = imageMemory = (char *) + malloc(tfBytesPerRow * 2 * tfImageHeight + 2); + MCHECK(imageMemory); + + /* + * If a scanline is of odd size the inner loop below will overshoot. + * This is handled very simply by recalculating the start point at + * each scanline and padding imageMemory a little at the end. + */ + for (i = 0; i < tfImageHeight; i++) { + if (TIFFReadScanline(tfFile, scan_line, i, 0) < 0) + break; + output_p = &imageMemory[i * tfImageWidth]; + input_p = scan_line; + for (j = 0; j < tfImageWidth; j += 2, input_p++) { + *output_p++ = (*input_p >> 4) + basePixel; + *output_p++ = (*input_p & 0xf) + basePixel; + } + } + } else if ((xImageDepth == 8) && (tfImageDepth == 2)) { + output_p = imageMemory = (char *) + malloc(tfBytesPerRow * 4 * tfImageHeight + 4); + MCHECK(imageMemory); + + for (i = 0; i < tfImageHeight; i++) { + if (TIFFReadScanline(tfFile, scan_line, i, 0) < 0) + break; + output_p = &imageMemory[i * tfImageWidth]; + input_p = scan_line; + for (j = 0; j < tfImageWidth; j += 4, input_p++) { + *output_p++ = (*input_p >> 6) + basePixel; + *output_p++ = ((*input_p >> 4) & 3) + basePixel; + *output_p++ = ((*input_p >> 2) & 3) + basePixel; + *output_p++ = (*input_p & 3) + basePixel; + } + } + } else if ((xImageDepth == 4) && (tfImageDepth == 2)) { + output_p = imageMemory = (char *) + malloc(tfBytesPerRow * 2 * tfImageHeight + 2); + MCHECK(imageMemory); + + for (i = 0; i < tfImageHeight; i++) { + if (TIFFReadScanline(tfFile, scan_line, i, 0) < 0) + break; + output_p = &imageMemory[i * tfBytesPerRow * 2]; + input_p = scan_line; + for (j = 0; j < tfImageWidth; j += 4, input_p++) { + *output_p++ = (((*input_p>>6) << 4) + | ((*input_p >> 4) & 3)) + basePixel; + *output_p++ = ((((*input_p>>2) & 3) << 4) + | (*input_p & 3)) + basePixel; + } + } + } else { + fprintf(stderr, + "xtiff: can't handle %d-bit TIFF file on an %d-bit display\n", + tfImageDepth, xImageDepth); + exit(0); + } + } + + free(scan_line); +} + +void +CreateXImage() +{ + XGCValues gc_values; + GC bitmap_gc; + + xOffset = yOffset = 0; + grabX = grabY = -1; + + xImage = XCreateImage(xDisplay, xVisual, xImageDepth, + xImageDepth == 1 ? XYBitmap : ZPixmap, /* offset */ 0, + (char *) imageMemory, tfImageWidth, tfImageHeight, + /* bitmap_pad */ 8, /* bytes_per_line */ 0); + + /* + * libtiff converts LSB data into MSB but doesn't change the FillOrder tag. + */ + if (xImageDepth == 1) + xImage->bitmap_bit_order = MSBFirst; + if (xImageDepth <= 8) + xImage->byte_order = MSBFirst; + + /* + * create an appropriate GC + */ + gc_values.function = GXcopy; + gc_values.plane_mask = AllPlanes; + if (tfPhotometricInterpretation == PHOTOMETRIC_MINISBLACK) { + gc_values.foreground = XWhitePixel(xDisplay, xScreen); + gc_values.background = XBlackPixel(xDisplay, xScreen); + } else { + gc_values.foreground = XBlackPixel(xDisplay, xScreen); + gc_values.background = XWhitePixel(xDisplay, xScreen); + } + xWinGc = XCreateGC(xDisplay, XtWindow(shellWidget), + GCFunction | GCPlaneMask | GCForeground | GCBackground, &gc_values); + + /* + * create the pixmap and load the image + */ + if (appData.usePixmap == True) { + xImagePixmap = XCreatePixmap(xDisplay, RootWindow(xDisplay, xScreen), + xImage->width, xImage->height, xImageDepth); + + /* + * According to the O'Reilly X Protocol Reference Manual, page 53, + * "A pixmap depth of one is always supported and listed, but windows + * of depth one might not be supported." Therefore we create a pixmap + * of depth one and use XCopyPlane(). This is idiomatic. + */ + if (xImageDepth == 1) { /* just pass the bits through */ + gc_values.foreground = 1; /* foreground describes set bits */ + gc_values.background = 0; /* background describes clear bits */ + bitmap_gc = XCreateGC(xDisplay, xImagePixmap, + GCForeground | GCBackground, &gc_values); + XPutImage(xDisplay, xImagePixmap, bitmap_gc, xImage, + 0, 0, 0, 0, xImage->width, xImage->height); + } else + XPutImage(xDisplay, xImagePixmap, xWinGc, xImage, + 0, 0, 0, 0, xImage->width, xImage->height); + XDestroyImage(xImage); + free(imageMemory); + } +} + +XtCallbackProc +SelectProc(w, unused_1, unused_2) + Widget w; + caddr_t unused_1; + caddr_t unused_2; +{ + XawListReturnStruct *list_return; + + list_return = XawListShowCurrent(w); + + switch (list_return->list_index) { + case ButtonQuit: + QuitProc(); + break; + case ButtonPreviousPage: + PreviousProc(); + break; + case ButtonNextPage: + NextProc(); + break; + default: + fprintf(stderr, "error in SelectProc\n"); + exit(0); + } + XawListUnhighlight(w); +} + +void +QuitProc(void) +{ + exit(0); +} + +void +NextProc() +{ + PageProc(ButtonNextPage); +} + +void +PreviousProc() +{ + PageProc(ButtonPreviousPage); +} + +void +PageProc(direction) + int direction; +{ + XEvent fake_event; + Arg args[4]; + + switch (direction) { + case ButtonPreviousPage: + if (tfDirectory > 0) + TIFFSetDirectory(tfFile, --tfDirectory); + else + return; + break; + case ButtonNextPage: + if (TIFFReadDirectory(tfFile) == True) + tfDirectory++; + else + return; + break; + default: + fprintf(stderr, "error in PageProc\n"); + exit(0); + } + + xOffset = yOffset = 0; + grabX = grabY = -1; + + GetTIFFHeader(); + SetNameLabel(); + GetTIFFImage(); + + if (appData.usePixmap == True) + XFreePixmap(xDisplay, xImagePixmap); + else + XDestroyImage(xImage); + + CreateXImage(); + + /* + * Using XtSetValues() to set the widget size causes a resize. + * This resize gets propagated up to the parent shell. + * In order to disable this visually disconcerting effect, + * shell resizing is temporarily disabled. + */ + XtSetArg(args[0], XtNallowShellResize, False); + XtSetValues(shellWidget, args, 1); + + XtSetArg(args[0], XtNwidth, tfImageWidth); + XtSetArg(args[1], XtNheight, tfImageHeight); + XtSetValues(imageWidget, args, 2); + + XtSetArg(args[0], XtNallowShellResize, True); + XtSetValues(shellWidget, args, 1); + + XClearWindow(xDisplay, XtWindow(imageWidget)); + + fake_event.type = Expose; + fake_event.xexpose.x = fake_event.xexpose.y = 0; + fake_event.xexpose.width = tfImageWidth; /* the window will clip */ + fake_event.xexpose.height = tfImageHeight; + EventProc(imageWidget, NULL, &fake_event); +} + +void +EventProc(widget, unused, event) + Widget widget; + caddr_t unused; + XEvent *event; +{ + int ih, iw, ww, wh, sx, sy, w, h, dx, dy; + Dimension w_width, w_height; + XEvent next_event; + Arg args[2]; + + if (event->type == MappingNotify) { + XRefreshKeyboardMapping((XMappingEvent *) event); + return; + } + + if (!XtIsRealized(widget)) + return; + + if ((event->type == ButtonPress) || (event->type == ButtonRelease)) + if (event->xbutton.button != Button1) + return; + + iw = tfImageWidth; /* avoid sign problems */ + ih = tfImageHeight; + + /* + * The grabX and grabY variables record where the user grabbed the image. + * They also record whether the mouse button is down or not. + */ + if (event->type == ButtonPress) { + grabX = event->xbutton.x; + grabY = event->xbutton.y; + return; + } + + /* + * imageWidget is a Core widget and doesn't get resized. + * So we calculate the size of its viewport here. + */ + XtSetArg(args[0], XtNwidth, &w_width); + XtSetArg(args[1], XtNheight, &w_height); + XtGetValues(shellWidget, args, 2); + ww = w_width; + wh = w_height; + XtGetValues(listWidget, args, 2); + wh -= w_height; + + switch (event->type) { + case Expose: + dx = event->xexpose.x; + dy = event->xexpose.y; + sx = dx + xOffset; + sy = dy + yOffset; + w = MIN(event->xexpose.width, iw); + h = MIN(event->xexpose.height, ih); + break; + case KeyPress: + if ((grabX >= 0) || (grabY >= 0)) /* Mouse button is still down */ + return; + switch (XLookupKeysym((XKeyEvent *) event, /* KeySyms index */ 0)) { + case XK_Up: + if (ih < wh) /* Don't scroll if the window fits the image. */ + return; + sy = yOffset + appData.translate; + sy = MIN(ih - wh, sy); + if (sy == yOffset) /* Filter redundant stationary refreshes. */ + return; + yOffset = sy; + sx = xOffset; + dx = dy = 0; + w = ww; h = wh; + break; + case XK_Down: + if (ih < wh) + return; + sy = yOffset - appData.translate; + sy = MAX(sy, 0); + if (sy == yOffset) + return; + yOffset = sy; + sx = xOffset; + dx = dy = 0; + w = ww; h = wh; + break; + case XK_Left: + if (iw < ww) + return; + sx = xOffset + appData.translate; + sx = MIN(iw - ww, sx); + if (sx == xOffset) + return; + xOffset = sx; + sy = yOffset; + dx = dy = 0; + w = ww; h = wh; + break; + case XK_Right: + if (iw < ww) + return; + sx = xOffset - appData.translate; + sx = MAX(sx, 0); + if (sx == xOffset) + return; + xOffset = sx; + sy = yOffset; + dx = dy = 0; + w = ww; h = wh; + break; + default: + return; + } + break; + case MotionNotify: + /* + * MotionEvent compression. Ignore multiple motion events. + * Ignore motion events if the mouse button is up. + */ + if (XPending(xDisplay)) /* Xlib doesn't flush the output buffer */ + if (XtPeekEvent(&next_event)) + if (next_event.type == MotionNotify) + return; + if ((grabX < 0) || (grabY < 0)) + return; + sx = xOffset + grabX - (int) event->xmotion.x; + if (sx >= (iw - ww)) /* clamp x motion but allow y motion */ + sx = iw - ww; + sx = MAX(sx, 0); + sy = yOffset + grabY - (int) event->xmotion.y; + if (sy >= (ih - wh)) /* clamp y motion but allow x motion */ + sy = ih - wh; + sy = MAX(sy, 0); + if ((sx == xOffset) && (sy == yOffset)) + return; + dx = dy = 0; + w = ww; h = wh; + break; + case ButtonRelease: + xOffset = xOffset + grabX - (int) event->xbutton.x; + xOffset = MIN(iw - ww, xOffset); + xOffset = MAX(xOffset, 0); + yOffset = yOffset + grabY - (int) event->xbutton.y; + yOffset = MIN(ih - wh, yOffset); + yOffset = MAX(yOffset, 0); + grabX = grabY = -1; + default: + return; + } + + if (appData.usePixmap == True) { + if (xImageDepth == 1) + XCopyPlane(xDisplay, xImagePixmap, XtWindow(widget), + xWinGc, sx, sy, w, h, dx, dy, 1); + else + XCopyArea(xDisplay, xImagePixmap, XtWindow(widget), + xWinGc, sx, sy, w, h, dx, dy); + } else + XPutImage(xDisplay, XtWindow(widget), xWinGc, xImage, + sx, sy, dx, dy, w, h); +} + +void +ResizeProc() +{ + Dimension w_width, w_height; + int xo, yo, ww, wh; + XEvent fake_event; + Arg args[2]; + + if ((xOffset == 0) && (yOffset == 0)) + return; + + XtSetArg(args[0], XtNwidth, &w_width); + XtSetArg(args[1], XtNheight, &w_height); + XtGetValues(shellWidget, args, 2); + ww = w_width; + wh = w_height; + XtGetValues(listWidget, args, 2); + wh -= w_height; + + xo = xOffset; yo = yOffset; + + if ((xOffset + ww) >= tfImageWidth) + xOffset = MAX((int) tfImageWidth - ww, 0); + if ((yOffset + wh) >= tfImageHeight) + yOffset = MAX((int) tfImageHeight - wh, 0); + + /* + * Send an ExposeEvent if the origin changed. + * We have to do this because of the use and semantics of bit gravity. + */ + if ((xo != xOffset) || (yo != yOffset)) { + fake_event.type = Expose; + fake_event.xexpose.x = fake_event.xexpose.y = 0; + fake_event.xexpose.width = tfImageWidth; + fake_event.xexpose.height = tfImageHeight; + EventProc(imageWidget, NULL, &fake_event); + } +} + +int +XTiffErrorHandler(display, error_event) + Display *display; + XErrorEvent *error_event; +{ + char message[80]; + + /* + * Some X servers limit the size of pixmaps. + */ + if ((error_event->error_code == BadAlloc) + && (error_event->request_code == X_CreatePixmap)) + fprintf(stderr, "xtiff: requested pixmap too big for display\n"); + else { + XGetErrorText(display, error_event->error_code, message, 80); + fprintf(stderr, "xtiff: error code %s\n", message); + } + + exit(0); +} + +void +Usage() +{ + fprintf(stderr, "Usage xtiff: [options] tiff-file\n"); + fprintf(stderr, "\tstandard Xt options\n"); + fprintf(stderr, "\t[-help]\n"); + fprintf(stderr, "\t[-gamma gamma]\n"); + fprintf(stderr, "\t[-usePixmap (True | False)]\n"); + fprintf(stderr, "\t[-viewportWidth pixels]\n"); + fprintf(stderr, "\t[-viewportHeight pixels]\n"); + fprintf(stderr, "\t[-translate pixels]\n"); + fprintf(stderr, "\t[-verbose (True | False)]\n"); + exit(0); +} + +/* vim: set ts=8 sts=8 sw=8 noet: */ + +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/tiff/contrib/dbs/xtiff/xtifficon.h b/tiff/contrib/dbs/xtiff/xtifficon.h new file mode 100644 index 0000000..3eac48e --- /dev/null +++ b/tiff/contrib/dbs/xtiff/xtifficon.h @@ -0,0 +1,21 @@ +#define xtifficon_width 32 +#define xtifficon_height 32 +static char xtifficon_bits[] = { + 0xff, 0x00, 0x00, 0xc0, 0xfe, 0x01, 0x7e, 0xc0, 0xfc, 0x03, 0x7e, 0x60, + 0xf8, 0x07, 0x06, 0x30, 0xf8, 0x07, 0x1e, 0x18, 0xf0, 0x0f, 0x1e, 0x0c, + 0xe0, 0x1f, 0x06, 0x06, 0xc0, 0x3f, 0x06, 0x06, 0xc0, 0x3f, 0x06, 0x03, + 0x80, 0x7f, 0x80, 0x01, 0x00, 0xff, 0xc0, 0x00, 0x00, 0xfe, 0x61, 0x00, + 0x00, 0xfe, 0x31, 0x7e, 0x7e, 0xfc, 0x33, 0x7e, 0x7e, 0xf8, 0x1b, 0x06, + 0x18, 0xf0, 0x0d, 0x1e, 0x18, 0xf0, 0x0e, 0x1e, 0x18, 0x60, 0x1f, 0x06, + 0x18, 0xb0, 0x3f, 0x06, 0x18, 0x98, 0x7f, 0x06, 0x18, 0x98, 0x7f, 0x00, + 0x00, 0x0c, 0xff, 0x00, 0x00, 0x06, 0xfe, 0x01, 0x00, 0x63, 0xfc, 0x03, + 0x80, 0x61, 0xfc, 0x03, 0xc0, 0x60, 0xf8, 0x07, 0xc0, 0x60, 0xf0, 0x0f, + 0x60, 0x60, 0xe0, 0x1f, 0x30, 0x60, 0xe0, 0x1f, 0x18, 0x60, 0xc0, 0x3f, + 0x0c, 0x60, 0x80, 0x7f, 0x06, 0x00, 0x00, 0xff}; +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ |