summaryrefslogtreecommitdiffstats
path: root/src/graphics/core
diff options
context:
space:
mode:
authorPiotr Dziwinski <piotrdz@gmail.com>2012-09-26 19:18:33 +0200
committerPiotr Dziwinski <piotrdz@gmail.com>2012-09-26 19:18:33 +0200
commit2fa4d7b0db88abcccbda287af10fc336a8dbb910 (patch)
treeda06fdca6da3b6b310139a8685d3662a5938f71d /src/graphics/core
parent00acce25d1dc050367c6b85a95dc6c0b4c9f0b18 (diff)
downloadcolobot-2fa4d7b0db88abcccbda287af10fc336a8dbb910.tar.gz
colobot-2fa4d7b0db88abcccbda287af10fc336a8dbb910.tar.bz2
colobot-2fa4d7b0db88abcccbda287af10fc336a8dbb910.zip
Refactored resource and relief loading
- now loading can be from any image format - added IntColor struct for precise pixel operations
Diffstat (limited to 'src/graphics/core')
-rw-r--r--src/graphics/core/color.h29
1 files changed, 29 insertions, 0 deletions
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
@@ -79,6 +79,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<unsigned char>(color.r * 255.0f),
+ static_cast<unsigned char>(color.g * 255.0f),
+ static_cast<unsigned char>(color.b * 255.0f),
+ static_cast<unsigned char>(color.a * 255.0f));
+}
+
+/**
* \struct ColorHSV
* \brief HSV color
*/