diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexOutputImageParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexOutputImageParameter.h index 37dc1434376dd6afe5806bb16367f9b59cecb644..371c4d416691d36e3e07ffe50ea69c1580c20284 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexOutputImageParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexOutputImageParameter.h @@ -85,6 +85,10 @@ public: /** Static method to convert pixel type into string */ static std::string ConvertPixelTypeToString(ComplexImagePixelType type); + /** Convert a string into a ComplexImagePixelType (returns false if the + * conversion fails) */ + static bool ConvertStringToPixelType(const std::string &value, ComplexImagePixelType &type); + /** Return true if a filename is set */ bool HasValue() const ITK_OVERRIDE; diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputImageParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputImageParameter.h index adbf9d12ee1628d5d1dd5e5f02e1b8a7ac8569c1..b420299ff6b707f8ccbed39577b488684e527fae 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputImageParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputImageParameter.h @@ -86,6 +86,10 @@ public: /** Static method to convert pixel type into string */ static std::string ConvertPixelTypeToString(ImagePixelType type); + /** Converts a string into a pixel type (returns false if the conversion + * fails) */ + static bool ConvertStringToPixelType(const std::string &value, ImagePixelType &type); + /** Return true if a filename is set */ bool HasValue() const ITK_OVERRIDE; diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperComplexOutputImageParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperComplexOutputImageParameter.cxx index ce11263ccd7cab428275ce32d374264afc12f85c..64ef3657181d767341ce804d642374d6ed7b6a27 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperComplexOutputImageParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperComplexOutputImageParameter.cxx @@ -73,6 +73,18 @@ ComplexOutputImageParameter::ConvertPixelTypeToString(ComplexImagePixelType type return ret; } +bool +ComplexOutputImageParameter::ConvertStringToPixelType(const std::string &value, ComplexImagePixelType &type) +{ + if (value == "cfloat") + type = ComplexImagePixelType_float; + else if (value == "cdouble") + type = ComplexImagePixelType_double; + else + return false; + return true; +} + void ComplexOutputImageParameter::InitializeWriters() { m_ComplexFloatWriter = ComplexFloatWriterType::New(); diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx index b2f2d8d5523d00adb29e556c0ca4d811b5902d43..2790bdce255aa5d0e8a3f92ab625e274ce48bf10 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx @@ -98,6 +98,28 @@ std::string OutputImageParameter::ConvertPixelTypeToString(ImagePixelType type) return ret; } +bool +OutputImageParameter::ConvertStringToPixelType(const std::string &value, ImagePixelType &type) +{ + if (value == "uint8") + type = ImagePixelType_uint8; + else if (value == "int16") + type = ImagePixelType_int16; + else if (value == "uint16") + type = ImagePixelType_uint16; + else if (value == "int32") + type = ImagePixelType_int32; + else if (value == "uint32") + type = ImagePixelType_uint32; + else if (value == "float") + type = ImagePixelType_float; + else if (value == "double") + type = ImagePixelType_double; + else + return false; + return true; +} + void OutputImageParameter::InitializeWriters() { m_UInt8Writer = UInt8WriterType::New();