From f8b8d932172a00fae0dbc07a322d66b495c33cd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 29 Mar 2013 16:01:34 +0100 Subject: [PATCH] TgaImporter: minor code cleanup, blind ES compilation fix. --- .../TgaImporter/Test/TgaImporterTest.cpp | 20 +++++++++++++------ src/Plugins/TgaImporter/TgaImporter.cpp | 14 ++++++------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/Plugins/TgaImporter/Test/TgaImporterTest.cpp b/src/Plugins/TgaImporter/Test/TgaImporterTest.cpp index ec7da8321..4a2ed2658 100644 --- a/src/Plugins/TgaImporter/Test/TgaImporterTest.cpp +++ b/src/Plugins/TgaImporter/Test/TgaImporterTest.cpp @@ -87,7 +87,7 @@ void TgaImporterTest::paletted() { void TgaImporterTest::nonRgb() { TgaImporter importer; - const char data[] = { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + const 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; @@ -111,13 +111,17 @@ void TgaImporterTest::bits24() { TgaImporter importer; const 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 + 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; #else const char pixels[] = { - 3, 2, 1, 4, 3, 2, 5, 4, 3, 6, 5, 4, 7, 6, 5, 8, 7, 6 + 3, 2, 1, 4, 3, 2, + 5, 4, 3, 6, 5, 4, + 7, 6, 5, 8, 7, 6 }; #endif CORRADE_VERIFY(importer.openData(data)); @@ -129,7 +133,7 @@ void TgaImporterTest::bits24() { #else CORRADE_COMPARE(image->format(), Trade::ImageData2D::Format::RGB); #endif - CORRADE_COMPARE(image->size(), Math::Vector2(2, 3)); + CORRADE_COMPARE(image->size(), Vector2i(2, 3)); CORRADE_COMPARE(image->type(), Trade::ImageData2D::Type::UnsignedByte); CORRADE_COMPARE(std::string(static_cast(image->data()), 2*3*3), std::string(pixels, 2*3*3)); @@ -140,13 +144,17 @@ void TgaImporterTest::bits32() { TgaImporter importer; const 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 + 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; #else const char pixels[] = { - 3, 2, 1, 1, 4, 3, 2, 1, 5, 4, 3, 1, 6, 5, 4, 1, 7, 6, 5, 1, 8, 7, 6, 1 + 3, 2, 1, 1, 4, 3, 2, 1, + 5, 4, 3, 1, 6, 5, 4, 1, + 7, 6, 5, 1, 8, 7, 6, 1 }; #endif CORRADE_VERIFY(importer.openData(data)); diff --git a/src/Plugins/TgaImporter/TgaImporter.cpp b/src/Plugins/TgaImporter/TgaImporter.cpp index bb1f97c59..42ae4f7d4 100644 --- a/src/Plugins/TgaImporter/TgaImporter.cpp +++ b/src/Plugins/TgaImporter/TgaImporter.cpp @@ -132,17 +132,17 @@ ImageData2D* TgaImporter::image2D(UnsignedInt id) { char* buffer = new char[size]; in->read(buffer, size); - Math::Vector2 dimensions(header.width, header.height); + Vector2i dimensions(header.width, header.height); #ifdef MAGNUM_TARGET_GLES - if(format == AbstractImage::Components::RGB) { - Math::Vector3* data = reinterpret_cast*>(buffer); + if(format == ImageData2D::Format::RGB) { + auto data = reinterpret_cast*>(buffer); std::transform(data, data + dimensions.product(), data, - [](Math::Vector3 pixel) { return swizzle<'b', 'g', 'r'>(pixel); }); - } else /* RGBA */ { - Math::Vector4* data = reinterpret_cast*>(buffer); + [](Math::Vector3 pixel) { return swizzle<'b', 'g', 'r'>(pixel); }); + } else if(format == ImageData2D::Format::RGBA) { + auto data = reinterpret_cast*>(buffer); std::transform(data, data + dimensions.product(), data, - [](Math::Vector4 pixel) { return swizzle<'b', 'g', 'r', 'a'>(pixel); }); + [](Math::Vector4 pixel) { return swizzle<'b', 'g', 'r', 'a'>(pixel); }); } #endif