|
|
|
|
@ -23,6 +23,7 @@
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
#include <sstream> |
|
|
|
|
#include <Containers/Array.h> |
|
|
|
|
#include <TestSuite/Tester.h> |
|
|
|
|
#include <Utility/Directory.h> |
|
|
|
|
#include <ImageFormat.h> |
|
|
|
|
@ -80,7 +81,7 @@ void TgaImporterTest::openInexistent() {
|
|
|
|
|
|
|
|
|
|
void TgaImporterTest::openShort() { |
|
|
|
|
TgaImporter importer; |
|
|
|
|
const char data[] = { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; |
|
|
|
|
const unsigned char data[] = { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; |
|
|
|
|
CORRADE_VERIFY(importer.openData(data)); |
|
|
|
|
|
|
|
|
|
std::ostringstream debug; |
|
|
|
|
@ -91,7 +92,7 @@ void TgaImporterTest::openShort() {
|
|
|
|
|
|
|
|
|
|
void TgaImporterTest::paletted() { |
|
|
|
|
TgaImporter importer; |
|
|
|
|
const char data[] = { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; |
|
|
|
|
const unsigned char data[] = { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; |
|
|
|
|
CORRADE_VERIFY(importer.openData(data)); |
|
|
|
|
|
|
|
|
|
std::ostringstream debug; |
|
|
|
|
@ -102,7 +103,7 @@ void TgaImporterTest::paletted() {
|
|
|
|
|
|
|
|
|
|
void TgaImporterTest::compressed() { |
|
|
|
|
TgaImporter importer; |
|
|
|
|
const char data[] = { 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; |
|
|
|
|
const unsigned char data[] = { 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; |
|
|
|
|
CORRADE_VERIFY(importer.openData(data)); |
|
|
|
|
|
|
|
|
|
std::ostringstream debug; |
|
|
|
|
@ -113,7 +114,7 @@ void TgaImporterTest::compressed() {
|
|
|
|
|
|
|
|
|
|
void TgaImporterTest::colorBits16() { |
|
|
|
|
TgaImporter importer; |
|
|
|
|
const char data[] = { 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0 }; |
|
|
|
|
const unsigned char data[] = { 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0 }; |
|
|
|
|
CORRADE_VERIFY(importer.openData(data)); |
|
|
|
|
|
|
|
|
|
std::ostringstream debug; |
|
|
|
|
@ -124,14 +125,14 @@ void TgaImporterTest::colorBits16() {
|
|
|
|
|
|
|
|
|
|
void TgaImporterTest::colorBits24() { |
|
|
|
|
TgaImporter importer; |
|
|
|
|
const char data[] = { |
|
|
|
|
const unsigned char data[] = { |
|
|
|
|
0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 3, 0, 24, 0, |
|
|
|
|
1, 2, 3, 2, 3, 4, |
|
|
|
|
3, 4, 5, 4, 5, 6, |
|
|
|
|
5, 6, 7, 6, 7, 8 |
|
|
|
|
}; |
|
|
|
|
#ifndef MAGNUM_TARGET_GLES |
|
|
|
|
const char* pixels = data + 18; |
|
|
|
|
const char* pixels = reinterpret_cast<const char*>(data) + 18; |
|
|
|
|
#else |
|
|
|
|
const char pixels[] = { |
|
|
|
|
3, 2, 1, 4, 3, 2, |
|
|
|
|
@ -157,14 +158,14 @@ void TgaImporterTest::colorBits24() {
|
|
|
|
|
|
|
|
|
|
void TgaImporterTest::colorBits32() { |
|
|
|
|
TgaImporter importer; |
|
|
|
|
const char data[] = { |
|
|
|
|
const unsigned char data[] = { |
|
|
|
|
0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 3, 0, 32, 0, |
|
|
|
|
1, 2, 3, 1, 2, 3, 4, 1, |
|
|
|
|
3, 4, 5, 1, 4, 5, 6, 1, |
|
|
|
|
5, 6, 7, 1, 6, 7, 8, 1 |
|
|
|
|
}; |
|
|
|
|
#ifndef MAGNUM_TARGET_GLES |
|
|
|
|
const char* pixels = data + 18; |
|
|
|
|
const char* pixels = reinterpret_cast<const char*>(data) + 18; |
|
|
|
|
#else |
|
|
|
|
const char pixels[] = { |
|
|
|
|
3, 2, 1, 1, 4, 3, 2, 1, |
|
|
|
|
@ -190,7 +191,7 @@ void TgaImporterTest::colorBits32() {
|
|
|
|
|
|
|
|
|
|
void TgaImporterTest::grayscaleBits8() { |
|
|
|
|
TgaImporter importer; |
|
|
|
|
const char data[] = { |
|
|
|
|
const unsigned char data[] = { |
|
|
|
|
0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 3, 0, 8, 0, |
|
|
|
|
1, 2, |
|
|
|
|
3, 4, |
|
|
|
|
@ -203,12 +204,13 @@ void TgaImporterTest::grayscaleBits8() {
|
|
|
|
|
CORRADE_COMPARE(image->format(), ImageFormat::Red); |
|
|
|
|
CORRADE_COMPARE(image->size(), Vector2i(2, 3)); |
|
|
|
|
CORRADE_COMPARE(image->type(), ImageType::UnsignedByte); |
|
|
|
|
CORRADE_COMPARE(std::string(reinterpret_cast<const char*>(image->data()), 2*3), std::string(data + 18, 2*3)); |
|
|
|
|
CORRADE_COMPARE(std::string(reinterpret_cast<const char*>(image->data()), 2*3), |
|
|
|
|
std::string(reinterpret_cast<const char*>(data) + 18, 2*3)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void TgaImporterTest::grayscaleBits16() { |
|
|
|
|
TgaImporter importer; |
|
|
|
|
const char data[] = { 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0 }; |
|
|
|
|
const unsigned char data[] = { 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0 }; |
|
|
|
|
CORRADE_VERIFY(importer.openData(data)); |
|
|
|
|
|
|
|
|
|
std::ostringstream debug; |
|
|
|
|
@ -219,7 +221,7 @@ void TgaImporterTest::grayscaleBits16() {
|
|
|
|
|
|
|
|
|
|
void TgaImporterTest::file() { |
|
|
|
|
TgaImporter importer; |
|
|
|
|
const char data[] = { |
|
|
|
|
const unsigned char data[] = { |
|
|
|
|
0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 3, 0, 8, 0, |
|
|
|
|
1, 2, |
|
|
|
|
3, 4, |
|
|
|
|
@ -232,7 +234,8 @@ void TgaImporterTest::file() {
|
|
|
|
|
CORRADE_COMPARE(image->format(), ImageFormat::Red); |
|
|
|
|
CORRADE_COMPARE(image->size(), Vector2i(2, 3)); |
|
|
|
|
CORRADE_COMPARE(image->type(), ImageType::UnsignedByte); |
|
|
|
|
CORRADE_COMPARE(std::string(reinterpret_cast<const char*>(image->data()), 2*3), std::string(data + 18, 2*3)); |
|
|
|
|
CORRADE_COMPARE(std::string(reinterpret_cast<const char*>(image->data()), 2*3), |
|
|
|
|
std::string(reinterpret_cast<const char*>(data) + 18, 2*3)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}}}} |
|
|
|
|
|