Add e
This commit is contained in:
12
e
Normal file
12
e
Normal file
@@ -0,0 +1,12 @@
|
||||
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);
|
||||
}
|
||||
Reference in New Issue
Block a user