Salome HOME
loadImage() for py scripts
[modules/hydro.git] / src / HYDROData / HYDROData_Image.cxx
index fa024b5ae1dd0b2b7f476cf40b18a4de4508427d..ff649a207f52e9b99862b84ce1c435db08eda780 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)