Files
dev.urandom/e
2025-11-13 10:51:51 -05:00

12 lines
552 B
Plaintext

public static Color from332(byte colorByte) {
int b = colorByte & 0b00000011; // Extract bits 1-0 (Blue, 2 bits)
int g = (colorByte >> 2) & 0b00000111; // Extract bits 4-2 (Green, 3 bits)
int r = (colorByte >> 5) & 0b00000111; // Extract bits 7-5 (Red, 3 bits)
// Scale 3-bit and 2-bit values to 0-255 range
int red = (r * 255) / 7; // 3 bits: 0..7
int green = (g * 255) / 7; // 3 bits: 0..7
int blue = (b * 255) / 3; // 2 bits: 0..3
return new Color(red, green, blue);
}