How to convert png to RB_565 on Android

Description

I have on a esp32 BLE, and lvgl running.
The application on esp32, should show one image, with different content.

What MCU/Processor/Board and compiler are you using?

esp32

What LVGL version are you using?

v7

What do you want to achieve?

I have a Android device, which is sending png to esp32,
on esp32, currently it is decoded by lvgl (lodepng) decoder.
After 3-4 times changing pictures, I run out of memory :frowning:

What have you tried so far?

Now, to get away from decoder, I thought, convert the png to rgb_565 on the android device.
to be honest, my knowledge in pictures, and color pallets and pictures formats, is not really good :frowning:

Thanks for your support !!!
Great stuff, what you guys are doing here !

What is LV_IMG_CACHE_DEF_SIZE in lv_conf.h or menuconfig?

I put it to 2.
Sorry for the long delay…
In general it is all working, but I still need to use the external loadpng.

So, Maybe I can reduce using memory, If I can already send the convert png to the esp32…

                            ByteArrayOutputStream stream = null;
                            Bitmap bitmap = ((BitmapDrawable) dr).getBitmap();
                            stream = new ByteArrayOutputStream();
                            bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
                            byte[] sendByte = stream.toByteArray().clone();
                            outMsgNavIcon = Base64.encode(sendByte, 0).clone();

Bitmap has the possibility during create, give options for Bitmap.Config.RGB_565, but not sure how to use.