mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-04 10:50:00 +00:00
Generate bindings of Image::to_rgb8/to_rgba8/to_rgba8_premultiplied f… (#6405)
ChangeLog: [C++] Add `Image::to_rgb8/to_rgba8/to_rgba8_premultiplied` pixel buffer accessors. Fixes #6399
This commit is contained in:
parent
4b880a7b49
commit
7db5024c52
6 changed files with 125 additions and 0 deletions
|
@ -218,6 +218,48 @@ public:
|
|||
cbindgen_private::types::slint_image_set_nine_slice_edges(&data, top, right, bottom, left);
|
||||
}
|
||||
|
||||
/// Returns the pixel buffer for the Image if available in RGB format without alpha.
|
||||
/// Returns nullopt if the pixels cannot be obtained, for example when the image was created
|
||||
/// from borrowed OpenGL textures.
|
||||
std::optional<SharedPixelBuffer<Rgb8Pixel>> to_rgb8() const
|
||||
{
|
||||
SharedPixelBuffer<Rgb8Pixel> result;
|
||||
if (cbindgen_private ::types::slint_image_to_rgb8(&data, &result.m_data, &result.m_width,
|
||||
&result.m_height)) {
|
||||
return result;
|
||||
} else {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the pixel buffer for the Image if available in RGBA format.
|
||||
/// Returns nullopt if the pixels cannot be obtained, for example when the image was created
|
||||
/// from borrowed OpenGL textures.
|
||||
std::optional<SharedPixelBuffer<Rgba8Pixel>> to_rgba8() const
|
||||
{
|
||||
SharedPixelBuffer<Rgba8Pixel> result;
|
||||
if (cbindgen_private ::types::slint_image_to_rgba8(&data, &result.m_data, &result.m_width,
|
||||
&result.m_height)) {
|
||||
return result;
|
||||
} else {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the pixel buffer for the Image if available in RGBA format, with the alpha channel
|
||||
/// pre-multiplied to the red, green, and blue channels. Returns nullopt if the pixels cannot be
|
||||
/// obtained, for example when the image was created from borrowed OpenGL textures.
|
||||
std::optional<SharedPixelBuffer<Rgba8Pixel>> to_rgba8_premultiplied() const
|
||||
{
|
||||
SharedPixelBuffer<Rgba8Pixel> result;
|
||||
if (cbindgen_private ::types::slint_image_to_rgba8_premultiplied(
|
||||
&data, &result.m_data, &result.m_width, &result.m_height)) {
|
||||
return result;
|
||||
} else {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns true if \a a refers to the same image as \a b; false otherwise.
|
||||
friend bool operator==(const Image &a, const Image &b)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue