Image tutorial have issue?

Thanks for replying…

I’d got eclipse work in linux, got same result as codeblocks in windows, here’s the warnings:

Warn: Image draw cannot open the image resource |(…/lvgl/src/lv_draw/lv_img_cache.c #118)
Warn: Image draw error |(…/lvgl/src/lv_draw/lv_draw_img.c #61)

Just a thought… can you make sure you have this commit in lv_examples?

If you do, can you find out exactly what the error returned from fopen in pcfs_open is? You’ll have to check the errno variable after the call to fopen. Doing printf("error: %s\n", strerror(errno)); should work.

Sure, let me see…

I checked, didn’t have that commit, so I changed it as the commit do.
the code is :

    pc_file_t f = fopen(buf, flags);
    printf("error: %s\n", strerror(errno));
    //if((long int)f <= 0) return LV_FS_RES_UNKNOWN;
    if(f == NULL) return LV_FS_RES_UNKNOWN;	

below is all the output:
error: Success
error: Success
error: Success
error: Success
Warn: Image draw cannot open the image resource (…/lvgl/src/lv_draw/lv_img_cache.c #118)
Warn: Image draw error (…/lvgl/src/lv_draw/lv_draw_img.c #61)
error: Success
Warn: Image draw cannot open the image resource (…/lvgl/src/lv_draw/lv_img_cache.c #118)
Warn: Image draw error (…/lvgl/src/lv_draw/lv_draw_img.c #61)
error: Success
Warn: Image draw cannot open the image resource (…/lvgl/src/lv_draw/lv_img_cache.c #118)
Warn: Image draw error (…/lvgl/src/lv_draw/lv_draw_img.c #61)
error: Success
Warn: Image draw cannot open the image resource (…/lvgl/src/lv_draw/lv_img_cache.c #118)
Warn: Image draw error (…/lvgl/src/lv_draw/lv_draw_img.c #61)
error: Success
Warn: Image draw cannot open the image resource (…/lvgl/src/lv_draw/lv_img_cache.c #118)
Warn: Image draw error (…/lvgl/src/lv_draw/lv_draw_img.c #61)
error: Success
Warn: Image draw cannot open the image resource (…/lvgl/src/lv_draw/lv_img_cache.c #118)
Warn: Image draw error (…/lvgl/src/lv_draw/lv_draw_img.c #61)
error: Success
Warn: Image draw cannot open the image resource (…/lvgl/src/lv_draw/lv_img_cache.c #118)
Warn: Image draw error (…/lvgl/src/lv_draw/lv_draw_img.c #61)
error: Success
Warn: Image draw cannot open the image resource (…/lvgl/src/lv_draw/lv_img_cache.c #118)
Warn: Image draw error (…/lvgl/src/lv_draw/lv_draw_img.c #61)
error: Success
Warn: Image draw cannot open the image resource (…/lvgl/src/lv_draw/lv_img_cache.c #118)
Warn: Image draw error (…/lvgl/src/lv_draw/lv_draw_img.c #61)
error: Success
Warn: Image draw cannot open the image resource (…/lvgl/src/lv_draw/lv_img_cache.c #118)
Warn: Image draw error (…/lvgl/src/lv_draw/lv_draw_img.c #61)
error: Success
Warn: Image draw cannot open the image resource (…/lvgl/src/lv_draw/lv_img_cache.c #118)
Warn: Image draw error (…/lvgl/src/lv_draw/lv_draw_img.c #61)
error: Success
Warn: Image draw cannot open the image resource (…/lvgl/src/lv_draw/lv_img_cache.c #118)
Warn: Image draw error (…/lvgl/src/lv_draw/lv_draw_img.c #61)
error: Success
Warn: Image draw cannot open the image resource (…/lvgl/src/lv_draw/lv_img_cache.c #118)
Warn: Image draw error (…/lvgl/src/lv_draw/lv_draw_img.c #61)
error: Success
Warn: Image draw cannot open the image resource (…/lvgl/src/lv_draw/lv_img_cache.c #118)
Warn: Image draw error (…/lvgl/src/lv_draw/lv_draw_img.c #61)
error: Success
Warn: Image draw cannot open the image resource (…/lvgl/src/lv_draw/lv_img_cache.c #118)
Warn: Image draw error (…/lvgl/src/lv_draw/lv_draw_img.c #61)
error: Success
Warn: Image draw cannot open the image resource (…/lvgl/src/lv_draw/lv_img_cache.c #118)
Warn: Image draw error (…/lvgl/src/lv_draw/lv_draw_img.c #61)
error: Success
Warn: Image draw cannot open the image resource (…/lvgl/src/lv_draw/lv_img_cache.c #118)
Warn: Image draw error (…/lvgl/src/lv_draw/lv_draw_img.c #61)
error: Success
Warn: Image draw cannot open the image resource (…/lvgl/src/lv_draw/lv_img_cache.c #118)
Warn: Image draw error (…/lvgl/src/lv_draw/lv_draw_img.c #61)
error: Success
Warn: Image draw cannot open the image resource (…/lvgl/src/lv_draw/lv_img_cache.c #118)
Warn: Image draw error (…/lvgl/src/lv_draw/lv_draw_img.c #61)
error: Success
Warn: Image draw cannot open the image resource (…/lvgl/src/lv_draw/lv_img_cache.c #118)
Warn: Image draw error (…/lvgl/src/lv_draw/lv_draw_img.c #61)
error: Success
Warn: Image draw cannot open the image resource (…/lvgl/src/lv_draw/lv_img_cache.c #118)
Warn: Image draw error (…/lvgl/src/lv_draw/lv_draw_img.c #61)
used: 3336 ( 3 %), frag: 1 %, biggest free: 127648
used: 3336 ( 3 %), frag: 1 %, biggest free: 127648
used: 3336 ( 3 %), frag: 1 %, biggest free: 127648
used: 3336 ( 3 %), frag: 1 %, biggest free: 127648
used: 3336 ( 3 %), frag: 1 %, biggest free: 127648
used: 3336 ( 3 %), frag: 1 %, biggest free: 127648
used: 3336 ( 3 %), frag: 1 %, biggest free: 127648

Odd; that means it’s finding the file just fine.

As I see, the file should be checked to exist before the next step.

That’s what if(f == NULL) does. fopen returns NULL if opening the file failed for any reason. The issue must be somewhere else, as errno is 0, meaning success.

To make it clear, I print the path+name stored in buf:

./lv_examples/lv_tutorial/6_images/blue_flower_32.bin
error: Success
./lv_examples/lv_tutorial/6_images/blue_rose_16.bin
error: Success
./lv_examples/lv_tutorial/6_images/flower_icon_alpha.bin
error: Success
./lv_examples/lv_tutorial/6_images/blue_flower_32.bin
error: Success
Warn: Image draw cannot open the image resource (…/lvgl/src/lv_draw/lv_img_cache.c #118)
Warn: Image draw error (…/lvgl/src/lv_draw/lv_draw_img.c #61)
./lv_examples/lv_tutorial/6_images/blue_flower_32.bin
error: Success
Warn: Image draw cannot open the image resource (…/lvgl/src/lv_draw/lv_img_cache.c #118)
Warn: Image draw error (…/lvgl/src/lv_draw/lv_draw_img.c #61)
./lv_examples/lv_tutorial/6_images/blue_flower_32.bin
error: Success
Warn: Image draw cannot open the image resource (…/lvgl/src/lv_draw/lv_img_cache.c #118)
Warn: Image draw error (…/lvgl/src/lv_draw/lv_draw_img.c #61)
./lv_examples/lv_tutorial/6_images/blue_flower_32.bin
error: Success
Warn: Image draw cannot open the image resource (…/lvgl/src/lv_draw/lv_img_cache.c #118)
Warn: Image draw error (…/lvgl/src/lv_draw/lv_draw_img.c #61)
./lv_examples/lv_tutorial/6_images/blue_flower_32.bin
error: Success
Warn: Image draw cannot open the image resource (…/lvgl/src/lv_draw/lv_img_cache.c #118)
Warn: Image draw error (…/lvgl/src/lv_draw/lv_draw_img.c #61)
./lv_examples/lv_tutorial/6_images/blue_flower_32.bin
error: Success
Warn: Image draw cannot open the image resource (…/lvgl/src/lv_draw/lv_img_cache.c #118)
Warn: Image draw error (…/lvgl/src/lv_draw/lv_draw_img.c #61)
./lv_examples/lv_tutorial/6_images/blue_flower_32.bin
error: Success
Warn: Image draw cannot open the image resource (…/lvgl/src/lv_draw/lv_img_cache.c #118)
Warn: Image draw error (…/lvgl/src/lv_draw/lv_draw_img.c #61)
./lv_examples/lv_tutorial/6_images/blue_flower_32.bin
error: Success
Warn: Image draw cannot open the image resource (…/lvgl/src/lv_draw/lv_img_cache.c #118)
Warn: Image draw error (…/lvgl/src/lv_draw/lv_draw_img.c #61)
./lv_examples/lv_tutorial/6_images/blue_rose_16.bin
error: Success
Warn: Image draw cannot open the image resource (…/lvgl/src/lv_draw/lv_img_cache.c #118)
Warn: Image draw error (…/lvgl/src/lv_draw/lv_draw_img.c #61)
./lv_examples/lv_tutorial/6_images/blue_rose_16.bin
error: Success
Warn: Image draw cannot open the image resource (…/lvgl/src/lv_draw/lv_img_cache.c #118)
Warn: Image draw error (…/lvgl/src/lv_draw/lv_draw_img.c #61)
./lv_examples/lv_tutorial/6_images/blue_rose_16.bin
error: Success
Warn: Image draw cannot open the image resource (…/lvgl/src/lv_draw/lv_img_cache.c #118)
Warn: Image draw error (…/lvgl/src/lv_draw/lv_draw_img.c #61)
./lv_examples/lv_tutorial/6_images/blue_rose_16.bin
error: Success
Warn: Image draw cannot open the image resource (…/lvgl/src/lv_draw/lv_img_cache.c #118)
Warn: Image draw error (…/lvgl/src/lv_draw/lv_draw_img.c #61)
./lv_examples/lv_tutorial/6_images/blue_rose_16.bin
error: Success
Warn: Image draw cannot open the image resource (…/lvgl/src/lv_draw/lv_img_cache.c #118)
Warn: Image draw error (…/lvgl/src/lv_draw/lv_draw_img.c #61)
./lv_examples/lv_tutorial/6_images/blue_rose_16.bin
error: Success
Warn: Image draw cannot open the image resource (…/lvgl/src/lv_draw/lv_img_cache.c #118)
Warn: Image draw error (…/lvgl/src/lv_draw/lv_draw_img.c #61)
./lv_examples/lv_tutorial/6_images/blue_rose_16.bin
error: Success
Warn: Image draw cannot open the image resource (…/lvgl/src/lv_draw/lv_img_cache.c #118)
Warn: Image draw error (…/lvgl/src/lv_draw/lv_draw_img.c #61)
./lv_examples/lv_tutorial/6_images/blue_rose_16.bin
error: Success
Warn: Image draw cannot open the image resource (…/lvgl/src/lv_draw/lv_img_cache.c #118)
Warn: Image draw error (…/lvgl/src/lv_draw/lv_draw_img.c #61)
./lv_examples/lv_tutorial/6_images/flower_icon_alpha.bin
error: Success
Warn: Image draw cannot open the image resource (…/lvgl/src/lv_draw/lv_img_cache.c #118)
Warn: Image draw error (…/lvgl/src/lv_draw/lv_draw_img.c #61)
./lv_examples/lv_tutorial/6_images/flower_icon_alpha.bin
error: Success
Warn: Image draw cannot open the image resource (…/lvgl/src/lv_draw/lv_img_cache.c #118)
Warn: Image draw error (…/lvgl/src/lv_draw/lv_draw_img.c #61)
./lv_examples/lv_tutorial/6_images/flower_icon_alpha.bin
error: Success
Warn: Image draw cannot open the image resource (…/lvgl/src/lv_draw/lv_img_cache.c #118)
Warn: Image draw error (…/lvgl/src/lv_draw/lv_draw_img.c #61)
./lv_examples/lv_tutorial/6_images/flower_icon_alpha.bin
error: Success
Warn: Image draw cannot open the image resource (…/lvgl/src/lv_draw/lv_img_cache.c #118)
Warn: Image draw error (…/lvgl/src/lv_draw/lv_draw_img.c #61)
./lv_examples/lv_tutorial/6_images/flower_icon_alpha.bin
error: Success
Warn: Image draw cannot open the image resource (…/lvgl/src/lv_draw/lv_img_cache.c #118)
Warn: Image draw error (…/lvgl/src/lv_draw/lv_draw_img.c #61)
used: 3336 ( 3 %), frag: 1 %, biggest free: 127648
used: 3336 ( 3 %), frag: 1 %, biggest free: 127648
used: 3336 ( 3 %), frag: 1 %, biggest free: 127648

It looks like when fopen success, it’s in pc_simulator_sdl_eclipse folder, when warnings come, it’s in debug folder

Look the warnings, …/, isn’t that a bug? did not notice.

I think that path comes from __FILE__, which is part of the compiler and not related to LittlevGL. It probably doesn’t show the absolute path of the file, but just the relative path.

dear all:
I already find about this question
Snipaste_2022-04-25_11-25-00

This is need correct image path.
such as follow:

image