diff options
-rw-r--r-- | source/blender/blenkernel/intern/image.c | 23 | ||||
-rw-r--r-- | source/blender/editors/space_image/image_buttons.c | 4 | ||||
-rw-r--r-- | source/blender/imbuf/IMB_imbuf_types.h | 6 | ||||
-rw-r--r-- | source/blender/imbuf/intern/tiff.c | 10 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_scene_types.h | 13 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_scene.c | 19 |
6 files changed, 71 insertions, 4 deletions
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 55cbf13ed34..95cf1ba987c 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -1623,6 +1623,14 @@ void BKE_imbuf_to_image_format(struct ImageFormatData *im_format, const ImBuf *i im_format->imtype = R_IMF_IMTYPE_TIFF; if (custom_flags & TIF_16BIT) im_format->depth = R_IMF_CHAN_DEPTH_16; + if (custom_flags & TIF_COMPRESS_NONE) + im_format->tiff_codec = R_IMF_TIFF_CODEC_NONE; + if (custom_flags & TIF_COMPRESS_DEFLATE) + im_format->tiff_codec = R_IMF_TIFF_CODEC_DEFLATE; + if (custom_flags & TIF_COMPRESS_LZW) + im_format->tiff_codec = R_IMF_TIFF_CODEC_LZW; + if (custom_flags & TIF_COMPRESS_PACKBITS) + im_format->tiff_codec = R_IMF_TIFF_CODEC_PACKBITS; } #endif @@ -2208,8 +2216,21 @@ void BKE_imbuf_write_prepare(ImBuf *ibuf, const ImageFormatData *imf) else if (imtype == R_IMF_IMTYPE_TIFF) { ibuf->ftype = IMB_FTYPE_TIF; - if (imf->depth == R_IMF_CHAN_DEPTH_16) + if (imf->depth == R_IMF_CHAN_DEPTH_16) { ibuf->foptions.flag |= TIF_16BIT; + } + if (imf->tiff_codec == R_IMF_TIFF_CODEC_NONE) { + ibuf->foptions.flag |= TIF_COMPRESS_NONE; + } + else if (imf->tiff_codec== R_IMF_TIFF_CODEC_DEFLATE) { + ibuf->foptions.flag |= TIF_COMPRESS_DEFLATE; + } + else if (imf->tiff_codec == R_IMF_TIFF_CODEC_LZW) { + ibuf->foptions.flag |= TIF_COMPRESS_LZW; + } + else if (imf->tiff_codec == R_IMF_TIFF_CODEC_PACKBITS) { + ibuf->foptions.flag |= TIF_COMPRESS_PACKBITS; + } } #endif #ifdef WITH_OPENEXR diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index ffd801d2146..4c124db359e 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -1126,6 +1126,10 @@ void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr, int color_man #endif } + if (imf->imtype == R_IMF_IMTYPE_TIFF) { + uiItemR(col, imfptr, "tiff_codec", 0, NULL, ICON_NONE); + } + /* color management */ if (color_management && (!BKE_imtype_requires_linear_float(imf->imtype) || diff --git a/source/blender/imbuf/IMB_imbuf_types.h b/source/blender/imbuf/IMB_imbuf_types.h index e9dcf2da723..0af203c9535 100644 --- a/source/blender/imbuf/IMB_imbuf_types.h +++ b/source/blender/imbuf/IMB_imbuf_types.h @@ -127,7 +127,11 @@ enum eImbTypes { #define RAWTGA 1 #ifdef WITH_TIFF -#define TIF_16BIT (1 << 8 ) +#define TIF_16BIT (1 << 8) +#define TIF_COMPRESS_NONE (1 << 7) +#define TIF_COMPRESS_DEFLATE (1 << 6) +#define TIF_COMPRESS_LZW (1 << 5) +#define TIF_COMPRESS_PACKBITS (1 << 4) #endif typedef struct ImbFormatOptions { 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); diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 42418f87bbd..f0b55e8b9be 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -355,7 +355,10 @@ typedef struct ImageFormatData { char jp2_flag; char jp2_codec; - char pad[5]; + /* TIFF */ + char tiff_codec; + + char pad[4]; /* Multiview */ char views_format; @@ -442,6 +445,14 @@ typedef struct ImageFormatData { /* ImageFormatData.cineon_flag */ #define R_IMF_CINEON_FLAG_LOG (1<<0) /* was R_CINEON_LOG */ +/* ImageFormatData.tiff_codec */ +enum { + R_IMF_TIFF_CODEC_DEFLATE = 0, + R_IMF_TIFF_CODEC_LZW = 1, + R_IMF_TIFF_CODEC_PACKBITS = 2, + R_IMF_TIFF_CODEC_NONE = 3, +}; + typedef struct BakeData { struct ImageFormatData im_format; diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index a0ff429a7e2..f7f6204113f 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -4580,6 +4580,16 @@ static void rna_def_scene_image_format_data(BlenderRNA *brna) }; #endif +#ifdef WITH_TIFF + static EnumPropertyItem tiff_codec_items[] = { + {R_IMF_TIFF_CODEC_NONE, "NONE", 0, "None", ""}, + {R_IMF_TIFF_CODEC_DEFLATE, "DEFLATE", 0, "Deflate", ""}, + {R_IMF_TIFF_CODEC_LZW, "LZW", 0, "LZW", ""}, + {R_IMF_TIFF_CODEC_PACKBITS, "PACKBITS", 0, "Pack Bits", ""}, + {0, NULL, 0, NULL, NULL} + }; +#endif + StructRNA *srna; PropertyRNA *prop; @@ -4679,6 +4689,15 @@ static void rna_def_scene_image_format_data(BlenderRNA *brna) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); #endif +#ifdef WITH_TIFF + /* TIFF */ + prop = RNA_def_property(srna, "tiff_codec", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "tiff_codec"); + RNA_def_property_enum_items(prop, tiff_codec_items); + RNA_def_property_ui_text(prop, "Compression", "Compression mode for TIFF"); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); +#endif + /* Cineon and DPX */ prop = RNA_def_property(srna, "use_cineon_log", PROP_BOOLEAN, PROP_NONE); |