diff --git a/CMakeLists.txt b/CMakeLists.txt index f195277..1fb2dbd 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) #----------------------------------------------------------------------------------------- diff --git a/build.nr b/build.nr index ad9032d..d4ece87 100644 --- a/build.nr +++ b/build.nr @@ -1 +1 @@ -1879 +1880 diff --git a/src/ostd/Color.cpp b/src/ostd/Color.cpp index 5f16a91..f10a125 100755 --- a/src/ostd/Color.cpp +++ b/src/ostd/Color.cpp @@ -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; } diff --git a/src/ostd/Color.hpp b/src/ostd/Color.hpp index 0015795..d3de6d8 100755 --- a/src/ostd/Color.hpp +++ b/src/ostd/Color.hpp @@ -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;