From 71f1a81d6f0cbc3c355885a1e65b58feffa97bf6 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 27 Jul 2009 15:21:51 +1000 Subject: Optimize video frame grabbing. Use QWidget::render instead of QPixmap::grabWidget --- tools/qmlviewer/qmlviewer.cpp | 5 +++-- tools/qmlviewer/qmlviewer.h | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/qmlviewer/qmlviewer.cpp b/tools/qmlviewer/qmlviewer.cpp index bc1333c..f4eff46 100644 --- a/tools/qmlviewer/qmlviewer.cpp +++ b/tools/qmlviewer/qmlviewer.cpp @@ -550,6 +550,7 @@ void QmlViewer::setRecording(bool on) QProcess *proc = new QProcess(this); connect(proc, SIGNAL(finished(int)), this, SLOT(ffmpegFinished(int))); frame_stream = proc; + frame = QImage(canvas->width(),canvas->height(),QImage::Format_RGB32); QStringList args; args << "-sameq"; // ie. high @@ -658,11 +659,11 @@ void QmlViewer::ffmpegFinished(int code) void QmlViewer::timerEvent(QTimerEvent *event) { if (event->timerId() == recordTimer.timerId()) { + canvas->QWidget::render(&frame); if (frame_stream) { - QImage frame = QPixmap::grabWidget(canvas).toImage(); frame_stream->write((char*)frame.bits(),frame.numBytes()); } else { - frames.append(new QImage(QPixmap::grabWidget(canvas).toImage())); + frames.append(new QImage(frame)); } if (record_autotime && autoTimer.elapsed() >= record_autotime) setRecording(false); diff --git a/tools/qmlviewer/qmlviewer.h b/tools/qmlviewer/qmlviewer.h index 62ee908..d671410 100644 --- a/tools/qmlviewer/qmlviewer.h +++ b/tools/qmlviewer/qmlviewer.h @@ -79,6 +79,7 @@ private: QmlPalette *palette; QmlPalette *disabledPalette; QBasicTimer recordTimer; + QImage frame; QList frames; QProcess* frame_stream; QBasicTimer autoStartTimer; -- cgit v0.12