1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-14 06:42:58 +08:00
lvgl/lv_objx/lv_img.h

159 lines
4.1 KiB
C
Raw Normal View History

2016-06-08 07:25:08 +02:00
/**
* @file lv_img.h
*
*/
#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
*********************/
#include "lv_conf.h"
2017-01-02 10:48:21 +01:00
#include "misc_conf.h"
#if USE_LV_IMG != 0 && USE_FSINT != 0
2017-01-15 21:52:21 +01:00
2016-06-08 07:25:08 +02:00
#include "../lv_obj/lv_obj.h"
2017-11-21 10:35:57 +01:00
#include "lvgl/misc/fs/fsint.h"
2016-06-08 07:25:08 +02:00
2017-04-24 16:16:36 +02:00
#ifndef LV_IMG_ENABLE_SYMBOLS
#define LV_IMG_ENABLE_SYMBOLS 0
#endif
#if LV_IMG_ENABLE_SYMBOLS != 0
2017-01-16 12:30:22 +01:00
#include "lv_label.h"
2017-11-21 10:35:57 +01:00
#include "lvgl/misc/gfx/fonts/symbol_def.h"
2017-01-16 12:30:22 +01:00
#endif
2016-06-08 07:25:08 +02:00
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/*Data of image*/
typedef struct
{
/*No inherited ext. because inherited from the base object*/ /*Ext. of ancestor*/
/*New data for this type */
2017-04-21 17:11:47 +02:00
char* fn; /*Image file name. E.g. "U:/my_image"*/
cord_t w; /*Width of the image (doubled when upscaled) (Handled by the library)*/
cord_t h; /*Height of the image (doubled when upscaled) (Handled by the library)*/
uint8_t auto_size :1; /*1: automatically set the object size to the image size*/
uint8_t upscale :1; /*1: upscale to double size with antialaissing*/
uint8_t transp :1; /*Transp. bit in the image header (Handled by the library)*/
}lv_img_ext_t;
2016-10-07 11:15:46 +02:00
2016-06-08 07:25:08 +02:00
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* 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
* @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
/**
* Create a file to the RAMFS from a picture data
* @param fn file name of the new file (e.g. "pic1", will be available at "U:/pic1")
* @param data pointer to a color map with lv_img_raw_header_t header
* @return result of the file operation. FS_RES_OK or any error from fs_res_t
*/
fs_res_t lv_img_create_file(const char * fn, const color_int_t * data);
2017-11-13 16:11:05 +01:00
/*=====================
* Setter functions
*====================*/
/**
* Set a file to the image
* @param img pointer to an image object
* @param fn file name in the RAMFS to set as picture (e.g. "U:/pic1").
*/
2016-10-07 11:15:46 +02:00
void lv_img_set_file(lv_obj_t * img, const char * fn);
/**
* 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-11-13 16:11:05 +01:00
void lv_img_set_auto_size(lv_obj_t * img, bool autosize_en);
/**
2017-11-13 16:11:05 +01:00
* Enable the upscaling if LV_ANTIALIAS is enabled.
2017-04-21 17:11:47 +02:00
* If enabled the object size will be same as the picture size.
* @param img pointer to an image
* @param en true: upscale enable, false: upscale disable
*/
void lv_img_set_upscale(lv_obj_t * img, bool en);
2016-06-08 07:25:08 +02: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);
}
/*=====================
* Getter functions
*====================*/
/**
* 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-11-13 16:11:05 +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);
/**
* Get the upscale enable attribute
* @param img pointer to an image
* @return true: upscale is enabled, false: upscale is disabled
*/
bool lv_img_get_upscale(lv_obj_t * img);
2016-06-08 07:25:08 +02:00
2017-11-13 16:11:05 +01:00
/**
* Get the style of an image object
* @param img pointer to an image object
* @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);
}
2016-06-08 07:25:08 +02:00
/**********************
* MACROS
**********************/
/*Use this macro to declare an image in a c file*/
2016-10-07 11:15:46 +02:00
#define LV_IMG_DECLARE(var_name) extern const color_int_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*/