# lv_snapshot.h (/api/draw/snapshot/lv_snapshot_h)



<ApiSummary functions="6" />

Functions [#functions]

<ApiMember kind="function" name="lv_snapshot_take" file="draw/snapshot/lv_snapshot.h" line="41" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/draw/snapshot/lv_snapshot.h#L41">
  lv_snapshot_take [#lv_snapshot_take]

  Take snapshot for object with its children, create the draw buffer as needed.

  ```c title=" " lineNumbers=1
  lv_draw_buf_t * lv_snapshot_take(lv_obj_t *obj, lv_color_format_t cf)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name  | Type                                             | Description                       |
  | ----- | ------------------------------------------------ | --------------------------------- |
  | `obj` | <ApiLink name="lv_obj_t" display="lv_obj_t *" /> | the object to generate snapshot.  |
  | `cf`  | <ApiLink name="lv_color_format_t" />             | color format for generated image. |

  **Returns:** <ApiLink name="lv_draw_buf_t" display="lv_draw_buf_t *" /> — a pointer to an draw buffer containing snapshot image, or NULL if failed.
</ApiMember>

<ApiMember kind="function" name="lv_snapshot_create_draw_buf" file="draw/snapshot/lv_snapshot.h" line="49" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/draw/snapshot/lv_snapshot.h#L49">
  lv_snapshot_create_draw_buf [#lv_snapshot_create_draw_buf]

  Create a draw buffer to store the snapshot image for object.

  ```c title=" " lineNumbers=1
  lv_draw_buf_t * lv_snapshot_create_draw_buf(lv_obj_t *obj, lv_color_format_t cf)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name  | Type                                             | Description                       |
  | ----- | ------------------------------------------------ | --------------------------------- |
  | `obj` | <ApiLink name="lv_obj_t" display="lv_obj_t *" /> | the object to generate snapshot.  |
  | `cf`  | <ApiLink name="lv_color_format_t" />             | color format for generated image. |

  **Returns:** <ApiLink name="lv_draw_buf_t" display="lv_draw_buf_t *" /> — a pointer to an draw buffer ready for taking snapshot, or NULL if failed.
</ApiMember>

<ApiMember kind="function" name="lv_snapshot_reshape_draw_buf" file="draw/snapshot/lv_snapshot.h" line="58" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/draw/snapshot/lv_snapshot.h#L58">
  lv_snapshot_reshape_draw_buf [#lv_snapshot_reshape_draw_buf]

  Reshape the draw buffer to prepare for taking snapshot for obj. This is usually used to check if the existing draw buffer is enough for obj snapshot. If return LV\_RESULT\_INVALID, you should create a new one.

  ```c title=" " lineNumbers=1
  lv_result_t lv_snapshot_reshape_draw_buf(lv_obj_t *obj, lv_draw_buf_t *draw_buf)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name       | Type                                                       | Description                      |
  | ---------- | ---------------------------------------------------------- | -------------------------------- |
  | `obj`      | <ApiLink name="lv_obj_t" display="lv_obj_t *" />           | the object to generate snapshot. |
  | `draw_buf` | <ApiLink name="lv_draw_buf_t" display="lv_draw_buf_t *" /> | the draw buffer to reshape.      |
</ApiMember>

<ApiMember kind="function" name="lv_snapshot_take_to_draw_buf" file="draw/snapshot/lv_snapshot.h" line="68" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/draw/snapshot/lv_snapshot.h#L68">
  lv_snapshot_take_to_draw_buf [#lv_snapshot_take_to_draw_buf]

  Take snapshot for object with its children, save image info to provided buffer.

  ```c title=" " lineNumbers=1
  lv_result_t lv_snapshot_take_to_draw_buf(lv_obj_t *obj, lv_color_format_t cf, lv_draw_buf_t *draw_buf)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name       | Type                                                       | Description                                                                                                   |
  | ---------- | ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
  | `obj`      | <ApiLink name="lv_obj_t" display="lv_obj_t *" />           | the object to generate snapshot.                                                                              |
  | `cf`       | <ApiLink name="lv_color_format_t" />                       | color format for new snapshot image. It could differ with cf of `draw_buf` as long as the new cf will fit in. |
  | `draw_buf` | <ApiLink name="lv_draw_buf_t" display="lv_draw_buf_t *" /> | the draw buffer to store the image result. It's reshaped automatically.                                       |

  **Returns:** <ApiLink name="lv_result_t" /> — LV\_RESULT\_OK on success, LV\_RESULT\_INVALID on error.
</ApiMember>

<ApiMember kind="function" name="lv_snapshot_free" file="draw/snapshot/lv_snapshot.h" line="76" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/draw/snapshot/lv_snapshot.h#L76">
  lv_snapshot_free [#lv_snapshot_free]

  \> &#x2A;*Deprecated:** Use `lv_draw_buf_destroy` instead.

  Free the snapshot image returned by <ApiLink name="lv_snapshot_take" />

  ```c title=" " lineNumbers=1
  void lv_snapshot_free(lv_image_dsc_t *dsc)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name  | Type                                                         | Description                                           |
  | ----- | ------------------------------------------------------------ | ----------------------------------------------------- |
  | `dsc` | <ApiLink name="lv_image_dsc_t" display="lv_image_dsc_t *" /> | the image descriptor generated by lv\_snapshot\_take. |
</ApiMember>

<ApiMember kind="function" name="lv_snapshot_take_to_buf" file="draw/snapshot/lv_snapshot.h" line="88" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/draw/snapshot/lv_snapshot.h#L88">
  lv_snapshot_take_to_buf [#lv_snapshot_take_to_buf]

  Take snapshot for object with its children, save image info to provided buffer.

  \> &#x2A;*Deprecated:** Use lv\_snapshot\_take\_to\_draw\_buf instead.

  ```c title=" " lineNumbers=1
  lv_result_t lv_snapshot_take_to_buf(lv_obj_t *obj, lv_color_format_t cf, lv_image_dsc_t *dsc, void *buf, uint32_t buf_size)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name       | Type                                                         | Description                                                     |
  | ---------- | ------------------------------------------------------------ | --------------------------------------------------------------- |
  | `obj`      | <ApiLink name="lv_obj_t" display="lv_obj_t *" />             | the object to generate snapshot.                                |
  | `cf`       | <ApiLink name="lv_color_format_t" />                         | color format for generated image.                               |
  | `dsc`      | <ApiLink name="lv_image_dsc_t" display="lv_image_dsc_t *" /> | image descriptor to store the image result.                     |
  | `buf`      | `void *`                                                     | the buffer to store image data. It must meet align requirement. |
  | `buf_size` | <ApiLink name="uint32_t" />                                  | provided buffer size in bytes.                                  |

  **Returns:** <ApiLink name="lv_result_t" /> — LV\_RESULT\_OK on success, LV\_RESULT\_INVALID on error.
</ApiMember>

Dependencies [#dependencies]

<FileIncludes includes="[&#x22;lv_obj.h&#x22;, &#x22;stdint.h&#x22;, &#x22;stddef.h&#x22;]" transitiveIncludes="[&#x22;lv_anim.h&#x22;, &#x22;lv_area.h&#x22;, &#x22;lv_array.h&#x22;, &#x22;lv_assert.h&#x22;, &#x22;lv_bidi.h&#x22;, &#x22;lv_color.h&#x22;, &#x22;lv_color_op.h&#x22;, &#x22;lv_conf_internal.h&#x22;, &#x22;lv_conf_kconfig.h&#x22;, &#x22;lv_display.h&#x22;, &#x22;lv_draw.h&#x22;, &#x22;lv_draw_arc.h&#x22;, &#x22;lv_draw_blur.h&#x22;, &#x22;lv_draw_buf.h&#x22;, &#x22;lv_draw_image.h&#x22;, &#x22;lv_draw_label.h&#x22;, &#x22;lv_draw_line.h&#x22;, &#x22;lv_draw_rect.h&#x22;, &#x22;lv_draw_triangle.h&#x22;, &#x22;lv_event.h&#x22;, &#x22;lv_ext_data.h&#x22;, &#x22;lv_flex.h&#x22;, &#x22;lv_font.h&#x22;, &#x22;lv_fs.h&#x22;, &#x22;lv_grad.h&#x22;, &#x22;lv_grid.h&#x22;, &#x22;lv_group.h&#x22;, &#x22;lv_image_decoder.h&#x22;, &#x22;lv_image_dsc.h&#x22;, &#x22;lv_indev.h&#x22;, &#x22;lv_layout.h&#x22;, &#x22;lv_ll.h&#x22;, &#x22;lv_log.h&#x22;, &#x22;lv_math.h&#x22;, &#x22;lv_matrix.h&#x22;, &#x22;lv_mem.h&#x22;, &#x22;lv_obj_class.h&#x22;, &#x22;lv_obj_draw.h&#x22;, &#x22;lv_obj_event.h&#x22;, &#x22;lv_obj_pos.h&#x22;, &#x22;lv_obj_property.h&#x22;, &#x22;lv_obj_property_names.h&#x22;, &#x22;lv_obj_scroll.h&#x22;, &#x22;lv_obj_style.h&#x22;, &#x22;lv_obj_style_gen.h&#x22;, &#x22;lv_obj_tree.h&#x22;, &#x22;lv_palette.h&#x22;, &#x22;lv_profiler.h&#x22;, &#x22;lv_profiler_builtin.h&#x22;, &#x22;lv_sprintf.h&#x22;, &#x22;lv_string.h&#x22;, &#x22;lv_style.h&#x22;, &#x22;lv_style_gen.h&#x22;, &#x22;lv_style_properties.h&#x22;, &#x22;lv_symbol_def.h&#x22;, &#x22;lv_text.h&#x22;, &#x22;lv_tick.h&#x22;, &#x22;lv_timer.h&#x22;, &#x22;lv_types.h&#x22;]" />
