Properly center fallback custom image

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
jpirnay
2026-04-30 18:57:18 +02:00
co-authored by Copilot
parent fb9cf4615a
commit 65d36d4f24
2 changed files with 7 additions and 7 deletions
+5 -6
View File
@@ -570,14 +570,12 @@ BookOverlayInfo SleepActivity::getBookOverlayInfo(const std::string& bookPath) c
return info;
}
void SleepActivity::renderBitmapSleepScreen(const Bitmap& bitmap, const BookOverlayInfo& overlayInfo) const {
void SleepActivity::renderBitmapSleepScreen(const Bitmap& bitmap, const BookOverlayInfo& overlayInfo,
bool topAlignForCoverFit) const {
int x, y;
const auto pageWidth = renderer.getScreenWidth();
const auto pageHeight = renderer.getScreenHeight();
float cropX = 0, cropY = 0;
const bool topAlignForCoverFit = (SETTINGS.sleepScreen == CrossPointSettings::SLEEP_SCREEN_MODE::COVER ||
SETTINGS.sleepScreen == CrossPointSettings::SLEEP_SCREEN_MODE::COVER_CUSTOM) &&
SETTINGS.sleepScreenCoverMode == CrossPointSettings::SLEEP_SCREEN_COVER_MODE::FIT;
LOG_DBG("SLP", "bitmap %d x %d, screen %d x %d", bitmap.getWidth(), bitmap.getHeight(), pageWidth, pageHeight);
if (bitmap.getWidth() > pageWidth || bitmap.getHeight() > pageHeight) {
@@ -791,7 +789,8 @@ void SleepActivity::renderCoverSleepScreen() const {
const uint8_t overlayMode = SETTINGS.sleepCoverOverlay;
const BookOverlayInfo coverOverlayInfo =
overlayMode != 0 ? getBookOverlayInfo(APP_STATE.openEpubPath) : BookOverlayInfo{};
renderBitmapSleepScreen(bitmap, coverOverlayInfo);
renderBitmapSleepScreen(bitmap, coverOverlayInfo,
SETTINGS.sleepScreenCoverMode == CrossPointSettings::SLEEP_SCREEN_COVER_MODE::FIT);
file.close();
return;
}
@@ -875,7 +874,7 @@ void SleepActivity::renderOverlaySleepScreen() const {
LOG_ERR("SLP", "Not enough heap for PNG overlay decoder");
return false;
}
std::unique_ptr<PNG> png(new (std::nothrow) PNG());
auto png = std::make_unique<PNG>();
if (!png) return false;
int rc = png->open(filename.c_str(), pngSleepOpen, pngSleepClose, pngSleepRead, pngSleepSeek, pngOverlayDraw);
+2 -1
View File
@@ -24,7 +24,8 @@ class SleepActivity final : public Activity {
void renderDefaultSleepScreen() const;
void renderCustomSleepScreen() const;
void renderCoverSleepScreen() const;
void renderBitmapSleepScreen(const Bitmap& bitmap, const BookOverlayInfo& overlayInfo) const;
void renderBitmapSleepScreen(const Bitmap& bitmap, const BookOverlayInfo& overlayInfo,
bool topAlignForCoverFit = false) const;
void renderBlankSleepScreen() const;
void renderOverlaySleepScreen() const;
BookOverlayInfo getBookOverlayInfo(const std::string& bookPath) const;