summaryrefslogtreecommitdiffstats
path: root/gui/pages.cpp
diff options
context:
space:
mode:
authorDees_Troy <dees_troy@teamw.in>2012-10-20 02:48:59 +0200
committerDees_Troy <dees_troy@teamw.in>2012-10-20 02:51:12 +0200
commit30b962eb5184490c10cd9f44cd161e4b93403b37 (patch)
treefdc5a138600233d2bc69a7edf04b13b0f7edcf20 /gui/pages.cpp
parentAdd ability for buttons to have highlights on touch (diff)
downloadandroid_bootable_recovery-30b962eb5184490c10cd9f44cd161e4b93403b37.tar
android_bootable_recovery-30b962eb5184490c10cd9f44cd161e4b93403b37.tar.gz
android_bootable_recovery-30b962eb5184490c10cd9f44cd161e4b93403b37.tar.bz2
android_bootable_recovery-30b962eb5184490c10cd9f44cd161e4b93403b37.tar.lz
android_bootable_recovery-30b962eb5184490c10cd9f44cd161e4b93403b37.tar.xz
android_bootable_recovery-30b962eb5184490c10cd9f44cd161e4b93403b37.tar.zst
android_bootable_recovery-30b962eb5184490c10cd9f44cd161e4b93403b37.zip
Diffstat (limited to 'gui/pages.cpp')
-rw-r--r--gui/pages.cpp29
1 files changed, 18 insertions, 11 deletions
diff --git a/gui/pages.cpp b/gui/pages.cpp
index 7e9274def..c4a65b43a 100644
--- a/gui/pages.cpp
+++ b/gui/pages.cpp
@@ -54,17 +54,24 @@ int ConvertStrToColor(std::string str, COLOR* color)
if (str[0] != '#') return -1;
str.erase(0, 1);
- int result = strtol(str.c_str(), NULL, 16);
- if (str.size() > 6)
- {
- // We have alpha channel
- color->alpha = result & 0x000000FF;
- result = result >> 8;
- }
- color->red = (result >> 16) & 0x000000FF;
- color->green = (result >> 8) & 0x000000FF;
- color->blue = result & 0x000000FF;
- return 0;
+ int result;
+ if (str.size() >= 8) {
+ // We have alpha channel
+ string alpha = str.substr(6, 2);
+ result = strtol(alpha.c_str(), NULL, 16);
+ color->alpha = result & 0x000000FF;
+ str.resize(6);
+ result = strtol(str.c_str(), NULL, 16);
+ color->red = (result >> 16) & 0x000000FF;
+ color->green = (result >> 8) & 0x000000FF;
+ color->blue = result & 0x000000FF;
+ } else {
+ result = strtol(str.c_str(), NULL, 16);
+ color->red = (result >> 16) & 0x000000FF;
+ color->green = (result >> 8) & 0x000000FF;
+ color->blue = result & 0x000000FF;
+ }
+ return 0;
}
// Helper APIs