diff --git a/Code/IO/otbONERAImageIO.cxx b/Code/IO/otbONERAImageIO.cxx index b1c2ade4ae8291d7accd68c723644486d05802e1..489629c1cfa4e3e1a28b3563d4333539cc744d98 100644 --- a/Code/IO/otbONERAImageIO.cxx +++ b/Code/IO/otbONERAImageIO.cxx @@ -241,11 +241,20 @@ otbMsgDevMacro( <<" Nb Of Components : "<<this->GetNumberOfComponents()); } //byte swapping depending on pixel type: - if(this->GetComponentType() == FLOAT) +/* if(this->GetComponentType() == FLOAT) { itk::ByteSwapper<float>::SwapRangeFromSystemToLittleEndian( reinterpret_cast<float *>(buffer),cpt); - } + }*/ + unsigned long numberOfPixelsPerRegion = lNbLignes * lNbColonnes * 2; + // Swap bytes if necessary + if ( 0 ) {} + otbSwappFileToSystemMacro( float, FLOAT, buffer, numberOfPixelsPerRegion ) + otbSwappFileToSystemMacro( double, DOUBLE, buffer, numberOfPixelsPerRegion ) + else + { + itkExceptionMacro(<<"ONERAImageIO::Read() undefined component type! " ); + } delete [] value; @@ -386,7 +395,9 @@ void ONERAImageIO::InternalReadImageInformation() otbMsgDebugMacro( <<"Driver to read: ONERA"); otbMsgDebugMacro( <<" Read file : "<< m_FileName); otbMsgDebugMacro( <<" Size : "<<m_Dimensions[0]<<","<<m_Dimensions[1]); -otbMsgDebugMacro( <<" ComponentType : "<<this->GetComponentType() ); +otbMsgDebugMacro( <<" PixelType : "<<this->GetPixelTypeAsString(this->GetPixelType())); +otbMsgDebugMacro( <<" ComponentType : "<<this->GetComponentTypeAsString(this->GetComponentType())); +otbMsgDebugMacro( <<" ComponentSize : "<<this->GetComponentSize()); otbMsgDebugMacro( <<" NumberOfComponents : "<<this->GetNumberOfComponents()); otbMsgDebugMacro( <<" NbOctetPixel : "<<m_NbOctetPixel); @@ -490,11 +501,11 @@ otbMsgDevMacro( <<" Dimensions de l'image : "<<m_Dimensions[0]<<","<<m_Dimensio otbMsgDevMacro( <<" Region lue (IORegion) : "<<this->GetIORegion()); otbMsgDevMacro( <<" Nb Of Components : "<<this->GetNumberOfComponents()); - // Cas particuliers : on controle que si la r�gion � �crire est de la m�me dimension que l'image enti�re, - // on commence l'offset � 0 (lorsque que l'on est pas en "Streaming") + // Cas particuliers : on controle que si la r�gion � �crire est de la m�me dimension que l'image enti�re, + // on commence l'offset � 0 (lorsque que l'on est pas en "Streaming") if( (lNbLignes == m_Dimensions[1]) && (lNbColonnes == m_Dimensions[0])) { - otbMsgDevMacro(<<"Force l'offset de l'IORegion � 0"); + otbMsgDevMacro(<<"Force l'offset de l'IORegion � 0"); lPremiereLigne = 0; lPremiereColonne = 0; } diff --git a/Code/IO/otbONERAImageIO.h b/Code/IO/otbONERAImageIO.h index 5f6aefa687cdfb6df72af4b052be96922f53abde..243ee053c68b6b5ecf2c984e40f4f602374e6d36 100644 --- a/Code/IO/otbONERAImageIO.h +++ b/Code/IO/otbONERAImageIO.h @@ -18,6 +18,7 @@ #ifndef __otbONERAImageIO_h #define __otbONERAImageIO_h +#include "itkByteSwapper.h" #include "itkImageIOBase.h" #include <fstream> @@ -119,18 +120,24 @@ private: ONERAImageIO(const Self&); //purposely not implemented void operator=(const Self&); //purposely not implemented - /** M�thode analyse le nom du fichier a ouvrir. S'il s'agit d'un r�pertoire, - * on regarde s'il contient un produit le fichier ent�te (fichier "ENT...") + /** M�thode analyse le nom du fichier a ouvrir. S'il s'agit d'un r�pertoire, + * on regarde s'il contient un produit le fichier ent�te (fichier "ENT...") * Dans ce cas, ONERAFileName contient le nom du fichier a ouvrir. * Sinon ONERAFileName contient filename */ void GetOneraImageFileName( const char * filename, std::string & OneraFileName ); +#define otbSwappFileToSystemMacro(StrongType, WeakType, buffer, buffer_size) \ + else if ( this->GetComponentType() == WeakType ) \ + { \ + typedef itk::ByteSwapper< StrongType > InternalByteSwapperType; \ + InternalByteSwapperType::SwapRangeFromSystemToLittleEndian((StrongType *)buffer, buffer_size ); \ + } /** Nombre d'octets par pixel */ int m_NbOctetPixel; bool m_FlagWriteImageInformation; - + };