freebsd-ports/graphics/libimg/files/patch-tiff
2014-06-09 22:03:14 +00:00

330 lines
8.8 KiB
Text

--- tiff/configure 2013-11-21 17:03:14.000000000 -0500
+++ tiff/configure 2014-06-09 14:00:22.000000000 -0400
@@ -8232,5 +8232,5 @@
- 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>
#ifdef HAVE_STDLIB_H
#undef HAVE_STDLIB_H
#endif
-#include "jpegtcl.h"
+#include <jpeglib.h>
@@ -35,7 +39,4 @@ static int SetupTiffLibrary(Tcl_Interp *
#include "init.c"
-#include "tiffInt.h"
-
-
extern DLLIMPORT int unlink(const char *);
@@ -88,10 +89,4 @@ SetupTiffLibrary (interp)
Tcl_Interp *interp;
{
- static int initialized = 0;
-
- if (Tifftcl_InitStubs(interp, TIFFTCL_VERSION, 0) == NULL) {
- return TCL_ERROR;
- }
-
if (errorMessage) {
ckfree(errorMessage);
@@ -105,35 +100,4 @@ SetupTiffLibrary (interp)
}
- /*
- * Initialize jpeg and zlib too, for use by the CODEC's we register
- * with the base TIFF library in this package.
- */
-
- if (Jpegtcl_InitStubs(interp, JPEGTCL_VERSION, 0) == NULL) {
- return TCL_ERROR;
- }
-
- if (!initialized) {
- initialized = 1;
- if (
- TIFFRegisterCODEC && TIFFError && TIFFPredictorInit &&
- _TIFFMergeFieldInfo && TIFFFlushData1 && _TIFFNoPostDecode &&
- TIFFTileRowSize && TIFFScanlineSize && _TIFFsetByteArray &&
- TIFFVSetField && TIFFSwabArrayOfShort
- ) {
-
- if (Zlibtcl_InitStubs(interp, ZLIBTCL_VERSION, 0) == NULL) {
- return TCL_ERROR;
- }
- TIFFRegisterCODEC (COMPRESSION_DEFLATE, "Deflate", TkimgTIFFInitZip);
- TIFFRegisterCODEC (COMPRESSION_ADOBE_DEFLATE, "AdobeDeflate", TkimgTIFFInitZip);
-
- if (Jpegtcl_InitStubs(interp, JPEGTCL_VERSION, 0) == NULL) {
- return TCL_ERROR;
- }
- TIFFRegisterCODEC (COMPRESSION_JPEG, "JPEG", TkimgTIFFInitJpeg);
- TIFFRegisterCODEC (COMPRESSION_PIXARLOG, "PixarLog", TkimgTIFFInitPixar);
- }
- }
return TCL_OK;
}
@@ -451,8 +415,6 @@ ObjRead(interp, data, format, imageHandl
{
TIFF *tif;
- char *tempFileName = NULL, tempFileNameBuffer[256];
- int count, result;
+ int result;
tkimg_MFile handle;
- char buffer[1024];
char *dataPtr = NULL;
@@ -461,35 +423,13 @@ ObjRead(interp, data, format, imageHandl
}
- if (TIFFClientOpen) {
- if (handle.state != IMG_STRING) {
- dataPtr = ckalloc((handle.length*3)/4 + 2);
- 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);
- } else {
- Tcl_Channel outchan;
- tempFileName = tmpnam(tempFileNameBuffer);
- outchan = tkimg_OpenFileChannel(interp, tempFileName, 0644);
- if (!outchan) {
- return TCL_ERROR;
- }
-
- count = tkimg_Read(&handle, buffer, 1024);
- while (count == 1024) {
- Tcl_Write(outchan, buffer, count);
- count = tkimg_Read(&handle, buffer, 1024);
- }
- if (count>0){
- Tcl_Write(outchan, buffer, count);
- }
- if (Tcl_Close(interp, outchan) == TCL_ERROR) {
- return TCL_ERROR;
- }
- tif = TIFFOpen(tempFileName, "r");
- }
+ if (handle.state != IMG_STRING) {
+ dataPtr = ckalloc((handle.length*3)/4 + 2);
+ 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);
if (tif != NULL) {
@@ -499,7 +439,4 @@ ObjRead(interp, data, format, imageHandl
result = TCL_ERROR;
}
- if (tempFileName) {
- unlink(tempFileName);
- }
if (result == TCL_ERROR) {
Tcl_AppendResult(interp, errorMessage, (char *) NULL);
@@ -526,37 +463,12 @@ ChnRead(interp, chan, fileName, format,
{
TIFF *tif;
- char *tempFileName = NULL, tempFileNameBuffer[256];
- int count, result;
- char buffer[1024];
-
- if (TIFFClientOpen) {
- tkimg_MFile handle;
- handle.data = (char *) chan;
- handle.state = IMG_CHAN;
- tif = TIFFClientOpen(fileName, "r", (thandle_t) &handle,
- readMFile, writeDummy, seekMFile, closeDummy,
- sizeMFile, mapDummy, unMapDummy);
- } else {
- Tcl_Channel outchan;
- tempFileName = tmpnam(tempFileNameBuffer);
- outchan = tkimg_OpenFileChannel(interp, tempFileName, 0644);
- if (!outchan) {
- return TCL_ERROR;
- }
-
- count = Tcl_Read(chan, buffer, 1024);
- while (count == 1024) {
- Tcl_Write(outchan, buffer, count);
- count = Tcl_Read(chan, buffer, 1024);
- }
- if (count>0){
- Tcl_Write(outchan, buffer, count);
- }
- if (Tcl_Close(interp, outchan) == TCL_ERROR) {
- return TCL_ERROR;
- }
+ 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);
if (tif) {
result = CommonRead(interp, tif, format, imageHandle,
@@ -565,7 +477,4 @@ ChnRead(interp, chan, fileName, format,
result = TCL_ERROR;
}
- if (tempFileName) {
- unlink(tempFileName);
- }
if (result == TCL_ERROR) {
Tcl_AppendResult(interp, errorMessage, (char *) NULL);
@@ -635,5 +544,5 @@ CommonRead(interp, tif, format, imageHan
npixels = w * h;
- raster = (uint32*) TkimgTIFFmalloc(npixels * sizeof (uint32));
+ raster = (uint32*) _TIFFmalloc(npixels * sizeof (uint32));
block.width = w;
block.height = h;
@@ -646,5 +555,5 @@ CommonRead(interp, tif, format, imageHan
if (!TIFFReadRGBAImage(tif, w, h, raster, 0) || errorMessage) {
- TkimgTIFFfree (raster);
+ _TIFFfree (raster);
if (errorMessage) {
Tcl_AppendResult(interp, errorMessage, (char *) NULL);
@@ -663,5 +572,5 @@ CommonRead(interp, tif, format, imageHan
}
- TkimgTIFFfree (raster);
+ _TIFFfree (raster);
TIFFClose(tif);
return result;
@@ -674,7 +583,6 @@ static int StringWrite(
) {
TIFF *tif;
- int result, comp;
+ int result, comp, length;
tkimg_MFile handle;
- char *tempFileName = NULL, tempFileNameBuffer[256];
Tcl_DString dstring;
const char *mode;
@@ -686,14 +594,9 @@ static int StringWrite(
}
- if (TIFFClientOpen) {
- Tcl_DStringInit(&dstring);
- tkimg_WriteInit(&dstring, &handle);
- tif = TIFFClientOpen("inline data", mode, (thandle_t) &handle,
- readString, writeString, seekString, closeDummy,
- sizeString, mapDummy, unMapDummy);
- } else {
- tempFileName = tmpnam(tempFileNameBuffer);
- tif = TIFFOpen(tempFileName,mode);
- }
+ Tcl_DStringInit(&dstring);
+ tkimg_WriteInit(&dstring, &handle);
+ tif = TIFFClientOpen("inline data", mode, (thandle_t) &handle,
+ readString, writeString, seekString, closeDummy,
+ sizeString, mapDummy, unMapDummy);
result = CommonWrite(interp, tif, comp, blockPtr);
@@ -701,7 +604,4 @@ static int StringWrite(
if (result != TCL_OK) {
- if (tempFileName) {
- unlink(tempFileName);
- }
Tcl_AppendResult(interp, errorMessage, (char *) NULL);
ckfree(errorMessage);
@@ -710,29 +610,8 @@ static int StringWrite(
}
- 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);
- }
+ length = handle.length;
+ tkimg_WriteInit(&data, &handle);
+ tkimg_Write(&handle, Tcl_DStringValue(&dstring), length);
+ Tcl_DStringFree(&dstring);
tkimg_Putc(IMG_DONE, &handle);
if (result == TCL_OK) {
@@ -954,36 +833,2 @@ CommonWrite(interp, tif, comp, blockPtr)
return TCL_OK;
}
-
-void
-TkimgTIFFfree (data)
- tdata_t data;
-{
- if (_TIFFfree) {
- _TIFFfree(data);
- } else {
- ckfree((char *) data);
- }
-}
-
-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);
- }
-}