Refactoring and proper handling of quantization.

Moving color and dithering related helpers into dedicated file.
In case of 2bpp (i.e. file generated from JPG), we don't apply any color
adjustments. In other cases, they are applied based on selected
algorithm.
This commit is contained in:
Jonas Diemer
2026-01-09 20:46:04 +01:00
parent 1cfbc6173e
commit 904af4cdf3
5 changed files with 349 additions and 173 deletions

View File

@@ -7,8 +7,7 @@
#include <cstdio>
#include <cstring>
#include "Bitmap.h"
#include "Dithering.h"
#include "BitmapHelpers.h"
// Context structure for picojpeg callback
struct JpegReadContext {
@@ -356,7 +355,7 @@ bool JpegToBmpConverter::jpegFileToBmpStream(FsFile& jpegFile, Print& bmpOut) {
}
} else {
for (int x = 0; x < outWidth; x++) {
const uint8_t gray = mcuRowBuffer[bufferY * imageInfo.m_width + x];
const uint8_t gray = adjustPixel(mcuRowBuffer[bufferY * imageInfo.m_width + x]);
uint8_t twoBit;
if (atkinsonDitherer) {
twoBit = atkinsonDitherer->processPixel(gray, x);