Quellcode durchsuchen

added to_ABGR32() to core/Color

toger5 vor 8 Jahren
Ursprung
Commit
426c6b2c49
2 geänderte Dateien mit 14 neuen und 2 gelöschten Zeilen
  1. 12 0
      core/color.cpp
  2. 2 2
      core/color.h

+ 12 - 0
core/color.cpp

@@ -47,6 +47,18 @@ uint32_t Color::to_ARGB32() const {
 	return c;
 }
 
+uint32_t Color::to_ABGR32() const {
+	uint32_t c = (uint8_t)(a * 255);
+	c <<= 8;
+	c |= (uint8_t)(b * 255);
+	c <<= 8;
+	c |= (uint8_t)(g * 255);
+	c <<= 8;
+	c |= (uint8_t)(r * 255);
+
+	return c;
+}
+
 uint32_t Color::to_32() const {
 
 	uint32_t c = (uint8_t)(a * 255);

+ 2 - 2
core/color.h

@@ -53,6 +53,7 @@ struct Color {
 
 	uint32_t to_32() const;
 	uint32_t to_ARGB32() const;
+	uint32_t to_ABGR32() const;
 	float gray() const;
 	float get_h() const;
 	float get_s() const;
@@ -148,8 +149,7 @@ struct Color {
 				b < 0.0031308 ? 12.92 * b : (1.0 + 0.055) * Math::pow(b, 1.0f / 2.4f) - 0.055, a);
 	}
 
-	static Color
-	hex(uint32_t p_hex);
+	static Color hex(uint32_t p_hex);
 	static Color html(const String &p_color);
 	static bool html_is_valid(const String &p_color);
 	static Color named(const String &p_name);