Add end of book actions screen
This commit is contained in:
+23
-2
@@ -3,6 +3,7 @@
|
||||
#include <FsHelpers.h>
|
||||
#include <JpegToBmpConverter.h>
|
||||
#include <Logging.h>
|
||||
#include <PngToBmpConverter.h>
|
||||
|
||||
Txt::Txt(std::string path, std::string cacheBasePath)
|
||||
: filepath(std::move(path)), cacheBasePath(std::move(cacheBasePath)) {
|
||||
@@ -156,10 +157,30 @@ bool Txt::generateCoverBmp() const {
|
||||
LOG_DBG("TXT", "Generated BMP from JPG cover image");
|
||||
}
|
||||
return success;
|
||||
} else if (FsHelpers::hasPngExtension(coverImagePath)) {
|
||||
LOG_DBG("TXT", "Generating BMP from PNG cover image");
|
||||
FsFile coverPng, coverBmp;
|
||||
if (!Storage.openFileForRead("TXT", coverImagePath, coverPng)) {
|
||||
return false;
|
||||
}
|
||||
if (!Storage.openFileForWrite("TXT", getCoverBmpPath(), coverBmp)) {
|
||||
coverPng.close();
|
||||
return false;
|
||||
}
|
||||
const bool success = PngToBmpConverter::pngFileToBmpStream(coverPng, coverBmp);
|
||||
coverPng.close();
|
||||
coverBmp.close();
|
||||
|
||||
if (!success) {
|
||||
LOG_ERR("TXT", "Failed to generate BMP from PNG cover image");
|
||||
Storage.remove(getCoverBmpPath().c_str());
|
||||
} else {
|
||||
LOG_DBG("TXT", "Generated BMP from PNG cover image");
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
// PNG files are not supported (would need a PNG decoder)
|
||||
LOG_ERR("TXT", "Cover image format not supported (only BMP/JPG/JPEG)");
|
||||
LOG_ERR("TXT", "Cover image format not supported (only BMP/JPG/JPEG/PNG)");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user