Fixing brightness and Mask effects to calculate factor with a float type, giving more fine control

This commit is contained in:
Jonathan Thomas
2017-11-14 00:15:42 -06:00
parent 67d355d215
commit 7490aaa3e4
2 changed files with 2 additions and 2 deletions

View File

@@ -91,7 +91,7 @@ std::shared_ptr<Frame> Brightness::GetFrame(std::shared_ptr<Frame> frame, int64_
int A = pixels[byte_index + 3];
// Adjust the contrast
int factor = (259 * (contrast_value + 255)) / (255 * (259 - contrast_value));
float factor = (259 * (contrast_value + 255)) / (255 * (259 - contrast_value));
R = constrain((factor * (R - 128)) + 128);
G = constrain((factor * (G - 128)) + 128);
B = constrain((factor * (B - 128)) + 128);

View File

@@ -88,7 +88,7 @@ void Mask::set_grayscale_mask(std::shared_ptr<QImage> mask_frame_image, int widt
int gray_value = qGray(R, G, B);
// Adjust the contrast
int factor = (259 * (contrast + 255)) / (255 * (259 - contrast));
float factor = (259 * (contrast + 255)) / (255 * (259 - contrast));
gray_value = constrain((factor * (gray_value - 128)) + 128);
// Adjust the brightness