c++ - How To change the background color of a container using the Hex format? -
i'm developing blackberry 10 mobile application using momentics ide (native sdk).
i want change background color of container using c++. unfortunately, relating [link], can define below :
**creating color in c++:** color c1 = color::fromrgba(0.5f, 1.0f, 0.2f, 0.8f); color c2 = color::fromargb(0xff996633);
for color, want use hex format ("#xxxxxx"). 1 can guide me on ?
color c2 = color::fromargb(0xff996633);
using hex 0x c++ representation of hex code
. ff component, 99 r, 66 g , 33 b
so if want use hex value #000099 no alpha
then
color::fromargb(0x00000099)
the following code convert string hex value, need remove # string before hand however, , can pass string buffer object
#include <iostream> #include <sstream> int main() { std::string hexstring("#ffffff"); hexstring.erase(hexstring.begin()); std::istringstream buffer(hexstring); int value; buffer >> std::hex >> value; std::cout << std::hex << value; return 0; }
Comments
Post a Comment