From b7e241f17a267702dc013c9907e6eb38c870449e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Tue, 8 Oct 2013 11:40:50 +0200 Subject: [PATCH] Adapted to Magnum changes. --- .../MagnumFontConverter.cpp | 4 ++-- .../Test/MagnumFontConverterTest.cpp | 6 ++--- .../Test/TgaImageConverterTest.cpp | 20 ++++++++--------- .../TgaImageConverter/TgaImageConverter.cpp | 22 +++++++++---------- .../TgaImageConverter/TgaImageConverter.h | 4 ++-- .../TgaImporter/Test/TgaImporterTest.cpp | 22 +++++++++---------- src/Plugins/TgaImporter/TgaImporter.cpp | 22 +++++++++---------- src/Plugins/TgaImporter/TgaImporter.h | 12 +++++----- 8 files changed, 56 insertions(+), 56 deletions(-) diff --git a/src/Plugins/MagnumFontConverter/MagnumFontConverter.cpp b/src/Plugins/MagnumFontConverter/MagnumFontConverter.cpp index d54036b20..0e841fca3 100644 --- a/src/Plugins/MagnumFontConverter/MagnumFontConverter.cpp +++ b/src/Plugins/MagnumFontConverter/MagnumFontConverter.cpp @@ -27,8 +27,8 @@ #include #include #include +#include #include -#include #include #include #include @@ -102,7 +102,7 @@ std::vector>> MagnumFont std::copy(confStr.begin(), confStr.end(), confData.begin()); /* Save cache image */ - Image2D image(ImageFormat::Red, ImageType::UnsignedByte); + Image2D image(ColorFormat::Red, ColorType::UnsignedByte); cache.texture().image(0, image); auto tgaData = Trade::TgaImageConverter().exportToData(image); diff --git a/src/Plugins/MagnumFontConverter/Test/MagnumFontConverterTest.cpp b/src/Plugins/MagnumFontConverter/Test/MagnumFontConverterTest.cpp index 25e37df0c..9e00c415c 100644 --- a/src/Plugins/MagnumFontConverter/Test/MagnumFontConverterTest.cpp +++ b/src/Plugins/MagnumFontConverter/Test/MagnumFontConverterTest.cpp @@ -24,8 +24,8 @@ #include #include +#include #include -#include #include #include #include @@ -91,8 +91,8 @@ void MagnumFontConverterTest::exportFont() { std::optional image = importer.image2D(0); CORRADE_VERIFY(image); CORRADE_COMPARE(image->size(), Vector2i(256)); - CORRADE_COMPARE(image->format(), ImageFormat::Red); - CORRADE_COMPARE(image->type(), ImageType::UnsignedByte); + CORRADE_COMPARE(image->format(), ColorFormat::Red); + CORRADE_COMPARE(image->type(), ColorType::UnsignedByte); } }}} diff --git a/src/Plugins/TgaImageConverter/Test/TgaImageConverterTest.cpp b/src/Plugins/TgaImageConverter/Test/TgaImageConverterTest.cpp index c2d0c3490..20e1a5c77 100644 --- a/src/Plugins/TgaImageConverter/Test/TgaImageConverterTest.cpp +++ b/src/Plugins/TgaImageConverter/Test/TgaImageConverterTest.cpp @@ -27,8 +27,8 @@ #include #include #include +#include #include -#include #include #include #include @@ -49,9 +49,9 @@ class TgaImageConverterTest: public TestSuite::Tester { namespace { #ifndef MAGNUM_TARGET_GLES - const Image2D original(ImageFormat::BGR, ImageType::UnsignedByte, {2, 3}, new char[18] + const Image2D original(ColorFormat::BGR, ColorType::UnsignedByte, {2, 3}, new char[18] #else - const Image2D original(ImageFormat::RGB, ImageType::UnsignedByte, {2, 3}, new char[18] + const Image2D original(ColorFormat::RGB, ColorType::UnsignedByte, {2, 3}, new char[18] #endif { 1, 2, 3, 2, 3, 4, @@ -68,25 +68,25 @@ TgaImageConverterTest::TgaImageConverterTest() { } void TgaImageConverterTest::wrongFormat() { - ImageReference2D image(ImageFormat::RG, ImageType::UnsignedByte, {}, nullptr); + ImageReference2D image(ColorFormat::RG, ColorType::UnsignedByte, {}, nullptr); std::ostringstream out; Error::setOutput(&out); const auto data = TgaImageConverter().exportToData(image); CORRADE_VERIFY(!data); - CORRADE_COMPARE(out.str(), "Trade::TgaImageConverter::convertToData(): unsupported image format ImageFormat::RG\n"); + CORRADE_COMPARE(out.str(), "Trade::TgaImageConverter::convertToData(): unsupported image format ColorFormat::RG\n"); } void TgaImageConverterTest::wrongType() { - ImageReference2D image(ImageFormat::Red, ImageType::Float, {}, nullptr); + ImageReference2D image(ColorFormat::Red, ColorType::Float, {}, nullptr); std::ostringstream out; Error::setOutput(&out); const auto data = TgaImageConverter().exportToData(image); CORRADE_VERIFY(!data); - CORRADE_COMPARE(out.str(), "Trade::TgaImageConverter::convertToData(): unsupported image type ImageType::Float\n"); + CORRADE_COMPARE(out.str(), "Trade::TgaImageConverter::convertToData(): unsupported image type ColorType::Float\n"); } void TgaImageConverterTest::data() { @@ -99,11 +99,11 @@ void TgaImageConverterTest::data() { CORRADE_COMPARE(converted->size(), Vector2i(2, 3)); #ifndef MAGNUM_TARGET_GLES - CORRADE_COMPARE(converted->format(), ImageFormat::BGR); + CORRADE_COMPARE(converted->format(), ColorFormat::BGR); #else - CORRADE_COMPARE(converted->format(), ImageFormat::RGB); + CORRADE_COMPARE(converted->format(), ColorFormat::RGB); #endif - CORRADE_COMPARE(converted->type(), ImageType::UnsignedByte); + CORRADE_COMPARE(converted->type(), ColorType::UnsignedByte); CORRADE_COMPARE(std::string(reinterpret_cast(converted->data()), 2*3*3), std::string(reinterpret_cast(original.data()), 2*3*3)); } diff --git a/src/Plugins/TgaImageConverter/TgaImageConverter.cpp b/src/Plugins/TgaImageConverter/TgaImageConverter.cpp index 1e259fdc0..e273226ae 100644 --- a/src/Plugins/TgaImageConverter/TgaImageConverter.cpp +++ b/src/Plugins/TgaImageConverter/TgaImageConverter.cpp @@ -28,8 +28,8 @@ #include #include #include +#include #include -#include #ifdef MAGNUM_TARGET_GLES #include @@ -48,20 +48,20 @@ auto TgaImageConverter::doFeatures() const -> Features { return Feature::Convert Containers::Array TgaImageConverter::doExportToData(const ImageReference2D& image) const { #ifndef MAGNUM_TARGET_GLES - if(image.format() != ImageFormat::BGR && - image.format() != ImageFormat::BGRA && - image.format() != ImageFormat::Red) + if(image.format() != ColorFormat::BGR && + image.format() != ColorFormat::BGRA && + image.format() != ColorFormat::Red) #else - if(image.format() != ImageFormat::RGB && - image.format() != ImageFormat::RGBA && - image.format() != ImageFormat::Red) + if(image.format() != ColorFormat::RGB && + image.format() != ColorFormat::RGBA && + image.format() != ColorFormat::Red) #endif { Error() << "Trade::TgaImageConverter::convertToData(): unsupported image format" << image.format(); return nullptr; } - if(image.type() != ImageType::UnsignedByte) { + if(image.type() != ColorType::UnsignedByte) { Error() << "Trade::TgaImageConverter::convertToData(): unsupported image type" << image.type(); return nullptr; } @@ -72,7 +72,7 @@ Containers::Array TgaImageConverter::doExportToData(const ImageRe /* Fill header */ auto header = reinterpret_cast(data.begin()); - header->imageType = image.format() == ImageFormat::Red ? 3 : 2; + header->imageType = image.format() == ColorFormat::Red ? 3 : 2; header->bpp = pixelSize*8; header->width = Utility::Endianness::littleEndian(image.size().x()); header->height = Utility::Endianness::littleEndian(image.size().y()); @@ -81,11 +81,11 @@ Containers::Array TgaImageConverter::doExportToData(const ImageRe std::copy(image.data(), image.data()+pixelSize*image.size().product(), data.begin()+sizeof(TgaHeader)); #ifdef MAGNUM_TARGET_GLES - if(image->format() == ImageFormat::RGB) { + if(image->format() == ColorFormat::RGB) { auto pixels = reinterpret_cast*>(data.begin()+sizeof(TgaHeader)); std::transform(pixels, pixels + image.size().product(), pixels, [](Math::Vector3 pixel) { return swizzle<'b', 'g', 'r'>(pixel); }); - } else if(image.format() == ImageFormat::RGBA) { + } else if(image.format() == ColorFormat::RGBA) { auto pixels = reinterpret_cast*>(data.begin()+sizeof(TgaHeader)); std::transform(pixels, pixels + image.size().product(), pixels, [](Math::Vector4 pixel) { return swizzle<'b', 'g', 'r', 'a'>(pixel); }); diff --git a/src/Plugins/TgaImageConverter/TgaImageConverter.h b/src/Plugins/TgaImageConverter/TgaImageConverter.h index 1379582cb..60fd6b8b0 100644 --- a/src/Plugins/TgaImageConverter/TgaImageConverter.h +++ b/src/Plugins/TgaImageConverter/TgaImageConverter.h @@ -44,8 +44,8 @@ namespace Magnum { namespace Trade { /** @brief TGA image converter -Supports images with format @ref ImageFormat::BGR, @ref ImageFormat::BGRA or -@ref ImageFormat::Red and type @ref ImageType::UnsignedByte. +Supports images with format @ref ColorFormat::BGR, @ref ColorFormat::BGRA or +@ref ColorFormat::Red and type @ref ColorType::UnsignedByte. */ class MAGNUM_TRADE_TGAIMAGECONVERTER_EXPORT TgaImageConverter: public AbstractImageConverter { public: diff --git a/src/Plugins/TgaImporter/Test/TgaImporterTest.cpp b/src/Plugins/TgaImporter/Test/TgaImporterTest.cpp index f0e14d83c..7f08d8c62 100644 --- a/src/Plugins/TgaImporter/Test/TgaImporterTest.cpp +++ b/src/Plugins/TgaImporter/Test/TgaImporterTest.cpp @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include "TgaImporter/TgaImporter.h" @@ -145,12 +145,12 @@ void TgaImporterTest::colorBits24() { std::optional 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(image->data()), 2*3*3), std::string(pixels, 2*3*3)); } @@ -176,12 +176,12 @@ void TgaImporterTest::colorBits32() { std::optional 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(image->data()), 2*3*3), std::string(pixels, 2*3*3)); } @@ -197,9 +197,9 @@ void TgaImporterTest::grayscaleBits8() { std::optional 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(image->data()), 2*3), std::string(reinterpret_cast(data) + 18, 2*3)); } @@ -227,9 +227,9 @@ void TgaImporterTest::file() { std::optional 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(image->data()), 2*3), std::string(reinterpret_cast(data) + 18, 2*3)); } diff --git a/src/Plugins/TgaImporter/TgaImporter.cpp b/src/Plugins/TgaImporter/TgaImporter.cpp index 27a4fa30e..5e6867c4e 100644 --- a/src/Plugins/TgaImporter/TgaImporter.cpp +++ b/src/Plugins/TgaImporter/TgaImporter.cpp @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #ifdef MAGNUM_TARGET_GLES @@ -89,7 +89,7 @@ std::optional TgaImporter::doImage2D(UnsignedInt) { header.height = Utility::Endianness::littleEndian(header.height); /* Image format */ - ImageFormat format; + ColorFormat format; if(header.colorMapType != 0) { Error() << "Trade::TgaImporter::image2D(): paletted files are not supported"; return std::nullopt; @@ -100,16 +100,16 @@ std::optional TgaImporter::doImage2D(UnsignedInt) { switch(header.bpp) { case 24: #ifndef MAGNUM_TARGET_GLES - format = ImageFormat::BGR; + format = ColorFormat::BGR; #else - format = ImageFormat::RGB; + format = ColorFormat::RGB; #endif break; case 32: #ifndef MAGNUM_TARGET_GLES - format = ImageFormat::BGRA; + format = ColorFormat::BGRA; #else - format = ImageFormat::RGBA; + format = ColorFormat::RGBA; #endif break; default: @@ -121,9 +121,9 @@ std::optional TgaImporter::doImage2D(UnsignedInt) { } else if(header.imageType == 3) { #ifdef MAGNUM_TARGET_GLES format = Context::current() && Context::current()->isExtensionSupported() ? - ImageFormat::Red : ImageFormat::Luminance; + ColorFormat::Red : ColorFormat::Luminance; #else - format = ImageFormat::Red; + format = ColorFormat::Red; #endif if(header.bpp != 8) { Error() << "Trade::TgaImporter::image2D(): unsupported grayscale bits-per-pixel:" << header.bpp; @@ -143,18 +143,18 @@ std::optional TgaImporter::doImage2D(UnsignedInt) { Vector2i size(header.width, header.height); #ifdef MAGNUM_TARGET_GLES - if(format == ImageFormat::RGB) { + if(format == ColorFormat::RGB) { auto pixels = reinterpret_cast*>(data); std::transform(pixels, pixels + size.product(), pixels, [](Math::Vector3 pixel) { return swizzle<'b', 'g', 'r'>(pixel); }); - } else if(format == ImageFormat::RGBA) { + } else if(format == ColorFormat::RGBA) { auto pixels = reinterpret_cast*>(data); std::transform(pixels, pixels + size.product(), pixels, [](Math::Vector4 pixel) { return swizzle<'b', 'g', 'r', 'a'>(pixel); }); } #endif - return ImageData2D(format, ImageType::UnsignedByte, size, data); + return ImageData2D(format, ColorType::UnsignedByte, size, data); } }} diff --git a/src/Plugins/TgaImporter/TgaImporter.h b/src/Plugins/TgaImporter/TgaImporter.h index 728c9ea69..63e83654e 100644 --- a/src/Plugins/TgaImporter/TgaImporter.h +++ b/src/Plugins/TgaImporter/TgaImporter.h @@ -47,14 +47,14 @@ namespace Magnum { namespace Trade { Supports uncompressed BGR, BGRA or grayscale images with 8 bits per channel. -The images are imported with @ref ImageType::UnsignedByte and @ref ImageFormat::BGR, -@ref ImageFormat::BGRA or @ref ImageFormat::Red, respectively. Grayscale images +The images are imported with @ref ColorType::UnsignedByte and @ref ColorFormat::BGR, +@ref ColorFormat::BGRA or @ref ColorFormat::Red, respectively. Grayscale images require extension @extension{ARB,texture_rg}. -In OpenGL ES BGR and BGRA images are converted to @ref ImageFormat::RGB -and @ref ImageFormat::RGBA. In OpenGL ES 2.0, if @es_extension{EXT,texture_rg} -is not supported, grayscale images use @ref ImageFormat::Luminance instead of -@ref ImageFormat::Red. +In OpenGL ES BGR and BGRA images are converted to @ref ColorFormat::RGB +and @ref ColorFormat::RGBA. In OpenGL ES 2.0, if @es_extension{EXT,texture_rg} +is not supported, grayscale images use @ref ColorFormat::Luminance instead of +@ref ColorFormat::Red. */ class MAGNUM_TRADE_TGAIMPORTER_EXPORT TgaImporter: public AbstractImporter { public: