diff --git a/src/Trade/AbstractImageConverter.cpp b/src/Trade/AbstractImageConverter.cpp index 225895af5..5bdf5e8b4 100644 --- a/src/Trade/AbstractImageConverter.cpp +++ b/src/Trade/AbstractImageConverter.cpp @@ -34,33 +34,33 @@ AbstractImageConverter::AbstractImageConverter() = default; AbstractImageConverter::AbstractImageConverter(PluginManager::AbstractManager* manager, std::string plugin): AbstractPlugin(manager, std::move(plugin)) {} -Image2D* AbstractImageConverter::exportToImage(const Image2D* const image) const { +Image2D* AbstractImageConverter::exportToImage(const ImageReference2D& image) const { CORRADE_ASSERT(features() & Feature::ConvertImage, "Trade::AbstractImageConverter::exportToImage(): feature not supported", nullptr); return doExportToImage(image); } -Image2D* AbstractImageConverter::doExportToImage(const Image2D*) const { +Image2D* AbstractImageConverter::doExportToImage(const ImageReference2D&) const { CORRADE_ASSERT(false, "Trade::AbstractImageConverter::exportToImage(): feature advertised but not implemented", nullptr); } -Containers::Array AbstractImageConverter::exportToData(const Image2D* const image) const { +Containers::Array AbstractImageConverter::exportToData(const ImageReference2D& image) const { CORRADE_ASSERT(features() & Feature::ConvertData, "Trade::AbstractImageConverter::exportToData(): feature not supported", nullptr); return doExportToData(image); } -Containers::Array AbstractImageConverter::doExportToData(const Image2D*) const { +Containers::Array AbstractImageConverter::doExportToData(const ImageReference2D&) const { CORRADE_ASSERT(false, "Trade::AbstractImageConverter::exportToData(): feature advertised but not implemented", nullptr); } -bool AbstractImageConverter::exportToFile(const Image2D* const image, const std::string& filename) const { +bool AbstractImageConverter::exportToFile(const ImageReference2D& image, const std::string& filename) const { return doExportToFile(image, filename); } -bool AbstractImageConverter::doExportToFile(const Image2D* const image, const std::string& filename) const { +bool AbstractImageConverter::doExportToFile(const ImageReference2D& image, const std::string& filename) const { CORRADE_ASSERT(features() & Feature::ConvertData, "Trade::AbstractImageConverter::exportToFile(): not implemented", false); auto data = doExportToData(image); diff --git a/src/Trade/AbstractImageConverter.h b/src/Trade/AbstractImageConverter.h index 126964286..5b40c8cd3 100644 --- a/src/Trade/AbstractImageConverter.h +++ b/src/Trade/AbstractImageConverter.h @@ -56,7 +56,7 @@ checked by the implementation: is supported. */ class MAGNUM_EXPORT AbstractImageConverter: public PluginManager::AbstractPlugin { - CORRADE_PLUGIN_INTERFACE("cz.mosra.magnum.Trade.AbstractImageConverter/0.2") + CORRADE_PLUGIN_INTERFACE("cz.mosra.magnum.Trade.AbstractImageConverter/0.2.1") public: /** @@ -95,7 +95,7 @@ class MAGNUM_EXPORT AbstractImageConverter: public PluginManager::AbstractPlugin * Returns converted image on success, `nullptr` otherwise. * @see features(), exportToData(), exportToFile() */ - Image2D* exportToImage(const Image2D* image) const; + Image2D* exportToImage(const ImageReference2D& image) const; /** * @brief Export image to raw data @@ -104,7 +104,7 @@ class MAGNUM_EXPORT AbstractImageConverter: public PluginManager::AbstractPlugin * Returns data on success, zero-sized array otherwise. * @see features(), exportToImage(), exportToFile() */ - Containers::Array exportToData(const Image2D* image) const; + Containers::Array exportToData(const ImageReference2D& image) const; /** * @brief Export image to file @@ -112,7 +112,7 @@ class MAGNUM_EXPORT AbstractImageConverter: public PluginManager::AbstractPlugin * Returns `true` on success, `false` otherwise. * @see features(), exportToImage(), exportToData() */ - bool exportToFile(const Image2D* image, const std::string& filename) const; + bool exportToFile(const ImageReference2D& image, const std::string& filename) const; #ifndef DOXYGEN_GENERATING_OUTPUT private: @@ -123,10 +123,10 @@ class MAGNUM_EXPORT AbstractImageConverter: public PluginManager::AbstractPlugin virtual Features doFeatures() const = 0; /** @brief Implementation of exportToImage() */ - virtual Image2D* doExportToImage(const Image2D* image) const; + virtual Image2D* doExportToImage(const ImageReference2D& image) const; /** @brief Implementation of exportToData() */ - virtual Containers::Array doExportToData(const Image2D* image) const; + virtual Containers::Array doExportToData(const ImageReference2D& image) const; /** * @brief Implementation of exportToFile() @@ -135,7 +135,7 @@ class MAGNUM_EXPORT AbstractImageConverter: public PluginManager::AbstractPlugin * implementation calls doExportToData() and saves the result to given * file. */ - virtual bool doExportToFile(const Image2D* image, const std::string& filename) const; + virtual bool doExportToFile(const ImageReference2D& image, const std::string& filename) const; }; CORRADE_ENUMSET_OPERATORS(AbstractImageConverter::Features) diff --git a/src/Trade/Test/AbstractImageConverterTest.cpp b/src/Trade/Test/AbstractImageConverterTest.cpp index 7fbfae7c3..e03d441d9 100644 --- a/src/Trade/Test/AbstractImageConverterTest.cpp +++ b/src/Trade/Test/AbstractImageConverterTest.cpp @@ -27,8 +27,8 @@ #include #include -#include "Image.h" #include "ImageFormat.h" +#include "ImageReference.h" #include "Trade/AbstractImageConverter.h" #include "testConfigure.h" @@ -51,10 +51,10 @@ void AbstractImageConverterTest::exportToFile() { private: Features doFeatures() const override { return Feature::ConvertData; } - Containers::Array doExportToData(const Image2D* image) const override { + Containers::Array doExportToData(const ImageReference2D& image) const override { Containers::Array out(2); - out[0] = image->size().x(); - out[1] = image->size().y(); + out[0] = image.size().x(); + out[1] = image.size().y(); return out; }; }; @@ -64,8 +64,8 @@ void AbstractImageConverterTest::exportToFile() { /* doExportToFile() should call doExportToData() */ DataExporter exporter; - Image2D image(ImageFormat::RGBA, ImageType::UnsignedByte, {0xfe, 0xed}, nullptr); - CORRADE_VERIFY(exporter.exportToFile(&image, Utility::Directory::join(TRADE_TEST_OUTPUT_DIR, "image.out"))); + ImageReference2D image(ImageFormat::RGBA, ImageType::UnsignedByte, {0xfe, 0xed}, nullptr); + CORRADE_VERIFY(exporter.exportToFile(image, Utility::Directory::join(TRADE_TEST_OUTPUT_DIR, "image.out"))); CORRADE_COMPARE_AS(Utility::Directory::join(TRADE_TEST_OUTPUT_DIR, "image.out"), "\xFE\xED", TestSuite::Compare::FileToString); }