32-bit color support

This commit is contained in:
elasota
2020-06-13 04:33:41 -04:00
parent 24f43b973a
commit 4920781619
42 changed files with 1161 additions and 450 deletions

View File

@@ -10,7 +10,9 @@ namespace PortabilityLayer
bool operator==(const RGBAColor &other) const;
bool operator!=(const RGBAColor &other) const;
static RGBAColor Create(uint8_t r, uint8_t g, uint8_t b, uint8_t a);
static RGBAColor Create(uint8_t r, uint8_t g, uint8_t b, uint8_t a);
uint32_t AsUInt32() const;
};
inline RGBAColor RGBAColor::Create(uint8_t r, uint8_t g, uint8_t b, uint8_t a)
@@ -32,5 +34,16 @@ namespace PortabilityLayer
inline bool RGBAColor::operator!=(const RGBAColor &other) const
{
return !((*this) == other);
}
}
inline uint32_t RGBAColor::AsUInt32() const
{
uint32_t rgbaColor = 0;
uint8_t *rgbaColorBytes = reinterpret_cast<uint8_t*>(&rgbaColor);
rgbaColorBytes[0] = r;
rgbaColorBytes[1] = g;
rgbaColorBytes[2] = b;
rgbaColorBytes[3] = a;
return rgbaColor;
}
}