Address review comment #6:
- isFormatSupported() was passing the full path to supportsFormat()
which only matches extensions like ".jpg", so it always returned false
- Delegate to getDecoder() which correctly extracts the extension first
Address review comments #2 and #3:
- Remove duplicated bayer4x4, applyBayerDither4Level(),
drawPixelWithRenderMode(), and PixelCache from JPEG decoder
- Include shared DitherUtils.h and PixelCache.h instead
Address review comments #1 and #7:
- Replace all file-scope global variables (gRenderer, gConfig, gScale,
gCacheBuffer, etc.) with a PngContext struct passed through pDraw->pUser
- Unify file I/O callbacks to use pFile->fHandle instead of global FsFile*
- Remove the unused FsFile opened at the start of decodeToFramebuffer()
that was never used for actual decoding (duplicate open)
- Use shared PixelCache from PixelCache.h instead of hand-rolled globals
Address review comments #2, #3, and #10:
- Extract duplicated bayer4x4 matrix, applyBayerDither4Level(), and
drawPixelWithRenderMode() into shared DitherUtils.h
- Extract duplicated PixelCache struct into shared PixelCache.h so both
JPEG and PNG decoders use the same implementation
- Add MAX_CACHE_BYTES (256KB) size limit to PixelCache::allocate() to
proactively guard against oversized allocations on embedded targets