Fixing regression with mask effect caused by contrast being adjusted after we modulate the brightness (sort error)

This commit is contained in:
Jonathan Thomas
2022-11-18 00:24:43 -06:00
parent 7617e9165e
commit 553dcc64e1

View File

@@ -110,13 +110,13 @@ std::shared_ptr<openshot::Frame> Mask::GetFrame(std::shared_ptr<openshot::Frame>
// Get the average luminosity
int gray_value = qGray(R, G, B);
// Adjust the brightness
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);
// Adjust the brightness
gray_value += (255 * brightness_value);
// Constrain the value from 0 to 255
gray_value = constrain(gray_value);