From c1ead4a59ead03738610f3285d076bcb3abdd214 Mon Sep 17 00:00:00 2001 From: Neil Date: Thu, 13 Apr 2023 09:21:59 +1000 Subject: Use & instead of cast to avoid warning in header. Use named constant for mask that chooses RGB part. --- src/Geometry.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Geometry.h b/src/Geometry.h index 4e4fe95d9..f417caae0 100644 --- a/src/Geometry.h +++ b/src/Geometry.h @@ -172,6 +172,7 @@ PRectangle PixelAlignOutside(const PRectangle &rc, int pixelDivisions) noexcept; */ constexpr const float componentMaximum = 255.0f; class ColourRGBA { + static constexpr int rgbMask = 0xffffff; int co; public: constexpr explicit ColourRGBA(int co_ = 0) noexcept : co(co_) { @@ -190,11 +191,11 @@ public: } static constexpr ColourRGBA FromIpRGB(intptr_t co_) noexcept { - return ColourRGBA(static_cast(co_) | (0xffu << 24)); + return ColourRGBA((co_ & rgbMask) | (0xffu << 24)); } constexpr ColourRGBA WithoutAlpha() const noexcept { - return ColourRGBA(co & 0xffffff); + return ColourRGBA(co & rgbMask); } constexpr ColourRGBA Opaque() const noexcept { @@ -206,7 +207,7 @@ public: } constexpr int OpaqueRGB() const noexcept { - return co & 0xffffff; + return co & rgbMask; } // Red, green and blue values as bytes 0..255 -- cgit v1.2.3