From 8d4dba4a45855249f5eb022e9cc7dcff202bce3c Mon Sep 17 00:00:00 2001 From: isn Date: Thu, 12 Oct 2017 16:19:24 +0300 Subject: [PATCH] loadImage() for py scripts --- src/HYDROData/HYDROData_Image.cxx | 14 ++++++++++++-- src/HYDROGUI/HYDROGUI_ImportImageDlg.cxx | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/HYDROData/HYDROData_Image.cxx b/src/HYDROData/HYDROData_Image.cxx index fa024b5a..ff649a20 100644 --- a/src/HYDROData/HYDROData_Image.cxx +++ b/src/HYDROData/HYDROData_Image.cxx @@ -43,6 +43,7 @@ #include #include +#include #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) diff --git a/src/HYDROGUI/HYDROGUI_ImportImageDlg.cxx b/src/HYDROGUI/HYDROGUI_ImportImageDlg.cxx index 8116bfd5..8ad0fcbd 100644 --- a/src/HYDROGUI/HYDROGUI_ImportImageDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_ImportImageDlg.cxx @@ -813,7 +813,7 @@ void HYDROGUI_ImportImageDlg::ActivateFile( const QString& theFileName, bool isE QFileInfo aFI( theFileName ); QImage anImage; HYDROData_Image::ECW_FileInfo* theECWInfo = NULL; - if (aFI.completeSuffix().toLower() == "ecw") + if (aFI.suffix().toLower() == "ecw") { theECWInfo = new HYDROData_Image::ECW_FileInfo; HYDROData_Image::OpenECW(theFileName.toLatin1().data(), anImage, theECWInfo); -- 2.39.2