From 4b23b151bf51f27711941a472d9893d9c2e72e7f Mon Sep 17 00:00:00 2001 From: Clemens <41959005+Martinius79@users.noreply.github.com> Date: Thu, 19 Sep 2024 10:31:55 +0200 Subject: [PATCH] Bugfix - Fix pallete size calculation (#87) * Create cmake-multi-platform.yml tryout1 * Update cmake-multi-platform.yml * Update cmake-multi-platform.yml * Update cmake-multi-platform.yml * Update cmake-multi-platform.yml * Update cmake-multi-platform.yml * edited and renamed github action workflow file * updated build definition * fixing build definition * Fixed calculation of palette size for most palletized bitmaps. 2^bitDepth instead of bitDepth*bitDepth. Calculation is needed because paletteSize in the DIB header is not filled correctly by the most image libs/tools, so 0 is read and calculation was wrong. --- EleksTubeHAX_pio/src/TFTs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EleksTubeHAX_pio/src/TFTs.cpp b/EleksTubeHAX_pio/src/TFTs.cpp index 05dcf83..a990d91 100644 --- a/EleksTubeHAX_pio/src/TFTs.cpp +++ b/EleksTubeHAX_pio/src/TFTs.cpp @@ -270,7 +270,7 @@ bool TFTs::LoadImageIntoBuffer(uint8_t file_index) { { read32(bmpFS); read32(bmpFS); 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 = pow(2, 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);