Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load PNG from variable #9

Closed
beckmx opened this issue Feb 13, 2021 · 3 comments
Closed

Load PNG from variable #9

beckmx opened this issue Feb 13, 2021 · 3 comments

Comments

@beckmx
Copy link

beckmx commented Feb 13, 2021

Hello, guys, I have a doubt, if I follow the instructions to load data from the .c file, it loads, then if I provide the file directly with bytes, it shows me the "No data" message but in the log it says, it recognizes the file type, this is the snipet:

uint8_t tmp_img[20869];
File f = SPIFFS.open("/test.png", "r");
          Serial.print("Size:");
          Serial.println(f.size());
          if (f) {
            Serial.print("Bytes read:");
            Serial.println(f.readBytes((char *)tmp_img, f.size()));
            f.close();
          }
          const lv_img_header_t png_decoder_test_map_header2 = {
          LV_IMG_CF_RAW_ALPHA,
          0,
          2,
          200,
          150
          };
          const lv_img_dsc_t png_decoder_test2 = {
          png_decoder_test_map_header2,
          20869,
          tmp_img
          };
          lv_img_set_src(img1, &png_decoder_test2);

It does provide the bytes from what I can see and the logs say:

Size:20869
Bytes read:20869
Info: lv_img_set_src:  `LV_IMG_SRC_VARIABLE` type found 	(lv_img.c #180 lv_img_set_src())
Data x48
Data y118
Info: image draw: cache miss, close and reuse an entry 	(lv_img_cache.c #120 _lv_img_cache_open())
Warn: Image draw cannot open the image resource 	(lv_img_cache.c #135 _lv_img_cache_open())
Warn: Image draw error 	(lv_draw_img.c #88 lv_draw_img())

So, right afer it extracts the bytes it just goes directly to "No data"

@kisvegabor
Copy link
Member

The only I can imagine tmp_img is a local variable and goes out of the scope (hence destroyed).

What if you make it static uint8_t tmp_img[20869];?

@beckmx
Copy link
Author

beckmx commented Feb 16, 2021

Well I tried also, still getting the no data, that variable was defined at the top of my file, noton a scoped structure though

@beckmx
Copy link
Author

beckmx commented Feb 16, 2021

Ok, I am going to close it, I could load the image from flash which is an huge step forward

@beckmx beckmx closed this as completed Feb 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants