mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2024-12-12 11:14:14 +01:00
Merge pull request #1379 from lioncash/color
color: Make trivial helpers constexpr
This commit is contained in:
commit
3ab6d77c20
@ -11,42 +11,42 @@
|
|||||||
namespace Color {
|
namespace Color {
|
||||||
|
|
||||||
/// Convert a 1-bit color component to 8 bit
|
/// Convert a 1-bit color component to 8 bit
|
||||||
inline u8 Convert1To8(u8 value) {
|
constexpr u8 Convert1To8(u8 value) {
|
||||||
return value * 255;
|
return value * 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convert a 4-bit color component to 8 bit
|
/// Convert a 4-bit color component to 8 bit
|
||||||
inline u8 Convert4To8(u8 value) {
|
constexpr u8 Convert4To8(u8 value) {
|
||||||
return (value << 4) | value;
|
return (value << 4) | value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convert a 5-bit color component to 8 bit
|
/// Convert a 5-bit color component to 8 bit
|
||||||
inline u8 Convert5To8(u8 value) {
|
constexpr u8 Convert5To8(u8 value) {
|
||||||
return (value << 3) | (value >> 2);
|
return (value << 3) | (value >> 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convert a 6-bit color component to 8 bit
|
/// Convert a 6-bit color component to 8 bit
|
||||||
inline u8 Convert6To8(u8 value) {
|
constexpr u8 Convert6To8(u8 value) {
|
||||||
return (value << 2) | (value >> 4);
|
return (value << 2) | (value >> 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convert a 8-bit color component to 1 bit
|
/// Convert a 8-bit color component to 1 bit
|
||||||
inline u8 Convert8To1(u8 value) {
|
constexpr u8 Convert8To1(u8 value) {
|
||||||
return value >> 7;
|
return value >> 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convert a 8-bit color component to 4 bit
|
/// Convert a 8-bit color component to 4 bit
|
||||||
inline u8 Convert8To4(u8 value) {
|
constexpr u8 Convert8To4(u8 value) {
|
||||||
return value >> 4;
|
return value >> 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convert a 8-bit color component to 5 bit
|
/// Convert a 8-bit color component to 5 bit
|
||||||
inline u8 Convert8To5(u8 value) {
|
constexpr u8 Convert8To5(u8 value) {
|
||||||
return value >> 3;
|
return value >> 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convert a 8-bit color component to 6 bit
|
/// Convert a 8-bit color component to 6 bit
|
||||||
inline u8 Convert8To6(u8 value) {
|
constexpr u8 Convert8To6(u8 value) {
|
||||||
return value >> 2;
|
return value >> 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user