2018-06-07 15:32:19 +02:00
|
|
|
/**
|
|
|
|
* @file lv_draw_img.h
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef LV_DRAW_IMG_H
|
|
|
|
#define LV_DRAW_IMG_H
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*********************
|
|
|
|
* INCLUDES
|
|
|
|
*********************/
|
|
|
|
#include "lv_draw.h"
|
2019-05-15 05:22:03 +02:00
|
|
|
#include "lv_img_decoder.h"
|
2018-06-07 15:32:19 +02:00
|
|
|
|
|
|
|
/*********************
|
|
|
|
* DEFINES
|
|
|
|
*********************/
|
|
|
|
|
|
|
|
/**********************
|
|
|
|
* TYPEDEFS
|
|
|
|
**********************/
|
2018-08-20 22:25:28 +02:00
|
|
|
|
2018-06-07 15:32:19 +02:00
|
|
|
/**********************
|
|
|
|
* GLOBAL PROTOTYPES
|
|
|
|
**********************/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Draw an image
|
|
|
|
* @param coords the coordinates of the image
|
|
|
|
* @param mask the image will be drawn only in this area
|
2018-06-14 13:08:19 +02:00
|
|
|
* @param src pointer to a lv_color_t array which contains the pixels of the image
|
|
|
|
* @param style style of the image
|
|
|
|
* @param opa_scale scale down all opacities by the factor
|
2018-06-07 15:32:19 +02:00
|
|
|
*/
|
2019-04-04 07:15:40 +02:00
|
|
|
void lv_draw_img(const lv_area_t * coords, const lv_area_t * mask, const void * src,
|
|
|
|
const lv_style_t * style, lv_opa_t opa_scale);
|
2018-08-08 09:50:01 +02:00
|
|
|
|
2018-08-16 00:15:19 +02: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 a file (e.g. "S:/folder/image.bin")
|
2019-03-07 00:05:16 +01:00
|
|
|
* - or a symbol (e.g. LV_SYMBOL_CLOSE)
|
2019-03-05 14:21:13 +01:00
|
|
|
* @return type of the image source LV_IMG_SRC_VARIABLE/FILE/SYMBOL/UNKNOWN
|
2018-08-16 00:15:19 +02:00
|
|
|
*/
|
|
|
|
lv_img_src_t lv_img_src_get_type(const void * src);
|
2018-08-08 09:50:01 +02:00
|
|
|
|
2019-03-27 00:04:57 +01:00
|
|
|
/**
|
|
|
|
* Get the color of an image's pixel
|
|
|
|
* @param dsc an image descriptor
|
|
|
|
* @param x x coordinate of the point to get
|
|
|
|
* @param y x coordinate of the point to get
|
2019-04-04 07:15:40 +02:00
|
|
|
* @param style style of the image. In case of `LV_IMG_CF_ALPHA_1/2/4/8` `style->image.color` shows
|
|
|
|
* the color. Can be `NULL` but for `ALPHA` images black will be returned. In other cases it is not
|
|
|
|
* used.
|
2019-03-27 00:04:57 +01:00
|
|
|
* @return color of the point
|
|
|
|
*/
|
2019-04-04 07:15:40 +02:00
|
|
|
lv_color_t lv_img_buf_get_px_color(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y,
|
2019-04-11 19:59:55 +08:00
|
|
|
const lv_style_t * style);
|
2019-03-27 00:04:57 +01:00
|
|
|
/**
|
|
|
|
* Get the alpha value of an image's pixel
|
|
|
|
* @param dsc pointer to an image descriptor
|
|
|
|
* @param x x coordinate of the point to set
|
|
|
|
* @param y x coordinate of the point to set
|
|
|
|
* @return alpha value of the point
|
|
|
|
*/
|
2019-04-04 07:15:40 +02:00
|
|
|
lv_opa_t lv_img_buf_get_px_alpha(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y);
|
2018-08-08 09:50:01 +02:00
|
|
|
|
2019-03-24 09:52:24 -04:00
|
|
|
/**
|
2019-03-27 00:04:57 +01:00
|
|
|
* Set the color of a pixel of an image. The alpha channel won't be affected.
|
|
|
|
* @param dsc pointer to an image descriptor
|
2019-03-24 09:52:24 -04:00
|
|
|
* @param x x coordinate of the point to set
|
|
|
|
* @param y x coordinate of the point to set
|
|
|
|
* @param c color of the point
|
|
|
|
*/
|
2019-04-04 07:15:40 +02:00
|
|
|
void lv_img_buf_set_px_color(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y, lv_color_t c);
|
2019-03-27 00:04:57 +01:00
|
|
|
|
2019-03-24 09:52:24 -04:00
|
|
|
/**
|
2019-03-27 00:04:57 +01:00
|
|
|
* Set the alpha value of a pixel of an image. The color won't be affected
|
|
|
|
* @param dsc pointer to an image descriptor
|
2019-03-24 09:52:24 -04:00
|
|
|
* @param x x coordinate of the point to set
|
|
|
|
* @param y x coordinate of the point to set
|
2019-03-27 00:04:57 +01:00
|
|
|
* @param opa the desired opacity
|
|
|
|
*/
|
2019-04-04 07:15:40 +02:00
|
|
|
void lv_img_buf_set_px_alpha(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y, lv_opa_t opa);
|
2019-03-27 00:04:57 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the palette color of an indexed image. Valid only for `LV_IMG_CF_INDEXED1/2/4/8`
|
|
|
|
* @param dsc pointer to an image descriptor
|
|
|
|
* @param color_id the palette color to set:
|
|
|
|
* - for `LV_IMG_CF_INDEXED1`: 0..1
|
|
|
|
* - for `LV_IMG_CF_INDEXED2`: 0..3
|
|
|
|
* - for `LV_IMG_CF_INDEXED4`: 0..15
|
|
|
|
* - for `LV_IMG_CF_INDEXED8`: 0..255
|
|
|
|
* @param color the color to set
|
2019-03-24 09:52:24 -04:00
|
|
|
*/
|
2019-04-04 07:15:40 +02:00
|
|
|
void lv_img_buf_set_palette(lv_img_dsc_t * dsc, int color_id, lv_color_t color);
|
2019-03-27 00:04:57 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the pixel size of a color format in bits
|
|
|
|
* @param cf a color format (`LV_IMG_CF_...`)
|
|
|
|
* @return the pixel size in bits
|
|
|
|
*/
|
|
|
|
uint8_t lv_img_color_format_get_px_size(lv_img_cf_t cf);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if a color format is chroma keyed or not
|
|
|
|
* @param cf a color format (`LV_IMG_CF_...`)
|
|
|
|
* @return true: chroma keyed; false: not chroma keyed
|
|
|
|
*/
|
|
|
|
bool lv_img_color_format_is_chroma_keyed(lv_img_cf_t cf);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if a color format has alpha channel or not
|
|
|
|
* @param cf a color format (`LV_IMG_CF_...`)
|
|
|
|
* @return true: has alpha channel; false: doesn't have alpha channel
|
|
|
|
*/
|
|
|
|
bool lv_img_color_format_has_alpha(lv_img_cf_t cf);
|
2018-08-08 09:50:01 +02:00
|
|
|
|
2018-06-07 15:32:19 +02:00
|
|
|
/**********************
|
|
|
|
* MACROS
|
|
|
|
**********************/
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
} /* extern "C" */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /*LV_TEMPL_H*/
|