6 Commits

Author SHA1 Message Date
Eunchurn Park
e9ffe1a39e
Apply clang-format fixes 2025-12-25 00:45:43 +09:00
Eunchurn Park
16568932cf
Improve EPUB cover image quality with pre-scaling and Atkinson dithering
Pre-scaling (critical fix):
- Add pre-scaling to fit display dimensions (480x800) before dithering
  to prevent post-downsampling artifacts that destroy dithering patterns
- Use fixed-point (16.16) math for sub-pixel accurate scaling
- Implement area averaging for smooth downsampling

Dithering improvements:
- Add Atkinson dithering (75% error diffusion) for cleaner results
- Add Floyd-Steinberg dithering option with serpentine scanning
- Keep clustered-dot halftone and Bayer as compile-time options

Image adjustments:
- Add brightness, contrast, and gamma adjustments for better visibility
- Adjust RGB to grayscale conversion (25-50-25) to reduce blue darkness

Other changes:
- Fix MCU block indexing bug for correct picojpeg buffer access
- Pre-generate cover BMP when EPUB is loaded for faster sleep screen
2025-12-25 00:33:15 +09:00
Eunchurn Park
c801da2d9a
Merge branch 'daveallie:master' into feature/cover-image 2025-12-24 22:02:26 +09:00
Dave Allie
27035b2b91
Handle 16x16 MCU blocks in JPEG decoding (#120)
## Summary

* Handle 16x16 MCU blocks in JPEG decoding
* We were only correctly handling 8x8 blocks, which means that we did
not correctly support a lot of JPGs leading to an interlacing style on
the images

## Additional Context

* Fixes https://github.com/daveallie/crosspoint-reader/issues/118
2025-12-24 22:21:41 +11:00
Eunchurn Park
9aa305700c
Add Bayer 4x4 ordered dithering for EPUB cover images
Replace simple threshold-based grayscale quantization with ordered
dithering using a 4x4 Bayer matrix. This eliminates color banding
artifacts and produces smoother gradients on e-ink display.

- Add 4x4 Bayer dithering matrix for 16-level threshold patterns
- Modify grayscaleTo2Bit() to use pixel position for dithering
- Simulates smooth grayscale transitions in BW mode without flicker
2025-12-24 03:45:34 +09:00
Dave Allie
2a27c6d068
Add JPG image support (#23)
## Summary

- Add basic JPG image support
- Map JPG back to 2-bit BMP output
- Can be used to later render the BMP file from disk or directly pass to
output if wanted
- Give the 3 passes over the data needed to render grayscale content,
putting it on disk is preferred to outputting it multiple times

## Additional Context

- WIP, looking forward to BMP support from
https://github.com/daveallie/crosspoint-reader/pull/16
- Addresses some of #11
2025-12-21 17:15:17 +11:00