aboutsummaryrefslogtreecommitdiff
path: root/graphics/libimg
diff options
context:
space:
mode:
authorMikhail Teterin <mi@FreeBSD.org>2014-06-09 20:20:42 +0000
committerMikhail Teterin <mi@FreeBSD.org>2014-06-09 20:20:42 +0000
commit0f2b12d983538a1a175d0da3f7ee59e5790f6bad (patch)
treebbf3d1177b94f9738e3335b23dbda9c0c93ac35d /graphics/libimg
parentebe8ac6b286d85b435a5bf3cd734e505163bbb71 (diff)
downloadports-0f2b12d983538a1a175d0da3f7ee59e5790f6bad.tar.gz
ports-0f2b12d983538a1a175d0da3f7ee59e5790f6bad.zip
Upgrade from 1.2.4 to 1.4.2. Allow for staging.
Notes
Notes: svn path=/head/; revision=357202
Diffstat (limited to 'graphics/libimg')
-rw-r--r--graphics/libimg/Makefile63
-rw-r--r--graphics/libimg/distinfo4
-rw-r--r--graphics/libimg/files/Makefile.bsd72
-rw-r--r--graphics/libimg/files/Makefile.tkstep8054
-rw-r--r--graphics/libimg/files/patch-config60
-rw-r--r--graphics/libimg/files/patch-jpeg682
-rw-r--r--graphics/libimg/files/patch-png429
-rw-r--r--graphics/libimg/files/patch-tiff690
-rw-r--r--graphics/libimg/files/patch-warnings220
-rw-r--r--graphics/libimg/files/pre-tk84-warnings38
-rw-r--r--graphics/libimg/files/tk84-Tk_PhotoPutBlock145
-rw-r--r--graphics/libimg/files/tk84-warnings211
-rw-r--r--graphics/libimg/files/tk85-Tk_PhotoPutBlock237
-rw-r--r--graphics/libimg/pkg-plist51
14 files changed, 448 insertions, 2508 deletions
diff --git a/graphics/libimg/Makefile b/graphics/libimg/Makefile
index 55e736921281..588ea6f97537 100644
--- a/graphics/libimg/Makefile
+++ b/graphics/libimg/Makefile
@@ -2,57 +2,52 @@
# $FreeBSD$
PORTNAME= libimg
-PORTVERSION= 1.2.4
-PORTREVISION= 9
+PORTVERSION= 1.4.2
CATEGORIES?= graphics tk
MASTER_SITES= SF/tkimg/tkimg/${PORTVERSION:R}
-DISTNAME= img${PORTVERSION}
+DISTNAME= tkimg${PORTVERSION}
MAINTAINER= mi@aldan.algebra.com
COMMENT= A library of image format handlers for Tk4.1 and later
+BUILD_DEPENDS= dtplite:${PORTSDIR}/devel/tcllib
LIB_DEPENDS= libpng15.so:${PORTSDIR}/graphics/png \
libjpeg.so:${PORTSDIR}/graphics/jpeg \
libtiff.so:${PORTSDIR}/graphics/tiff
-DIR= lib/Img1.2
-
-SHLIB_NAME= libimg.so.1
-SHLIB_LINK= ${SHLIB_NAME:R}
-
-PLIST_SUB+= DIR="${DIR}" SHLIB_NAME="${SHLIB_NAME}" \
+PLIST_SUB+= SHLIB_NAME="${SHLIB_NAME}" \
SHLIB_LINK="${SHLIB_LINK}"
-WRKSRC= ${WRKDIR}/img${PORTVERSION}
-MAKEFILE= ${FILESDIR}/Makefile.bsd
+WRKSRC= ${WRKDIR}/tkimg${PORTVERSION:R}
USES= tk
-MAKE_ENV+= TCL_VER=${TCL_VER}
+USE_BZIP2= yes
# We don't need the bundled libraries:
-EXTRACT_AFTER_ARGS= --exclude '*/libz/*' \
+EXTRACT_AFTER_ARGS= --exclude '*/libz/*' --exclude zlib \
+ --exclude 'config.*' --exclude Makefile \
--exclude '*/compat/*' --exclude '*/libtiff/*' \
--exclude '*/libjpeg/*' --exclude '*/libpng/*'
-
-MAKE_ARGS= PORTVERSION="${PORTVERSION}" LOCALBASE="${LOCALBASE}" \
- MKDIR="${MKDIR}" INSTALL_DATA="${INSTALL_DATA}" \
- SHLIB_NAME="${SHLIB_NAME}" \
- DIR="${DIR}"
-
-USE_LDCONFIG= yes
+MAKE_ARGS+= INSTALL_ROOT="${STAGEDIR}"
+USE_AUTOTOOLS= autoconf
+CONFIGURE_ARGS= --with-tcl="${TCL_LIBDIR}" --with-tk="${TK_LIBDIR}"
+CONFIGURE_ENV= WRKDIR="${WRKDIR}"
+
+post-patch:
+ ${REINPLACE_CMD} -E -e 's,"(zlib|tiff|jpeg|png)tcl.h",<\1.h>,' \
+ -e 's,jpeg\.h,jpeglib.h,' ${WRKSRC}/*/*.[ch]
+.for d in jpeg png tiff zlib
+ touch ${WRKDIR}/$dtclConfig.sh
+.endfor
+
+post-configure:
+.for l in jpeg png tiff
+ ${REINPLACE_CMD} -E -e 's,^SHLIB_LD_LIBS[[:space:]]*=[[:space:]]*(.*),SHLIB_LD_LIBS=\1 -l$l,' \
+ -e 's,-lpng$$,-lpng15,' ${WRKSRC}/$l/Makefile
+.endfor
post-install:
- ${MKDIR} ${STAGEDIR}${DOCSDIR}
- ${INSTALL_DATA} ${WRKSRC}/doc/* ${STAGEDIR}${DOCSDIR}
-
-.include <bsd.port.pre.mk>
-
-.if ${TCL_VER} == 8.4
-PKGNAMESUFFIX= -tk84
-EXTRA_PATCHES= ${FILESDIR}/tk84-Tk_PhotoPutBlock ${FILESDIR}/tk84-warnings
-CONFLICTS= libimg-tkstep-1.*
-.else
-EXTRA_PATCHES= ${FILESDIR}/tk85-Tk_PhotoPutBlock ${FILESDIR}/tk84-warnings
-CONFLICTS= libimg-tk84-1.* libimg-tkstep-1.*
-.endif
+ ${MKDIR} ${STAGEDIR}${EXAMPLESDIR}/msgs/
+ ${INSTALL_DATA} ${WRKSRC}/msgs/*.msg ${STAGEDIR}${EXAMPLESDIR}/msgs/
+ ${INSTALL_SCRIPT} ${WRKSRC}/demo.tcl ${WRKSRC}/tkv.tcl ${STAGEDIR}${EXAMPLESDIR}/
-.include <bsd.port.post.mk>
+.include <bsd.port.mk>
diff --git a/graphics/libimg/distinfo b/graphics/libimg/distinfo
index 31558bc94333..693252d065fd 100644
--- a/graphics/libimg/distinfo
+++ b/graphics/libimg/distinfo
@@ -1,2 +1,2 @@
-SHA256 (img1.2.4.tar.gz) = 1e3cb9c28fdf1ef87cd7c379ba1eb46988524d42120ae2d22d856a2dfee71fa0
-SIZE (img1.2.4.tar.gz) = 1672758
+SHA256 (tkimg1.4.2.tar.bz2) = bcced9c9e799e256683885ab703bc6777c95e415ed6f0b8c18793057fd87b866
+SIZE (tkimg1.4.2.tar.bz2) = 5541116
diff --git a/graphics/libimg/files/Makefile.bsd b/graphics/libimg/files/Makefile.bsd
deleted file mode 100644
index de70cbac30c0..000000000000
--- a/graphics/libimg/files/Makefile.bsd
+++ /dev/null
@@ -1,72 +0,0 @@
-SHLIB_NAME?= libimg.so.1
-
-PORTVERSION?= 1.2.4
-LOCALBASE?= /usr/local
-.if !defined(TCL_VER)
-TCL_VER= 8.4
-.endif
-
-.if exists(${LOCALBASE}/lib/tk${TCL_VER}/tkConfig.sh)
-# If for some reason the file does not exist -- make the best guess. In
-# reality, it will exist by the time we are actually doing the build, so
-# the quality of the guess does not matter. But we still try well. -mi
-TCL_STUB_LIB_SPEC!= . ${LOCALBASE}/lib/tcl${TCL_VER}/tclConfig.sh; \
- echo $$TCL_STUB_LIB_SPEC
-TK_STUB_LIB_SPEC!= . ${LOCALBASE}/lib/tk${TCL_VER}/tkConfig.sh; \
- echo $$TK_STUB_LIB_SPEC
-.else
-TCL_STUB_LIB_SPEC= -L${LOCALBASE}/lib -ltclstub${TCL_VER:S/.//}
-TK_STUB_LIB_SPEC= -L${LOCALBASE}/lib -ltkstub${TCL_VER:S/.//}
-.endif
-
-LDADD= -lm -lz -L${LOCALBASE}/lib -lpng -ljpeg -ltiff \
- ${TCL_STUB_LIB_SPEC} ${TK_STUB_LIB_SPEC} \
- -lX11
-
-CFLAGS+= -I${LOCALBASE}/include/tcl${TCL_VER}
-CFLAGS+= -I${LOCALBASE}/include/tcl${TCL_VER}/generic
-CFLAGS+= -D__X11__ -I${LOCALBASE}/include -DALLOW_B64
-CFLAGS+= -I${LOCALBASE}/include/tk${TCL_VER}
-CFLAGS+= -DNDEBUG -Wall -I. -DUSE_TCL_STUBS -DUSE_TK_STUBS
-CFLAGS+= -DVERSION=\"${PORTVERSION}\" -I${LOCALBASE}/include
-CFLAGS+= -DHAVE_JPEGLIB_H -DHAVE_TIFF_H -DHAVE_DLFCN_H -DHAVE_IMG_H
-CFLAGS+= -DHAVE_INTTYPES_H -DHAVE_STDINT_H -DHAVE_UNISTD_H -DSTDC_HEADERS
-CFLAGS+= -DUSE_INTERP_RESULT
-
-all: pkgIndex.tcl
-
-pkgIndex.tcl: pkgIndex.tcl.in
- sed -e 's,@IMG_PATCH_LEVEL@,${PORTVERSION},g' \
- -e 's,@IMG_SHARED_LIB_FILE@,../${SHLIB_NAME},g' \
- < pkgIndex.tcl.in > pkgIndex.tcl
-
-DIR? = lib/Img1.2
-INSTDIR = ${DESTDIR}${PREFIX}/${DIR}
-LIBDIR = ${PREFIX}/lib
-
-${INSTDIR} ${INSTDIR}/msgs:
- ${MKDIR} $@
-
-beforeinstall: ${INSTDIR} ${INSTDIR}/msgs
- ${INSTALL_DATA} pkgIndex.tcl ${.CURDIR}/demo.tcl ${.CURDIR}/tkv.tcl \
- ${.CURDIR}/imgmsg.tcl ${INSTDIR}
- ${INSTALL_DATA} ${.CURDIR}/msgs/* ${INSTDIR}/msgs/
-
-environ:
- @${ECHO} SHLIB_NAME=${SHLIB_NAME} SHLIB_LINK=${SHLIB_LINK} DIR=${DIR}
-
-# fundamentals of this library
-SRCS = imgInit.c imgObj.c imgUtil.c imgPmap.c imgUnixPmap.c \
- imgBMP.c imgGIF.c imgJPEG.c imgPNG.c imgPS.c \
- imgTIFF.c \
- imgWindow.c imgXBM.c imgXPM.c
-
-test: $(SHLIB_NAME)
- PATH=${TK_BIN_DIR}:${PATH}; export PATH; \
- TCLLIBPATH=`pwd`; export TCLLIBPATH; \
- export SHLIB_PATH; \
- LD_LIBRARY_PATH=`pwd`; \
- export LD_LIBRARY_PATH; \
- wish${TCL_VER} demo.tcl
-
-.include <bsd.lib.mk>
diff --git a/graphics/libimg/files/Makefile.tkstep80 b/graphics/libimg/files/Makefile.tkstep80
deleted file mode 100644
index 7788c1607a4c..000000000000
--- a/graphics/libimg/files/Makefile.tkstep80
+++ /dev/null
@@ -1,54 +0,0 @@
-SHLIB_NAME?= libimg.so.1
-
-PORTVERSION?= 1.2.4
-LOCALBASE?= /usr/local
-TCL_VER?= 8.0
-
-LDADD= -lm -lz -L${LOCALBASE}/lib -lpng -ljpeg -ltiff \
- -lX11
-
-CFLAGS+= -I${LOCALBASE}/include/tcl${TCL_VER}
-CFLAGS+= -I${LOCALBASE}/include/tcl${TCL_VER}/generic
-CFLAGS+= -D__X11__ -I${LOCALBASE}/include -DALLOW_B64
-CFLAGS+= -I${LOCALBASE}/include/tkstep${TCL_VER}
-CFLAGS+= -DNDEBUG -Wall -I.
-CFLAGS+= -DVERSION=\"${PORTVERSION}\" -I${LOCALBASE}/include
-CFLAGS+= -DHAVE_JPEGLIB_H -DHAVE_TIFF_H -DHAVE_DLFCN_H -DHAVE_IMG_H
-
-all: pkgIndex.tcl
-
-pkgIndex.tcl: pkgIndex.tcl.in
- sed -e 's,@IMG_PATCH_LEVEL@,${PORTVERSION},g' \
- -e 's,@IMG_SHARED_LIB_FILE@,../${SHLIB_NAME},g' \
- < pkgIndex.tcl.in > pkgIndex.tcl
-
-DIR? = lib/Img1.2
-INSTDIR = ${LOCALBASE}/${DIR}
-LIBDIR = ${LOCALBASE}/lib
-
-${INSTDIR} ${INSTDIR}/msgs:
- ${MKDIR} $@
-
-beforeinstall: ${INSTDIR} ${INSTDIR}/msgs
- ${INSTALL_DATA} pkgIndex.tcl ${.CURDIR}/demo.tcl ${.CURDIR}/tkv.tcl \
- ${.CURDIR}/imgmsg.tcl ${INSTDIR}
- ${INSTALL_DATA} ${.CURDIR}/msgs/* ${INSTDIR}/msgs/
-
-environ:
- @${ECHO} SHLIB_NAME=${SHLIB_NAME} SHLIB_LINK=${SHLIB_LINK} DIR=${DIR}
-
-# fundamentals of this library
-SRCS = imgInit.c imgObj.c imgUtil.c imgPmap.c imgUnixPmap.c \
- imgBMP.c imgGIF.c imgJPEG.c imgPNG.c imgPS.c \
- imgTIFF.c \
- imgWindow.c imgXBM.c imgXPM.c
-
-test: $(SHLIB_NAME)
- PATH=${TK_BIN_DIR}:${PATH}; export PATH; \
- TCLLIBPATH=`pwd`; export TCLLIBPATH; \
- export SHLIB_PATH; \
- LD_LIBRARY_PATH=`pwd`; \
- export LD_LIBRARY_PATH; \
- wish${TCL_VER} demo.tcl
-
-.include <bsd.lib.mk>
diff --git a/graphics/libimg/files/patch-config b/graphics/libimg/files/patch-config
new file mode 100644
index 000000000000..3c32088896d9
--- /dev/null
+++ b/graphics/libimg/files/patch-config
@@ -0,0 +1,60 @@
+--- base/Makefile.in 2013-11-21 17:03:14.000000000 -0500
++++ base/Makefile.in 2014-06-09 15:29:06.000000000 -0400
+@@ -432,5 +432,5 @@
+ $(INSTALL_DATA) pkgIndex.tcl $(DESTDIR)$(pkglibdir); \
+ fi
+- $(INSTALL_DATA) tkimgConfig.sh $(DESTDIR)$(libdir)
++ $(INSTALL_DATA) tkimgConfig.sh $(DESTDIR)$(libdir)/Img
+
+ #========================================================================
+--- Makefile.in 2013-11-21 17:03:12.000000000 -0500
++++ Makefile.in 2014-06-09 15:13:46.000000000 -0400
+@@ -58,5 +58,5 @@
+
+ # Directory where libimg.a is at run-time:
+-LIB_RUNTIME_DIR = $(libdir)/$(PACKAGE_NAME)$(PACKAGE_VERSION)
++LIB_RUNTIME_DIR = $(libdir)/$(PACKAGE_NAME)
+
+ # Directory in which to install the archive libimg.a:
+@@ -145,5 +145,5 @@
+ mv pkgIndex.tcl Img/exec_prefix/lib/Img/pkgIndex.tcl
+ chmod ugo+w Img/exec_prefix/lib/Img/pkgIndex.tcl
+- for p in Img/exec_prefix/lib/*.sh ; do \
++ for p in Img/exec_prefix/lib/Img/*.sh ; do \
+ sed -e 's#$(libdir)/[^/ ]*\([/ ]\)#$(LIB_RUNTIME_DIR)\1#' \
+ $$p > $$p.1 && mv -f $$p.1 $$p ; \
+@@ -156,5 +156,5 @@
+ done
+ mkdir -p $(INSTALL_ROOT)$(libdir)
+- for p in Img/exec_prefix/lib/*.sh ; do \
++ for p in Img/exec_prefix/lib/Img/*.sh ; do \
+ $(INSTALL_PROGRAM) $$p $(INSTALL_ROOT)$(libdir)/`basename $$p` ; \
+ done
+--- configure.in 2014-06-09 15:13:46.000000000 -0400
++++ configure.in 2013-11-21 17:03:14.000000000 -0500
+@@ -110,16 +110,12 @@
+
+ TEA_CONFIG_COLLECT
+-TEA_CONFIG_SUBDIR(zlib, [--disable-option-checking])
+-TEA_CONFIG_SUBDIR(libpng, [--with-zlibtcl=`pwd`/zlib --disable-option-checking])
+-TEA_CONFIG_SUBDIR(libtiff, [--disable-option-checking])
+-TEA_CONFIG_SUBDIR(libjpeg, [--disable-option-checking])
+ TEA_CONFIG_SUBDIR(base, [--disable-option-checking])
+ TEA_CONFIG_SUBDIR(bmp, [--with-tkimg=`pwd`/base --disable-option-checking])
+ TEA_CONFIG_SUBDIR(gif, [--with-tkimg=`pwd`/base --disable-option-checking])
+ TEA_CONFIG_SUBDIR(ico, [--with-tkimg=`pwd`/base --disable-option-checking])
+-TEA_CONFIG_SUBDIR(jpeg, [--with-tkimg=`pwd`/base --with-jpegtcl=`pwd`/libjpeg --disable-option-checking])
++TEA_CONFIG_SUBDIR(jpeg, [--with-tkimg=`pwd`/base --with-jpegtcl="$WRKDIR" --disable-option-checking])
+ TEA_CONFIG_SUBDIR(pcx, [--with-tkimg=`pwd`/base --disable-option-checking])
+ TEA_CONFIG_SUBDIR(pixmap, [--with-tkimg=`pwd`/base --disable-option-checking])
+-TEA_CONFIG_SUBDIR(png, [--with-tkimg=`pwd`/base --with-pngtcl=`pwd`/libpng --with-zlibtcl=`pwd`/zlib --disable-option-checking])
++TEA_CONFIG_SUBDIR(png, [--with-tkimg=`pwd`/base --with-pngtcl="$WRKDIR" --with-zlibtcl="$WRKDIR" --disable-option-checking])
+ TEA_CONFIG_SUBDIR(ppm, [--with-tkimg=`pwd`/base --disable-option-checking])
+ TEA_CONFIG_SUBDIR(ps, [--with-tkimg=`pwd`/base --disable-option-checking])
+@@ -127,5 +123,5 @@
+ TEA_CONFIG_SUBDIR(sun, [--with-tkimg=`pwd`/base --disable-option-checking])
+ TEA_CONFIG_SUBDIR(tga, [--with-tkimg=`pwd`/base --disable-option-checking])
+-TEA_CONFIG_SUBDIR(tiff, [--with-tkimg=`pwd`/base --with-tifftcl=`pwd`/libtiff --with-zlibtcl=`pwd`/zlib --with-jpegtcl=`pwd`/libjpeg --disable-option-checking])
++TEA_CONFIG_SUBDIR(tiff, [--with-tkimg=`pwd`/base --with-tifftcl="$WRKDIR" --with-zlibtcl="WRKDIR" --with-jpegtcl="$WRKDIR" --disable-option-checking])
+ TEA_CONFIG_SUBDIR(window, [--with-tkimg=`pwd`/base --disable-option-checking])
+ TEA_CONFIG_SUBDIR(xbm, [--with-tkimg=`pwd`/base --disable-option-checking])
diff --git a/graphics/libimg/files/patch-jpeg b/graphics/libimg/files/patch-jpeg
index ec10e9dd4948..541764f3a31a 100644
--- a/graphics/libimg/files/patch-jpeg
+++ b/graphics/libimg/files/patch-jpeg
@@ -1,606 +1,100 @@
---- imgJPEG.c Thu Jun 9 06:36:41 2005
-+++ imgJPEG.c Thu Jun 9 20:27:11 2005
-@@ -173,115 +173,4 @@
- j_common_ptr cinfo));
- static int load_jpeg_library _ANSI_ARGS_((Tcl_Interp *interp));
--static int CreateCompress _ANSI_ARGS_((j_compress_ptr, int, size_t));
--static int CreateDecompress _ANSI_ARGS_((j_decompress_ptr, int, size_t));
+--- jpeg/jpeg.c 2013-04-09 15:10:34.000000000 -0400
++++ jpeg/jpeg.c 2014-06-09 13:53:53.000000000 -0400
+@@ -56,5 +56,9 @@
+ #endif
+ #include "tkimg.h"
+-#include "jpegtcl.h"
++#ifdef EXTERN
++# undef EXTERN
++#endif
++#include <jpeglib.h>
++#include <jerror.h>
+
+ static int SetupJPegLibrary(Tcl_Interp *interp);
+@@ -137,86 +141,11 @@
+
+
-
--/*
-- * Stuff to support dynamic loading of libjpeg
-- */
+ static int
+ SetupJPegLibrary (interp)
+ Tcl_Interp *interp;
+ {
+- struct jpeg_compress_struct *cinfo; /* libjpeg's parameter structure */
+- struct my_error_mgr jerror; /* for controlling libjpeg error handling */
+- int i;
-
--static struct JpegFunctions {
-- VOID *handle;
-- int (* abort_decompress) _ANSI_ARGS_((j_decompress_ptr));
-- int (* destroy_compress) _ANSI_ARGS_((j_compress_ptr));
-- int (* destroy_decompress) _ANSI_ARGS_((j_decompress_ptr));
-- int (* finish_compress) _ANSI_ARGS_((j_compress_ptr));
-- int (* finish_decompress) _ANSI_ARGS_((j_decompress_ptr));
-- int (* read_header) _ANSI_ARGS_((j_decompress_ptr, int));
-- JDIMENSION (* read_scanlines) _ANSI_ARGS_((j_decompress_ptr,
-- JSAMPARRAY, JDIMENSION));
-- boolean (* resync_to_restart) _ANSI_ARGS_((j_decompress_ptr, int));
-- int (* set_defaults) _ANSI_ARGS_((j_compress_ptr));
-- int (* start_compress) _ANSI_ARGS_((j_compress_ptr, int));
-- int (* start_decompress) _ANSI_ARGS_((j_decompress_ptr));
-- struct jpeg_error_mgr *(* std_error) _ANSI_ARGS_((struct jpeg_error_mgr *));
-- JDIMENSION (* write_scanlines) _ANSI_ARGS_((j_compress_ptr,
-- JSAMPARRAY, JDIMENSION));
-- int (* set_colorspace) _ANSI_ARGS_((j_compress_ptr, J_COLOR_SPACE));
-- int (* set_quality) _ANSI_ARGS_((j_compress_ptr, int, int));
-- int (* simple_progression) _ANSI_ARGS_((j_compress_ptr));
-- int (* CreateCompress) _ANSI_ARGS_((j_compress_ptr, int, size_t));
-- int (* CreateDecompress) _ANSI_ARGS_((j_decompress_ptr, int, size_t));
-- int (* create_compress) _ANSI_ARGS_((j_compress_ptr));
-- int (* create_decompress) _ANSI_ARGS_((j_decompress_ptr));
-- void (* destroy) _ANSI_ARGS_((j_common_ptr));
-- JDIMENSION (* write_raw_data) _ANSI_ARGS_((j_compress_ptr,
-- JSAMPIMAGE, JDIMENSION));
-- void (* suppress_tables) _ANSI_ARGS_((j_compress_ptr, boolean));
-- void (* write_tables) _ANSI_ARGS_((j_compress_ptr));
-- JDIMENSION (* read_raw_data) _ANSI_ARGS_((j_decompress_ptr,
-- JSAMPIMAGE, JDIMENSION));
-- void (* abort) _ANSI_ARGS_((j_common_ptr));
--} jpeg = {0};
+- if (Jpegtcl_InitStubs(interp, JPEGTCL_VERSION, 0) == NULL) {
+- return TCL_ERROR;
+- }
-
--static char *symbols[] = {
--#ifdef NEED_SHORT_EXTERNAL_NAMES
-- "jAbrtDecompress",
-- "jDestCompress",
-- "jDestDecompress",
-- "jFinCompress",
-- "jFinDecompress",
-- "jReadHeader",
-- "jReadScanlines",
-- "jResyncRestart",
-- "jSetDefaults",
-- "jStrtCompress",
-- "jStrtDecompress",
-- "jStdError",
-- "jWrtScanlines",
-- /* the following 3 symbols are not crucial. They implement
-- resp. the "-grayscale", "-quality" and "-progressive"
-- options. If any of the symbols are missing from the
-- library, the corresponding option just has no effect. */
-- "jSetColorspace",
-- "jSetQuality",
-- "jSimProgress",
-- "jCreaCompress",
-- "jCreaDecompress",
-- "jCreaCompress",
-- "jCreaDecompress",
-- "jDestroy",
-- "jWrtRawData",
-- "jSuppressTables",
-- "jWrtTables",
-- "jReadRawData",
-- "jAbort",
--#else
-- "jpeg_abort_decompress",
-- "jpeg_destroy_compress",
-- "jpeg_destroy_decompress",
-- "jpeg_finish_compress",
-- "jpeg_finish_decompress",
-- "jpeg_read_header",
-- "jpeg_read_scanlines",
-- "jpeg_resync_to_restart",
-- "jpeg_set_defaults",
-- "jpeg_start_compress",
-- "jpeg_start_decompress",
-- "jpeg_std_error",
-- "jpeg_write_scanlines",
-- /* the following 3 symbols are not crucial. They implement
-- resp. the "-grayscale", "-quality" and "-progressive"
-- options. If any of the symbols are missing from the
-- library, the corresponding option just has no effect. */
-- "jpeg_set_colorspace",
-- "jpeg_set_quality",
-- "jpeg_simple_progression",
-- /* In later versions, jpeg_create_compress and jpeg_create_decompress
-- are macros pointing to jpeg_CreateCompress and jpeg_CreateDecompres.
-- Which one is found depends on the version. */
-- "jpeg_CreateCompress",
-- "jpeg_CreateDecompress",
-- "jpeg_create_compress",
-- "jpeg_create_decompress",
-- "jpeg_destroy",
-- "jpeg_write_raw_data",
-- "jpeg_suppress_tables",
-- "jpeg_write_tables",
-- "jpeg_read_raw_data",
-- "jpeg_abort",
--#endif
-- (char *) NULL
--};
+- /* The followin code tries to determine if the JPEG library is
+- valid at all. The library might be configured differently,
+- which will produce core dumps. Also it might be that
+- fields appear in different places in jpeg_compress_struct
+- or jpeg_decompress_struct. This will make the library totally
+- unusable. In stead of a core-dump, we better have a proper
+- error message */
+-
+- /* overallocat size, so we don't get a core-dump if the library
+- thinks that the structure is much larger */
+-
+- cinfo = (struct jpeg_compress_struct *) ckalloc(8*sizeof(struct jpeg_compress_struct));
+- cinfo->err = jpeg_std_error(&jerror.pub);
+- jerror.pub.error_exit = my_error_exit;
+- jerror.pub.output_message = my_output_message;
+- /* Establish the setjmp return context for my_error_exit to use. */
+- if (setjmp(jerror.setjmp_buffer)) {
+- /* If we get here, the JPEG library is invalid. */
+- jpeg_destroy_compress(cinfo);
+- ckfree((char *)cinfo);
+-
+- if (interp) {
+- Tcl_AppendResult(interp, "couldn't use \"", "jpegtcl",
+- "\": please upgrade to at least version 6a", (char *) NULL);
+- }
+- return TCL_ERROR;
+- }
-
-
- static int
-@@ -292,21 +181,10 @@
- struct my_error_mgr jerror; /* for controlling libjpeg error handling */
- int i;
-+ static int initialized;
-
-- if (ImgLoadLib(interp, JPEG_LIB_NAME, &jpeg.handle, symbols, 13)
-- != TCL_OK) {
-- return TCL_ERROR;
+- /* Now we can initialize libjpeg. */
+- ((char *) cinfo)[sizeof(struct jpeg_compress_struct)] = 53;
+- jpeg_create_compress(cinfo);
+- if (((char *) cinfo)[sizeof(struct jpeg_compress_struct)] != 53) {
+- /* Oops. The library changed this value, which is outside the
+- * structure. Definitely, the library is invalid!!!! */
+- ERREXIT(cinfo, JMSG_NOMESSAGE);
- }
-- if (jpeg.CreateCompress == NULL) {
-- if (jpeg.create_compress == NULL) {
-- goto load_failed;
-- }
-- jpeg.CreateCompress = CreateCompress;
+-
+- /* Set up JPEG compression parameters. */
+- cinfo->image_width = 16;
+- cinfo->image_height = 16;
+- cinfo->input_components = 3;
+- cinfo->in_color_space = JCS_RGB;
+- cinfo->data_precision = -1;
+- cinfo->optimize_coding = TRUE;
+- cinfo->dct_method = -1;
+- cinfo->X_density = 0;
+- cinfo->Y_density = 0;
+- jpeg_set_defaults(cinfo);
+-
+- if ((cinfo->data_precision != BITS_IN_JSAMPLE) ||
+- (cinfo->optimize_coding != FALSE) ||
+- (cinfo->dct_method != JDCT_DEFAULT) ||
+- (cinfo->X_density != 1) ||
+- (cinfo->Y_density != 1)) {
+- ERREXIT(cinfo, JMSG_NOMESSAGE);
- }
-- if (jpeg.CreateDecompress == NULL) {
-- if (jpeg.create_decompress == NULL) {
-- goto load_failed;
+- for (i = 0; i < NUM_ARITH_TBLS; i++) {
+- if ((cinfo->arith_dc_L[i] != 0) ||
+- (cinfo->arith_dc_U[i] != 1) ||
+- (cinfo->arith_ac_K[i] != 5)) {
+- ERREXIT(cinfo, JMSG_NOMESSAGE);
- }
-- jpeg.CreateDecompress = CreateDecompress;
- }
-+ if (initialized)
-+ return TCL_OK;
-+
-+ initialized = 1;
-
- /* The followin code tries to determine if the JPEG library is
-@@ -322,5 +200,5 @@
- cinfo = (struct jpeg_compress_struct *)
- ckalloc(8*sizeof(struct jpeg_compress_struct));
-- cinfo->err = jpeg.std_error(&jerror.pub);
-+ cinfo->err = jpeg_std_error(&jerror.pub);
- jerror.pub.error_exit = my_error_exit;
- jerror.pub.output_message = my_output_message;
-@@ -328,18 +206,16 @@
- if (setjmp(jerror.setjmp_buffer)) {
- /* If we get here, the JPEG library is invalid. */
-- jpeg.destroy_compress(cinfo);
-+ jpeg_destroy_compress(cinfo);
- ckfree((char *)cinfo);
--load_failed:
- if (interp) {
-- Tcl_AppendResult(interp, "couldn't load \"", JPEG_LIB_NAME,
-- "\": please upgrade to at least version 6a", (char *) NULL);
-+ Tcl_AppendResult(interp, "JPEG library mismatch, expecting \"",
-+ JPEG_LIB_NAME, NULL);
- }
-- ImgLoadFailed(&jpeg.handle);
- return TCL_ERROR;
- }
-
- /* Now we can initialize libjpeg. */
- ((char *) cinfo)[sizeof(struct jpeg_compress_struct)] = 53;
-- jpeg.CreateCompress(cinfo, JPEG_LIB_VERSION,
-+ jpeg_CreateCompress(cinfo, JPEG_LIB_VERSION,
- (size_t) sizeof(struct jpeg_compress_struct));
- if (((char *) cinfo)[sizeof(struct jpeg_compress_struct)] != 53) {
-@@ -359,5 +235,5 @@
- cinfo->X_density = 0;
- cinfo->Y_density = 0;
-- jpeg.set_defaults(cinfo);
-+ jpeg_set_defaults(cinfo);
-
- if ((cinfo->data_precision != BITS_IN_JSAMPLE) ||
-@@ -375,5 +251,5 @@
- }
- }
-- jpeg.destroy_compress(cinfo);
-+ jpeg_destroy_compress(cinfo);
- ckfree((char *) cinfo);
+- jpeg_destroy_compress(cinfo);
+- ckfree((char *) cinfo);
return TCL_OK;
-@@ -383,13 +259,6 @@
- ImgLoadJpegLibrary()
- {
-- if ((load_jpeg_library(NULL) == TCL_OK)
-- && jpeg.destroy
-- && jpeg.write_raw_data
-- && jpeg.suppress_tables
-- && jpeg.write_tables
-- && jpeg.read_raw_data
-- && jpeg.abort) {
-+ if (load_jpeg_library(NULL) == TCL_OK)
- return TCL_OK;
-- }
- return TCL_ERROR;
}
-@@ -420,179 +289,4 @@
- JSAMPARRAY, JDIMENSION));
--static int
--CreateCompress(cinfo, version, size)
-- j_compress_ptr cinfo;
-- int version;
-- size_t size;
--{
-- return jpeg.create_compress(cinfo);
--}
--
--static int
--CreateDecompress(cinfo, version, size)
-- j_decompress_ptr cinfo;
-- int version;
-- size_t size;
--{
-- return jpeg.create_decompress(cinfo);
--}
--
--int
--Imgjpeg_CreateCompress(cinfo, version, size)
-- j_compress_ptr cinfo;
-- int version;
-- size_t size;
--{
-- return jpeg.CreateCompress(cinfo, version, size);
--}
--
--int
--Imgjpeg_CreateDecompress(cinfo, version, size)
-- j_decompress_ptr cinfo;
-- int version;
-- size_t size;
--{
-- return jpeg.CreateDecompress(cinfo, version, size);
--}
--
--boolean
--Imgjpeg_resync_to_restart(a,b)
-- j_decompress_ptr a;
-- int b;
--{
-- return jpeg.resync_to_restart(a,b);
--}
--
--JDIMENSION
--Imgjpeg_read_scanlines(a,b,c)
-- j_decompress_ptr a;
-- JSAMPARRAY b;
-- JDIMENSION c;
--{
-- return jpeg.read_scanlines(a,b,c);
--}
--
--int
--Imgjpeg_set_colorspace(a,b)
-- j_compress_ptr a;
-- J_COLOR_SPACE b;
--{
-- return jpeg.set_colorspace(a,b);
--}
--
--int
--Imgjpeg_set_defaults(a)
-- j_compress_ptr a;
--{
-- return jpeg.set_defaults(a);
--}
--
--int
--Imgjpeg_start_decompress(a)
-- j_decompress_ptr a;
--{
-- return jpeg.start_decompress(a);
--}
--
--void
--Imgjpeg_destroy(a)
-- j_common_ptr a;
--{
-- jpeg.destroy(a);
--}
--
--struct jpeg_error_mgr *
--Imgjpeg_std_error(a)
-- struct jpeg_error_mgr *a;
--{
-- return jpeg.std_error(a);
--}
--
--JDIMENSION Imgjpeg_write_raw_data(a,b,c)
-- j_compress_ptr a;
-- JSAMPIMAGE b;
-- JDIMENSION c;
--{
-- return jpeg.write_raw_data(a,b,c);
--}
--
--void
--Imgjpeg_suppress_tables(a,b)
-- j_compress_ptr a;
-- boolean b;
--{
-- jpeg.suppress_tables(a,b);
--}
--
--void
--Imgjpeg_abort(a)
-- j_common_ptr a;
--{
-- jpeg.abort(a);
--}
--
--int
--Imgjpeg_read_header(a,b)
-- j_decompress_ptr a;
-- int b;
--{
-- return jpeg.read_header(a,b);
--}
--
--int
--Imgjpeg_start_compress(a,b)
-- j_compress_ptr a;
-- int b;
--{
-- return jpeg.start_compress(a,b);
--}
-
--void
--Imgjpeg_write_tables(a)
-- j_compress_ptr a;
--{
-- jpeg.write_tables(a);
--}
--
--int
--Imgjpeg_finish_decompress(a)
-- j_decompress_ptr a;
--{
-- return jpeg.finish_decompress(a);
--}
--
--int
--Imgjpeg_finish_compress(a)
-- j_compress_ptr a;
--{
-- return jpeg.finish_compress(a);
--}
--
--JDIMENSION
--Imgjpeg_read_raw_data(a,b,c)
-- j_decompress_ptr a;
-- JSAMPIMAGE b;
-- JDIMENSION c;
--{
-- return jpeg.read_raw_data(a,b,c);
--}
--
--int
--Imgjpeg_set_quality(a,b,c)
-- j_compress_ptr a;
-- int b;
-- int c;
--{
-- return jpeg.set_quality(a,b,c);
--}
--
--JDIMENSION
--Imgjpeg_write_scanlines(a,b,c)
-- j_compress_ptr a;
-- JSAMPARRAY b;
-- JDIMENSION c;
--{
-- return jpeg.write_scanlines(a,b,c);
--}
-
-
-@@ -794,5 +488,5 @@
- /* Initialize JPEG error handler */
- /* We set up the normal JPEG error routines, then override error_exit. */
-- cinfo.err = jpeg.std_error(&jerror.pub);
-+ cinfo.err = jpeg_std_error(&jerror.pub);
- jerror.pub.error_exit = my_error_exit;
- jerror.pub.output_message = my_output_message;
-@@ -803,10 +497,10 @@
- Tcl_AppendResult(interp, "couldn't read JPEG string: ", (char *) NULL);
- append_jpeg_message(interp, (j_common_ptr) &cinfo);
-- jpeg.destroy_decompress(&cinfo);
-+ jpeg_destroy_decompress(&cinfo);
- return TCL_ERROR;
- }
-
- /* Now we can initialize libjpeg. */
-- jpeg.CreateDecompress(&cinfo, JPEG_LIB_VERSION,
-+ jpeg_CreateDecompress(&cinfo, JPEG_LIB_VERSION,
- (size_t) sizeof(struct jpeg_decompress_struct));
- jpeg_channel_src(&cinfo, chan);
-@@ -817,5 +511,5 @@
-
- /* Reclaim libjpeg's internal resources. */
-- jpeg.destroy_decompress(&cinfo);
-+ jpeg_destroy_decompress(&cinfo);
-
- return result;
-@@ -865,5 +559,5 @@
- /* Initialize JPEG error handler */
- /* We set up the normal JPEG error routines, then override error_exit. */
-- cinfo.err = jpeg.std_error(&jerror.pub);
-+ cinfo.err = jpeg_std_error(&jerror.pub);
- jerror.pub.error_exit = my_error_exit;
- jerror.pub.output_message = my_output_message;
-@@ -874,10 +568,10 @@
- Tcl_AppendResult(interp, "couldn't read JPEG string: ", (char *) NULL);
- append_jpeg_message(interp, (j_common_ptr) &cinfo);
-- jpeg.destroy_decompress(&cinfo);
-+ jpeg_destroy_decompress(&cinfo);
- return TCL_ERROR;
- }
-
- /* Now we can initialize libjpeg. */
-- jpeg.CreateDecompress(&cinfo, JPEG_LIB_VERSION,
-+ jpeg_CreateDecompress(&cinfo, JPEG_LIB_VERSION,
- (size_t) sizeof(struct jpeg_decompress_struct));
- jpeg_obj_src(&cinfo, data);
-@@ -888,5 +582,5 @@
-
- /* Reclaim libjpeg's internal resources. */
-- jpeg.destroy_decompress(&cinfo);
-+ jpeg_destroy_decompress(&cinfo);
-
- return result;
-@@ -926,5 +620,5 @@
- * in image being read. */
- {
-- static char *jpegReadOptions[] = {"-fast", "-grayscale", NULL};
-+ static const char *jpegReadOptions[] = {"-fast", "-grayscale", NULL};
- int fileWidth, fileHeight, stopY, curY, outY, outWidth, outHeight;
- myblock bl;
-@@ -935,5 +629,5 @@
-
- /* Ready to read header data. */
-- jpeg.read_header(cinfo, TRUE);
-+ jpeg_read_header(cinfo, TRUE);
-
- /* This code only supports 8-bit-precision JPEG files. */
-@@ -972,5 +666,5 @@
- }
-
-- jpeg.start_decompress(cinfo);
-+ jpeg_start_decompress(cinfo);
-
- /* Check dimensions. */
-@@ -1029,5 +723,5 @@
- outY = destY;
- for (curY = 0; curY < stopY; curY++) {
-- jpeg.read_scanlines(cinfo, buffer, 1);
-+ jpeg_read_scanlines(cinfo, buffer, 1);
- if (curY >= srcY) {
- Tk_PhotoPutBlock(imageHandle, &block, destX, outY, outWidth, 1, TK_PHOTO_COMPOSITE_SET);
-@@ -1038,7 +732,7 @@
- /* Do normal cleanup if we read the whole image; else early abort */
- if (cinfo->output_scanline == cinfo->output_height)
-- jpeg.finish_decompress(cinfo);
-+ jpeg_finish_decompress(cinfo);
- else
-- jpeg.abort_decompress(cinfo);
-+ jpeg_abort_decompress(cinfo);
-
- return TCL_OK;
-@@ -1086,5 +780,5 @@
- /* Initialize JPEG error handler */
- /* We set up the normal JPEG error routines, then override error_exit. */
-- cinfo.err = jpeg.std_error(&jerror.pub);
-+ cinfo.err = jpeg_std_error(&jerror.pub);
- jerror.pub.error_exit = my_error_exit;
- jerror.pub.output_message = my_output_message;
-@@ -1096,11 +790,11 @@
- "\": ", (char *) NULL);
- append_jpeg_message(interp, (j_common_ptr) &cinfo);
-- jpeg.destroy_compress(&cinfo);
-+ jpeg_destroy_compress(&cinfo);
- Tcl_Close(interp, chan);
- return TCL_ERROR;
- }
-
- /* Now we can initialize libjpeg. */
-- jpeg.CreateCompress(&cinfo, JPEG_LIB_VERSION,
-+ jpeg_CreateCompress(&cinfo, JPEG_LIB_VERSION,
- (size_t) sizeof(struct jpeg_compress_struct));
- jpeg_channel_dest(&cinfo, chan);
-@@ -1109,5 +803,5 @@
- result = CommonWriteJPEG(interp, &cinfo, format, blockPtr);
-
-- jpeg.destroy_compress(&cinfo);
-+ jpeg_destroy_compress(&cinfo);
- if (Tcl_Close(interp, chan) == TCL_ERROR) {
- return TCL_ERROR;
-@@ -1154,5 +848,5 @@
- /* Initialize JPEG error handler */
- /* We set up the normal JPEG error routines, then override error_exit. */
-- cinfo.err = jpeg.std_error(&jerror.pub);
-+ cinfo.err = jpeg_std_error(&jerror.pub);
- jerror.pub.error_exit = my_error_exit;
- jerror.pub.output_message = my_output_message;
-@@ -1167,6 +861,6 @@
- }
-
- /* Now we can initialize libjpeg. */
-- jpeg.CreateCompress(&cinfo, JPEG_LIB_VERSION,
-+ jpeg_CreateCompress(&cinfo, JPEG_LIB_VERSION,
- (size_t) sizeof(struct jpeg_compress_struct));
- jpeg_string_dest(&cinfo, dataPtr);
-@@ -1177,5 +871,5 @@
- writeend:
-
-- jpeg.destroy_compress(&cinfo);
-+ jpeg_destroy_compress(&cinfo);
- if (dataPtr == &data) {
- if (result == TCL_OK) {
-@@ -1210,5 +904,5 @@
- Tk_PhotoImageBlock *blockPtr;
- {
-- static char *jpegWriteOptions[] = {"-grayscale", "-optimize",
-+ static const char *jpegWriteOptions[] = {"-grayscale", "-optimize",
- "-progressive", "-quality", "-smooth", NULL};
- JSAMPROW row_pointer[1]; /* pointer to original data scanlines */
-@@ -1239,5 +933,5 @@
- cinfo->in_color_space = JCS_RGB;
-
-- jpeg.set_defaults(cinfo);
-+ jpeg_set_defaults(cinfo);
-
- /* Parse options, if any, and alter default parameters */
-@@ -1262,7 +956,7 @@
- }
- case 2: {
-- if (jpeg.simple_progression != NULL) {
-+ if (jpeg_simple_progression != NULL) {
- /* Select simple progressive mode. */
-- jpeg.simple_progression(cinfo);
-+ jpeg_simple_progression(cinfo);
- }
- break;
-@@ -1278,5 +972,5 @@
- return TCL_ERROR;
- }
-- jpeg.set_quality(cinfo, quality, FALSE);
-+ jpeg_set_quality(cinfo, quality, FALSE);
- break;
- }
-@@ -1301,11 +995,11 @@
- greenOffset = blockPtr->offset[1] - blockPtr->offset[0];
- blueOffset = blockPtr->offset[2] - blockPtr->offset[0];
-- if ((jpeg.set_colorspace != NULL) &&
-+ if ((jpeg_set_colorspace != NULL) &&
- (grayscale || (!greenOffset && !blueOffset))) {
- /* Generate monochrome JPEG file if source block is grayscale. */
-- jpeg.set_colorspace(cinfo, JCS_GRAYSCALE);
-+ jpeg_set_colorspace(cinfo, JCS_GRAYSCALE);
- }
-
-- jpeg.start_compress(cinfo, TRUE);
-+ jpeg_start_compress(cinfo, TRUE);
-
- /* note: we assume libjpeg is configured for standard RGB pixel order. */
-@@ -1315,5 +1009,5 @@
- for (h = blockPtr->height; h > 0; h--) {
- row_pointer[0] = (JSAMPROW) pixLinePtr;
-- jpeg.write_scanlines(cinfo, row_pointer, 1);
-+ jpeg_write_scanlines(cinfo, row_pointer, 1);
- pixLinePtr += blockPtr->pitch;
- }
-@@ -1341,10 +1035,10 @@
- pixelPtr += blockPtr->pixelSize;
- }
-- jpeg.write_scanlines(cinfo, buffer, 1);
-+ jpeg_write_scanlines(cinfo, buffer, 1);
- pixLinePtr += blockPtr->pitch;
- }
- }
-
-- jpeg.finish_compress(cinfo);
-+ jpeg_finish_compress(cinfo);
- return TCL_OK;
- }
-@@ -1370,5 +1064,5 @@
- src->pub.fill_input_buffer = fill_input_buffer;
- src->pub.skip_input_data = skip_input_data;
-- src->pub.resync_to_restart = jpeg.resync_to_restart; /* use default method */
-+ src->pub.resync_to_restart = jpeg_resync_to_restart; /* use default method */
- src->pub.term_source = dummy_source;
-
-@@ -1443,5 +1137,5 @@
- src->pub.fill_input_buffer = fill_input_buffer;
- src->pub.skip_input_data = skip_input_data;
-- src->pub.resync_to_restart = jpeg.resync_to_restart; /* use default method */
-+ src->pub.resync_to_restart = jpeg_resync_to_restart; /* use default method */
- src->pub.term_source = dummy_source;
-
+ /*
+ *----------------------------------------------------------------------
diff --git a/graphics/libimg/files/patch-png b/graphics/libimg/files/patch-png
index 05041d90273b..3828d67783a0 100644
--- a/graphics/libimg/files/patch-png
+++ b/graphics/libimg/files/patch-png
@@ -1,414 +1,39 @@
---- imgPNG.c Tue Jan 15 16:00:08 2002
-+++ imgPNG.c Thu Jun 9 20:11:01 2005
-@@ -104,5 +104,4 @@
- static void tk_png_error _ANSI_ARGS_((png_structp, png_const_charp));
- static void tk_png_warning _ANSI_ARGS_((png_structp, png_const_charp));
--static int load_png_library _ANSI_ARGS_((Tcl_Interp *interp));
-
- /*
-@@ -116,87 +115,4 @@
- static void tk_png_flush _ANSI_ARGS_((png_structp));
-
--static struct PngFunctions {
-- VOID *handle;
-- png_structp (* create_read_struct) _ANSI_ARGS_((png_const_charp,
-- png_voidp, png_error_ptr, png_error_ptr));
-- png_infop (* create_info_struct) _ANSI_ARGS_((png_structp));
-- png_structp (* create_write_struct) _ANSI_ARGS_((png_const_charp,
-- png_voidp, png_error_ptr, png_error_ptr));
-- void (* destroy_read_struct) _ANSI_ARGS_((png_structpp,
-- png_infopp, png_infopp));
-- void (* destroy_write_struct) _ANSI_ARGS_((png_structpp, png_infopp));
-- void (* error) _ANSI_ARGS_((png_structp, png_charp));
-- png_byte (* get_channels) _ANSI_ARGS_((png_structp, png_infop));
-- png_voidp (* get_error_ptr) _ANSI_ARGS_((png_structp));
-- png_voidp (* get_progressive_ptr) _ANSI_ARGS_((png_structp));
-- png_uint_32 (* get_rowbytes) _ANSI_ARGS_((png_structp, png_infop));
-- png_uint_32 (* get_IHDR) _ANSI_ARGS_((png_structp, png_infop,
-- png_uint_32*, png_uint_32*, int*, int*, int*, int*, int*));
-- png_uint_32 (* get_valid) _ANSI_ARGS_((png_structp, png_infop, png_uint_32));
-- void (* read_image) _ANSI_ARGS_((png_structp, png_bytepp));
-- void (* read_info) _ANSI_ARGS_((png_structp, png_infop));
-- void (* read_update_info) _ANSI_ARGS_((png_structp, png_infop));
-- int (* set_interlace_handling) _ANSI_ARGS_ ((png_structp));
-- void (* set_read_fn) _ANSI_ARGS_((png_structp, png_voidp, png_rw_ptr));
-- void (* set_text) _ANSI_ARGS_((png_structp, png_infop, png_textp, int));
-- void (* set_write_fn) _ANSI_ARGS_((png_structp, png_voidp,
-- png_rw_ptr, png_voidp));
-- void (* set_IHDR) _ANSI_ARGS_((png_structp, png_infop, png_uint_32,
-- png_uint_32, int, int, int, int, int));
-- void (* write_end) _ANSI_ARGS_((png_structp, png_infop));
-- void (* write_info) _ANSI_ARGS_((png_structp, png_infop));
-- void (* write_row) _ANSI_ARGS_((png_structp, png_bytep));
-- void (* set_expand) _ANSI_ARGS_((png_structp));
-- void (* set_filler) _ANSI_ARGS_((png_structp, png_uint_32, int));
-- void (* set_strip_16) _ANSI_ARGS_((png_structp));
-- png_uint_32 (* get_sRGB) _ANSI_ARGS_((png_structp, png_infop, int *));
-- void (* set_sRGB) _ANSI_ARGS_((png_structp, png_infop, int));
-- png_uint_32 (* get_gAMA) _ANSI_ARGS_((png_structp, png_infop, double *));
-- void (* set_gAMA) PNGARG((png_structp png_ptr, png_infop, double));
-- void (* set_gamma) _ANSI_ARGS_((png_structp, double, double));
-- void (* set_sRGB_gAMA_and_cHRM) _ANSI_ARGS_((png_structp, png_infop, int));
-- void (* write_iTXt) _ANSI_ARGS_((png_structp, int, png_charp, png_charp,
-- png_charp, png_charp));
--} png = {0};
--
--static char *symbols[] = {
-- "png_create_read_struct",
-- "png_create_info_struct",
-- "png_create_write_struct",
-- "png_destroy_read_struct",
-- "png_destroy_write_struct",
-- "png_error",
-- "png_get_channels",
-- "png_get_error_ptr",
-- "png_get_progressive_ptr",
-- "png_get_rowbytes",
-- "png_get_IHDR",
-- "png_get_valid",
-- "png_read_image",
-- "png_read_info",
-- "png_read_update_info",
-- "png_set_interlace_handling",
-- "png_set_read_fn",
-- "png_set_text",
-- "png_set_write_fn",
-- "png_set_IHDR",
-- "png_write_end",
-- "png_write_info",
-- "png_write_row",
-- /* The following symbols are not crucial. All of them
-- are checked at runtime. */
-- "png_set_expand",
-- "png_set_filler",
-- "png_set_strip_16",
-- "png_get_sRGB",
-- "png_set_sRGB",
-- "png_get_gAMA",
-- "png_set_gAMA",
-- "png_set_gamma",
-- "png_set_sRGB_gAMA_and_cHRM",
-- "png_write_iTXt", /* Only used to check if libpng has iTXt support at runtime */
-- (char *) NULL
--};
--
- typedef struct cleanup_info {
+--- png/png.c 2013-11-21 17:03:12.000000000 -0500
++++ png/png.c 2014-06-09 13:57:22.000000000 -0400
+@@ -36,7 +36,8 @@
+ */
+
+-#include "pngtcl.h"
++#include <png.h>
+ #include <string.h>
+ #include <stdlib.h>
++#include <tcl.h>
+
+ static int SetupPngLibrary(Tcl_Interp *interp);
+@@ -171,7 +172,4 @@
Tcl_Interp *interp;
-@@ -209,5 +125,5 @@
- png_const_charp error_msg;
- {
-- cleanup_info *info = (cleanup_info *) png.get_error_ptr(png_ptr);
-+ cleanup_info *info = (cleanup_info *) png_get_error_ptr(png_ptr);
- Tcl_AppendResult(info->interp, error_msg, (char *) NULL);
- longjmp(info->jmpbuf,1);
-@@ -228,7 +144,7 @@
- png_size_t length;
{
-- if (ImgRead((MFile *) png.get_progressive_ptr(png_ptr),
-+ if (ImgRead((MFile *) png_get_progressive_ptr(png_ptr),
- (char *) data, (size_t) length) != (int) length) {
-- png.error(png_ptr, "Read Error");
-+ png_error(png_ptr, "Read Error");
- }
- }
-@@ -240,7 +156,7 @@
- png_size_t length;
- {
-- if (ImgWrite((MFile *) png.get_progressive_ptr(png_ptr),
-+ if (ImgWrite((MFile *) png_get_progressive_ptr(png_ptr),
- (char *) data, (size_t) length) != (int) length) {
-- png.error(png_ptr, "Write Error");
-+ png_error(png_ptr, "Write Error");
- }
- }
-@@ -303,15 +219,4 @@
- }
-
--static int
--load_png_library(interp)
-- Tcl_Interp *interp;
--{
-- if (ImgLoadLib(interp, PNG_LIB_NAME, &png.handle, symbols, 22)
-- != TCL_OK) {
-- return TCL_ERROR;
-- }
-- return TCL_OK;
--}
--
- static int ChnReadPNG(interp, chan, fileName, format, imageHandle,
- destX, destY, width, height, srcX, srcY)
-@@ -329,8 +234,4 @@
- cleanup_info cleanup;
-
-- if (load_png_library(interp) != TCL_OK) {
-- return TCL_ERROR;
-- }
--
- handle.data = (char *) chan;
- handle.state = IMG_CHAN;
-@@ -338,9 +239,9 @@
- cleanup.interp = interp;
-
-- png_ptr=png.create_read_struct(PNG_LIBPNG_VER_STRING,
-+ png_ptr=png_create_read_struct(PNG_LIBPNG_VER_STRING,
- (png_voidp) &cleanup,tk_png_error,tk_png_warning);
- if (!png_ptr) return(0);
-
-- png.set_read_fn(png_ptr, (png_voidp) &handle, tk_png_read);
-+ png_set_read_fn(png_ptr, (png_voidp) &handle, tk_png_read);
-
- return CommonReadPNG(png_ptr, format, imageHandle, destX, destY,
-@@ -362,11 +263,7 @@
- cleanup_info cleanup;
-
-- if (load_png_library(interp) != TCL_OK) {
-- return TCL_ERROR;
+- if (Pngtcl_InitStubs(interp, PNGTCL_VERSION, 0) == NULL) {
+- return TCL_ERROR;
- }
--
- cleanup.interp = interp;
-
-- png_ptr=png.create_read_struct(PNG_LIBPNG_VER_STRING,
-+ png_ptr=png_create_read_struct(PNG_LIBPNG_VER_STRING,
- (png_voidp) &cleanup,tk_png_error,tk_png_warning);
- if (!png_ptr) return TCL_ERROR;
-@@ -374,5 +271,5 @@
- ImgReadInit(dataObj,'\211',&handle);
-
-- png.set_read_fn(png_ptr,(png_voidp) &handle, tk_png_read);
-+ png_set_read_fn(png_ptr,(png_voidp) &handle, tk_png_read);
-
- return CommonReadPNG(png_ptr, format, imageHandle, destX, destY,
-@@ -406,27 +303,27 @@
- int intent;
-
-- info_ptr=png.create_info_struct(png_ptr);
-+ info_ptr=png_create_info_struct(png_ptr);
- if (!info_ptr) {
-- png.destroy_read_struct(&png_ptr,NULL,NULL);
-+ png_destroy_read_struct(&png_ptr,NULL,NULL);
- return(TCL_ERROR);
- }
-
-- end_info=png.create_info_struct(png_ptr);
-+ end_info=png_create_info_struct(png_ptr);
- if (!end_info) {
-- png.destroy_read_struct(&png_ptr,&info_ptr,NULL);
-+ png_destroy_read_struct(&png_ptr,&info_ptr,NULL);
- return(TCL_ERROR);
- }
-
-- if (setjmp((((cleanup_info *) png.get_error_ptr(png_ptr))->jmpbuf))) {
-+ if (setjmp((((cleanup_info *) png_get_error_ptr(png_ptr))->jmpbuf))) {
- if (png_data) {
- ckfree((char *)png_data);
- }
-- png.destroy_read_struct(&png_ptr, &info_ptr, &end_info);
-+ png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
- return TCL_ERROR;
- }
-
-- png.read_info(png_ptr,info_ptr);
-+ png_read_info(png_ptr,info_ptr);
-
-- png.get_IHDR(png_ptr, info_ptr, &info_width, &info_height, &bit_depth,
-+ png_get_IHDR(png_ptr, info_ptr, &info_width, &info_height, &bit_depth,
- &color_type, &interlace_type, (int *) NULL, (int *) NULL);
-
-@@ -447,6 +344,6 @@
- Tk_PhotoGetImage(imageHandle, &block);
-
-- if (png.set_strip_16 != NULL) {
-- png.set_strip_16(png_ptr);
-+ if (png_set_strip_16 != NULL) {
-+ png_set_strip_16(png_ptr);
- } else if (bit_depth == 16) {
- block.offset[1] = 2;
-@@ -454,11 +351,11 @@
- }
-
-- if (png.set_expand != NULL) {
-- png.set_expand(png_ptr);
-+ if (png_set_expand != NULL) {
-+ png_set_expand(png_ptr);
- }
-
-- png.read_update_info(png_ptr,info_ptr);
-- block.pixelSize = png.get_channels(png_ptr, info_ptr);
-- block.pitch = png.get_rowbytes(png_ptr, info_ptr);
-+ png_read_update_info(png_ptr,info_ptr);
-+ block.pixelSize = png_get_channels(png_ptr, info_ptr);
-+ block.pitch = png_get_rowbytes(png_ptr, info_ptr);
-
- if ((color_type & PNG_COLOR_MASK_COLOR) == 0) {
-@@ -471,5 +368,5 @@
-
- if ((color_type & PNG_COLOR_MASK_ALPHA)
-- || png.get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) {
-+ || png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) {
- /* with alpha channel */
- block.offset[3] = block.pixelSize - 1;
-@@ -479,12 +376,13 @@
+ return TCL_OK;
+ }
+@@ -465,7 +463,7 @@
}
-- if (png.get_sRGB && png.get_sRGB(png_ptr, info_ptr, &intent)) {
-- png.set_sRGB(png_ptr, info_ptr, intent);
-- } else if (png.get_gAMA) {
+- if (png_get_sRGB && png_get_sRGB(png_ptr, info_ptr, &intent)) {
+ if (png_get_sRGB(png_ptr, info_ptr, &intent)) {
-+ /* XXX does this get/set make sense? */
-+ png_set_sRGB(png_ptr, info_ptr, intent);
+ png_set_sRGB(png_ptr, info_ptr, intent);
+- } else if (png_get_gAMA) {
+ } else {
- double gamma;
-- if (!png.get_gAMA(png_ptr, info_ptr, &gamma)) {
-+ if (!png_get_gAMA(png_ptr, info_ptr, &gamma)) {
- gamma = 0.45455;
- }
-- png.set_gamma(png_ptr, 1.0, gamma);
-+ png_set_gamma(png_ptr, 1.0, gamma);
- }
-
-@@ -498,10 +396,10 @@
- block.pixelPtr=(unsigned char *) (png_data[srcY]+srcX*block.pixelSize);
-
-- png.read_image(png_ptr,(png_bytepp) png_data);
-+ png_read_image(png_ptr,(png_bytepp) png_data);
-
- ImgPhotoPutBlock(imageHandle,&block,destX,destY,width,height);
-
- ckfree((char *) png_data);
-- png.destroy_read_struct(&png_ptr,&info_ptr,&end_info);
-+ png_destroy_read_struct(&png_ptr,&info_ptr,&end_info);
-
- return(TCL_OK);
-@@ -529,12 +427,7 @@
- handle.state = IMG_CHAN;
-
-- if (load_png_library(interp) != TCL_OK) {
-- Tcl_Close(NULL, chan);
-- return TCL_ERROR;
-- }
--
- cleanup.interp = interp;
-
-- png_ptr=png.create_write_struct(PNG_LIBPNG_VER_STRING,
-+ png_ptr=png_create_write_struct(PNG_LIBPNG_VER_STRING,
- (png_voidp) &cleanup,tk_png_error,tk_png_warning);
- if (!png_ptr) {
-@@ -543,12 +436,12 @@
- }
-
-- info_ptr=png.create_info_struct(png_ptr);
-+ info_ptr=png_create_info_struct(png_ptr);
- if (!info_ptr) {
-- png.destroy_write_struct(&png_ptr,NULL);
-+ png_destroy_write_struct(&png_ptr,NULL);
- Tcl_Close(NULL, chan);
- return TCL_ERROR;
- }
-
-- png.set_write_fn(png_ptr,(png_voidp) &handle, tk_png_write, tk_png_flush);
-+ png_set_write_fn(png_ptr,(png_voidp) &handle, tk_png_write, tk_png_flush);
-
- result = CommonWritePNG(interp, png_ptr, info_ptr, format, blockPtr);
-@@ -572,11 +465,7 @@
- ImgFixStringWriteProc(&data, &interp, &dataPtr, &format, &blockPtr);
+ double gamma;
+ if (!png_get_gAMA(png_ptr, info_ptr, &gamma)) {
+@@ -659,7 +657,5 @@
+ PNG_FILTER_TYPE_BASE);
-- if (load_png_library(interp) != TCL_OK) {
-- return TCL_ERROR;
-- }
--
- cleanup.interp = interp;
-
-- png_ptr=png.create_write_struct(PNG_LIBPNG_VER_STRING,
-+ png_ptr=png_create_write_struct(PNG_LIBPNG_VER_STRING,
- (png_voidp) &cleanup, tk_png_error, tk_png_warning);
- if (!png_ptr) {
-@@ -584,11 +473,11 @@
- }
-
-- info_ptr = png.create_info_struct(png_ptr);
-+ info_ptr = png_create_info_struct(png_ptr);
- if (!info_ptr) {
-- png.destroy_write_struct(&png_ptr,NULL);
-+ png_destroy_write_struct(&png_ptr,NULL);
- return TCL_ERROR;
- }
-
-- png.set_write_fn(png_ptr, (png_voidp) &handle, tk_png_write, tk_png_flush);
-+ png_set_write_fn(png_ptr, (png_voidp) &handle, tk_png_write, tk_png_flush);
-
- ImgWriteInit(dataPtr, &handle);
-@@ -621,9 +510,9 @@
- tagcount = (tagcount > 1) ? (tagcount/2 - 1) : 0;
-
-- if (setjmp((((cleanup_info *) png.get_error_ptr(png_ptr))->jmpbuf))) {
-+ if (setjmp((((cleanup_info *) png_get_error_ptr(png_ptr))->jmpbuf))) {
- if (row_pointers) {
- ckfree((char *) row_pointers);
- }
-- png.destroy_write_struct(&png_ptr,&info_ptr);
-+ png_destroy_write_struct(&png_ptr,&info_ptr);
- return TCL_ERROR;
- }
-@@ -652,5 +541,5 @@
- #if 0 /* The function png_set_filler doesn't seem to work; don't known why :-( */
- } else if ((blockPtr->pixelSize==4) && (newPixelSize == 3)
-- && (png.set_filler != NULL)) {
-+ && (png_set_filler != NULL)) {
- /*
- * The set_filler() function doesn't need to be called
-@@ -660,16 +549,14 @@
- * possible with v0.95 and higher.
- */
-- png.set_filler(png_ptr, 0, PNG_FILLER_AFTER);
-+ png_set_filler(png_ptr, 0, PNG_FILLER_AFTER);
- newPixelSize++;
- #endif
- }
-
-- png.set_IHDR(png_ptr, info_ptr, blockPtr->width, blockPtr->height, 8,
-+ png_set_IHDR(png_ptr, info_ptr, blockPtr->width, blockPtr->height, 8,
- color_type, PNG_INTERLACE_ADAM7, PNG_COMPRESSION_TYPE_BASE,
- PNG_FILTER_TYPE_BASE);
-
-- if (png.set_gAMA) {
-- png.set_gAMA(png_ptr, info_ptr, 1.0);
+- if (png_set_gAMA) {
+- png_set_gAMA(png_ptr, info_ptr, 1.0);
- }
+ png_set_gAMA(png_ptr, info_ptr, 1.0);
if (tagcount > 0) {
-@@ -686,10 +573,10 @@
- }
- text.lang = NULL;
-- png.set_text(png_ptr, info_ptr, (png_text *) &text, 1);
-+ png_set_text(png_ptr, info_ptr, (png_text *) &text, 1);
- }
- }
-- png.write_info(png_ptr,info_ptr);
-+ png_write_info(png_ptr,info_ptr);
-
-- number_passes = png.set_interlace_handling(png_ptr);
-+ number_passes = png_set_interlace_handling(png_ptr);
-
- if (blockPtr->pixelSize != newPixelSize) {
-@@ -709,5 +596,5 @@
- dst += newPixelSize;
- }
-- png.write_row(png_ptr, row_pointers);
-+ png_write_row(png_ptr, row_pointers);
- }
- }
-@@ -717,11 +604,11 @@
- for (pass = 0; pass < number_passes; pass++) {
- for(I=0;I<blockPtr->height;I++) {
-- png.write_row(png_ptr, (png_bytep) blockPtr->pixelPtr
-+ png_write_row(png_ptr, (png_bytep) blockPtr->pixelPtr
- + I * blockPtr->pitch + blockPtr->offset[0]);
- }
- }
- }
-- png.write_end(png_ptr,NULL);
-- png.destroy_write_struct(&png_ptr,&info_ptr);
-+ png_write_end(png_ptr,NULL);
-+ png_destroy_write_struct(&png_ptr,&info_ptr);
-
- return(TCL_OK);
diff --git a/graphics/libimg/files/patch-tiff b/graphics/libimg/files/patch-tiff
index 5722f0ca1612..bcb54a10a9fd 100644
--- a/graphics/libimg/files/patch-tiff
+++ b/graphics/libimg/files/patch-tiff
@@ -1,363 +1,123 @@
---- imgTIFF.c Tue Jan 15 15:59:58 2002
-+++ imgTIFF.c Thu Jun 9 19:57:53 2005
-@@ -4,5 +4,5 @@
- * A photo image file handler for TIFF files.
- *
-- * Uses the libtiff.so library, which is dynamically
-+ * Uses the libTIFFso library, which is dynamically
- * loaded only when used.
- *
-@@ -40,9 +40,9 @@
+--- tiff/configure 2013-11-21 17:03:14.000000000 -0500
++++ tiff/configure 2014-06-09 14:00:22.000000000 -0400
+@@ -8232,5 +8232,5 @@
- #ifdef __WIN32__
--#define TIFF_LIB_NAME "tiff.dll"
-+#define TIFF_LIB_NAME "TIFFdll"
+
+- vars="tiff.c tiffJpeg.c tiffZip.c tiffPixar.c"
++ vars="tiff.c"
+ for i in $vars; do
+ case $i in
+--- tiff/tiff.c 2013-11-21 17:03:14.000000000 -0500
++++ tiff/tiff.c 2014-06-09 14:16:39.000000000 -0400
+@@ -19,11 +19,15 @@
#endif
+ #include "tkimg.h"
+-#include "tifftcl.h"
+-#include "zlibtcl.h"
++#ifdef EXTERN
++# undef EXTERN
++#endif
++#include <tiff.h>
++#include <tiffio.h>
++#include <zlib.h>
- #ifndef TIFF_LIB_NAME
--#define TIFF_LIB_NAME "libtiff.so"
-+#define TIFF_LIB_NAME "libTIFFso"
+ #ifdef HAVE_STDLIB_H
+ #undef HAVE_STDLIB_H
#endif
+-#include "jpegtcl.h"
++#include <jpeglib.h>
-@@ -78,73 +78,4 @@
- };
--static struct TiffFunctions {
-- VOID *handle;
-- void (* Close) _ANSI_ARGS_((TIFF *));
-- int (* GetField) _ANSI_ARGS_(TCL_VARARGS(TIFF *, tif));
-- int (* GetFieldDefaulted) _ANSI_ARGS_(TCL_VARARGS(TIFF *,tif));
-- TIFF* (* Open) _ANSI_ARGS_((CONST char*, CONST char*));
-- int (* ReadEncodedStrip) _ANSI_ARGS_((TIFF*, tstrip_t, tdata_t, tsize_t));
-- int (* ReadRGBAImage) _ANSI_ARGS_((TIFF *, uint32, uint32, uint32*, int));
-- int (* ReadTile) _ANSI_ARGS_((TIFF *, uint32, uint32, uint32*, int));
-- int (* SetField) _ANSI_ARGS_(TCL_VARARGS(TIFF *, tif));
-- tsize_t (* TileSize) _ANSI_ARGS_((TIFF*));
-- int (* WriteEncodedStrip) _ANSI_ARGS_((TIFF*, tstrip_t, tdata_t, tsize_t));
-- void (* free) _ANSI_ARGS_((tdata_t));
-- tdata_t (* malloc) _ANSI_ARGS_((tsize_t));
-- tdata_t (* memcpy) _ANSI_ARGS_((tdata_t, tdata_t, tsize_t));
-- tdata_t (* realloc) _ANSI_ARGS_((tdata_t, tsize_t));
-- TIFFErrorHandler (* SetErrorHandler) _ANSI_ARGS_((TIFFErrorHandler));
-- TIFFErrorHandler (* SetWarningHandler) _ANSI_ARGS_((TIFFErrorHandler));
-- TIFF* (* ClientOpen) _ANSI_ARGS_((CONST char*, CONST char*, VOID *,
-- TIFFReadWriteProc, TIFFReadWriteProc, TIFFSeekProc,
-- TIFFCloseProc, TIFFSizeProc, TIFFMapFileProc, TIFFUnmapFileProc));
-- TIFFCodec* (*RegisterCODEC) _ANSI_ARGS_((uint16, CONST char*, VOID *));
-- void (* Error) _ANSI_ARGS_(TCL_VARARGS(CONST char *, arg1));
-- int (* PredictorInit) _ANSI_ARGS_((TIFF *));
-- void (* MergeFieldInfo) _ANSI_ARGS_((TIFF *, CONST VOID *, int));
-- int (* FlushData1) _ANSI_ARGS_((TIFF *));
-- void (* NoPostDecode) _ANSI_ARGS_((TIFF *, VOID*, tsize_t));
-- tsize_t (* TileRowSize) _ANSI_ARGS_((TIFF *));
-- tsize_t (* ScanlineSize) _ANSI_ARGS_((TIFF *));
-- void (* setByteArray) _ANSI_ARGS_((VOID **, VOID*, long));
-- int (* VSetField) _ANSI_ARGS_((TIFF *, ttag_t, va_list));
-- void (* SwabArrayOfShort) _ANSI_ARGS_((uint16*, unsigned long));
--} tiff = {0};
--
--static char *symbols[] = {
-- "TIFFClose",
-- "TIFFGetField",
-- "TIFFGetFieldDefaulted",
-- "TIFFOpen",
-- "TIFFReadEncodedStrip",
-- "TIFFReadRGBAImage",
-- "TIFFReadTile",
-- "TIFFSetField",
-- "TIFFTileSize",
-- "TIFFWriteEncodedStrip",
-- /* The following symbols are not crucial. If they cannot be
-- found, just don't use them. The ClientOpen function is
-- more difficult to emulate, but even that is possible. */
-- "_TIFFfree",
-- "_TIFFmalloc",
-- "_TIFFmemcpy",
-- "_TIFFrealloc",
-- "TIFFSetErrorHandler",
-- "TIFFSetWarningHandler",
-- "TIFFClientOpen",
-- "TIFFRegisterCODEC", /* not in libtiff.def */
-- "TIFFError",
-- "TIFFPredictorInit", /* not in libtiff.def */
-- "_TIFFMergeFieldInfo", /* not in libtiff.def */
-- "TIFFFlushData1", /* not in libtiff.def */
-- "_TIFFNoPostDecode", /* not in libtiff.def */
-- "TIFFTileRowSize",
-- "TIFFScanlineSize",
-- "_TIFFsetByteArray", /* not in libtiff.def */
-- "TIFFVSetField",
-- "TIFFSwabArrayOfShort",
-- (char *) NULL
--};
+@@ -35,7 +39,4 @@
+ #include "init.c"
+
+-#include "tiffInt.h"
-
- /*
- * Prototypes for local procedures defined in this file:
-@@ -162,166 +93,5 @@
- static int ParseWriteFormat _ANSI_ARGS_((Tcl_Interp *interp, Tcl_Obj *format,
- int *comp, char **mode));
--static int load_tiff_library _ANSI_ARGS_((Tcl_Interp *interp));
- static void _TIFFerr _ANSI_ARGS_((CONST char *, CONST char *, va_list));
--static void _TIFFwarn _ANSI_ARGS_((CONST char *, CONST char *, va_list));
--void ImgTIFFfree _ANSI_ARGS_((tdata_t data));
--tdata_t ImgTIFFmalloc _ANSI_ARGS_((tsize_t size));
--tdata_t ImgTIFFrealloc _ANSI_ARGS_((tdata_t data, tsize_t size));
--tdata_t ImgTIFFmemcpy _ANSI_ARGS_((tdata_t, tdata_t, tsize_t));
--void ImgTIFFError _ANSI_ARGS_(TCL_VARARGS(CONST char *, module));
--int ImgTIFFPredictorInit _ANSI_ARGS_((TIFF *tif));
--void ImgTIFFMergeFieldInfo _ANSI_ARGS_((TIFF* tif, CONST VOID *voidp, int i));
--int ImgTIFFFlushData1 _ANSI_ARGS_((TIFF *tif));
--void ImgTIFFNoPostDecode _ANSI_ARGS_((TIFF *, VOID *, tsize_t));
--tsize_t ImgTIFFTileRowSize _ANSI_ARGS_((TIFF *));
--tsize_t ImgTIFFScanlineSize _ANSI_ARGS_((TIFF *));
--void ImgTIFFsetByteArray _ANSI_ARGS_((VOID **, VOID*, long));
--int ImgTIFFSetField _ANSI_ARGS_(TCL_VARARGS(TIFF *, tif));
--tsize_t ImgTIFFTileSize _ANSI_ARGS_((TIFF*));
--void ImgTIFFSwabArrayOfShort _ANSI_ARGS_((uint16*, unsigned long));
-
--/*
-- * External hooks to functions, so they can be called from
-- * imgTIFFzip.c and imgTIFFjpeg.c as well.
-- */
+ extern DLLIMPORT int unlink(const char *);
+
+@@ -88,10 +89,4 @@
+ Tcl_Interp *interp;
+ {
+- static int initialized = 0;
-
--void ImgTIFFfree (data)
-- tdata_t data;
--{
-- if (tiff.free) {
-- tiff.free(data);
-- } else {
-- ckfree((char *) data);
+- if (Tifftcl_InitStubs(interp, TIFFTCL_VERSION, 0) == NULL) {
+- return TCL_ERROR;
- }
--}
-
--tdata_t ImgTIFFmalloc(size)
-- tsize_t size;
--{
-- if (tiff.malloc) {
-- return tiff.malloc(size);
-- } else {
-- return ckalloc(size);
-- }
--}
+ if (errorMessage) {
+ ckfree(errorMessage);
+@@ -105,35 +100,4 @@
+ }
+
+- /*
+- * Initialize jpeg and zlib too, for use by the CODEC's we register
+- * with the base TIFF library in this package.
+- */
-
--tdata_t ImgTIFFrealloc(data, size)
-- tdata_t data;
-- tsize_t size;
--{
-- if (tiff.realloc) {
-- return tiff.realloc(data, size);
-- } else {
-- return ckrealloc(data, size);
+- if (Jpegtcl_InitStubs(interp, JPEGTCL_VERSION, 0) == NULL) {
+- return TCL_ERROR;
- }
--}
--
--tdata_t
--ImgTIFFmemcpy(a,b,c)
-- tdata_t a;
-- tdata_t b;
-- tsize_t c;
--{
-- return tiff.memcpy(a,b,c);
--}
--
--void
--ImgTIFFError TCL_VARARGS_DEF(CONST char *, arg1)
--{
-- va_list ap;
-- CONST char* module;
-- CONST char* fmt;
--
-- module = (CONST char*) TCL_VARARGS_START(CONST char *, arg1, ap);
-- fmt = va_arg(ap, CONST char *);
-- _TIFFerr(module, fmt, ap);
-- va_end(ap);
--}
--
--int
--ImgTIFFPredictorInit(tif)
-- TIFF *tif;
--{
-- return tiff.PredictorInit(tif);
--}
--
--void
--ImgTIFFMergeFieldInfo(tif, voidp, i)
-- TIFF* tif;
-- CONST VOID *voidp;
-- int i;
--{
-- tiff.MergeFieldInfo(tif, voidp, i);
--}
-
--int
--ImgTIFFFlushData1(tif)
-- TIFF *tif;
--{
-- return tiff.FlushData1(tif);
--}
--
--void
--ImgTIFFNoPostDecode(tif,a,b)
-- TIFF * tif;
-- VOID *a;
-- tsize_t b;
--{
-- tiff.NoPostDecode(tif, a, b);
--}
+- if (!initialized) {
+- initialized = 1;
+- if (
+- TIFFRegisterCODEC && TIFFError && TIFFPredictorInit &&
+- _TIFFMergeFieldInfo && TIFFFlushData1 && _TIFFNoPostDecode &&
+- TIFFTileRowSize && TIFFScanlineSize && _TIFFsetByteArray &&
+- TIFFVSetField && TIFFSwabArrayOfShort
+- ) {
-
--tsize_t
--ImgTIFFTileRowSize(tif)
-- TIFF * tif;
--{
-- return tiff.TileRowSize(tif);
--}
--
--tsize_t
--ImgTIFFScanlineSize(tif)
-- TIFF *tif;
--{
-- return tiff.ScanlineSize(tif);
--}
--
--void
--ImgTIFFsetByteArray(a,b,c)
-- VOID **a;
-- VOID *b;
-- long c;
--{
-- tiff.setByteArray(a,b,c);
--}
--
--int
--ImgTIFFSetField TCL_VARARGS_DEF(TIFF*, arg1)
--{
-- va_list ap;
-- TIFF* tif;
-- ttag_t tag;
-- int result;
--
-- tif = (TIFF*) TCL_VARARGS_START(TIFF*, arg1, ap);
-- tag = va_arg(ap, ttag_t);
-- result = tiff.VSetField(tif, tag, ap);
-- va_end(ap);
-- return result;
--}
--
--tsize_t
--ImgTIFFTileSize(tif)
-- TIFF* tif;
--{
-- return tiff.TileSize(tif);
--}
+- if (Zlibtcl_InitStubs(interp, ZLIBTCL_VERSION, 0) == NULL) {
+- return TCL_ERROR;
+- }
+- TIFFRegisterCODEC (COMPRESSION_DEFLATE, "Deflate", TkimgTIFFInitZip);
+- TIFFRegisterCODEC (COMPRESSION_ADOBE_DEFLATE, "AdobeDeflate", TkimgTIFFInitZip);
-
--void
--ImgTIFFSwabArrayOfShort(p, l)
-- uint16* p;
-- unsigned long l;
--{
-- tiff.SwabArrayOfShort(p,l);
-- return;
--}
-
- /*
-@@ -369,37 +139,15 @@
- }
-
--static int
--load_tiff_library(interp)
-- Tcl_Interp *interp;
-+static void
-+initialize(void)
- {
-- static int initialized = 0;
-- if (errorMessage) {
-- ckfree(errorMessage);
-- errorMessage = NULL;
-- }
-- if (ImgLoadLib(interp, TIFF_LIB_NAME, &tiff.handle, symbols, 10)
-- != TCL_OK) {
-- return TCL_ERROR;
-- }
-- if (tiff.SetErrorHandler != NULL) {
-- tiff.SetErrorHandler(_TIFFerr);
-- }
-- if (tiff.SetWarningHandler != NULL) {
-- tiff.SetWarningHandler(_TIFFwarn);
-- }
-+ static int initialized;
-+
- if (!initialized) {
-+ TIFFSetErrorHandler(_TIFFerr);
- initialized = 1;
-- if (tiff.RegisterCODEC && tiff.Error && tiff.PredictorInit &&
-- tiff.MergeFieldInfo && tiff.FlushData1 && tiff.NoPostDecode &&
-- tiff.TileRowSize && tiff.ScanlineSize && tiff.setByteArray &&
-- tiff.VSetField && tiff.SwabArrayOfShort) {
-- tiff.RegisterCODEC(COMPRESSION_DEFLATE, "Deflate", ImgInitTIFFzip);
-- tiff.RegisterCODEC(COMPRESSION_JPEG, "JPEG", ImgInitTIFFjpeg);
-- tiff.RegisterCODEC(COMPRESSION_PIXARLOG, "PixarLog", ImgInitTIFFpixar);
+- if (Jpegtcl_InitStubs(interp, JPEGTCL_VERSION, 0) == NULL) {
+- return TCL_ERROR;
+- }
+- TIFFRegisterCODEC (COMPRESSION_JPEG, "JPEG", TkimgTIFFInitJpeg);
+- TIFFRegisterCODEC (COMPRESSION_PIXARLOG, "PixarLog", TkimgTIFFInitPixar);
- }
- }
-- return TCL_OK;
- }
--
-+
- static void _TIFFerr(module, fmt, ap)
- CONST char *module;
-@@ -423,12 +171,4 @@
+- }
+ return TCL_OK;
}
-
--/* warnings are not processed in Tcl */
--static void _TIFFwarn(module, fmt, ap)
-- CONST char *module;
-- CONST char *fmt;
-- va_list ap;
--{
--}
--
- static int
- mapDummy(fd, base, size)
-@@ -686,12 +426,9 @@
+@@ -451,8 +415,6 @@
+ {
TIFF *tif;
- char tempFileName[256];
+- char *tempFileName = NULL, tempFileNameBuffer[256];
- int count, result;
+ int result;
- MFile handle;
+ tkimg_MFile handle;
- char buffer[1024];
char *dataPtr = NULL;
-- if (load_tiff_library(interp) != TCL_OK) {
-- return TCL_ERROR;
-- }
-+ initialize();
-
- if (!ImgReadInit(data, '\115', &handle)) {
-@@ -699,36 +436,14 @@
+@@ -461,35 +423,13 @@
}
-- if (tiff.ClientOpen) {
-- tempFileName[0] = 0;
+- if (TIFFClientOpen) {
- if (handle.state != IMG_STRING) {
- dataPtr = ckalloc((handle.length*3)/4 + 2);
-- handle.length = ImgRead(&handle, dataPtr, handle.length);
+- handle.length = tkimg_Read(&handle, dataPtr, handle.length);
- handle.data = dataPtr;
- }
- handle.state = 0;
-- tif = tiff.ClientOpen("inline data", "r", (thandle_t) &handle,
+- tif = TIFFClientOpen("inline data", "r", (thandle_t) &handle,
- readString, writeString, seekString, closeDummy,
- sizeString, mapDummy, unMapDummy);
- } else {
- Tcl_Channel outchan;
-- tmpnam(tempFileName);
-- outchan = ImgOpenFileChannel(interp, tempFileName, 0644);
+- tempFileName = tmpnam(tempFileNameBuffer);
+- outchan = tkimg_OpenFileChannel(interp, tempFileName, 0644);
- if (!outchan) {
- return TCL_ERROR;
- }
-
-- count = ImgRead(&handle, buffer, 1024);
+- count = tkimg_Read(&handle, buffer, 1024);
- while (count == 1024) {
- Tcl_Write(outchan, buffer, count);
-- count = ImgRead(&handle, buffer, 1024);
+- count = tkimg_Read(&handle, buffer, 1024);
- }
- if (count>0){
- Tcl_Write(outchan, buffer, count);
@@ -365,49 +125,49 @@
- if (Tcl_Close(interp, outchan) == TCL_ERROR) {
- return TCL_ERROR;
- }
-- tif = tiff.Open(tempFileName, "r");
+- tif = TIFFOpen(tempFileName, "r");
- }
-+ tempFileName[0] = 0;
+ if (handle.state != IMG_STRING) {
+ dataPtr = ckalloc((handle.length*3)/4 + 2);
-+ handle.length = ImgRead(&handle, dataPtr, handle.length);
++ handle.length = tkimg_Read(&handle, dataPtr, handle.length);
+ handle.data = dataPtr;
+ }
+ handle.state = 0;
+ tif = TIFFClientOpen("inline data", "r", (thandle_t) &handle,
-+ readString, writeString, seekString, closeDummy,
-+ sizeString, mapDummy, unMapDummy);
++ readString, writeString, seekString, closeDummy,
++ sizeString, mapDummy, unMapDummy);
if (tif != NULL) {
-@@ -765,41 +480,16 @@
+@@ -499,7 +439,4 @@
+ result = TCL_ERROR;
+ }
+- if (tempFileName) {
+- unlink(tempFileName);
+- }
+ if (result == TCL_ERROR) {
+ Tcl_AppendResult(interp, errorMessage, (char *) NULL);
+@@ -526,37 +463,12 @@
+ {
TIFF *tif;
- char tempFileName[256];
+- char *tempFileName = NULL, tempFileNameBuffer[256];
- int count, result;
- char buffer[1024];
-
-- if (load_tiff_library(interp) != TCL_OK) {
-- return TCL_ERROR;
-- }
-+ int result;
-+ MFile handle;
-
-- if (tiff.ClientOpen) {
-- MFile handle;
-- tempFileName[0] = 0;
+- if (TIFFClientOpen) {
+- tkimg_MFile handle;
- handle.data = (char *) chan;
- handle.state = IMG_CHAN;
-- tif = tiff.ClientOpen(fileName, "r", (thandle_t) &handle,
+- tif = TIFFClientOpen(fileName, "r", (thandle_t) &handle,
- readMFile, writeDummy, seekMFile, closeDummy,
- sizeMFile, mapDummy, unMapDummy);
- } else {
- Tcl_Channel outchan;
-- tmpnam(tempFileName);
-- outchan = ImgOpenFileChannel(interp, tempFileName, 0644);
+- tempFileName = tmpnam(tempFileNameBuffer);
+- outchan = tkimg_OpenFileChannel(interp, tempFileName, 0644);
- if (!outchan) {
- return TCL_ERROR;
- }
-+ initialize();
-
+-
- count = Tcl_Read(chan, buffer, 1024);
- while (count == 1024) {
- Tcl_Write(outchan, buffer, count);
@@ -419,174 +179,148 @@
- if (Tcl_Close(interp, outchan) == TCL_ERROR) {
- return TCL_ERROR;
- }
-+ tempFileName[0] = 0;
++ int result;
++ tkimg_MFile handle;
+
+- tif = TIFFOpen(tempFileName, "r");
+- }
+ handle.data = (char *) chan;
+ handle.state = IMG_CHAN;
+ tif = TIFFClientOpen(fileName, "r", (thandle_t) &handle,
+ readMFile, writeDummy, seekMFile, closeDummy,
+ sizeMFile, mapDummy, unMapDummy);
-
-- tif = tiff.Open(tempFileName, "r");
-- }
if (tif) {
- result = CommonReadTIFF(interp, tif, format, imageHandle,
-@@ -857,12 +547,8 @@
- block.pixelSize = sizeof (uint32);
-
-- tiff.GetField(tif, TIFFTAG_IMAGEWIDTH, &w);
-- tiff.GetField(tif, TIFFTAG_IMAGELENGTH, &h);
-+ TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w);
-+ TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h);
- npixels = w * h;
-- if (tiff.malloc == NULL) {
-- raster = (uint32 *) ckalloc(npixels * sizeof (uint32));
-- } else {
-- raster = (uint32 *) tiff.malloc(npixels * sizeof (uint32));
+ result = CommonRead(interp, tif, format, imageHandle,
+@@ -565,7 +477,4 @@
+ result = TCL_ERROR;
+ }
+- if (tempFileName) {
+- unlink(tempFileName);
- }
-+ raster = _TIFFmalloc(npixels * sizeof (uint32));
+ if (result == TCL_ERROR) {
+ Tcl_AppendResult(interp, errorMessage, (char *) NULL);
+@@ -635,5 +544,5 @@
+ npixels = w * h;
+
+- raster = (uint32*) TkimgTIFFmalloc(npixels * sizeof (uint32));
++ raster = (uint32*) _TIFFmalloc(npixels * sizeof (uint32));
block.width = w;
block.height = h;
-@@ -874,10 +560,6 @@
- }
+@@ -646,5 +555,5 @@
-- if (!tiff.ReadRGBAImage(tif, w, h, raster, 0) || errorMessage) {
-- if (tiff.free == NULL) {
-- ckfree((char *)raster);
-- } else {
-- tiff.free((char *)raster);
-- }
-+ if (!TIFFReadRGBAImage(tif, w, h, raster, 0) || errorMessage) {
-+ _TIFFfree(raster);
+ if (!TIFFReadRGBAImage(tif, w, h, raster, 0) || errorMessage) {
+- TkimgTIFFfree (raster);
++ _TIFFfree (raster);
if (errorMessage) {
Tcl_AppendResult(interp, errorMessage, (char *) NULL);
-@@ -894,10 +576,6 @@
- destY, width, height);
-
-- if (tiff.free == NULL) {
-- ckfree((char *)raster);
-- } else {
-- tiff.free((char *)raster);
-- }
-- tiff.Close(tif);
-+ _TIFFfree(raster);
-+ TIFFClose(tif);
- return TCL_OK;
- }
-@@ -917,7 +595,5 @@
- Tcl_DString data;
-
-- if (load_tiff_library(interp) != TCL_OK) {
-- return TCL_ERROR;
-- }
-+ initialize();
+@@ -663,5 +572,5 @@
+ }
- ImgFixStringWriteProc(&data, &interp, &dataPtr, &format, &blockPtr);
-@@ -927,18 +603,13 @@
+- TkimgTIFFfree (raster);
++ _TIFFfree (raster);
+ TIFFClose(tif);
+ return result;
+@@ -676,5 +585,4 @@
+ int result, comp;
+ tkimg_MFile handle;
+- char *tempFileName = NULL, tempFileNameBuffer[256];
+ Tcl_DString dstring;
+ const char *mode;
+@@ -686,14 +594,9 @@
}
-- if (tiff.ClientOpen) {
-- tempFileName[0] = 0;
+- if (TIFFClientOpen) {
- Tcl_DStringInit(&dstring);
-- ImgWriteInit(&dstring, &handle);
-- tif = tiff.ClientOpen("inline data", mode, (thandle_t) &handle,
+- tkimg_WriteInit(&dstring, &handle);
+- tif = TIFFClientOpen("inline data", mode, (thandle_t) &handle,
- readString, writeString, seekString, closeDummy,
- sizeString, mapDummy, unMapDummy);
- } else {
-- tmpnam(tempFileName);
-- tif = tiff.Open(tempFileName,mode);
+- tempFileName = tmpnam(tempFileNameBuffer);
+- tif = TIFFOpen(tempFileName,mode);
- }
-+ tempFileName[0] = 0;
+ Tcl_DStringInit(&dstring);
-+ ImgWriteInit(&dstring, &handle);
++ tkimg_WriteInit(&dstring, &handle);
+ tif = TIFFClientOpen("inline data", mode, (thandle_t) &handle,
+ readString, writeString, seekString, closeDummy,
+ sizeString, mapDummy, unMapDummy);
- result = CommonWriteTIFF(interp, tif, comp, blockPtr);
-- tiff.Close(tif);
-+ TIFFClose(tif);
+ result = CommonWrite(interp, tif, comp, blockPtr);
+@@ -701,7 +604,4 @@
if (result != TCL_OK) {
-@@ -999,8 +670,5 @@
+- if (tempFileName) {
+- unlink(tempFileName);
+- }
+ Tcl_AppendResult(interp, errorMessage, (char *) NULL);
+ ckfree(errorMessage);
+@@ -710,29 +610,7 @@
}
-- if (load_tiff_library(interp) != TCL_OK) {
-- Tcl_DStringFree(&nameBuffer);
-- return TCL_ERROR;
+- if (tempFileName) {
+- Tcl_Channel inchan;
+- char buffer[1024];
+- inchan = tkimg_OpenFileChannel(interp, tempFileName, 0644);
+- if (!inchan) {
+- return TCL_ERROR;
+- }
+- tkimg_WriteInit(&data, &handle);
+-
+- result = Tcl_Read(inchan, buffer, 1024);
+- while ((result == TCL_OK) && !Tcl_Eof(inchan)) {
+- tkimg_Write(&handle, buffer, result);
+- result = Tcl_Read(inchan, buffer, 1024);
+- }
+- if (result == TCL_OK) {
+- tkimg_Write(&handle, buffer, result);
+- result = Tcl_Close(interp, inchan);
+- }
+- unlink(tempFileName);
+- } else {
+- int length = handle.length;
+- tkimg_WriteInit(&data, &handle);
+- tkimg_Write(&handle, Tcl_DStringValue(&dstring), length);
+- Tcl_DStringFree(&dstring);
- }
-+ initialize();
-
- if (ParseWriteFormat(interp, format, &comp, &mode) != TCL_OK) {
-@@ -1009,5 +677,5 @@
- }
-
-- if (!(tif = tiff.Open(fullname, mode))) {
-+ if (!(tif = TIFFOpen(fullname, mode))) {
- Tcl_AppendResult(interp, filename, ": ", Tcl_PosixError(interp),
- (char *)NULL);
-@@ -1019,5 +687,5 @@
-
- result = CommonWriteTIFF(interp, tif, comp, blockPtr);
-- tiff.Close(tif);
-+ TIFFClose(tif);
- return result;
++ tkimg_WriteInit(&data, &handle);
++ tkimg_Write(&handle, Tcl_DStringValue(&dstring), handle.length);
++ Tcl_DStringFree(&dstring);
+ tkimg_Putc(IMG_DONE, &handle);
+ if (result == TCL_OK) {
+@@ -954,36 +832,2 @@
+ return TCL_OK;
}
-@@ -1029,5 +697,5 @@
- char **mode;
- {
-- static char *tiffWriteOptions[] = {"-compression", "-byteorder"};
-+ static const char *tiffWriteOptions[] = {"-compression", "-byteorder"};
- int objc, length, c, i, index;
- Tcl_Obj **objv;
-@@ -1112,27 +780,27 @@
- unsigned char *data = NULL;
-
-- tiff.SetField(tif, TIFFTAG_IMAGEWIDTH, blockPtr->width);
-- tiff.SetField(tif, TIFFTAG_IMAGELENGTH, blockPtr->height);
-- tiff.SetField(tif, TIFFTAG_COMPRESSION, comp);
-
-- tiff.SetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
-- tiff.SetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1);
-- tiff.SetField(tif, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
-- tiff.SetField(tif, TIFFTAG_ROWSPERSTRIP, blockPtr->height);
+-void
+-TkimgTIFFfree (data)
+- tdata_t data;
+-{
+- if (_TIFFfree) {
+- _TIFFfree(data);
+- } else {
+- ckfree((char *) data);
+- }
+-}
-
-- tiff.SetField(tif, TIFFTAG_RESOLUTIONUNIT, (int)2);
-- tiff.SetField(tif, TIFFTAG_XRESOLUTION, (float)1200.0);
-- tiff.SetField(tif, TIFFTAG_YRESOLUTION, (float)1200.0);
-+ TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, blockPtr->width);
-+ TIFFSetField(tif, TIFFTAG_IMAGELENGTH, blockPtr->height);
-+ TIFFSetField(tif, TIFFTAG_COMPRESSION, comp);
-+
-+ TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
-+ TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1);
-+ TIFFSetField(tif, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
-+ TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, blockPtr->height);
-+
-+ TIFFSetField(tif, TIFFTAG_RESOLUTIONUNIT, (int)2);
-+ TIFFSetField(tif, TIFFTAG_XRESOLUTION, (float)1200.0);
-+ TIFFSetField(tif, TIFFTAG_YRESOLUTION, (float)1200.0);
-
-- tiff.SetField(tif, TIFFTAG_BITSPERSAMPLE, 8);
-+ TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8);
- if ((blockPtr->offset[0] == blockPtr->offset[1])
- && (blockPtr->offset[0] == blockPtr->offset[2])) {
- numsamples = 1;
-- tiff.SetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1);
-- tiff.SetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK);
-+ TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1);
-+ TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK);
- } else {
- numsamples = 3;
-- tiff.SetField(tif, TIFFTAG_SAMPLESPERPIXEL, 3);
-- tiff.SetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
-+ TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 3);
-+ TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
- }
-
-@@ -1186,5 +854,5 @@
- }
-
-- tiff.WriteEncodedStrip(tif, 0, data,
-+ TIFFWriteEncodedStrip(tif, 0, data,
- numsamples * blockPtr->width * blockPtr->height);
- if (data != blockPtr->pixelPtr) {
+-tdata_t
+-TkimgTIFFmalloc(size)
+- tsize_t size;
+-{
+- if (_TIFFmalloc) {
+- return _TIFFmalloc(size);
+- } else {
+- return ckalloc(size);
+- }
+-}
+-
+-tdata_t
+-TkimgTIFFrealloc(data, size)
+- tdata_t data;
+- tsize_t size;
+-{
+- if (_TIFFrealloc) {
+- return _TIFFrealloc(data, size);
+- } else {
+- return ckrealloc(data, size);
+- }
+-}
diff --git a/graphics/libimg/files/patch-warnings b/graphics/libimg/files/patch-warnings
deleted file mode 100644
index 61bc1a82b9a8..000000000000
--- a/graphics/libimg/files/patch-warnings
+++ /dev/null
@@ -1,220 +0,0 @@
---- imgObj.c 2002-01-15 16:00:08.000000000 -0500
-+++ imgObj.c 2011-09-19 18:18:06.000000000 -0400
-@@ -23,5 +23,5 @@
-
- static int initialized = 0;
--static Tcl_ObjType* byteArrayType = 0;
-+static const Tcl_ObjType* byteArrayType = 0;
-
- int
-@@ -33,5 +33,5 @@
- return (initialized = IMG_PERL|IMG_OBJS);
- #else
-- char *version;
-+ const char *version;
- initialized = IMG_TCL;
- if (!Tcl_GetCommandInfo(interp,"image", &cmdInfo)) {
-@@ -186,5 +186,5 @@
- *lengthPtr = baPtr->used;
- }
-- return (unsigned char *) baPtr->bytes;
-+ return (char *)baPtr->bytes;
- } else {
- char *string = (char *) objPtr;
---- imgInit.c Tue Jan 15 15:59:58 2002
-+++ imgInit.c Thu Jun 9 05:27:40 2005
-@@ -94,5 +94,5 @@
- {
- Tk_PhotoImageFormat **formatPtr = Formats;
-- char *version;
-+ const char *version;
-
- if ((version = Tcl_InitStubs(interp, "8.0", 0)) == NULL) {
---- imgBMP.c 2002-01-15 16:00:07.000000000 -0500
-+++ imgBMP.c 2011-09-14 01:52:28.000000000 -0400
-@@ -222,5 +222,6 @@
- unsigned char *colorMap = NULL;
- char buf[10];
-- unsigned char *line = NULL, *expline = NULL;
-+ char *line = NULL;
-+ unsigned char *expline = NULL;
-
- CommonMatchBMP(handle, &fileWidth, &fileHeight, &colorMap, &numBits,
-@@ -237,5 +238,5 @@
-
- bytesPerLine = ((numBits * fileWidth + 31)/32)*4;
-- line = (unsigned char *) ckalloc(bytesPerLine);
-+ line = ckalloc(bytesPerLine);
-
- for(y=srcY+height; y<fileHeight; y++) {
-@@ -253,5 +254,5 @@
- switch (numBits) {
- case 24:
-- block.pixelPtr = line + srcX*3;
-+ block.pixelPtr = (unsigned char *)line + srcX*3;
- for( y = height-1; y>=0; y--) {
- ImgRead(handle, line, bytesPerLine);
---- imgGIF.c 2002-01-15 16:00:07.000000000 -0500
-+++ imgGIF.c 2011-09-14 02:10:28.000000000 -0400
-@@ -115,5 +115,5 @@
- int flag));
- static int GetDataBlock _ANSI_ARGS_((MFile *handle,
-- unsigned char *buf));
-+ char *buf));
- static int ReadColorMap _ANSI_ARGS_((MFile *handle, int number,
- unsigned char buffer[MAXCOLORMAPSIZE][4]));
-@@ -256,6 +256,6 @@
- Tcl_Obj **objv = NULL;
- myblock bl;
-- unsigned char buf[100];
-- unsigned char *trashBuffer = NULL;
-+ char buf[100];
-+ char *trashBuffer = NULL;
- int bitPixel;
- unsigned int colorResolution;
-@@ -402,6 +402,5 @@
- if (trashBuffer == NULL) {
- nBytes = fileWidth * fileHeight * 3;
-- trashBuffer =
-- (unsigned char *) ckalloc((unsigned int) nBytes);
-+ trashBuffer = ckalloc((unsigned int) nBytes);
- }
-
-@@ -602,9 +601,9 @@
- * returned here. */
- {
-- unsigned char buf[7];
-+ char buf[7];
-
- if ((ImgRead(handle, buf, 6) != 6)
-- || ((strncmp(GIF87a, (char *) buf, 6) != 0)
-- && (strncmp(GIF89a, (char *) buf, 6) != 0))) {
-+ || ((strncmp(GIF87a, buf, 6) != 0)
-+ && (strncmp(GIF89a, buf, 6) != 0))) {
- return 0;
- }
-@@ -633,5 +632,5 @@
- {
- int i;
-- unsigned char rgb[3];
-+ char rgb[3];
-
- for (i = 0; i < number; ++i) {
-@@ -658,5 +657,5 @@
- int *transparent;
- {
-- static unsigned char buf[256];
-+ static char buf[256];
- int count;
-
-@@ -670,10 +669,10 @@
- case 0xfe: /* Comment Extension */
- do {
-- count = GetDataBlock(handle, (unsigned char*) buf);
-+ count = GetDataBlock(handle, buf);
- } while (count > 0);
- return count;
-
- case 0xf9: /* Graphic Control Extension */
-- count = GetDataBlock(handle, (unsigned char*) buf);
-+ count = GetDataBlock(handle, buf);
- if (count < 0) {
- return 1;
-@@ -684,5 +683,5 @@
-
- do {
-- count = GetDataBlock(handle, (unsigned char*) buf);
-+ count = GetDataBlock(handle, buf);
- } while (count > 0);
- return count;
-@@ -690,5 +689,5 @@
-
- do {
-- count = GetDataBlock(handle, (unsigned char*) buf);
-+ count = GetDataBlock(handle, buf);
- } while (count > 0);
- return count;
-@@ -700,7 +699,7 @@
- GetDataBlock(handle, buf)
- MFile *handle;
-- unsigned char *buf;
-+ char *buf;
- {
-- unsigned char count;
-+ char count;
-
- if (! ReadOK(handle,&count,1)) {
-@@ -759,5 +758,5 @@
- int transparent;
- {
-- unsigned char initialCodeSize;
-+ char initialCodeSize;
- int v;
- int xpos = 0, ypos = 0, pass = 0, i;
-@@ -982,7 +981,7 @@
- int flag;
- {
-- static unsigned char buf[280];
-+ static char buf[280];
- static int bytes = 0, done;
-- static unsigned char *c;
-+ static char *c;
-
- static unsigned int window;
-@@ -1473,5 +1472,5 @@
- static int obits;
- static MFile *ofile;
--static unsigned char oblock[MAXCOLORMAPSIZE];
-+static char oblock[MAXCOLORMAPSIZE];
- static int oblen;
-
---- imgJPEG.c 2002-01-15 15:59:56.000000000 -0500
-+++ imgJPEG.c 2011-09-14 02:22:30.000000000 -0400
-@@ -1386,5 +1080,5 @@
- int nbytes;
-
-- nbytes = ImgRead(&src->handle, src->buffer, STRING_BUF_SIZE);
-+ nbytes = ImgRead(&src->handle, (char *)src->buffer, STRING_BUF_SIZE);
-
- if (nbytes <= 0) {
---- imgPS.c Sun Aug 13 06:06:53 2000
-+++ imgPS.c 2011-09-14 03:05:21.000000000 -0400
-@@ -178,5 +178,5 @@
- int *widthPtr, *heightPtr;
- {
-- unsigned char buf[41];
-+ char buf[41];
-
- if ((ImgRead(handle, (char *) buf, 11) != 11)
-@@ -184,11 +184,11 @@
- return 0;
- }
-- while (ImgRead(handle,(char *) buf, 1) == 1) {
-+ while (ImgRead(handle, buf, 1) == 1) {
- if (buf[0] == '%' &&
-- (ImgRead(handle, (char *) buf, 2) == 2) &&
-+ (ImgRead(handle, buf, 2) == 2) &&
- (!memcmp(buf, "%B", 2) &&
-- (ImgRead(handle, (char *) buf, 11) == 11) &&
-+ (ImgRead(handle, buf, 11) == 11) &&
- (!memcmp(buf, "oundingBox:", 11)) &&
-- (ImgRead(handle, (char *) buf, 40) == 40))) {
-+ (ImgRead(handle, buf, 40) == 40))) {
- int w, h, zoomx, zoomy;
- char *p = buf;
-@@ -272,5 +272,6 @@
- int len, i, j, fileWidth, fileHeight, maxintensity, index;
- char *p, type;
-- unsigned char buffer[1025], *line = NULL, *line3 = NULL;
-+ char buffer[1025];
-+ unsigned char *line = NULL, *line3 = NULL;
- char zoom[64], papersize[64];
- Tcl_Channel chan;
---- imgUtil.c 2002-01-15 15:59:59.000000000 -0500
-+++ imgUtil.c 2011-09-14 03:40:28.000000000 -0400
-@@ -249,3 +249,3 @@
- }
- *handlePtr = IMG_FAILED;
--}
-\ No newline at end of file
-+}
diff --git a/graphics/libimg/files/pre-tk84-warnings b/graphics/libimg/files/pre-tk84-warnings
deleted file mode 100644
index 3e152814887c..000000000000
--- a/graphics/libimg/files/pre-tk84-warnings
+++ /dev/null
@@ -1,38 +0,0 @@
---- imgXPM.c Tue Jan 15 16:00:08 2002
-+++ imgXPM.c Thu Jun 9 20:33:32 2005
-@@ -287,6 +287,6 @@
- char buffer[MAX_BUFFER];
- int i, isMono;
-- int color1;
-- unsigned int data;
-+ intptr_t color1;
-+ uintptr_t data;
- Tcl_HashEntry *hPtr;
-
-@@ -466,5 +466,5 @@
-
- for (i = 0; i < width; ) {
-- unsigned int col;
-+ uintptr_t col;
-
- memcpy((char *) &color1, p, byteSize);
-@@ -476,7 +476,7 @@
- */
- if (hPtr != (Tcl_HashEntry *)NULL)
-- col = (int)Tcl_GetHashValue(hPtr);
-+ col = (uintptr_t)Tcl_GetHashValue(hPtr);
- else
-- col = (int)0;
-+ col = 0;
-
- /*
-@@ -500,7 +500,7 @@
- hPtr = Tcl_FindHashEntry(&colorTable, (char *) color1);
- if (hPtr != (Tcl_HashEntry *)NULL)
-- col = (int)Tcl_GetHashValue(hPtr);
-+ col = (uintptr_t)Tcl_GetHashValue(hPtr);
- else
-- col = (int)0;
-+ col = 0;
- }
- } while ((i < width) && col);
diff --git a/graphics/libimg/files/tk84-Tk_PhotoPutBlock b/graphics/libimg/files/tk84-Tk_PhotoPutBlock
deleted file mode 100644
index 16e5a903ff7c..000000000000
--- a/graphics/libimg/files/tk84-Tk_PhotoPutBlock
+++ /dev/null
@@ -1,145 +0,0 @@
---- imgBMP.c Sun Aug 13 06:08:30 2000
-+++ imgBMP.c Mon Dec 1 12:49:07 2003
-@@ -256,7 +256,7 @@
- for( y = height-1; y>=0; y--) {
- ImgRead(handle, line, bytesPerLine);
- Tk_PhotoPutBlock(imageHandle, &block, destX, destY+y,
-- width,1);
-+ width,1,TK_PHOTO_COMPOSITE_SET);
- }
- break;
- case 8:
-@@ -268,7 +268,7 @@
- expline += 3;
- }
- Tk_PhotoPutBlock(imageHandle, &block, destX, destY+y,
-- width,1);
-+ width,1,TK_PHOTO_COMPOSITE_SET);
- expline = block.pixelPtr;
- }
- break;
-@@ -287,7 +287,7 @@
- expline += 3;
- }
- Tk_PhotoPutBlock(imageHandle, &block, destX, destY+y,
-- width,1);
-+ width,1,TK_PHOTO_COMPOSITE_SET);
- expline = block.pixelPtr;
- }
- break;
-@@ -302,7 +302,7 @@
- expline += 3;
- }
- Tk_PhotoPutBlock(imageHandle, &block, destX, destY+y,
-- width,1);
-+ width,1,TK_PHOTO_COMPOSITE_SET);
- expline = block.pixelPtr;
- }
- break;
---- imgGIF.c Sun Aug 13 06:09:39 2000
-+++ imgGIF.c Mon Dec 1 12:50:19 2003
-@@ -482,7 +482,7 @@
- }
-
- if (transparent == -1) {
-- Tk_PhotoPutBlock(imageHandle, &block, destX, destY, width, height);
-+ Tk_PhotoPutBlock(imageHandle, &block, destX, destY, width, height, TK_PHOTO_COMPOSITE_SET);
- } else {
- ImgPhotoPutBlock(imageHandle, &block, destX, destY, width, height);
- }
---- imgJPEG.c Sun Aug 13 06:10:22 2000
-+++ imgJPEG.c Mon Dec 1 12:50:53 2003
-@@ -1030,7 +1030,7 @@
- for (curY = 0; curY < stopY; curY++) {
- jpeg.read_scanlines(cinfo, buffer, 1);
- if (curY >= srcY) {
-- Tk_PhotoPutBlock(imageHandle, &block, destX, outY, outWidth, 1);
-+ Tk_PhotoPutBlock(imageHandle, &block, destX, outY, outWidth, 1, TK_PHOTO_COMPOSITE_SET);
- outY++;
- }
- }
---- imgPS.c Sun Aug 13 06:06:53 2000
-+++ imgPS.c Mon Dec 1 12:51:42 2003
-@@ -395,7 +395,7 @@
- for (j = 0; j < width; j++) {
- line3[j] = ((line[(j+srcX)/8]>>(7-(j+srcX)%8) & 1)) ? 0 : 255;
- }
-- Tk_PhotoPutBlock(imageHandle, &block, destX, destY++, width, 1);
-+ Tk_PhotoPutBlock(imageHandle, &block, destX, destY++, width, 1, TK_PHOTO_COMPOSITE_SET);
- }
- break;
- case '5':
-@@ -413,7 +413,7 @@
- c++;
- }
- }
-- Tk_PhotoPutBlock(imageHandle, &block, destX, destY++, width, 1);
-+ Tk_PhotoPutBlock(imageHandle, &block, destX, destY++, width, 1, TK_PHOTO_COMPOSITE_SET);
- }
- break;
- case '6':
-@@ -435,7 +435,7 @@
- c++;
- }
- }
-- Tk_PhotoPutBlock(imageHandle, &block, destX, destY++, width, 1);
-+ Tk_PhotoPutBlock(imageHandle, &block, destX, destY++, width, 1, TK_PHOTO_COMPOSITE_SET);
- }
- break;
- }
---- imgUtil.c Tue Jan 15 15:59:59 2002
-+++ imgUtil.c Thu Jun 9 20:51:49 2005
-@@ -95,7 +95,7 @@
- }
- if (end > X) {
- blockPtr->pixelPtr = rowPtr + blockPtr->pixelSize * X;
-- Tk_PhotoPutBlock(handle, blockPtr, x+X, y+Y, end-X, 1);
-+ Tk_PhotoPutBlock(handle, blockPtr, x+X, y+Y, end-X, 1, TK_PHOTO_COMPOSITE_SET);
- }
- X = end;
- }
-@@ -103,12 +103,12 @@
- }
- blockPtr->pixelPtr = imagePtr;
- } else {
-- Tk_PhotoPutBlock(handle,blockPtr,x,y,width,height);
-+ Tk_PhotoPutBlock(handle,blockPtr,x,y,width,height,TK_PHOTO_COMPOSITE_SET);
- }
- return TCL_OK;
- }
-
--
-+#if 0 /* OS run-time linker is better suited for this job { */
- /*
- *----------------------------------------------------------------------
- *
-@@ -248,4 +248,5 @@
- dlclose(*handlePtr);
- }
- *handlePtr = IMG_FAILED;
--}
-\ No newline at end of file
-+}
-+#endif /* } */
---- imgWindow.c Sat Jan 15 13:25:37 2000
-+++ imgWindow.c Mon Dec 1 12:52:11 2003
-@@ -378,7 +378,7 @@
- }
- }
-
-- Tk_PhotoPutBlock(imageHandle, &block, destX, destY, width, height);
-+ Tk_PhotoPutBlock(imageHandle, &block, destX, destY, width, height, TK_PHOTO_COMPOSITE_SET);
-
- #ifndef __WIN32__
- XDestroyImage(ximage);
---- imgXPM.c Sun Aug 13 06:41:31 2000
-+++ imgXPM.c Mon Dec 1 12:52:34 2003
-@@ -504,7 +504,7 @@
- col = (int)0;
- }
- } while ((i < width) && col);
-- Tk_PhotoPutBlock(imageHandle, &block.pub, destX+j, destY, len, 1);
-+ Tk_PhotoPutBlock(imageHandle, &block.pub, destX+j, destY, len, 1, TK_PHOTO_COMPOSITE_SET);
- } else {
- p += byteSize;
- i++;
diff --git a/graphics/libimg/files/tk84-warnings b/graphics/libimg/files/tk84-warnings
deleted file mode 100644
index a458bf591d07..000000000000
--- a/graphics/libimg/files/tk84-warnings
+++ /dev/null
@@ -1,211 +0,0 @@
---- imgPmap.h Tue Jan 15 15:59:58 2002
-+++ imgPmap.h Thu Jun 9 05:48:57 2005
-@@ -53,5 +53,5 @@
- int ncolors; /* number of colors */
- int cpp; /* characters per pixel */
-- char ** data; /* The data that defines this pixmap
-+ const char ** data; /* The data that defines this pixmap
- * image (array of strings). It is
- * converted into an X Pixmap when this
---- imgPmap.c Tue Jan 15 15:59:58 2002
-+++ imgPmap.c Thu Jun 9 05:52:31 2005
-@@ -49,6 +53,5 @@
- Display *display));
- static void ImgXpmDelete _ANSI_ARGS_((ClientData clientData));
--static int ImgXpmCmd _ANSI_ARGS_((ClientData clientData,
-- Tcl_Interp *interp, int argc, char **argv));
-+static Tcl_CmdProc ImgXpmCmd;
- static void ImgXpmCmdDeletedProc _ANSI_ARGS_((
- ClientData clientData));
-@@ -56,11 +59,11 @@
- PixmapInstance *instancePtr));
- static int ImgXpmConfigureMaster _ANSI_ARGS_((
-- PixmapMaster *masterPtr, int argc, char **argv,
-- int flags));
-+ PixmapMaster *masterPtr, int argc,
-+ const char **argv, int flags));
- static int ImgXpmGetData _ANSI_ARGS_((Tcl_Interp *interp,
- PixmapMaster *masterPtr));
--static char ** ImgXpmGetDataFromFile _ANSI_ARGS_((Tcl_Interp * interp,
-+static const char ** ImgXpmGetDataFromFile _ANSI_ARGS_((Tcl_Interp * interp,
- char * string, int * numLines_return));
--static char ** ImgXpmGetDataFromString _ANSI_ARGS_((Tcl_Interp*interp,
-+static const char ** ImgXpmGetDataFromString _ANSI_ARGS_((Tcl_Interp*interp,
- char * string, int * numLines_return));
- static void ImgXpmGetPixmapFromData _ANSI_ARGS_((
-@@ -68,7 +71,7 @@
- PixmapMaster *masterPtr,
- PixmapInstance *instancePtr));
--static char * GetType _ANSI_ARGS_((char * colorDefn,
-+static const char * GetType _ANSI_ARGS_((const char * colorDefn,
- int * type_ret));
--static char * GetColor _ANSI_ARGS_((char * colorDefn,
-+static const char * GetColor _ANSI_ARGS_((const char * colorDefn,
- char * colorName, int * type_ret));
-
-@@ -131,6 +134,6 @@
- PixmapMaster *masterPtr;
- int i;
-- char *argvbuf[10];
-- char **args = argvbuf;
-+ const char *argvbuf[10];
-+ const char **args = argvbuf;
-
- /*
-@@ -138,5 +141,5 @@
- */
- if (argc > 10) {
-- args = (char **) ckalloc(argc * sizeof(char *));
-+ args = (const char **)ckalloc(argc * sizeof(char *));
- }
- for (i = 0; i < argc; i++) {
-@@ -197,5 +200,5 @@
- * overall pixmap image to (reconfigure). */
- int argc; /* Number of entries in argv. */
-- char **argv; /* Pairs of configuration options for image. */
-+ const char **argv; /* Pairs of configuration options for image. */
- int flags; /* Flags to pass to Tk_ConfigureWidget,
- * such as TK_CONFIG_ARGV_ONLY. */
-@@ -280,8 +283,8 @@
- PixmapMaster *masterPtr;
- {
-- char ** data = NULL;
-+ const char ** data = NULL;
- int isAllocated = 0; /* do we need to free "data"? */
- int listArgc;
-- char ** listArgv = NULL;
-+ const char ** listArgv = NULL;
- int numLines;
- int size[2];
-@@ -371,5 +374,6 @@
- }
-
--static char ** ImgXpmGetDataFromString(interp, string, numLines_return)
-+static const char **
-+ImgXpmGetDataFromString(interp, string, numLines_return)
- Tcl_Interp * interp;
- char * string;
-@@ -379,5 +383,5 @@
- char * p, * list;
- int numLines;
-- char ** data;
-+ const char ** data;
-
- /* skip the leading blanks (leading blanks are not defined in the
-@@ -497,8 +501,9 @@
- error:
- Tcl_AppendResult(interp, "File format error", NULL);
-- return (char**) NULL;
-+ return NULL;
- }
-
--static char ** ImgXpmGetDataFromFile(interp, fileName, numLines_return)
-+static const char **
-+ImgXpmGetDataFromFile(interp, fileName, numLines_return)
- Tcl_Interp * interp;
- char * fileName;
-@@ -507,10 +512,10 @@
- Tcl_Channel chan;
- int size;
-- char ** data = (char **) NULL;
-+ const char ** data = NULL;
- char *cmdBuffer = NULL;
-
- chan = ImgOpenFileChannel(interp, fileName, 0);
- if (!chan) {
-- return (char **) NULL;
-+ return NULL;
- }
-
-@@ -540,10 +545,10 @@
-
-
--static char *
-+static const char *
- GetType(colorDefn, type_ret)
-- char * colorDefn;
-+ const char * colorDefn;
- int * type_ret;
- {
-- char * p = colorDefn;
-+ const char * p = colorDefn;
-
- /* skip white spaces */
-@@ -590,7 +595,7 @@
- * colorName is guaranteed to be big enough
- */
--static char *
-+static const char *
- GetColor(colorDefn, colorName, type_ret)
-- char * colorDefn;
-+ const char * colorDefn;
- char * colorName; /* if found, name is copied to this array */
- int * type_ret;
-@@ -699,5 +704,5 @@
-
- for (i=0; i<masterPtr->ncolors; i++) {
-- char * colorDefn; /* the color definition line */
-+ const char * colorDefn; /* the color definition line */
- char * colorName; /* temp place to hold the color name
- * defined for one type of visual */
-@@ -790,5 +795,5 @@
- */
- for (i=0; i<masterPtr->size[1]; i++) {
-- char * p = masterPtr->data[i+lOffset];
-+ const char * p = masterPtr->data[i+lOffset];
-
- for (j=0; j<masterPtr->size[0]; j++) {
-@@ -905,5 +910,5 @@
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
-- char **argv; /* Argument strings. */
-+ const char *argv[]; /* Argument strings. */
- {
- PixmapMaster *masterPtr = (PixmapMaster *) clientData;
---- imgPS.c Tue Jan 15 16:00:10 2002
-+++ imgPS.c Thu Jun 9 05:58:04 2005
-@@ -269,5 +269,5 @@
- {
- #ifndef MAC_TCL
-- char *argv[10];
-+ const char *argv[10];
- int len, i, j, fileWidth, fileHeight, maxintensity, index;
- char *p, type;
---- imgXPM.c Tue Jan 15 16:00:08 2002
-+++ imgXPM.c Thu Jun 9 20:33:32 2005
-@@ -287,6 +287,6 @@
- char buffer[MAX_BUFFER];
- int i, isMono;
-- int color1;
-- unsigned int data;
-+ intptr_t color1;
-+ uintptr_t data;
- Tcl_HashEntry *hPtr;
-
-@@ -466,5 +466,5 @@
-
- for (i = 0; i < width; ) {
-- unsigned int col;
-+ uintptr_t col;
-
- memcpy((char *) &color1, p, byteSize);
-@@ -476,7 +476,7 @@
- */
- if (hPtr != (Tcl_HashEntry *)NULL)
-- col = (int)Tcl_GetHashValue(hPtr);
-+ col = (uintptr_t)Tcl_GetHashValue(hPtr);
- else
-- col = (int)0;
-+ col = 0;
-
- /*
-@@ -500,7 +500,7 @@
- hPtr = Tcl_FindHashEntry(&colorTable, (char *) color1);
- if (hPtr != (Tcl_HashEntry *)NULL)
-- col = (int)Tcl_GetHashValue(hPtr);
-+ col = (uintptr_t)Tcl_GetHashValue(hPtr);
- else
-- col = (int)0;
-+ col = 0;
- }
- } while ((i < width) && col);
diff --git a/graphics/libimg/files/tk85-Tk_PhotoPutBlock b/graphics/libimg/files/tk85-Tk_PhotoPutBlock
deleted file mode 100644
index 86868e5eee7e..000000000000
--- a/graphics/libimg/files/tk85-Tk_PhotoPutBlock
+++ /dev/null
@@ -1,237 +0,0 @@
---- imgBMP.c Sun Aug 13 06:08:30 2000
-+++ imgBMP.c Mon Dec 1 12:49:07 2003
-@@ -235,5 +236,5 @@
- }
-
-- Tk_PhotoExpand(imageHandle, destX + width, destY + height);
-+ Tk_PhotoExpand(interp, imageHandle, destX + width, destY + height);
-
- bytesPerLine = ((numBits * fileWidth + 31)/32)*4;
-@@ -256,7 +256,7 @@
- for( y = height-1; y>=0; y--) {
- ImgRead(handle, line, bytesPerLine);
-- Tk_PhotoPutBlock(imageHandle, &block, destX, destY+y,
-+ Tk_PhotoPutBlock(interp, imageHandle, &block, destX, destY+y,
-- width,1);
-+ width,1,TK_PHOTO_COMPOSITE_SET);
- }
- break;
- case 8:
-@@ -268,7 +268,7 @@
- expline += 3;
- }
-- Tk_PhotoPutBlock(imageHandle, &block, destX, destY+y,
-+ Tk_PhotoPutBlock(interp, imageHandle, &block, destX, destY+y,
-- width,1);
-+ width,1,TK_PHOTO_COMPOSITE_SET);
- expline = block.pixelPtr;
- }
- break;
-@@ -287,7 +287,7 @@
- expline += 3;
- }
-- Tk_PhotoPutBlock(imageHandle, &block, destX, destY+y,
-+ Tk_PhotoPutBlock(interp, imageHandle, &block, destX, destY+y,
-- width,1);
-+ width,1,TK_PHOTO_COMPOSITE_SET);
- expline = block.pixelPtr;
- }
- break;
-@@ -302,7 +302,7 @@
- expline += 3;
- }
-- Tk_PhotoPutBlock(imageHandle, &block, destX, destY+y,
-+ Tk_PhotoPutBlock(interp, imageHandle, &block, destX, destY+y,
-- width,1);
-+ width,1,TK_PHOTO_COMPOSITE_SET);
- expline = block.pixelPtr;
- }
- break;
---- imgGIF.c Sun Aug 13 06:09:39 2000
-+++ imgGIF.c Mon Dec 1 12:50:19 2003
-@@ -322,5 +322,5 @@
- }
-
-- Tk_PhotoExpand(imageHandle, destX + width, destY + height);
-+ Tk_PhotoExpand(interp, imageHandle, destX + width, destY + height);
-
- block.pixelSize = 4;
-@@ -482,7 +482,7 @@
- }
-
- if (transparent == -1) {
-- Tk_PhotoPutBlock(imageHandle, &block, destX, destY, width, height);
-+ Tk_PhotoPutBlock(interp, imageHandle, &block, destX, destY, width, height, TK_PHOTO_COMPOSITE_SET);
- } else {
- ImgPhotoPutBlock(imageHandle, &block, destX, destY, width, height);
- }
---- imgJPEG.c Sun Aug 13 06:10:22 2000
-+++ imgJPEG.c Mon Dec 1 12:50:53 2003
-@@ -1017,5 +711,5 @@
- block.offset[3] = block.offset[0];
-
-- Tk_PhotoExpand(imageHandle, destX + outWidth, destY + outHeight);
-+ Tk_PhotoExpand(interp, imageHandle, destX + outWidth, destY + outHeight);
-
- /* Make a temporary one-row-high sample array */
-@@ -1030,7 +1030,7 @@
- for (curY = 0; curY < stopY; curY++) {
- jpeg.read_scanlines(cinfo, buffer, 1);
- if (curY >= srcY) {
-- Tk_PhotoPutBlock(imageHandle, &block, destX, outY, outWidth, 1);
-+ Tk_PhotoPutBlock(interp, imageHandle, &block, destX, outY, outWidth, 1, TK_PHOTO_COMPOSITE_SET);
- outY++;
- }
- }
---- imgPS.c Sun Aug 13 06:06:53 2000
-+++ imgPS.c Mon Dec 1 12:51:42 2003
-@@ -365,5 +365,5 @@
- return TCL_OK;
- }
-- Tk_PhotoExpand(imageHandle, destX + width, destY + height);
-+ Tk_PhotoExpand(interp, imageHandle, destX + width, destY + height);
-
- maxintensity = strtoul(p, &p, 0);
-@@ -395,7 +395,7 @@
- for (j = 0; j < width; j++) {
- line3[j] = ((line[(j+srcX)/8]>>(7-(j+srcX)%8) & 1)) ? 0 : 255;
- }
-- Tk_PhotoPutBlock(imageHandle, &block, destX, destY++, width, 1);
-+ Tk_PhotoPutBlock(interp, imageHandle, &block, destX, destY++, width, 1, TK_PHOTO_COMPOSITE_SET);
- }
- break;
- case '5':
-@@ -413,7 +413,7 @@
- c++;
- }
- }
-- Tk_PhotoPutBlock(imageHandle, &block, destX, destY++, width, 1);
-+ Tk_PhotoPutBlock(interp, imageHandle, &block, destX, destY++, width, 1, TK_PHOTO_COMPOSITE_SET);
- }
- break;
- case '6':
-@@ -435,7 +435,7 @@
- c++;
- }
- }
-- Tk_PhotoPutBlock(imageHandle, &block, destX, destY++, width, 1);
-+ Tk_PhotoPutBlock(interp, imageHandle, &block, destX, destY++, width, 1, TK_PHOTO_COMPOSITE_SET);
- }
- break;
- }
---- imgUtil.c Tue Jan 15 15:59:59 2002
-+++ imgUtil.c Thu Jun 9 20:51:49 2005
-@@ -95,7 +95,7 @@
- }
- if (end > X) {
- blockPtr->pixelPtr = rowPtr + blockPtr->pixelSize * X;
-- Tk_PhotoPutBlock(handle, blockPtr, x+X, y+Y, end-X, 1);
-+ Tk_PhotoPutBlock(NULL, handle, blockPtr, x+X, y+Y, end-X, 1, TK_PHOTO_COMPOSITE_SET);
- }
- X = end;
- }
-@@ -103,12 +103,12 @@
- }
- blockPtr->pixelPtr = imagePtr;
- } else {
-- Tk_PhotoPutBlock(handle,blockPtr,x,y,width,height);
-+ Tk_PhotoPutBlock(NULL, handle,blockPtr,x,y,width,height,TK_PHOTO_COMPOSITE_SET);
- }
- return TCL_OK;
- }
-
--
-+#if 0 /* OS run-time linker is better suited for this job { */
- /*
- *----------------------------------------------------------------------
- *
-@@ -248,4 +248,5 @@
- dlclose(*handlePtr);
- }
- *handlePtr = IMG_FAILED;
--}
-\ No newline at end of file
-+}
-+#endif /* } */
---- imgWindow.c Sat Jan 15 13:25:37 2000
-+++ imgWindow.c Mon Dec 1 12:52:11 2003
-@@ -327,5 +327,5 @@
- #endif
-
-- Tk_PhotoExpand(imageHandle, destX + width, destY + height);
-+ Tk_PhotoExpand(interp, imageHandle, destX + width, destY + height);
- block.offset[0] = 0;
- block.offset[3] = 0;
-@@ -378,7 +378,7 @@
- }
- }
-
-- Tk_PhotoPutBlock(imageHandle, &block, destX, destY, width, height);
-+ Tk_PhotoPutBlock(interp, imageHandle, &block, destX, destY, width, height, TK_PHOTO_COMPOSITE_SET);
-
- #ifndef __WIN32__
- XDestroyImage(ximage);
---- imgXPM.c Sun Aug 13 06:41:31 2000
-+++ imgXPM.c Mon Dec 1 12:52:34 2003
-@@ -438,5 +438,5 @@
- block.pub.pixelPtr = (unsigned char *) ckalloc((unsigned) block.pub.pixelSize * width);
-
-- Tk_PhotoExpand(imageHandle, destX + width, destY + height);
-+ Tk_PhotoExpand(interp, imageHandle, destX + width, destY + height);
-
- i = srcY;
-@@ -504,7 +504,7 @@
- col = (int)0;
- }
- } while ((i < width) && col);
-- Tk_PhotoPutBlock(imageHandle, &block.pub, destX+j, destY, len, 1);
-+ Tk_PhotoPutBlock(interp, imageHandle, &block.pub, destX+j, destY, len, 1, TK_PHOTO_COMPOSITE_SET);
- } else {
- p += byteSize;
- i++;
---- imgPNG.c 2002-01-15 16:00:08.000000000 -0500
-+++ imgPNG.c 2011-09-14 02:26:32.000000000 -0400
-@@ -96,5 +96,5 @@
- static int CommonMatchPNG _ANSI_ARGS_((MFile *handle, int *widthPtr,
- int *heightPtr));
--static int CommonReadPNG _ANSI_ARGS_((png_structp png_ptr, Tcl_Obj *format,
-+static int CommonReadPNG _ANSI_ARGS_((Tcl_Interp *interp, png_structp png_ptr, Tcl_Obj *format,
- Tk_PhotoHandle imageHandle, int destX, int destY, int width,
- int height, int srcX, int srcY));
-@@ -345,4 +246,4 @@
-
-- return CommonReadPNG(png_ptr, format, imageHandle, destX, destY,
-+ return CommonReadPNG(interp, png_ptr, format, imageHandle, destX, destY,
- width, height, srcX, srcY);
- }
-@@ -377,4 +274,4 @@
-
-- return CommonReadPNG(png_ptr, format, imageHandle, destX, destY,
-+ return CommonReadPNG(interp, png_ptr, format, imageHandle, destX, destY,
- width, height, srcX, srcY);
- }
-@@ -388,6 +285,7 @@
- #define block bl.ck
-
--static int CommonReadPNG(png_ptr, format, imageHandle, destX, destY,
-+static int CommonReadPNG(interp, png_ptr, format, imageHandle, destX, destY,
- width, height, srcX, srcY)
-+ Tcl_Interp *interp;
- png_structp png_ptr;
- Tcl_Obj *format;
-@@ -443,5 +340,5 @@
- }
-
-- Tk_PhotoExpand(imageHandle, destX + width, destY + height);
-+ Tk_PhotoExpand(interp, imageHandle, destX + width, destY + height);
-
- Tk_PhotoGetImage(imageHandle, &block);
---- imgXBM.c 2002-01-15 16:00:08.000000000 -0500
-+++ imgXBM.c 2011-09-14 03:20:16.000000000 -0400
-@@ -227,5 +227,5 @@
- }
-
-- Tk_PhotoExpand(imageHandle, destX + width, destY + height);
-+ Tk_PhotoExpand(interp, imageHandle, destX + width, destY + height);
-
- numBytes = ((fileWidth+7)/8)*32;
diff --git a/graphics/libimg/pkg-plist b/graphics/libimg/pkg-plist
index 89b3a55b5059..6aa4536dbe23 100644
--- a/graphics/libimg/pkg-plist
+++ b/graphics/libimg/pkg-plist
@@ -1,21 +1,30 @@
-%%DIR%%/pkgIndex.tcl
-%%DIR%%/demo.tcl
-%%DIR%%/tkv.tcl
-%%DIR%%/imgmsg.tcl
-lib/%%SHLIB_NAME%%
-lib/%%SHLIB_LINK%%
-%%DIR%%/msgs/de.msg
-%%DIR%%/msgs/el.msg
-%%DIR%%/msgs/en.msg
-%%DIR%%/msgs/es.msg
-%%DIR%%/msgs/fr.msg
-%%DIR%%/msgs/ja.msg
-%%DIR%%/msgs/nl.msg
-@dirrm %%DIR%%/msgs
-@dirrm %%DIR%%
-%%PORTDOCS%%%%DOCSDIR%%/default.css
-%%PORTDOCS%%%%DOCSDIR%%/formats.htm
-%%PORTDOCS%%%%DOCSDIR%%/index.htm
-%%PORTDOCS%%%%DOCSDIR%%/install.htm
-%%PORTDOCS%%%%DOCSDIR%%/library.htm
-%%PORTDOCS%%@dirrm %%DOCSDIR%%
+%%EXAMPLESDIR%%/demo.tcl
+%%EXAMPLESDIR%%/tkv.tcl
+%%EXAMPLESDIR%%/msgs/de.msg
+%%EXAMPLESDIR%%/msgs/el.msg
+%%EXAMPLESDIR%%/msgs/en.msg
+%%EXAMPLESDIR%%/msgs/es.msg
+%%EXAMPLESDIR%%/msgs/fr.msg
+%%EXAMPLESDIR%%/msgs/ja.msg
+%%EXAMPLESDIR%%/msgs/nl.msg
+@dirrm %%EXAMPLESDIR%%/msgs
+@dirrm %%EXAMPLESDIR%%
+man/mann/img-bmp.n.gz
+man/mann/img-dted.n.gz
+man/mann/img-gif.n.gz
+man/mann/img-ico.n.gz
+man/mann/img-jpeg.n.gz
+man/mann/img-pcx.n.gz
+man/mann/img-pixmap.n.gz
+man/mann/img-png.n.gz
+man/mann/img-ppm.n.gz
+man/mann/img-ps.n.gz
+man/mann/img-raw.n.gz
+man/mann/img-sgi.n.gz
+man/mann/img-sun.n.gz
+man/mann/img-tga.n.gz
+man/mann/img-tiff.n.gz
+man/mann/img-window.n.gz
+man/mann/img-xbm.n.gz
+man/mann/img-xpm.n.gz
+man/mann/img.n.gz