X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=common%2FclitkEsrfHstImageIO.cxx;h=a17807c2df2c61494d3144e1a3eb33a5d147f29e;hb=a9a144f59b821751d19a41bd7b8e5bc6d6ff7a01;hp=8023ddd62d5aff56046c7fa26c9b4b2a45007ca6;hpb=c7f88ac1c53bedf4c01562761bf1bd3c91773181;p=clitk.git diff --git a/common/clitkEsrfHstImageIO.cxx b/common/clitkEsrfHstImageIO.cxx index 8023ddd..a17807c 100644 --- a/common/clitkEsrfHstImageIO.cxx +++ b/common/clitkEsrfHstImageIO.cxx @@ -79,7 +79,7 @@ bool clitk::EsrfHstImageIO::CanReadFile(const char* FileNameToRead) std::string firstLine; std::getline(is, firstLine); - if(firstLine != std::string("") ) + if(firstLine.find( std::string("") ) == std::string::npos) return false; return true; @@ -107,6 +107,7 @@ void clitk::EsrfHstImageIO::Read(void * buffer) // Adapted from itkRawImageIO { +#if ( ITK_VERSION_MAJOR < 5 ) using namespace itk; // Swap bytes if necessary if itkReadRawBytesAfterSwappingMacro( unsigned short, USHORT ) @@ -115,10 +116,35 @@ void clitk::EsrfHstImageIO::Read(void * buffer) else if itkReadRawBytesAfterSwappingMacro( unsigned char, UCHAR ) else if itkReadRawBytesAfterSwappingMacro( unsigned int, UINT ) else if itkReadRawBytesAfterSwappingMacro( int, INT ) - else if itkReadRawBytesAfterSwappingMacro( unsigned int, ULONG ) - else if itkReadRawBytesAfterSwappingMacro( int, LONG ) - else if itkReadRawBytesAfterSwappingMacro( float, FLOAT ) - else if itkReadRawBytesAfterSwappingMacro( double, DOUBLE ); + else if itkReadRawBytesAfterSwappingMacro( float, FLOAT ) + else if itkReadRawBytesAfterSwappingMacro( double, DOUBLE ); +#else + #define itkReadRawBytesAfterSwappingMacro(StrongType, WeakType) \ + ( this->GetComponentType() == WeakType ) \ + { \ + using InternalByteSwapperType = itk::ByteSwapper; \ + if ( m_ByteOrder == LittleEndian ) \ + { \ + InternalByteSwapperType::SwapRangeFromSystemToLittleEndian( \ + (StrongType *)buffer, this->GetImageSizeInComponents() ); \ + } \ + else if ( m_ByteOrder == BigEndian ) \ + { \ + InternalByteSwapperType::SwapRangeFromSystemToBigEndian( \ + (StrongType *)buffer, this->GetImageSizeInComponents() ); \ + } \ + } + + // Swap bytes if necessary + if itkReadRawBytesAfterSwappingMacro( unsigned short, USHORT ) + else if itkReadRawBytesAfterSwappingMacro( short, SHORT ) + else if itkReadRawBytesAfterSwappingMacro( char, CHAR ) + else if itkReadRawBytesAfterSwappingMacro( unsigned char, UCHAR ) + else if itkReadRawBytesAfterSwappingMacro( unsigned int, UINT ) + else if itkReadRawBytesAfterSwappingMacro( int, INT ) + else if itkReadRawBytesAfterSwappingMacro( float, FLOAT ) + else if itkReadRawBytesAfterSwappingMacro( double, DOUBLE ); +#endif } }