Add BMP image decoder#70
Open
felixsmole-hash wants to merge 2 commits into
Open
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The desktop and file manager already treat
.bmpas an image type —kernel/gui/desktop.cextension-matches it, andbootstrap_landscape_bmp.hetc. declare extern BMP arrays — but no BMP decoder exists anywhere in the kernel, so opening a.bmpsilently fails. This fills that gap.media_decode_bmp()inkernel/media/media.c: uncompressed 24/32bpp BMPs withBITMAPINFOHEADERor 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.BMmagic at all three of its decode sites, alongside the existing PNG-magic/JPEG-fallback logic..bmpon double-click and tints its icon like other image types; the terminalviewcommand now accepts.png/.bmpalongside.jpg(the viewer already decoded PNG by magic — only the extension gate was missing)./Pictures/test.bmpat 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:/Pictures/test.bmpseeded and visible in the file managerview /Pictures/test.bmpopens the viewer too🤖 Generated with Claude Code