mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-11-25 14:16:20 -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;
|
||||
switch (type) {
|
||||
case 5: {
|
||||
uint16_t color16 = (uint16_t)buffer[0] | ((uint16_t)buffer[1] << 8);
|
||||
px = ui::Color(color16); // has glitches!
|
||||
// ARGB1555
|
||||
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;
|
||||
}
|
||||
case 2: // 32
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue