lexus2k / ssd1306

Driver for SSD1306, SSD1331, SSD1351, IL9163, ILI9341, ST7735, PCD8544, Nokia 5110 displays running on Arduino/ESP32/Linux (Rasperry) platforms
MIT License
664 stars 127 forks source link

Add support of BMP format to read bitmaps from BMP files/buffers #55

Closed lexus2k closed 5 years ago

lexus2k commented 5 years ago

Add support of BMP format to read bitmaps from BMP files/buffers. This will allow to load and use bitmaps from file systems on ESP32

lexus2k commented 5 years ago

BMP format is fully incompatible with 1-bit/8-bit modes, used by ssd1306 library. Thus, implementing work with bitmap formats is possible only in case larger footprint of library code, or large SRAM consumption.

Monochrome BMP Monochrome BMP files encode pixels as bits from high bit to low. This order is reverse compared to XBMP, supported by ssd1306 library. Thus, we need to decide, which implementation is more important: speed or memory consumption.

8-bit BMP 8-bit format is completely different from format, used by LCD/OLED displays. Because 8-bit mode for LCD displays is 3-3-2 color mode, but 8-bit BMP files contain color indexes to predefined palette. There 2 possible implementations:

16-bit BMP Even 16-bit BMP cannot be used as is with color displays. Because 16-bit BMP pixels are in 5-5-5, but most color displays use 5-6-5.

From described above, I see the only simple way - to develop functions for converting BMP to internal ssd1306 library format. But this way eliminates BMP usage for AVR controllers because of high requirements to SRAM.

lexus2k commented 5 years ago

No plan for now to implement bitmap format support. Maybe this feature will be added in future, if there will be some interest from users.