Skip same frames
This commit is contained in:
parent
3f439c1ef2
commit
0bf8fa23d9
@ -25,6 +25,7 @@
|
||||
#include <QIcon>
|
||||
#include <QImageWriter>
|
||||
#include <QInputDialog>
|
||||
#include <QMessageBox>
|
||||
#include <QSplitter>
|
||||
#include <fstream>
|
||||
#include "designwidget.h"
|
||||
@ -400,11 +401,14 @@ void BaseMainWindow::saveMovie()
|
||||
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
|
||||
if (!dir.isEmpty()) {
|
||||
bool ok;
|
||||
int frames = QInputDialog::getInt(this, "Skip frames", tr("Frames to skip (1 frame = 50ms):"), 5, 0, 1000,
|
||||
1, &ok);
|
||||
if (ok)
|
||||
fpgaView->movieStart(dir, frames);
|
||||
else
|
||||
int frames =
|
||||
QInputDialog::getInt(this, "Recording", tr("Frames to skip (1 frame = 50ms):"), 5, 0, 1000, 1, &ok);
|
||||
if (ok) {
|
||||
QMessageBox::StandardButton reply =
|
||||
QMessageBox::question(this, "Recording", "Skip identical frames ?",
|
||||
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
|
||||
fpgaView->movieStart(dir, frames, (reply == QMessageBox::Yes));
|
||||
} else
|
||||
actionMovie->setChecked(false);
|
||||
} else
|
||||
actionMovie->setChecked(false);
|
||||
|
@ -329,14 +329,17 @@ void FPGAViewWidget::paintGL()
|
||||
if (movieCounter == currentFrameSkip) {
|
||||
QMutexLocker lock(&rendererArgsLock_);
|
||||
movieCounter = 0;
|
||||
currentMovieFrame++;
|
||||
|
||||
QImage image = grabFramebuffer();
|
||||
QString number = QString("movie_%1.png").arg(currentMovieFrame, 5, 10, QChar('0'));
|
||||
if (!movieSkipSame || movieLastImage != image) {
|
||||
currentMovieFrame++;
|
||||
|
||||
QFileInfo fileName = QFileInfo(QDir(movieDir), number);
|
||||
QImageWriter imageWriter(fileName.absoluteFilePath(), "png");
|
||||
imageWriter.write(image);
|
||||
QString number = QString("movie_%1.png").arg(currentMovieFrame, 5, 10, QChar('0'));
|
||||
|
||||
QFileInfo fileName = QFileInfo(QDir(movieDir), number);
|
||||
QImageWriter imageWriter(fileName.absoluteFilePath(), "png");
|
||||
imageWriter.write(image);
|
||||
movieLastImage = image;
|
||||
}
|
||||
} else {
|
||||
movieCounter++;
|
||||
}
|
||||
@ -599,9 +602,11 @@ void FPGAViewWidget::renderLines(void)
|
||||
}
|
||||
}
|
||||
|
||||
void FPGAViewWidget::movieStart(QString dir, long frameSkip)
|
||||
void FPGAViewWidget::movieStart(QString dir, long frameSkip, bool skipSame)
|
||||
{
|
||||
QMutexLocker locker(&rendererArgsLock_);
|
||||
movieLastImage = QImage();
|
||||
movieSkipSame = skipSame;
|
||||
movieDir = dir;
|
||||
currentMovieFrame = 0;
|
||||
movieCounter = 0;
|
||||
|
@ -120,7 +120,7 @@ class FPGAViewWidget : public QOpenGLWidget, protected QOpenGLFunctions
|
||||
void zoomSelected();
|
||||
void zoomOutbound();
|
||||
void enableDisableDecals(bool bels, bool wires, bool pips, bool groups);
|
||||
void movieStart(QString dir, long frameSkip);
|
||||
void movieStart(QString dir, long frameSkip, bool skipSame);
|
||||
void movieStop();
|
||||
Q_SIGNALS:
|
||||
void clickedBel(BelId bel, bool add);
|
||||
@ -133,6 +133,8 @@ class FPGAViewWidget : public QOpenGLWidget, protected QOpenGLFunctions
|
||||
long currentFrameSkip;
|
||||
long movieCounter;
|
||||
bool movieSaving;
|
||||
bool movieSkipSame;
|
||||
QImage movieLastImage;
|
||||
const float zoomNear_ = 0.05f; // do not zoom closer than this
|
||||
float zoomFar_ = 10.0f; // do not zoom further than this
|
||||
const float zoomLvl1_ = 1.0f;
|
||||
|
Loading…
Reference in New Issue
Block a user