C++: implement creation of image from raw data

Issue #616
This commit is contained in:
Olivier Goffart 2023-03-17 17:20:04 +01:00 committed by Olivier Goffart
parent c1dbe974ef
commit be47c8464c
3 changed files with 48 additions and 6 deletions

View file

@ -172,6 +172,23 @@ TEST_CASE("Image")
REQUIRE(actual_path.has_value());
REQUIRE(*actual_path == SOURCE_DIR "/../../../logo/slint-logo-square-light-128x128.png");
}
img = Image::from_raw_data(0, 0, SharedVector<Rgba8Pixel> {});
{
auto size = img.size();
REQUIRE(size.width == 0);
REQUIRE(size.height == 0);
REQUIRE(!img.path().has_value());
}
auto red = Rgb8Pixel { 0xff, 0, 0 };
auto blu = Rgb8Pixel { 0, 0, 0xff };
img = Image::from_raw_data(3, 2, SharedVector<Rgb8Pixel> { red, red, blu, red, blu, blu });
{
auto size = img.size();
REQUIRE(size.width == 3);
REQUIRE(size.height == 2);
REQUIRE(!img.path().has_value());
}
}
TEST_CASE("SharedVector")