Skip to content

Commit

Permalink
Fix for displaying 1bpp bmp files (usermod EleksTube IPS) (wled#2988)
Browse files Browse the repository at this point in the history
* Fix for displaying 1bpp bmp files

* EleksTubeIPS optimizations

* Fixed incorrect paletteSize

* stray tab

---------

Co-authored-by: Aircoookie <[email protected]>
  • Loading branch information
dvdavide and Aircoookie authored May 31, 2023
1 parent a5161eb commit e3783e0
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions usermods/EleksTube_IPS/TFTs.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,13 @@ class TFTs : public TFT_eSPI {
return false;
}

read32(bmpFS); // filesize in bytes
read32(bmpFS); // reserved
(void) read32(bmpFS); // filesize in bytes
(void) read32(bmpFS); // reserved
seekOffset = read32(bmpFS); // start of bitmap
headerSize = read32(bmpFS); // header size
w = read32(bmpFS); // width
h = read32(bmpFS); // height
read16(bmpFS); // color planes (must be 1)
(void) read16(bmpFS); // color planes (must be 1)
bitDepth = read16(bmpFS);

if (read32(bmpFS) != 0 || (bitDepth != 24 && bitDepth != 1 && bitDepth != 4 && bitDepth != 8)) {
Expand All @@ -151,9 +151,9 @@ class TFTs : public TFT_eSPI {
uint32_t palette[256];
if (bitDepth <= 8) // 1,4,8 bit bitmap: read color palette
{
read32(bmpFS); read32(bmpFS); read32(bmpFS); // size, w resolution, h resolution
(void) read32(bmpFS); (void) read32(bmpFS); (void) read32(bmpFS); // size, w resolution, h resolution
paletteSize = read32(bmpFS);
if (paletteSize == 0) paletteSize = bitDepth * bitDepth; //if 0, size is 2^bitDepth
if (paletteSize == 0) paletteSize = 1 << bitDepth; //if 0, size is 2^bitDepth
bmpFS.seek(14 + headerSize); // start of color palette
for (uint16_t i = 0; i < paletteSize; i++) {
palette[i] = read32(bmpFS);
Expand Down Expand Up @@ -198,7 +198,7 @@ class TFTs : public TFT_eSPI {
}
b = c; g = c >> 8; r = c >> 16;
}
if (dimming != 255) { // only dimm when needed
if (dimming != 255) { // only dim when needed
r *= dimming; g *= dimming; b *= dimming;
r = r >> 8; g = g >> 8; b = b >> 8;
}
Expand Down

0 comments on commit e3783e0

Please sign in to comment.