Color4 ToUnsignedA8R8G8B8 function

This commit is contained in:
alemuntoni 2021-03-31 11:10:14 +02:00
parent 895f8b0d03
commit 4c719ae5d0
1 changed files with 12 additions and 0 deletions

View File

@ -261,6 +261,7 @@ inline static Color4 ColorRamp(const float &minf,const float &maxf ,float v )
inline static unsigned short ToUnsignedB5G5R5(const Color4 &) { return 0;} inline static unsigned short ToUnsignedB5G5R5(const Color4 &) { return 0;}
inline static unsigned short ToUnsignedR5G5B5(const Color4 &) { return 0;} inline static unsigned short ToUnsignedR5G5B5(const Color4 &) { return 0;}
inline static unsigned int ToUnsignedA8R8G8B8(const Color4 &) { return 0;}
inline static Color4 FromUnsignedB5G5R5(unsigned short) inline static Color4 FromUnsignedB5G5R5(unsigned short)
{ {
@ -439,6 +440,17 @@ inline unsigned short Color4<unsigned char>::ToUnsignedR5G5B5(const Color4<unsig
return res; return res;
} }
template<>
inline unsigned int Color4<unsigned char>::ToUnsignedA8R8G8B8(const Color4<unsigned char> &cc)
{
unsigned int r = cc[0];
unsigned int g = cc[1];
unsigned int b = cc[2];
unsigned int a = cc[3];
unsigned int res = (r << 16) | (g << 8) | (b) | (a << 24);
return res;
}
template<> template<>
inline Color4<unsigned char> Color4<unsigned char>::FromUnsignedR5G5B5(unsigned short val) inline Color4<unsigned char> Color4<unsigned char>::FromUnsignedR5G5B5(unsigned short val)