From 2fa4d7b0db88abcccbda287af10fc336a8dbb910 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Wed, 26 Sep 2012 19:18:33 +0200 Subject: Refactored resource and relief loading - now loading can be from any image format - added IntColor struct for precise pixel operations --- src/graphics/core/color.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/graphics/core') diff --git a/src/graphics/core/color.h b/src/graphics/core/color.h index 4b152c1..0bec7e9 100644 --- a/src/graphics/core/color.h +++ b/src/graphics/core/color.h @@ -78,6 +78,35 @@ struct Color } }; +/** + * \struct IntColor + * \brief Color with integer values + * + * May be used for precise pixel manipulations. + */ +struct IntColor +{ + //! Red, green, blue and alpha components + unsigned char r, g, b, a; + + //! Constructor; default values are (0,0,0,0) = black + explicit IntColor(unsigned char aR = 0, unsigned char aG = 0, unsigned char aB = 0, unsigned char aA = 0) + : r(aR), g(aG), b(aB), a(aA) {} +}; + +inline Color IntColorToColor(IntColor color) +{ + return Color(color.r / 255.0f, color.g / 255.0f, color.b / 255.0f, color.a / 255.0f); +} + +inline IntColor ColorToIntColor(Color color) +{ + return IntColor(static_cast(color.r * 255.0f), + static_cast(color.g * 255.0f), + static_cast(color.b * 255.0f), + static_cast(color.a * 255.0f)); +} + /** * \struct ColorHSV * \brief HSV color -- cgit v1.2.3-1-g7c22