Salome HOME
Merge remote-tracking branch 'origin/BR_DEMO' into BR_2017
[modules/hydro.git] / src / HYDROData / HYDROData_Image.cxx
index fa024b5ae1dd0b2b7f476cf40b18a4de4508427d..a957d7f9f97a78c51cc9b1e644ef2b87172871c5 100644 (file)
@@ -43,6 +43,7 @@
 
 #include <QStringList>
 #include <QFile>
+#include <QFileInfo>
 
 #ifdef WIN32
   #pragma warning ( default: 4251 )
@@ -310,10 +311,19 @@ void HYDROData_Image::SetImage(const QImage& theImage)
 
 bool HYDROData_Image::LoadImage( const QString& theFilePath )
 {
-  QImage anImage( theFilePath );
+  QFileInfo aFI(theFilePath);
+  QImage anImage;
+  HYDROData_Image::ECW_FileInfo* theECWInfo;
+  if (aFI.suffix().toLower() == "ecw")
+  {
+    theECWInfo = new HYDROData_Image::ECW_FileInfo;
+    HYDROData_Image::OpenECW(theFilePath.toLatin1().data(), anImage, theECWInfo);
+  }
+  else
+    anImage = QImage(theFilePath);
   SetImage( anImage );
   SetFilePath( theFilePath );
-  return !anImage.isNull(); //TODO open ecw from this func!
+  return !anImage.isNull();
 }
 
 bool HYDROData_Image::OpenECW(char* theFileName, QImage& theImage, ECW_FileInfo* theECWInfo)
@@ -397,6 +407,7 @@ bool HYDROData_Image::OpenECW(char* theFileName, QImage& theImage, ECW_FileInfo*
   free(pRGBTriplets);
   NCScbmCloseFileView(pNCSFileView);
   theImage = anImage;
+  return true;
 }
 
 bool HYDROData_Image::LoadImageECW( const QString& theFilePath )