diff --git a/src/Magnum/Trade/AbstractImageConverter.cpp b/src/Magnum/Trade/AbstractImageConverter.cpp index bca9feeea..1c5539ea8 100644 --- a/src/Magnum/Trade/AbstractImageConverter.cpp +++ b/src/Magnum/Trade/AbstractImageConverter.cpp @@ -29,22 +29,24 @@ #include #include +#include "Magnum/Image.h" + namespace Magnum { namespace Trade { AbstractImageConverter::AbstractImageConverter() = default; AbstractImageConverter::AbstractImageConverter(PluginManager::AbstractManager& manager, std::string plugin): AbstractPlugin(manager, std::move(plugin)) {} -Image2D* AbstractImageConverter::exportToImage(const ImageReference2D& image) const { +std::optional AbstractImageConverter::exportToImage(const ImageReference2D& image) const { CORRADE_ASSERT(features() & Feature::ConvertImage, - "Trade::AbstractImageConverter::exportToImage(): feature not supported", nullptr); + "Trade::AbstractImageConverter::exportToImage(): feature not supported", {}); return doExportToImage(image); } -Image2D* AbstractImageConverter::doExportToImage(const ImageReference2D&) const { - CORRADE_ASSERT(false, "Trade::AbstractImageConverter::exportToImage(): feature advertised but not implemented", nullptr); - return nullptr; +std::optional AbstractImageConverter::doExportToImage(const ImageReference2D&) const { + CORRADE_ASSERT(false, "Trade::AbstractImageConverter::exportToImage(): feature advertised but not implemented", {}); + return std::nullopt; } Containers::Array AbstractImageConverter::exportToData(const ImageReference2D& image) const { diff --git a/src/Magnum/Trade/AbstractImageConverter.h b/src/Magnum/Trade/AbstractImageConverter.h index cc0913f11..6a84f98f6 100644 --- a/src/Magnum/Trade/AbstractImageConverter.h +++ b/src/Magnum/Trade/AbstractImageConverter.h @@ -34,6 +34,7 @@ #include "Magnum/Magnum.h" #include "Magnum/visibility.h" #include "Magnum/Text/Text.h" +#include "MagnumExternal/Optional/optional.hpp" namespace Magnum { namespace Trade { @@ -95,10 +96,10 @@ class MAGNUM_EXPORT AbstractImageConverter: public PluginManager::AbstractPlugin * @brief Convert image to different format * * Available only if @ref Feature::ConvertImage is supported. Returns - * converted image on success, `nullptr` otherwise. + * converted image on success, `std::nullopt` otherwise. * @see @ref features(), @ref exportToData(), @ref exportToFile() */ - Image2D* exportToImage(const ImageReference2D& image) const; + std::optional exportToImage(const ImageReference2D& image) const; /** * @brief Export image to raw data @@ -126,7 +127,7 @@ class MAGNUM_EXPORT AbstractImageConverter: public PluginManager::AbstractPlugin virtual Features doFeatures() const = 0; /** @brief Implementation of @ref exportToImage() */ - virtual Image2D* doExportToImage(const ImageReference2D& image) const; + virtual std::optional doExportToImage(const ImageReference2D& image) const; /** @brief Implementation of @ref exportToData() */ virtual Containers::Array doExportToData(const ImageReference2D& image) const;