MCPcopy Create free account
hub / github.com/OpenEPaperLink/OpenEPaperLink / spr2buffer

Function spr2buffer

ESP32_AP-Flasher/src/makeimage.cpp:417–612  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

415}
416
417void 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();

Callers 13

jpg2bufferFunction · 0.85
drawDateFunction · 0.85
drawNumberFunction · 0.85
drawWeatherFunction · 0.85
drawForecastFunction · 0.85
getRssFeedFunction · 0.85
getCalFeedFunction · 0.85
getDayAheadFeedFunction · 0.85
drawQRFunction · 0.85
drawBuienradarFunction · 0.85
drawAPinfoFunction · 0.85
drawTimestampFunction · 0.85

Calls 15

doTimestampFunction · 0.85
memcpyFunction · 0.85
printLargestFreeBlockFunction · 0.85
spr2colorFunction · 0.85
prepareHeaderFunction · 0.85
initializeCompressorFunction · 0.85
compressAndWriteFunction · 0.85
rewriteHeaderFunction · 0.85
g5CompressFunction · 0.85
setRotationMethod · 0.80
widthMethod · 0.80
heightMethod · 0.80

Tested by

no test coverage detected