1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-14 20:10:08 +03:00

[X7] fix #5911 and bmp loading (#6703)

* lcdDraw1bitBitmap now bit exact

* bmp rows are padded up to a multiple of 4 bytes
This commit is contained in:
Raphael Coeffic 2019-09-03 07:11:20 +02:00 committed by Bertrand Songis
parent 56127e5808
commit 27946ee92b
3 changed files with 24 additions and 4 deletions

View file

@ -129,10 +129,11 @@ uint8_t * lcdLoadBitmap(uint8_t * bmp, const char * filename, uint8_t width, uin
memset(dest, 0, BITMAP_BUFFER_SIZE(w, h) - 2); memset(dest, 0, BITMAP_BUFFER_SIZE(w, h) - 2);
uint8_t rowSize = (w + 7) / 8; uint8_t rowSize;
switch (depth) { switch (depth) {
case 1: case 1:
rowSize = ((w + 31) / 32) * 4;
for (int8_t i=h-1; i>=0; i--) { for (int8_t i=h-1; i>=0; i--) {
result = f_read(&bmpFile, buf, rowSize, &read); result = f_read(&bmpFile, buf, rowSize, &read);
if (result != FR_OK || read != rowSize) { if (result != FR_OK || read != rowSize) {

View file

@ -922,15 +922,34 @@ void lcdDraw1bitBitmap(coord_t x, coord_t y, const uint8_t * img, uint8_t idx, L
const uint8_t * q = img; const uint8_t * q = img;
uint8_t w = *q++; uint8_t w = *q++;
uint8_t hb = ((*q++) + 7) / 8; uint8_t hb = ((*q++) + 7) / 8;
uint8_t yShift = y % 8;
bool inv = (att & INVERS) ? true : (att & BLINK ? BLINK_ON_PHASE : false); bool inv = (att & INVERS) ? true : (att & BLINK ? BLINK_ON_PHASE : false);
q += idx*w*hb; q += idx*w*hb;
for (uint8_t yb = 0; yb < hb; yb++) { for (uint8_t yb = 0; yb < hb; yb++) {
uint8_t *p = &displayBuf[(y / 8 + yb) * LCD_W + x]; uint8_t *p = &displayBuf[(y / 8 + yb) * LCD_W + x];
for (coord_t i=0; i<w; i++){ for (coord_t i=0; i<w; i++){
uint8_t b = *q++;
uint8_t b = inv ? ~(*q++) : *q++;
if (p < DISPLAY_END) { if (p < DISPLAY_END) {
*p++ = inv ? ~b : b;
if (!yShift) {
*p = b;
}
else {
*p = (*p & ((1 << yShift) - 1)) | (b << yShift);
if (p + LCD_W < DISPLAY_END) {
p[LCD_W] = (p[LCD_W] & (0xFF >> yShift)) | (b >> (8 - yShift));
}
}
} }
p++;
} }
} }
} }

View file

@ -541,7 +541,7 @@ Draw a bitmap at (x,y)
@param name (string) full path to the bitmap on SD card (i.e. /IMAGES/test.bmp) @param name (string) full path to the bitmap on SD card (i.e. /IMAGES/test.bmp)
@notice Only available on Taranis X9 series. Maximum image size if 106 x 64 pixels (width x height). @notice Maximum image size is [display width / 2] x [display height] pixels.
@status current Introduced in 2.0.0 @status current Introduced in 2.0.0
*/ */