Browse Source

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

tags/2021-05-28
jules 11 years ago
parent
commit
1db908d5cc
1 changed files with 2 additions and 1 deletions
  1. +2
    -1
      modules/juce_graphics/colour/juce_Colour.cpp

+ 2
- 1
modules/juce_graphics/colour/juce_Colour.cpp 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


Loading…
Cancel
Save