Skip to content

Commit

Permalink
Core (Tests): Add test for BMP image loading.
Browse files Browse the repository at this point in the history
  • Loading branch information
kaixiong committed Jan 17, 2025
1 parent 492c956 commit d9611dd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
Binary file not shown.
Binary file added libvisual/tests/images/additive-colors-rgb24.bmp
Binary file not shown.
28 changes: 15 additions & 13 deletions libvisual/tests/video_test/video_load_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,8 @@ namespace
LV::VideoPtr load_raw_indexed_image (std::filesystem::path const& image_path,
std::filesystem::path const& palette_path,
int width,
int height,
VisVideoDepth depth)
int height)
{
if (depth != VISUAL_VIDEO_DEPTH_24BIT) {
return nullptr;
}

auto image {LV::Video::create (width, height, VISUAL_VIDEO_DEPTH_8BIT)};

std::size_t const content_bytes_per_row = image->get_width () * image->get_bpp ();
Expand All @@ -89,28 +84,34 @@ namespace
}
image->set_palette (palette.value());

auto final_image {LV::Video::create (image->get_width(), image->get_height(), VISUAL_VIDEO_DEPTH_24BIT)};
final_image->convert_depth(image);

return final_image;
return image;
}

void test_load_indexed8 ()
{
auto bmp_image {LV::Video::create_from_file ("../images/additive-colors-indexed8.bmp")};
LV_TEST_ASSERT (bmp_image);

auto png_image {LV::Video::create_from_file ("../images/additive-colors-indexed8.png")};
LV_TEST_ASSERT (png_image);

auto raw_image {load_raw_indexed_image ("../images/additive-colors-indexed8.raw",
"../images/additive-colors-indexed8.raw.pal",
png_image->get_width (),
png_image->get_height (),
VISUAL_VIDEO_DEPTH_24BIT)};
png_image->get_height ())};

LV_TEST_ASSERT (png_image->has_same_content (raw_image));
auto raw_image_rgb24 {LV::Video::create (raw_image->get_width(), raw_image->get_height(), VISUAL_VIDEO_DEPTH_24BIT)};
raw_image_rgb24->convert_depth(raw_image);

LV_TEST_ASSERT (bmp_image->has_same_content (raw_image));
LV_TEST_ASSERT (png_image->has_same_content (raw_image_rgb24));
}

void test_load_rgb24 ()
{
auto bmp_image {LV::Video::create_from_file ("../images/additive-colors-rgb24.bmp")};
LV_TEST_ASSERT (bmp_image);

auto png_image {LV::Video::create_from_file ("../images/additive-colors-rgb24.png")};
LV_TEST_ASSERT (png_image);

Expand All @@ -119,6 +120,7 @@ namespace
png_image->get_height (),
VISUAL_VIDEO_DEPTH_24BIT)};

LV_TEST_ASSERT (bmp_image->has_same_content (raw_image));
LV_TEST_ASSERT (png_image->has_same_content (raw_image));
}

Expand Down

0 comments on commit d9611dd

Please sign in to comment.