Partial fixes from upstream #1607
This commit is contained in:
@@ -14,8 +14,8 @@ void ScreenshotUtil::takeScreenshot(GfxRenderer& renderer) {
|
||||
const uint8_t* fb = renderer.getFrameBuffer();
|
||||
if (fb) {
|
||||
String filename_str = "/screenshots/screenshot-" + String(millis()) + ".bmp";
|
||||
if (ScreenshotUtil::saveFramebufferAsBmp(filename_str.c_str(), fb, display.getDisplayWidth(),
|
||||
display.getDisplayHeight())) {
|
||||
if (ScreenshotUtil::saveFramebufferAsBmp(filename_str.c_str(), fb, renderer.getDisplayWidth(),
|
||||
renderer.getDisplayHeight())) {
|
||||
LOG_DBG("SCR", "Screenshot saved to %s", filename_str.c_str());
|
||||
} else {
|
||||
LOG_ERR("SCR", "Failed to save screenshot");
|
||||
@@ -26,7 +26,7 @@ void ScreenshotUtil::takeScreenshot(GfxRenderer& renderer) {
|
||||
|
||||
// Display a border around the screen to indicate a screenshot was taken
|
||||
if (renderer.storeBwBuffer()) {
|
||||
renderer.drawRect(6, 6, display.getDisplayHeight() - 12, display.getDisplayWidth() - 12, 2, true);
|
||||
renderer.drawRect(6, 6, renderer.getDisplayHeight() - 12, renderer.getDisplayWidth() - 12, 2, true);
|
||||
renderer.displayBuffer();
|
||||
delay(1000);
|
||||
renderer.restoreBwBuffer();
|
||||
@@ -45,7 +45,7 @@ bool ScreenshotUtil::saveFramebufferAsBmp(const char* filename, const uint8_t* f
|
||||
|
||||
std::string path(filename);
|
||||
size_t last_slash = path.find_last_of('/');
|
||||
if (last_slash != std::string::npos && last_slash > 0) {
|
||||
if (last_slash != std::string::npos) {
|
||||
std::string dir = path.substr(0, last_slash);
|
||||
if (!Storage.exists(dir.c_str())) {
|
||||
if (!Storage.mkdir(dir.c_str())) {
|
||||
@@ -76,7 +76,7 @@ bool ScreenshotUtil::saveFramebufferAsBmp(const char* filename, const uint8_t* f
|
||||
}
|
||||
|
||||
const uint32_t rowSizePadded = (phyWidth + 31) / 32 * 4;
|
||||
// Max row size for 528px width (X3) = 68 bytes; use fixed buffer to avoid VLA
|
||||
// Max row size for 528px height (X3) after rotation = 68 bytes; use fixed buffer to avoid VLA
|
||||
constexpr size_t kMaxRowSize = 68;
|
||||
if (rowSizePadded > kMaxRowSize) {
|
||||
LOG_ERR("SCR", "Row size %u exceeds buffer capacity", rowSizePadded);
|
||||
|
||||
Reference in New Issue
Block a user