mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-06 23:57:39 +03:00
Add Epub::getCoverBmpPath
This commit is contained in:
parent
f1a8e4e00a
commit
c50257c9da
@ -219,9 +219,11 @@ const std::string& Epub::getPath() const { return filepath; }
|
|||||||
|
|
||||||
const std::string& Epub::getTitle() const { return title; }
|
const std::string& Epub::getTitle() const { return title; }
|
||||||
|
|
||||||
|
std::string Epub::getCoverBmpPath() const { return cachePath + "/cover.bmp"; }
|
||||||
|
|
||||||
bool Epub::generateCoverBmp() const {
|
bool Epub::generateCoverBmp() const {
|
||||||
// Already generated, return true
|
// Already generated, return true
|
||||||
if (SD.exists((getCachePath() + "/cover.bmp").c_str())) {
|
if (SD.exists(getCoverBmpPath().c_str())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,11 +240,16 @@ bool Epub::generateCoverBmp() const {
|
|||||||
coverJpg.close();
|
coverJpg.close();
|
||||||
|
|
||||||
coverJpg = SD.open((getCachePath() + "/.cover.jpg").c_str(), FILE_READ);
|
coverJpg = SD.open((getCachePath() + "/.cover.jpg").c_str(), FILE_READ);
|
||||||
File coverBmp = SD.open((getCachePath() + "/cover.bmp").c_str(), FILE_WRITE, true);
|
File coverBmp = SD.open(getCoverBmpPath().c_str(), FILE_WRITE, true);
|
||||||
const bool success = JpegToBmpConverter::jpegFileToBmpStream(coverJpg, coverBmp);
|
const bool success = JpegToBmpConverter::jpegFileToBmpStream(coverJpg, coverBmp);
|
||||||
coverJpg.close();
|
coverJpg.close();
|
||||||
coverBmp.close();
|
coverBmp.close();
|
||||||
SD.remove((getCachePath() + "/.cover.jpg").c_str());
|
SD.remove((getCachePath() + "/.cover.jpg").c_str());
|
||||||
|
|
||||||
|
if (!success) {
|
||||||
|
Serial.printf("[%lu] [EBP] Failed to generate BMP from JPG cover image\n", millis());
|
||||||
|
SD.remove(getCoverBmpPath().c_str());
|
||||||
|
}
|
||||||
Serial.printf("[%lu] [EBP] Generated BMP from JPG cover image, success: %s\n", millis(), success ? "yes" : "no");
|
Serial.printf("[%lu] [EBP] Generated BMP from JPG cover image, success: %s\n", millis(), success ? "yes" : "no");
|
||||||
return success;
|
return success;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -48,6 +48,7 @@ class Epub {
|
|||||||
const std::string& getCachePath() const;
|
const std::string& getCachePath() const;
|
||||||
const std::string& getPath() const;
|
const std::string& getPath() const;
|
||||||
const std::string& getTitle() const;
|
const std::string& getTitle() const;
|
||||||
|
std::string getCoverBmpPath() const;
|
||||||
bool generateCoverBmp() const;
|
bool generateCoverBmp() const;
|
||||||
uint8_t* readItemContentsToBytes(const std::string& itemHref, size_t* size = nullptr,
|
uint8_t* readItemContentsToBytes(const std::string& itemHref, size_t* size = nullptr,
|
||||||
bool trailingNullByte = false) const;
|
bool trailingNullByte = false) const;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user