diff --git a/src/effects/Brightness.cpp b/src/effects/Brightness.cpp index 8b2ddc87..58340fff 100644 --- a/src/effects/Brightness.cpp +++ b/src/effects/Brightness.cpp @@ -63,16 +63,29 @@ std::shared_ptr Brightness::GetFrame(std::shared_ptr Hue::GetFrame(std::shared_ptr #pragma omp parallel for shared (pixels) for (int pixel = 0; pixel < pixel_count; ++pixel) { - // Get the RGB values from the pixel (ignore the alpha channel) - int R = pixels[pixel * 4]; - int G = pixels[pixel * 4 + 1]; - int B = pixels[pixel * 4 + 2]; + // Calculate alpha % (to be used for removing pre-multiplied alpha value) + int A = pixels[pixel * 4 + 3]; + float alpha_percent = A / 255.0; + + // Get RGB values, and remove pre-multiplied alpha + int R = pixels[pixel * 4 + 0] / alpha_percent; + int G = pixels[pixel * 4 + 1] / alpha_percent; + int B = pixels[pixel * 4 + 2] / alpha_percent; // Multiply each color by the hue rotation matrix pixels[pixel * 4] = constrain(R * matrix[0] + G * matrix[1] + B * matrix[2]); pixels[pixel * 4 + 1] = constrain(R * matrix[2] + G * matrix[0] + B * matrix[1]); pixels[pixel * 4 + 2] = constrain(R * matrix[1] + G * matrix[2] + B * matrix[0]); + + // Pre-multiply the alpha back into the color channels + pixels[pixel * 4 + 0] *= alpha_percent; + pixels[pixel * 4 + 1] *= alpha_percent; + pixels[pixel * 4 + 2] *= alpha_percent; } // return the modified frame diff --git a/src/effects/Saturation.cpp b/src/effects/Saturation.cpp index f242ee14..6733deec 100644 --- a/src/effects/Saturation.cpp +++ b/src/effects/Saturation.cpp @@ -72,10 +72,14 @@ std::shared_ptr Saturation::GetFrame(std::shared_ptr Saturation::GetFrame(std::shared_ptr Saturation::GetFrame(std::shared_ptr