From fc7575b60ea5bc10ebab5209ba6db662b6a30a61 Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Fri, 18 Nov 2022 00:32:48 -0600 Subject: [PATCH] Implementing a fix for mask contrast proposed by GitHub user xotmatrix --- src/effects/Mask.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/effects/Mask.cpp b/src/effects/Mask.cpp index 2ad1987a..8cd71cee 100644 --- a/src/effects/Mask.cpp +++ b/src/effects/Mask.cpp @@ -114,11 +114,8 @@ std::shared_ptr Mask::GetFrame(std::shared_ptr gray_value += (255 * brightness_value); // Adjust the contrast - float factor = (259 * (contrast_value + 255)) / (255 * (259 - contrast_value)); - gray_value = constrain((factor * (gray_value - 128)) + 128); - - // Constrain the value from 0 to 255 - gray_value = constrain(gray_value); + float factor = (20 / (20 - contrast_value)); + gray_value = (factor * (gray_value - 128) + 128); // Calculate the % change in alpha float alpha_percent = float(constrain(A - gray_value)) / 255.0;