Clean up in DTOR, remove unneccessary argument.

This commit is contained in:
Jonas Diemer 2026-01-12 12:31:29 +01:00
parent 93a5c41cf2
commit 6ad26c26f6
3 changed files with 8 additions and 5 deletions

View File

@ -14,6 +14,9 @@ constexpr bool USE_ATKINSON = true; // Use Atkinson dithering instead of Floyd-
Bitmap::~Bitmap() { Bitmap::~Bitmap() {
delete[] errorCurRow; delete[] errorCurRow;
delete[] errorNextRow; delete[] errorNextRow;
delete atkinsonDitherer;
delete fsDitherer;
} }
uint16_t Bitmap::readLE16(FsFile& f) { uint16_t Bitmap::readLE16(FsFile& f) {
@ -168,7 +171,7 @@ BmpReaderError Bitmap::readNextRow(uint8_t* data, uint8_t* rowBuffer) const {
if (atkinsonDitherer) { if (atkinsonDitherer) {
color = atkinsonDitherer->processPixel(adjustPixel(lum), currentX); color = atkinsonDitherer->processPixel(adjustPixel(lum), currentX);
} else if (fsDitherer) { } else if (fsDitherer) {
color = fsDitherer->processPixel(adjustPixel(lum), currentX, fsDitherer->isReverseRow()); color = fsDitherer->processPixel(adjustPixel(lum), currentX);
} else { } else {
if (bpp > 2) { if (bpp > 2) {
// Simple quantization or noise dithering // Simple quantization or noise dithering

View File

@ -134,7 +134,7 @@ class FloydSteinbergDitherer {
// Process a single pixel and return quantized 2-bit value // Process a single pixel and return quantized 2-bit value
// x is the logical x position (0 to width-1), direction handled internally // 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 // Add accumulated error to this pixel
int adjusted = gray + errorCurRow[x + 1]; int adjusted = gray + errorCurRow[x + 1];
@ -179,7 +179,7 @@ class FloydSteinbergDitherer {
int error = adjusted - quantizedValue; int error = adjusted - quantizedValue;
// Distribute error to neighbors (serpentine: direction-aware) // Distribute error to neighbors (serpentine: direction-aware)
if (!reverseDirection) { if (!isReverseRow()) {
// Left to right: standard distribution // Left to right: standard distribution
// Right: 7/16 // Right: 7/16
errorCurRow[x + 2] += (error * 7) >> 4; errorCurRow[x + 2] += (error * 7) >> 4;

View File

@ -360,7 +360,7 @@ bool JpegToBmpConverter::jpegFileToBmpStream(FsFile& jpegFile, Print& bmpOut) {
if (atkinsonDitherer) { if (atkinsonDitherer) {
twoBit = atkinsonDitherer->processPixel(gray, x); twoBit = atkinsonDitherer->processPixel(gray, x);
} else if (fsDitherer) { } else if (fsDitherer) {
twoBit = fsDitherer->processPixel(gray, x, fsDitherer->isReverseRow()); twoBit = fsDitherer->processPixel(gray, x);
} else { } else {
twoBit = quantize(gray, x, y); twoBit = quantize(gray, x, y);
} }
@ -423,7 +423,7 @@ bool JpegToBmpConverter::jpegFileToBmpStream(FsFile& jpegFile, Print& bmpOut) {
if (atkinsonDitherer) { if (atkinsonDitherer) {
twoBit = atkinsonDitherer->processPixel(gray, x); twoBit = atkinsonDitherer->processPixel(gray, x);
} else if (fsDitherer) { } else if (fsDitherer) {
twoBit = fsDitherer->processPixel(gray, x, fsDitherer->isReverseRow()); twoBit = fsDitherer->processPixel(gray, x);
} else { } else {
twoBit = quantize(gray, x, currentOutY); twoBit = quantize(gray, x, currentOutY);
} }