Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef GNASH_RGBA_H
00022 #define GNASH_RGBA_H
00023
00024 #include <string>
00025 #include <boost/cstdint.hpp>
00026
00027 #include "dsodefs.h"
00028 #include "SWF.h"
00029
00030 namespace gnash {
00031
00033
00036 class DSOEXPORT rgba
00037 {
00038 public:
00039
00041
00043 rgba()
00044 :
00045 m_r(255),
00046 m_g(255),
00047 m_b(255),
00048 m_a(255)
00049 {}
00050
00052
00057 rgba(boost::uint8_t r, boost::uint8_t g, boost::uint8_t b,
00058 boost::uint8_t a)
00059 :
00060 m_r(r),
00061 m_g(g),
00062 m_b(b),
00063 m_a(a)
00064 {
00065 }
00066
00068
00074 void parseRGB(boost::uint32_t rgbCol) {
00075 m_r = static_cast<boost::uint8_t>(rgbCol >> 16);
00076 m_g = static_cast<boost::uint8_t>(rgbCol >> 8);
00077 m_b = static_cast<boost::uint8_t>(rgbCol);
00078 }
00079
00081
00087 boost::uint32_t toRGB() const {
00088 return (m_r << 16) + (m_g << 8) + m_b;
00089 }
00090
00092
00097 boost::uint32_t toRGBA() const {
00098 return toRGB() + (m_a << 24);
00099 }
00100
00101 friend std::ostream& operator<<(std::ostream& os, const rgba& r);
00102
00103 bool operator==(const rgba& o) const {
00104 return m_r == o.m_r &&
00105 m_g == o.m_g &&
00106 m_b == o.m_b &&
00107 m_a == o.m_a;
00108 }
00109
00110 bool operator!=(const rgba& o) const {
00111 return !(*this == o);
00112 }
00113
00114 boost::uint8_t m_r, m_g, m_b, m_a;
00115
00116 };
00117
00118 std::ostream& operator<<(std::ostream& os, const rgba& r);
00119
00121
00125 rgba colorFromHexString(const std::string& color);
00126
00128 rgba lerp(const rgba& a, const rgba& b, float f);
00129
00130 }
00131
00132 #endif
00133
00134
00135
00136
00137
00138