Added implementatino of color conversion method, and added tests
This commit is contained in:
@@ -29,6 +29,7 @@ add_executable(Test
|
||||
MirrorVertically.cpp
|
||||
SwapChannels.cpp
|
||||
Rotate.cpp
|
||||
ConvertColormode.cpp
|
||||
)
|
||||
|
||||
# Move test images to build dir
|
||||
|
68
Test/ConvertColormode.cpp
Normal file
68
Test/ConvertColormode.cpp
Normal file
@@ -0,0 +1,68 @@
|
||||
#include <Bmp.h>
|
||||
#include <stdexcept>
|
||||
#include "Catch2.h"
|
||||
|
||||
using namespace Leonetienne::BmpPP;
|
||||
using namespace Eule;
|
||||
|
||||
// Tests converting between color modes works
|
||||
TEST_CASE(__FILE__"/Converting_between_color_modes_works", "[Conversion]")
|
||||
{
|
||||
SECTION("RGB to RGB") {
|
||||
// Read an RGB image
|
||||
BMP bmp("base_kyokucho.bmp");
|
||||
|
||||
// Convert it to RGB
|
||||
bmp.ConvertColormode(Colormode::RGB);
|
||||
|
||||
// Read reference image
|
||||
const BMP reference("base_kyokucho.bmp");
|
||||
|
||||
// Assert that they are equal
|
||||
REQUIRE(bmp == reference);
|
||||
}
|
||||
|
||||
SECTION("RGB to RGBA") {
|
||||
// Read an RGB image
|
||||
BMP bmp("base_kyokucho.bmp");
|
||||
|
||||
// Convert it to RGBA
|
||||
bmp.ConvertColormode(Colormode::RGBA);
|
||||
|
||||
// Read reference image
|
||||
const BMP reference("basea_kyokucho.bmp");
|
||||
|
||||
// Assert that they are equal
|
||||
REQUIRE(bmp == reference);
|
||||
}
|
||||
|
||||
SECTION("RGBA to RGB") {
|
||||
// Read an RGBA image
|
||||
BMP bmp("basea_kyokucho.bmp");
|
||||
|
||||
// Convert it to RGB
|
||||
bmp.ConvertColormode(Colormode::RGB);
|
||||
|
||||
// Read reference image
|
||||
const BMP reference("base_kyokucho.bmp");
|
||||
|
||||
// Assert that they are equal
|
||||
REQUIRE(bmp == reference);
|
||||
}
|
||||
|
||||
SECTION("RGBA to RGBA") {
|
||||
// Read an RGBA image
|
||||
BMP bmp("basea_kyokucho.bmp");
|
||||
|
||||
// Convert it to RGBA
|
||||
bmp.ConvertColormode(Colormode::RGBA);
|
||||
|
||||
// Read reference image
|
||||
const BMP reference("basea_kyokucho.bmp");
|
||||
|
||||
// Assert that they are equal
|
||||
REQUIRE(bmp == reference);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
BIN
Test/TestAssets/base_kyokucho.bmp
Normal file
BIN
Test/TestAssets/base_kyokucho.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 80 KiB |
BIN
Test/TestAssets/basea_kyokucho.bmp
Normal file
BIN
Test/TestAssets/basea_kyokucho.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 107 KiB |
Reference in New Issue
Block a user