Partial fixes from upstream #1607
This commit is contained in:
@@ -30,14 +30,14 @@ struct DirectPixelWriter {
|
||||
void init(GfxRenderer& renderer) {
|
||||
fb = renderer.getFrameBuffer();
|
||||
mode = renderer.getRenderMode();
|
||||
displayWidthBytes = display.getDisplayWidthBytes();
|
||||
displayWidthBytes = renderer.getDisplayWidthBytes();
|
||||
|
||||
const int phyW = display.getDisplayWidth();
|
||||
const int phyH = display.getDisplayHeight();
|
||||
const int phyW = renderer.getDisplayWidth();
|
||||
const int phyH = renderer.getDisplayHeight();
|
||||
|
||||
switch (renderer.getOrientation()) {
|
||||
case GfxRenderer::Portrait:
|
||||
// phyX = y, phyY = (DISPLAY_HEIGHT-1) - x
|
||||
// phyX = y, phyY = (phyH-1) - x
|
||||
phyXBase = 0;
|
||||
phyYBase = phyH - 1;
|
||||
phyXStepX = 0;
|
||||
@@ -46,7 +46,7 @@ struct DirectPixelWriter {
|
||||
phyYStepY = 0;
|
||||
break;
|
||||
case GfxRenderer::LandscapeClockwise:
|
||||
// phyX = (DISPLAY_WIDTH-1) - x, phyY = (DISPLAY_HEIGHT-1) - y
|
||||
// phyX = (phyW-1) - x, phyY = (phyH-1) - y
|
||||
phyXBase = phyW - 1;
|
||||
phyYBase = phyH - 1;
|
||||
phyXStepX = -1;
|
||||
@@ -55,7 +55,7 @@ struct DirectPixelWriter {
|
||||
phyYStepY = -1;
|
||||
break;
|
||||
case GfxRenderer::PortraitInverted:
|
||||
// phyX = (DISPLAY_WIDTH-1) - y, phyY = x
|
||||
// phyX = (phyW-1) - y, phyY = x
|
||||
phyXBase = phyW - 1;
|
||||
phyYBase = 0;
|
||||
phyXStepX = 0;
|
||||
|
||||
@@ -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