A fork of https://github.com/crosspoint-reader/crosspoint-reader
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: epub images not rendering correctly on x3 (#1572)

Replace hardcoded DISPLAY_WIDTH, DISPLAY_HEIGHT, and DISPLAY_WIDTH_BYTES
constants with runtime values from display object to support multiple
device models (X3 and X4) with different screen dimensions.

authored by

Justin Mitchell and committed by
GitHub
6cd19f56 cff3e12a

+15 -10
+10 -5
lib/Epub/Epub/converters/DirectPixelWriter.h
··· 15 15 struct DirectPixelWriter { 16 16 uint8_t* fb; 17 17 GfxRenderer::RenderMode mode; 18 + uint16_t displayWidthBytes; // Runtime framebuffer stride (X4: 100, X3: 99) 18 19 19 20 // Orientation is collapsed into a linear transform: 20 21 // phyX = phyXBase + x * phyXStepX + y * phyXStepY ··· 29 30 void init(GfxRenderer& renderer) { 30 31 fb = renderer.getFrameBuffer(); 31 32 mode = renderer.getRenderMode(); 33 + displayWidthBytes = display.getDisplayWidthBytes(); 34 + 35 + const int phyW = display.getDisplayWidth(); 36 + const int phyH = display.getDisplayHeight(); 32 37 33 38 switch (renderer.getOrientation()) { 34 39 case GfxRenderer::Portrait: 35 40 // phyX = y, phyY = (DISPLAY_HEIGHT-1) - x 36 41 phyXBase = 0; 37 - phyYBase = HalDisplay::DISPLAY_HEIGHT - 1; 42 + phyYBase = phyH - 1; 38 43 phyXStepX = 0; 39 44 phyYStepX = -1; 40 45 phyXStepY = 1; ··· 42 47 break; 43 48 case GfxRenderer::LandscapeClockwise: 44 49 // phyX = (DISPLAY_WIDTH-1) - x, phyY = (DISPLAY_HEIGHT-1) - y 45 - phyXBase = HalDisplay::DISPLAY_WIDTH - 1; 46 - phyYBase = HalDisplay::DISPLAY_HEIGHT - 1; 50 + phyXBase = phyW - 1; 51 + phyYBase = phyH - 1; 47 52 phyXStepX = -1; 48 53 phyYStepX = 0; 49 54 phyXStepY = 0; ··· 51 56 break; 52 57 case GfxRenderer::PortraitInverted: 53 58 // phyX = (DISPLAY_WIDTH-1) - y, phyY = x 54 - phyXBase = HalDisplay::DISPLAY_WIDTH - 1; 59 + phyXBase = phyW - 1; 55 60 phyYBase = 0; 56 61 phyXStepX = 0; 57 62 phyYStepX = 1; ··· 115 120 const int phyX = rowPhyXBase + logicalX * phyXStepX; 116 121 const int phyY = rowPhyYBase + logicalX * phyYStepX; 117 122 118 - const uint16_t byteIndex = phyY * HalDisplay::DISPLAY_WIDTH_BYTES + (phyX >> 3); 123 + const uint16_t byteIndex = phyY * displayWidthBytes + (phyX >> 3); 119 124 const uint8_t bitMask = 1 << (7 - (phyX & 7)); 120 125 121 126 if (state) {
+5 -5
src/util/ScreenshotUtil.cpp
··· 14 14 const uint8_t* fb = renderer.getFrameBuffer(); 15 15 if (fb) { 16 16 String filename_str = "/screenshots/screenshot-" + String(millis()) + ".bmp"; 17 - if (ScreenshotUtil::saveFramebufferAsBmp(filename_str.c_str(), fb, HalDisplay::DISPLAY_WIDTH, 18 - HalDisplay::DISPLAY_HEIGHT)) { 17 + if (ScreenshotUtil::saveFramebufferAsBmp(filename_str.c_str(), fb, display.getDisplayWidth(), 18 + display.getDisplayHeight())) { 19 19 LOG_DBG("SCR", "Screenshot saved to %s", filename_str.c_str()); 20 20 } else { 21 21 LOG_ERR("SCR", "Failed to save screenshot"); ··· 26 26 27 27 // Display a border around the screen to indicate a screenshot was taken 28 28 if (renderer.storeBwBuffer()) { 29 - renderer.drawRect(6, 6, HalDisplay::DISPLAY_HEIGHT - 12, HalDisplay::DISPLAY_WIDTH - 12, 2, true); 29 + renderer.drawRect(6, 6, display.getDisplayHeight() - 12, display.getDisplayWidth() - 12, 2, true); 30 30 renderer.displayBuffer(); 31 31 delay(1000); 32 32 renderer.restoreBwBuffer(); ··· 76 76 } 77 77 78 78 const uint32_t rowSizePadded = (phyWidth + 31) / 32 * 4; 79 - // Max row size for 480px width = 60 bytes; use fixed buffer to avoid VLA 80 - constexpr size_t kMaxRowSize = 64; 79 + // Max row size for 528px width (X3) = 68 bytes; use fixed buffer to avoid VLA 80 + constexpr size_t kMaxRowSize = 68; 81 81 if (rowSizePadded > kMaxRowSize) { 82 82 LOG_ERR("SCR", "Row size %u exceeds buffer capacity", rowSizePadded); 83 83 file.close();