diff --git a/common/gal/color4d.cpp b/common/gal/color4d.cpp index b7653f3ccb..d4abcf5c01 100644 --- a/common/gal/color4d.cpp +++ b/common/gal/color4d.cpp @@ -79,6 +79,20 @@ COLOR4D::COLOR4D( EDA_COLOR_T aColor ) } + wxColour COLOR4D::ToColour() const + { + using CHAN_T = wxColourBase::ChannelType; + + const wxColour colour( + static_cast<CHAN_T>( r * 255 + 0.5 ), + static_cast<CHAN_T>( g * 255 + 0.5 ), + static_cast<CHAN_T>( b * 255 + 0.5 ), + static_cast<CHAN_T>( a * 255 + 0.5 ) + ); + return colour; + } + + COLOR4D COLOR4D::LegacyMix( COLOR4D aColor ) const { COLOR4D candidate; diff --git a/include/gal/color4d.h b/include/gal/color4d.h index c5ff3ccc5c..a5bf00c865 100644 --- a/include/gal/color4d.h +++ b/include/gal/color4d.h @@ -89,11 +89,7 @@ public: wxString ToWxString( long flags ) const; - wxColour ToColour() const - { - wxColour colour( r * 255, g * 255, b * 255, a * 255 ); - return colour; - } + wxColour ToColour() const; /** * Function LegacyMix() diff --git a/qa/common/test_color4d.cpp b/qa/common/test_color4d.cpp index 940fb0ad1d..9d9354c4a2 100644 --- a/qa/common/test_color4d.cpp +++ b/qa/common/test_color4d.cpp @@ -247,12 +247,11 @@ static std::vector<WX_CONV_CASE> wx_conv_cases = { { { 0xFF, 0x00, 0x00, 0xFF }, { 0.999, 0.001, 0.0, 1.0 } }, }; -#ifdef HAVE_EXPECTED_FAILURES /** * Check conversion to WxColour */ -BOOST_AUTO_TEST_CASE( ToWx, *boost::unit_test::expected_failures( 3 ) ) +BOOST_AUTO_TEST_CASE( ToWx ) { for( const auto& c : wx_conv_cases ) { @@ -266,8 +265,6 @@ BOOST_AUTO_TEST_CASE( ToWx, *boost::unit_test::expected_failures( 3 ) ) } } -#endif // HAVE_EXPECTED_FAILURES - /** * Check conversion from WxColour