mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-11-25 06:13:13 -05:00
Fix bmp16bit with nocomp header (#2769)
This commit is contained in:
parent
4dda7cfaa5
commit
fe826d5d98
1 changed files with 12 additions and 2 deletions
|
|
@ -167,8 +167,18 @@ bool BMPFile::read_next_px(ui::Color& px, bool seek = true) {
|
||||||
if (res.is_error()) return false;
|
if (res.is_error()) return false;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 5: {
|
case 5: {
|
||||||
uint16_t color16 = (uint16_t)buffer[0] | ((uint16_t)buffer[1] << 8);
|
// ARGB1555
|
||||||
px = ui::Color(color16); // has glitches!
|
uint16_t val = buffer[0] | (buffer[1] << 8);
|
||||||
|
// Extract components
|
||||||
|
//*a = (val >> 15) & 0x01; // 1-bit alpha
|
||||||
|
uint8_t r = (val >> 10) & 0x1F; // 5-bit red
|
||||||
|
uint8_t g = (val >> 5) & 0x1F; // 5-bit green
|
||||||
|
uint8_t b = (val)&0x1F; // 5-bit blue
|
||||||
|
// expand
|
||||||
|
r = (r << 3) | (r >> 2);
|
||||||
|
g = (g << 3) | (g >> 2);
|
||||||
|
b = (b << 3) | (b >> 2);
|
||||||
|
px = ui::Color(r, g, b);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 2: // 32
|
case 2: // 32
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue