From 100b64931e4dd11b2392c2467588dd0ebeed446c Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Wed, 10 Sep 2014 12:14:03 +0100 Subject: [PATCH] Bugfix when saving a module result frame --- source/app/SubWindowHandle.cpp | 27 ++++++++++++++++++++++++++- source/lib/PlaYUVerStream.cpp | 1 + 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/source/app/SubWindowHandle.cpp b/source/app/SubWindowHandle.cpp index 5c7d4e1..d9eddda 100644 --- a/source/app/SubWindowHandle.cpp +++ b/source/app/SubWindowHandle.cpp @@ -201,8 +201,33 @@ Void SubWindowHandle::refreshFrame() Bool SubWindowHandle::save( QString filename ) { + Bool iRet = false; QApplication::setOverrideCursor( Qt::WaitCursor ); - Bool iRet = m_pCurrStream->saveFrame( filename ); + if( !m_pCurrStream ) + { + if( !m_pcCurrFrame ) + { + return false; + } + Int iFileFormat = PlaYUVerStream::INVALID_INPUT; + QStringList formatsExt = PlaYUVerStream::supportedReadFormatsExt(); + QString currExt = QFileInfo( filename ).suffix(); + if( formatsExt.contains( currExt ) ) + { + iFileFormat = formatsExt.indexOf( currExt ); + } + if( iFileFormat == PlaYUVerStream::YUVINPUT ) + { + return false; + } + m_pcCurrFrame->FrametoRGB8(); + QImage qimg = QImage( m_pcCurrFrame->getQImageBuffer(), m_pcCurrFrame->getWidth(), m_pcCurrFrame->getHeight(), QImage::Format_RGB888 ); + iRet = qimg.save( filename ); + } + else + { + iRet = m_pCurrStream->saveFrame( filename ); + } QApplication::restoreOverrideCursor(); return iRet; } diff --git a/source/lib/PlaYUVerStream.cpp b/source/lib/PlaYUVerStream.cpp index 19cf2e7..5349bab 100644 --- a/source/lib/PlaYUVerStream.cpp +++ b/source/lib/PlaYUVerStream.cpp @@ -536,6 +536,7 @@ Bool PlaYUVerStream::saveFrame( const QString& filename ) } else { + m_pcCurrFrame->FrametoRGB8(); QImage qimg = QImage( m_pcCurrFrame->getQImageBuffer(), m_pcCurrFrame->getWidth(), m_pcCurrFrame->getHeight(), QImage::Format_RGB888 ); return qimg.save( filename ); }