From 80a89d2de50e46d65940864d18ced946eec29ba7 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Tue, 1 Jun 2010 01:01:25 +0000 Subject: * Only print libtiff debug messages to the console when in debug mode * Allow loading non 3/4 channel TIFFs (eg. greyscale). This was already working, but disabled out of caution. Seems to work fine in my recent tests though. --- source/blender/imbuf/intern/IMB_filetype.h | 1 + source/blender/imbuf/intern/filetype.c | 5 +---- source/blender/imbuf/intern/tiff.c | 16 +++++++++------- 3 files changed, 11 insertions(+), 11 deletions(-) (limited to 'source') diff --git a/source/blender/imbuf/intern/IMB_filetype.h b/source/blender/imbuf/intern/IMB_filetype.h index f6afe20cb5c..9fd4108bee9 100644 --- a/source/blender/imbuf/intern/IMB_filetype.h +++ b/source/blender/imbuf/intern/IMB_filetype.h @@ -109,6 +109,7 @@ struct ImBuf *imb_loadhdr(unsigned char *mem, int size, int flags); int imb_savehdr(struct ImBuf * ibuf, char *name, int flags); /* tiff */ +void imb_inittiff(void); int imb_is_a_tiff(unsigned char *buf); struct ImBuf *imb_loadtiff(unsigned char *mem, int size, int flags); void imb_loadtiletiff(struct ImBuf *ibuf, unsigned char *mem, int size, diff --git a/source/blender/imbuf/intern/filetype.c b/source/blender/imbuf/intern/filetype.c index a0ff4476556..c2140e12013 100644 --- a/source/blender/imbuf/intern/filetype.c +++ b/source/blender/imbuf/intern/filetype.c @@ -54,9 +54,6 @@ void quicktime_init(void); void quicktime_exit(void); #endif -void libtiff_init(void); -void libtiff_exit(void); - ImFileType IMB_FILE_TYPES[]= { {NULL, NULL, imb_is_a_iris, imb_ftype_iris, imb_loadiris, imb_saveiris, NULL, 0, IMAGIC}, {NULL, NULL, imb_is_a_jpeg, imb_ftype_default, imb_load_jpeg, imb_savejpeg, NULL, 0, JPG}, @@ -66,7 +63,7 @@ ImFileType IMB_FILE_TYPES[]= { {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}, #ifdef WITH_TIFF - {NULL, NULL, imb_is_a_tiff, imb_ftype_default, imb_loadtiff, imb_savetiff, imb_loadtiletiff, 0, TIF}, + {imb_inittiff, 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}, #endif diff --git a/source/blender/imbuf/intern/tiff.c b/source/blender/imbuf/intern/tiff.c index 488340aec88..99f74fea640 100644 --- a/source/blender/imbuf/intern/tiff.c +++ b/source/blender/imbuf/intern/tiff.c @@ -356,6 +356,7 @@ static void scanline_separate_32bit(float *rectf, float *fbuf, int scanline_w, i } +#if 0 /* * Use the libTIFF RGBAImage API to read a TIFF image. * This function uses the "RGBA Image" support from libtiff, which enables @@ -387,6 +388,7 @@ static int imb_read_tiff_pixels_rgba(ImBuf *ibuf, TIFF *image, int premul) return success; } +#endif /* * Use the libTIFF scanline API to read a TIFF image. @@ -409,12 +411,6 @@ static int imb_read_tiff_pixels(ImBuf *ibuf, TIFF *image, int premul) 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); @@ -427,7 +423,7 @@ static int imb_read_tiff_pixels(ImBuf *ibuf, TIFF *image, int premul) } 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++) { @@ -512,6 +508,12 @@ static int imb_read_tiff_pixels(ImBuf *ibuf, TIFF *image, int premul) return success; } +void imb_inittiff(void) +{ + if (!(G.f & G_DEBUG)) + TIFFSetErrorHandler(NULL); +} + /** * Loads a TIFF file. * -- cgit v1.2.3