Coder Social home page Coder Social logo

lv_lib_png's Introduction

English | 中文 | Português do Brasil | 日本語


 

 

Light and Versatile Graphics Library

 

   

Website | Docs | Forum | Demos | Services


📒 Overview

Mature and Well-known
LVGL is the most popular free and open source embedded graphics library to create beautiful UIs for any MCU, MPU and display type. It's supported by industry leading vendors and projects like  Arm, STM32, NXP, Espressif, Nuvoton, Arduino, RT-Thread, Zephyr, NuttX, Adafruit and many more.

Feature Rich
It has all the features to create modern and beautiful GUIs: 30+ built-in widgets, a powerful style system, web inspired layout managers, and a typography system supporting many languages. To integrate LVGL into your platform, all you need is at least 32kB RAM and 128 kB Flash, a C compiler, a frame buffer, and at least an 1/10 screen sized buffer for rendering.

Services
Our team is ready to help you with graphics design, UI implementation and consulting services. Contact us if you need some support during the development of your next GUI project.

🚀 Features

Free and Portable

  • A fully portable C (C++ compatible) library with no external dependencies.
  • Can be compiled to any MCU or MPU, with any (RT)OS.
  • Supports monochrome, ePaper, OLED or TFT displays, or even monitors. Porting Guide
  • Distributed under the MIT license, so you can easily use it in commercial projects too.
  • Needs only 32kB RAM and 128 kB Flash, a frame buffer, and at least an 1/10 screen sized buffer for rendering.
  • OS, External memory and GPU are supported but not required.

Widgets, Styles, Layouts and more

  • 30+ built-in Widgets:  Button, Label, Slider, Chart, Keyboard, Meter, Arc, Table and many more.
  • Flexible Style system with  ~100 style properties to customize any part of the widgets in any state.
  • Flexbox and Grid-like layouts engines to automatically size and position the widgets in a responsive way.
  • Texts are rendered with UTF-8 encoding supporting CJK, Thai, Hindi, Arabic, Persian writing systems.
  • Word wrapping, kerning, text scrolling, sub-pixel rendering, Pinyin-IME Chinese input, Emojis in texts.
  • Rendering engine supporting animations, anti-aliasing, opacity, smooth scrolling, shadows, image transformation, etc  
  • Supports Mouse, Touchpad, Keypad, Keyboard, External buttons, Encoder Input devices.
  • Multiple display support.

Binding and Build Support

  • Micropython Binding exposes LVGL API
  • PikaScript Binding python on MCU lighter and easier.
  • No custom build system is used. You can build LVGL as you build the other files of your project.
  • Support for Make and CMake is included out of the box.
  • Develop on PC and use the same UI code on embedded hardware.
  • Convert the C UI code to HTML file with our Emscripten port.

Docs, Tools, and Services

❤️ Sponsor

If LVGL saved you a lot of time and money or you just had fun using it, consider Supporting its Development.

How do we spend the donations?
Our goal is to provide financial compensation for people who do the most for LVGL. It means not only the maintainers but anyone who implements a great feature should get a payment from the accumulated money. We use the donations to cover our operational costs like servers and related services.

How to donate?
We use GitHub Sponsors where you can easily send one time or recurring donations. You can also see all of our expenses in a transparent way.

How to get paid for your contribution?
If someone implements or fixes an issue labeled as Sponsored he or she will get a payment for that work. We estimate the required time, complexity and importance of the issue and set a price accordingly. To jump in just comment on a Sponsored issue saying "Hi, I'd like to deal with it. This is how I'm planning to fix/implement it...". A work is considered ready when it's approved and merged by a maintainer. After that you can submit and expense at opencollective.com and you will receive the payment in a few days.

Organizations supporting LVGL
Sponsors of LVGL

Individuals supporting LVGL
Backers of LVGL

📦 Packages

LVGL is available as:

🤖 Examples

See some examples of creating widgets, using layouts and applying styles. You will find C and MicroPython code, and links to try out or edit the examples in an online MicroPython editor.

For more examples check out the Examples folder.

Hello world label

Simple Hello world label example in LVGL

C code
/*Change the active screen's background color*/
lv_obj_set_style_bg_color(lv_screen_active(), lv_color_hex(0x003a57), LV_PART_MAIN);

/*Create a white label, set its text and align it to the center*/
lv_obj_t * label = lv_label_create(lv_screen_active());
lv_label_set_text(label, "Hello world");
lv_obj_set_style_text_color(label, lv_color_hex(0xffffff), LV_PART_MAIN);
lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
MicroPython code | Online Simulator
# Change the active screen's background color
scr = lv.screen_active()
scr.set_style_bg_color(lv.color_hex(0x003a57), lv.PART.MAIN)

# Create a white label, set its text and align it to the center
label = lv.label(lv.screen_active())
label.set_text("Hello world")
label.set_style_text_color(lv.color_hex(0xffffff), lv.PART.MAIN)
label.align(lv.ALIGN.CENTER, 0, 0)

Button with Click Event

LVGL button with label example

C code
lv_obj_t * button = lv_button_create(lv_screen_active());                   /*Add a button to the current screen*/
lv_obj_center(button);                                             /*Set its position*/
lv_obj_set_size(button, 100, 50);                                  /*Set its size*/
lv_obj_add_event_cb(button, button_event_cb, LV_EVENT_CLICKED, NULL); /*Assign a callback to the button*/

lv_obj_t * label = lv_label_create(button);                        /*Add a label to the button*/
lv_label_set_text(label, "Button");                             /*Set the labels text*/
lv_obj_center(label);                                           /*Align the label to the center*/
...

void button_event_cb(lv_event_t * e)
{
  printf("Clicked\n");
}
MicroPython code | Online Simulator
def button_event_cb(e):
  print("Clicked")

# Create a Button and a Label
button = lv.button(lv.screen_active())
button.center()
button.set_size(100, 50)
button.add_event_cb(button_event_cb, lv.EVENT.CLICKED, None)

label = lv.label(button)
label.set_text("Button")
label.center()

Checkboxes with Layout

Checkboxes with layout in LVGL

C code
lv_obj_set_flex_flow(lv_screen_active(), LV_FLEX_FLOW_COLUMN);
lv_obj_set_flex_align(lv_screen_active(), LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER);

lv_obj_t * cb;
cb = lv_checkbox_create(lv_screen_active());
lv_checkbox_set_text(cb, "Apple");
lv_obj_add_event_cb(cb, event_handler, LV_EVENT_ALL, NULL);

cb = lv_checkbox_create(lv_screen_active());
lv_checkbox_set_text(cb, "Banana");
lv_obj_add_state(cb, LV_STATE_CHECKED);
lv_obj_add_event_cb(cb, event_handler, LV_EVENT_ALL, NULL);

cb = lv_checkbox_create(lv_screen_active());
lv_checkbox_set_text(cb, "Lemon");
lv_obj_add_state(cb, LV_STATE_DISABLED);
lv_obj_add_event_cb(cb, event_handler, LV_EVENT_ALL, NULL);

cb = lv_checkbox_create(lv_screen_active());
lv_obj_add_state(cb, LV_STATE_CHECKED | LV_STATE_DISABLED);
lv_checkbox_set_text(cb, "Melon\nand a new line");
lv_obj_add_event_cb(cb, event_handler, LV_EVENT_ALL, NULL);
MicroPython code | Online Simulator
def event_handler(e):
    code = e.get_code()
    obj = e.get_target_obj()
    if code == lv.EVENT.VALUE_CHANGED:
        txt = obj.get_text()
        if obj.get_state() & lv.STATE.CHECKED:
            state = "Checked"
        else:
            state = "Unchecked"
        print(txt + ":" + state)


lv.screen_active().set_flex_flow(lv.FLEX_FLOW.COLUMN)
lv.screen_active().set_flex_align(lv.FLEX_ALIGN.CENTER, lv.FLEX_ALIGN.START, lv.FLEX_ALIGN.CENTER)

cb = lv.checkbox(lv.screen_active())
cb.set_text("Apple")
cb.add_event_cb(event_handler, lv.EVENT.ALL, None)

cb = lv.checkbox(lv.screen_active())
cb.set_text("Banana")
cb.add_state(lv.STATE.CHECKED)
cb.add_event_cb(event_handler, lv.EVENT.ALL, None)

cb = lv.checkbox(lv.screen_active())
cb.set_text("Lemon")
cb.add_state(lv.STATE.DISABLED)
cb.add_event_cb(event_handler, lv.EVENT.ALL, None)

cb = lv.checkbox(lv.screen_active())
cb.add_state(lv.STATE.CHECKED | lv.STATE.DISABLED)
cb.set_text("Melon")
cb.add_event_cb(event_handler, lv.EVENT.ALL, None)

Styling a Slider

Styling a slider with LVGL

C code
lv_obj_t * slider = lv_slider_create(lv_screen_active());
lv_slider_set_value(slider, 70, LV_ANIM_OFF);
lv_obj_set_size(slider, 300, 20);
lv_obj_center(slider);

/*Add local styles to MAIN part (background rectangle)*/
lv_obj_set_style_bg_color(slider, lv_color_hex(0x0F1215), LV_PART_MAIN);
lv_obj_set_style_bg_opa(slider, 255, LV_PART_MAIN);
lv_obj_set_style_border_color(slider, lv_color_hex(0x333943), LV_PART_MAIN);
lv_obj_set_style_border_width(slider, 5, LV_PART_MAIN);
lv_obj_set_style_pad_all(slider, 5, LV_PART_MAIN);

/*Create a reusable style sheet for the INDICATOR part*/
static lv_style_t style_indicator;
lv_style_init(&style_indicator);
lv_style_set_bg_color(&style_indicator, lv_color_hex(0x37B9F5));
lv_style_set_bg_grad_color(&style_indicator, lv_color_hex(0x1464F0));
lv_style_set_bg_grad_dir(&style_indicator, LV_GRAD_DIR_HOR);
lv_style_set_shadow_color(&style_indicator, lv_color_hex(0x37B9F5));
lv_style_set_shadow_width(&style_indicator, 15);
lv_style_set_shadow_spread(&style_indicator, 5);
4
/*Add the style sheet to the slider's INDICATOR part*/
lv_obj_add_style(slider, &style_indicator, LV_PART_INDICATOR);

/*Add the same style to the KNOB part too and locally overwrite some properties*/
lv_obj_add_style(slider, &style_indicator, LV_PART_KNOB);

lv_obj_set_style_outline_color(slider, lv_color_hex(0x0096FF), LV_PART_KNOB);
lv_obj_set_style_outline_width(slider, 3, LV_PART_KNOB);
lv_obj_set_style_outline_pad(slider, -5, LV_PART_KNOB);
lv_obj_set_style_shadow_spread(slider, 2, LV_PART_KNOB);
MicroPython code | Online Simulator
# Create a slider and add the style
slider = lv.slider(lv.screen_active())
slider.set_value(70, lv.ANIM.OFF)
slider.set_size(300, 20)
slider.center()

# Add local styles to MAIN part (background rectangle)
slider.set_style_bg_color(lv.color_hex(0x0F1215), lv.PART.MAIN)
slider.set_style_bg_opa(255, lv.PART.MAIN)
slider.set_style_border_color(lv.color_hex(0x333943), lv.PART.MAIN)
slider.set_style_border_width(5, lv.PART.MAIN)
slider.set_style_pad_all(5, lv.PART.MAIN)

# Create a reusable style sheet for the INDICATOR part
style_indicator = lv.style_t()
style_indicator.init()
style_indicator.set_bg_color(lv.color_hex(0x37B9F5))
style_indicator.set_bg_grad_color(lv.color_hex(0x1464F0))
style_indicator.set_bg_grad_dir(lv.GRAD_DIR.HOR)
style_indicator.set_shadow_color(lv.color_hex(0x37B9F5))
style_indicator.set_shadow_width(15)
style_indicator.set_shadow_spread(5)

# Add the style sheet to the slider's INDICATOR part
slider.add_style(style_indicator, lv.PART.INDICATOR)
slider.add_style(style_indicator, lv.PART.KNOB)

# Add the same style to the KNOB part too and locally overwrite some properties
slider.set_style_outline_color(lv.color_hex(0x0096FF), lv.PART.KNOB)
slider.set_style_outline_width(3, lv.PART.KNOB)
slider.set_style_outline_pad(-5, lv.PART.KNOB)
slider.set_style_shadow_spread(2, lv.PART.KNOB)

English, Hebrew (mixed LTR-RTL) and Chinese texts

English, Hebrew and Chinese texts with LVGL

C code
lv_obj_t * ltr_label = lv_label_create(lv_screen_active());
lv_label_set_text(ltr_label, "In modern terminology, a microcontroller is similar to a system on a chip (SoC).");
lv_obj_set_style_text_font(ltr_label, &lv_font_montserrat_16, 0);
lv_obj_set_width(ltr_label, 310);
lv_obj_align(ltr_label, LV_ALIGN_TOP_LEFT, 5, 5);

lv_obj_t * rtl_label = lv_label_create(lv_screen_active());
lv_label_set_text(rtl_label,"מעבד, או בשמו המלא יחידת עיבוד מרכזית (באנגלית: CPU - Central Processing Unit).");
lv_obj_set_style_base_dir(rtl_label, LV_BASE_DIR_RTL, 0);
lv_obj_set_style_text_font(rtl_label, &lv_font_dejavu_16_persian_hebrew, 0);
lv_obj_set_width(rtl_label, 310);
lv_obj_align(rtl_label, LV_ALIGN_LEFT_MID, 5, 0);

lv_obj_t * cz_label = lv_label_create(lv_screen_active());
lv_label_set_text(cz_label,
                  "嵌入式系统(Embedded System),\n是一种嵌入机械或电气系统内部、具有专一功能和实时计算性能的计算机系统。");
lv_obj_set_style_text_font(cz_label, &lv_font_simsun_16_cjk, 0);
lv_obj_set_width(cz_label, 310);
lv_obj_align(cz_label, LV_ALIGN_BOTTOM_LEFT, 5, -5);
MicroPython code | Online Simulator
ltr_label = lv.label(lv.screen_active())
ltr_label.set_text("In modern terminology, a microcontroller is similar to a system on a chip (SoC).")
ltr_label.set_style_text_font(lv.font_montserrat_16, 0);

ltr_label.set_width(310)
ltr_label.align(lv.ALIGN.TOP_LEFT, 5, 5)

rtl_label = lv.label(lv.screen_active())
rtl_label.set_text("מעבד, או בשמו המלא יחידת עיבוד מרכזית (באנגלית: CPU - Central Processing Unit).")
rtl_label.set_style_base_dir(lv.BASE_DIR.RTL, 0)
rtl_label.set_style_text_font(lv.font_dejavu_16_persian_hebrew, 0)
rtl_label.set_width(310)
rtl_label.align(lv.ALIGN.LEFT_MID, 5, 0)

font_simsun_16_cjk = lv.font_load("S:../../assets/font/lv_font_simsun_16_cjk.fnt")

cz_label = lv.label(lv.screen_active())
cz_label.set_style_text_font(font_simsun_16_cjk, 0)
cz_label.set_text("嵌入式系统(Embedded System),\n是一种嵌入机械或电气系统内部、具有专一功能和实时计算性能的计算机系统。")
cz_label.set_width(310)
cz_label.align(lv.ALIGN.BOTTOM_LEFT, 5, -5)

▶️ Get started

This list will guide you to get started with LVGL step-by-step.

Get Familiar with LVGL

  1. Check the Online demos to see LVGL in action (3 minutes)
  2. Read the Introduction page of the documentation (5 minutes)
  3. Get familiar with the basics on the Quick overview page (15 minutes)

Start to Use LVGL

  1. Set up a Simulator (10 minutes)
  2. Try out some Examples
  3. Port LVGL to a board. See the Porting guide or check the ready to use Projects

Become a Pro

  1. Read the Overview page to get a better understanding of the library (2-3 hours)
  2. Check the documentation of the Widgets to see their features and usage

Get Help and Help Others

  1. If you have questions go to the Forum
  2. Read the Contributing guide to see how you can help to improve LVGL (15 minutes)

🤝 Services

LVGL LLC was established to provide a solid background for LVGL library and to offer several type of services to help you in UI development. With 15+ years of experience in the user interface and graphics industry we can help you the bring your UI to the next level.

  • Graphics design Our in-house graphics designers are experts in creating beautiful modern designs which fit to your product and the resources of your hardware.
  • UI implementation We can also implement your UI based on the design you or we have created. You can be sure that we will make the most out of your hardware and LVGL. If a feature or widget is missing from LVGL, don't worry, we will implement it for you.
  • Consulting and Support We can support you with consulting as well to avoid pricey and time consuming mistakes during the UI development.
  • Board certification For companies who are offering development boards, or production ready kits we do board certification which shows how board can run LVGL.

Check out our Demos as reference. For more information take look at the Services page.

Contact us and tell how we can help.

🌟 Contributing

LVGL is an open project and contribution is very welcome. There are many ways to contribute from simply speaking about your project, through writing examples, improving the documentation, fixing bugs or even hosting your own project under the LVGL organization.

For a detailed description of contribution opportunities visit the Contributing section of the documentation.

More than 300 people already left their fingerprint in LVGL. Be one them! See you here! 🙂

... and many other.

lv_lib_png's People

Contributors

ali-rostami avatar alsaleem00 avatar bku-sue avatar fastshift avatar glory-man avatar kisvegabor avatar leiflm avatar rzr avatar simonchen007 avatar varigigi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lv_lib_png's Issues

invalid ADLER32 while drawing image

I try to draw attached png on the screen and received error 58 - invalid ADLER32 encountered. At the same time, this image is normally opened by any desktop-image-viewer. Is this an image problem? Is it possible to fix it?
car

error: conflicting types for 'decoder_info'

Attempted to build using pio and I run into this error:

CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/m5stack-core2.html
PLATFORM: Espressif 32 (3.2.1) > M5Stack Core2
HARDWARE: ESP32 240MHz, 6.25MB RAM, 16MB Flash
DEBUG: Current (esp-prog) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
 - framework-espidf 3.40201.210513 (4.2.1)
 - tool-cmake 3.16.4
 - tool-esptoolpy 1.30000.201119 (3.0.0)
 - tool-idf 1.0.1
 - tool-mconf 1.4060000.20190628 (406.0.0)
 - tool-mkspiffs 2.230.0 (2.30)
 - tool-ninja 1.9.0
 - toolchain-esp32ulp 1.22851.191205 (2.28.51)
 - toolchain-xtensa32 2.80400.210211 (8.4.0)
Reading CMake configuration...
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 0 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio\build\core2foraws\components\lv_lib_png\lv_png.o
components\lv_lib_png\lv_png.c:31:37: warning: 'struct _lv_img_decoder_t' declared inside parameter list will not be visible outside of this definition or declaration
 static lv_res_t decoder_info(struct _lv_img_decoder_t * decoder, const void * src, lv_img_header_t * header);
                                     ^~~~~~~~~~~~~~~~~
components\lv_lib_png\lv_png.c: In function 'lv_png_init':
components\lv_lib_png\lv_png.c:54:37: warning: passing argument 2 of 'lv_img_decoder_set_info_cb' from incompatible pointer type [-Wincompatible-pointer-types]
     lv_img_decoder_set_info_cb(dec, decoder_info);
                                     ^~~~~~~~~~~~
In file included from components\core2forAWS\tft\lvgl/lvgl/src/lv_core/../lv_draw/lv_draw_img.h:16,
                 from components\core2forAWS\tft\lvgl/lvgl/src/lv_core/lv_obj.h:29,
                 from components\core2forAWS\tft\lvgl/lvgl/lvgl.h:32,
                 from components\lv_lib_png\lv_png.c:12:
components\core2forAWS\tft\lvgl/lvgl/src/lv_core/../lv_draw/lv_img_decoder.h:201:85: note: expected 'lv_img_decoder_info_f_t' {aka 'unsigned char (*)(struct _lv_img_decoder *, const void *, struct <anonymous> *)'} but argument is of type 'lv_res_t (*)(struct _lv_img_decoder_t *, const void *, lv_img_header_t *)' {aka 'unsigned char (*)(struct _lv_img_decoder_t *, const void *, struct <anonymous> *)'}
 void lv_img_decoder_set_info_cb(lv_img_decoder_t * decoder, lv_img_decoder_info_f_t info_cb);
                                                             ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
components\lv_lib_png\lv_png.c: At top level:
components\lv_lib_png\lv_png.c:70:37: warning: 'struct _lv_img_decoder_t' declared inside parameter list will not be visible outside of this definition or declaration
 static lv_res_t decoder_info(struct _lv_img_decoder_t * decoder, const void * src, lv_img_header_t * header)
                                     ^~~~~~~~~~~~~~~~~
components\lv_lib_png\lv_png.c:70:17: error: conflicting types for 'decoder_info'
 static lv_res_t decoder_info(struct _lv_img_decoder_t * decoder, const void * src, lv_img_header_t * header)
                 ^~~~~~~~~~~~
components\lv_lib_png\lv_png.c:31:17: note: previous declaration of 'decoder_info' was here
 static lv_res_t decoder_info(struct _lv_img_decoder_t * decoder, const void * src, lv_img_header_t * header);
                 ^~~~~~~~~~~~
components\lv_lib_png\lv_png.c:31:17: warning: 'decoder_info' used but never defined
components\lv_lib_png\lv_png.c:70:17: warning: 'decoder_info' defined but not used [-Wunused-function]
 static lv_res_t decoder_info(struct _lv_img_decoder_t * decoder, const void * src, lv_img_header_t * header)
                 ^~~~~~~~~~~~
Compiling .pio\build\core2foraws\lwip\lwip\src\core\pbuf.o
Compiling .pio\build\core2foraws\lwip\lwip\src\core\raw.o
Compiling .pio\build\core2foraws\lwip\lwip\src\core\stats.o
Compiling .pio\build\core2foraws\lwip\lwip\src\core\sys.o
Compiling .pio\build\core2foraws\lwip\lwip\src\core\tcp.o
Compiling .pio\build\core2foraws\lwip\lwip\src\core\tcp_in.o
*** [.pio\build\core2foraws\components\lv_lib_png\lv_png.o] Error 1

Png picture distortion

Hello, I use the lv_lib_png have a problem.
LVGL version: 7.0.
My PNG image is RGBA8888, and the LV_COLOR_DEPTH is set to 16 because the device only supports 16bit pix. when trying to display some image with gradient color, there is a picture distortion problem.
original image is:
original_image
in fact, displaying image is:
distortion_image
I find the problem is in function "convert_color_depth" in lv_png.c. In this function, RGB888 is converted to RGB 565, and low bits of R byte、G byte and B byte are dropped, which creates such a problem.
So,there is a better way to deal with it. Thank you for your replying!

PNG photo 8 bitcolor someting wrong

maybe it should be:
#elif LV_COLOR_DEPTH == 8
lv_color32_t * img_argb = (lv_color32_t*)img;
lv_color_t c;
uint32_t i;
for(i = 0; i < px_cnt; i++) {
c = lv_color_make(img_argb[i].ch.blue, img_argb[i].ch.green, img_argb[i].ch.red);
img[i2 + 1] = img_argb[i].ch.alpha;
img[i
2 + 0] = c.full;
}

bug with LODEPNG_COMPILE_ALLOCATORS option

I am testing (lv_lib_png) performance and heap allocation.
I implemented my allocator (tracing/logging mallocs) to test software (basically the lodepng library) and enabling the MEM_BLOCK.

I found there is a missing FreeMem call which will result in memory leak (here)

I know is not lvgl code, so i went to lodepng site to report issue.
I found that this code is no longer exist.

In fact, I found that lv_lib_png is using "20180611" release. lodepng is now "20201017"

Regards,

Load PNG from variable

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"

png image not displayed properly

i am trying to open .png file from SD card and display on LCD but it shows image with white background with nodata text.
how to resolve that?

can't display the png img in vs2019 simulator

I use LVGL's file system API, it work fine when i transform the img to bin file,but when i open png file directly,it display “nodata”.

I Initalize the decocer with lv_png_init() and add #define LV_PNG_USE_LV_FILESYSTEM 1.

It printf: ERROR 48:empty input buffer given to decoder. Maybe caused by non-existing file?

Problem when using canvas on top of png

Hello guys,

I noticed something weird, if I load my png alone (only the image on the screen) it loads fast (esp32 with 4mgs external ram) but if I add a canvas on top, it just gets to run very slow, I understand the canvas is this transparent piece of component that can be used to draw "primitives" to screen, but I am finding it quite difficult to make it faster with the canvas, can I draw a square on top of the PNG image without using the canvas?

'LV_PNG_USE_LV_FILESYSTEM' is never used?

Hello, I use the lv_lib_png have a problem.
LVGL version: 8.0.1
First, I need to state steps before asking the question:

  1. I add the lv_fs_if in my project, and I am sure that it is available. Because I can load my qingtian.bin used with lv_img_set_src.
  2. Then, I add the #define LV_PNG_USE 1 #define LV_PNG_USE_LV_FILESYSTEM 1 at the end of 'lv_cong.h'.But Clion(platformio) remind #define LV_PNG_USE 1 #define LV_PNG_USE_LV_FILESYSTEM 1 is never used.
    neveruse
  3. Create lv_obj_img in my project.code
  4. Include and init it.
    init
  5. My monitor(ST7789) show "No data" in weather_imgobj, It is wrong.

So, I don`t know what happend? Where is the problem?

PNG test on lv_port_stm32f429_disco

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"

how to enhance decoder's performance ?

If I show two 720p png,the decoder performance is terrible,the fps almost half lower than just show one picture,but if I replace one of it with a c array it works well.I'm sure the chip I'm using is powerful enouth to decode this so I wonder if there is some problem such as memory allowcation or some options I didn't notice? Can you give some advice about how to locate this problem.

Lv_lib_png showing white rectangle

Hello
I'm using esp32(arduino framework) + lvgl + lv_lib_lodepng.
when I try to show a png image it doesn’t work. it only shows a white rectangle with a “No data” text on the top left corner. I tried to Use PNG images from flash and file as instructed in the README file of the library and none of them works. the problem is only with png files because when i use a true color image it works fine.
I also Enabled the log module on LV_LOG_LEVEL_WARN level and the following lines are printed in the console:
.pio\libdeps\esp32dev\lvgl\src\lv_draw\lv_img_cache.c@131->fnn: _lv_img_cache_open ->Image draw cannot open the image resource .pio\libdeps\esp32dev\lvgl\src\lv_draw\lv_draw_img.c@87->fnn: lv_draw_img ->Image draw error
also the same code works in vs simulator and the problem only occurs when I’m using esp32.
Code to reproduce
void setup() { display_init(); touch_init(); lv_fs_if_init(); LV_IMG_DECLARE(png_decoder_test); lv_obj_t *img = lv_img_create(lv_scr_act(), NULL); lv_img_set_src(img, &png_decoder_test); } void loop() { lv_task_handler(); delay(5); }
the lv_png_init() is inside the display_init() function.
Screenshot and/or video
2f7e7d4ebaea75d69a2f2a12e2ebfcc70f1ad4bb

Some problems with imgbtn

I have made another thread to call lv_img_btn_set_src with png files as an event interruption,but it shows nothing.However it works well with imgbtn api in main thread or img api in both main and second thread.

how to make the background of image button to be transparent?

I'm using LVGL8.0 and RGB585 format images ,

I tried #define LV_COLOR_CHROMA_KEY lv_color_hex(0x000000) /black as background and not draw/ and it takes no effect.
my main screen's background is black and there're some overlapped area between image buttons as bellow ing:

memory allocation failed

hello,

I'm using esp32 + lvgl + lv_lib_lodepng,
but when I use a png more 20K , it would shows "memory allocation failed", where can I change for making the memory allocation bigger ?

free memory

It seems like code in this repo has an error with free memory resources

free(png_data); /*Free the loaded file*/

free((uint8_t *)dsc->img_data);

It uses free() while png_data and img_data are allocated in lodepng.c with lodepng_malloc(), lodepng_realloc().

image with alpha channel is broken

I used such image - 4 rectangles filled with almost the same color but different alpha value
bitmap

After it drawed on the screen it looks strange - with lines, although rectangles at the source image has solid filled alpha-channel
IMG_20211102_173710

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.