Added color mode parameter to ostd::Color::asInteger()
This commit is contained in:
parent
f92b90ae9a
commit
a622db4b1a
4 changed files with 20 additions and 8 deletions
|
|
@ -87,7 +87,7 @@ if (UNIX)
|
|||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath='$ORIGIN'")
|
||||
target_link_libraries(${OMNIA_STD_LIB} PUBLIC tinfo boost_regex)
|
||||
target_link_libraries(${OMNIA_GFX_LIB} PUBLIC xcb xcb-randr)
|
||||
endif (UNIX)
|
||||
endif (UNIX)
|
||||
target_link_libraries(${OMNIA_GFX_LIB} PUBLIC SDL2main SDL2 SDL2_gfx SDL2_ttf)
|
||||
target_link_libraries(${OMNIA_STD_LIB} PUBLIC ssl crypto)
|
||||
#-----------------------------------------------------------------------------------------
|
||||
|
|
|
|||
2
build.nr
2
build.nr
|
|
@ -1 +1 @@
|
|||
1879
|
||||
1880
|
||||
|
|
|
|||
|
|
@ -181,16 +181,26 @@ namespace ostd
|
|||
return rgb;
|
||||
}
|
||||
|
||||
uint32_t Color::asInteger(void) const
|
||||
uint32_t Color::asInteger(eColorFormat format) const
|
||||
{
|
||||
union uC32 {
|
||||
uint8_t data[4];
|
||||
uint32_t value;
|
||||
} c32_u;
|
||||
c32_u.data[0] = a;
|
||||
c32_u.data[1] = b;
|
||||
c32_u.data[2] = g;
|
||||
c32_u.data[3] = r;
|
||||
if (format == eColorFormat::RGBA)
|
||||
{
|
||||
c32_u.data[0] = a;
|
||||
c32_u.data[1] = b;
|
||||
c32_u.data[2] = g;
|
||||
c32_u.data[3] = r;
|
||||
}
|
||||
else if (format == eColorFormat::ARGB)
|
||||
{
|
||||
c32_u.data[0] = r;
|
||||
c32_u.data[1] = g;
|
||||
c32_u.data[2] = b;
|
||||
c32_u.data[3] = a;
|
||||
}
|
||||
return c32_u.value;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ namespace ostd
|
|||
FloatCol(float _r, float _g, float _b, float _a) : r(_r), g(_g), b(_b), a(_a) { }
|
||||
};
|
||||
|
||||
public: enum class eColorFormat { RGBA = 0, ARGB };
|
||||
|
||||
public:
|
||||
Color(void);
|
||||
Color(uint8_t rgb_single_value, uint8_t alpha = 255);
|
||||
|
|
@ -41,7 +43,7 @@ namespace ostd
|
|||
|
||||
String hexString(bool include_alpha = false, String prefix = "0x") const;
|
||||
String rgbString(bool include_parenthesis = true, bool include_alpha = false) const;
|
||||
uint32_t asInteger(void) const;
|
||||
uint32_t asInteger(eColorFormat format = eColorFormat::RGBA) const;
|
||||
FloatCol getNormalizedColor(void) const;
|
||||
|
||||
String toString(void) const override;
|
||||
|
|
|
|||
Loading…
Reference in a new issue