From 1db908d5cc67eb06b7e88ba2c6359b73d35eb262 Mon Sep 17 00:00:00 2001 From: jules Date: Mon, 6 Jan 2014 11:52:42 +0000 Subject: [PATCH] Accuracy tweak to float->int conversions in the Colour class. --- modules/juce_graphics/colour/juce_Colour.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/juce_graphics/colour/juce_Colour.cpp b/modules/juce_graphics/colour/juce_Colour.cpp index d2095ccbea..575e7dfc5b 100644 --- a/modules/juce_graphics/colour/juce_Colour.cpp +++ b/modules/juce_graphics/colour/juce_Colour.cpp @@ -26,7 +26,8 @@ namespace ColourHelpers { static uint8 floatToUInt8 (const float n) noexcept { - return n <= 0.0f ? 0 : (n >= 1.0f ? 255 : (uint8) (n * 255.0f)); + // the multiplier has a small extra amount to allow for FP rounding errors. + return n <= 0.0f ? 0 : (n >= 1.0f ? 255 : (uint8) (n * 255.1f)); } // This is an adjusted brightness value, based on the way the human