Moved header structs and some methods to cpp files, reading pnm images upside-down
This commit is contained in:
@@ -24,7 +24,7 @@ TEST_CASE("ImageLoaderPnm - Load P1 (ASCII Black & White)")
|
||||
REQUIRE(image->resolution.x == 4);
|
||||
REQUIRE(image->resolution.y == 2);
|
||||
REQUIRE(image->dataFormat == DataFormat::Format::R8_UINT);
|
||||
REQUIRE(image->data == Array<uint8_t> { 255, 0, 255, 0, 0, 255, 0, 255 });
|
||||
REQUIRE(image->data == Array<uint8_t> { 0, 255, 0, 255, 255, 0, 255, 0 });
|
||||
}
|
||||
|
||||
TEST_CASE("ImageLoaderPnm - Load P2 (ASCII Grayscale)")
|
||||
@@ -38,21 +38,21 @@ TEST_CASE("ImageLoaderPnm - Load P2 (ASCII Grayscale)")
|
||||
REQUIRE(image->resolution.x == 4);
|
||||
REQUIRE(image->resolution.y == 2);
|
||||
REQUIRE(image->dataFormat == DataFormat::Format::R8_UINT);
|
||||
REQUIRE(image->data == Array<uint8_t> { 0, 64, 128, 255, 255, 128, 64, 0 });
|
||||
REQUIRE(image->data == Array<uint8_t> { 255, 128, 64, 0, 0, 64, 128, 255 });
|
||||
}
|
||||
|
||||
TEST_CASE("ImageLoaderPnm - Load P3 (ASCII RGB)")
|
||||
{
|
||||
std::vector<uint8_t> p3Buffer = { 'P', '3', '\n', '2', ' ', '2', '\n', '2', '5', '5', '\n', '2', '5', '5', ' ', '0',
|
||||
' ', '0', ' ', '0', ' ', '2', '5', '5', ' ', '0', '\n', '0', ' ', '0', ' ', '2',
|
||||
'5', '5', ' ', '2', '5', '5', ' ', '2', '5', '5', ' ', '2', '5', '5', '\n' };
|
||||
std::vector<uint8_t> p3Buffer = { 'P', '3', '\n', '2', ' ', '2', '\n', '2', '5', '5', '\n',
|
||||
'2', '5', '5', ' ', '0', ' ', '0', ' ', '0', ' ', '2', '5', '5', ' ', '0', '\n',
|
||||
'0', ' ', '0', ' ', '2', '5', '5', ' ', '2', '5', '5', ' ', '2', '5', '5', ' ', '2', '5', '5', '\n' };
|
||||
ImageLoaderPnm loader;
|
||||
auto image = loader.loadFromMemory(p3Buffer);
|
||||
|
||||
REQUIRE(image->resolution.x == 2);
|
||||
REQUIRE(image->resolution.y == 2);
|
||||
REQUIRE(image->dataFormat == DataFormat::Format::R8G8B8_UINT);
|
||||
REQUIRE(image->data == Array<uint8_t> { 255, 0, 0, 0, 255, 0, 0, 0, 255, 255, 255, 255 });
|
||||
REQUIRE(image->data == Array<uint8_t> { 0, 0, 255, 255, 255, 255, 255, 0, 0, 0, 255, 0 });
|
||||
}
|
||||
|
||||
TEST_CASE("ImageLoaderPnm - Load P4 (Binary Black & White)")
|
||||
@@ -66,8 +66,8 @@ TEST_CASE("ImageLoaderPnm - Load P4 (Binary Black & White)")
|
||||
REQUIRE(image->dataFormat == DataFormat::Format::R8_UINT);
|
||||
REQUIRE(image->data
|
||||
== Array<uint8_t> {
|
||||
255, 0, 255, 0, 255, 0, 255, 0, // Row 1
|
||||
0, 255, 0, 255, 0, 255, 0, 255 // Row 2
|
||||
0, 255, 0, 255, 0, 255, 0, 255, // Row 1
|
||||
255, 0, 255, 0, 255, 0, 255, 0 // Row 2
|
||||
});
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ TEST_CASE("ImageLoaderPnm - Load P5 (Binary Grayscale)")
|
||||
REQUIRE(image->resolution.x == 4);
|
||||
REQUIRE(image->resolution.y == 2);
|
||||
REQUIRE(image->dataFormat == DataFormat::Format::R8_UINT);
|
||||
REQUIRE(image->data == Array<uint8_t> { 0, 64, 128, 255, 255, 128, 64, 0 });
|
||||
REQUIRE(image->data == Array<uint8_t> { 255, 128, 64, 0, 0, 64, 128, 255 });
|
||||
}
|
||||
|
||||
TEST_CASE("ImageLoaderPnm - Load P6 (Binary RGB)")
|
||||
@@ -94,7 +94,7 @@ TEST_CASE("ImageLoaderPnm - Load P6 (Binary RGB)")
|
||||
REQUIRE(image->resolution.x == 2);
|
||||
REQUIRE(image->resolution.y == 2);
|
||||
REQUIRE(image->dataFormat == DataFormat::Format::R8G8B8_UINT);
|
||||
REQUIRE(image->data == Array<uint8_t> { 255, 0, 0, 0, 255, 0, 0, 0, 255, 255, 255, 255 });
|
||||
REQUIRE(image->data == Array<uint8_t> { 0, 0, 255, 255, 255, 255, 255, 0, 0, 0, 255, 0 });
|
||||
}
|
||||
|
||||
TEST_CASE("ImageLoaderPnm - Get Dimensions")
|
||||
|
||||
Reference in New Issue
Block a user