From e5a135e0b26d7a268e7507ffb1be2f2fcc1b0b9c Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 19 Feb 2013 08:37:08 +0000 Subject: Fixes for alpha mode do_versions code Before this change only old flag "Premultiply" was used to detect alpha mode, which is not enough actually. Now the logic here is: - If "Premultiply" was enabled it is likely float image with straight alpha, which shall be premultiplied before usage. In this case image/sequence Alpha Mode is set to Straight. - Otherwise use default alpha mode for image format based on an extension. This could fail in some cases like TIFF, but this wasn't handled fully correct in older blender anyway. Initial discovered issue was that EXR images saved in older Blender versions were set to Straight alpha mode, which is obviously a straight way to lots of headache. --- source/blender/blenkernel/intern/sequencer.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'source/blender/blenkernel/intern/sequencer.c') diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 45393726add..68618287546 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -3955,6 +3955,24 @@ Sequence *BKE_sequence_alloc(ListBase *lb, int cfra, int machine) return seq; } +void BKE_sequence_alpha_mode_from_extension(Sequence *seq) +{ + if (seq->strip && seq->strip->stripdata) { + char *name = seq->strip->stripdata->name; + + if (BLI_testextensie(name, ".exr") || + BLI_testextensie(name, ".cin") || + BLI_testextensie(name, ".dpx") || + BLI_testextensie(name, ".hdr")) + { + seq->alpha_mode = IMA_ALPHA_PREMUL; + } + else { + seq->alpha_mode = IMA_ALPHA_STRAIGHT; + } + } +} + void BKE_sequence_init_colorspace(Sequence *seq) { if (seq->strip && seq->strip->stripdata) { -- cgit v1.2.3