1 /**
2  * @file lv_snapshot.h
3  *
4  */
5 
6 #ifndef LV_SNAPSHOT_H
7 #define LV_SNAPSHOT_H
8 
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12 
13 /*********************
14  *      INCLUDES
15  *********************/
16 #include "../../core/lv_obj.h"
17 
18 #if LV_USE_SNAPSHOT
19 
20 #include <stdint.h>
21 #include <stddef.h>
22 
23 /*********************
24  *      DEFINES
25  *********************/
26 
27 /**********************
28  *      TYPEDEFS
29  **********************/
30 
31 /**********************
32  * GLOBAL PROTOTYPES
33  **********************/
34 
35 /**
36  * Take snapshot for object with its children, create the draw buffer as needed.
37  * @param obj   the object to generate snapshot.
38  * @param cf    color format for generated image.
39  * @return      a pointer to an draw buffer containing snapshot image, or NULL if failed.
40  */
41 lv_draw_buf_t * lv_snapshot_take(lv_obj_t * obj, lv_color_format_t cf);
42 
43 /**
44  * Create a draw buffer to store the snapshot image for object.
45  * @param obj   the object to generate snapshot.
46  * @param cf    color format for generated image.
47  * @return      a pointer to an draw buffer ready for taking snapshot, or NULL if failed.
48  */
49 lv_draw_buf_t * lv_snapshot_create_draw_buf(lv_obj_t * obj, lv_color_format_t cf);
50 
51 /**
52  * Reshape the draw buffer to prepare for taking snapshot for obj.
53  * This is usually used to check if the existing draw buffer is enough for
54  * obj snapshot. If return LV_RESULT_INVALID, you should create a new one.
55  * @param draw_buf  the draw buffer to reshape.
56  * @param obj       the object to generate snapshot.
57  */
58 lv_result_t lv_snapshot_reshape_draw_buf(lv_obj_t * obj, lv_draw_buf_t * draw_buf);
59 
60 /**
61  * Take snapshot for object with its children, save image info to provided buffer.
62  * @param obj       the object to generate snapshot.
63  * @param cf        color format for new snapshot image.
64  *                  It could differ with cf of `draw_buf` as long as the new cf will fit in.
65  * @param draw_buf  the draw buffer to store the image result. It's reshaped automatically.
66  * @return          LV_RESULT_OK on success, LV_RESULT_INVALID on error.
67  */
68 lv_result_t lv_snapshot_take_to_draw_buf(lv_obj_t * obj, lv_color_format_t cf, lv_draw_buf_t * draw_buf);
69 
70 /**
71  * @deprecated Use `lv_draw_buf_destroy` instead.
72  *
73  * Free the snapshot image returned by @ref lv_snapshot_take
74  * @param dsc   the image descriptor generated by lv_snapshot_take.
75  */
76 void lv_snapshot_free(lv_image_dsc_t * dsc);
77 
78 /**
79  * Take snapshot for object with its children, save image info to provided buffer.
80  * @param obj       the object to generate snapshot.
81  * @param cf        color format for generated image.
82  * @param dsc       image descriptor to store the image result.
83  * @param buf       the buffer to store image data. It must meet align requirement.
84  * @param buf_size  provided buffer size in bytes.
85  * @return          LV_RESULT_OK on success, LV_RESULT_INVALID on error.
86  * @deprecated      Use lv_snapshot_take_to_draw_buf instead.
87  */
88 lv_result_t lv_snapshot_take_to_buf(lv_obj_t * obj, lv_color_format_t cf, lv_image_dsc_t * dsc,
89                                     void * buf,
90                                     uint32_t buf_size);
91 
92 /**********************
93  *      MACROS
94  **********************/
95 #endif /*LV_USE_SNAPSHOT*/
96 
97 #ifdef __cplusplus
98 } /*extern "C"*/
99 #endif
100 
101 #endif
102