aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/FbTk/Color.cc16
-rw-r--r--src/FbTk/Color.hh1
2 files changed, 3 insertions, 14 deletions
diff --git a/src/FbTk/Color.cc b/src/FbTk/Color.cc
index b2d61ec..ea3f04e 100644
--- a/src/FbTk/Color.cc
+++ b/src/FbTk/Color.cc
@@ -31,14 +31,6 @@ using std::cerr;
31using std::endl; 31using std::endl;
32using std::string; 32using std::string;
33 33
34namespace {
35
36inline unsigned char maxValue(unsigned short colval) {
37 return colval == 65535 ? 0xFF : static_cast<unsigned char>(colval/0xFF);
38}
39
40}
41
42namespace FbTk { 34namespace FbTk {
43 35
44Color::Color(): 36Color::Color():
@@ -96,9 +88,7 @@ bool Color::setFromString(const char *color_string, int screen) {
96 return false; 88 return false;
97 89
98 setPixel(color.pixel); 90 setPixel(color.pixel);
99 setRGB(maxValue(color.red), 91 setRGB(color.red / 256, color.green / 256, color.blue / 256);
100 maxValue(color.green),
101 maxValue(color.blue));
102 setAllocated(true); 92 setAllocated(true);
103 m_screen = screen; 93 m_screen = screen;
104 94
@@ -168,9 +158,7 @@ void Color::allocate(unsigned short red, unsigned short green, unsigned short bl
168 cerr<<"FbTk::Color: "<<_FBTK_CONSOLETEXT(Error, ColorAllocation, "Allocation error.", "XAllocColor failed...")<<endl; 158 cerr<<"FbTk::Color: "<<_FBTK_CONSOLETEXT(Error, ColorAllocation, "Allocation error.", "XAllocColor failed...")<<endl;
169 } else { 159 } else {
170 free(); 160 free();
171 setRGB(maxValue(color.red), 161 setRGB(color.red / 256, color.green / 256, color.blue / 256);
172 maxValue(color.green),
173 maxValue(color.blue));
174 setPixel(color.pixel); 162 setPixel(color.pixel);
175 setAllocated(true); 163 setAllocated(true);
176 } 164 }
diff --git a/src/FbTk/Color.hh b/src/FbTk/Color.hh
index 588fcc1..151390e 100644
--- a/src/FbTk/Color.hh
+++ b/src/FbTk/Color.hh
@@ -63,6 +63,7 @@ private:
63 void setRGB(unsigned short red, unsigned short green, unsigned short blue); 63 void setRGB(unsigned short red, unsigned short green, unsigned short blue);
64 64
65 65
66 // stored in [0 - 255] range
66 unsigned short m_red, m_green, m_blue; 67 unsigned short m_red, m_green, m_blue;
67 unsigned long m_pixel; 68 unsigned long m_pixel;
68 bool m_allocated; 69 bool m_allocated;