261 if (!colorname.empty() && colorname[0] ==
'#')
263 std::string hexcode = colorname.substr(1);
267 for (
size_t i = 0; i < hexcode.length(); i++) {
269 if (!((c >=
'0' && c <=
'9') || (c >=
'A' && c <=
'F') || (c >=
'a' && c <=
'f'))) {
275 if (valid && (hexcode.length() == 3 || hexcode.length() == 6 || hexcode.length() == 8))
277 int r = 0, g = 0, b = 0, a = 255;
279 if (hexcode.length() == 3) {
281 r = std::stoi(hexcode.substr(0, 1),
nullptr, 16) * 17;
282 g = std::stoi(hexcode.substr(1, 1),
nullptr, 16) * 17;
283 b = std::stoi(hexcode.substr(2, 1),
nullptr, 16) * 17;
285 else if (hexcode.length() == 6) {
287 r = std::stoi(hexcode.substr(0, 2),
nullptr, 16);
288 g = std::stoi(hexcode.substr(2, 2),
nullptr, 16);
289 b = std::stoi(hexcode.substr(4, 2),
nullptr, 16);
291 else if (hexcode.length() == 8) {
293 r = std::stoi(hexcode.substr(0, 2),
nullptr, 16);
294 g = std::stoi(hexcode.substr(2, 2),
nullptr, 16);
295 b = std::stoi(hexcode.substr(4, 2),
nullptr, 16);
296 a = std::stoi(hexcode.substr(6, 2),
nullptr, 16);
299 mRed = To8BitColor(r);
300 mGreen = To8BitColor(g);
301 mBlue = To8BitColor(b);
302 mAlpha = To8BitColor(a);
315 int mid = (top + bottom)/2;
335 while(((top - bottom) > 1) && (foundindex == -1) && !sep1)
339 mid = (top + bottom)/2;
342 if((top - bottom) == 1) sep1 =
true;