From 14e9689e4cc01d8faf143b13f61319c749dc5aa5 Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Sun, 25 Jun 2023 02:03:20 +0100 Subject: [PATCH] sdl_bilinear_scale.cpp: Fix `MixColorsWithAlpha` comment The previous comment was incorrect and had a typo in the formula. --- Source/utils/sdl_bilinear_scale.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/utils/sdl_bilinear_scale.cpp b/Source/utils/sdl_bilinear_scale.cpp index 078a65d16..9d9b1a2f7 100644 --- a/Source/utils/sdl_bilinear_scale.cpp +++ b/Source/utils/sdl_bilinear_scale.cpp @@ -56,9 +56,9 @@ uint8_t MixColorsWithAlpha(uint8_t first, uint8_t firstAlpha, // To avoid the overflow we divide each term by `mixedAlpha` separately. // // This would be lower precision and could result in a negative overall result, - // so we do the rounding integer division for each term (instead of a truncating one): + // so we do the rounding-up integer division for each term (instead of a truncating one): // - // (a + (a - 1)) / b` + // (a + (b - 1)) / b return ToInt((secondWithAlpha - firstWithAlpha) * ((ratio + (mixedAlpha - 1)) / mixedAlpha)) + (firstWithAlpha + (mixedAlpha - 1)) / mixedAlpha; }