When creating an image object, the background is always white with the text “No data” in the top left corner.
I want to change the background to black, and get rid of the text.
What MCU/Processor/Board and compiler are you using?
N/A
What LVGL version are you using?
v7
What do you want to achieve?
I want to make image objects that are empty (no actual image data) to appear differently than they do.
I suspect that the background color is hardcoded at the moment. I will need to look into whether it’s possible to use the background color from the styles.
It’s really hardcoded now but the problem is that the drawing functions don’t see the object itself, only areas and properties to draw. Hence the image drawer can’t see the image object to get its bg color.
At the very least, an empty image object should show nothing. Then at least a plain object with the same size can be used as the background.
Right now, white + text is not ideal, especially hard coded.
For my purpose, I “fixed” this by using a black object behind the image, and set the image size to 0x0 pixels when there is no data.
This way, the image area looks like a black box when there is no image data, then when there is image data I align it to the center of the black object, so there is still a black background.
Basically I wanted an image placeholder even when there is no data (the image data comes in live over the air and can change at any time/not yet exist). So I have essentially solved that problem but in a roundabout way.
In general I am not a fan of things like the hard coded “No\rData” or even “Text” as the default text for a label… wastes code space, etc. when you are just going to change it anyway (and if you want it blank, you have to explicitly set it to a blank string). But that is just my opinion…
If you are thinking of images included in the UI design itself, then generally there should be an image available. But if you think of, say, an image viewer application developed in LVGL, using an LVGL image object to display a user selected image, then there are plenty of use cases where the image is not “available immediately”, like the user hasn’t selected one, uploaded it, etc., like this: