A fork of https://github.com/crosspoint-reader/crosspoint-reader
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Generate different .bmp for cropped covers so settings have effect. (#330)

Addresses
https://github.com/daveallie/crosspoint-reader/pull/225#issuecomment-3735150337

authored by

Jonas Diemer and committed by
GitHub
a9242fe6 88d0d904

+13 -9
+8 -5
lib/Epub/Epub.cpp
··· 345 345 return bookMetadataCache->coreMetadata.author; 346 346 } 347 347 348 - std::string Epub::getCoverBmpPath() const { return cachePath + "/cover.bmp"; } 348 + std::string Epub::getCoverBmpPath(bool cropped) const { 349 + const auto coverFileName = "cover" + cropped ? "_crop" : ""; 350 + return cachePath + "/" + coverFileName + ".bmp"; 351 + } 349 352 350 - bool Epub::generateCoverBmp() const { 353 + bool Epub::generateCoverBmp(bool cropped) const { 351 354 // Already generated, return true 352 - if (SdMan.exists(getCoverBmpPath().c_str())) { 355 + if (SdMan.exists(getCoverBmpPath(cropped).c_str())) { 353 356 return true; 354 357 } 355 358 ··· 381 384 } 382 385 383 386 FsFile coverBmp; 384 - if (!SdMan.openFileForWrite("EBP", getCoverBmpPath(), coverBmp)) { 387 + if (!SdMan.openFileForWrite("EBP", getCoverBmpPath(cropped), coverBmp)) { 385 388 coverJpg.close(); 386 389 return false; 387 390 } ··· 392 395 393 396 if (!success) { 394 397 Serial.printf("[%lu] [EBP] Failed to generate BMP from JPG cover image\n", millis()); 395 - SdMan.remove(getCoverBmpPath().c_str()); 398 + SdMan.remove(getCoverBmpPath(cropped).c_str()); 396 399 } 397 400 Serial.printf("[%lu] [EBP] Generated BMP from JPG cover image, success: %s\n", millis(), success ? "yes" : "no"); 398 401 return success;
+2 -2
lib/Epub/Epub.h
··· 44 44 const std::string& getPath() const; 45 45 const std::string& getTitle() const; 46 46 const std::string& getAuthor() const; 47 - std::string getCoverBmpPath() const; 48 - bool generateCoverBmp() const; 47 + std::string getCoverBmpPath(bool cropped = false) const; 48 + bool generateCoverBmp(bool cropped = false) const; 49 49 uint8_t* readItemContentsToBytes(const std::string& itemHref, size_t* size = nullptr, 50 50 bool trailingNullByte = false) const; 51 51 bool readItemContentsToStream(const std::string& itemHref, Print& out, size_t chunkSize) const;
+3 -2
src/activities/boot_sleep/SleepActivity.cpp
··· 199 199 } 200 200 201 201 std::string coverBmpPath; 202 + bool cropped = SETTINGS.sleepScreenCoverMode == CrossPointSettings::SLEEP_SCREEN_COVER_MODE::CROP; 202 203 203 204 if (StringUtils::checkFileExtension(APP_STATE.openEpubPath, ".xtc") || 204 205 StringUtils::checkFileExtension(APP_STATE.openEpubPath, ".xtch")) { ··· 223 224 return renderDefaultSleepScreen(); 224 225 } 225 226 226 - if (!lastEpub.generateCoverBmp()) { 227 + if (!lastEpub.generateCoverBmp(cropped)) { 227 228 Serial.println("[SLP] Failed to generate cover bmp"); 228 229 return renderDefaultSleepScreen(); 229 230 } 230 231 231 - coverBmpPath = lastEpub.getCoverBmpPath(); 232 + coverBmpPath = lastEpub.getCoverBmpPath(cropped); 232 233 } else { 233 234 return renderDefaultSleepScreen(); 234 235 }