LittlevGL  3.20.00.19
Data Structures | Typedefs | Enumerations | Functions
lv_img_decoder.h File Reference
#include "../../../lv_conf.h"
#include <stdint.h>
#include "../lv_misc/lv_fs.h"
#include "../lv_misc/lv_types.h"
#include "../lv_misc/lv_area.h"
#include "../lv_core/lv_style.h"
Include dependency graph for lv_img_decoder.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  lv_img_header_t
 
struct  lv_img_dsc_t
 
struct  _lv_img_decoder
 
struct  _lv_img_decoder_dsc
 

Typedefs

typedef uint8_t lv_img_src_t
 
typedef uint8_t lv_img_cf_t
 
typedef lv_res_t(* lv_img_decoder_info_f_t) (struct _lv_img_decoder *decoder, const void *src, lv_img_header_t *header)
 
typedef lv_res_t(* lv_img_decoder_open_f_t) (struct _lv_img_decoder *decoder, struct _lv_img_decoder_dsc *dsc)
 
typedef lv_res_t(* lv_img_decoder_read_line_f_t) (struct _lv_img_decoder *decoder, struct _lv_img_decoder_dsc *dsc, lv_coord_t x, lv_coord_t y, lv_coord_t len, uint8_t *buf)
 
typedef void(* lv_img_decoder_close_f_t) (struct _lv_img_decoder *decoder, struct _lv_img_decoder_dsc *dsc)
 
typedef struct _lv_img_decoder lv_img_decoder_t
 
typedef struct _lv_img_decoder_dsc lv_img_decoder_dsc_t
 

Enumerations

enum  { LV_IMG_SRC_VARIABLE, LV_IMG_SRC_FILE, LV_IMG_SRC_SYMBOL, LV_IMG_SRC_UNKNOWN }
 
enum  {
  LV_IMG_CF_UNKNOWN = 0, LV_IMG_CF_RAW, LV_IMG_CF_RAW_ALPHA, LV_IMG_CF_RAW_CHROMA_KEYED,
  LV_IMG_CF_TRUE_COLOR, LV_IMG_CF_TRUE_COLOR_ALPHA, LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED, LV_IMG_CF_INDEXED_1BIT,
  LV_IMG_CF_INDEXED_2BIT, LV_IMG_CF_INDEXED_4BIT, LV_IMG_CF_INDEXED_8BIT, LV_IMG_CF_ALPHA_1BIT,
  LV_IMG_CF_ALPHA_2BIT, LV_IMG_CF_ALPHA_4BIT, LV_IMG_CF_ALPHA_8BIT, LV_IMG_CF_RESERVED_15,
  LV_IMG_CF_RESERVED_16, LV_IMG_CF_RESERVED_17, LV_IMG_CF_RESERVED_18, LV_IMG_CF_RESERVED_19,
  LV_IMG_CF_RESERVED_20, LV_IMG_CF_RESERVED_21, LV_IMG_CF_RESERVED_22, LV_IMG_CF_RESERVED_23,
  LV_IMG_CF_USER_ENCODED_0, LV_IMG_CF_USER_ENCODED_1, LV_IMG_CF_USER_ENCODED_2, LV_IMG_CF_USER_ENCODED_3,
  LV_IMG_CF_USER_ENCODED_4, LV_IMG_CF_USER_ENCODED_5, LV_IMG_CF_USER_ENCODED_6, LV_IMG_CF_USER_ENCODED_7
}
 

Functions

void lv_img_decoder_init (void)
 
lv_res_t lv_img_decoder_get_info (const char *src, lv_img_header_t *header)
 
lv_res_t lv_img_decoder_open (lv_img_decoder_dsc_t *dsc, const void *src, const lv_style_t *style)
 
lv_res_t lv_img_decoder_read_line (lv_img_decoder_dsc_t *dsc, lv_coord_t x, lv_coord_t y, lv_coord_t len, uint8_t *buf)
 
void lv_img_decoder_close (lv_img_decoder_dsc_t *dsc)
 
lv_img_decoder_tlv_img_decoder_create (void)
 
void lv_img_decoder_delete (lv_img_decoder_t *decoder)
 
void lv_img_decoder_set_info_cb (lv_img_decoder_t *decoder, lv_img_decoder_info_f_t info_cb)
 
void lv_img_decoder_set_open_cb (lv_img_decoder_t *decoder, lv_img_decoder_open_f_t open_cb)
 
void lv_img_decoder_set_read_line_cb (lv_img_decoder_t *decoder, lv_img_decoder_read_line_f_t read_line_cb)
 
void lv_img_decoder_set_close_cb (lv_img_decoder_t *decoder, lv_img_decoder_close_f_t close_cb)
 
lv_res_t lv_img_decoder_built_in_info (lv_img_decoder_t *decoder, const void *src, lv_img_header_t *header)
 
lv_res_t lv_img_decoder_built_in_open (lv_img_decoder_t *decoder, lv_img_decoder_dsc_t *dsc)
 
lv_res_t lv_img_decoder_built_in_read_line (lv_img_decoder_t *decoder, lv_img_decoder_dsc_t *dsc, lv_coord_t x, lv_coord_t y, lv_coord_t len, uint8_t *buf)
 
void lv_img_decoder_built_in_close (lv_img_decoder_t *decoder, lv_img_decoder_dsc_t *dsc)
 

Typedef Documentation

§ lv_img_src_t

typedef uint8_t lv_img_src_t

§ lv_img_cf_t

typedef uint8_t lv_img_cf_t

§ lv_img_decoder_info_f_t

typedef lv_res_t(* lv_img_decoder_info_f_t) (struct _lv_img_decoder *decoder, const void *src, lv_img_header_t *header)

Get info from an image and store in the header

Parameters
srcthe image source. Can be a pointer to a C array or a file name (Use lv_img_src_get_type to determine the type)
headerstore the info here
Returns
LV_RES_OK: info written correctly; LV_RES_INV: failed

§ lv_img_decoder_open_f_t

typedef lv_res_t(* lv_img_decoder_open_f_t) (struct _lv_img_decoder *decoder, struct _lv_img_decoder_dsc *dsc)

Open an image for decoding. Prepare it as it is required to read it later

Parameters
decoderpointer to the decoder the function associated with
dscpointer to decoder descriptor. src, style are already initialized in it.

§ lv_img_decoder_read_line_f_t

typedef lv_res_t(* lv_img_decoder_read_line_f_t) (struct _lv_img_decoder *decoder, struct _lv_img_decoder_dsc *dsc, lv_coord_t x, lv_coord_t y, lv_coord_t len, uint8_t *buf)

Decode len pixels starting from the given x, y coordinates and store them in buf. Required only if the "open" function can't return with the whole decoded pixel array.

Parameters
decoderpointer to the decoder the function associated with
dscpointer to decoder descriptor
xstart x coordinate
ystart y coordinate
lennumber of pixels to decode
bufa buffer to store the decoded pixels
Returns
LV_RES_OK: ok; LV_RES_INV: failed

§ lv_img_decoder_close_f_t

typedef void(* lv_img_decoder_close_f_t) (struct _lv_img_decoder *decoder, struct _lv_img_decoder_dsc *dsc)

Close the pending decoding. Free resources etc.

Parameters
decoderpointer to the decoder the function associated with
dscpointer to decoder descriptor

§ lv_img_decoder_t

§ lv_img_decoder_dsc_t

Describe an image decoding session. Stores data about the decoding

Enumeration Type Documentation

§ anonymous enum

anonymous enum

Source of image.

Enumerator
LV_IMG_SRC_VARIABLE 
LV_IMG_SRC_FILE 

Binary/C variable

LV_IMG_SRC_SYMBOL 

File in filesystem

LV_IMG_SRC_UNKNOWN 

Symbol (lv_symbol_def.h)

§ anonymous enum

anonymous enum
Enumerator
LV_IMG_CF_UNKNOWN 
LV_IMG_CF_RAW 

Contains the file as it is. Needs custom decoder function

LV_IMG_CF_RAW_ALPHA 

Contains the file as it is. The image has alpha. Needs custom decoder function

LV_IMG_CF_RAW_CHROMA_KEYED 

Contains the file as it is. The image is chroma keyed. Needs custom decoder function

LV_IMG_CF_TRUE_COLOR 

Color format and depth should match with LV_COLOR settings

LV_IMG_CF_TRUE_COLOR_ALPHA 

Same as LV_IMG_CF_TRUE_COLOR but every pixel has an alpha byte

LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED 

Same as LV_IMG_CF_TRUE_COLOR but LV_COLOR_TRANSP pixels will be transparent

LV_IMG_CF_INDEXED_1BIT 

Can have 2 different colors in a palette (always chroma keyed)

LV_IMG_CF_INDEXED_2BIT 

Can have 4 different colors in a palette (always chroma keyed)

LV_IMG_CF_INDEXED_4BIT 

Can have 16 different colors in a palette (always chroma keyed)

LV_IMG_CF_INDEXED_8BIT 

Can have 256 different colors in a palette (always chroma keyed)

LV_IMG_CF_ALPHA_1BIT 

Can have one color and it can be drawn or not

LV_IMG_CF_ALPHA_2BIT 

Can have one color but 4 different alpha value

LV_IMG_CF_ALPHA_4BIT 

Can have one color but 16 different alpha value

LV_IMG_CF_ALPHA_8BIT 

Can have one color but 256 different alpha value

LV_IMG_CF_RESERVED_15 

Reserved for further use.

LV_IMG_CF_RESERVED_16 

Reserved for further use.

LV_IMG_CF_RESERVED_17 

Reserved for further use.

LV_IMG_CF_RESERVED_18 

Reserved for further use.

LV_IMG_CF_RESERVED_19 

Reserved for further use.

LV_IMG_CF_RESERVED_20 

Reserved for further use.

LV_IMG_CF_RESERVED_21 

Reserved for further use.

LV_IMG_CF_RESERVED_22 

Reserved for further use.

LV_IMG_CF_RESERVED_23 

Reserved for further use.

LV_IMG_CF_USER_ENCODED_0 

User holder encoding format.

LV_IMG_CF_USER_ENCODED_1 

User holder encoding format.

LV_IMG_CF_USER_ENCODED_2 

User holder encoding format.

LV_IMG_CF_USER_ENCODED_3 

User holder encoding format.

LV_IMG_CF_USER_ENCODED_4 

User holder encoding format.

LV_IMG_CF_USER_ENCODED_5 

User holder encoding format.

LV_IMG_CF_USER_ENCODED_6 

User holder encoding format.

LV_IMG_CF_USER_ENCODED_7 

User holder encoding format.

Function Documentation

§ lv_img_decoder_init()

void lv_img_decoder_init ( void  )

Initialize the image decoder module

§ lv_img_decoder_get_info()

lv_res_t lv_img_decoder_get_info ( const char *  src,
lv_img_header_t header 
)

Get information about an image. Try the created image decoder one by one. Once one is able to get info that info will be used.

Parameters
srcthe image source. Can be 1) File name: E.g. "S:folder/img1.png" (The drivers needs to registered via lv_fs_add_drv()) 2) Variable: Pointer to an lv_img_dsc_t variable 3) Symbol: E.g. LV_SYMBOL_OK
headerthe image info will be stored here
Returns
LV_RES_OK: success; LV_RES_INV: wasn't able to get info about the image

§ lv_img_decoder_open()

lv_res_t lv_img_decoder_open ( lv_img_decoder_dsc_t dsc,
const void *  src,
const lv_style_t style 
)

Open an image. Try the created image decoder one by one. Once one is able to open the image that decoder is save in dsc

Parameters
dscdescribe a decoding session. Simply a pointer to an lv_img_decoder_dsc_t variable.
srcthe image source. Can be 1) File name: E.g. "S:folder/img1.png" (The drivers needs to registered via lv_fs_add_drv()) 2) Variable: Pointer to an lv_img_dsc_t variable 3) Symbol: E.g. LV_SYMBOL_OK
stylethe style of the image
Returns
LV_RES_OK: opened the image. dsc->img_data and dsc->header are set. LV_RES_INV: none of the registered image decoders were able to open the image.

§ lv_img_decoder_read_line()

lv_res_t lv_img_decoder_read_line ( lv_img_decoder_dsc_t dsc,
lv_coord_t  x,
lv_coord_t  y,
lv_coord_t  len,
uint8_t *  buf 
)

Read a line from an opened image

Parameters
dscpointer to lv_img_decoder_dsc_t used in lv_img_decoder_open
xstart X coordinate (from left)
ystart Y coordinate (from top)
lennumber of pixels to read
bufstore the data here
Returns
LV_RES_OK: success; LV_RES_INV: an error occurred

§ lv_img_decoder_close()

void lv_img_decoder_close ( lv_img_decoder_dsc_t dsc)

Close a decoding session

Parameters
dscpointer to lv_img_decoder_dsc_t used in lv_img_decoder_open

§ lv_img_decoder_create()

lv_img_decoder_t* lv_img_decoder_create ( void  )

Create a new image decoder

Returns
pointer to the new image decoder

§ lv_img_decoder_delete()

void lv_img_decoder_delete ( lv_img_decoder_t decoder)

Delete an image decoder

Parameters
decoderpointer to an image decoder

§ lv_img_decoder_set_info_cb()

void lv_img_decoder_set_info_cb ( lv_img_decoder_t decoder,
lv_img_decoder_info_f_t  info_cb 
)

Set a callback to get information about the image

Parameters
decoderpointer to an image decoder
info_cba function to collect info about an image (fill an lv_img_header_t struct)

§ lv_img_decoder_set_open_cb()

void lv_img_decoder_set_open_cb ( lv_img_decoder_t decoder,
lv_img_decoder_open_f_t  open_cb 
)

Set a callback to open an image

Parameters
decoderpointer to an image decoder
open_cba function to open an image

§ lv_img_decoder_set_read_line_cb()

void lv_img_decoder_set_read_line_cb ( lv_img_decoder_t decoder,
lv_img_decoder_read_line_f_t  read_line_cb 
)

Set a callback to a decoded line of an image

Parameters
decoderpointer to an image decoder
read_line_cba function to read a line of an image

§ lv_img_decoder_set_close_cb()

void lv_img_decoder_set_close_cb ( lv_img_decoder_t decoder,
lv_img_decoder_close_f_t  close_cb 
)

Set a callback to close a decoding session. E.g. close files and free other resources.

Parameters
decoderpointer to an image decoder
close_cba function to close a decoding session

§ lv_img_decoder_built_in_info()

lv_res_t lv_img_decoder_built_in_info ( lv_img_decoder_t decoder,
const void *  src,
lv_img_header_t header 
)

Get info about a built-in image

Parameters
decoderthe decoder where this function belongs
srcthe image source: pointer to an lv_img_dsc_t variable, a file path or a symbol
headerstore the image data here
Returns
LV_RES_OK: the info is successfully stored in header; LV_RES_INV: unknown format or other error.

§ lv_img_decoder_built_in_open()

lv_res_t lv_img_decoder_built_in_open ( lv_img_decoder_t decoder,
lv_img_decoder_dsc_t dsc 
)

Open a built in image

Parameters
decoderthe decoder where this function belongs
dscpointer to decoder descriptor. src, style are already initialized in it.
Returns
LV_RES_OK: the info is successfully stored in header; LV_RES_INV: unknown format or other error.

§ lv_img_decoder_built_in_read_line()

lv_res_t lv_img_decoder_built_in_read_line ( lv_img_decoder_t decoder,
lv_img_decoder_dsc_t dsc,
lv_coord_t  x,
lv_coord_t  y,
lv_coord_t  len,
uint8_t *  buf 
)

Decode len pixels starting from the given x, y coordinates and store them in buf. Required only if the "open" function can't return with the whole decoded pixel array.

Parameters
decoderpointer to the decoder the function associated with
dscpointer to decoder descriptor
xstart x coordinate
ystart y coordinate
lennumber of pixels to decode
bufa buffer to store the decoded pixels
Returns
LV_RES_OK: ok; LV_RES_INV: failed

§ lv_img_decoder_built_in_close()

void lv_img_decoder_built_in_close ( lv_img_decoder_t decoder,
lv_img_decoder_dsc_t dsc 
)

Close the pending decoding. Free resources etc.

Parameters
decoderpointer to the decoder the function associated with
dscpointer to decoder descriptor
© Copyright 1995-2019, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale