Fix last commit. Use just one QImage for every frame
This commit is contained in:
1 parent
fcef6e09c4
commit
3cf0d866ad
5 files changed
+48
-41
No files matched your search
@@ -243,14 +243,14 @@ Void InputStream::readFrame()
|
||||
|
||||
Bool InputStream::writeFrame( const QString& filename )
|
||||
{
|
||||
getFrameQImage().save( filename );
|
||||
QImage img( m_uiWidth, m_uiHeight, QImage::Format_RGB888 );
|
||||
getFrame( &img );
|
||||
img.save( filename );
|
||||
return true;
|
||||
}
|
||||
|
||||
QImage InputStream::getFrameQImage()
|
||||
Void InputStream::getFrame( QImage *qimage )
|
||||
{
|
||||
// Create QImage
|
||||
QImage img( m_uiWidth, m_uiHeight, QImage::Format_RGB888 );
|
||||
Pel*** bufferRGB = m_cCurrFrame->getPelBufferRGB();
|
||||
|
||||
if( sizeof(Pel) == sizeof(unsigned char) )
|
||||
@@ -259,7 +259,7 @@ QImage InputStream::getFrameQImage()
|
||||
{
|
||||
for( Int x = 0; x < m_uiWidth; x++ )
|
||||
{
|
||||
img.setPixel( x, y, qRgb( bufferRGB[0][y][x], bufferRGB[1][y][x], bufferRGB[2][y][x] ) );
|
||||
qimage->setPixel( x, y, qRgb( bufferRGB[0][y][x], bufferRGB[1][y][x], bufferRGB[2][y][x] ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -267,7 +267,6 @@ QImage InputStream::getFrameQImage()
|
||||
{
|
||||
Q_ASSERT( 0 );
|
||||
}
|
||||
return img;
|
||||
}
|
||||
|
||||
#ifdef USE_OPENCV
|
||||
|
||||
@@ -103,7 +103,7 @@ public:
|
||||
|
||||
Bool writeFrame( const QString& filename );
|
||||
|
||||
QImage getFrameQImage();
|
||||
Void getFrame( QImage *qimage );
|
||||
#ifdef USE_OPENCV
|
||||
cv::Mat getFrameCvMat();
|
||||
#endif
|
||||
|
||||
+32
-24
@@ -61,28 +61,32 @@ bool SubWindowHandle::loadFile( const QString &fileName )
|
||||
{
|
||||
ConfigureFormatDialog formatDialog( this );
|
||||
|
||||
if( m_currStream.needFormatDialog( fileName ) )
|
||||
m_pCurrStream = new InputStream;
|
||||
|
||||
if( m_pCurrStream->needFormatDialog( fileName ) )
|
||||
{
|
||||
if( formatDialog.exec() == QDialog::Rejected )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
m_currStream.init( fileName, formatDialog.getResolution().width(), formatDialog.getResolution().height(), formatDialog.getPixelFormat(),
|
||||
m_pCurrStream->init( fileName, formatDialog.getResolution().width(), formatDialog.getResolution().height(), formatDialog.getPixelFormat(),
|
||||
formatDialog.getFrameRate() );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_currStream.init( fileName, 0, 0, 0, 0 );
|
||||
m_pCurrStream->init( fileName, 0, 0, 0, 0 );
|
||||
}
|
||||
QApplication::setOverrideCursor( Qt::WaitCursor );
|
||||
QApplication::restoreOverrideCursor();
|
||||
if( m_currStream.getStatus() == 0 )
|
||||
if( m_pCurrStream->getStatus() == 0 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
m_currStream.readFrame();
|
||||
if( m_currStream.checkErrors( READING ) )
|
||||
m_pCurrFrameQImage = new QImage( m_pCurrStream->getWidth(), m_pCurrStream->getHeight(), QImage::Format_RGB888 );
|
||||
|
||||
m_pCurrStream->readFrame();
|
||||
if( m_pCurrStream->checkErrors( READING ) )
|
||||
{
|
||||
QMessageBox::warning( this, tr( "plaYUVer" ), tr( "Cannot read %1." ).arg( fileName ) );
|
||||
return false;
|
||||
@@ -90,12 +94,13 @@ bool SubWindowHandle::loadFile( const QString &fileName )
|
||||
|
||||
QApplication::restoreOverrideCursor();
|
||||
|
||||
m_cViewArea->setImage( QPixmap::fromImage( m_currStream.getFrameQImage() ) );
|
||||
m_pCurrStream->getFrame( m_pCurrFrameQImage );
|
||||
m_cViewArea->setImage( QPixmap::fromImage( *m_pCurrFrameQImage ) );
|
||||
|
||||
normalSize();
|
||||
|
||||
m_cWindowName = QString( "ola" );
|
||||
m_cWindowName = m_currStream.getStreamInformationString();
|
||||
m_cWindowName = QString( " " );
|
||||
m_cWindowName = m_pCurrStream->getStreamInformationString();
|
||||
|
||||
m_cCurrFileName = fileName;
|
||||
|
||||
@@ -122,7 +127,7 @@ bool SubWindowHandle::save()
|
||||
|
||||
QApplication::setOverrideCursor( Qt::WaitCursor );
|
||||
|
||||
if( !m_currStream.writeFrame( fileName ) )
|
||||
if( !m_pCurrStream->writeFrame( fileName ) )
|
||||
{
|
||||
QApplication::restoreOverrideCursor();
|
||||
QMessageBox::warning( this, tr( "SCode" ), tr( "Cannot save file %1" ).arg( fileName ) );
|
||||
@@ -134,31 +139,34 @@ bool SubWindowHandle::save()
|
||||
return true;
|
||||
}
|
||||
|
||||
int SubWindowHandle::playEvent()
|
||||
bool SubWindowHandle::playEvent()
|
||||
{
|
||||
bool iRet = true;
|
||||
if( m_bIsPlaying )
|
||||
{
|
||||
m_currStream.readFrame();
|
||||
if( m_currStream.checkErrors( READING ) )
|
||||
m_pCurrStream->readFrame();
|
||||
if( m_pCurrStream->checkErrors( READING ) )
|
||||
{
|
||||
QMessageBox::warning( this, tr( "plaYUVer" ), tr( "Cannot read %1." ).arg( m_cCurrFileName ) );
|
||||
return false;
|
||||
}
|
||||
else if( m_currStream.checkErrors( END_OF_SEQ ) )
|
||||
else if( m_pCurrStream->checkErrors( END_OF_SEQ ) )
|
||||
{
|
||||
m_cViewArea->setImage( QPixmap::fromImage( m_currStream.getFrameQImage() ) );
|
||||
return false;
|
||||
iRet = false;
|
||||
}
|
||||
m_cViewArea->setImage( QPixmap::fromImage( m_currStream.getFrameQImage() ) );
|
||||
m_pCurrStream->getFrame( m_pCurrFrameQImage );
|
||||
m_cViewArea->setImage( QPixmap::fromImage( *m_pCurrFrameQImage ) );
|
||||
return iRet;
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
Void SubWindowHandle::stopEvent()
|
||||
{
|
||||
m_currStream.seekInput( 0 );
|
||||
m_currStream.readFrame();
|
||||
m_cViewArea->setImage( QPixmap::fromImage( m_currStream.getFrameQImage() ) );
|
||||
m_pCurrStream->seekInput( 0 );
|
||||
m_pCurrStream->readFrame();
|
||||
m_pCurrStream->getFrame( m_pCurrFrameQImage );
|
||||
m_cViewArea->setImage( QPixmap::fromImage( *m_pCurrFrameQImage ) );
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -173,7 +181,7 @@ Void SubWindowHandle::zoomToFit()
|
||||
{
|
||||
// Scale to a smaller size that the real to a nicer look
|
||||
QSize niceFit( m_cScrollArea->viewport()->size().width() - 10, m_cScrollArea->viewport()->size().height() - 10 );
|
||||
if( m_currStream.getWidth() <= niceFit.width() && m_currStream.getHeight() <= niceFit.height() )
|
||||
if( m_pCurrStream->getWidth() <= niceFit.width() && m_pCurrStream->getHeight() <= niceFit.height() )
|
||||
{
|
||||
normalSize();
|
||||
return;
|
||||
@@ -196,7 +204,7 @@ Void SubWindowHandle::scaleView( Int width, Int height )
|
||||
|
||||
Void SubWindowHandle::scaleView( const QSize & size )
|
||||
{
|
||||
QSize imgViewSize( m_currStream.getWidth(), m_currStream.getHeight() );
|
||||
QSize imgViewSize( m_pCurrStream->getWidth(), m_pCurrStream->getHeight() );
|
||||
QSize newSize = imgViewSize;
|
||||
newSize.scale( size, Qt::KeepAspectRatio );
|
||||
|
||||
@@ -233,7 +241,7 @@ QSize SubWindowHandle::sizeHint() const
|
||||
maxSize = p->size();
|
||||
}
|
||||
|
||||
QSize isize = QSize( m_currStream.getWidth() + 500, m_currStream.getHeight() + 500 );
|
||||
QSize isize = QSize( m_pCurrStream->getWidth() + 500, m_pCurrStream->getHeight() + 500 );
|
||||
|
||||
// If the SubWindowHandle needs more space that the avaiable, we'll give
|
||||
// to the subwindow a reasonable size preserving the image aspect ratio.
|
||||
|
||||
@@ -50,7 +50,8 @@ private:
|
||||
QScrollArea* m_cScrollArea;
|
||||
ViewArea* m_cViewArea;
|
||||
|
||||
InputStream m_currStream;
|
||||
InputStream* m_pCurrStream;
|
||||
QImage* m_pCurrFrameQImage;
|
||||
|
||||
QString m_cWindowName;
|
||||
QString m_cCurrFileName;
|
||||
@@ -70,7 +71,7 @@ public:
|
||||
|
||||
InputStream* getInputStream()
|
||||
{
|
||||
return &m_currStream;
|
||||
return m_pCurrStream;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,7 +128,7 @@ protected:
|
||||
Void closeEvent( QCloseEvent *event );
|
||||
|
||||
public Q_SLOTS:
|
||||
int playEvent();
|
||||
bool playEvent();
|
||||
};
|
||||
|
||||
} // NAMESPACE
|
||||
|
||||
@@ -139,24 +139,23 @@ void plaYUVerApp::play()
|
||||
UInt frameRate = activeSubWindow()->getInputStream()->getFrameRate();
|
||||
UInt timeInterval = ( UInt )( 1000.0 / frameRate + 0.5 );
|
||||
playingTimer->start( timeInterval );
|
||||
//connect( playingTimer, SIGNAL( timeout() ), activeSubWindow(), SLOT( playEvent() ) );
|
||||
connect( playingTimer, SIGNAL( timeout() ), this, SLOT( playEvent() ) );
|
||||
connect( playingTimer, SIGNAL( timeout() ), activeSubWindow(), SLOT( playEvent() ) );
|
||||
//connect( playingTimer, SIGNAL( timeout() ), this, SLOT( playEvent() ) );
|
||||
}
|
||||
}
|
||||
|
||||
void plaYUVerApp::pause()
|
||||
{
|
||||
playingTimer->stop();
|
||||
disconnect( activeSubWindow(), SLOT( playEvent() ) );
|
||||
}
|
||||
|
||||
void plaYUVerApp::stop()
|
||||
{
|
||||
if( activeSubWindow() )
|
||||
{
|
||||
activeSubWindow()->stopEvent();
|
||||
}
|
||||
activeSubWindow()->stopEvent();
|
||||
disconnect( activeSubWindow(), SLOT( playEvent() ) );
|
||||
playingTimer->stop();
|
||||
//disconnect( playingTimer, SIGNAL( timeout() ), 0, 0 );
|
||||
|
||||
}
|
||||
|
||||
void plaYUVerApp::playEvent()
|
||||
|
||||
Reference in new issue
Block a user