Fine-tuned simple quantization to better match the values of display.

This commit is contained in:
Jonas Diemer 2026-01-09 16:23:47 +01:00
parent 79e9c6dcc8
commit 6ac920854a
2 changed files with 14 additions and 3 deletions

View File

@ -34,7 +34,19 @@ static inline uint8_t boostBrightness(int gray, uint8_t boost) {
return gray; return gray;
} }
// Simple quantization without dithering - just divide into 4 levels // Simple quantization without dithering - just divide into 4 levels
static inline uint8_t quantizeSimple(int gray) { return static_cast<uint8_t>(gray >> 6); } static inline uint8_t quantizeSimple(int gray) {
// return static_cast<uint8_t>(gray >> 6);
if (gray < 50) {
return 0;
} else if (gray < 70) {
return 1;
} else if (gray < 140) {
return 2;
} else {
return 3;
}
}
// Hash-based noise dithering - survives downsampling without moiré artifacts // Hash-based noise dithering - survives downsampling without moiré artifacts
static inline uint8_t quantizeNoise(int gray, int x, int y) { static inline uint8_t quantizeNoise(int gray, int x, int y) {
@ -279,7 +291,6 @@ BmpReaderError Bitmap::readNextRow(uint8_t* data, uint8_t* rowBuffer) const {
false); false);
} else { } else {
// Simple quantization or noise dithering // Simple quantization or noise dithering
color = quantize(boostBrightness(lum, brightnessBoost), currentX, prevRowY); color = quantize(boostBrightness(lum, brightnessBoost), currentX, prevRowY);
} }
currentOutByte |= (color << bitShift); currentOutByte |= (color << bitShift);

View File

@ -101,7 +101,7 @@ void SleepActivity::renderCustomSleepScreen() const {
// render a custom sleep screen instead of the default. // render a custom sleep screen instead of the default.
FsFile file; FsFile file;
if (SdMan.openFileForRead("SLP", "/sleep.bmp", file)) { if (SdMan.openFileForRead("SLP", "/sleep.bmp", file)) {
Bitmap bitmap(file, true, 0); Bitmap bitmap(file, true);
if (bitmap.parseHeaders() == BmpReaderError::Ok) { if (bitmap.parseHeaders() == BmpReaderError::Ok) {
Serial.printf("[%lu] [SLP] Loading: /sleep.bmp\n", millis()); Serial.printf("[%lu] [SLP] Loading: /sleep.bmp\n", millis());
renderBitmapSleepScreen(bitmap); renderBitmapSleepScreen(bitmap);