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 "SWF.h"
00025
00026 #include <string>
00027 #include <boost/cstdint.hpp>
00028
00029 namespace gnash {
00030 class SWFStream;
00031 }
00032
00033 namespace gnash {
00034
00036
00039 class rgba
00040 {
00041 public:
00042
00044
00046 rgba()
00047 :
00048 m_r(255),
00049 m_g(255),
00050 m_b(255),
00051 m_a(255)
00052 {}
00053
00055
00060 rgba(boost::uint8_t r, boost::uint8_t g, boost::uint8_t b,
00061 boost::uint8_t a)
00062 :
00063 m_r(r),
00064 m_g(g),
00065 m_b(b),
00066 m_a(a)
00067 {
00068 }
00069
00071
00077 void parseRGB(boost::uint32_t rgbCol) {
00078 m_r = static_cast<boost::uint8_t>(rgbCol >> 16);
00079 m_g = static_cast<boost::uint8_t>(rgbCol >> 8);
00080 m_b = static_cast<boost::uint8_t>(rgbCol);
00081 }
00082
00084
00090 boost::uint32_t toRGB() const {
00091 return (m_r << 16) + (m_g << 8) + m_b;
00092 }
00093
00095
00100 boost::uint32_t toRGBA() const {
00101 return toRGB() + (m_a << 24);
00102 }
00103
00105 void set(boost::uint8_t r, boost::uint8_t g, boost::uint8_t b,
00106 boost::uint8_t a) {
00107 m_r = r;
00108 m_g = g;
00109 m_b = b;
00110 m_a = a;
00111 }
00112
00114 void set_lerp(const rgba& a, const rgba& b, float f);
00115
00117 std::string toShortString() const;
00118
00119 friend std::ostream& operator<< (std::ostream& os, const rgba& r);
00120
00121 bool operator==(const rgba& o) const {
00122 return m_r == o.m_r &&
00123 m_g == o.m_g &&
00124 m_b == o.m_b &&
00125 m_a == o.m_a;
00126 }
00127
00128 bool operator!=(const rgba& o) const {
00129 return !(*this == o);
00130 }
00131
00132 boost::uint8_t m_r, m_g, m_b, m_a;
00133
00134 };
00135
00136 std::ostream& operator<< (std::ostream& os, const rgba& r);
00137
00139
00142 rgba readRGBA(SWFStream& in);
00143
00145 rgba readRGB(SWFStream& in);
00146
00148
00152 rgba colorFromHexString(const std::string& color);
00153
00154
00155 }
00156
00157 #endif
00158
00159
00160
00161
00162
00163