Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
CTCaer
GitHub Repository: CTCaer/hekate
Path: blob/master/bdk/libs/lvgl/lv_objx/lv_img.h
1476 views
1
/**
2
* @file lv_img.h
3
*
4
*/
5
6
#ifndef LV_IMG_H
7
#define LV_IMG_H
8
9
#ifdef __cplusplus
10
extern "C" {
11
#endif
12
13
/*********************
14
* INCLUDES
15
*********************/
16
#ifdef LV_CONF_INCLUDE_SIMPLE
17
#include "lv_conf.h"
18
#else
19
#include "../../lv_conf.h"
20
#endif
21
22
#if USE_LV_IMG != 0
23
24
#include "../lv_core/lv_obj.h"
25
#include "../lv_misc/lv_fs.h"
26
#include "../lv_misc/lv_symbol_def.h"
27
#include "lv_label.h"
28
#include "../lv_draw/lv_draw.h"
29
30
/*********************
31
* DEFINES
32
*********************/
33
34
/**********************
35
* TYPEDEFS
36
**********************/
37
/*Data of image*/
38
typedef struct
39
{
40
/*No inherited ext. because inherited from the base object*/ /*Ext. of ancestor*/
41
/*New data for this type */
42
const void * src; /*Image source: Pointer to an array or a file or a symbol*/
43
44
lv_coord_t w; /*Width of the image (Handled by the library)*/
45
lv_coord_t h; /*Height of the image (Handled by the library)*/
46
#if USE_LV_MULTI_LANG
47
uint16_t lang_txt_id; /*The ID of the image to display. */
48
#endif
49
uint8_t src_type :2; /*See: lv_img_src_t*/
50
uint8_t auto_size :1; /*1: automatically set the object size to the image size*/
51
uint8_t cf :5; /*Color format from `lv_img_color_format_t`*/
52
} lv_img_ext_t;
53
54
/**********************
55
* GLOBAL PROTOTYPES
56
**********************/
57
58
/**
59
* Create an image objects
60
* @param par pointer to an object, it will be the parent of the new button
61
* @param copy pointer to a image object, if not NULL then the new object will be copied from it
62
* @return pointer to the created image
63
*/
64
lv_obj_t * lv_img_create(lv_obj_t * par, const lv_obj_t * copy);
65
66
/*=====================
67
* Setter functions
68
*====================*/
69
70
/**
71
* Set the pixel map to display by the image
72
* @param img pointer to an image object
73
* @param data the image data
74
*/
75
void lv_img_set_src(lv_obj_t * img, const void * src_img);
76
77
#if USE_LV_MULTI_LANG
78
/**
79
* Set an ID which means a the same source but on different languages
80
* @param img pointer to an image object
81
* @param src_id ID of the source
82
*/
83
void lv_img_set_src_id(lv_obj_t * img, uint32_t txt_id);
84
#endif
85
86
/**
87
* Obsolete since v5.1. Just for compatibility with v5.0. Will be removed in v6.0.
88
* Use 'lv_img_set_src()' instead.
89
* @param img -
90
* @param fn -
91
*/
92
static inline void lv_img_set_file(lv_obj_t * img, const char * fn)
93
{
94
(void) img;
95
(void) fn;
96
}
97
98
/**
99
* Enable the auto size feature.
100
* If enabled the object size will be same as the picture size.
101
* @param img pointer to an image
102
* @param en true: auto size enable, false: auto size disable
103
*/
104
void lv_img_set_auto_size(lv_obj_t * img, bool autosize_en);
105
106
/**
107
* Set the style of an image
108
* @param img pointer to an image object
109
* @param style pointer to a style
110
*/
111
static inline void lv_img_set_style(lv_obj_t *img, lv_style_t *style)
112
{
113
lv_obj_set_style(img, style);
114
}
115
116
/**
117
* Obsolete since v5.1. Just for compatibility with v5.0. Will be removed in v6.0
118
* @param img -
119
* @param upscale -
120
*/
121
static inline void lv_img_set_upscale(lv_obj_t * img, bool upcale)
122
{
123
(void) img;
124
(void) upcale;
125
}
126
127
/*=====================
128
* Getter functions
129
*====================*/
130
131
/**
132
* Get the source of the image
133
* @param img pointer to an image object
134
* @return the image source (symbol, file name or C array)
135
*/
136
const void * lv_img_get_src(lv_obj_t * img);
137
138
/**
139
* Get the name of the file set for an image
140
* @param img pointer to an image
141
* @return file name
142
*/
143
const char * lv_img_get_file_name(const lv_obj_t * img);
144
145
#if USE_LV_MULTI_LANG
146
/**
147
* Get the source ID of the image. (Used by the multi-language feature)
148
* @param img pointer to an image
149
* @return ID of the source
150
*/
151
uint16_t lv_img_get_src_id(lv_obj_t * img);
152
#endif
153
154
/**
155
* Get the auto size enable attribute
156
* @param img pointer to an image
157
* @return true: auto size is enabled, false: auto size is disabled
158
*/
159
bool lv_img_get_auto_size(const lv_obj_t * img);
160
161
/**
162
* Get the style of an image object
163
* @param img pointer to an image object
164
* @return pointer to the image's style
165
*/
166
static inline lv_style_t* lv_img_get_style(const lv_obj_t *img)
167
{
168
return lv_obj_get_style(img);
169
}
170
171
/**
172
* Obsolete since v5.1. Just for compatibility with v5.0. Will be removed in v6.0
173
* @param img -
174
* @return false
175
*/
176
static inline bool lv_img_get_upscale(const lv_obj_t * img)
177
{
178
(void)img;
179
return false;
180
}
181
182
/**********************
183
* MACROS
184
**********************/
185
186
/*Use this macro to declare an image in a c file*/
187
#define LV_IMG_DECLARE(var_name) extern const lv_img_dsc_t var_name;
188
189
#endif /*USE_LV_IMG*/
190
191
#ifdef __cplusplus
192
} /* extern "C" */
193
#endif
194
195
#endif /*LV_IMG_H*/
196
197