1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-21 06:53:01 +08:00
lvgl/src/lv_widgets/lv_img.h

219 lines
5.9 KiB
C
Raw Normal View History

2016-06-08 07:25:08 +02:00
/**
* @file lv_img.h
2018-06-19 09:49:58 +02:00
*
2016-06-08 07:25:08 +02:00
*/
#ifndef LV_IMG_H
#define LV_IMG_H
2017-07-09 15:32:49 +02:00
#ifdef __cplusplus
extern "C" {
#endif
2016-06-08 07:25:08 +02:00
/*********************
* INCLUDES
*********************/
#include "../lv_conf_internal.h"
#if LV_USE_IMG != 0
2017-01-15 21:52:21 +01:00
2017-11-30 11:35:33 +01:00
#include "../lv_core/lv_obj.h"
2017-11-23 20:42:14 +01:00
#include "../lv_misc/lv_fs.h"
2017-11-26 11:38:28 +01:00
#include "lv_label.h"
2018-02-09 12:40:00 +01:00
#include "../lv_draw/lv_draw.h"
2017-01-16 12:30:22 +01:00
2016-06-08 07:25:08 +02:00
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/*Data of image*/
2020-02-26 19:48:27 +01:00
typedef struct {
/*No inherited ext. because inherited from the base object*/ /*Ext. of ancestor*/
/*New data for this type */
2019-04-04 07:15:40 +02:00
const void * src; /*Image source: Pointer to an array or a file or a symbol*/
2019-03-04 12:47:03 +03:30
lv_point_t offset;
2019-04-04 07:15:40 +02:00
lv_coord_t w; /*Width of the image (Handled by the library)*/
lv_coord_t h; /*Height of the image (Handled by the library)*/
2020-02-26 19:48:27 +01:00
uint16_t angle; /*rotation angle of the image*/
lv_point_t pivot; /*rotation center of the image*/
2019-11-08 22:43:58 +01:00
uint16_t zoom; /*256 means no zoom, 512 double size, 128 hasl size*/
2019-04-04 07:15:40 +02:00
uint8_t src_type : 2; /*See: lv_img_src_t*/
uint8_t auto_size : 1; /*1: automatically set the object size to the image size*/
uint8_t cf : 5; /*Color format from `lv_img_color_format_t`*/
2020-02-26 19:48:27 +01:00
uint8_t antialias : 1; /*Apply anti-aliasing in transformations (rotate, zoom)*/
2018-06-19 09:49:58 +02:00
} lv_img_ext_t;
2016-10-07 11:15:46 +02:00
2019-12-31 23:02:25 +01:00
/*Image parts*/
enum {
2019-12-31 23:02:25 +01:00
LV_IMG_PART_MAIN,
};
2019-12-31 23:02:25 +01:00
typedef uint8_t lv_img_part_t;
2016-06-08 07:25:08 +02:00
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Create an image objects
* @param par pointer to an object, it will be the parent of the new button
2017-04-21 17:11:47 +02:00
* @param copy pointer to a image object, if not NULL then the new object will be copied from it
* @return pointer to the created image
*/
lv_obj_t * lv_img_create(lv_obj_t * par, const lv_obj_t * copy);
2016-06-08 07:25:08 +02:00
2017-11-13 16:11:05 +01:00
/*=====================
* Setter functions
*====================*/
/**
* Set the pixel map to display by the image
* @param img pointer to an image object
* @param data the image data
*/
void lv_img_set_src(lv_obj_t * img, const void * src_img);
/**
* Enable the auto size feature.
* If enabled the object size will be same as the picture size.
* @param img pointer to an image
* @param en true: auto size enable, false: auto size disable
*/
2017-11-13 16:11:05 +01:00
void lv_img_set_auto_size(lv_obj_t * img, bool autosize_en);
/**
* Set an offset for the source of an image.
* so the image will be displayed from the new origin.
* @param img pointer to an image
* @param x: the new offset along x axis.
*/
2019-04-04 07:15:40 +02:00
void lv_img_set_offset_x(lv_obj_t * img, lv_coord_t x);
/**
* Set an offset for the source of an image.
* so the image will be displayed from the new origin.
* @param img pointer to an image
* @param y: the new offset along y axis.
2019-03-04 12:47:03 +03:30
*/
2019-04-04 07:15:40 +02:00
void lv_img_set_offset_y(lv_obj_t * img, lv_coord_t y);
2019-11-29 11:32:22 +08:00
/**
* Set the rotation center of the image.
* The image will be rotated around this point
2019-11-29 11:32:22 +08:00
* @param img pointer to an image object
* @param pivot_x rotation center x of the image
* @param pivot_y rotation center y of the image
2019-11-29 11:32:22 +08:00
*/
void lv_img_set_pivot(lv_obj_t * img, lv_coord_t pivot_x, lv_coord_t pivot_y);
2019-11-29 11:32:22 +08:00
2019-11-03 16:21:58 +01:00
/**
* Set the rotation angle of the image.
* The image will be rotated around the set pivot set by `lv_img_set_pivot()`
2019-11-03 16:21:58 +01:00
* @param img pointer to an image object
* @param angle rotation angle in degree with 0.1 degree resolution (0..3600: clock wise)
2019-11-03 16:21:58 +01:00
*/
void lv_img_set_angle(lv_obj_t * img, int16_t angle);
2019-11-08 22:43:58 +01:00
/**
* Set the zoom factor of the image.
* @param img pointer to an image object
* @param zoom the zoom factor.
* - 256 or LV_ZOOM_IMG_NONE for no zoom
* - <256: scale down
* - >256 scale up
* - 128 half size
* - 512 double size
*/
void lv_img_set_zoom(lv_obj_t * img, uint16_t zoom);
/**
* Enable/disable anti-aliasing for the transformations (rotate, zoom) or not
* @param img pointer to an image object
* @param antialias true: anti-aliased; false: not anti-aliased
*/
2019-11-14 21:08:23 -05:00
void lv_img_set_antialias(lv_obj_t * img, bool antialias);
2019-11-08 22:43:58 +01:00
2017-11-13 16:11:05 +01:00
/*=====================
* Getter functions
*====================*/
/**
* Get the source of the image
* @param img pointer to an image object
* @return the image source (symbol, file name or C array)
*/
const void * lv_img_get_src(lv_obj_t * img);
2018-02-23 17:03:00 +01:00
/**
* Get the name of the file set for an image
* @param img pointer to an image
* @return file name
*/
const char * lv_img_get_file_name(const lv_obj_t * img);
/**
* Get the auto size enable attribute
* @param img pointer to an image
* @return true: auto size is enabled, false: auto size is disabled
*/
bool lv_img_get_auto_size(const lv_obj_t * img);
/**
* Get the offset.x attribute of the img object.
* @param img pointer to an image
* @return offset.x value.
*/
2019-04-04 07:15:40 +02:00
lv_coord_t lv_img_get_offset_x(lv_obj_t * img);
/**
* Get the offset.y attribute of the img object.
* @param img pointer to an image
* @return offset.y value.
*/
2019-04-04 07:15:40 +02:00
lv_coord_t lv_img_get_offset_y(lv_obj_t * img);
2019-11-03 16:21:58 +01:00
/**
* Get the rotation angle of the image.
* @param img pointer to an image object
* @return rotation angle in degree (0..359)
*/
uint16_t lv_img_get_angle(lv_obj_t * img);
2019-11-29 11:32:22 +08:00
/**
* Get the rotation center of the image.
* @param img pointer to an image object
* @param center rotation center of the image
*/
2020-02-26 19:48:27 +01:00
void lv_img_get_pivot(lv_obj_t * img, lv_point_t * center);
2019-11-29 11:32:22 +08:00
2019-11-08 22:43:58 +01:00
/**
* Get the zoom factor of the image.
* @param img pointer to an image object
* @return zoom factor (256: no zoom)
*/
uint16_t lv_img_get_zoom(lv_obj_t * img);
/**
* Get whether the transformations (rotate, zoom) are anti-aliased or not
* @param img pointer to an image object
* @return true: anti-aliased; false: not anti-aliased
*/
2019-11-14 21:08:23 -05:00
bool lv_img_get_antialias(lv_obj_t * img);
2019-11-08 22:43:58 +01:00
2016-06-08 07:25:08 +02:00
/**********************
* MACROS
**********************/
/*Use this macro to declare an image in a c file*/
#define LV_IMG_DECLARE(var_name) extern const lv_img_dsc_t var_name;
2016-06-08 07:25:08 +02:00
2019-04-04 07:15:40 +02:00
#endif /*LV_USE_IMG*/
2016-06-08 07:25:08 +02:00
2017-07-09 15:32:49 +02:00
#ifdef __cplusplus
} /* extern "C" */
2016-06-08 07:25:08 +02:00
#endif
2017-07-09 15:32:49 +02:00
2019-04-04 07:15:40 +02:00
#endif /*LV_IMG_H*/