FIX: support alpha color in 3DScene

Change-Id: Id6e6346b8ddb77a911ff5d56331d9088ca41017e
This commit is contained in:
chunmao.guo 2023-05-16 17:52:16 +08:00 committed by Lane.Wei
parent 149b1112fc
commit 2b5f8082be
4 changed files with 31 additions and 27 deletions

View file

@ -444,5 +444,21 @@ bool BitmapCache::parse_color(const std::string& scolor, unsigned char* rgb_out)
return true;
}
bool BitmapCache::parse_color4(const std::string& scolor, unsigned char* rgba_out)
{
rgba_out[0] = rgba_out[1] = rgba_out[2] = 0; rgba_out[3] = 255;
if ((scolor.size() != 7 && scolor.size() != 9) || scolor.front() != '#')
return false;
const char* c = scolor.data() + 1;
for (size_t i = 0; i < scolor.size() / 2; ++i) {
int digit1 = hex_digit_to_int(*c++);
int digit2 = hex_digit_to_int(*c++);
if (digit1 == -1 || digit2 == -1)
return false;
rgba_out[i] = (unsigned char)(digit1 * 16 + digit2);
}
return true;
}
} // namespace GUI
} // namespace Slic3r