From 6ad26c26f641accc6fae4438ae2653b89bead598 Mon Sep 17 00:00:00 2001 From: Jonas Diemer Date: Mon, 12 Jan 2026 12:31:29 +0100 Subject: [PATCH] Clean up in DTOR, remove unneccessary argument. --- lib/GfxRenderer/Bitmap.cpp | 5 ++++- lib/GfxRenderer/BitmapHelpers.h | 4 ++-- lib/JpegToBmpConverter/JpegToBmpConverter.cpp | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/GfxRenderer/Bitmap.cpp b/lib/GfxRenderer/Bitmap.cpp index 577410fb..1a3b4406 100644 --- a/lib/GfxRenderer/Bitmap.cpp +++ b/lib/GfxRenderer/Bitmap.cpp @@ -14,6 +14,9 @@ constexpr bool USE_ATKINSON = true; // Use Atkinson dithering instead of Floyd- Bitmap::~Bitmap() { delete[] errorCurRow; delete[] errorNextRow; + + delete atkinsonDitherer; + delete fsDitherer; } uint16_t Bitmap::readLE16(FsFile& f) { @@ -168,7 +171,7 @@ BmpReaderError Bitmap::readNextRow(uint8_t* data, uint8_t* rowBuffer) const { if (atkinsonDitherer) { color = atkinsonDitherer->processPixel(adjustPixel(lum), currentX); } else if (fsDitherer) { - color = fsDitherer->processPixel(adjustPixel(lum), currentX, fsDitherer->isReverseRow()); + color = fsDitherer->processPixel(adjustPixel(lum), currentX); } else { if (bpp > 2) { // Simple quantization or noise dithering diff --git a/lib/GfxRenderer/BitmapHelpers.h b/lib/GfxRenderer/BitmapHelpers.h index e93ed0dc..300527e0 100644 --- a/lib/GfxRenderer/BitmapHelpers.h +++ b/lib/GfxRenderer/BitmapHelpers.h @@ -134,7 +134,7 @@ class FloydSteinbergDitherer { // Process a single pixel and return quantized 2-bit value // x is the logical x position (0 to width-1), direction handled internally - uint8_t processPixel(int gray, int x, bool reverseDirection) { + uint8_t processPixel(int gray, int x) { // Add accumulated error to this pixel int adjusted = gray + errorCurRow[x + 1]; @@ -179,7 +179,7 @@ class FloydSteinbergDitherer { int error = adjusted - quantizedValue; // Distribute error to neighbors (serpentine: direction-aware) - if (!reverseDirection) { + if (!isReverseRow()) { // Left to right: standard distribution // Right: 7/16 errorCurRow[x + 2] += (error * 7) >> 4; diff --git a/lib/JpegToBmpConverter/JpegToBmpConverter.cpp b/lib/JpegToBmpConverter/JpegToBmpConverter.cpp index f79bfa06..30c1314f 100644 --- a/lib/JpegToBmpConverter/JpegToBmpConverter.cpp +++ b/lib/JpegToBmpConverter/JpegToBmpConverter.cpp @@ -360,7 +360,7 @@ bool JpegToBmpConverter::jpegFileToBmpStream(FsFile& jpegFile, Print& bmpOut) { if (atkinsonDitherer) { twoBit = atkinsonDitherer->processPixel(gray, x); } else if (fsDitherer) { - twoBit = fsDitherer->processPixel(gray, x, fsDitherer->isReverseRow()); + twoBit = fsDitherer->processPixel(gray, x); } else { twoBit = quantize(gray, x, y); } @@ -423,7 +423,7 @@ bool JpegToBmpConverter::jpegFileToBmpStream(FsFile& jpegFile, Print& bmpOut) { if (atkinsonDitherer) { twoBit = atkinsonDitherer->processPixel(gray, x); } else if (fsDitherer) { - twoBit = fsDitherer->processPixel(gray, x, fsDitherer->isReverseRow()); + twoBit = fsDitherer->processPixel(gray, x); } else { twoBit = quantize(gray, x, currentOutY); }