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
|
@ -200,6 +200,31 @@ TEST_CASE("Image")
|
|||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Image buffer access")
|
||||
{
|
||||
using namespace slint;
|
||||
|
||||
auto img = Image::load_from_path(SOURCE_DIR "/redpixel.png");
|
||||
|
||||
REQUIRE(!img.to_rgb8().has_value());
|
||||
|
||||
{
|
||||
auto rgb = img.to_rgba8();
|
||||
REQUIRE(rgb.has_value());
|
||||
REQUIRE(rgb->width() == 1);
|
||||
REQUIRE(rgb->height() == 1);
|
||||
REQUIRE(*rgb->begin() == Rgba8Pixel { 255, 0, 0, 255 });
|
||||
}
|
||||
|
||||
{
|
||||
auto rgb = img.to_rgba8_premultiplied();
|
||||
REQUIRE(rgb.has_value());
|
||||
REQUIRE(rgb->width() == 1);
|
||||
REQUIRE(rgb->height() == 1);
|
||||
REQUIRE(*rgb->begin() == Rgba8Pixel { 255, 0, 0, 255 });
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("SharedVector")
|
||||
{
|
||||
using namespace slint;
|
||||
|
|
BIN
api/cpp/tests/redpixel.png
Normal file
BIN
api/cpp/tests/redpixel.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 163 B |
Loading…
Add table
Add a link
Reference in a new issue