How to upscale an icon without lv_img_set_zoom

What LVGL version are you using?

LvGL 8.3.9

What do you want to achieve?

To save memory I m using monochrome icon, CF_ALPHA_1BIT, so the fonction lv_img_set_zoom() don’t work for them.
Someone have a way or an idea to upscale them ? The operation need to be done only at start depending of the device resolution, so I haven’t performance issue.

why not make the icon larger using a paint program on a PC??

You do realize that alpha 1 bit color format is not for monochrome right?. You want to be using a 1 bit grayscale format which I am not sure is supported by LVGL. I see indexed color formats and your typical RGB color formats but nothing specifically intended for monochrome. I am assuming by monochrome you mean there is only 2 “colors” dark and light. That would be a 1 bit per pixel color format.

Someone else would have to chime in here on this.

What I am getting at is the color format you are using for a monochrome image is 16 bits per pixel and if you only have 2 color possibilities then using that color format is going to be a horrific waste of memory and also storage. If you used a monochrome image format that is 1 bit per pixel you could just make the size of the image larger in a paint program on a PC You would have top make the image some 16 times larger before it would end up using the same amount of ram/flash as the original sized one using a 16bpp color format.

a 20 x 20 image in 16bpp is going to take up 800 bytes of ram and I am not sure on the flash. with a 1bpp color format that same 20 x 20 image is going to take up 50 bytes or ram and it will look exactly identical if you are only using 2 colors. an 80 x 80 x 1bpp image takes up the same amount of ram as a 20 x 20 x 16bpp image if only 2 colors are being used.

See what I am getting at with this.

IDK if LVGL supports anything lower than a 16bpp color format. For some reason I don’t think it does.

Yep it’s 2 color file, I m using Alpha for transparency (icons are recolorised)

const lv_img_dsc_t blinds35x35 = { = LV_IMG_CF_ALPHA_1BIT,
  .header.always_zero = 0,
  .header.reserved = 0,
  .header.w = 35,
  .header.h = 35,
  .data_size = 175,
  .data = blinds35x35_map,

My problem is to avoid to make more than 1 “icons set”, I prefer resize them during the application launch.

No one have already tried to create a icon dynamically using a small one ?

Else I can use the same C file for 2 formats (at least) and use #define to select one map or another. But it will mean more work, and only 2 sizes possibles.

take a look at the canvas widget it might be able to do what you want.

Ha yes, it’s something new for me, but I can probably make something with them.

I am not all that familiar with lvgl 8.3. you might need to upgrade to 9.0 in order to do it. I would have to look at the API. Maybe @kisvegabor would know to do what you want.

Just to confirm, so you have enough RAM to store the upscaled images, right? I want to clarify this first, as it’s very rare the you don’t have enough flash, but has plenty of RAM.

Yes, it’s not a RAM issue.
In fact the code can be used on different devices, with different resolutions. All the code is dynamic (I m using absolute values in percent), so widget dimension adapt themself to the resolution, but not icons.

Using Alpha 8 bit still an option for you?

If so, this feature of LVGL v9 could be really useful.

lv_image_set_inner_align(image, LV_IMAGE_ALIGN_STRETCH) automatically scales the image to cover the width/height you set. You need to use A8, as A1/2/4 cannot be scaled.

IDK, I will take a look on canvas this Week End.
But Alpha 8 bit mean 8 time more bigger size than 1 Bit, and my code is still on 8.3.9.

I can make too an algorithm that can double the table data, I don’t think it will be so hard with 1 bit.