1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Accuracy tweak to float->int conversions in the Colour class.

This commit is contained in:
jules 2014-01-06 11:52:42 +00:00
parent 42bff200ed
commit 1db908d5cc

View file

@ -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