added GetRGB/GetBGR in Color.h/.cpp

This commit is contained in:
HuYingzhuo(hugo/hyzboy) 2023-09-15 20:16:19 +08:00
parent c78733216f
commit 2e14c54ca4
2 changed files with 30 additions and 0 deletions

View File

@ -3,6 +3,7 @@
#include<hgl/TypeFunc.h> #include<hgl/TypeFunc.h>
#include<hgl/color/Color4f.h> #include<hgl/color/Color4f.h>
#include<hgl/math/Vector.h>
namespace hgl namespace hgl
{ {
/** /**
@ -261,6 +262,9 @@ namespace hgl
ENUM_CLASS_RANGE(AliceBlue,YellowGreen) ENUM_CLASS_RANGE(AliceBlue,YellowGreen)
};//enum COLOR_ENUM };//enum COLOR_ENUM
bool GetRGB(const enum class COLOR &ce,Vector3u8 &);
bool GetBGR(const enum class COLOR &ce,Vector3u8 &);
const uint32 GetRGBA(const enum class COLOR &ce,const uint8 &alpha); const uint32 GetRGBA(const enum class COLOR &ce,const uint8 &alpha);
const uint32 GetABGR(const enum class COLOR &ce,const uint8 &alpha); const uint32 GetABGR(const enum class COLOR &ce,const uint8 &alpha);

View File

@ -302,6 +302,32 @@ namespace hgl
#undef DEF_COLOR #undef DEF_COLOR
bool GetRGB(const enum class COLOR &ce,Vector3u8 &color)
{
RANGE_CHECK_RETURN_FALSE(ce);
const COLOR_DEF &c=prv_color[size_t(ce)];
color.r=c.red;
color.g=c.green;
color.b=c.blue;
return(true);
}
bool GetBGR(const enum class COLOR &ce,Vector3u8 &color)
{
RANGE_CHECK_RETURN_FALSE(ce);
const COLOR_DEF &c=prv_color[size_t(ce)];
color.b=c.red;
color.g=c.green;
color.r=c.blue;
return(true);
}
const uint32 GetRGBA(const enum class COLOR &ce,const uint8 &alpha) const uint32 GetRGBA(const enum class COLOR &ce,const uint8 &alpha)
{ {
const COLOR_DEF &c=prv_color[size_t(ce)]; const COLOR_DEF &c=prv_color[size_t(ce)];