Image tutorial have issue?

lvgl_image

It’s run in codeblocks on windows 7
The images from files can’t be displayed, tried to put files in the exe file path, don’t work.

Also tried changing “sprintf(buf, “./%s”, fn);” to “sprintf(buf, “…/…/%s”, fn);” , still don’t work

Can you find out the working directory of the process when it’s running (possibly using getcwd)?

Yeah, that’s where I copied files of images to, when I did this, I also changed path like “P:/lv_examples/lv_tutorial/6_images/blue_flower_8.bin” to “P:/blue_flower_8.bin”, and keep “sprintf(buf, “./%s”, fn);” not changed

In this way, there would be no “No data”, but blank areas.

Maybe you should use \ instead of /.

Just tried that, not work.
Also tried “blue_flower_8.bin” way, not work.

By not work here, I mean there’re no “No data”, but blank areas.

You should turn on logging in lv_conf.h:

  • LV_USE_LOG 1
  • LV_LOG_PRINTF 1

What log messages do you see?

I turned on the logging as you say, but didn’t see any log info in Debugger window.

So I set a breakpoint at line 177 of lv_tutorial_images.c:
lv_img_set_src(img_bin, “blue_rose_16.bin”);

and traced in, at line 409 of lv_draw_img.c:
const uint8_t * u8_p = src;

I see u8_p got a value of 0x466400<red_flower>, then img_src_type would be 0, that’s LV_IMG_SRC_VARIABLE…

So, seems u8_p got a wrong value of 0x466400 is the keypoint of the issue, any ideas on that?

Sorry, I realized that 0x466400 is come from previous call, not the line 177 of lv_tutorial_images.c I want to see.

So here’s right result:
u8_p: 0x4afb73 <flower_icon_alpha_map+1299> “blue_rose_16.bin”
img_src_type: LV_IMG_SRC_FILE

It looks good…?

It’s not good if flower_icon_alpha_map+1299 is shown for blue_rose_16.bin.
For the screenshot, it’s clear that the “red” flowers are working which come from the RAM (C files) and the “blue” flowers have the issue (come from bin files.)

I suggest creating a text.txt file, place it next to the bin images and try to open it with
lv_fs_res_t res = lv_fs_open. (similarly to the images) What is the value of res?

I tried it, res is LV_FS_RES_NOT_EX when path is “text.txt”, and LV_FS_RES_UNKNOWN when path is “P:/text.txt” or “P:\text.txt”

P: is required in the path in lv_fs_open to tell LittlevGL which “driver” to use.

Can you open the file directly with fopen? (No “P:” is required here)

res is LV_FS_RES_NOT_EX when path is “text.txt”

if you mean pcfs_open by fopen, please provide an example on how to use it

fopen is not part of LittlevGL. It’s a “standard” C function to open a file.
See: https://www.tutorialspoint.com/c_standard_library/c_function_fopen.htm

Thank you, I’m not familiar in windows programming.

I tried the example in your link, it don’t work running in codeblocks, but works if I call it in command line

here’s the result running in codeblocks:
Process returned -1073741819 (0xC0000005) execution time : 1.873 s
Press any key to continue.

I also tried to run lvgl program in command line, though, it still don’t work

Sorry, but dealing with fopen is out of scope for LittlevGL. There are plenty of tutorials about it.
Please try to make it work on your system (open, write, read a file).

Actually, fopen works in command line, but lvgl program don’t

It should work in both. Did you try just calling fopen at the beginning of main?