Rgba2Hex add

pull/3158/head
Hehongyuanlove 2020-04-17 12:31:07 +08:00 committed by GitHub
parent 4314fc0521
commit 3154cec79c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 0 deletions

View File

@ -145,4 +145,22 @@ std::string DecimalToHexa( T toConvert ) {
return result;
}
/// @fn Rgba2Hex
/// @brief translate RGBA to String
/// @param r aiColor.r
/// @param g aiColor.g
/// @param b aiColor.b
/// @param a aiColor.a
/// @param with_head #
/// @return The hexadecimal string, is empty in case of an error.
AI_FORCE_INLINE
std::string Rgba2Hex(int r, int g, int b, int a, bool with_head)
{
std::stringstream ss;
if (with_head)
ss << "#";
ss << std::hex << (r << 24 | g << 16 | b << 8 | a);
return ss.str();
}
#endif // INCLUDED_AI_STRINGUTILS_H