diff options
author | Quentin Wenger <matpi@protonmail.ch> | 2016-01-14 13:02:13 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-01-14 13:33:46 +0300 |
commit | 370a8ee7417f37bbedf814582d9f14e855da0c3e (patch) | |
tree | 6419c5126e0d3b62b1ffc3fa7443a2a9eadfb372 /source/blender/imbuf/intern/tiff.c | |
parent | 1f273cec00feddb1065847e3c8163cdcf8a6d89a (diff) |
Add compression modes for TIFF images
This patch aims at providing multiple compression modes for TIFF output,
particularly uncompressed mode.
At this moment have None, Deflate, LZW and Pack Bits modes been integrated,
mimicking The GIMP export modes (except JPEG mode, which returned encoding
errors).
More modes could be added if needed.
Default remains Deflate.
Reviewers: campbellbarton, mont29, sergey
Differential Revision: https://developer.blender.org/D1709
Diffstat (limited to 'source/blender/imbuf/intern/tiff.c')
-rw-r--r-- | source/blender/imbuf/intern/tiff.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/source/blender/imbuf/intern/tiff.c b/source/blender/imbuf/intern/tiff.c index 1c501f8f592..4368a428186 100644 --- a/source/blender/imbuf/intern/tiff.c +++ b/source/blender/imbuf/intern/tiff.c @@ -708,6 +708,7 @@ int imb_savetiff(ImBuf *ibuf, const char *name, int flags) float *fromf = NULL; float xres, yres; int x, y, from_i, to_i, i; + int compress_mode = COMPRESSION_NONE; /* 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 @@ -725,6 +726,13 @@ int imb_savetiff(ImBuf *ibuf, const char *name, int flags) else bitspersample = 8; + if (ibuf->foptions.flag & TIF_COMPRESS_DEFLATE) + compress_mode = COMPRESSION_DEFLATE; + else if (ibuf->foptions.flag & TIF_COMPRESS_LZW) + compress_mode = COMPRESSION_LZW; + else if (ibuf->foptions.flag & TIF_COMPRESS_PACKBITS) + compress_mode = COMPRESSION_PACKBITS; + /* open TIFF file for writing */ if (flags & IB_mem) { /* bork at the creation of a TIFF in memory */ @@ -839,7 +847,7 @@ int imb_savetiff(ImBuf *ibuf, const char *name, int flags) 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_COMPRESSION, compress_mode); TIFFSetField(image, TIFFTAG_FILLORDER, FILLORDER_MSB2LSB); TIFFSetField(image, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); |