Image converter

Converting image file

The LittleV Graphics Library uses a simple raw image format to display images. You can convert your images to this format using a Python script located at lv_utils/img_conv.
In order to use the script you have to install Python on your computer. If you are a Linux user probably it is already installed.

Open a Terminal and try out the script:

python img_conv.py --help

If it dosn't work try reach Python directly. For example:

C:/Python27/python img_conv.py --help

Next to the scrip there is a test.jpg file. To convert it type:

python img_conv.py -f test.jpg -c 16

It will create 2 files:

  • C source file
  • binaray fie

The C file contains color arrays with 1, 8, 16 and 24 color depths as well. The color depth of the binary file is specified by the -b flag.

To mark the image as chroma keyed the -t flag can be assigned. It this case LV_COLOR_TRANSP (defined in lv_conf.h) colors will be transparent.

Use the converted image file

The Littlev Graphics Library uses the images as files and not simple variables. Due to this the images can be displayed from the program memory or any external memory (e.g. SD card) in the same way.

Image sotored in the flash

The simpler case when you are using the C file. You just need to copy it somewhere in your project to compaile it with other source codes.

In a source file, where you would like to use the image declare the image variable in the following way:

LV_IMG_DECLARE(img_test);

To create a file from the variable into the RAM file system do this:

lv_img_create_file("image_file1", img_test);

It will create a file as: U:/image_file1.

Then just create an image object and set the file for it.

lv_obj_t *img = lv_img_create(lv_scr_act(), NULL);	/*Create an image object*/
lv_img_set_file(img, "U:/image_file1");		        /*Set the file to display by the image object*/

Image sotored externally

To use files from external memory in LittlevGL you need to register some basic functions in the library (open, close, read etc.) To learn more see the tutorial.

If you registered for example an SD card (with drive letter S) and copied the binary file to it you can set the file for an image:

lv_obj_t * img = lv_img_create(lv_scr_act(), NULL);	/*Create an image object*/
lv_img_set_file(img, "S:/img_file1.bin");		    /*Set the file to display by the image object*/

LittlevGL - Open-source Embedded GUI Library

LittlevGL is a free and open-source graphics library providing everything you need to create embedded GUI with easy-to-use graphical elements, beautiful visual effects and low memory footprint.

If you like LittlevGL, please
support its deveopment!


The founder of Littlev Graphics Library (LittlevGL) and related software modules is:
Gábor Kiss-Vámosi
All Rights Reserved ©  2018 Hungary