diff --git a/packages/react-native/ReactCommon/react/renderer/graphics/Color.cpp b/packages/react-native/ReactCommon/react/renderer/graphics/Color.cpp index b1e9c9cc791825..94c9ad2c9b2ed6 100644 --- a/packages/react-native/ReactCommon/react/renderer/graphics/Color.cpp +++ b/packages/react-native/ReactCommon/react/renderer/graphics/Color.cpp @@ -28,23 +28,23 @@ ColorComponents colorComponentsFromColor(SharedColor sharedColor) { } // Read alpha channel in [0, 255] range -float alphaFromColor(SharedColor color) { - return alphaFromHostPlatformColor(*color); +uint8_t alphaFromColor(SharedColor color) { + return static_cast(std::round(alphaFromHostPlatformColor(*color))); } // Read red channel in [0, 255] range -float redFromColor(SharedColor color) { - return redFromHostPlatformColor(*color); +uint8_t redFromColor(SharedColor color) { + return static_cast(std::round(redFromHostPlatformColor(*color))); } // Read green channel in [0, 255] range -float greenFromColor(SharedColor color) { - return greenFromHostPlatformColor(*color); +uint8_t greenFromColor(SharedColor color) { + return static_cast(std::round(greenFromHostPlatformColor(*color))); } // Read blue channel in [0, 255] range -float blueFromColor(SharedColor color) { - return blueFromHostPlatformColor(*color); +uint8_t blueFromColor(SharedColor color) { + return static_cast(std::round(blueFromHostPlatformColor(*color))); } // Create Color with RGBA values in [0, 255] range diff --git a/packages/react-native/ReactCommon/react/renderer/graphics/Color.h b/packages/react-native/ReactCommon/react/renderer/graphics/Color.h index c63dacae164047..3ef5627fd5789b 100644 --- a/packages/react-native/ReactCommon/react/renderer/graphics/Color.h +++ b/packages/react-native/ReactCommon/react/renderer/graphics/Color.h @@ -57,10 +57,10 @@ bool isColorMeaningful(const SharedColor& color) noexcept; SharedColor colorFromComponents(ColorComponents components); ColorComponents colorComponentsFromColor(SharedColor color); -float alphaFromColor(SharedColor color); -float redFromColor(SharedColor color); -float greenFromColor(SharedColor color); -float blueFromColor(SharedColor color); +uint8_t alphaFromColor(SharedColor color); +uint8_t redFromColor(SharedColor color); +uint8_t greenFromColor(SharedColor color); +uint8_t blueFromColor(SharedColor color); SharedColor colorFromRGBA(uint8_t r, uint8_t g, uint8_t b, uint8_t a); SharedColor clearColor();