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