| 415 | } |
| 416 | |
| 417 | void spr2buffer(TFT_eSprite &spr, String &fileout, imgParam &imageParams) { |
| 418 | long t = millis(); |
| 419 | |
| 420 | if (imageParams.ts_option) doTimestamp(&spr,imageParams.ts_option); |
| 421 | #ifdef HAS_TFT |
| 422 | extern uint8_t YellowSense; |
| 423 | if (fileout == "direct") { |
| 424 | if (tftOverride == false) { |
| 425 | TFT_eSprite spr2 = TFT_eSprite(&tft2); |
| 426 | #ifdef ST7735_NANO_TLSR |
| 427 | tft2.setRotation(1); |
| 428 | #else |
| 429 | tft2.setRotation(YellowSense == 1 ? 1 : 3); |
| 430 | #endif |
| 431 | spr2.createSprite(spr.width(), spr.height()); |
| 432 | spr2.setColorDepth(spr.getColorDepth()); |
| 433 | |
| 434 | void *spriteData = spr.getPointer(); |
| 435 | void *spriteData2 = spr2.getPointer(); |
| 436 | size_t dataSize = spr.width() * spr.height() * (spr.getColorDepth() / 8); |
| 437 | memcpy(spriteData2, spriteData, dataSize); |
| 438 | |
| 439 | #if defined HAS_LILYGO_TPANEL || defined HAS_4inch_TPANEL |
| 440 | if (spr.getColorDepth() == 16) { |
| 441 | long dy = spr.height(); |
| 442 | long dx = spr.width(); |
| 443 | |
| 444 | uint16_t *data = static_cast<uint16_t *>(const_cast<void *>(spriteData2)); |
| 445 | |
| 446 | gfx->draw16bitRGBBitmap(0, 0, (uint16_t *)spriteData2, dx, dy); |
| 447 | spr2.deleteSprite(); |
| 448 | } |
| 449 | #else |
| 450 | spr2.pushSprite(0, 0); |
| 451 | #endif |
| 452 | } |
| 453 | return; |
| 454 | } |
| 455 | #endif |
| 456 | |
| 457 | xSemaphoreTake(fsMutex, portMAX_DELAY); |
| 458 | fs::File f_out = contentFS->open(fileout, "w"); |
| 459 | |
| 460 | switch (imageParams.bpp) { |
| 461 | case 1: |
| 462 | case 2: { |
| 463 | long bufw = spr.width(), bufh = spr.height(); |
| 464 | size_t buffer_size = ((bufw * bufh) + 7) / 8; // round up: not all dimensions are multiples of 8 |
| 465 | #ifdef BOARD_HAS_PSRAM |
| 466 | uint8_t *buffer = (uint8_t *)ps_malloc(buffer_size); |
| 467 | #else |
| 468 | uint8_t *buffer = (uint8_t *)malloc(buffer_size); |
| 469 | imageParams.zlib = 0; |
| 470 | imageParams.g5 = 0; |
| 471 | #endif |
| 472 | if (!buffer) { |
| 473 | Serial.println("Failed to allocate buffer"); |
| 474 | util::printLargestFreeBlock(); |
no test coverage detected