mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-04 10:50:00 +00:00
Changelog: C++: Add slint::Window::take_snapshot()
Corresponds to the Rust API.
This commit is contained in:
parent
8fdbfc5ee5
commit
a7a3b3f9ee
5 changed files with 39 additions and 2 deletions
|
@ -573,6 +573,7 @@ fn gen_corelib(
|
|||
"slint_windowrc_is_fullscreen",
|
||||
"slint_windowrc_is_minimized",
|
||||
"slint_windowrc_is_maximized",
|
||||
"slint_windowrc_take_snapshot",
|
||||
"slint_new_path_elements",
|
||||
"slint_new_path_events",
|
||||
"slint_color_brighter",
|
||||
|
|
|
@ -64,6 +64,7 @@ struct SharedPixelBuffer
|
|||
|
||||
private:
|
||||
friend struct Image;
|
||||
friend class Window;
|
||||
uint32_t m_width;
|
||||
uint32_t m_height;
|
||||
SharedVector<Pixel> m_data;
|
||||
|
|
|
@ -602,6 +602,21 @@ public:
|
|||
return cbindgen_private::slint_windowrc_has_active_animations(&inner.handle());
|
||||
}
|
||||
|
||||
/// Takes a snapshot of the window contents and returns it as RGBA8 encoded pixel buffer.
|
||||
///
|
||||
/// Note that this function may be slow to call. Reading from the framebuffer previously
|
||||
/// rendered, too, may take a long time.
|
||||
std::optional<SharedPixelBuffer<Rgba8Pixel>> take_snapshot() const
|
||||
{
|
||||
SharedPixelBuffer<Rgba8Pixel> result;
|
||||
if (cbindgen_private::slint_windowrc_take_snapshot(&inner.handle(), &result.m_data,
|
||||
&result.m_width, &result.m_height)) {
|
||||
return result;
|
||||
} else {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
/// \private
|
||||
private_api::WindowAdapterRc &window_handle() { return inner; }
|
||||
/// \private
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue