diff --git a/source/SubWindowHandle.cpp b/source/SubWindowHandle.cpp index 9119127..47281f8 100644 --- a/source/SubWindowHandle.cpp +++ b/source/SubWindowHandle.cpp @@ -109,6 +109,10 @@ bool SubWindowHandle::loadFile( const QString &fileName ) return true; } +/** + * Functions to enable a module in the + * current SubWindow + */ Void SubWindowHandle::enableModule( PlaYUVerModuleIf* select_module ) { m_pcCurrentModule = select_module; @@ -116,16 +120,40 @@ Void SubWindowHandle::enableModule( PlaYUVerModuleIf* select_module ) refreshFrame(); } +Void SubWindowHandle::disableModule() +{ + m_pcCurrentModule->destroy(); + m_pcCurrentModule = NULL; + refreshFrame(); +} + +QImage* SubWindowHandle::FrameToQImage( PlaYUVerFrame* curr_frame ) +{ + Pel*** bufferRGB = curr_frame->getPelBufferRGB(); + + curr_frame->YUV420toRGB(); + + for( Int y = 0; y < curr_frame->getHeight(); y++ ) + { + for( Int x = 0; x < curr_frame->getWidth(); x++ ) + { + m_pCurrFrameQImage->setPixel( x, y, qRgb( bufferRGB[0][y][x], bufferRGB[1][y][x], bufferRGB[2][y][x] ) ); + } + } + return m_pCurrFrameQImage; +} + Void SubWindowHandle::refreshFrame() { if( m_pcCurrentModule ) { - m_pcCurrentModule->process( m_pCurrStream->getFrame( m_pcCurrentModule->getModImage() ) ); + FrameToQImage( m_pcCurrentModule->process( m_pCurrStream->getFrame( m_pcCurrentModule->getModImage() ) ) ); } else { - m_cViewArea->setImage( QPixmap::fromImage( *( m_pCurrStream->getFrame( m_pCurrFrameQImage ) ) ) ); + FrameToQImage( m_pCurrStream->getFrame( (PlaYUVerFrame*) NULL ) ); } + m_cViewArea->setImage( QPixmap::fromImage( *m_pCurrFrameQImage ) ); } bool SubWindowHandle::save() diff --git a/source/SubWindowHandle.h b/source/SubWindowHandle.h index 6423487..4d90f98 100644 --- a/source/SubWindowHandle.h +++ b/source/SubWindowHandle.h @@ -73,6 +73,7 @@ public: Void stopEvent(); Void seekEvent( UInt new_frame_num ); + QImage* FrameToQImage( PlaYUVerFrame* curr_frame ); Void refreshFrame(); InputStream* getInputStream() @@ -81,10 +82,11 @@ public: } /** - * Function to enable a module in the + * Functions to enable a module in the * current SubWindow */ Void enableModule( PlaYUVerModuleIf* select_module ); + Void disableModule(); /** * Show the image at its original size diff --git a/source/modules/FilterFrame.cpp b/source/modules/FilterFrame.cpp index 849af81..8aa66b3 100644 --- a/source/modules/FilterFrame.cpp +++ b/source/modules/FilterFrame.cpp @@ -48,7 +48,7 @@ PlaYUVerFrame* FilterFrame::process( PlaYUVerFrame* InputFrame ) pppPelYUV[2][y][x] = 128; } } - + m_pcFilteredFrame->YUV420toRGB(); return m_pcFilteredFrame; } diff --git a/source/plaYUVerApp.cpp b/source/plaYUVerApp.cpp index b035590..9401a07 100644 --- a/source/plaYUVerApp.cpp +++ b/source/plaYUVerApp.cpp @@ -71,6 +71,8 @@ plaYUVerApp::plaYUVerApp() setAcceptDrops( true ); mdiArea->setAcceptDrops( true ); + + m_pcCurrentSubWindow = NULL; } Void plaYUVerApp::closeEvent( QCloseEvent *event ) @@ -231,8 +233,12 @@ void plaYUVerApp::chageSubWindowSelection() playingTimer->stop(); if( activeSubWindow() ) { + if( m_pcCurrentSubWindow ) + m_pcCurrentSubWindow->disableModule(); + m_pcFrameSlider->setMaximum( activeSubWindow()->getInputStream()->getFrameNum() - 1 ); m_pcFrameSlider->setValue( activeSubWindow()->getInputStream()->getCurrFrameNum() ); + m_pcCurrentSubWindow = activeSubWindow(); } updateMenus(); //updateWindowMenu(); diff --git a/source/plaYUVerApp.h b/source/plaYUVerApp.h index a6c2ec0..a7b3705 100644 --- a/source/plaYUVerApp.h +++ b/source/plaYUVerApp.h @@ -92,6 +92,7 @@ private Q_SLOTS: private: QMdiArea *mdiArea; + SubWindowHandle *m_pcCurrentSubWindow; ModulesHandle *m_pcModulesHandle; QString m_cLastOpenPath;