GithubHelp home page GithubHelp logo

12zz / lv_utils Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lvgl/lv_utils

0.0 1.0 0.0 6.55 MB

Convert images or system fonts to C arrays. Written for LittlevGL embedded GUI library

Home Page: https://littlevgl.com

Python 100.00%

lv_utils's Introduction

Utilities

Utilities to convert

  • pictures
  • operation system fonts

to raw C arrays.

The utilities are written to be compatible with the Littlev Graphics Library.

GitHub: https://github.com/littlevgl/lvgl Website: https://littlevgl.com

Usage

Both of the utilities are Python scripts. So you has to install Python on your operation system.

Clone or download the repository: git clone https://github.com/littlevgl/lv_utils.git

Image converter

It vraetes a c and a bin file fro mthe image. The c file contains 8, 16 and 32 bit color depth arrays but the binary file containsonly the specified color depth (see below)

The c file can be copied and cmpiled with your project. The binary file an be used on external memory devices (e.g. SD card)

  1. Copy an image to img_conv folder
  2. Open a Terminal and go to this directory
  3. Type to the Terminal: python img_cony.py -f test.png -c 16. Parameters:
    • -f: Image file name
    • -c Color depth: 8/16/24 (only for the binary file)
    • -t Chroma keyed: pixels with a specific color (lv_conf.h LV_COLOR_TRANSP) are not drawn
  4. Check the output img_test.c and img_test.bin

For more information visit: https://littlevgl.com/image-converter

Font converter

fnt2c.py reads bitmap font output from the Bitmap Font Generator by AngelCode: http://www.angelcode.com/products/bmfont/ and outputs byte table arrays in C language which is compatible with LittlevGL fonts.

  1. Install BMfont with font_create/install_bmfont_1.13.exe
  2. Open BMfont:
    1. In Options/Font settings choose a font, set its size and other settings (bold, italian etc.)
    2. In Options/Export settings choose XML file format and .png texture. Set the texture width and height to 2048.
    3. Save the fnt file: Options/Save bitmap font as…
  3. fnt2.c.py usage: python fnt2c.py -f <font_name> [-o <output file> -s <start unicode> -e <end unicide>]
    • -f, --font name of the font file without any extension (e.g. arial_10)
    • -o, --output name of the output file without any extension (e.g. arial_10_cyrillic). Optional, default: font name
    • -s, --start first unicode charater to convert (e.g. 1024). Optional, default: 32
    • -e, --end last unicode charater to convert (e.g. 1279). Optional, default: 126
  4. Convert the ASCII characters from dejavu_20.fnt/png and save to devaju_20.c/h:
    • python fnt2c.py -f dejavu_20
  5. Convert the Cyrillic code page from dejavu_20.fnt/png and save to devaju_20_cyrillic.c/h:
    • python fnt2c.py -f dejavu_20 -o dejavu_20_cyrillic -s 1024 -e 1279

e them in your project

For more information visit: https://littlevgl.com/font-converter

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.