From 6da48b933aa7edc56f4e8749174617df9c97e5a9 Mon Sep 17 00:00:00 2001 From: Lawrence Lee <45837045+Lawrence37@users.noreply.github.com> Date: Fri, 5 Jul 2024 22:21:46 -0700 Subject: [PATCH] Handle masked area black level with LibRaw Copied from ART commit 9a24f2567a452f0ca788f51e88b92b479002b149. --- rtengine/rawimage.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/rtengine/rawimage.cc b/rtengine/rawimage.cc index 53914694a..02f6e42c5 100644 --- a/rtengine/rawimage.cc +++ b/rtengine/rawimage.cc @@ -839,6 +839,13 @@ int RawImage::loadRaw(bool loadData, unsigned int imageNum, bool closeFile, Prog profile_data = new char[profile_length]; memcpy(profile_data, libraw->imgdata.color.profile, profile_length); } + + if (isBayer() && RT_blacklevel_from_constant == ThreeValBool::T && max(black, cblack[0], cblack[1], cblack[2], cblack[3]) == 0) { + auto &black_stat = libraw->imgdata.color.black_stat; + for (int i = 0; i < 4; ++i) { + cblack[i] = black_stat[i] / (1+black_stat[i+4]); + } + } } if (!float_raw_image) { // apply baseline exposure only for float DNGs