Date: | 2014-07-17 19:27:39 (9 years 8 months ago) |
---|---|
Author: | Maarten ter Huurne |
Commit: | 5f454a856991737da96de872c7fc68589e99e930 |
Message: | Made strtorgba into a factory method of RGBAColor The method is RGBAColor::fromString. |
Files: |
src/gmenu2x.cpp (1 diff) src/surface.cpp (1 diff) src/surface.h (1 diff) |
Change Details
src/gmenu2x.cpp | ||
---|---|---|
830 | 830 | if (value.length()>1 && value.at(0)=='"' && value.at(value.length()-1)=='"') |
831 | 831 | skinConfStr[name] = value.substr(1,value.length()-2); |
832 | 832 | else if (value.at(0) == '#') |
833 | skinConfColors[stringToColor(name)] = strtorgba( value.substr(1,value.length()) ); | |
833 | skinConfColors[stringToColor(name)] = | |
834 | RGBAColor::fromString(value.substr(1, value.length())); | |
834 | 835 | else |
835 | 836 | skinConfInt[name] = atoi(value.c_str()); |
836 | 837 | } |
src/surface.cpp | ||
---|---|---|
31 | 31 | |
32 | 32 | using namespace std; |
33 | 33 | |
34 | RGBAColor strtorgba(const string &strColor) { | |
35 | RGBAColor c = {0,0,0,255}; | |
36 | c.r = constrain( strtol( strColor.substr(0,2).c_str(), NULL, 16 ), 0, 255 ); | |
37 | c.g = constrain( strtol( strColor.substr(2,2).c_str(), NULL, 16 ), 0, 255 ); | |
38 | c.b = constrain( strtol( strColor.substr(4,2).c_str(), NULL, 16 ), 0, 255 ); | |
39 | c.a = constrain( strtol( strColor.substr(6,2).c_str(), NULL, 16 ), 0, 255 ); | |
40 | return c; | |
34 | RGBAColor RGBAColor::fromString(const string &strColor) { | |
35 | return { | |
36 | uint8_t(constrain(strtol(strColor.substr(0, 2).c_str(), nullptr, 16), | |
37 | 0, 255)), | |
38 | uint8_t(constrain(strtol(strColor.substr(2, 2).c_str(), nullptr, 16), | |
39 | 0, 255)), | |
40 | uint8_t(constrain(strtol(strColor.substr(4, 2).c_str(), nullptr, 16), | |
41 | 0, 255)), | |
42 | uint8_t(constrain(strtol(strColor.substr(6, 2).c_str(), nullptr, 16), | |
43 | 0, 255)), | |
44 | }; | |
41 | 45 | } |
42 | 46 | |
43 | 47 | Surface *Surface::openOutputSurface(int width, int height, int bitsperpixel) { |
src/surface.h | ||
---|---|---|
29 | 29 | |
30 | 30 | struct RGBAColor { |
31 | 31 | uint8_t r, g, b, a; |
32 | static RGBAColor fromString(std::string const& strColor); | |
32 | 33 | }; |
33 | 34 | |
34 | RGBAColor strtorgba(const std::string &strColor); | |
35 | ||
36 | 35 | /** |
37 | 36 | Wrapper around SDL_Surface |
38 | 37 | @author Massimiliano Torromeo <massimiliano.torromeo@gmail.com> |
Branches:
install_locations
master
opkrun
packages