|
|
|
|
@ -26,7 +26,7 @@
|
|
|
|
|
#include <Containers/Array.h> |
|
|
|
|
#include <TestSuite/Tester.h> |
|
|
|
|
#include <Utility/Directory.h> |
|
|
|
|
#include <ImageFormat.h> |
|
|
|
|
#include <ColorFormat.h> |
|
|
|
|
#include <Trade/ImageData.h> |
|
|
|
|
|
|
|
|
|
#include "TgaImporter/TgaImporter.h" |
|
|
|
|
@ -142,18 +142,16 @@ void TgaImporterTest::colorBits24() {
|
|
|
|
|
#endif |
|
|
|
|
CORRADE_VERIFY(importer.openData(data)); |
|
|
|
|
|
|
|
|
|
Trade::ImageData2D* image = importer.image2D(0); |
|
|
|
|
std::optional<Trade::ImageData2D> image = importer.image2D(0); |
|
|
|
|
CORRADE_VERIFY(image); |
|
|
|
|
#ifndef MAGNUM_TARGET_GLES |
|
|
|
|
CORRADE_COMPARE(image->format(), ImageFormat::BGR); |
|
|
|
|
CORRADE_COMPARE(image->format(), ColorFormat::BGR); |
|
|
|
|
#else |
|
|
|
|
CORRADE_COMPARE(image->format(), ImageFormat::RGB); |
|
|
|
|
CORRADE_COMPARE(image->format(), ColorFormat::RGB); |
|
|
|
|
#endif |
|
|
|
|
CORRADE_COMPARE(image->size(), Vector2i(2, 3)); |
|
|
|
|
CORRADE_COMPARE(image->type(), ImageType::UnsignedByte); |
|
|
|
|
CORRADE_COMPARE(image->type(), ColorType::UnsignedByte); |
|
|
|
|
CORRADE_COMPARE(std::string(reinterpret_cast<const char*>(image->data()), 2*3*3), std::string(pixels, 2*3*3)); |
|
|
|
|
|
|
|
|
|
delete image; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void TgaImporterTest::colorBits32() { |
|
|
|
|
@ -175,18 +173,16 @@ void TgaImporterTest::colorBits32() {
|
|
|
|
|
#endif |
|
|
|
|
CORRADE_VERIFY(importer.openData(data)); |
|
|
|
|
|
|
|
|
|
Trade::ImageData2D* image = importer.image2D(0); |
|
|
|
|
std::optional<Trade::ImageData2D> image = importer.image2D(0); |
|
|
|
|
CORRADE_VERIFY(image); |
|
|
|
|
#ifndef MAGNUM_TARGET_GLES |
|
|
|
|
CORRADE_COMPARE(image->format(), ImageFormat::BGRA); |
|
|
|
|
CORRADE_COMPARE(image->format(), ColorFormat::BGRA); |
|
|
|
|
#else |
|
|
|
|
CORRADE_COMPARE(image->format(), ImageFormat::RGBA); |
|
|
|
|
CORRADE_COMPARE(image->format(), ColorFormat::RGBA); |
|
|
|
|
#endif |
|
|
|
|
CORRADE_COMPARE(image->size(), Vector2i(2, 3)); |
|
|
|
|
CORRADE_COMPARE(image->type(), ImageType::UnsignedByte); |
|
|
|
|
CORRADE_COMPARE(image->type(), ColorType::UnsignedByte); |
|
|
|
|
CORRADE_COMPARE(std::string(reinterpret_cast<const char*>(image->data()), 2*3*3), std::string(pixels, 2*3*3)); |
|
|
|
|
|
|
|
|
|
delete image; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void TgaImporterTest::grayscaleBits8() { |
|
|
|
|
@ -199,11 +195,11 @@ void TgaImporterTest::grayscaleBits8() {
|
|
|
|
|
}; |
|
|
|
|
CORRADE_VERIFY(importer.openData(data)); |
|
|
|
|
|
|
|
|
|
Trade::ImageData2D* image = importer.image2D(0); |
|
|
|
|
std::optional<Trade::ImageData2D> image = importer.image2D(0); |
|
|
|
|
CORRADE_VERIFY(image); |
|
|
|
|
CORRADE_COMPARE(image->format(), ImageFormat::Red); |
|
|
|
|
CORRADE_COMPARE(image->format(), ColorFormat::Red); |
|
|
|
|
CORRADE_COMPARE(image->size(), Vector2i(2, 3)); |
|
|
|
|
CORRADE_COMPARE(image->type(), ImageType::UnsignedByte); |
|
|
|
|
CORRADE_COMPARE(image->type(), ColorType::UnsignedByte); |
|
|
|
|
CORRADE_COMPARE(std::string(reinterpret_cast<const char*>(image->data()), 2*3), |
|
|
|
|
std::string(reinterpret_cast<const char*>(data) + 18, 2*3)); |
|
|
|
|
} |
|
|
|
|
@ -229,11 +225,11 @@ void TgaImporterTest::file() {
|
|
|
|
|
}; |
|
|
|
|
CORRADE_VERIFY(importer.openFile(Utility::Directory::join(TGAIMPORTER_TEST_DIR, "file.tga"))); |
|
|
|
|
|
|
|
|
|
Trade::ImageData2D* image = importer.image2D(0); |
|
|
|
|
std::optional<Trade::ImageData2D> image = importer.image2D(0); |
|
|
|
|
CORRADE_VERIFY(image); |
|
|
|
|
CORRADE_COMPARE(image->format(), ImageFormat::Red); |
|
|
|
|
CORRADE_COMPARE(image->format(), ColorFormat::Red); |
|
|
|
|
CORRADE_COMPARE(image->size(), Vector2i(2, 3)); |
|
|
|
|
CORRADE_COMPARE(image->type(), ImageType::UnsignedByte); |
|
|
|
|
CORRADE_COMPARE(image->type(), ColorType::UnsignedByte); |
|
|
|
|
CORRADE_COMPARE(std::string(reinterpret_cast<const char*>(image->data()), 2*3), |
|
|
|
|
std::string(reinterpret_cast<const char*>(data) + 18, 2*3)); |
|
|
|
|
} |
|
|
|
|
|