1 /** 2 * @file lv_draw_image.h 3 * 4 */ 5 6 #ifndef LV_DRAW_IMAGE_H 7 #define LV_DRAW_IMAGE_H 8 9 #ifdef __cplusplus 10 extern "C" { 11 #endif 12 13 /********************* 14 * INCLUDES 15 *********************/ 16 #include "lv_draw.h" 17 #include "lv_image_decoder.h" 18 #include "lv_draw_buf.h" 19 #include "../misc/lv_style.h" 20 21 /********************* 22 * DEFINES 23 *********************/ 24 25 /********************** 26 * MACROS 27 **********************/ 28 29 typedef struct _lv_draw_image_dsc_t { 30 lv_draw_dsc_base_t base; 31 32 const void * src; 33 lv_image_header_t header; 34 35 int32_t rotation; 36 int32_t scale_x; 37 int32_t scale_y; 38 int32_t skew_x; 39 int32_t skew_y; 40 lv_point_t pivot; 41 42 lv_color_t recolor; 43 lv_opa_t recolor_opa; 44 45 lv_opa_t opa; 46 lv_blend_mode_t blend_mode : 3; 47 48 uint16_t antialias : 1; 49 uint16_t tile : 1; 50 lv_draw_image_sup_t * sup; 51 52 /** Used to indicate the entire original, non-clipped area where the image is to be drawn. 53 * This is important for: 54 * 1. Layer rendering, where it might happen that only a smaller area of the layer is rendered. 55 * 2. Tiled images, where the target draw area is larger than the image to be tiled. 56 */ 57 lv_area_t image_area; 58 59 int32_t clip_radius; 60 61 const lv_image_dsc_t * bitmap_mask_src; 62 } lv_draw_image_dsc_t; 63 64 /** 65 * PErform the actual rendering of a decoded image 66 * @param draw_unit pointer to a draw unit 67 * @param draw_dsc the draw descriptor of the image 68 * @param decoder_dsc pointer to the decoded image's descriptor 69 * @param sup supplementary data 70 * @param img_coords the absolute coordinates of the image 71 * @param clipped_img_area the absolute clip coordinates 72 */ 73 typedef void (*lv_draw_image_core_cb)(lv_draw_unit_t * draw_unit, const lv_draw_image_dsc_t * draw_dsc, 74 const lv_image_decoder_dsc_t * decoder_dsc, lv_draw_image_sup_t * sup, 75 const lv_area_t * img_coords, const lv_area_t * clipped_img_area); 76 77 /********************** 78 * GLOBAL PROTOTYPES 79 **********************/ 80 81 /** 82 * Initialize an image draw descriptor. 83 * @param dsc pointer to a draw descriptor 84 */ 85 void lv_draw_image_dsc_init(lv_draw_image_dsc_t * dsc); 86 87 /** 88 * Try to get an image draw descriptor from a draw task. 89 * @param task draw task 90 * @return the task's draw descriptor or NULL if the task is not of type LV_DRAW_TASK_TYPE_IMAGE 91 */ 92 lv_draw_image_dsc_t * lv_draw_task_get_image_dsc(lv_draw_task_t * task); 93 94 /** 95 * Create an image draw task 96 * @param layer pointer to a layer 97 * @param dsc pointer to an initialized draw descriptor 98 * @param coords the coordinates of the image 99 * @note `coords` can be small than the real image area 100 * (if only a part of the image is rendered) 101 * or can be larger (in case of tiled images). . 102 */ 103 void lv_draw_image(lv_layer_t * layer, const lv_draw_image_dsc_t * dsc, const lv_area_t * coords); 104 105 /** 106 * Create a draw task to blend a layer to another layer 107 * @param layer pointer to a layer 108 * @param dsc pointer to an initialized draw descriptor 109 * @param coords the coordinates of the layer. 110 * @note `coords` can be small than the total widget area from which the layer is created 111 * (if only a part of the widget was rendered to a layer) 112 */ 113 void lv_draw_layer(lv_layer_t * layer, const lv_draw_image_dsc_t * dsc, const lv_area_t * coords); 114 115 /** 116 * Get the type of an image source 117 * @param src pointer to an image source: 118 * - pointer to an 'lv_image_t' variable (image stored internally and compiled into the code) 119 * - a path to a file (e.g. "S:/folder/image.bin") 120 * - or a symbol (e.g. LV_SYMBOL_CLOSE) 121 * @return type of the image source LV_IMAGE_SRC_VARIABLE/FILE/SYMBOL/UNKNOWN 122 */ 123 lv_image_src_t lv_image_src_get_type(const void * src); 124 125 #ifdef __cplusplus 126 } /*extern "C"*/ 127 #endif 128 129 #endif /*LV_DRAW_IMAGE_H*/ 130