diff --git a/src/TFTs.cpp b/src/TFTs.cpp index 5434886..2b849ca 100644 --- a/src/TFTs.cpp +++ b/src/TFTs.cpp @@ -465,7 +465,7 @@ bool TFTs::LoadBMPImageIntoBuffer(fs::File &bmpFile) { Serial.println(dimming); #endif uint32_t palette[256]; - if (bitDepth <= 8) // 1,4,8 bit bitmap: read color palette + if (bitDepth <= 8) // 1,2,4,8 bit bitmap: read color palette { read32(bmpFile); read32(bmpFile); read32(bmpFile); // size, w resolution, h resolution paletteSize = read32(bmpFile); @@ -652,7 +652,7 @@ bool TFTs::LoadImageBytesIntoSprite(int16_t w, int16_t h, uint8_t bitDepth, int1 b = c; g = c >> 8; r = c >> 16; break; case 2: - pixel = (*inputPtr >> ((3 - (col & 0x03))) << 1) & 0x03; + pixel = (*inputPtr >> ((3 - (col & 0x03))<< 1)) & 0x03; if ((col & 0x03) == 0x03) inputPtr++; c = palette[pixel]; b = c; g = c >> 8; r = c >> 16; diff --git a/tools/batch_convert_images.py b/tools/batch_convert_images.py index 3b42718..4cfe3cd 100644 --- a/tools/batch_convert_images.py +++ b/tools/batch_convert_images.py @@ -12,7 +12,9 @@ def create_header(width, height): palette_size = 0 match args.bpp: case 4: - palette_size = 32 + palette_size = 64 + case 2: + palette_size = 16 case 1: palette_size = 8 @@ -38,6 +40,10 @@ def create_header(width, height): header += struct.pack('<2I', 0, 0) # RGB565 masks # header += struct.pack('<3I', 0x0000f800, 0x000007e0, 0x0000001f) + case 4: + header += struct.pack('<2I', 16, 16) + case 2: + header += struct.pack('<2I', 4, 4) case 1: header += struct.pack('<2I', 2, 2) @@ -66,12 +72,62 @@ def write_bin(f, image, width, height): if (width % 2) == 1: f.write(struct.pack('