mikroSDK Reference Manual
lv_img_buf.h
Go to the documentation of this file.
1
6#ifndef LV_IMG_BUF_H
7#define LV_IMG_BUF_H
8
9#ifdef __cplusplus
10extern "C" {
11#endif
12
13/*********************
14 * INCLUDES
15 *********************/
16#include <stdbool.h>
17#include "../misc/lv_color.h"
18#include "../misc/lv_area.h"
19
20/*********************
21 * DEFINES
22 *********************/
23/*If image pixels contains alpha we need to know how much byte is a pixel*/
24#if LV_COLOR_DEPTH == 1 || LV_COLOR_DEPTH == 8
25#define LV_IMG_PX_SIZE_ALPHA_BYTE 2
26#elif LV_COLOR_DEPTH == 16
27#define LV_IMG_PX_SIZE_ALPHA_BYTE 3
28#elif LV_COLOR_DEPTH == 32
29#define LV_IMG_PX_SIZE_ALPHA_BYTE 4
30#endif
31
32#define LV_IMG_BUF_SIZE_TRUE_COLOR(w, h) ((LV_COLOR_SIZE / 8) * w * h)
33#define LV_IMG_BUF_SIZE_TRUE_COLOR_CHROMA_KEYED(w, h) ((LV_COLOR_SIZE / 8) * w * h)
34#define LV_IMG_BUF_SIZE_TRUE_COLOR_ALPHA(w, h) (LV_IMG_PX_SIZE_ALPHA_BYTE * w * h)
35
36/*+ 1: to be sure no fractional row*/
37#define LV_IMG_BUF_SIZE_ALPHA_1BIT(w, h) ((((w / 8) + 1) * h))
38#define LV_IMG_BUF_SIZE_ALPHA_2BIT(w, h) ((((w / 4) + 1) * h))
39#define LV_IMG_BUF_SIZE_ALPHA_4BIT(w, h) ((((w / 2) + 1) * h))
40#define LV_IMG_BUF_SIZE_ALPHA_8BIT(w, h) ((w * h))
41
42/*4 * X: for palette*/
43#define LV_IMG_BUF_SIZE_INDEXED_1BIT(w, h) (LV_IMG_BUF_SIZE_ALPHA_1BIT(w, h) + 4 * 2)
44#define LV_IMG_BUF_SIZE_INDEXED_2BIT(w, h) (LV_IMG_BUF_SIZE_ALPHA_2BIT(w, h) + 4 * 4)
45#define LV_IMG_BUF_SIZE_INDEXED_4BIT(w, h) (LV_IMG_BUF_SIZE_ALPHA_4BIT(w, h) + 4 * 16)
46#define LV_IMG_BUF_SIZE_INDEXED_8BIT(w, h) (LV_IMG_BUF_SIZE_ALPHA_8BIT(w, h) + 4 * 256)
47
48#define _LV_ZOOM_INV_UPSCALE 5
49
50/**********************
51 * TYPEDEFS
52 **********************/
53
54/*Image color format*/
55enum {
56 LV_IMG_CF_UNKNOWN = 0,
57
79 LV_IMG_CF_RGB888,
80 LV_IMG_CF_RGBA8888,
81 LV_IMG_CF_RGBX8888,
82 LV_IMG_CF_RGB565,
83 LV_IMG_CF_RGBA5658,
84 LV_IMG_CF_RGB565A8,
85
104};
105typedef uint8_t lv_img_cf_t;
106
107
114#if LV_BIG_ENDIAN_SYSTEM
115typedef struct {
116
117 uint32_t h : 11; /*Height of the image map*/
118 uint32_t w : 11; /*Width of the image map*/
119 uint32_t reserved : 2; /*Reserved to be used later*/
120 uint32_t always_zero : 3; /*It the upper bits of the first byte. Always zero to look like a
121 non-printable character*/
122 uint32_t cf : 5; /*Color format: See `lv_img_color_format_t`*/
123
125#else
126typedef struct {
127
128 uint32_t cf : 5; /*Color format: See `lv_img_color_format_t`*/
129 uint32_t always_zero : 3; /*It the upper bits of the first byte. Always zero to look like a
130 non-printable character*/
131
132 uint32_t reserved : 2; /*Reserved to be used later*/
133
134 uint32_t w : 11; /*Width of the image map*/
135 uint32_t h : 11; /*Height of the image map*/
137#endif
138
141typedef struct {
143 uint32_t data_size;
144 const uint8_t * data;
146
147/**********************
148 * GLOBAL PROTOTYPES
149 **********************/
150
158lv_img_dsc_t * lv_img_buf_alloc(lv_coord_t w, lv_coord_t h, lv_img_cf_t cf);
159
170lv_color_t lv_img_buf_get_px_color(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y, lv_color_t color);
171
180lv_opa_t lv_img_buf_get_px_alpha(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y);
181
190void lv_img_buf_set_px_color(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y, lv_color_t c);
191
200void lv_img_buf_set_px_alpha(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y, lv_opa_t opa);
201
212void lv_img_buf_set_palette(lv_img_dsc_t * dsc, uint8_t id, lv_color_t c);
213
219
227uint32_t lv_img_buf_get_img_size(lv_coord_t w, lv_coord_t h, lv_img_cf_t cf);
228
238void _lv_img_buf_get_transformed_area(lv_area_t * res, lv_coord_t w, lv_coord_t h, int16_t angle, uint16_t zoom,
239 const lv_point_t * pivot);
240
241/**********************
242 * MACROS
243 **********************/
244
245#ifdef __cplusplus
246} /*extern "C"*/
247#endif
248
249#endif /*LV_IMG_BUF_H*/
void lv_img_buf_set_px_alpha(lv_img_dsc_t *dsc, lv_coord_t x, lv_coord_t y, lv_opa_t opa)
@ LV_IMG_CF_INDEXED_8BIT
Definition lv_img_buf.h:72
@ LV_IMG_CF_ALPHA_1BIT
Definition lv_img_buf.h:74
@ LV_IMG_CF_RAW_CHROMA_KEYED
Definition lv_img_buf.h:61
@ LV_IMG_CF_USER_ENCODED_0
Definition lv_img_buf.h:96
@ LV_IMG_CF_ALPHA_2BIT
Definition lv_img_buf.h:75
@ LV_IMG_CF_RESERVED_17
Definition lv_img_buf.h:88
@ LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED
Definition lv_img_buf.h:66
@ LV_IMG_CF_USER_ENCODED_3
Definition lv_img_buf.h:99
@ LV_IMG_CF_RESERVED_20
Definition lv_img_buf.h:91
@ LV_IMG_CF_TRUE_COLOR_ALPHA
Definition lv_img_buf.h:65
@ LV_IMG_CF_USER_ENCODED_1
Definition lv_img_buf.h:97
@ LV_IMG_CF_RESERVED_18
Definition lv_img_buf.h:89
@ LV_IMG_CF_USER_ENCODED_5
Definition lv_img_buf.h:101
@ LV_IMG_CF_RESERVED_19
Definition lv_img_buf.h:90
@ LV_IMG_CF_ALPHA_4BIT
Definition lv_img_buf.h:76
@ LV_IMG_CF_USER_ENCODED_7
Definition lv_img_buf.h:103
@ LV_IMG_CF_RESERVED_21
Definition lv_img_buf.h:92
@ LV_IMG_CF_INDEXED_2BIT
Definition lv_img_buf.h:70
@ LV_IMG_CF_ALPHA_8BIT
Definition lv_img_buf.h:77
@ LV_IMG_CF_USER_ENCODED_6
Definition lv_img_buf.h:102
@ LV_IMG_CF_RESERVED_23
Definition lv_img_buf.h:94
@ LV_IMG_CF_USER_ENCODED_2
Definition lv_img_buf.h:98
@ LV_IMG_CF_RAW_ALPHA
Definition lv_img_buf.h:59
@ LV_IMG_CF_RESERVED_16
Definition lv_img_buf.h:87
@ LV_IMG_CF_INDEXED_4BIT
Definition lv_img_buf.h:71
@ LV_IMG_CF_RESERVED_15
Definition lv_img_buf.h:86
@ LV_IMG_CF_TRUE_COLOR
Definition lv_img_buf.h:64
@ LV_IMG_CF_INDEXED_1BIT
Definition lv_img_buf.h:69
@ LV_IMG_CF_RAW
Definition lv_img_buf.h:58
@ LV_IMG_CF_USER_ENCODED_4
Definition lv_img_buf.h:100
@ LV_IMG_CF_RESERVED_22
Definition lv_img_buf.h:93
void _lv_img_buf_get_transformed_area(lv_area_t *res, lv_coord_t w, lv_coord_t h, int16_t angle, uint16_t zoom, const lv_point_t *pivot)
uint32_t lv_img_buf_get_img_size(lv_coord_t w, lv_coord_t h, lv_img_cf_t cf)
void lv_img_buf_set_px_color(lv_img_dsc_t *dsc, lv_coord_t x, lv_coord_t y, lv_color_t c)
lv_img_dsc_t * lv_img_buf_alloc(lv_coord_t w, lv_coord_t h, lv_img_cf_t cf)
lv_color_t lv_img_buf_get_px_color(lv_img_dsc_t *dsc, lv_coord_t x, lv_coord_t y, lv_color_t color)
lv_opa_t lv_img_buf_get_px_alpha(lv_img_dsc_t *dsc, lv_coord_t x, lv_coord_t y)
void lv_img_buf_set_palette(lv_img_dsc_t *dsc, uint8_t id, lv_color_t c)
void lv_img_buf_free(lv_img_dsc_t *dsc)
Definition lv_area.h:43
Definition lv_img_buf.h:141
const uint8_t * data
Definition lv_img_buf.h:144
lv_img_header_t header
Definition lv_img_buf.h:142
uint32_t data_size
Definition lv_img_buf.h:143
Definition lv_img_buf.h:126
Definition lv_area.h:37