Giter Site home page Giter Site logo

lvgl / lv_img_conv Goto Github PK

View Code? Open in Web Editor NEW
84.0 3.0 37.0 3.14 MB

Image converter for LVGL, written in JS

Home Page: https://lvgl.github.io/lv_img_conv/

License: Other

TypeScript 96.28% JavaScript 0.07% HTML 3.45% Perl 0.05% Dockerfile 0.10% Shell 0.05%
lvgl image-converter

lv_img_conv'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(lv_screen_active(), 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_img_conv's People

Contributors

embeddedt avatar fralonra avatar gokhannsahin avatar higaski avatar kisvegabor avatar robert-alfaro avatar yohannfra avatar zjanosy 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

lv_img_conv's Issues

How to convert image to .bin

Hello, I'm trying to use this script to convert a bunch of png files to .bin but can't find the flag to do so.

Thanks

mac npm install error !

npm install
npm WARN deprecated [email protected]: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
npm ERR! code 1
npm ERR! path /Users/lewis/Documents/lv_img_conv/node_modules/canvas
npm ERR! command failed
npm ERR! command sh -c node-pre-gyp install --fallback-to-build
npm ERR! Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/Users/lewis/Documents/lv_img_conv/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/Users/lewis/Documents/lv_img_conv/node_modules/canvas/build/Release --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v108' (1)
npm ERR! node-pre-gyp info it worked if it ends with ok
npm ERR! node-pre-gyp info using [email protected]
npm ERR! node-pre-gyp info using [email protected] | darwin | x64
npm ERR! node-pre-gyp info check checked for "/Users/lewis/Documents/lv_img_conv/node_modules/canvas/build/Release/canvas.node" (not found)
npm ERR! node-pre-gyp http GET https://github.com/Automattic/node-canvas/releases/download/v2.9.0/canvas-v2.9.0-node-v108-darwin-unknown-x64.tar.gz
npm ERR! node-pre-gyp ERR! install response status 404 Not Found on https://github.com/Automattic/node-canvas/releases/download/v2.9.0/canvas-v2.9.0-node-v108-darwin-unknown-x64.tar.gz 
npm ERR! node-pre-gyp WARN Pre-built binaries not installable for [email protected] and [email protected] (node-v108 ABI, unknown) (falling back to source compile with node-gyp) 
npm ERR! node-pre-gyp WARN Hit error response status 404 Not Found on https://github.com/Automattic/node-canvas/releases/download/v2.9.0/canvas-v2.9.0-node-v108-darwin-unknown-x64.tar.gz 
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | darwin | x64
npm ERR! gyp info ok 
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | darwin | x64
npm ERR! gyp info find Python using Python version 3.9.1 found at "/usr/local/opt/[email protected]/bin/python3.9"
npm ERR! gyp info spawn /usr/local/opt/[email protected]/bin/python3.9
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args   'binding.gyp',
npm ERR! gyp info spawn args   '-f',
npm ERR! gyp info spawn args   'make',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/lewis/Documents/lv_img_conv/node_modules/canvas/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/lewis/Library/Caches/node-gyp/18.1.0/include/node/common.gypi',
npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
npm ERR! gyp info spawn args   '-Dvisibility=default',
npm ERR! gyp info spawn args   '-Dnode_root_dir=/Users/lewis/Library/Caches/node-gyp/18.1.0',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/Users/lewis/Library/Caches/node-gyp/18.1.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/Users/lewis/Documents/lv_img_conv/node_modules/canvas',
npm ERR! gyp info spawn args   '-Dnode_engine=v8',
npm ERR! gyp info spawn args   '--depth=.',
npm ERR! gyp info spawn args   '--no-parallel',
npm ERR! gyp info spawn args   '--generator-output',
npm ERR! gyp info spawn args   'build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! Package pixman-1 was not found in the pkg-config search path.
npm ERR! Perhaps you should add the directory containing `pixman-1.pc'
npm ERR! to the PKG_CONFIG_PATH environment variable
npm ERR! No package 'pixman-1' found
npm ERR! gyp: Call to 'pkg-config pixman-1 --libs' returned exit status 1 while in binding.gyp. while trying to load binding.gyp
npm ERR! gyp ERR! configure error 
npm ERR! gyp ERR! stack Error: `gyp` failed with exit code: 1
npm ERR! gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:261:16)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:527:28)
npm ERR! gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:291:12)
npm ERR! gyp ERR! System Darwin 21.2.0
npm ERR! gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/Users/lewis/Documents/lv_img_conv/node_modules/canvas/build/Release/canvas.node" "--module_name=canvas" "--module_path=/Users/lewis/Documents/lv_img_conv/node_modules/canvas/build/Release" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v108"
npm ERR! gyp ERR! cwd /Users/lewis/Documents/lv_img_conv/node_modules/canvas
npm ERR! gyp ERR! node -v v18.1.0
npm ERR! gyp ERR! node-gyp -v v9.0.0
npm ERR! gyp ERR! not ok 
npm ERR! node-pre-gyp ERR! build error 
npm ERR! node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/Users/lewis/Documents/lv_img_conv/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/Users/lewis/Documents/lv_img_conv/node_modules/canvas/build/Release --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v108' (1)
npm ERR! node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/Users/lewis/Documents/lv_img_conv/node_modules/@mapbox/node-pre-gyp/lib/util/compile.js:89:23)
npm ERR! node-pre-gyp ERR! stack     at ChildProcess.emit (node:events:527:28)
npm ERR! node-pre-gyp ERR! stack     at maybeClose (node:internal/child_process:1090:16)
npm ERR! node-pre-gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:302:5)
npm ERR! node-pre-gyp ERR! System Darwin 21.2.0
npm ERR! node-pre-gyp ERR! command "/usr/local/bin/node" "/Users/lewis/Documents/lv_img_conv/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
npm ERR! node-pre-gyp ERR! cwd /Users/lewis/Documents/lv_img_conv/node_modules/canvas
npm ERR! node-pre-gyp ERR! node -v v18.1.0
npm ERR! node-pre-gyp ERR! node-pre-gyp -v v1.0.8
npm ERR! node-pre-gyp ERR! not ok

I checked that the github repository address is gone, how can I solve this problem? thanks

npm ERR! node-pre-gyp http GET https://github.com/Automattic/node-canvas/releases/download/v2.9.0/canvas-v2.9.0-node-v108-darwin-unknown-x64.tar.gz

Running in container fails

I followed the steps in the README to run lv_img_conv in a container:

docker build -t lv_img_conv .

It fails to build [email protected]. Adding the missing dependency

RUN apt update && apt install libsdl-pango-dev -y

to the docker solves this.

However if I then run

docker run -ti --rm -u 1000:1000 lv_img_conv lv_img_conv.js

it fails with:

npx: installed 17 in 1.434s
@swc/core threw an error when attempting to validate swc compiler options.
You may be using an old version of swc which does not support the options used by ts-node.
Try upgrading to the latest version of swc.
Error message from swc:
Failed to deserialize buffer as swc::config::Options
JSON: {"sourceMaps":true,"module":{"type":"commonjs","noInterop":false,"strictMode":true,"ignoreDynamic":false},"swcrc":false,"jsc":{"parser":{"syntax":"typescript","tsx":false,"dynamicImport":true,"importAssertions":true},"target":"es5","transform":{"legacyDecorator":true,"react":{"throwIfNamespace":false,"useBuiltins":false,"runtime":"automatic"},"useDefineForClassFields":false},"keepClassNames":false,"experimental":{"keepImportAttributes":true,"emitAssertForImportAttributes":true}}}

Caused by:
    unknown field `keepImportAttributes`, expected one of `plugins`, `keepImportAssertions`, `cacheRoot` at line 1 column 484

Convert to CF_RAW_ALPHA return width and height zero

Hi, when i genrate C array of png picture to Raw alpha format, it always return size to zero. I have to change manualy all files. Can you help me! Thanks

const lv_img_dsc_t Background = {
.header.cf = LV_IMG_CF_RAW_ALPHA,
.header.always_zero = 0,
.header.reserved = 0,
.header.w = 0,
.header.h = 0,
.data_size = 15469,
.data = Background_map,
};

Development version for v9

Hi @embeddedt,

In v9 the the name the usage of the color formats has been changed. Do you have a little bit of free time to add some minor modifications to the image converter and push it to a dev branch?

These are the new color format options_

  • Native RGB (LV_COLOR_FORMAT_NATIVE): It's resolved to LV_COLOR_FORMAT_L8/RGB565/RGB888/XRGB8888 internally according to LV_COLOR_DEPTH. Same as LV_IMG_CF_TRUE_COLOR in v8.
  • Native ARGB (LV_COLOR_FORMAT_NATIVE_WITH_ALPHA): It's resolved to LV_COLOR_FORMAT_AL88/RGB565A8/ARGB8888 internally according to LV_COLOR_DEPTH. Same as LV_IMG_CF_TRUE_COLOR_ALPHA in v8.
  • LV_COLOR_FORMAT_RGB565_CHROMA_KEYED
  • LV_COLOR_FORMAT_RGB888_CHROMA_KEYED
  • There is no LV_COLOR_FORMAT_XRGB88888_CHROMA_KEYED as there ARGB8888 is a better option with the same size.
  • Alpha 8 (LV_COLOR_FORMAT_A8): Alpha 1, 2 and 4 are removed
  • Indexed 1/2/4/8 (LV_COLOR_FORMAT_I1/2/4/8)
  • These color formats are included in Native RGB and Native ARGB but it'd be great to select them individually too:
    • LV_COLOR_FORMAT_L8
    • LV_COLOR_FORMAT_A8
    • LV_COLOR_FORMAT_AL88
    • LV_COLOR_FORMAT_RGB565
    • LV_COLOR_FORMAT_RGB565A8
    • LV_COLOR_FORMAT_RGB888
    • LV_COLOR_FORMAT_XRGB8888
    • LV_COLOR_FORMAT_ARGB8888

Off-By-One Size Error When Converting Images To Alpha-Only C code

What happens?

When I use lv_img_conv.js to export an image to a C array with the format CF_ALPHA_4_BIT the resulting C file specifies a data_size that is one larger than I expect.

Replication

  1. Create an image (I've attached a sample).
  2. Convert using ./lv_img_conv.js <image> -f -c CF_ALPHA_4_BIT.
  3. Compare .data_size to WIDTH * HEIGHT * 4 / 8.

(With the 32x32 sample image, I expect 32*32*4/8 = 512 but I get 513)

const lv_img_dsc_t test_image = {
  .header.cf = LV_IMG_CF_ALPHA_4BIT,
  .header.always_zero = 0,
  .header.reserved = 0,
  .header.w = 32,
  .header.h = 32,
  .data_size = 513,
  .data = test_image_map,
};

Note that the C array output only has 512 bytes in it, so if the LVGL library reads 513 bytes, it'll read into uninitialized memory and not padding.

Investigation

I think that the cause is likely this line: https://github.com/lvgl/lv_img_conv/blob/master/lib/convert.ts#L575 Removing it resolves the issue - but I do not know the full effects or why the line is there.

Online Image Converter with gif not work

in LVGL 8.2.
when i use example libs gif folder, it wroking.
it's .header.cf = LV_IMG_CF_RAW.
buf if i use "LVGL Online Image Converter" to create raw .c.
it will not show anything. it show the header.cf is LV_IMG_CF_RAW_CHROMA,.
and lvgl 8.2 identifier "LV_IMG_CF_RAW_CHROMA" is undefined.
how to fix it?

Chroma Keying

Hello,

Running on an ESP32S3 with LVGL near master, with color depth set to 16_SWAP with an ST7789 driving a 240x320 LCD.

I am attempting to take the below PNG image, with a transparent background and running through lv_img_conv.js

hand

Passing CF_TRUE_COLOR_CHROMA as the color format to converter

My chroma key as set in kconfig is 0xFF00FF

The converter translates the transparent background to black, as I would expect which in turn is displayed on a given view.

In my case, I want to use the chroma key as an effective replacement of transparency from the original PNG.

hand (1)

This image has been altered from the original in GIMP. A black layer is added with burn blending, and a pink layer is added. This is coming at the cost of dithering on the PNG.

If I instead provide this image to the converter, where the background has been translated to 0xFF00FF, the image ALMOST converts as I'd expect. With or without dithering enabled, I am seeing pink pixels make it through to the LCD with this method. If I dither, the pink pixels form a complete edge around the image. If I dont dither, a few scattered pixels make it in.


Suggested Fix:

When I am calling lv_img_conv.js, I'd like to be able to pass the chroma color expected by LVGL when using CF_TRUE_COLOR_CHROMA (or any other chroma format), such that the conversion translates the original PNG with transparency, with or without dithering to a chroma keyed c array.

The converter then should be able to translate fully opaque pixels to the desired chroma color, while preserving any dithering that may have already been performed in the PNG.

Dithering should also accomodate chroma color, and not dither against a color that is not intended to be rendered in LVGL. This will actively form a pink edge around the content of the image, while removing the background.

I am not familiar with script, but am happy to help on changes if someone more familiar can help point me in a direction to start.

Node 18 or 20 support

Node V14 is no longer a LTS release and node-gyp no longer works with MacOS Sonoma when installing the node dependencies.

On Sonoma, I am receiving the error ValueError: invalid mode: 'rU' while trying to load binding.gyp when attempting to npm install. I think this is because node-gyp is outdated and doesn't support newer XCodes, which are installing newer python versions.

When running with Node 18 on Linux and MacOS, the error is sh: 1: ts-node: not found.

Add unit tests

Before any code cleanup/refactoring takes place, some type of unit testing should be added to ensure all types of images always convert and are displayed correctly.

As the image format has not changed in years, and major changes are unlikely, checking that the C file output matches an expected one should be good enough for testing purposes, and avoids the need to depend on the lvgl/lvgl repository.

An exception occurred during image conversion.

@swc/core threw an error when attempting to validate swc compiler options.
You may be using an old version of swc which does not support the options used by ts-node.
Try upgrading to the latest version of swc.
Error message from swc:
Failed to deserialize buffer as swc::config::Options
JSON: {"sourceMaps":true,"module":{"noInterop":false,"type":"commonjs","strictMode":true,"ignoreDynamic":false},"swcrc":false,"jsc":{"parser":{"syntax":"typescript","tsx":false,"dynamicImport":true,"importAssertions":true},"target":"es5","transform":{"legacyDecorator":true,"react":{"throwIfNamespace":false,"useBuiltins":false,"runtime":"automatic"}},"keepClassNames":false,"experimental":{"keepImportAssertions":true}}}

Caused by:
unknown field keepImportAssertions, expected one of plugins, keepImportAttributes, emitAssertForImportAttributes, cacheRoot, disableBuiltinTransformsForInternalTesting at line 1 column 415

Image Converter doesn't work with Firefox

When converting an image using the online image converter (https://lvgl.io/tools/imageconverter) in Firefox, the resulting lvgl images are almost entirely garbage data. I'm using the latest version of firefox available on my distro (FF 105.0.1). I've attached a test image and the image converter output from both firefox and google chrome. I'm using format CF_TRUE_COLOR_ALPHA, with otherwise default options.

Test image - 4x4 pixels, with top left 4 pixels full red, top right 4 full green, bottom left 4 full blue, bottom right black/white checkered, saved as .png:
img_test_png

Converter output from Firefox (pixel data only):

const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMG_IMG_TEST_PNG uint8_t img_test_png_map[] = {

#if LV_COLOR_DEPTH == 1 || LV_COLOR_DEPTH == 8
/*Pixel format: Alpha 8 bit, Red: 3 bit, Green: 3 bit, Blue: 2 bit*/
0x2f, 0x86, 0x59, 0x1b, 0xcf, 0x25, 0xeb, 0xc6,
0xd4, 0x38, 0x9f, 0xc0, 0xc7, 0x70, 0x62, 0x87,
0x2f, 0x86, 0x59, 0x1b, 0xcf, 0x25, 0xeb, 0xc6,
0xd4, 0x38, 0x9f, 0xc0, 0xc7, 0x70, 0x62, 0x87,
#endif
#if LV_COLOR_DEPTH == 16 && LV_COLOR_16_SWAP == 0
/*Pixel format: Alpha 8 bit, Red: 5 bit, Green: 6 bit, Blue: 5 bit*/
0x3d, 0x2b, 0x86, 0x28, 0x36, 0x1b, 0x5b, 0xcb, 0x25, 0x5d, 0xf2, 0xc6,
0xe3, 0xcc, 0x38, 0xb8, 0x86, 0xc0, 0xd7, 0xb8, 0x70, 0x51, 0x60, 0x87,
0x3d, 0x2b, 0x86, 0x28, 0x36, 0x1b, 0x5b, 0xcb, 0x25, 0x5d, 0xf2, 0xc6,
0xe3, 0xcc, 0x38, 0xb8, 0x86, 0xc0, 0xd7, 0xb8, 0x70, 0x51, 0x60, 0x87,
#endif
#if LV_COLOR_DEPTH == 16 && LV_COLOR_16_SWAP != 0
/*Pixel format: Alpha 8 bit, Red: 5 bit, Green: 6 bit, Blue: 5 bit BUT the 2 color bytes are swapped*/
0x2b, 0x3d, 0x86, 0x36, 0x28, 0x1b, 0xcb, 0x5b, 0x25, 0xf2, 0x5d, 0xc6,
0xcc, 0xe3, 0x38, 0x86, 0xb8, 0xc0, 0xb8, 0xd7, 0x70, 0x60, 0x51, 0x87,
0x2b, 0x3d, 0x86, 0x36, 0x28, 0x1b, 0xcb, 0x5b, 0x25, 0xf2, 0x5d, 0xc6,
0xcc, 0xe3, 0x38, 0x86, 0xb8, 0xc0, 0xb8, 0xd7, 0x70, 0x60, 0x51, 0x87,
#endif
#if LV_COLOR_DEPTH == 32
0xe9, 0x65, 0x27, 0x86, 0x41, 0xc2, 0x31, 0x1b, 0xda, 0x67, 0xc5, 0x25, 0xe5, 0x46, 0xef, 0xc6,
0x14, 0x9d, 0xc9, 0x38, 0xc3, 0xd3, 0x7d, 0xc0, 0xb7, 0x19, 0xb6, 0x70, 0x84, 0x07, 0x62, 0x87,
0xe9, 0x65, 0x27, 0x86, 0x41, 0xc2, 0x31, 0x1b, 0xda, 0x67, 0xc5, 0x25, 0xe5, 0x46, 0xef, 0xc6,
0x14, 0x9d, 0xc9, 0x38, 0xc3, 0xd3, 0x7d, 0xc0, 0xb7, 0x19, 0xb6, 0x70, 0x84, 0x07, 0x62, 0x87,
#endif
};

Output from Google Chrome:

const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMG_IMG_TEST_PNG uint8_t img_test_png_map[] = {
#if LV_COLOR_DEPTH == 1 || LV_COLOR_DEPTH == 8
/*Pixel format: Alpha 8 bit, Red: 3 bit, Green: 3 bit, Blue: 2 bit*/
0xe0, 0xff, 0xe0, 0xff, 0x1c, 0xff, 0x1c, 0xff,
0xe0, 0xff, 0xe0, 0xff, 0x1c, 0xff, 0x1c, 0xff,
0x03, 0xff, 0x03, 0xff, 0x00, 0xff, 0xff, 0xff,
0x03, 0xff, 0x03, 0xff, 0xff, 0xff, 0x00, 0xff,
#endif
#if LV_COLOR_DEPTH == 16 && LV_COLOR_16_SWAP == 0
/*Pixel format: Alpha 8 bit, Red: 5 bit, Green: 6 bit, Blue: 5 bit*/
0x00, 0xf8, 0xff, 0x00, 0xf8, 0xff, 0xe0, 0x07, 0xff, 0xe0, 0x07, 0xff,
0x00, 0xf8, 0xff, 0x00, 0xf8, 0xff, 0xe0, 0x07, 0xff, 0xe0, 0x07, 0xff,
0x1f, 0x00, 0xff, 0x1f, 0x00, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
0x1f, 0x00, 0xff, 0x1f, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff,
#endif
#if LV_COLOR_DEPTH == 16 && LV_COLOR_16_SWAP != 0
/*Pixel format: Alpha 8 bit, Red: 5 bit, Green: 6 bit, Blue: 5 bit BUT the 2 color bytes are swapped*/
0xf8, 0x00, 0xff, 0xf8, 0x00, 0xff, 0x07, 0xe0, 0xff, 0x07, 0xe0, 0xff,
0xf8, 0x00, 0xff, 0xf8, 0x00, 0xff, 0x07, 0xe0, 0xff, 0x07, 0xe0, 0xff,
0x00, 0x1f, 0xff, 0x00, 0x1f, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
0x00, 0x1f, 0xff, 0x00, 0x1f, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff,
#endif
#if LV_COLOR_DEPTH == 32
0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff,
0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff,
0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff,
#endif
};

Can't build/install on ubuntu18

I am getting the following when trying to install with npm after cloning the git repo:

/pinetime/lv_img_conv$ npm install
loadDep:yargs → 304       ▌ ╢██████████████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░╟
loadDep:tar → addNameRang ▌ ╢███████████████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░╟
WARN engine [email protected]: wanted: {"node":">=10"} (current: {"node":"8.10.0","npm":"3.5.2"})
loadDep:set-blocking → re ▌ ╢███████████████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░╟
WARN engine [email protected]: wanted: {"node":">=10"} (current: {"node":"8.10.0","npm":"3.5.2"})
loadDep:lru-cache → get   ▌ ╢███████████████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░╟
loadDep:mkdirp → request  ▄ ╢███████████████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░╟
loadDep:mkdirp → get      ▄ ╢███████████████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░╟
npm ERR! Linux 5.4.0-149-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install"
npm ERR! node v8.10.0
npm ERR! npm  v3.5.2
npm ERR! code EMISSINGARG

npm ERR! typeerror Error: Missing required argument #1
npm ERR! typeerror     at andLogAndFinish (/usr/share/npm/lib/fetch-package-metadata.js:31:3)
npm ERR! typeerror     at fetchPackageMetadata (/usr/share/npm/lib/fetch-package-metadata.js:51:22)
npm ERR! typeerror     at resolveWithNewModule (/usr/share/npm/lib/install/deps.js:456:12)
npm ERR! typeerror     at /usr/share/npm/lib/install/deps.js:457:7
npm ERR! typeerror     at /usr/share/npm/node_modules/iferr/index.js:13:50
npm ERR! typeerror     at /usr/share/npm/lib/fetch-package-metadata.js:37:12
npm ERR! typeerror     at addRequestedAndFinish (/usr/share/npm/lib/fetch-package-metadata.js:82:5)
npm ERR! typeerror     at returnAndAddMetadata (/usr/share/npm/lib/fetch-package-metadata.js:117:7)
npm ERR! typeerror     at pickVersionFromRegistryDocument (/usr/share/npm/lib/fetch-package-metadata.js:134:20)
npm ERR! typeerror     at /usr/share/npm/node_modules/iferr/index.js:13:50
npm ERR! typeerror This is an error with npm itself. Please report this error at:
npm ERR! typeerror     <http://github.com/npm/npm/issues>

All dependency steps are met otherwise.

Is there a way to avoid using npm for this step?

Place converted images in current working directory

The php script places the generated files in the current working directory. This allows a lot more flexibility in where the files are places. E.G. in CMake we can place the generated files in the build folder:

    add_custom_command(OUTPUT ${C}
        COMMAND php ${CMAKE_CURRENT_LIST_DIR}/img_conv_core.php name=${T}&img=${P}
        DEPENDS ${P}
        WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
        VERBATIM)

This is not possible with this script. Could you add an option to place the outputs in the working directory instead of next to the input files?

Android execution/port?

Hey all,

We have an app that send images to Android smart glasses and displays them on the glasses: https://github.com/emexlabs/WearableIntelligenceSystem

We are porting the thin client on the glasses to run on an MCU (ESP32) which is using Lovyan + LVGL to display information on the HUD.

Would there be an easy way to run this functionality on Android? Would there be a simple way to port it to Android?

If not, we could run this in the cloud and call it as an API, but this is less ideal than doing it locally in terms of latency, bandwidth, internet connection reliance, etc.

Thanks

CC: @alex1115alex

alpha-only and indexed-color format binary file not working

Hi,
Using the online image converters, both alpha-only and indexed color format of binary are not working.
The generated binary file size is same as the one using true-color-alpha format.

Output format is always set to binary-rgb888 when tesing.

Check the binary data with c-array, it seems binary file always use 4byte/pixel

Attached is the original file and generated binary files.

Regards,
binary-images.zip

Auto generate titles

When I want to convert 100 images I don't want to fill all the names one by one, it would be better if the names were auto generated.

For now if I don't specify names when giving multiples images the output is
bin, bin1, bin2 ....

But it should be that if we don't specify names then the names are generated from the input file.
my_house.png -> my_house.bin

I'll try to make the pr today.

Thanks

How do I specify the output directory?

The files I generate using the following command are always in the lib directory:
ts-node cli.ts ./2_watchface/conlon_2.png --emit -f -c CF_TRUE_COLOR_ALPHA -t bin --binary-format ARGB8565
How do I specify the output directory?

Node.js 17 not supported (Failed to install node-gyp)

Just to have this on record for other users with the same problem: Running npm install with Node.js 17 will fail with an error that tries to mention that node-gyp cannot be installed:

`npm install` error, click to open
RUN npm install:                                                                                                                                                                                                     
#10 7.958 npm WARN deprecated [email protected]: request-promise-native has been deprecated because it extends the now deprecated request package, see https://github.com/request/request/issues/3142              
#10 9.397 npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142                                                                                                 
#10 11.03 npm WARN deprecated [email protected]: this library is no longer supported                                                                                                                                        
#10 13.93 npm WARN deprecated [email protected]: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.                                                                                           
#10 19.19 npm WARN deprecated [email protected]: Parcel v1 is no longer maintained. Please migrate to v2, which is published under the 'parcel' package. See https://v2.parceljs.org/getting-started/migration for details.
#10 21.26 npm WARN deprecated [email protected]: core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.
#10 29.26 npm notice 
#10 29.26 npm notice New patch version of npm available! 8.1.2 -> 8.1.3
#10 29.26 npm notice Changelog: <https://github.com/npm/cli/releases/tag/v8.1.3>
#10 29.26 npm notice Run `npm install -g [email protected]` to update!
#10 29.27 npm notice 
#10 29.27 npm ERR! code 1
#10 29.27 npm ERR! path /usr/src/app/node_modules/canvas
#10 29.27 npm ERR! command failed
#10 29.27 npm ERR! command sh -c node-pre-gyp install --fallback-to-build
#10 29.27 npm ERR! make: Entering directory '/usr/src/app/node_modules/canvas/build'
#10 29.27 npm ERR!   SOLINK_MODULE(target) Release/obj.target/canvas-postbuild.node
#10 29.27 npm ERR!   COPY Release/canvas-postbuild.node
#10 29.27 npm ERR!   CXX(target) Release/obj.target/canvas/src/backend/Backend.o
#10 29.27 npm ERR! make: Leaving directory '/usr/src/app/node_modules/canvas/build'
#10 29.27 npm ERR! Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/usr/src/app/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/usr/src/app/node_modules/canvas/build/Release --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v102' (1)
#10 29.27 npm ERR! node-pre-gyp info it worked if it ends with ok
#10 29.27 npm ERR! node-pre-gyp info using [email protected]
#10 29.27 npm ERR! node-pre-gyp info using [email protected] | linux | x64
#10 29.27 npm ERR! node-pre-gyp WARN Using request for node-pre-gyp https download 
#10 29.27 npm ERR! node-pre-gyp info check checked for "/usr/src/app/node_modules/canvas/build/Release/canvas.node" (not found)
#10 29.27 npm ERR! node-pre-gyp http GET https://github.com/Automattic/node-canvas/releases/download/v2.7.0/canvas-v2.7.0-node-v102-linux-glibc-x64.tar.gz
#10 29.27 npm ERR! node-pre-gyp http 404 https://github.com/Automattic/node-canvas/releases/download/v2.7.0/canvas-v2.7.0-node-v102-linux-glibc-x64.tar.gz
#10 29.27 npm ERR! node-pre-gyp WARN Tried to download(404): https://github.com/Automattic/node-canvas/releases/download/v2.7.0/canvas-v2.7.0-node-v102-linux-glibc-x64.tar.gz 
#10 29.27 npm ERR! node-pre-gyp WARN Pre-built binaries not found for [email protected] and [email protected] (node-v102 ABI, glibc) (falling back to source compile with node-gyp) 
#10 29.27 npm ERR! node-pre-gyp http 404 status code downloading tarball https://github.com/Automattic/node-canvas/releases/download/v2.7.0/canvas-v2.7.0-node-v102-linux-glibc-x64.tar.gz 
#10 29.27 npm ERR! gyp info it worked if it ends with ok
#10 29.27 npm ERR! gyp info using [email protected]
#10 29.27 npm ERR! gyp info using [email protected] | linux | x64
#10 29.27 npm ERR! gyp info ok 
#10 29.27 npm ERR! gyp info it worked if it ends with ok
#10 29.27 npm ERR! gyp info using [email protected]
#10 29.27 npm ERR! gyp info using [email protected] | linux | x64
#10 29.28 npm ERR! gyp info find Python using Python version 3.9.2 found at "/usr/bin/python3"
#10 29.28 npm ERR! gyp http GET https://nodejs.org/download/release/v17.1.0/node-v17.1.0-headers.tar.gz
#10 29.28 npm ERR! gyp http 200 https://nodejs.org/download/release/v17.1.0/node-v17.1.0-headers.tar.gz
#10 29.28 npm ERR! gyp http GET https://nodejs.org/download/release/v17.1.0/SHASUMS256.txt
#10 29.28 npm ERR! gyp http 200 https://nodejs.org/download/release/v17.1.0/SHASUMS256.txt
#10 29.28 npm ERR! gyp info spawn /usr/bin/python3
#10 29.28 npm ERR! gyp info spawn args [
#10 29.28 npm ERR! gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
#10 29.28 npm ERR! gyp info spawn args   'binding.gyp',
#10 29.28 npm ERR! gyp info spawn args   '-f',
#10 29.28 npm ERR! gyp info spawn args   'make',
#10 29.28 npm ERR! gyp info spawn args   '-I',
#10 29.28 npm ERR! gyp info spawn args   '/usr/src/app/node_modules/canvas/build/config.gypi',
#10 29.28 npm ERR! gyp info spawn args   '-I',
#10 29.28 npm ERR! gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
#10 29.28 npm ERR! gyp info spawn args   '-I',
#10 29.28 npm ERR! gyp info spawn args   '/root/.cache/node-gyp/17.1.0/include/node/common.gypi',
#10 29.28 npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
#10 29.28 npm ERR! gyp info spawn args   '-Dvisibility=default',
#10 29.28 npm ERR! gyp info spawn args   '-Dnode_root_dir=/root/.cache/node-gyp/17.1.0',
#10 29.28 npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
#10 29.28 npm ERR! gyp info spawn args   '-Dnode_lib_file=/root/.cache/node-gyp/17.1.0/<(target_arch)/node.lib',
#10 29.28 npm ERR! gyp info spawn args   '-Dmodule_root_dir=/usr/src/app/node_modules/canvas',
#10 29.28 npm ERR! gyp info spawn args   '-Dnode_engine=v8',
#10 29.28 npm ERR! gyp info spawn args   '--depth=.',
#10 29.28 npm ERR! gyp info spawn args   '--no-parallel',
#10 29.28 npm ERR! gyp info spawn args   '--generator-output',
#10 29.28 npm ERR! gyp info spawn args   'build',
#10 29.28 npm ERR! gyp info spawn args   '-Goutput_dir=.'
#10 29.28 npm ERR! gyp info spawn args ]
#10 29.28 npm ERR! gyp info ok 
#10 29.28 npm ERR! gyp info it worked if it ends with ok
#10 29.28 npm ERR! gyp info using [email protected]
#10 29.28 npm ERR! gyp info using [email protected] | linux | x64
#10 29.28 npm ERR! gyp info spawn make
#10 29.28 npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
#10 29.28 npm ERR! In file included from ../../nan/nan.h:2884,
#10 29.28 npm ERR!                  from ../src/backend/Backend.h:6,
#10 29.28 npm ERR!                  from ../src/backend/Backend.cc:1:
#10 29.28 npm ERR! ../../nan/nan_typedarray_contents.h: In constructor 'Nan::TypedArrayContents<T>::TypedArrayContents(v8::Local<v8::Value>)':
#10 29.28 npm ERR! ../../nan/nan_typedarray_contents.h:34:43: error: 'class v8::ArrayBuffer' has no member named 'GetContents'
#10 29.28 npm ERR!    34 |       data   = static_cast<char*>(buffer->GetContents().Data()) + byte_offset;
#10 29.28 npm ERR!       |                                           ^~~~~~~~~~~
#10 29.28 npm ERR! make: *** [canvas.target.mk:162: Release/obj.target/canvas/src/backend/Backend.o] Error 1
#10 29.28 npm ERR! gyp ERR! build error 
#10 29.28 npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
#10 29.28 npm ERR! gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
#10 29.28 npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
#10 29.28 npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
#10 29.28 npm ERR! gyp ERR! System Linux 5.10.25-linuxkit
#10 29.28 npm ERR! gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/usr/src/app/node_modules/canvas/build/Release/canvas.node" "--module_name=canvas" "--module_path=/usr/src/app/node_modules/canvas/build/Release" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v102"
#10 29.28 npm ERR! gyp ERR! cwd /usr/src/app/node_modules/canvas
#10 29.28 npm ERR! gyp ERR! node -v v17.1.0
#10 29.28 npm ERR! gyp ERR! node-gyp -v v8.3.0
#10 29.28 npm ERR! gyp ERR! not ok 
#10 29.28 npm ERR! node-pre-gyp ERR! build error 
#10 29.28 npm ERR! node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/usr/src/app/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/usr/src/app/node_modules/canvas/build/Release --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v102' (1)
#10 29.28 npm ERR! node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/usr/src/app/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
#10 29.28 npm ERR! node-pre-gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
#10 29.28 npm ERR! node-pre-gyp ERR! stack     at maybeClose (node:internal/child_process:1062:16)
#10 29.28 npm ERR! node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
#10 29.28 npm ERR! node-pre-gyp ERR! System Linux 5.10.25-linuxkit
#10 29.28 npm ERR! node-pre-gyp ERR! command "/usr/local/bin/node" "/usr/src/app/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
#10 29.28 npm ERR! node-pre-gyp ERR! cwd /usr/src/app/node_modules/canvas
#10 29.28 npm ERR! node-pre-gyp ERR! node -v v17.1.0
#10 29.28 npm ERR! node-pre-gyp ERR! node-pre-gyp -v v0.15.0
#10 29.28 npm ERR! node-pre-gyp ERR! not ok
#10 29.32 
#10 29.32 npm ERR! A complete log of this run can be found in:
#10 29.32 npm ERR!     /root/.npm/_logs/2021-11-11T09_11_17_325Z-debug.log

Installation an usage with Node.js 16 works without any issue, and because V17 is not indicated as 'the best to use', I think there is no issue here. This is just to help others who have V17 installed and to see if we can find a solution somewhere in the future.

FYI, I used this Dockerfile to build:

FROM node:17
# Change above to 'FROM node:16' to get this to work

WORKDIR /usr/src/app
RUN apt-get update
RUN apt-get install -y build-essential libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev

COPY package*.json ./

RUN npm install
RUN npm install -g typescript

COPY . .
RUN tsc --build

# Test to see if script runs
CMD [ "node", "lv_img_conv.js", "-h"]

Very slow script startup

I've installed this script from the npm registry.

When I run it from the command line, the startup takes a few seconds. This is the same every time it is started.

I'm trying to convert about a dozen images, so this really slows down the build. Is there any way to speed it up? The old PHP script was quite fast, but is more difficult to run on windows, so I'm looking into this nodejs version.

$ time lv_img_conv --version
0.1.3

real    0m2.837s
user    0m4.670s
sys     0m0.210s

"True color chroma keyed" option generates empty c array data by Image converter

Perform all steps below and tick them with [x]

  • Check the related part of the Documentation
  • Update lvgl to the latest version
  • Reproduce the issue in a Simulator

Describe the bug

I remebered it use to work before,
but when using "True color chroma keyed" option, it generates empty c array data.
I've tried offline version with various png files but it gets same result.
(/lv_img_conv.js icon_free_c.png -f -c CF_TRUE_COLOR_CHROMA)

const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_IMG_IMG_1 uint8_t img_1_map[] = {
     ----- this is all blank -----  
};

const lv_img_dsc_t img_1 = {
  .header.always_zero = 0,
  .header.w = 100,
  .header.h = 100,
  .data_size = 10000 * LV_COLOR_SIZE / 8,
  .header.cf = LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED,
  .data = img_1_map,
};

Windows error when running

When running the script from Windows I get the following error:

C:\>%appdata%\npm\lv_img_conv
The system cannot find the path specified.

I've installed from the npm registry. How can I use this script in Windows cmd.exe?

R and B swap?

Hi,

I am not sure if this is an issue with the display that I am using, DT028BTFT, or the driver, but in order to get things functioning properly I had to add an additional option to this CLI tool, that not only swaps the bytes (565_SWAP), but R and B bits as well.

It's in a fork here.

Error: swc compiler requires either @swc/core or @swc/wasm to be installed...

When trying to install this globally, I encountered the following error:

$ lv_img_conv 
    /home/luda/.npm/_npx/1bf7c3c15bf47d04/node_modules/ts-node/src/transpilers/swc.ts:45
        throw new Error(
              ^
    Error: swc compiler requires either @swc/core or @swc/wasm to be installed as a dependency.  See https://typestrong.org/ts-node/docs/transpilers
    ...

After researching the issue, I could solve it by installing the devDependencies for ts-node.

$ cd lv_img_conv/
$ sudo npm install ts-node --save-dev
$ lv_img_conv 
  Options:
      --help               Show help                                       [boolean]
      --version            Show version number                             [boolean]
      --output-file, -o    output file path (for single-image conversion)   [string]
    ...

Consider this closed. I'm leaving this here in case it helps others as well

ARGB1555 and ARGB4444 support

For 16 bit color depth + Alpha now only the non-standard ARGB8565 format can be used. I think it'd be great to support ARGB1555 and ARGB4444 in LVGL hence GPUs could accelerate the drawing of 16 bit ARGB images too.

So the question is how difficult would it be to add support for these formats in the converter?

If the converter supported them, I could quickly made them work in LVGL.

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.