From 40b1b1ea2b5a000903c98fb10c6b8c2d0f2d72c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 18 Jan 2013 17:28:26 +0100 Subject: [PATCH] Adapted to Magnum changes. --- .../TgaImporter/Test/TgaImporterTest.cpp | 13 ++++++------ src/Plugins/TgaImporter/TgaImporter.cpp | 20 +++++++++---------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/Plugins/TgaImporter/Test/TgaImporterTest.cpp b/src/Plugins/TgaImporter/Test/TgaImporterTest.cpp index 4f595a236..8a6527fc1 100644 --- a/src/Plugins/TgaImporter/Test/TgaImporterTest.cpp +++ b/src/Plugins/TgaImporter/Test/TgaImporterTest.cpp @@ -15,6 +15,7 @@ #include "TgaImporterTest.h" +#include #include #include #include @@ -112,12 +113,12 @@ void TgaImporterTest::bits24() { CORRADE_VERIFY(importer.open(in)); auto image = importer.image2D(0); #ifndef MAGNUM_TARGET_GLES - CORRADE_VERIFY(image->components() == AbstractImage::Components::BGR); + CORRADE_COMPARE(image->format(), Trade::ImageData2D::Format::BGR); #else - CORRADE_VERIFY(image->components() == AbstractImage::Components::RGB); + CORRADE_COMPARE(image->format(), Trade::ImageData2D::Format::RGB); #endif CORRADE_COMPARE(image->size(), Math::Vector2(2, 3)); - CORRADE_VERIFY(image->type() == TypeTraits::imageType()); + 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)); } @@ -139,12 +140,12 @@ void TgaImporterTest::bits32() { CORRADE_VERIFY(importer.open(in)); auto image = importer.image2D(0); #ifndef MAGNUM_TARGET_GLES - CORRADE_VERIFY(image->components() == AbstractImage::Components::BGRA); + CORRADE_COMPARE(image->format(), Trade::ImageData2D::Format::BGRA); #else - CORRADE_VERIFY(image->components() == AbstractImage::Components::RGBA); + CORRADE_COMPARE(image->format(), Trade::ImageData2D::Format::RGBA); #endif CORRADE_COMPARE(image->size(), Math::Vector2(2, 3)); - CORRADE_VERIFY(image->type() == TypeTraits::imageType()); + 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)); } diff --git a/src/Plugins/TgaImporter/TgaImporter.cpp b/src/Plugins/TgaImporter/TgaImporter.cpp index ec3c5bbb0..23f3121a8 100644 --- a/src/Plugins/TgaImporter/TgaImporter.cpp +++ b/src/Plugins/TgaImporter/TgaImporter.cpp @@ -74,35 +74,35 @@ bool TgaImporter::open(std::istream& in, const std::string& name) { return false; } - AbstractImage::Components components; + ImageData2D::Format format; switch(header.bpp) { case 24: #ifndef MAGNUM_TARGET_GLES - components = AbstractImage::Components::BGR; + format = ImageData2D::Format::BGR; #else - components = AbstractImage::Components::RGB; + format = ImageData2D::Format::RGB; #endif break; case 32: #ifndef MAGNUM_TARGET_GLES - components = AbstractImage::Components::BGRA; + format = ImageData2D::Format::BGRA; #else - components = AbstractImage::Components::RGBA; + format = ImageData2D::Format::RGBA; #endif break; default: - Error() << "TgaImporter: unsupported bits-per-pixel:" << int(header.bpp); + Error() << "TgaImporter: unsupported bits-per-pixel:" << header.bpp; return false; } std::size_t size = header.width*header.height*header.bpp/8; - GLubyte* buffer = new GLubyte[size]; - in.read(reinterpret_cast(buffer), size); + char* buffer = new char[size]; + in.read(buffer, size); Math::Vector2 dimensions(header.width, header.height); #ifdef MAGNUM_TARGET_GLES - if(components == AbstractImage::Components::RGB) { + if(format == AbstractImage::Components::RGB) { Math::Vector3* data = reinterpret_cast*>(buffer); std::transform(data, data + dimensions.product(), data, [](Math::Vector3 pixel) { return swizzle<'b', 'g', 'r'>(pixel); }); @@ -113,7 +113,7 @@ bool TgaImporter::open(std::istream& in, const std::string& name) { } #endif - _image = new ImageData2D(name, dimensions, components, buffer); + _image = new ImageData2D(name, dimensions, format, ImageData2D::Type::UnsignedByte, buffer); return true; }