You've already forked libopenshot
mirror of
https://github.com/OpenShot/libopenshot.git
synced 2026-03-02 08:53:52 -08:00
Fixing brightness and Mask effects to calculate factor with a float type, giving more fine control
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user