Repository navigation
feat(lua): add lvgl.bitmap object with owned image pixels - #7972
Open
thomaskistler wants to merge 1 commit into
Open
thomaskistler wants to merge 1 commit into
thomaskistler wants to merge 1 commit into
Conversation
This was referenced Nov 1, 2026
thomaskistler
force-pushed
the
thomaskistler/lvgl-bitmap-widget
branch
from
November 2, 2026 04:16
1b849f5 to
8a43230
Compare
Add the bitmap object and Lua registration on upstream main without shared Lua/LVGL hardening. Keep RGB565 and alpha conversion, source/frame decode coalescing, protected bitmap-only setter staging, image-canvas preservation, and source/scaling bounds. Make update virtual for bitmap-specific setters. Retain the existing constructor, callback and manager behavior and cover the feature with bitmap-focused regressions. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
thomaskistler
force-pushed
the
thomaskistler/lvgl-bitmap-widget
branch
from
November 3, 2026 06:00
8a43230 to
2c63158
Compare
This branch has not been deployed
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.
Fixes: N/A (feature; no linked issue).
Summary of changes:
Adds
lvgl.bitmap([parent, ]params)andlvgl.BITMAPforlvgl.build(): an image object that owns its decoded, scaled pixels rather than relying on LVGL's shared image cache. This is an alternative to #7947, keeping bitmap ownership in a separate object instead of adding another source type tolvgl.image.Motivation
lvgl.imagedecodes through LVGL's shared image cache, which has 8 entries (LV_IMG_CACHE_DEF_SIZE). A Lua widget that shows more images than that, for example a map made of 256x256 JPEG tiles, keeps evicting images that are still visible and decodes them again on redraw.lvgl.bitmapdecodes once when itsfilechanges and the object owns the pixels, so a widget can keep one object per image and decide for itself which ones stay decoded.Details
fileis a string or a function, likelvgl.image. A function is only called while the object is visible. Setting a string replaces a previous function. Repeating the same file and frame size does not decode again.worhreloads the file. Hidden objects keep their pixels.StaticBitmap::setSource(filename)chooses RGB565 for opaque images and ARGB4444 for images with alpha.setSource(filename, fmt)forces a format, and the constructor accepts the same optional format. Existing callers in model selection, file preview, and the model bitmap widget explicitly retain ARGB4444 rendering.LUA_MEM_EXTRA_MAX). The per-object frame limit is not a total-memory budget; scripts control how many decoded images they retain.fileis only applied after all parameters of an update have been accepted. A rejectedset()preserves the source and releases its staged callback. Changing file and size together decodes once, after any dynamic filename and size callbacks have supplied their final values. Other parameters retain the existing partially applied behavior ofset().set({file=''})clears the image immediately, including while hidden.sizefunction, and cover at most four display areas. Frames larger than the display are allowed. The scaled image must fit LVGL's 2047-pixel-per-axis descriptor limit; bitmap source and scaled-allocation dimensions are checked before narrowing or scaling.lvgl.clear(bitmap)removes all children except the object's own image canvas. Its pixels are freed when the source changes, the source is cleared, or the native window closes. RGB565 scaling fills the complete destination, and conversion failures leave no incorrectly formatted canvas.ETX_BITMAPis inserted afterETX_QRCODE, shifting subsequent numeric type constants by one. Scripts should use the namedlvgl.*constants. The new API is documented in its luadoc block and marked as introduced in 3.0.0.Validation
Native test build succeeded. All 292 tests across 39 suites passed. Under GuardMalloc, all 77 bitmap/Lua/LCD/window tests passed, plus ten shuffled passes of the 49 bitmap tests.
Not performed: ARM firmware or Companion builds, hardware performance measurements, or radio heap measurements.