Comments (23)
I don't think the screen needs to have an alpha channel; the alpha values are consumed by LVGL in the rendering process (e.g. for rendering widgets behind the image).
from lv_img_conv.
@tvanfossen Thanks for opening this. I agree that the dithering logic could be improved in this scenario so I'll see what I can do. I also like the idea of having the converter handle chroma-keying the image for you.
I cannot reproduce the first part of your issue, where pink pixels are still visible on the LCD even if dithering is not enabled. Here is the command I am running:
./lv_img_conv.js img.png -f -c CF_TRUE_COLOR_CHROMA -o ~/work/lv_newproj/lv_sim_eclipse_sdl/test.c -i test_img
I am then using the resulting image in the PC simulator by creating an image object and setting its source - no other changes.
When I tried putting the simulator in 16bpp mode, I can see that the edges of the hand might be very slightly pink, but only if I zoom in on the individual pixels in GIMP. On the simulator itself I can't tell.
from lv_img_conv.
indexed should do an even better job as you can have a semi-transparent colors too. E.g. opa=25%, 50%, 75%, etc.
from lv_img_conv.
If transformations are also required you can do 4 things:
- Use chroma keying without having alpha channel (result in jagged edges)
- If you always place the images on this dark background you don't need alpha channel. Just use TRUE_COLOR format and the dark background on the image too
- Use TRUE_COLOR_ALPHA images (3 bytes/pixel)
- Use the new transformation feature of LVGL. It renders the widget into a buffer first and rotates that buffer. The only difference is that you need to use
style_transform_angle
andlv_img_set_angle()
. It will temporarily allocate a buffer equal to the size of the transformed widget. To great thing in it is that the children are transformed as well.
from lv_img_conv.
Original image used in both examples below to generate c array is slightly different than chroma colored image above. It leaves the dithering from original transparent image from above in place instead of making it all white.
Using the above as part of an invoke call to generate images from a provided folder produces the below image on LCD, hard to see but see a non-uniform pink edge around the image (so sounds like a 16bpp issue here, or indirectly an issue with how I was trying to leave dithering from png in place)
Using the above with dithering on, seeing a uniform pink edge around the image. Nominally would prefer to leave dithering on
Obviously a bit hard to see given the resolution of the screen against camera artifacts, but in all cases, LVGL is doing what its supposed to in not drawing the chroma color (0xFF00FF)
from lv_img_conv.
@tvanfossen Sorry for the delay in getting back to you. I'm still unable to reproduce this so I must be doing something wrong. I tried your second image with this command:
./lv_img_conv.js -d true -f -c CF_TRUE_COLOR_CHROMA -o hand.c hand.png
However, it looks perfect on my screen:
I don't doubt that there's an issue here, and your explanation makes sense. However, I need to figure out how to reproduce it to fix it. Did I miss something?
from lv_img_conv.
What color depth are you displaying on-screen? Could it be an issue only present in 565 displays?
from lv_img_conv.
from lv_img_conv.
These are the c array files being converted (with and without dithering)
I can confirm that I do not see this issue on the TFT simulator, but DO see this issue on the LCD
Tried both dithered and undithered c arrays on simulator and see no pink outline in either case. Simulator set to use color depth 16 with swap
On the LCD, the same c arrays both produce a pink outline
from lv_img_conv.
Overlaid the hand images onto a parent lv_obj_t grey circle as in the examples on LCD screen provided above for sanity, seeing the same case of no pink outline showing in simulator.
from lv_img_conv.
@kisvegabor Any ideas why SDL and an actual LCD would display an image differently, if they are both using the same color depth?
from lv_img_conv.
It seems there is a problem with the image:
So the image has alpha channel too. When I removed the Alpha channel in GIMP, the image looks like:
Okay, the extra pixels are not not pink but blue, but I believe it causes the problem.
from lv_img_conv.
interesting, odd that it converts to blue? For the SDL sim to not show an outline, but on an LCD to show, with the same bitmap, seems to imply a problem in the display driver as well?
from lv_img_conv.
Does the other colors look correct on your device? E.g. if you set the bg color of rectangle to lv_color_hex(0xff0000)
will it be red?
from lv_img_conv.
Yes, all other colors appear as intended
from lv_img_conv.
I have no idea why they turn to purple . 🙁 Probably we could track it, but I think there is no defined behavior (at least I not defined it when implemented the image renderers 😄 ) when chroma keying and alpha are used together.
Does chorma keying works well if you remove the alpha channel?
from lv_img_conv.
Removing every bit of transparency from PNG will give a properly colored image, but then results in jagged edges due to lack of dithering
Have tried a few different ways in gimp to keep the dithering in place while replacing alpha with chroma, with no luck
from lv_img_conv.
For an image like this I suggest using e.g. INDEXED_4BIT. With this you have 16colors in a palette and any of these colors can have any alpha value.
from lv_img_conv.
I'll give indexed a shot - was trying chroma keying to be able to layer images/widgets on top of each other nicely
from lv_img_conv.
Would there be any issues with that on an RGB565 screen without an alpha channel?
from lv_img_conv.
This 100% resolves the issue with dithering in chroma keying, but introduces a separate issue
When producing bitmaps from PNG assets (the hand png from above with alpha channel) with CF_INDEXED_8_BIT, image looks perfect on screen, exactly as desired.
However, rotation and zoom animations no longer perform as expected on these images. I might just be missing something simple as I havent used the indexed color in LVGL as of yet.
Which after a moment of checking the docs
So while an indexed image resolves the issue with chroma keying, it breaks animations that would otherwise be applied normally to a chroma keyed image
from lv_img_conv.
For reference, the same screen/animations with the chroma keyed image asset
from lv_img_conv.
Will give the transform a try!
from lv_img_conv.
Related Issues (20)
- Very slow script startup HOT 5
- Place converted images in current working directory HOT 1
- Windows error when running HOT 3
- R and B swap?
- Off-By-One Size Error When Converting Images To Alpha-Only C code HOT 4
- Online Image Converter with gif not work HOT 4
- ARGB1555 and ARGB4444 support HOT 18
- mac npm install error ! HOT 2
- Convert to CF_RAW_ALPHA return width and height zero HOT 14
- Push the newest version to NPM HOT 1
- Multiple byte characters filename support HOT 1
- Image Converter doesn't work with Firefox HOT 3
- GIFs will be converted to LV_IMG_CF_RAW_CHROMA_KEYED format HOT 2
- Android execution/port? HOT 1
- Error: swc compiler requires either @swc/core or @swc/wasm to be installed... HOT 2
- How do I specify the output directory? HOT 4
- Development version for v9 HOT 10
- Can't build/install on ubuntu18 HOT 4
- An exception occurred during image conversion. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lv_img_conv.