From 0fee1a3c0b125321ed5acb880958864ac043c88e Mon Sep 17 00:00:00 2001 From: Gaia Clary Date: Fri, 17 Aug 2012 23:29:39 +0000 Subject: [PATCH] Suport function for Collada exporter: after a generated image was stored to disk, the new filetype was not always recognized. --- source/blender/blenkernel/intern/image.c | 47 +++++++++++++----------- source/blender/imbuf/IMB_imbuf_types.h | 4 +- 2 files changed, 28 insertions(+), 23 deletions(-) diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 5f6fedc553c..d84c20f7a94 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -1212,43 +1212,46 @@ void BKE_imformat_defaults(ImageFormatData *im_format) void BKE_imbuf_to_image_format(struct ImageFormatData *im_format, const ImBuf *imbuf) { + int ftype = imbuf->ftype & ~IB_CUSTOM_FLAGS_MASK; + int custom_flags = imbuf->ftype & IB_CUSTOM_FLAGS_MASK; + BKE_imformat_defaults(im_format); /* file type */ - if (imbuf->ftype == IMAGIC) + if (ftype == IMAGIC) im_format->imtype = R_IMF_IMTYPE_IRIS; #ifdef WITH_HDR - else if (imbuf->ftype == RADHDR) + else if (ftype == RADHDR) im_format->imtype = R_IMF_IMTYPE_RADHDR; #endif - else if (imbuf->ftype == PNG) + else if (ftype == PNG) im_format->imtype = R_IMF_IMTYPE_PNG; #ifdef WITH_DDS - else if (imbuf->ftype == DDS) + else if (ftype == DDS) im_format->imtype = R_IMF_IMTYPE_DDS; #endif - else if (imbuf->ftype == BMP) + else if (ftype == BMP) im_format->imtype = R_IMF_IMTYPE_BMP; #ifdef WITH_TIFF - else if (imbuf->ftype & TIF) { + else if (ftype == TIF) { im_format->imtype = R_IMF_IMTYPE_TIFF; - if (imbuf->ftype & TIF_16BIT) + if (custom_flags & TIF_16BIT) im_format->depth = R_IMF_CHAN_DEPTH_16; } #endif #ifdef WITH_OPENEXR - else if (imbuf->ftype & OPENEXR) { + else if (ftype == OPENEXR) { im_format->imtype = R_IMF_IMTYPE_OPENEXR; - if (imbuf->ftype & OPENEXR_HALF) + if (custom_flags & OPENEXR_HALF) im_format->depth = R_IMF_CHAN_DEPTH_16; - if (imbuf->ftype & OPENEXR_COMPRESS) + if (custom_flags & OPENEXR_COMPRESS) im_format->exr_codec = R_IMF_EXR_CODEC_ZIP; // Can't determine compression if (imbuf->zbuf_float) im_format->flag |= R_IMF_FLAG_ZBUF; @@ -1256,35 +1259,35 @@ void BKE_imbuf_to_image_format(struct ImageFormatData *im_format, const ImBuf *i #endif #ifdef WITH_CINEON - else if (imbuf->ftype == CINEON) + else if (ftype == CINEON) im_format->imtype = R_IMF_IMTYPE_CINEON; - else if (imbuf->ftype == DPX) + else if (ftype == DPX) im_format->imtype = R_IMF_IMTYPE_DPX; #endif - else if (imbuf->ftype == TGA) { + else if (ftype == TGA) { im_format->imtype = R_IMF_IMTYPE_TARGA; } - else if (imbuf->ftype == RAWTGA) { + else if (ftype == RAWTGA) { im_format->imtype = R_IMF_IMTYPE_RAWTGA; } #ifdef WITH_OPENJPEG - else if (imbuf->ftype & JP2) { + else if (ftype & JP2) { im_format->imtype = R_IMF_IMTYPE_JP2; - im_format->quality = imbuf->ftype & ~JPG_MSK; + im_format->quality = custom_flags & ~JPG_MSK; - if (imbuf->ftype & JP2_16BIT) + if (ftype & JP2_16BIT) im_format->depth = R_IMF_CHAN_DEPTH_16; - else if (imbuf->ftype & JP2_12BIT) + else if (ftype & JP2_12BIT) im_format->depth = R_IMF_CHAN_DEPTH_12; - if (imbuf->ftype & JP2_YCC) + if (ftype & JP2_YCC) im_format->jp2_flag |= R_IMF_JP2_FLAG_YCC; - if (imbuf->ftype & JP2_CINE) { + if (ftype & JP2_CINE) { im_format->jp2_flag |= R_IMF_JP2_FLAG_CINE_PRESET; - if (imbuf->ftype & JP2_CINE_48FPS) + if (ftype & JP2_CINE_48FPS) im_format->jp2_flag |= R_IMF_JP2_FLAG_CINE_48; } } @@ -1292,7 +1295,7 @@ void BKE_imbuf_to_image_format(struct ImageFormatData *im_format, const ImBuf *i else { im_format->imtype = R_IMF_IMTYPE_JPEG90; - im_format->quality = imbuf->ftype & ~JPG_MSK; + im_format->quality = custom_flags & ~JPG_MSK; } /* planes */ diff --git a/source/blender/imbuf/IMB_imbuf_types.h b/source/blender/imbuf/IMB_imbuf_types.h index dcb5cdd7d32..be93d51d7d7 100644 --- a/source/blender/imbuf/IMB_imbuf_types.h +++ b/source/blender/imbuf/IMB_imbuf_types.h @@ -165,8 +165,10 @@ typedef struct ImBuf { /* * The bit flag is stored in the ImBuf.ftype variable. - * Note that the lower 10 bits is used for storing custom flags + * Note that the lower 10 bits is used for storing custom flags */ +#define IB_CUSTOM_FLAGS_MASK 0x3ff + #define PNG (1 << 30) #define TGA (1 << 28) #define JPG (1 << 27)