Fixing build error xdrv_13_display.ino with JPEG_PICTS (#22265)

On ESP32, with `#define JPEG_PICTS` without the scripter, build fails due to the function `Draw_jpeg` being defined after use. Order swapped to satisfy the compiler.

Change tested to compile without errors, but not being 100% sure of when/how it is supposed to work, no verification of this.
This commit is contained in:
sfromis 2024-10-13 11:10:27 +02:00 committed by GitHub
parent 63d44c8b30
commit c07b8a59c0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 22 additions and 22 deletions

View File

@ -2442,6 +2442,28 @@ void Draw_RGB_Bitmap(char *file, uint16_t xp, uint16_t yp, uint8_t scale, bool i
#ifdef ESP32
#ifdef JPEG_PICTS
#define JPG_DEFSIZE 150000
void Draw_jpeg(uint8_t *mem, uint16_t jpgsize, uint16_t xp, uint16_t yp, uint8_t scale) {
if (mem[0] == 0xff && mem[1] == 0xd8) {
uint16_t xsize;
uint16_t ysize;
get_jpeg_size(mem, jpgsize, &xsize, &ysize);
//AddLog(LOG_LEVEL_INFO, PSTR("Pict size %d - %d - %d"), xsize, ysize, jpgsize);
scale &= 3;
uint8_t fac = 1 << scale;
xsize /= fac;
ysize /= fac;
renderer->setAddrWindow(xp, yp, xp + xsize, yp + ysize);
uint8_t *rgbmem = (uint8_t *)special_malloc(xsize * ysize * 2);
if (rgbmem) {
//jpg2rgb565(mem, jpgsize, rgbmem, JPG_SCALE_NONE);
jpg2rgb565(mem, jpgsize, rgbmem, (jpg_scale_t)scale);
renderer->pushColors((uint16_t*)rgbmem, xsize * ysize, true);
free(rgbmem);
}
renderer->setAddrWindow(0, 0, 0, 0);
}
}
void Draw_JPG_from_URL(char *url, uint16_t xp, uint16_t yp, uint8_t scale) {
uint8_t *mem = 0;
WiFiClient http_client;
@ -2484,28 +2506,6 @@ void Draw_JPG_from_URL(char *url, uint16_t xp, uint16_t yp, uint8_t scale) {
}
if (mem) free(mem);
}
void Draw_jpeg(uint8_t *mem, uint16_t jpgsize, uint16_t xp, uint16_t yp, uint8_t scale) {
if (mem[0] == 0xff && mem[1] == 0xd8) {
uint16_t xsize;
uint16_t ysize;
get_jpeg_size(mem, jpgsize, &xsize, &ysize);
//AddLog(LOG_LEVEL_INFO, PSTR("Pict size %d - %d - %d"), xsize, ysize, jpgsize);
scale &= 3;
uint8_t fac = 1 << scale;
xsize /= fac;
ysize /= fac;
renderer->setAddrWindow(xp, yp, xp + xsize, yp + ysize);
uint8_t *rgbmem = (uint8_t *)special_malloc(xsize * ysize * 2);
if (rgbmem) {
//jpg2rgb565(mem, jpgsize, rgbmem, JPG_SCALE_NONE);
jpg2rgb565(mem, jpgsize, rgbmem, (jpg_scale_t)scale);
renderer->pushColors((uint16_t*)rgbmem, xsize * ysize, true);
free(rgbmem);
}
renderer->setAddrWindow(0, 0, 0, 0);
}
}
#endif // JPEG_PICTS
#endif // ESP32