1 /**
2  * @file lv_draw_img.h
3  *
4  */
5 
6 #ifndef LV_DRAW_IMG_H
7 #define LV_DRAW_IMG_H
8 
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12 
13 /*********************
14  *      INCLUDES
15  *********************/
16 #include "lv_draw.h"
17 #include "lv_img_decoder.h"
18 
19 /*********************
20  *      DEFINES
21  *********************/
22 
23 /**********************
24  *      TYPEDEFS
25  **********************/
26 
27 /**********************
28  * GLOBAL PROTOTYPES
29  **********************/
30 
31 /**
32  * Draw an image
33  * @param coords the coordinates of the image
34  * @param mask the image will be drawn only in this area
35  * @param src pointer to a lv_color_t array which contains the pixels of the image
36  * @param style style of the image
37  * @param opa_scale scale down all opacities by the factor
38  */
39 void lv_draw_img(const lv_area_t * coords, const lv_area_t * mask, const void * src, const lv_style_t * style,
40                  lv_opa_t opa_scale);
41 
42 /**
43  * Get the type of an image source
44  * @param src pointer to an image source:
45  *  - pointer to an 'lv_img_t' variable (image stored internally and compiled into the code)
46  *  - a path to a file (e.g. "S:/folder/image.bin")
47  *  - or a symbol (e.g. LV_SYMBOL_CLOSE)
48  * @return type of the image source LV_IMG_SRC_VARIABLE/FILE/SYMBOL/UNKNOWN
49  */
50 lv_img_src_t lv_img_src_get_type(const void * src);
51 
52 /**
53  * Get the color of an image's pixel
54  * @param dsc an image descriptor
55  * @param x x coordinate of the point to get
56  * @param y x coordinate of the point to get
57  * @param style style of the image. In case of `LV_IMG_CF_ALPHA_1/2/4/8` `style->image.color` shows
58  * the color. Can be `NULL` but for `ALPHA` images black will be returned. In other cases it is not
59  * used.
60  * @return color of the point
61  */
62 lv_color_t lv_img_buf_get_px_color(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y, const lv_style_t * style);
63 /**
64  * Get the alpha value of an image's pixel
65  * @param dsc pointer to an image descriptor
66  * @param x x coordinate of the point to set
67  * @param y x coordinate of the point to set
68  * @return alpha value of the point
69  */
70 lv_opa_t lv_img_buf_get_px_alpha(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y);
71 
72 /**
73  * Set the color of a pixel of an image. The alpha channel won't be affected.
74  * @param dsc pointer to an image descriptor
75  * @param x x coordinate of the point to set
76  * @param y x coordinate of the point to set
77  * @param c color of the point
78  */
79 void lv_img_buf_set_px_color(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y, lv_color_t c);
80 
81 /**
82  * Set the alpha value of a pixel of an image. The color won't be affected
83  * @param dsc pointer to an image descriptor
84  * @param x x coordinate of the point to set
85  * @param y x coordinate of the point to set
86  * @param opa the desired opacity
87  */
88 void lv_img_buf_set_px_alpha(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y, lv_opa_t opa);
89 
90 /**
91  * Set the palette color of an indexed image. Valid only for `LV_IMG_CF_INDEXED1/2/4/8`
92  * @param dsc pointer to an image descriptor
93  * @param id the palette color to set:
94  *   - for `LV_IMG_CF_INDEXED1`: 0..1
95  *   - for `LV_IMG_CF_INDEXED2`: 0..3
96  *   - for `LV_IMG_CF_INDEXED4`: 0..15
97  *   - for `LV_IMG_CF_INDEXED8`: 0..255
98  * @param c the color to set
99  */
100 void lv_img_buf_set_palette(lv_img_dsc_t * dsc, uint8_t id, lv_color_t c);
101 
102 /**
103  * Get the pixel size of a color format in bits
104  * @param cf a color format (`LV_IMG_CF_...`)
105  * @return the pixel size in bits
106  */
107 uint8_t lv_img_color_format_get_px_size(lv_img_cf_t cf);
108 
109 /**
110  * Check if a color format is chroma keyed or not
111  * @param cf a color format (`LV_IMG_CF_...`)
112  * @return true: chroma keyed; false: not chroma keyed
113  */
114 bool lv_img_color_format_is_chroma_keyed(lv_img_cf_t cf);
115 
116 /**
117  * Check if a color format has alpha channel or not
118  * @param cf a color format (`LV_IMG_CF_...`)
119  * @return true: has alpha channel; false: doesn't have alpha channel
120  */
121 bool lv_img_color_format_has_alpha(lv_img_cf_t cf);
122 
123 /**********************
124  *      MACROS
125  **********************/
126 
127 #ifdef __cplusplus
128 } /* extern "C" */
129 #endif
130 
131 #endif /*LV_TEMPL_H*/
132