1
0
mirror of https://github.com/thooge/esp32-nmea2000-obp60.git synced 2026-08-18 18:32:30 +02:00

Fix image converter

This commit is contained in:
Norbert Walter
2026-02-28 15:55:52 +00:00
parent 2d6127912b
commit 7434601382
+29 -16
View File
@@ -148,30 +148,43 @@ LGFX & getdisplay();
#define PAGE_HIBERNATE 2 // page wants displey to hibernate #define PAGE_HIBERNATE 2 // page wants displey to hibernate
// Draw monochrome bitmap on both E-Ink and TFT displays // Draw monochrome bitmap on both E-Ink and TFT displays
// Konvertiert 1-Bit Bilder automatisch zu RGB565 für Farbdisplays // supports various packing and bit orders; optional runtime conversion for TFT
inline void drawMonochromeBitmap( inline void drawMonochromeBitmap(
int16_t x, int16_t y, int16_t x, int16_t y,
const uint8_t *bitmap, const uint8_t *bmp,
int16_t w, int16_t h, int16_t w, int16_t h,
uint16_t color) { uint16_t color,
bool vertical=false, // true: bytes run vertically (each byte 8 pixels down)
bool lsbFirst=false) // true: least significant bit = left/top pixel
{
#ifdef DISPLAY_ST7796 #ifdef DISPLAY_ST7796
// Für RGB565 TFT: Konvertierung von 1-Bit zu Pixel-Zeichnung // TFT converts perpixel
for (int row = 0; row < h; row++) { for (int yy = 0; yy < h; yy++) {
for (int col = 0; col < w; col++) { for (int xx = 0; xx < w; xx++) {
int byteIdx = (row * ((w + 7) / 8)) + (col / 8); int byteIdx;
int bitIdx = col % 8; int bitIdx;
uint8_t byte = bitmap[byteIdx]; if (vertical) {
byteIdx = xx * ((h + 7) / 8) + (yy / 8);
// LSB-first format (Adafruit standard) bitIdx = yy % 8;
if (byte & (1 << bitIdx)) { } else {
getdisplay().drawPixel(x + col, y + row, color); byteIdx = yy * ((w + 7) / 8) + (xx / 8);
bitIdx = xx % 8;
}
uint8_t b = bmp[byteIdx];
bool pix;
if (lsbFirst) {
pix = b & (1 << bitIdx);
} else {
pix = b & (1 << (7 - bitIdx));
}
if (pix) {
getdisplay().drawPixel(x + xx, y + yy, color);
} }
} }
} }
#else #else
// Für E-Ink Displays: direkt drawBitmap verwenden // EPaper: just hand over to driver (expects MSBfirst horizontal)
getdisplay().drawBitmap(x, y, bitmap, w, h, color); getdisplay().drawBitmap(x, y, bmp, w, h, color);
#endif #endif
} }