diff options
31 files changed, 338 insertions, 419 deletions
diff --git a/CMake/macros.cmake b/CMake/macros.cmake index 73458d7312e..54b14dbd5ce 100644 --- a/CMake/macros.cmake +++ b/CMake/macros.cmake @@ -61,6 +61,9 @@ MACRO(SETUP_LIBDIRS) IF(WITH_OPENEXR) LINK_DIRECTORIES(${OPENEXR_LIBPATH}) ENDIF(WITH_OPENEXR) + IF(WITH_TIFF) + LINK_DIRECTORIES(${TIFF_LIBPATH}) + ENDIF(WITH_TIFF) IF(WITH_QUICKTIME) LINK_DIRECTORIES(${QUICKTIME_LIBPATH}) ENDIF(WITH_QUICKTIME) @@ -134,6 +137,9 @@ MACRO(SETUP_LIBLINKS IF(WITH_QUICKTIME) TARGET_LINK_LIBRARIES(${target} ${QUICKTIME_LIB}) ENDIF(WITH_QUICKTIME) + IF(WITH_TIFF) + TARGET_LINK_LIBRARIES(${target} ${TIFF_LIBRARY}) + ENDIF(WITH_TIFF) IF(WITH_OPENEXR) IF(WIN32) FOREACH(loop_var ${OPENEXR_LIB}) diff --git a/CMakeLists.txt b/CMakeLists.txt index 038b61e56a6..57a6e8998fd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,6 +63,7 @@ OPTION(WITH_BULLET "Enable Bullet (Physics Engine)" ON) OPTION(WITH_INTERNATIONAL "Enable I18N (International fonts and text)" ON) OPTION(WITH_ELBEEM "Enable Elbeem (Fluid Simulation)" ON) OPTION(WITH_OPENEXR "Enable OpenEXR Support (http://www.openexr.com)" ON) +OPTION(WITH_TIFF "Enable LibTIFF Support" ON) OPTION(WITH_DDS "Enable DDS Support" ON) OPTION(WITH_FFMPEG "Enable FFMPeg Support (http://ffmpeg.mplayerhq.hu/)" OFF) OPTION(WITH_PYTHON "Enable Embedded Python API" ON) @@ -410,6 +411,8 @@ IF(WIN32) SET(TIFF ${LIBDIR}/tiff) SET(TIFF_INC ${TIFF}/include) + SET(TIFF_LIBRARY tiff) + SET(TIFF_LIBPATH ${TIFF}/lib) SET(WINTAB_INC ${LIBDIR}/wintab/include) @@ -586,6 +589,8 @@ IF(APPLE) SET(TIFF ${LIBDIR}/tiff) SET(TIFF_INC ${TIFF}/include) + SET(TIFF_LIBRARY tiff) + SET(TIFF_LIBPATH ${TIFF}/lib) SET(EXETYPE MACOSX_BUNDLE) diff --git a/config/darwin-config.py b/config/darwin-config.py index bac4c9ab165..2c3d0a7e87e 100644 --- a/config/darwin-config.py +++ b/config/darwin-config.py @@ -163,8 +163,11 @@ BF_PNG_INC = '${BF_PNG}/include' BF_PNG_LIB = 'png' BF_PNG_LIBPATH = '${BF_PNG}/lib' +WITH_BF_TIFF = True BF_TIFF = LIBDIR + '/tiff' BF_TIFF_INC = '${BF_TIFF}/include' +BF_TIFF_LIB = 'tiff' +BF_TIFF_LIBPATH = '${BF_TIFF}/lib' WITH_BF_ZLIB = True BF_ZLIB = '/usr' diff --git a/config/linux2-config.py b/config/linux2-config.py index 3951dac2454..199ea391d4e 100644 --- a/config/linux2-config.py +++ b/config/linux2-config.py @@ -68,8 +68,10 @@ BF_PNG = '/usr' BF_PNG_INC = '${BF_PNG}/include' BF_PNG_LIB = 'png' +WITH_BF_TIFF = True BF_TIFF = '/usr' BF_TIFF_INC = '${BF_TIFF}/include' +BF_TIFF_LIB = 'tiff' WITH_BF_ZLIB = True BF_ZLIB = '/usr' diff --git a/config/win32-mingw-config.py b/config/win32-mingw-config.py index 9088db5a5d8..319c9b264f2 100644 --- a/config/win32-mingw-config.py +++ b/config/win32-mingw-config.py @@ -73,6 +73,7 @@ BF_PNG_INC = '${BF_PNG}/include' BF_PNG_LIB = 'png' BF_PNG_LIBPATH = '${BF_PNG}/lib' +WITH_BF_TIFF = True BF_TIFF = LIBDIR + '/tiff' BF_TIFF_INC = '${BF_TIFF}/include' BF_TIFF_LIB = 'libtiff' diff --git a/config/win32-vc-config.py b/config/win32-vc-config.py index 3e8dfc3d5df..b3766247d2d 100644 --- a/config/win32-vc-config.py +++ b/config/win32-vc-config.py @@ -79,6 +79,7 @@ BF_PNG_INC = '${BF_PNG}/include' BF_PNG_LIB = 'libpng_st' BF_PNG_LIBPATH = '${BF_PNG}/lib' +WITH_BF_TIFF = True BF_TIFF = LIBDIR + '/tiff' BF_TIFF_INC = '${BF_TIFF}/include' BF_TIFF_LIB = 'libtiff' diff --git a/config/win64-vc-config.py b/config/win64-vc-config.py index 41772dea14b..c1cbb7cfee8 100644 --- a/config/win64-vc-config.py +++ b/config/win64-vc-config.py @@ -75,6 +75,7 @@ BF_PNG_INC = '${BF_PNG}/include' BF_PNG_LIB = 'libpng' BF_PNG_LIBPATH = '${BF_PNG}/lib' +WITH_BF_TIFF = True BF_TIFF = LIBDIR + '/tiff' BF_TIFF_INC = '${BF_TIFF}/include' BF_TIFF_LIB = 'libtiff' diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenkernel/BKE_global.h index 291deb5ea70..6a602339e11 100644 --- a/source/blender/blenkernel/BKE_global.h +++ b/source/blender/blenkernel/BKE_global.h @@ -83,9 +83,6 @@ typedef struct Global { struct VFont *selfont; struct ListBase ttfdata; - /* libtiff flag used to determine if shared library loaded for libtiff*/ - int have_libtiff; - /* this variable is written to / read from FileGlobal->fileflags */ int fileflags; diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index afb29fbcd62..68684bcc0a1 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -50,6 +50,10 @@ IF(WITH_OPENEXR) ADD_DEFINITIONS(-DWITH_OPENEXR) ENDIF(WITH_OPENEXR) +IF(WITH_TIFF) + ADD_DEFINITIONS(-DWITH_TIFF) +ENDIF(WITH_TIFF) + IF(WITH_OPENJPEG) ADD_DEFINITIONS(-DWITH_OPENJPEG) ENDIF(WITH_OPENJPEG) diff --git a/source/blender/blenkernel/SConscript b/source/blender/blenkernel/SConscript index 57d7e45d986..6198520c853 100644 --- a/source/blender/blenkernel/SConscript +++ b/source/blender/blenkernel/SConscript @@ -38,6 +38,9 @@ else: if env['WITH_BF_OPENEXR']: defs.append('WITH_OPENEXR') +if env['WITH_BF_TIFF']: + defs.append('WITH_TIFF') + if env['WITH_BF_OPENJPEG']: defs.append('WITH_OPENJPEG') diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index eb478eaddf5..5588c8df161 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -779,10 +779,12 @@ void BKE_add_image_extension(char *string, int imtype) if(!BLI_testextensie(string, ".bmp")) extension= ".bmp"; } - else if(G.have_libtiff && (imtype==R_TIFF)) { +#ifdef WITH_TIFF + else if(imtype==R_TIFF) { if(!BLI_testextensie(string, ".tif") && !BLI_testextensie(string, ".tiff")) extension= ".tif"; } +#endif #ifdef WITH_OPENEXR else if( ELEM(imtype, R_OPENEXR, R_MULTILAYER)) { if(!BLI_testextensie(string, ".exr")) @@ -1187,12 +1189,14 @@ int BKE_write_ibuf(Scene *scene, ImBuf *ibuf, char *name, int imtype, int subimt else if ((imtype==R_BMP)) { ibuf->ftype= BMP; } - else if ((G.have_libtiff) && (imtype==R_TIFF)) { +#ifdef WITH_TIFF + else if (imtype==R_TIFF) { ibuf->ftype= TIF; if(subimtype & R_TIFF_16BIT) ibuf->ftype |= TIF_16BIT; } +#endif #ifdef WITH_OPENEXR else if (imtype==R_OPENEXR || imtype==R_MULTILAYER) { ibuf->ftype= OPENEXR; diff --git a/source/blender/editors/CMakeLists.txt b/source/blender/editors/CMakeLists.txt index 86085aa0573..bf379ae3ca6 100644 --- a/source/blender/editors/CMakeLists.txt +++ b/source/blender/editors/CMakeLists.txt @@ -57,6 +57,10 @@ IF(WITH_OPENEXR) ADD_DEFINITIONS(-DWITH_OPENEXR) ENDIF(WITH_OPENEXR) +IF(WITH_TIFF) + ADD_DEFINITIONS(-DWITH_TIFF) +ENDIF(WITH_TIFF) + IF(WITH_OPENJPEG) ADD_DEFINITIONS(-DWITH_OPENJPEG) ENDIF(WITH_OPENJPEG) diff --git a/source/blender/editors/space_file/SConscript b/source/blender/editors/space_file/SConscript index b22a265dcbc..9de705e99d3 100644 --- a/source/blender/editors/space_file/SConscript +++ b/source/blender/editors/space_file/SConscript @@ -12,9 +12,13 @@ defs = [] if env['WITH_BF_OPENJPEG']: defs.append('WITH_OPENJPEG') + if env['WITH_BF_OPENEXR']: defs.append('WITH_OPENEXR') +if env['WITH_BF_TIFF']: + defs.append('WITH_TIFF') + if env['OURPLATFORM'] == 'linux2': cflags='-pthread' incs += ' ../../../extern/binreloc/include' diff --git a/source/blender/editors/space_file/writeimage.c b/source/blender/editors/space_file/writeimage.c index c9b30983b93..05efdc12596 100644 --- a/source/blender/editors/space_file/writeimage.c +++ b/source/blender/editors/space_file/writeimage.c @@ -143,10 +143,11 @@ void save_image_filesel_str(Scene *scene, char *str) case R_BMP: strcpy(str, "Save BMP"); break; +#ifdef WITH_TIFF case R_TIFF: - if (G.have_libtiff) - strcpy(str, "Save TIFF"); + strcpy(str, "Save TIFF"); break; +#endif #ifdef WITH_OPENEXR case R_OPENEXR: strcpy(str, "Save OpenEXR"); diff --git a/source/blender/editors/space_image/SConscript b/source/blender/editors/space_image/SConscript index dd43559645d..b38e1473a0c 100644 --- a/source/blender/editors/space_image/SConscript +++ b/source/blender/editors/space_image/SConscript @@ -13,6 +13,8 @@ if env['WITH_BF_LCMS']: defs.append('WITH_LCMS') if env['WITH_BF_OPENEXR']: defs.append('WITH_OPENEXR') +if env['WITH_BF_TIFF']: + defs.append('WITH_TIFF') if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc'): incs += ' ' + env['BF_PTHREADS_INC'] diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 274d26c8760..64d24ed578a 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -637,8 +637,9 @@ static const EnumPropertyItem image_file_type_items[] = { {R_JP2, "JPEG_2000", 0, "Jpeg 2000", ""}, #endif {R_IRIS, "IRIS", 0, "Iris", ""}, - //if(G.have_libtiff) +#ifdef WITH_TIFF {R_TIFF, "TIFF", 0, "Tiff", ""}, +#endif {R_RADHDR, "RADIANCE_HDR", 0, "Radiance HDR", ""}, {R_CINEON, "CINEON", 0, "Cineon", ""}, {R_DPX, "DPX", 0, "DPX", ""}, diff --git a/source/blender/imbuf/CMakeLists.txt b/source/blender/imbuf/CMakeLists.txt index 5af39cea832..6940ac8514f 100644 --- a/source/blender/imbuf/CMakeLists.txt +++ b/source/blender/imbuf/CMakeLists.txt @@ -32,7 +32,6 @@ SET(INC ../avi ../blenkernel ${JPEG_INC} ${PNG_INC} - ${TIFF_INC} ${ZLIB_INC} ${OPENJPEG_INC} ) @@ -45,6 +44,11 @@ IF(WITH_OPENEXR) ADD_DEFINITIONS(-DWITH_OPENEXR) ENDIF(WITH_OPENEXR) +IF(WITH_TIFF) + SET(INC ${INC} ${TIFF_INC}) + ADD_DEFINITIONS(-DWITH_TIFF) +ENDIF(WITH_TIFF) + IF(WITH_OPENJPEG) ADD_DEFINITIONS(-DWITH_OPENJPEG) ENDIF(WITH_OPENJPEG) diff --git a/source/blender/imbuf/SConscript b/source/blender/imbuf/SConscript index b4f56df9ec0..439cdecdf5b 100644 --- a/source/blender/imbuf/SConscript +++ b/source/blender/imbuf/SConscript @@ -20,6 +20,9 @@ if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc'): if env['WITH_BF_OPENEXR']: defs.append('WITH_OPENEXR') +if env['WITH_BF_TIFF']: + defs.append('WITH_TIFF') + if env['WITH_BF_DDS']: defs.append('WITH_DDS') diff --git a/source/blender/imbuf/intern/dynlibtiff.c b/source/blender/imbuf/intern/dynlibtiff.c deleted file mode 100644 index eb1b5f8e10a..00000000000 --- a/source/blender/imbuf/intern/dynlibtiff.c +++ /dev/null @@ -1,280 +0,0 @@ -/** - * Dynamically loaded libtiff support. - * - * This file is automatically generated by the gen_dynlibtiff.py script. - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Contributor(s): Jonathan Merritt. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** - * To use the dynamic libtiff support, you must initialize the library using: - * libtiff_init() - * This attempts to load libtiff dynamically at runtime. G.have_libtiff will - * be set to indicate whether or not libtiff is available. If libtiff is - * not available, Blender can proceed with no ill effects, provided that - * it does not attempt to use any of the libtiff_ functions. When you're - * finished, close the library with: - * libtiff_exit() - * These functions are both declared in IMB_imbuf.h - * - * The functions provided by dyn_libtiff.h are the same as those in the - * normal static / shared libtiff, except that they are prefixed by the - * string "libtiff_" to indicate that they belong to a dynamically-loaded - * version. - */ -#include "dynlibtiff.h" - -#include <assert.h> -#include <stdio.h> -#include <stdlib.h> - -#include "BLI_blenlib.h" - -#include "imbuf.h" -#include "IMB_imbuf.h" - -#include "BKE_global.h" -#include "PIL_dynlib.h" - -/********************* - * LOCAL DEFINITIONS * - *********************/ -PILdynlib *libtiff = NULL; -void libtiff_loadlibtiff(void); -void* libtiff_findsymbol(char*); -int libtiff_load_symbols(void); - - -/************************** - * LIBRARY INITIALIZATION * - **************************/ - -void libtiff_loadlibtiff(void) -{ - char *filename; - libtiff = NULL; - - filename = getenv("BF_TIFF_LIB"); - if (filename) libtiff = PIL_dynlib_open(filename); - if (libtiff != NULL) return; - - /* Try to find libtiff in a couple of standard places */ -#ifdef __APPLE__ - /* OSX has version specific library */ - //standard install location - libtiff = PIL_dynlib_open("/usr/local/lib/libtiff.dylib"); - if (libtiff != NULL) return; - libtiff = PIL_dynlib_open("/usr/local/lib/libtiff.3.dylib"); - if (libtiff != NULL) return; - libtiff = PIL_dynlib_open("/usr/local/lib/libtiff.4.dylib"); - if (libtiff != NULL) return; - //inside the blender app package contents/resources - libtiff = PIL_dynlib_open("@executable_path/../resources/libtiff.dylib"); - if (libtiff != NULL) return; - libtiff = PIL_dynlib_open("@executable_path/../resources/libtiff.3.dylib"); - if (libtiff != NULL) return; - libtiff = PIL_dynlib_open("@executable_path/../resources/libtiff.4.dylib"); - if (libtiff != NULL) return; - //inside the blender app package contents/frameworks - libtiff = PIL_dynlib_open("@executable_path/../frameworks/libtiff.dylib"); - if (libtiff != NULL) return; - libtiff = PIL_dynlib_open("@executable_path/../frameworks/libtiff.3.dylib"); - if (libtiff != NULL) return; - libtiff = PIL_dynlib_open("@executable_path/../frameworks/libtiff.4.dylib"); - if (libtiff != NULL) return; - //along side the blender app package - libtiff = PIL_dynlib_open("@executable_path/../../../libtiff.dylib"); - if (libtiff != NULL) return; - libtiff = PIL_dynlib_open("@executable_path/../../../libtiff.3.dylib"); - if (libtiff != NULL) return; - libtiff = PIL_dynlib_open("@executable_path/../../../libtiff.4.dylib"); - if (libtiff != NULL) return; - //inside the blender app package contents/MacOS - libtiff = PIL_dynlib_open("@executable_path/libtiff.dylib"); - if (libtiff != NULL) return; - libtiff = PIL_dynlib_open("@executable_path/libtiff.3.dylib"); - if (libtiff != NULL) return; - libtiff = PIL_dynlib_open("@executable_path/libtiff.4.dylib"); - if (libtiff != NULL) return; -#else - libtiff = PIL_dynlib_open("libtiff.so"); - if (libtiff != NULL) return; - libtiff = PIL_dynlib_open("libtiff.so.3"); - if (libtiff != NULL) return; - libtiff = PIL_dynlib_open("libtiff.so.4"); - if (libtiff != NULL) return; - libtiff = PIL_dynlib_open("libtiff.dll"); - if (libtiff != NULL) return; - libtiff = PIL_dynlib_open("/usr/lib/libtiff.so"); - if (libtiff != NULL) return; - libtiff = PIL_dynlib_open("/usr/lib/libtiff.so.3"); - if (libtiff != NULL) return; - libtiff = PIL_dynlib_open("/usr/lib/libtiff.so.4"); - if (libtiff != NULL) return; -#ifdef __x86_64__ - libtiff = PIL_dynlib_open("/usr/lib64/libtiff.so"); - if (libtiff != NULL) return; - libtiff = PIL_dynlib_open("/usr/lib64/libtiff.so.3"); - if (libtiff != NULL) return; - libtiff = PIL_dynlib_open("/usr/lib64/libtiff.so.4"); - if (libtiff != NULL) return; -#endif - libtiff = PIL_dynlib_open("/usr/local/lib/libtiff.so"); - if (libtiff != NULL) return; - /* For solaris */ - libtiff = PIL_dynlib_open("/usr/openwin/lib/libtiff.so"); -#endif - -} - -void *libtiff_findsymbol(char *name) -{ - void *symbol = NULL; - assert(libtiff != NULL); - symbol = PIL_dynlib_find_symbol(libtiff, name); - if (symbol == NULL) { - char *err = PIL_dynlib_get_error_as_string(libtiff); - - if (err) printf("libtiff_findsymbol: error %s\n",err); - else printf("libtiff_findsymbol: error Unknown.\n"); - - libtiff = NULL; - G.have_libtiff = (0); - return NULL; - } - return symbol; -} - -void libtiff_init(void) -{ - if (libtiff != NULL) { - printf("libtiff_init: Attempted to load libtiff twice!\n"); - return; - } - libtiff_loadlibtiff(); - G.have_libtiff = ((libtiff != NULL) && (libtiff_load_symbols())); - - if (!G.have_libtiff && (G.f & G_DEBUG)) { - printf("Unable to load: libtiff.\n"); - printf("Try setting the BF_TIFF_LIB environment variable if you want this support.\n"); - printf("Example: setenv BF_TIFF_LIB /usr/lib/libtiff.so\n"); - } -} - -void libtiff_exit(void) -{ - if (libtiff != NULL) { - PIL_dynlib_close(libtiff); - libtiff = NULL; - } -} - - -int libtiff_load_symbols(void) -{ - /* Attempt to load TIFFClientOpen */ - libtiff_TIFFClientOpen = libtiff_findsymbol("TIFFClientOpen"); - if (libtiff_TIFFClientOpen == NULL) { - return (0); - } - /* Attempt to load TIFFClose */ - libtiff_TIFFClose = libtiff_findsymbol("TIFFClose"); - if (libtiff_TIFFClose == NULL) { - return (0); - } - /* Attempt to load TIFFGetField */ - libtiff_TIFFGetField = libtiff_findsymbol("TIFFGetField"); - if (libtiff_TIFFGetField == NULL) { - return (0); - } - /* Attempt to load TIFFOpen */ - libtiff_TIFFOpen = libtiff_findsymbol("TIFFOpen"); - if (libtiff_TIFFOpen == NULL) { - return (0); - } - /* Attempt to load TIFFReadRGBAImage */ - libtiff_TIFFReadRGBAImage = libtiff_findsymbol("TIFFReadRGBAImage"); - if (libtiff_TIFFReadRGBAImage == NULL) { - return (0); - } - /* Attempt to load TIFFSetField */ - libtiff_TIFFSetField = libtiff_findsymbol("TIFFSetField"); - if (libtiff_TIFFSetField == NULL) { - return (0); - } - /* Attempt to load TIFFWriteEncodedStrip */ - libtiff_TIFFWriteEncodedStrip = libtiff_findsymbol("TIFFWriteEncodedStrip"); - if (libtiff_TIFFWriteEncodedStrip == NULL) { - return (0); - } - /* Attempt to load _TIFFfree */ - libtiff__TIFFfree = libtiff_findsymbol("_TIFFfree"); - if (libtiff__TIFFfree == NULL) { - return (0); - } - /* Attempt to load _TIFFmalloc */ - libtiff__TIFFmalloc = libtiff_findsymbol("_TIFFmalloc"); - if (libtiff__TIFFmalloc == NULL) { - return (0); - } - /* Attempt to load TIFFSetDirectory */ - libtiff_TIFFSetDirectory = libtiff_findsymbol("TIFFSetDirectory"); - if (libtiff_TIFFSetDirectory == NULL) { - return (0); - } - /* Attempt to load TIFFNumberOfDirectories */ - libtiff_TIFFNumberOfDirectories = libtiff_findsymbol("TIFFNumberOfDirectories"); - if (libtiff_TIFFNumberOfDirectories == NULL) { - return (0); - } - /* Attempt to load TIFFIsTiled */ - libtiff_TIFFIsTiled = libtiff_findsymbol("TIFFIsTiled"); - if (libtiff_TIFFIsTiled == NULL) { - return (0); - } - /* Attempt to load TIFFReadRGBATile */ - libtiff_TIFFReadRGBATile = libtiff_findsymbol("TIFFReadRGBATile"); - if (libtiff_TIFFReadRGBATile == NULL) { - return (0); - } - return (1); -} - - -/******************* - * SYMBOL POINTERS * - *******************/ - -TIFF* (*libtiff_TIFFClientOpen)(const char*, const char*, thandle_t, TIFFReadWriteProc, TIFFReadWriteProc, TIFFSeekProc, TIFFCloseProc, TIFFSizeProc, TIFFMapFileProc, TIFFUnmapFileProc) = NULL; -void (*libtiff_TIFFClose)(TIFF*) = NULL; -int (*libtiff_TIFFGetField)(TIFF*, ttag_t, ...) = NULL; -TIFF* (*libtiff_TIFFOpen)(const char*, const char*) = NULL; -int (*libtiff_TIFFReadRGBAImage)(TIFF*, uint32, uint32, uint32*, int) = NULL; -int (*libtiff_TIFFSetField)(TIFF*, ttag_t, ...) = NULL; -tsize_t (*libtiff_TIFFWriteEncodedStrip)(TIFF*, tstrip_t, tdata_t, tsize_t) = NULL; -void (*libtiff__TIFFfree)(tdata_t) = NULL; -tdata_t (*libtiff__TIFFmalloc)(tsize_t) = NULL; -int (*libtiff_TIFFSetDirectory)(TIFF*, tdir_t) = NULL; -tdir_t (*libtiff_TIFFNumberOfDirectories)(TIFF*) = NULL; -int (*libtiff_TIFFIsTiled)(TIFF*) = NULL; -int (*libtiff_TIFFReadRGBATile)(TIFF*, uint32, uint32, uint32 * ) = NULL; - - diff --git a/source/blender/imbuf/intern/dynlibtiff.h b/source/blender/imbuf/intern/dynlibtiff.h deleted file mode 100644 index 5fafafbcf94..00000000000 --- a/source/blender/imbuf/intern/dynlibtiff.h +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Dynamically loaded libtiff support. - * - * This file is automatically generated by the gen_dynlibtiff.py script. - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Contributor(s): Jonathan Merritt. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** - * To use the dynamic libtiff support, you must initialize the library using: - * libtiff_init() - * This attempts to load libtiff dynamically at runtime. G.have_libtiff will - * be set to indicate whether or not libtiff is available. If libtiff is - * not available, Blender can proceed with no ill effects, provided that - * it does not attempt to use any of the libtiff_ functions. When you're - * finished, close the library with: - * libtiff_exit() - * These functions are both declared in IMB_imbuf.h - * - * The functions provided by dyn_libtiff.h are the same as those in the - * normal static / shared libtiff, except that they are prefixed by the - * string "libtiff_" to indicate that they belong to a dynamically-loaded - * version. - */ -#ifndef DYN_LIBTIFF_H -#include "tiffio.h" -extern TIFF* (*libtiff_TIFFClientOpen)(const char*, const char*, thandle_t, TIFFReadWriteProc, TIFFReadWriteProc, TIFFSeekProc, TIFFCloseProc, TIFFSizeProc, TIFFMapFileProc, TIFFUnmapFileProc); -extern void (*libtiff_TIFFClose)(TIFF*); -extern int (*libtiff_TIFFGetField)(TIFF*, ttag_t, ...); -extern TIFF* (*libtiff_TIFFOpen)(const char*, const char*); -extern int (*libtiff_TIFFReadRGBAImage)(TIFF*, uint32, uint32, uint32*, int); -extern int (*libtiff_TIFFSetField)(TIFF*, ttag_t, ...); -extern tsize_t (*libtiff_TIFFWriteEncodedStrip)(TIFF*, tstrip_t, tdata_t, tsize_t); -extern void (*libtiff__TIFFfree)(tdata_t); -extern tdata_t (*libtiff__TIFFmalloc)(tsize_t); -extern int (*libtiff_TIFFSetDirectory)(TIFF*, tdir_t); -extern tdir_t (*libtiff_TIFFNumberOfDirectories)(TIFF*); -extern int (*libtiff_TIFFIsTiled)(TIFF*); -extern int (*libtiff_TIFFReadRGBATile)(TIFF*, uint32, uint32, uint32 * ); -#endif /* DYN_LIBTIFF_H */ - diff --git a/source/blender/imbuf/intern/filetype.c b/source/blender/imbuf/intern/filetype.c index 4a491ceba22..a0ff4476556 100644 --- a/source/blender/imbuf/intern/filetype.c +++ b/source/blender/imbuf/intern/filetype.c @@ -65,10 +65,10 @@ ImFileType IMB_FILE_TYPES[]= { {NULL, NULL, imb_is_a_targa, imb_ftype_default, imb_loadtarga, imb_savetarga, NULL, 0, TGA}, {NULL, NULL, imb_is_dpx, imb_ftype_default, imb_loaddpx, imb_save_dpx, NULL, IM_FTYPE_FLOAT, DPX}, {NULL, NULL, imb_is_cineon, imb_ftype_default, imb_loadcineon, imb_savecineon, NULL, IM_FTYPE_FLOAT, CINEON}, -#if defined(__APPLE__) && defined(IMBUF_COCOA) +#ifdef WITH_TIFF + {NULL, NULL, imb_is_a_tiff, imb_ftype_default, imb_loadtiff, imb_savetiff, imb_loadtiletiff, 0, TIF}, +#elif defined(__APPLE__) && defined(IMBUF_COCOA) {NULL, NULL, imb_is_a_cocoa, imb_ftype_cocoa, imb_imb_cocoaLoadImage, imb_savecocoa, NULL, 0, TIF}, -#else - {libtiff_init, libtiff_exit, imb_is_a_tiff, imb_ftype_default, imb_loadtiff, imb_savetiff, imb_loadtiletiff, 0, TIF}, #endif {NULL, NULL, imb_is_a_hdr, imb_ftype_default, imb_loadhdr, imb_savehdr, NULL, IM_FTYPE_FLOAT, RADHDR}, #ifdef WITH_OPENEXR diff --git a/source/blender/imbuf/intern/tiff.c b/source/blender/imbuf/intern/tiff.c index 3bc3f616da0..1e4b2ea7110 100644 --- a/source/blender/imbuf/intern/tiff.c +++ b/source/blender/imbuf/intern/tiff.c @@ -40,10 +40,12 @@ * used to compress images. */ +#ifdef WITH_TIFF + #include <string.h> #include "imbuf.h" - + #include "BKE_global.h" #include "BKE_utildefines.h" @@ -57,7 +59,7 @@ #include "IMB_filetype.h" #include "IMB_filter.h" -#include "dynlibtiff.h" +#include "tiffio.h" @@ -267,7 +269,7 @@ static TIFF *imb_tiff_client_open(ImbTIFFMemFile *memFile, unsigned char *mem, i memFile->offset = 0; memFile->size = size; - return libtiff_TIFFClientOpen("(Blender TIFF Interface Layer)", + return TIFFClientOpen("(Blender TIFF Interface Layer)", "r", (thandle_t)(memFile), imb_tiff_ReadProc, imb_tiff_WriteProc, imb_tiff_SeekProc, imb_tiff_CloseProc, @@ -299,16 +301,77 @@ int imb_is_a_tiff(unsigned char *mem) (memcmp(lil_endian, mem, IMB_TIFF_NCB) == 0) ); } -static int imb_read_tiff_pixels(ImBuf *ibuf, TIFF *image, int premul) +static void scanline_contig_8bit(unsigned char *rect, unsigned char *cbuf, int scanline_w, int spp) +{ + int i; + for (i=0; i < scanline_w; i++) { + rect[i*4 + 0] = cbuf[i*spp + 0]; + rect[i*4 + 1] = cbuf[i*spp + 1]; + rect[i*4 + 2] = cbuf[i*spp + 2]; + rect[i*4 + 3] = (spp==4)?cbuf[i*spp + 3]:255; + } +} + +static void scanline_contig_16bit(float *rectf, unsigned short *sbuf, int scanline_w, int spp) +{ + int i; + for (i=0; i < scanline_w; i++) { + rectf[i*4 + 0] = sbuf[i*spp + 0] / 65535.0; + rectf[i*4 + 1] = sbuf[i*spp + 1] / 65535.0; + rectf[i*4 + 2] = sbuf[i*spp + 2] / 65535.0; + rectf[i*4 + 3] = (spp==4)?(sbuf[i*spp + 3] / 65535.0):1.0; + } +} + +static void scanline_contig_32bit(float *rectf, float *fbuf, int scanline_w, int spp) +{ + int i; + for (i=0; i < scanline_w; i++) { + rectf[i*4 + 0] = fbuf[i*spp + 0]; + rectf[i*4 + 1] = fbuf[i*spp + 1]; + rectf[i*4 + 2] = fbuf[i*spp + 2]; + rectf[i*4 + 3] = (spp==4)?fbuf[i*spp + 3]:1.0; + } +} + +static void scanline_separate_8bit(unsigned char *rect, unsigned char *cbuf, int scanline_w, int chan) +{ + int i; + for (i=0; i < scanline_w; i++) + rect[i*4 + chan] = cbuf[i]; +} + +static void scanline_separate_16bit(float *rectf, unsigned short *sbuf, int scanline_w, int chan) +{ + int i; + for (i=0; i < scanline_w; i++) + rectf[i*4 + chan] = sbuf[i] / 65535.0; +} + +static void scanline_separate_32bit(float *rectf, float *fbuf, int scanline_w, int chan) +{ + int i; + for (i=0; i < scanline_w; i++) + rectf[i*4 + chan] = fbuf[i]; +} + + +/* + * Use the libTIFF RGBAImage API to read a TIFF image. + * This function uses the "RGBA Image" support from libtiff, which enables + * it to load most commonly-encountered TIFF formats. libtiff handles format + * conversion, color depth conversion, etc. + */ +static int imb_read_tiff_pixels_rgba(ImBuf *ibuf, TIFF *image, int premul) { ImBuf *tmpibuf; int success; - + tmpibuf= IMB_allocImBuf(ibuf->x, ibuf->y, 32, IB_rect, 0); - success= libtiff_TIFFReadRGBAImage(image, ibuf->x, ibuf->y, tmpibuf->rect, 0); + success= TIFFReadRGBAImage(image, ibuf->x, ibuf->y, tmpibuf->rect, 0); if(ENDIAN_ORDER == B_ENDIAN) - IMB_convert_rgba_to_abgr(tmpibuf); + IMB_convert_rgba_to_abgr(tmpibuf); if(premul) { IMB_premultiply_alpha(tmpibuf); ibuf->flags |= IB_premul; @@ -325,12 +388,133 @@ static int imb_read_tiff_pixels(ImBuf *ibuf, TIFF *image, int premul) return success; } +/* + * Use the libTIFF scanline API to read a TIFF image. + * This method is most flexible and can handle multiple different bit depths + * and RGB channel orderings. + */ +static int imb_read_tiff_pixels(ImBuf *ibuf, TIFF *image, int premul) +{ + ImBuf *tmpibuf; + int success; + short bitspersample, spp, config; + size_t scanline; + int ib_flag=0, row, chan; + float *fbuf=NULL; + unsigned short *sbuf=NULL; + unsigned char *cbuf=NULL; + + TIFFGetField(image, TIFFTAG_BITSPERSAMPLE, &bitspersample); + TIFFGetField(image, TIFFTAG_SAMPLESPERPIXEL, &spp); /* number of 'channels' */ + TIFFGetField(image, TIFFTAG_PLANARCONFIG, &config); + scanline = TIFFScanlineSize(image); + + /* if file has an unsupported channel count, use libTIFF to + * convert to an 8 bit RGBA image */ + if (!ELEM(spp, 3, 4)) + return imb_read_tiff_pixels_rgba(ibuf, image, premul); + + + if (bitspersample == 32) { + ib_flag = IB_rectfloat; + fbuf = (float *)_TIFFmalloc(scanline); + } else if (bitspersample == 16) { + ib_flag = IB_rectfloat; + sbuf = (unsigned short *)_TIFFmalloc(scanline); + } else if (bitspersample == 8) { + ib_flag = IB_rect; + cbuf = (unsigned char *)_TIFFmalloc(scanline); + } + + tmpibuf= IMB_allocImBuf(ibuf->x, ibuf->y, ibuf->depth, ib_flag, 0); + + /* contiguous channels: RGBRGBRGB */ + if (config == PLANARCONFIG_CONTIG) { + for (row = 0; row < ibuf->y; row++) { + int ib_offset = ibuf->x*ibuf->y*4 - ibuf->x*4 * (row+1); + + if (bitspersample == 32) { + success = TIFFReadScanline(image, fbuf, row, 0); + scanline_contig_32bit(tmpibuf->rect_float+ib_offset, fbuf, ibuf->x, spp); + + } else if (bitspersample == 16) { + success = TIFFReadScanline(image, sbuf, row, 0); + scanline_contig_16bit(tmpibuf->rect_float+ib_offset, sbuf, ibuf->x, spp); + + } else if (bitspersample == 8) { + unsigned char *crect = (unsigned char*)tmpibuf->rect; + success = TIFFReadScanline(image, cbuf, row, 0); + scanline_contig_8bit(crect+ib_offset, cbuf, ibuf->x, spp); + } + } + /* separate channels: RRRGGGBBB */ + } else if (config == PLANARCONFIG_SEPARATE) { + + /* imbufs always have 4 channels of data, so we iterate over all of them + * but only fill in from the TIFF scanline where necessary. */ + for (chan = 0; chan < 4; chan++) { + for (row = 0; row < ibuf->y; row++) { + int ib_offset = ibuf->x*ibuf->y*4 - ibuf->x*4 * (row+1); + + if (bitspersample == 32) { + if (chan == 3 && spp == 3) /* fill alpha if only RGB TIFF */ + memset(fbuf, 1.0, sizeof(fbuf)); + else + success = TIFFReadScanline(image, fbuf, row, chan); + scanline_separate_32bit(tmpibuf->rect_float+ib_offset, fbuf, ibuf->x, chan); + + } else if (bitspersample == 16) { + if (chan == 3 && spp == 3) /* fill alpha if only RGB TIFF */ + memset(sbuf, 65535, sizeof(sbuf)); + else + success = TIFFReadScanline(image, sbuf, row, chan); + scanline_separate_16bit(tmpibuf->rect_float+ib_offset, sbuf, ibuf->x, chan); + + } else if (bitspersample == 8) { + unsigned char *crect = (unsigned char*)tmpibuf->rect; + if (chan == 3 && spp == 3) /* fill alpha if only RGB TIFF */ + memset(cbuf, 255, sizeof(cbuf)); + else + success = TIFFReadScanline(image, cbuf, row, chan); + scanline_separate_8bit(crect+ib_offset, cbuf, ibuf->x, chan); + } + } + } + } + + ibuf->profile = (bitspersample==32)?IB_PROFILE_LINEAR_RGB:IB_PROFILE_SRGB; + + if (bitspersample == 32) + _TIFFfree(fbuf); + else if (bitspersample == 16) + _TIFFfree(sbuf); + else if (bitspersample == 8) + _TIFFfree(cbuf); + + if(ENDIAN_ORDER == B_ENDIAN) + IMB_convert_rgba_to_abgr(tmpibuf); + if(premul) { + IMB_premultiply_alpha(tmpibuf); + ibuf->flags |= IB_premul; + } + + /* assign rect last */ + if (tmpibuf->rect_float) + ibuf->rect_float= tmpibuf->rect_float; + else + ibuf->rect= tmpibuf->rect; + ibuf->mall |= ib_flag; + ibuf->flags |= ib_flag; + + tmpibuf->mall &= ~ib_flag; + IMB_freeImBuf(tmpibuf); + + return success; +} + /** * Loads a TIFF file. * - * This function uses the "RGBA Image" support from libtiff, which enables - * it to load most commonly-encountered TIFF formats. libtiff handles format - * conversion, color depth conversion, etc. * * @param mem: Memory containing the TIFF file. * @param size: Size of the mem buffer. @@ -347,9 +531,8 @@ ImBuf *imb_loadtiff(unsigned char *mem, int size, int flags) uint32 width, height; char *format = NULL; int level; - - if(!G.have_libtiff) - return NULL; + short spp; + int ib_depth; /* check whether or not we have a TIFF file */ if(size < IMB_TIFF_NCB) { @@ -367,24 +550,27 @@ ImBuf *imb_loadtiff(unsigned char *mem, int size, int flags) } /* allocate the image buffer */ - libtiff_TIFFGetField(image, TIFFTAG_IMAGEWIDTH, &width); - libtiff_TIFFGetField(image, TIFFTAG_IMAGELENGTH, &height); - ibuf = IMB_allocImBuf(width, height, 32, 0, 0); + TIFFGetField(image, TIFFTAG_IMAGEWIDTH, &width); + TIFFGetField(image, TIFFTAG_IMAGELENGTH, &height); + TIFFGetField(image, TIFFTAG_SAMPLESPERPIXEL, &spp); + + ib_depth = (spp==3)?24:32; + + ibuf = IMB_allocImBuf(width, height, ib_depth, 0, 0); if(ibuf) { ibuf->ftype = TIF; - ibuf->profile = IB_PROFILE_SRGB; } else { fprintf(stderr, "imb_loadtiff: could not allocate memory for TIFF " \ "image.\n"); - libtiff_TIFFClose(image); + TIFFClose(image); return NULL; } /* if testing, we're done */ if(flags & IB_test) { - libtiff_TIFFClose(image); + TIFFClose(image); return ibuf; } @@ -392,14 +578,14 @@ ImBuf *imb_loadtiff(unsigned char *mem, int size, int flags) we don't read pixels but leave it to the cache to load tiles */ if(flags & IB_tilecache) { format= NULL; - libtiff_TIFFGetField(image, TIFFTAG_PIXAR_TEXTUREFORMAT, &format); + TIFFGetField(image, TIFFTAG_PIXAR_TEXTUREFORMAT, &format); - if(format && strcmp(format, "Plain Texture")==0 && libtiff_TIFFIsTiled(image)) { - int numlevel = libtiff_TIFFNumberOfDirectories(image); + if(format && strcmp(format, "Plain Texture")==0 && TIFFIsTiled(image)) { + int numlevel = TIFFNumberOfDirectories(image); /* create empty mipmap levels in advance */ for(level=0; level<numlevel; level++) { - if(!libtiff_TIFFSetDirectory(image, level)) + if(!TIFFSetDirectory(image, level)) break; if(level > 0) { @@ -418,8 +604,8 @@ ImBuf *imb_loadtiff(unsigned char *mem, int size, int flags) else hbuf= ibuf; - libtiff_TIFFGetField(image, TIFFTAG_TILEWIDTH, &hbuf->tilex); - libtiff_TIFFGetField(image, TIFFTAG_TILELENGTH, &hbuf->tiley); + TIFFGetField(image, TIFFTAG_TILEWIDTH, &hbuf->tilex); + TIFFGetField(image, TIFFTAG_TILELENGTH, &hbuf->tiley); hbuf->xtiles= ceil(hbuf->x/(float)hbuf->tilex); hbuf->ytiles= ceil(hbuf->y/(float)hbuf->tiley); @@ -434,12 +620,12 @@ ImBuf *imb_loadtiff(unsigned char *mem, int size, int flags) /* read pixels */ if(!(ibuf->flags & IB_tilecache) && !imb_read_tiff_pixels(ibuf, image, 0)) { fprintf(stderr, "imb_loadtiff: Failed to read tiff image.\n"); - libtiff_TIFFClose(image); + TIFFClose(image); return NULL; } /* close the client layer interface to the in-memory file */ - libtiff_TIFFClose(image); + TIFFClose(image); /* return successfully */ return ibuf; @@ -458,15 +644,15 @@ void imb_loadtiletiff(ImBuf *ibuf, unsigned char *mem, int size, int tx, int ty, return; } - if(libtiff_TIFFSetDirectory(image, ibuf->miplevel)) { + if(TIFFSetDirectory(image, ibuf->miplevel)) { /* allocate the image buffer */ - libtiff_TIFFGetField(image, TIFFTAG_IMAGEWIDTH, &width); - libtiff_TIFFGetField(image, TIFFTAG_IMAGELENGTH, &height); + TIFFGetField(image, TIFFTAG_IMAGEWIDTH, &width); + TIFFGetField(image, TIFFTAG_IMAGELENGTH, &height); if(width == ibuf->x && height == ibuf->y) { if(rect) { /* tiff pixels are bottom to top, tiles are top to bottom */ - if(libtiff_TIFFReadRGBATile(image, tx*ibuf->tilex, (ibuf->ytiles - 1 - ty)*ibuf->tiley, rect) == 1) { + if(TIFFReadRGBATile(image, tx*ibuf->tilex, (ibuf->ytiles - 1 - ty)*ibuf->tiley, rect) == 1) { if(ibuf->tiley > ibuf->y) memmove(rect, rect+ibuf->tilex*(ibuf->tiley - ibuf->y), sizeof(int)*ibuf->tilex*ibuf->y); @@ -484,7 +670,7 @@ void imb_loadtiletiff(ImBuf *ibuf, unsigned char *mem, int size, int tx, int ty, printf("imb_loadtiff: could not find mipmap level %d\n", ibuf->miplevel); /* close the client layer interface to the in-memory file */ - libtiff_TIFFClose(image); + TIFFClose(image); } /** @@ -515,10 +701,6 @@ int imb_savetiff(ImBuf *ibuf, char *name, int flags) int x, y, from_i, to_i, i; int extraSampleTypes[1] = { EXTRASAMPLE_ASSOCALPHA }; - if(!G.have_libtiff) { - fprintf(stderr, "imb_savetiff: no tiff library available.\n"); - return (0); - } /* check for a valid number of bytes per pixel. Like the PNG writer, * the TIFF writer supports 1, 3 or 4 bytes per pixel, corresponding @@ -546,7 +728,7 @@ int imb_savetiff(ImBuf *ibuf, char *name, int flags) } else { /* create image as a file */ - image = libtiff_TIFFOpen(name, "w"); + image = TIFFOpen(name, "w"); } if(image == NULL) { fprintf(stderr, @@ -557,16 +739,16 @@ int imb_savetiff(ImBuf *ibuf, char *name, int flags) /* allocate array for pixel data */ npixels = ibuf->x * ibuf->y; if(bitspersample == 16) - pixels16 = (unsigned short*)libtiff__TIFFmalloc(npixels * + pixels16 = (unsigned short*)_TIFFmalloc(npixels * samplesperpixel * sizeof(unsigned short)); else - pixels = (unsigned char*)libtiff__TIFFmalloc(npixels * + pixels = (unsigned char*)_TIFFmalloc(npixels * samplesperpixel * sizeof(unsigned char)); if(pixels == NULL && pixels16 == NULL) { fprintf(stderr, "imb_savetiff: could not allocate pixels array.\n"); - libtiff_TIFFClose(image); + TIFFClose(image); return (0); } @@ -581,24 +763,24 @@ int imb_savetiff(ImBuf *ibuf, char *name, int flags) } /* setup samples per pixel */ - libtiff_TIFFSetField(image, TIFFTAG_BITSPERSAMPLE, bitspersample); - libtiff_TIFFSetField(image, TIFFTAG_SAMPLESPERPIXEL, samplesperpixel); + TIFFSetField(image, TIFFTAG_BITSPERSAMPLE, bitspersample); + TIFFSetField(image, TIFFTAG_SAMPLESPERPIXEL, samplesperpixel); if(samplesperpixel == 4) { /* RGBA images */ - libtiff_TIFFSetField(image, TIFFTAG_EXTRASAMPLES, 1, + TIFFSetField(image, TIFFTAG_EXTRASAMPLES, 1, extraSampleTypes); - libtiff_TIFFSetField(image, TIFFTAG_PHOTOMETRIC, + TIFFSetField(image, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB); } else if(samplesperpixel == 3) { /* RGB images */ - libtiff_TIFFSetField(image, TIFFTAG_PHOTOMETRIC, + TIFFSetField(image, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB); } else if(samplesperpixel == 1) { /* greyscale images, 1 channel */ - libtiff_TIFFSetField(image, TIFFTAG_PHOTOMETRIC, + TIFFSetField(image, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK); } @@ -635,30 +817,31 @@ int imb_savetiff(ImBuf *ibuf, char *name, int flags) } /* write the actual TIFF file */ - libtiff_TIFFSetField(image, TIFFTAG_IMAGEWIDTH, ibuf->x); - libtiff_TIFFSetField(image, TIFFTAG_IMAGELENGTH, ibuf->y); - libtiff_TIFFSetField(image, TIFFTAG_ROWSPERSTRIP, ibuf->y); - libtiff_TIFFSetField(image, TIFFTAG_COMPRESSION, COMPRESSION_DEFLATE); - libtiff_TIFFSetField(image, TIFFTAG_FILLORDER, FILLORDER_MSB2LSB); - libtiff_TIFFSetField(image, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); - libtiff_TIFFSetField(image, TIFFTAG_XRESOLUTION, 150.0); - libtiff_TIFFSetField(image, TIFFTAG_YRESOLUTION, 150.0); - libtiff_TIFFSetField(image, TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH); - if(libtiff_TIFFWriteEncodedStrip(image, 0, + TIFFSetField(image, TIFFTAG_IMAGEWIDTH, ibuf->x); + TIFFSetField(image, TIFFTAG_IMAGELENGTH, ibuf->y); + TIFFSetField(image, TIFFTAG_ROWSPERSTRIP, ibuf->y); + TIFFSetField(image, TIFFTAG_COMPRESSION, COMPRESSION_DEFLATE); + TIFFSetField(image, TIFFTAG_FILLORDER, FILLORDER_MSB2LSB); + TIFFSetField(image, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); + TIFFSetField(image, TIFFTAG_XRESOLUTION, 150.0); + TIFFSetField(image, TIFFTAG_YRESOLUTION, 150.0); + TIFFSetField(image, TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH); + if(TIFFWriteEncodedStrip(image, 0, (bitspersample == 16)? (unsigned char*)pixels16: pixels, ibuf->x*ibuf->y*samplesperpixel*bitspersample/8) == -1) { fprintf(stderr, "imb_savetiff: Could not write encoded TIFF.\n"); - libtiff_TIFFClose(image); - if(pixels) libtiff__TIFFfree(pixels); - if(pixels16) libtiff__TIFFfree(pixels16); + TIFFClose(image); + if(pixels) _TIFFfree(pixels); + if(pixels16) _TIFFfree(pixels16); return (1); } /* close the TIFF file */ - libtiff_TIFFClose(image); - if(pixels) libtiff__TIFFfree(pixels); - if(pixels16) libtiff__TIFFfree(pixels16); + TIFFClose(image); + if(pixels) _TIFFfree(pixels); + if(pixels16) _TIFFfree(pixels16); return (1); } +#endif /* WITH_TIFF */
\ No newline at end of file diff --git a/source/blender/imbuf/intern/util.c b/source/blender/imbuf/intern/util.c index aff05b4eaff..e6f4e226caa 100644 --- a/source/blender/imbuf/intern/util.c +++ b/source/blender/imbuf/intern/util.c @@ -105,17 +105,19 @@ static int IMB_ispic_name(char *name) int IMB_ispic(char *filename) { if(U.uiflag & USER_FILTERFILEEXTS) { - if (G.have_libtiff && (BLI_testextensie(filename, ".tif") + if (BLI_testextensie(filename, ".tif") || BLI_testextensie(filename, ".tiff") - || BLI_testextensie(filename, ".tx"))) { + || BLI_testextensie(filename, ".tx")) { return IMB_ispic_name(filename); } if (G.have_quicktime){ if( BLI_testextensie(filename, ".jpg") || BLI_testextensie(filename, ".jpeg") +#ifdef WITH_TIFF || BLI_testextensie(filename, ".tif") || BLI_testextensie(filename, ".tiff") || BLI_testextensie(filename, ".tx") +#endif || BLI_testextensie(filename, ".hdr") || BLI_testextensie(filename, ".tga") || BLI_testextensie(filename, ".rgb") @@ -144,9 +146,14 @@ int IMB_ispic(char *filename) } else { return(FALSE); } - } else { /* no quicktime or libtiff */ + } else { /* no quicktime */ if( BLI_testextensie(filename, ".jpg") || BLI_testextensie(filename, ".jpeg") +#ifdef WITH_TIFF + || BLI_testextensie(filename, ".tif") + || BLI_testextensie(filename, ".tiff") + || BLI_testextensie(filename, ".tx") +#endif || BLI_testextensie(filename, ".hdr") || BLI_testextensie(filename, ".tga") || BLI_testextensie(filename, ".rgb") diff --git a/source/blender/makesrna/SConscript b/source/blender/makesrna/SConscript index 71cfc3c7da4..c4ee90dde16 100644 --- a/source/blender/makesrna/SConscript +++ b/source/blender/makesrna/SConscript @@ -15,6 +15,9 @@ defs = [] if env['WITH_BF_OPENEXR']: defs.append('WITH_OPENEXR') +if env['WITH_BF_TIFF']: + defs.append('WITH_TIFF') + if env['WITH_BF_OPENJPEG']: defs.append('WITH_OPENJPEG') diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt index 0e25160cdff..e9fc5c10f9e 100644 --- a/source/blender/makesrna/intern/CMakeLists.txt +++ b/source/blender/makesrna/intern/CMakeLists.txt @@ -58,6 +58,10 @@ IF(WITH_OPENEXR) ADD_DEFINITIONS(-DWITH_OPENEXR) ENDIF(WITH_OPENEXR) +IF(WITH_TIFF) + ADD_DEFINITIONS(-DWITH_TIFF) +ENDIF(WITH_TIFF) + IF(WITH_OPENJPEG) ADD_DEFINITIONS(-DWITH_OPENJPEG) ENDIF(WITH_OPENJPEG) diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 6a84846597b..a18c1021a8a 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -111,7 +111,9 @@ EnumPropertyItem image_type_items[] = { {R_OPENEXR, "OPEN_EXR", ICON_FILE_IMAGE, "OpenEXR", ""}, #endif {R_RADHDR, "HDR", ICON_FILE_IMAGE, "Radiance HDR", ""}, - {R_TIFF, "TIFF", ICON_FILE_IMAGE, "TIFF", ""}, // XXX only with G.have_libtiff +#ifdef WITH_TIFF + {R_TIFF, "TIFF", ICON_FILE_IMAGE, "TIFF", ""}, +#endif {0, "", 0, "Movie", NULL}, #ifdef _WIN32 {R_AVICODEC, "AVICODEC", ICON_FILE_MOVIE, "AVI Codec", ""}, // XXX Missing codec menu diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index 193217abc9d..d170e2374a8 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -61,6 +61,10 @@ IF(WITH_OPENEXR) ADD_DEFINITIONS(-DWITH_OPENEXR) ENDIF(WITH_OPENEXR) +IF(WITH_TIFF) + ADD_DEFINITIONS(-DWITH_TIFF) +ENDIF(WITH_TIFF) + IF(WITH_PYTHON) INCLUDE_DIRECTORIES(../blender/python) ELSE(WITH_PYTHON) @@ -280,7 +284,6 @@ IF(WITH_INSTALL) COMMAND copy /Y \"${WIN_LIBDIR}\\png\\lib\\libpng.dll\" \"${TARGETDIR}\\\" COMMAND copy /Y \"${WIN_LIBDIR}\\sdl\\lib\\SDL.dll\" \"${TARGETDIR}\\\" COMMAND copy /Y \"${WIN_LIBDIR}\\zlib\\lib\\zlib.dll\" \"${TARGETDIR}\\\" - COMMAND copy /Y \"${WIN_LIBDIR}\\tiff\\lib\\libtiff.dll\" \"${TARGETDIR}\\\" COMMAND copy /Y \"${WIN_LIBDIR}\\python\\lib\\python31.dll\" \"${TARGETDIR}\\\" COMMAND copy /Y \"${WIN_LIBDIR}\\python\\lib\\python31_d.dll\" \"${TARGETDIR}\\\" COMMAND copy /Y \"${WIN_LIBDIR}\\pthreads\\lib\\pthreadVC2.dll\" \"${TARGETDIR}\\\" diff --git a/source/creator/SConscript b/source/creator/SConscript index 6364f256cc5..815bd351f69 100644 --- a/source/creator/SConscript +++ b/source/creator/SConscript @@ -23,6 +23,9 @@ if env['WITH_BF_BINRELOC']: if env['WITH_BF_OPENEXR']: defs.append('WITH_OPENEXR') +if env['WITH_BF_TIFF']: + defs.append('WITH_TIFF') + if not env['WITH_BF_SDL']: defs.append('DISABLE_SDL') diff --git a/source/creator/creator.c b/source/creator/creator.c index 7544c3f8ff9..e3475e6ffe4 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -543,7 +543,9 @@ static int set_image_type(int argc, char **argv, void *data) else if (!strcmp(imtype,"QUICKTIME")) scene->r.imtype = R_QUICKTIME; else if (!strcmp(imtype,"BMP")) scene->r.imtype = R_BMP; else if (!strcmp(imtype,"HDR")) scene->r.imtype = R_RADHDR; +#ifdef WITH_TIFF else if (!strcmp(imtype,"TIFF")) scene->r.imtype = R_TIFF; +#endif #ifdef WITH_OPENEXR else if (!strcmp(imtype,"EXR")) scene->r.imtype = R_OPENEXR; else if (!strcmp(imtype,"MULTILAYER")) scene->r.imtype = R_MULTILAYER; diff --git a/tools/Blender.py b/tools/Blender.py index 441d454b782..69f6850fa52 100644 --- a/tools/Blender.py +++ b/tools/Blender.py @@ -146,6 +146,8 @@ def setup_staticlibs(lenv): libincs += Split(lenv['BF_OPENEXR_LIBPATH']) if lenv['WITH_BF_STATICOPENEXR']: statlibs += Split(lenv['BF_OPENEXR_LIB_STATIC']) + if lenv['WITH_BF_TIFF']: + libincs += Split(lenv['BF_TIFF_LIBPATH']) if lenv['WITH_BF_FFTW3']: libincs += Split(lenv['BF_FFTW3_LIBPATH']) if lenv['WITH_BF_INTERNATIONAL']: @@ -208,6 +210,8 @@ def setup_syslibs(lenv): if lenv['WITH_BF_OPENEXR']: if not lenv['WITH_BF_STATICOPENEXR']: syslibs += Split(lenv['BF_OPENEXR_LIB']) + if lenv['WITH_BF_TIFF']: + syslibs += Split(lenv['BF_TIFF_LIB']) if lenv['WITH_BF_FFMPEG']: syslibs += Split(lenv['BF_FFMPEG_LIB']) if lenv['WITH_BF_OGG']: diff --git a/tools/btools.py b/tools/btools.py index 4cb86ecee62..271fccff50c 100644 --- a/tools/btools.py +++ b/tools/btools.py @@ -42,7 +42,7 @@ def validate_arguments(args, bc): 'WITH_BF_OPENJPEG', 'BF_OPENJPEG', 'BF_OPENJPEG_INC', 'BF_OPENJPEG_LIB', 'BF_OPENJPEG_LIBPATH', 'WITH_BF_REDCODE', 'BF_REDCODE', 'BF_REDCODE_INC', 'BF_REDCODE_LIB', 'BF_REDCODE_LIBPATH', 'WITH_BF_PNG', 'BF_PNG', 'BF_PNG_INC', 'BF_PNG_LIB', 'BF_PNG_LIBPATH', - 'BF_TIFF', 'BF_TIFF_INC', 'BF_TIFF_LIB', 'BF_TIFF_LIBPATH', + 'WITH_BF_TIFF', 'BF_TIFF', 'BF_TIFF_INC', 'BF_TIFF_LIB', 'BF_TIFF_LIBPATH', 'WITH_BF_ZLIB', 'BF_ZLIB', 'BF_ZLIB_INC', 'BF_ZLIB_LIB', 'BF_ZLIB_LIBPATH', 'WITH_BF_INTERNATIONAL', 'BF_GETTEXT', 'BF_GETTEXT_INC', 'BF_GETTEXT_LIB', 'BF_GETTEXT_LIBPATH', @@ -261,6 +261,7 @@ def read_opts(cfg, args): ('BF_PNG_LIB', 'PNG library', ''), ('BF_PNG_LIBPATH', 'PNG library path', ''), + (BoolVariable('WITH_BF_TIFF', 'Use TIFF if true', True)), ('BF_TIFF', 'TIFF base path', ''), ('BF_TIFF_INC', 'TIFF include path', ''), ('BF_TIFF_LIB', 'TIFF library', ''), |