Rgba2Hex add

This commit is contained in:
Hehongyuanlove
2020-04-17 12:31:07 +08:00
committed by GitHub
parent 4314fc0521
commit 3154cec79c

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