Change subwindow save function and add a static function to PlaYUVerStream to save any imagem as long as supported. Support for current frame save is also present
This commit is contained in:
1 parent
f14c5c09b7
commit
06148e579b
3 files changed
+24
-35
No files matched your search
@@ -236,36 +236,17 @@ Bool SubWindowHandle::save( QString filename )
|
||||
{
|
||||
Bool iRet = false;
|
||||
QApplication::setOverrideCursor( Qt::WaitCursor );
|
||||
if( !m_pCurrStream || m_cSelectedArea.isValid() )
|
||||
|
||||
PlaYUVerFrame* saveFrame = m_pcCurrFrame;
|
||||
if( m_cSelectedArea.isValid() )
|
||||
{
|
||||
PlaYUVerFrame* savedFrame = m_pcCurrFrame;
|
||||
if( m_cSelectedArea.isValid() )
|
||||
{
|
||||
savedFrame = new PlaYUVerFrame( m_pcCurrFrame, m_cSelectedArea );
|
||||
}
|
||||
if( !savedFrame )
|
||||
{
|
||||
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;
|
||||
}
|
||||
savedFrame->FrametoRGB8();
|
||||
QImage qimg = QImage( savedFrame->getQImageBuffer(), savedFrame->getWidth(), savedFrame->getHeight(), QImage::Format_RGB888 );
|
||||
iRet = qimg.save( filename );
|
||||
saveFrame = new PlaYUVerFrame( m_pcCurrFrame, m_cSelectedArea );
|
||||
}
|
||||
else
|
||||
if( !saveFrame )
|
||||
{
|
||||
iRet = m_pCurrStream->saveFrame( filename );
|
||||
return false;
|
||||
}
|
||||
iRet = PlaYUVerStream::saveFrame( filename, saveFrame );
|
||||
QApplication::restoreOverrideCursor();
|
||||
return iRet;
|
||||
}
|
||||
|
||||
@@ -581,30 +581,35 @@ Void PlaYUVerStream::writeFrame( PlaYUVerFrame *pcFrame )
|
||||
|
||||
Bool PlaYUVerStream::saveFrame( const QString& filename )
|
||||
{
|
||||
Int iFileFormat = INVALID_INPUT;
|
||||
return saveFrame( filename, m_pcCurrFrame );
|
||||
}
|
||||
|
||||
QStringList formatsExt = PlaYUVerStream::supportedReadFormatsExt();
|
||||
Bool PlaYUVerStream::saveFrame( const QString& filename, PlaYUVerFrame *saveFrame )
|
||||
{
|
||||
Int iFileFormat = INVALID_OUTPUT;
|
||||
|
||||
QStringList formatsExt = PlaYUVerStream::supportedSaveFormatsExt();
|
||||
QString currExt = QFileInfo( filename ).suffix();
|
||||
if( formatsExt.contains( currExt ) )
|
||||
{
|
||||
iFileFormat = formatsExt.indexOf( currExt );
|
||||
}
|
||||
|
||||
if( iFileFormat == YUVINPUT )
|
||||
if( iFileFormat < TOTAL_OUTPUT_FORMATS )
|
||||
{
|
||||
PlaYUVerStream auxFrameStream;
|
||||
if( !auxFrameStream.open( filename, m_uiWidth, m_uiHeight, m_iPixelFormat, m_uiFrameRate, false ) )
|
||||
if( !auxFrameStream.open( filename, saveFrame->getWidth(), saveFrame->getHeight(), saveFrame->getPelFormat(), 1, false ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
auxFrameStream.writeFrame( m_pcCurrFrame );
|
||||
auxFrameStream.writeFrame( saveFrame );
|
||||
auxFrameStream.close();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pcCurrFrame->FrametoRGB8();
|
||||
QImage qimg = QImage( m_pcCurrFrame->getQImageBuffer(), m_pcCurrFrame->getWidth(), m_pcCurrFrame->getHeight(), QImage::Format_RGB888 );
|
||||
saveFrame->FrametoRGB8();
|
||||
QImage qimg = QImage( saveFrame->getQImageBuffer(), saveFrame->getWidth(), saveFrame->getHeight(), QImage::Format_RGB888 );
|
||||
return qimg.save( filename );
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -174,21 +174,23 @@ public:
|
||||
static QStringList supportedSaveFormatsExt()
|
||||
{
|
||||
QStringList formatsExt;
|
||||
formatsExt << "yuv"
|
||||
formatsExt << supportedWriteFormatsExt()
|
||||
<< "bmp"
|
||||
<< "jpeg"
|
||||
<< "png" // portable network graphics
|
||||
;
|
||||
formatsExt.removeDuplicates();
|
||||
return formatsExt;
|
||||
}
|
||||
|
||||
static QStringList supportedSaveFormatsName()
|
||||
{
|
||||
QStringList formatsName;
|
||||
formatsName << "Raw Video"
|
||||
formatsName << supportedWriteFormatsName()
|
||||
<< "Windows Bitmap"
|
||||
<< "Joint Photographic Experts Group"
|
||||
<< "Portable Network Graphics";
|
||||
formatsName.removeDuplicates();
|
||||
return formatsName;
|
||||
}
|
||||
|
||||
@@ -248,6 +250,7 @@ public:
|
||||
Void writeFrame( PlaYUVerFrame *pcFrame );
|
||||
|
||||
Bool saveFrame( const QString& filename );
|
||||
static Bool saveFrame( const QString& filename, PlaYUVerFrame *saveFrame );
|
||||
|
||||
Void setNextFrame();
|
||||
PlaYUVerFrame* getCurrFrame();
|
||||
|
||||
Reference in new issue
Block a user