lvgl / lv_port_pc_vscode

MIT License
250 stars 154 forks source link

When using LV_USE_DRAW_SDL, all images cannot be displayed. #44

Open sliang951753 opened 4 months ago

sliang951753 commented 4 months ago

There's two issues when using LV_USE_DRAW_SDL option in cmake.

  1. If LV_USE_DRAW_SDL option is enabled, it will cause the redefinition error because the macro LV_USE_DRAW_SDL already be defined in lv_conf.h file.
  2. If using sdl draw unit to run the widget demo, all images cannot be displayed. The console will continuously output the error "could not load image: SDL_RWFromFile(): No file or no mode specified"
kisvegabor commented 4 months ago

I started to work on completing the SDL renderer here: https://github.com/lvgl/lvgl/pull/6437

If LV_USE_DRAW_SDL option is enabled, it will cause the redefinition error because the macro LV_USE_DRAW_SDL already be defined in lv_conf.h file.

If you enable this option via CMake, you can remove LV_USE_DRAW_SDL from lv_conf.h

If using sdl draw unit to run the widget demo, all images cannot be displayed. The console will continuously output the error "could not load image: SDL_RWFromFile(): No file or no mode specified"

I'll resolve it in https://github.com/lvgl/lvgl/pull/6437

sliang951753 commented 4 months ago

Please help to check the RGB mask value in draw image task of SDL draw unit. I saw currently only 32bit color can work. For other color format (such as rgb565),the SDL will report color mask error.

kisvegabor commented 4 months ago

Is it with LVGL v8 or v9?

sliang951753 commented 4 months ago

Is it with LVGL v8 or v9?

v9

kisvegabor commented 4 months ago

I've tried the lv_demo_widgets() with LV_COLOR_DEPTH 16 and lvgl master. It worked well for me.

Have you installed libsdl2-image-dev?

sliang951753 commented 4 months ago

The problem is when the bpp of an image is not 32. for example, bpp = 16, then the R mask is 0x001F instead of 0x000000FF If you pass 0x000000FF to the SDL_CreateRGBSurfaceFrom function, it will report "Unknown pixel format " error. This can be reproduced by running the benchmark. For demo widgets, its ok.

kisvegabor commented 4 months ago

Oh I see. I can't see just a dirty fix to resolve it, however https://github.com/lvgl/lvgl/pull/6437 should fix it.