Skip to content

Add BMP image decoder#70

Open
felixsmole-hash wants to merge 2 commits into
viralcode:mainfrom
felixsmole-hash:feature/bmp-decoder
Open

Add BMP image decoder#70
felixsmole-hash wants to merge 2 commits into
viralcode:mainfrom
felixsmole-hash:feature/bmp-decoder

Conversation

@felixsmole-hash

Copy link
Copy Markdown

Summary

The desktop and file manager already treat .bmp as an image type — kernel/gui/desktop.c extension-matches it, and bootstrap_landscape_bmp.h etc. declare extern BMP arrays — but no BMP decoder exists anywhere in the kernel, so opening a .bmp silently fails. This fills that gap.

  • media_decode_bmp() in kernel/media/media.c: uncompressed 24/32bpp BMPs with BITMAPINFOHEADER or the larger V4/V5 headers, both bottom-up and top-down row order. Header fields, pixel-data offset, and row stride are all bounds-checked against the file size, with the same 16M-pixel cap as the other decoders.
  • Image Viewer dispatches on the BM magic at all three of its decode sites, alongside the existing PNG-magic/JPEG-fallback logic.
  • File manager opens .bmp on double-click and tints its icon like other image types; the terminal view command now accepts .png/.bmp alongside .jpg (the viewer already decoded PNG by magic — only the extension gate was missing).
  • A generated 200×150 24bpp test pattern is seeded to /Pictures/test.bmp at boot.

Note: includes the one-commit build fix from #68, since ARM64 doesn't compile without it on newer Clang. Happy to rebase once #68 merges.

Test plan

Verified in QEMU (aarch64 virt, ramfb, virtio input), driving the GUI via QMP and confirming with screendumps:

  • Kernel builds clean (Clang 22.x, ARM64)
  • /Pictures/test.bmp seeded and visible in the file manager
  • Double-click opens it in the Image Viewer, rendered correctly at 200×150
  • Channel order verified (red square top-left, blue circle bottom-right of the test pattern — a BGR swap would exchange them)
  • Bottom-up row order verified (green triangle points up; a flipped decode would invert the image)
  • Terminal view /Pictures/test.bmp opens the viewer too
  • No errors on the serial console

🤖 Generated with Claude Code

felixsmole-hash and others added 2 commits July 6, 2026 21:25
arch_context_get_pc() expects cpu_context_t*, but handle_sync_exception()
was passing it struct pt_regs* (the exception register frame) — two
unrelated structs that happen to both have a pc field. struct pt_regs
already stores pc directly, so use regs->pc instead.

This was a hard compile error on newer Clang (22.x), blocking ARM64
kernel builds.
The desktop and file manager already treated .bmp as an image type
(kernel/gui/desktop.c extension match, bootstrap_*_bmp.h extern
declarations), but no BMP decoder existed anywhere, so opening a .bmp
silently failed.

- media_decode_bmp() in kernel/media/media.c: uncompressed 24/32bpp
  BMPs with BITMAPINFOHEADER or the larger V4/V5 headers, both
  bottom-up and top-down row order, with bounds validation of the
  header fields, pixel-data offset, and row stride.
- Image Viewer now dispatches on the "BM" magic at all three of its
  decode sites, the file manager opens .bmp on double-click and tints
  its icon like other images, and the terminal "view" command accepts
  .png/.bmp alongside .jpg.
- A generated 200x150 24bpp test image is seeded to /Pictures/test.bmp
  at boot.

Verified in QEMU (aarch64 virt + ramfb): double-clicking test.bmp
renders it correctly in the Image Viewer - channel order, row order,
and dimensions all confirmed against the known test pattern.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant