diff options
Diffstat (limited to 'graphics/libimg/files/patch-tiff')
-rw-r--r-- | graphics/libimg/files/patch-tiff | 690 |
1 files changed, 212 insertions, 478 deletions
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); +- } +-} |