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

PNG test on lv_port_stm32f429_disco #16

Open
WiktorBAbove opened this issue May 6, 2021 · 9 comments
Open

PNG test on lv_port_stm32f429_disco #16

WiktorBAbove opened this issue May 6, 2021 · 9 comments

Comments

@WiktorBAbove
Copy link

Hello
Im trying to load the basic example on a stm32f429 discovery board.
Im not doing anything unusual,

    lv_init();
    tft_init();
    lv_png_init();
    .
    .
    .

    LV_IMG_DECLARE(png_decoder_test);
    lv_obj_t * imgpng = lv_img_create(lv_scr_act(), NULL);
    lv_img_set_src(imgpng, &png_decoder_test);
    lv_obj_align(imgpng, NULL, LV_ALIGN_CENTER, 0, 0);

The only thing I get on the screen is:

No
data

I just have one image, but I've #define LV_IMG_CACHE_DEF_SIZE 2
Is there anything else I need to think about?
Im using "7faf20592598e7f891cf2aceca32bbe6ff5fc36c"

@kisvegabor
Copy link
Member

Probably you are out of memory.

I've added a smaller png_decoder_test image. Does it work with that?

@WiktorBAbove
Copy link
Author

WiktorBAbove commented May 7, 2021

That worked well!
I have tried to convert myown png to 50x50 like png_decoder_test.

const lv_img_dsc_t png_decoder_test = {
  .header.always_zero = 0,
  .header.w = 50,
  .header.h = 50,
  .data_size = 5158,
  .header.cf = LV_IMG_CF_RAW_ALPHA,
  .data = png_decoder_test_map,
};

and mine is:

const lv_img_dsc_t testtubeslab2 = {
  .header.always_zero = 0,
  .header.w = 50,
  .header.h = 50,
  .data_size = 3727,
  .header.cf = LV_IMG_CF_RAW_ALPHA,
  .data = testtubeslab2_map,
};

It is smaller in size however it is showing just a bold text PNG on the screen.
I converted it by:
php ../lv_utils/img_conv_core.php "name=testtubeslab2&img=./png/testtubeslab2.png&format=c_array&cf=raw_alpha"
I am using php7.4-gd and php7.4-cli if that matters?
Am i missing something crucial for it to work?

@kisvegabor
Copy link
Member

Could you send the PNG image you used?

@WiktorBAbove
Copy link
Author

I think i figured out what was wrong!

  1. resized the original with windows10's builtin converter (powertoys)
  2. resized with imagick (convert)
    What I got was interesting:
  1. 3071bytes
  2. 3727bytes

Both files can be opened and viewed. However the current decoder cant handle an image that is resized with Imagick.
convert orig.png -resize 50x50 resized.png

Now I've actually managed to combine, a transparent PNG together with a 320x240 transparent GIF animation, without graphical issues.

I suppose we can close this issue, thank you for quick response! and your work!

@embeddedt
Copy link
Member

I'd be curious to know if the same issue happens when converting the PNG to LVGL format using the experimental JS converter. There are many variants of PNG and the PHP converter tends to fail on several of them.

@WiktorBAbove
Copy link
Author

@embeddedt:
Since you mentioned it, I have done the same test, but with the experimental "JS converter". It seems to work even though i converted it with Imagick with some extra bytes.
What is missing is the correct image-description of size,h and w in the generated C-file which I needed to update, or else "no bueno"
Other than that; maybe a 80char width would be more estethicaly appealing.

@embeddedt
Copy link
Member

What is missing is the correct image-description of size,h and w in the generated C-file which I needed to update, or else "no bueno"

Are you referring to the struct generated at the end of the file? That is using the dimension data provided by the browser, which should match the dimensions of the PNG file. If it's not matching, please provide the PNG file so I have something to replicate the issue with.

@WiktorBAbove
Copy link
Author

So i tried: https://blog.lvgl.io/assets/png_converter/png_decoder_test.png
All color formats give good dimensions, except all the RAW color formats selections where the dimensions have been zeroed out also the datasize.
The experimental one puts just zeroes on :

  .header.w = 0,
  .header.h = 0,
  .data_size = 0,

Note: the current image converter doesnt add the zeroes for the dimension but gives good .data_size on all RAW color formats.

@embeddedt
Copy link
Member

embeddedt commented May 11, 2021

Dimensions being 0 are intended, as the RAW feature actually allows you to convert any type of file. For a PNG image, the PNG decoder will take care of finding the width and height from the PNG data at runtime. I don't think you're supposed to have to add them by hand - @kisvegabor is this a bug in the PHP converter?

Data size being 0 is a bug on mine which should be fixed now. I also added line breaks for RAW images as it's easier to do there.

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

3 participants