style: apply clang-format-21 formatting
This commit is contained in:
parent
99702a342c
commit
41eabba0d4
@ -4,8 +4,8 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "blocks/TextBlock.h"
|
||||
#include "blocks/ImageBlock.h"
|
||||
#include "blocks/TextBlock.h"
|
||||
|
||||
enum PageElementTag : uint8_t {
|
||||
TAG_PageLine = 1,
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
#include "ImageBlock.h"
|
||||
#include "../converters/ImageDecoderFactory.h"
|
||||
|
||||
#include <FsHelpers.h>
|
||||
#include <GfxRenderer.h>
|
||||
#include <HardwareSerial.h>
|
||||
#include <Serialization.h>
|
||||
#include <SDCardManager.h>
|
||||
#include <FsHelpers.h>
|
||||
#include <Serialization.h>
|
||||
|
||||
#include "../converters/ImageDecoderFactory.h"
|
||||
|
||||
// Cache file format:
|
||||
// - uint16_t width
|
||||
@ -19,8 +21,7 @@ bool ImageBlock::imageExists() const {
|
||||
return SdMan.openFileForRead("IMG", imagePath, file);
|
||||
}
|
||||
|
||||
void ImageBlock::layout(GfxRenderer& renderer) {
|
||||
}
|
||||
void ImageBlock::layout(GfxRenderer& renderer) {}
|
||||
|
||||
static std::string getCachePath(const std::string& imagePath) {
|
||||
// Replace extension with .pxc (pixel cache)
|
||||
@ -31,7 +32,8 @@ static std::string getCachePath(const std::string& imagePath) {
|
||||
return imagePath + ".pxc";
|
||||
}
|
||||
|
||||
static bool renderFromCache(GfxRenderer& renderer, const std::string& cachePath, int x, int y, int expectedWidth, int expectedHeight) {
|
||||
static bool renderFromCache(GfxRenderer& renderer, const std::string& cachePath, int x, int y, int expectedWidth,
|
||||
int expectedHeight) {
|
||||
FsFile cacheFile;
|
||||
if (!SdMan.openFileForRead("IMG", cachePath, cacheFile)) {
|
||||
return false;
|
||||
@ -47,8 +49,8 @@ static bool renderFromCache(GfxRenderer& renderer, const std::string& cachePath,
|
||||
int widthDiff = abs(cachedWidth - expectedWidth);
|
||||
int heightDiff = abs(cachedHeight - expectedHeight);
|
||||
if (widthDiff > 1 || heightDiff > 1) {
|
||||
Serial.printf("[%lu] [IMG] Cache dimension mismatch: %dx%d vs %dx%d\n", millis(),
|
||||
cachedWidth, cachedHeight, expectedWidth, expectedHeight);
|
||||
Serial.printf("[%lu] [IMG] Cache dimension mismatch: %dx%d vs %dx%d\n", millis(), cachedWidth, cachedHeight,
|
||||
expectedWidth, expectedHeight);
|
||||
cacheFile.close();
|
||||
return false;
|
||||
}
|
||||
@ -99,8 +101,8 @@ void ImageBlock::render(GfxRenderer& renderer, const int x, const int y) {
|
||||
|
||||
// Bounds check render position using logical screen dimensions
|
||||
if (x < 0 || y < 0 || x + width > screenWidth || y + height > screenHeight) {
|
||||
Serial.printf("[%lu] [IMG] Invalid render position: (%d,%d) size (%dx%d) screen (%dx%d)\n",
|
||||
millis(), x, y, width, height, screenWidth, screenHeight);
|
||||
Serial.printf("[%lu] [IMG] Invalid render position: (%d,%d) size (%dx%d) screen (%dx%d)\n", millis(), x, y, width,
|
||||
height, screenWidth, screenHeight);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
#include <SdFat.h>
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include <SdFat.h>
|
||||
|
||||
#include "Block.h"
|
||||
|
||||
class ImageBlock final : public Block {
|
||||
|
||||
@ -1,11 +1,14 @@
|
||||
#include "ImageDecoderFactory.h"
|
||||
#include "JpegToFramebufferConverter.h"
|
||||
#include "PngToFramebufferConverter.h"
|
||||
|
||||
#include <HardwareSerial.h>
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "JpegToFramebufferConverter.h"
|
||||
#include "PngToFramebufferConverter.h"
|
||||
|
||||
std::unique_ptr<JpegToFramebufferConverter> ImageDecoderFactory::jpegDecoder = nullptr;
|
||||
std::unique_ptr<PngToFramebufferConverter> ImageDecoderFactory::pngDecoder = nullptr;
|
||||
bool ImageDecoderFactory::initialized = false;
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
#include "ImageToFramebufferDecoder.h"
|
||||
#include <HardwareSerial.h>
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <HardwareSerial.h>
|
||||
|
||||
bool ImageToFramebufferDecoder::validateImageDimensions(int width, int height, const std::string& format) {
|
||||
if (width > MAX_SOURCE_WIDTH || height > MAX_SOURCE_HEIGHT) {
|
||||
Serial.printf("[%lu] [IMG] Image too large (%dx%d %s), max supported: %dx%d\n",
|
||||
millis(), width, height, format.c_str(), MAX_SOURCE_WIDTH, MAX_SOURCE_HEIGHT);
|
||||
Serial.printf("[%lu] [IMG] Image too large (%dx%d %s), max supported: %dx%d\n", millis(), width, height,
|
||||
format.c_str(), MAX_SOURCE_WIDTH, MAX_SOURCE_HEIGHT);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@ -24,11 +24,7 @@ class ImageToFramebufferDecoder {
|
||||
public:
|
||||
virtual ~ImageToFramebufferDecoder() = default;
|
||||
|
||||
virtual bool decodeToFramebuffer(
|
||||
const std::string& imagePath,
|
||||
GfxRenderer& renderer,
|
||||
const RenderConfig& config
|
||||
) = 0;
|
||||
virtual bool decodeToFramebuffer(const std::string& imagePath, GfxRenderer& renderer, const RenderConfig& config) = 0;
|
||||
|
||||
virtual bool getDimensions(const std::string& imagePath, ImageDimensions& dims) const = 0;
|
||||
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
#include "JpegToFramebufferConverter.h"
|
||||
|
||||
#include <GfxRenderer.h>
|
||||
#include <HardwareSerial.h>
|
||||
#include <SdFat.h>
|
||||
#include <SDCardManager.h>
|
||||
#include <SdFat.h>
|
||||
#include <picojpeg.h>
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
|
||||
@ -68,8 +70,8 @@ struct PixelCache {
|
||||
cacheFile.write(buffer, bytesPerRow * height);
|
||||
cacheFile.close();
|
||||
|
||||
Serial.printf("[%lu] [JPG] Cache written: %s (%dx%d, %d bytes)\n", millis(),
|
||||
cachePath.c_str(), width, height, 4 + bytesPerRow * height);
|
||||
Serial.printf("[%lu] [JPG] Cache written: %s (%dx%d, %d bytes)\n", millis(), cachePath.c_str(), width, height,
|
||||
4 + bytesPerRow * height);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -141,11 +143,8 @@ uint8_t JpegToFramebufferConverter::applyAtkinsonDithering(uint8_t gray, int x,
|
||||
return outputGray;
|
||||
}
|
||||
|
||||
bool JpegToFramebufferConverter::decodeToFramebuffer(
|
||||
const std::string& imagePath,
|
||||
GfxRenderer& renderer,
|
||||
const RenderConfig& config
|
||||
) {
|
||||
bool JpegToFramebufferConverter::decodeToFramebuffer(const std::string& imagePath, GfxRenderer& renderer,
|
||||
const RenderConfig& config) {
|
||||
Serial.printf("[%lu] [JPG] Decoding JPEG: %s\n", millis(), imagePath.c_str());
|
||||
|
||||
FsFile file;
|
||||
@ -172,9 +171,8 @@ bool JpegToFramebufferConverter::decodeToFramebuffer(
|
||||
}
|
||||
|
||||
// Calculate scale factor to fit within maxWidth/maxHeight
|
||||
float scaleX = (config.maxWidth > 0 && imageInfo.m_width > config.maxWidth)
|
||||
? (float)config.maxWidth / imageInfo.m_width
|
||||
: 1.0f;
|
||||
float scaleX =
|
||||
(config.maxWidth > 0 && imageInfo.m_width > config.maxWidth) ? (float)config.maxWidth / imageInfo.m_width : 1.0f;
|
||||
float scaleY = (config.maxHeight > 0 && imageInfo.m_height > config.maxHeight)
|
||||
? (float)config.maxHeight / imageInfo.m_height
|
||||
: 1.0f;
|
||||
@ -185,8 +183,8 @@ bool JpegToFramebufferConverter::decodeToFramebuffer(
|
||||
int destHeight = (int)(imageInfo.m_height * scale);
|
||||
|
||||
Serial.printf("[%lu] [JPG] JPEG %dx%d -> %dx%d (scale %.2f), scan type: %d, MCU: %dx%d\n", millis(),
|
||||
imageInfo.m_width, imageInfo.m_height, destWidth, destHeight, scale,
|
||||
imageInfo.m_scanType, imageInfo.m_MCUWidth, imageInfo.m_MCUHeight);
|
||||
imageInfo.m_width, imageInfo.m_height, destWidth, destHeight, scale, imageInfo.m_scanType,
|
||||
imageInfo.m_MCUWidth, imageInfo.m_MCUHeight);
|
||||
|
||||
if (!imageInfo.m_pMCUBufR || !imageInfo.m_pMCUBufG || !imageInfo.m_pMCUBufB) {
|
||||
Serial.printf("[%lu] [JPG] Null buffer pointers in imageInfo\n", millis());
|
||||
@ -236,7 +234,8 @@ bool JpegToFramebufferConverter::decodeToFramebuffer(
|
||||
int destX = config.x + (int)(srcX * scale);
|
||||
if (destX >= screenWidth || destX >= config.x + destWidth) continue;
|
||||
uint8_t gray = imageInfo.m_pMCUBufR[row * 8 + col];
|
||||
uint8_t dithered = config.useDithering ? applyAtkinsonDithering(gray, destX, destY, screenWidth) : gray / 85;
|
||||
uint8_t dithered =
|
||||
config.useDithering ? applyAtkinsonDithering(gray, destX, destY, screenWidth) : gray / 85;
|
||||
if (dithered > 3) dithered = 3;
|
||||
renderer.drawPixel(destX, destY, dithered < 2);
|
||||
if (caching) cache.setPixel(destX, destY, dithered);
|
||||
@ -257,7 +256,8 @@ bool JpegToFramebufferConverter::decodeToFramebuffer(
|
||||
uint8_t g = imageInfo.m_pMCUBufG[row * 8 + col];
|
||||
uint8_t b = imageInfo.m_pMCUBufB[row * 8 + col];
|
||||
uint8_t gray = (uint8_t)((r * 77 + g * 150 + b * 29) >> 8);
|
||||
uint8_t dithered = config.useDithering ? applyAtkinsonDithering(gray, destX, destY, screenWidth) : gray / 85;
|
||||
uint8_t dithered =
|
||||
config.useDithering ? applyAtkinsonDithering(gray, destX, destY, screenWidth) : gray / 85;
|
||||
if (dithered > 3) dithered = 3;
|
||||
renderer.drawPixel(destX, destY, dithered < 2);
|
||||
if (caching) cache.setPixel(destX, destY, dithered);
|
||||
@ -280,7 +280,8 @@ bool JpegToFramebufferConverter::decodeToFramebuffer(
|
||||
uint8_t g = imageInfo.m_pMCUBufG[blockIndex * 64 + pixelIndex];
|
||||
uint8_t b = imageInfo.m_pMCUBufB[blockIndex * 64 + pixelIndex];
|
||||
uint8_t gray = (uint8_t)((r * 77 + g * 150 + b * 29) >> 8);
|
||||
uint8_t dithered = config.useDithering ? applyAtkinsonDithering(gray, destX, destY, screenWidth) : gray / 85;
|
||||
uint8_t dithered =
|
||||
config.useDithering ? applyAtkinsonDithering(gray, destX, destY, screenWidth) : gray / 85;
|
||||
if (dithered > 3) dithered = 3;
|
||||
renderer.drawPixel(destX, destY, dithered < 2);
|
||||
if (caching) cache.setPixel(destX, destY, dithered);
|
||||
@ -303,7 +304,8 @@ bool JpegToFramebufferConverter::decodeToFramebuffer(
|
||||
uint8_t g = imageInfo.m_pMCUBufG[blockIndex * 128 + pixelIndex];
|
||||
uint8_t b = imageInfo.m_pMCUBufB[blockIndex * 128 + pixelIndex];
|
||||
uint8_t gray = (uint8_t)((r * 77 + g * 150 + b * 29) >> 8);
|
||||
uint8_t dithered = config.useDithering ? applyAtkinsonDithering(gray, destX, destY, screenWidth) : gray / 85;
|
||||
uint8_t dithered =
|
||||
config.useDithering ? applyAtkinsonDithering(gray, destX, destY, screenWidth) : gray / 85;
|
||||
if (dithered > 3) dithered = 3;
|
||||
renderer.drawPixel(destX, destY, dithered < 2);
|
||||
if (caching) cache.setPixel(destX, destY, dithered);
|
||||
@ -329,7 +331,8 @@ bool JpegToFramebufferConverter::decodeToFramebuffer(
|
||||
uint8_t g = imageInfo.m_pMCUBufG[blockOffset + pixelIndex];
|
||||
uint8_t b = imageInfo.m_pMCUBufB[blockOffset + pixelIndex];
|
||||
uint8_t gray = (uint8_t)((r * 77 + g * 150 + b * 29) >> 8);
|
||||
uint8_t dithered = config.useDithering ? applyAtkinsonDithering(gray, destX, destY, screenWidth) : gray / 85;
|
||||
uint8_t dithered =
|
||||
config.useDithering ? applyAtkinsonDithering(gray, destX, destY, screenWidth) : gray / 85;
|
||||
if (dithered > 3) dithered = 3;
|
||||
renderer.drawPixel(destX, destY, dithered < 2);
|
||||
if (caching) cache.setPixel(destX, destY, dithered);
|
||||
@ -356,12 +359,8 @@ bool JpegToFramebufferConverter::decodeToFramebuffer(
|
||||
return true;
|
||||
}
|
||||
|
||||
unsigned char JpegToFramebufferConverter::jpegReadCallback(
|
||||
unsigned char* pBuf,
|
||||
unsigned char buf_size,
|
||||
unsigned char* pBytes_actually_read,
|
||||
void* pCallback_data
|
||||
) {
|
||||
unsigned char JpegToFramebufferConverter::jpegReadCallback(unsigned char* pBuf, unsigned char buf_size,
|
||||
unsigned char* pBytes_actually_read, void* pCallback_data) {
|
||||
JpegContext* context = reinterpret_cast<JpegContext*>(pCallback_data);
|
||||
|
||||
if (context->bufferPos >= context->bufferFilled) {
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "ImageToFramebufferDecoder.h"
|
||||
@ -8,11 +9,7 @@ class JpegToFramebufferConverter final : public ImageToFramebufferDecoder {
|
||||
public:
|
||||
static bool getDimensionsStatic(const std::string& imagePath, ImageDimensions& out);
|
||||
|
||||
bool decodeToFramebuffer(
|
||||
const std::string& imagePath,
|
||||
GfxRenderer& renderer,
|
||||
const RenderConfig& config
|
||||
) override;
|
||||
bool decodeToFramebuffer(const std::string& imagePath, GfxRenderer& renderer, const RenderConfig& config) override;
|
||||
|
||||
bool getDimensions(const std::string& imagePath, ImageDimensions& dims) const override {
|
||||
return getDimensionsStatic(imagePath, dims);
|
||||
@ -23,10 +20,6 @@ public:
|
||||
|
||||
private:
|
||||
uint8_t applyAtkinsonDithering(uint8_t gray, int x, int y, int width);
|
||||
static unsigned char jpegReadCallback(
|
||||
unsigned char* pBuf,
|
||||
unsigned char buf_size,
|
||||
unsigned char* pBytes_actually_read,
|
||||
void* pCallback_data
|
||||
);
|
||||
static unsigned char jpegReadCallback(unsigned char* pBuf, unsigned char buf_size,
|
||||
unsigned char* pBytes_actually_read, void* pCallback_data);
|
||||
};
|
||||
|
||||
@ -1,18 +1,16 @@
|
||||
#include "PngToFramebufferConverter.h"
|
||||
|
||||
#include <GfxRenderer.h>
|
||||
#include <HardwareSerial.h>
|
||||
#include <SdFat.h>
|
||||
#include <SDCardManager.h>
|
||||
#include <PNGdec.h>
|
||||
#include <SDCardManager.h>
|
||||
#include <SdFat.h>
|
||||
|
||||
static FsFile* gPngFile = nullptr;
|
||||
|
||||
static void* pngOpenForDims(const char* filename, int32_t* size) {
|
||||
return gPngFile;
|
||||
}
|
||||
static void* pngOpenForDims(const char* filename, int32_t* size) { return gPngFile; }
|
||||
|
||||
static void pngCloseForDims(void* handle) {
|
||||
}
|
||||
static void pngCloseForDims(void* handle) {}
|
||||
|
||||
static int32_t pngReadForDims(PNGFILE* pFile, uint8_t* pBuf, int32_t len) {
|
||||
if (!gPngFile) return 0;
|
||||
@ -157,14 +155,12 @@ static uint8_t getGrayFromPixel(uint8_t* pPixels, int x, int pixelType, uint8_t*
|
||||
case PNG_PIXEL_GRAYSCALE:
|
||||
return pPixels[x];
|
||||
|
||||
case PNG_PIXEL_TRUECOLOR:
|
||||
{
|
||||
case PNG_PIXEL_TRUECOLOR: {
|
||||
uint8_t* p = &pPixels[x * 3];
|
||||
return (uint8_t)((p[0] * 77 + p[1] * 150 + p[2] * 29) >> 8);
|
||||
}
|
||||
|
||||
case PNG_PIXEL_INDEXED:
|
||||
{
|
||||
case PNG_PIXEL_INDEXED: {
|
||||
uint8_t paletteIndex = pPixels[x];
|
||||
if (palette) {
|
||||
uint8_t* p = &palette[paletteIndex * 3];
|
||||
@ -176,8 +172,7 @@ static uint8_t getGrayFromPixel(uint8_t* pPixels, int x, int pixelType, uint8_t*
|
||||
case PNG_PIXEL_GRAY_ALPHA:
|
||||
return pPixels[x * 2];
|
||||
|
||||
case PNG_PIXEL_TRUECOLOR_ALPHA:
|
||||
{
|
||||
case PNG_PIXEL_TRUECOLOR_ALPHA: {
|
||||
uint8_t* p = &pPixels[x * 4];
|
||||
return (uint8_t)((p[0] * 77 + p[1] * 150 + p[2] * 29) >> 8);
|
||||
}
|
||||
@ -232,11 +227,8 @@ int pngDrawCallback(PNGDRAW* pDraw) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool PngToFramebufferConverter::decodeToFramebuffer(
|
||||
const std::string& imagePath,
|
||||
GfxRenderer& renderer,
|
||||
const RenderConfig& config
|
||||
) {
|
||||
bool PngToFramebufferConverter::decodeToFramebuffer(const std::string& imagePath, GfxRenderer& renderer,
|
||||
const RenderConfig& config) {
|
||||
Serial.printf("[%lu] [PNG] Decoding PNG: %s\n", millis(), imagePath.c_str());
|
||||
|
||||
FsFile file;
|
||||
@ -280,8 +272,8 @@ bool PngToFramebufferConverter::decodeToFramebuffer(
|
||||
gDstHeight = (int)(gSrcHeight * gScale);
|
||||
gLastDstY = -1; // Reset row tracking
|
||||
|
||||
Serial.printf("[%lu] [PNG] PNG %dx%d -> %dx%d (scale %.2f), bpp: %d\n", millis(),
|
||||
gSrcWidth, gSrcHeight, gDstWidth, gDstHeight, gScale, png.getBpp());
|
||||
Serial.printf("[%lu] [PNG] PNG %dx%d -> %dx%d (scale %.2f), bpp: %d\n", millis(), gSrcWidth, gSrcHeight, gDstWidth,
|
||||
gDstHeight, gScale, png.getBpp());
|
||||
|
||||
if (png.getBpp() != 8) {
|
||||
warnUnsupportedFeature("bit depth (" + std::to_string(png.getBpp()) + "bpp)", imagePath);
|
||||
@ -303,7 +295,8 @@ bool PngToFramebufferConverter::decodeToFramebuffer(
|
||||
gCacheBuffer = (uint8_t*)malloc(bufferSize);
|
||||
if (gCacheBuffer) {
|
||||
memset(gCacheBuffer, 0, bufferSize);
|
||||
Serial.printf("[%lu] [PNG] Allocated cache buffer: %d bytes for %dx%d\n", millis(), bufferSize, gCacheWidth, gCacheHeight);
|
||||
Serial.printf("[%lu] [PNG] Allocated cache buffer: %d bytes for %dx%d\n", millis(), bufferSize, gCacheWidth,
|
||||
gCacheHeight);
|
||||
} else {
|
||||
Serial.printf("[%lu] [PNG] Failed to allocate cache buffer, continuing without caching\n", millis());
|
||||
caching = false;
|
||||
@ -338,8 +331,8 @@ bool PngToFramebufferConverter::decodeToFramebuffer(
|
||||
cacheFile.write(&h, 2);
|
||||
cacheFile.write(gCacheBuffer, gCacheBytesPerRow * gCacheHeight);
|
||||
cacheFile.close();
|
||||
Serial.printf("[%lu] [PNG] Cache written: %s (%dx%d, %d bytes)\n", millis(),
|
||||
config.cachePath.c_str(), gCacheWidth, gCacheHeight, 4 + gCacheBytesPerRow * gCacheHeight);
|
||||
Serial.printf("[%lu] [PNG] Cache written: %s (%dx%d, %d bytes)\n", millis(), config.cachePath.c_str(),
|
||||
gCacheWidth, gCacheHeight, 4 + gCacheBytesPerRow * gCacheHeight);
|
||||
} else {
|
||||
Serial.printf("[%lu] [PNG] Failed to open cache file for writing: %s\n", millis(), config.cachePath.c_str());
|
||||
}
|
||||
|
||||
@ -1,17 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include "ImageToFramebufferDecoder.h"
|
||||
#include <PNGdec.h>
|
||||
|
||||
#include "ImageToFramebufferDecoder.h"
|
||||
|
||||
class PngToFramebufferConverter final : public ImageToFramebufferDecoder {
|
||||
public:
|
||||
static bool getDimensionsStatic(const std::string& imagePath, ImageDimensions& out);
|
||||
|
||||
bool decodeToFramebuffer(
|
||||
const std::string& imagePath,
|
||||
GfxRenderer& renderer,
|
||||
const RenderConfig& config
|
||||
) override;
|
||||
bool decodeToFramebuffer(const std::string& imagePath, GfxRenderer& renderer, const RenderConfig& config) override;
|
||||
|
||||
bool getDimensions(const std::string& imagePath, ImageDimensions& dims) const override {
|
||||
return getDimensionsStatic(imagePath, dims);
|
||||
|
||||
@ -5,10 +5,10 @@
|
||||
#include <SDCardManager.h>
|
||||
#include <expat.h>
|
||||
|
||||
#include "../Page.h"
|
||||
#include "../converters/ImageToFramebufferDecoder.h"
|
||||
#include "../converters/ImageDecoderFactory.h"
|
||||
#include "../../Epub.h"
|
||||
#include "../Page.h"
|
||||
#include "../converters/ImageDecoderFactory.h"
|
||||
#include "../converters/ImageToFramebufferDecoder.h"
|
||||
|
||||
const char* HEADER_TAGS[] = {"h1", "h2", "h3", "h4", "h5", "h6"};
|
||||
constexpr int NUM_HEADER_TAGS = sizeof(HEADER_TAGS) / sizeof(HEADER_TAGS[0]);
|
||||
@ -124,7 +124,8 @@ void XMLCALL ChapterHtmlSlimParser::startElement(void* userData, const XML_Char*
|
||||
if (extPos != std::string::npos) {
|
||||
ext = resolvedPath.substr(extPos);
|
||||
}
|
||||
std::string cachedImagePath = self->epub->getCachePath() + "/img_" + std::to_string(spineIndex) + "_" + std::to_string(self->imageCounter++) + ext;
|
||||
std::string cachedImagePath = self->epub->getCachePath() + "/img_" + std::to_string(spineIndex) + "_" +
|
||||
std::to_string(self->imageCounter++) + ext;
|
||||
|
||||
// Extract image to cache file
|
||||
FsFile cachedImageFile;
|
||||
@ -154,7 +155,8 @@ void XMLCALL ChapterHtmlSlimParser::startElement(void* userData, const XML_Char*
|
||||
int displayWidth = (int)(dims.width * scale);
|
||||
int displayHeight = (int)(dims.height * scale);
|
||||
|
||||
Serial.printf("[%lu] [EHP] Display size: %dx%d (scale %.2f)\n", millis(), displayWidth, displayHeight, scale);
|
||||
Serial.printf("[%lu] [EHP] Display size: %dx%d (scale %.2f)\n", millis(), displayWidth, displayHeight,
|
||||
scale);
|
||||
|
||||
// Create page for image
|
||||
if (self->currentPage && !self->currentPage->elements.empty()) {
|
||||
|
||||
@ -7,8 +7,8 @@
|
||||
#include <memory>
|
||||
|
||||
#include "../ParsedText.h"
|
||||
#include "../blocks/TextBlock.h"
|
||||
#include "../blocks/ImageBlock.h"
|
||||
#include "../blocks/TextBlock.h"
|
||||
|
||||
class Page;
|
||||
class GfxRenderer;
|
||||
@ -50,8 +50,8 @@ class ChapterHtmlSlimParser {
|
||||
static void XMLCALL endElement(void* userData, const XML_Char* name);
|
||||
|
||||
public:
|
||||
explicit ChapterHtmlSlimParser(std::shared_ptr<Epub> epub, const std::string& filepath, GfxRenderer& renderer, const int fontId,
|
||||
const float lineCompression, const bool extraParagraphSpacing,
|
||||
explicit ChapterHtmlSlimParser(std::shared_ptr<Epub> epub, const std::string& filepath, GfxRenderer& renderer,
|
||||
const int fontId, const float lineCompression, const bool extraParagraphSpacing,
|
||||
const uint8_t paragraphAlignment, const uint16_t viewportWidth,
|
||||
const uint16_t viewportHeight, const bool hyphenationEnabled,
|
||||
const std::function<void(std::unique_ptr<Page>)>& completePageFn,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user