2016-06-08 07:25:08 +02:00
|
|
|
/**
|
|
|
|
* @file lv_img.h
|
2018-06-19 09:49:58 +02:00
|
|
|
*
|
2016-06-08 07:25:08 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef LV_IMG_H
|
|
|
|
#define LV_IMG_H
|
|
|
|
|
2017-07-09 15:32:49 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2016-06-08 07:25:08 +02:00
|
|
|
/*********************
|
|
|
|
* INCLUDES
|
|
|
|
*********************/
|
2017-11-26 23:57:39 +01:00
|
|
|
#include "../../lv_conf.h"
|
2017-11-26 11:38:28 +01:00
|
|
|
#if USE_LV_IMG != 0
|
2017-01-15 21:52:21 +01:00
|
|
|
|
2017-11-30 11:35:33 +01:00
|
|
|
#include "../lv_core/lv_obj.h"
|
2017-11-23 20:42:14 +01:00
|
|
|
#include "../lv_misc/lv_fs.h"
|
2017-12-11 23:11:15 +01:00
|
|
|
#include "../lv_misc/lv_fonts/lv_symbol_def.h"
|
2017-11-26 11:38:28 +01:00
|
|
|
#include "lv_label.h"
|
2018-02-09 12:40:00 +01:00
|
|
|
#include "../lv_draw/lv_draw.h"
|
2017-01-16 12:30:22 +01:00
|
|
|
|
2016-06-08 07:25:08 +02:00
|
|
|
/*********************
|
|
|
|
* DEFINES
|
|
|
|
*********************/
|
|
|
|
|
|
|
|
/**********************
|
|
|
|
* TYPEDEFS
|
|
|
|
**********************/
|
2017-01-14 23:54:16 +01:00
|
|
|
/*Data of image*/
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
/*No inherited ext. because inherited from the base object*/ /*Ext. of ancestor*/
|
|
|
|
/*New data for this type */
|
2018-02-23 13:56:04 +01:00
|
|
|
const void * src; /*Image source: Pointer to an array or a file or a symbol*/
|
|
|
|
|
2018-04-05 22:21:44 +02:00
|
|
|
lv_coord_t w; /*Width of the image (Handled by the library)*/
|
|
|
|
lv_coord_t h; /*Height of the image (Handled by the library)*/
|
2018-02-23 13:56:04 +01:00
|
|
|
uint8_t src_type :2; /*See: lv_img_src_t*/
|
2017-04-21 17:11:47 +02:00
|
|
|
uint8_t auto_size :1; /*1: automatically set the object size to the image size*/
|
2018-02-23 13:56:04 +01:00
|
|
|
uint8_t chroma_keyed :1; /*1: Chroma keyed image, LV_COLOR_TRANSP (lv_conf.h) pixels will be transparent (Handled by the library)*/
|
|
|
|
uint8_t alpha_byte :1; /*1: Extra byte for every pixel to define opacity*/
|
2018-06-19 09:49:58 +02:00
|
|
|
} lv_img_ext_t;
|
2016-10-07 11:15:46 +02:00
|
|
|
|
2016-06-08 07:25:08 +02:00
|
|
|
/**********************
|
|
|
|
* GLOBAL PROTOTYPES
|
|
|
|
**********************/
|
2017-01-14 23:54:16 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create an image objects
|
|
|
|
* @param par pointer to an object, it will be the parent of the new button
|
2017-04-21 17:11:47 +02:00
|
|
|
* @param copy pointer to a image object, if not NULL then the new object will be copied from it
|
2017-01-14 23:54:16 +01:00
|
|
|
* @return pointer to the created image
|
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_t * lv_img_create(lv_obj_t * par, lv_obj_t * copy);
|
2016-06-08 07:25:08 +02:00
|
|
|
|
2017-11-13 16:11:05 +01:00
|
|
|
/*=====================
|
|
|
|
* Setter functions
|
|
|
|
*====================*/
|
|
|
|
|
2018-02-23 13:56:04 +01:00
|
|
|
/**
|
|
|
|
* Set the pixel map to display by the image
|
|
|
|
* @param img pointer to an image object
|
|
|
|
* @param data the image data
|
|
|
|
*/
|
|
|
|
void lv_img_set_src(lv_obj_t * img, const void * src_img);
|
|
|
|
|
2017-01-14 23:54:16 +01:00
|
|
|
/**
|
2018-02-23 17:03:00 +01:00
|
|
|
* Obsolete since v5.1. Just for compatibility with v5.0. Will be removed in v6.0.
|
|
|
|
* Use 'lv_img_set_src()' instead.
|
2018-04-05 22:21:44 +02:00
|
|
|
* @param img -
|
|
|
|
* @param fn -
|
2017-01-14 23:54:16 +01:00
|
|
|
*/
|
2018-02-23 17:03:00 +01:00
|
|
|
static inline void lv_img_set_file(lv_obj_t * img, const char * fn)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
2017-01-14 23:54:16 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Enable the auto size feature.
|
|
|
|
* If enabled the object size will be same as the picture size.
|
|
|
|
* @param img pointer to an image
|
2017-11-13 16:11:05 +01:00
|
|
|
* @param autosize_en true: auto size enable, false: auto size disable
|
2017-01-14 23:54:16 +01:00
|
|
|
*/
|
2017-11-13 16:11:05 +01:00
|
|
|
void lv_img_set_auto_size(lv_obj_t * img, bool autosize_en);
|
2017-01-14 23:54:16 +01:00
|
|
|
|
2017-11-13 16:11:05 +01:00
|
|
|
/**
|
|
|
|
* Set the style of an image
|
|
|
|
* @param img pointer to an image object
|
|
|
|
* @param style pointer to a style
|
|
|
|
*/
|
|
|
|
static inline void lv_img_set_style(lv_obj_t *img, lv_style_t *style)
|
|
|
|
{
|
|
|
|
lv_obj_set_style(img, style);
|
|
|
|
}
|
|
|
|
|
2018-02-23 17:03:00 +01:00
|
|
|
/**
|
|
|
|
* Obsolete since v5.1. Just for compatibility with v5.0. Will be removed in v6.0
|
2018-04-05 22:21:44 +02:00
|
|
|
* @param img -
|
|
|
|
* @param upscale -
|
2018-02-23 17:03:00 +01:00
|
|
|
*/
|
|
|
|
static inline void lv_img_set_upscale(lv_obj_t * img, bool upcale)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-11-13 16:11:05 +01:00
|
|
|
/*=====================
|
|
|
|
* Getter functions
|
|
|
|
*====================*/
|
|
|
|
|
2018-02-23 17:03:00 +01:00
|
|
|
/**
|
|
|
|
* Get the type of an image source
|
|
|
|
* @param src pointer to an image source:
|
|
|
|
* - pointer to an 'lv_img_t' variable (image stored internally and compiled into the code)
|
|
|
|
* - a path to an file (e.g. "S:/folder/image.bin")
|
|
|
|
* - or a symbol (e.g. SYMBOL_CLOSE)
|
|
|
|
* @return type of the image source LV_IMG_SRC_VARIABLE/FILE/SYMBOL/UNKOWN
|
|
|
|
*/
|
2018-02-23 13:56:04 +01:00
|
|
|
lv_img_src_t lv_img_get_src_type(const void * src);
|
|
|
|
|
2018-02-23 17:03:00 +01:00
|
|
|
|
2017-10-31 16:25:52 +01:00
|
|
|
/**
|
|
|
|
* Get the name of the file set for an image
|
|
|
|
* @param img pointer to an image
|
|
|
|
* @return file name
|
|
|
|
*/
|
|
|
|
const char * lv_img_get_file_name(lv_obj_t * img);
|
|
|
|
|
2017-01-14 23:54:16 +01:00
|
|
|
/**
|
|
|
|
* Get the auto size enable attribute
|
|
|
|
* @param img pointer to an image
|
|
|
|
* @return true: auto size is enabled, false: auto size is disabled
|
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
bool lv_img_get_auto_size(lv_obj_t * img);
|
2017-01-14 23:54:16 +01:00
|
|
|
|
2017-11-13 16:11:05 +01:00
|
|
|
/**
|
|
|
|
* Get the style of an image object
|
|
|
|
* @param img pointer to an image object
|
2017-11-15 15:50:33 +01:00
|
|
|
* @return pointer to the image's style
|
2017-11-13 16:11:05 +01:00
|
|
|
*/
|
|
|
|
static inline lv_style_t* lv_img_get_style(lv_obj_t *img)
|
|
|
|
{
|
|
|
|
return lv_obj_get_style(img);
|
|
|
|
}
|
|
|
|
|
2018-02-23 17:03:00 +01:00
|
|
|
/**
|
|
|
|
* Obsolete since v5.1. Just for compatibility with v5.0. Will be removed in v6.0
|
2018-04-05 22:21:44 +02:00
|
|
|
* @param img -
|
2018-02-23 17:03:00 +01:00
|
|
|
* @return false
|
|
|
|
*/
|
|
|
|
static inline bool lv_img_get_upscale(lv_obj_t * img)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-06-08 07:25:08 +02:00
|
|
|
/**********************
|
|
|
|
* MACROS
|
|
|
|
**********************/
|
2017-01-14 23:54:16 +01:00
|
|
|
|
|
|
|
/*Use this macro to declare an image in a c file*/
|
2018-02-23 13:56:04 +01:00
|
|
|
#define LV_IMG_DECLARE(var_name) extern const lv_img_t var_name;
|
2016-06-08 07:25:08 +02:00
|
|
|
|
2017-07-09 15:32:49 +02:00
|
|
|
#endif /*USE_LV_IMG*/
|
2016-06-08 07:25:08 +02:00
|
|
|
|
2017-07-09 15:32:49 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
} /* extern "C" */
|
2016-06-08 07:25:08 +02:00
|
|
|
#endif
|
2017-07-09 15:32:49 +02:00
|
|
|
|
|
|
|
#endif /*LV_IMG_H*/
|