acid-drop- Hacking the planet from a LilyGo T-Deck using custom firmware |
git clone git://git.acid.vegas/acid-drop.git |
Log | Files | Refs | Archive | README | LICENSE |
lv_img.h (6749B)
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 #include "../lv_conf_internal.h" 17 18 #if LV_USE_IMG != 0 19 20 /*Testing of dependencies*/ 21 #if LV_USE_LABEL == 0 22 #error "lv_img: lv_label is required. Enable it in lv_conf.h (LV_USE_LABEL 1)" 23 #endif 24 25 #include "../core/lv_obj.h" 26 #include "../misc/lv_fs.h" 27 #include "../draw/lv_draw.h" 28 29 /********************* 30 * DEFINES 31 *********************/ 32 33 /********************** 34 * TYPEDEFS 35 **********************/ 36 37 /** 38 * Data of image 39 */ 40 typedef struct { 41 lv_obj_t obj; 42 const void * src; /*Image source: Pointer to an array or a file or a symbol*/ 43 lv_point_t offset; 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 uint16_t angle; /*rotation angle of the image*/ 47 lv_point_t pivot; /*rotation center of the image*/ 48 uint16_t zoom; /*256 means no zoom, 512 double size, 128 half size*/ 49 uint8_t src_type : 2; /*See: lv_img_src_t*/ 50 uint8_t cf : 5; /*Color format from `lv_img_color_format_t`*/ 51 uint8_t antialias : 1; /*Apply anti-aliasing in transformations (rotate, zoom)*/ 52 uint8_t obj_size_mode: 2; /*Image size mode when image size and object size is different.*/ 53 } lv_img_t; 54 55 extern const lv_obj_class_t lv_img_class; 56 57 /** 58 * Image size mode, when image size and object size is different 59 */ 60 enum { 61 /** Zoom doesn't affect the coordinates of the object, 62 * however if zoomed in the image is drawn out of the its coordinates. 63 * The layout's won't change on zoom */ 64 LV_IMG_SIZE_MODE_VIRTUAL = 0, 65 66 /** If the object size is set to SIZE_CONTENT, then object size equals zoomed image size. 67 * It causes layout recalculation. 68 * If the object size is set explicitly, the image will be cropped when zoomed in.*/ 69 LV_IMG_SIZE_MODE_REAL, 70 }; 71 72 typedef uint8_t lv_img_size_mode_t; 73 74 /********************** 75 * GLOBAL PROTOTYPES 76 **********************/ 77 78 /** 79 * Create an image object 80 * @param parent pointer to an object, it will be the parent of the new image 81 * @return pointer to the created image 82 */ 83 lv_obj_t * lv_img_create(lv_obj_t * parent); 84 85 /*===================== 86 * Setter functions 87 *====================*/ 88 89 /** 90 * Set the image data to display on the object 91 * @param obj pointer to an image object 92 * @param src_img 1) pointer to an ::lv_img_dsc_t descriptor (converted by LVGL's image converter) (e.g. &my_img) or 93 * 2) path to an image file (e.g. "S:/dir/img.bin")or 94 * 3) a SYMBOL (e.g. LV_SYMBOL_OK) 95 */ 96 void lv_img_set_src(lv_obj_t * obj, const void * src); 97 98 /** 99 * Set an offset for the source of an image so the image will be displayed from the new origin. 100 * @param obj pointer to an image 101 * @param x the new offset along x axis. 102 */ 103 void lv_img_set_offset_x(lv_obj_t * obj, lv_coord_t x); 104 105 /** 106 * Set an offset for the source of an image. 107 * so the image will be displayed from the new origin. 108 * @param obj pointer to an image 109 * @param y the new offset along y axis. 110 */ 111 void lv_img_set_offset_y(lv_obj_t * obj, lv_coord_t y); 112 113 114 /** 115 * Set the rotation angle of the image. 116 * The image will be rotated around the set pivot set by `lv_img_set_pivot()` 117 * @param obj pointer to an image object 118 * @param angle rotation angle in degree with 0.1 degree resolution (0..3600: clock wise) 119 */ 120 void lv_img_set_angle(lv_obj_t * obj, int16_t angle); 121 122 /** 123 * Set the rotation center of the image. 124 * The image will be rotated around this point 125 * @param obj pointer to an image object 126 * @param x rotation center x of the image 127 * @param y rotation center y of the image 128 */ 129 void lv_img_set_pivot(lv_obj_t * obj, lv_coord_t x, lv_coord_t y); 130 131 132 /** 133 * Set the zoom factor of the image. 134 * @param img pointer to an image object 135 * @param zoom the zoom factor. 136 * @example 256 or LV_ZOOM_IMG_NONE for no zoom 137 * @example <256: scale down 138 * @example >256 scale up 139 * @example 128 half size 140 * @example 512 double size 141 */ 142 void lv_img_set_zoom(lv_obj_t * obj, uint16_t zoom); 143 144 /** 145 * Enable/disable anti-aliasing for the transformations (rotate, zoom) or not. 146 * The quality is better with anti-aliasing looks better but slower. 147 * @param obj pointer to an image object 148 * @param antialias true: anti-aliased; false: not anti-aliased 149 */ 150 void lv_img_set_antialias(lv_obj_t * obj, bool antialias); 151 152 /** 153 * Set the image object size mode. 154 * 155 * @param obj pointer to an image object 156 * @param mode the new size mode. 157 */ 158 void lv_img_set_size_mode(lv_obj_t * obj, lv_img_size_mode_t mode); 159 /*===================== 160 * Getter functions 161 *====================*/ 162 163 /** 164 * Get the source of the image 165 * @param obj pointer to an image object 166 * @return the image source (symbol, file name or ::lv-img_dsc_t for C arrays) 167 */ 168 const void * lv_img_get_src(lv_obj_t * obj); 169 170 /** 171 * Get the offset's x attribute of the image object. 172 * @param img pointer to an image 173 * @return offset X value. 174 */ 175 lv_coord_t lv_img_get_offset_x(lv_obj_t * obj); 176 177 /** 178 * Get the offset's y attribute of the image object. 179 * @param obj pointer to an image 180 * @return offset Y value. 181 */ 182 lv_coord_t lv_img_get_offset_y(lv_obj_t * obj); 183 184 /** 185 * Get the rotation angle of the image. 186 * @param obj pointer to an image object 187 * @return rotation angle in 0.1 degrees (0..3600) 188 */ 189 uint16_t lv_img_get_angle(lv_obj_t * obj); 190 191 /** 192 * Get the pivot (rotation center) of the image. 193 * @param img pointer to an image object 194 * @param pivot store the rotation center here 195 */ 196 void lv_img_get_pivot(lv_obj_t * obj, lv_point_t * pivot); 197 198 /** 199 * Get the zoom factor of the image. 200 * @param obj pointer to an image object 201 * @return zoom factor (256: no zoom) 202 */ 203 uint16_t lv_img_get_zoom(lv_obj_t * obj); 204 205 /** 206 * Get whether the transformations (rotate, zoom) are anti-aliased or not 207 * @param obj pointer to an image object 208 * @return true: anti-aliased; false: not anti-aliased 209 */ 210 bool lv_img_get_antialias(lv_obj_t * obj); 211 212 /** 213 * Get the size mode of the image 214 * @param obj pointer to an image object 215 * @return element of @ref lv_img_size_mode_t 216 */ 217 lv_img_size_mode_t lv_img_get_size_mode(lv_obj_t * obj); 218 219 /********************** 220 * MACROS 221 **********************/ 222 223 /** Use this macro to declare an image in a C file*/ 224 #define LV_IMG_DECLARE(var_name) extern const lv_img_dsc_t var_name; 225 226 #endif /*LV_USE_IMG*/ 227 228 #ifdef __cplusplus 229 } /*extern "C"*/ 230 #endif 231 232 #endif /*LV_IMG_H*/