diff options
author | Brecht Van Lommel <brecht@blender.org> | 2022-10-03 20:33:46 +0300 |
---|---|---|
committer | Brecht Van Lommel <brecht@blender.org> | 2022-10-03 22:59:31 +0300 |
commit | e2572bd89f145233092d56302972a241cb429b49 (patch) | |
tree | 3e679410011a0fc17639a03e72245f93135264f2 /source/blender/blenkernel/intern/image_save.cc | |
parent | 42f40657f143f4f8f0c473daf8d54bab6d7c303e (diff) |
Fix OpenEXR saving still outputting alpha when using RGB instead of RGBA mode
Contributed by linhsu0723.
Differential Revision: https://developer.blender.org/D15979
Diffstat (limited to 'source/blender/blenkernel/intern/image_save.cc')
-rw-r--r-- | source/blender/blenkernel/intern/image_save.cc | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/source/blender/blenkernel/intern/image_save.cc b/source/blender/blenkernel/intern/image_save.cc index 41a5f88f677..f145f5db624 100644 --- a/source/blender/blenkernel/intern/image_save.cc +++ b/source/blender/blenkernel/intern/image_save.cc @@ -724,6 +724,7 @@ bool BKE_image_render_write_exr(ReportList *reports, const bool half_float = (imf && imf->depth == R_IMF_CHAN_DEPTH_16); const bool multi_layer = !(imf && imf->imtype == R_IMF_IMTYPE_OPENEXR); const bool write_z = !multi_layer && (imf && (imf->flag & R_IMF_FLAG_ZBUF)); + const int channels = (!multi_layer && imf && imf->planes == R_IMF_PLANES_RGB) ? 3 : 4; Vector<float *> tmp_output_rects; /* Write first layer if not multilayer and no layer was specified. */ @@ -767,9 +768,10 @@ bool BKE_image_render_write_exr(ReportList *reports, rview->rectf, rr->rectx, rr->recty, 4, imf, tmp_output_rects) : rview->rectf; - for (int a = 0; a < 4; a++) { + for (int a = 0; a < channels; a++) { char passname[EXR_PASS_MAXNAME]; char layname[EXR_PASS_MAXNAME]; + /* "A" is not used if only "RGB" channels are output. */ const char *chan_id = "RGBA"; if (multi_layer) { @@ -832,8 +834,8 @@ bool BKE_image_render_write_exr(ReportList *reports, rp->rect, rr->rectx, rr->recty, rp->channels, imf, tmp_output_rects) : rp->rect; - for (int a = 0; a < rp->channels; a++) { - /* Save Combined as RGBA if single layer save. */ + for (int a = 0; a < std::min(channels, rp->channels); a++) { + /* Save Combined as RGBA or RGB if single layer save. */ char passname[EXR_PASS_MAXNAME]; char layname[EXR_PASS_MAXNAME]; |