lv_img_conv: Add CF_TRUE_COLOR output - #2458
#2458Open
JoeStrout wants to merge 1 commit into
InfiniTimeOrg:mainInfiniTimeOrg/InfiniTime:mainfrom
JoeStrout:lv-img-conv-true-colorJoeStrout/InfiniTime:lv-img-conv-true-colorCopy head branch name to clipboard
Open
lv_img_conv: Add CF_TRUE_COLOR output#2458JoeStrout wants to merge 1 commit intoInfiniTimeOrg:mainInfiniTimeOrg/InfiniTime:mainfrom JoeStrout:lv-img-conv-true-colorJoeStrout/InfiniTime:lv-img-conv-true-colorCopy head branch name to clipboard
JoeStrout wants to merge 1 commit into
InfiniTimeOrg:mainInfiniTimeOrg/InfiniTime:mainfrom
JoeStrout:lv-img-conv-true-colorJoeStrout/InfiniTime:lv-img-conv-true-colorCopy head branch name to clipboard
Conversation
Only CF_INDEXED_1_BIT and CF_TRUE_COLOR_ALPHA were implemented, so a plain true-colour image -- the obvious choice for a full-screen watch face background -- could not be converted at all. Add CF_TRUE_COLOR: 2 bytes per pixel, RGB565 high byte first, matching the existing alpha path and LV_COLOR_16_SWAP=1, with cf = 4 in the header. Alpha is dropped on input, since the format does not carry it. Also fix a typo on an adjacent line: pritn -> print in the refuse-to-overwrite path, which raised NameError instead of printing the intended message.
|
Build size and comparison to main:
|
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.
Only CF_INDEXED_1_BIT and CF_TRUE_COLOR_ALPHA were implemented, so a plain true-color image without alpha could not be converted into a 2-bytes-per-pixel file. (I ran into this while trying to use a full-color image as a watch background.)
This PR adds support for CF_TRUE_COLOR with binary format ARGB8565_RBSWAP, written as 2 bytes per pixel, RGB565 high byte first, matching the existing alpha path and LV_COLOR_16_SWAP=1, with cf = 4 in the header. Alpha is dropped on input, since the format does not carry it.
(You might wonder why the format is ARGB8565_RBSWAP in this case, which claims an alpha channel. That's because all the format choices claim an alpha channel; there is no plain RGB565_SWAP option. Yet some existing
color_formatoptions (see the--color-formatchoices list) imply no alpha, and this is the part that determines whether we actually have an alpha channel or not. When used with a format with no alpha, ARGB8565_RBSWAP would reduce to just RGB565_RBSWAP. We could add that as an alias just to reduce confusion, but it's not necessary and seemed out of scope for this PR. This also matches how CF_INDEXED_1_BIT overrides the given binary format as needed.)Verified by using this to convert a full-color 240x240 pixel image into a 115,200-byte file (plus header) that exactly matched a hand-built one, and which displays correctly both in InfiniSim and on device.
This PR also fixes a typo on a nearby line:
pritn->printin the refuse-to-overwrite path, which raised NameError instead of printing the intended message.