[vlmc-devel] Add ThumbnailWorker
Yikai Lu
git at videolan.org
Tue Aug 16 03:37:01 CEST 2016
vlmc | branch: master | Yikai Lu <luyikei.qmltu at gmail.com> | Mon Aug 15 20:20:45 2016 -0500| [367fecdff799a0092112b94c17a484980b07eb1b] | committer: Yikai Lu
Add ThumbnailWorker
> https://code.videolan.org/videolan/vlmc/commit/367fecdff799a0092112b94c17a484980b07eb1b
---
Makefile.am | 2 ++
src/Workflow/ThumbnailWorker.cpp | 26 ++++++++++++++++++++++++++
src/Workflow/ThumbnailWorker.h | 21 +++++++++++++++++++++
3 files changed, 49 insertions(+)
diff --git a/Makefile.am b/Makefile.am
index a8660f6..b3ec9e1 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -37,6 +37,7 @@ vlmc_SOURCES = \
src/Workflow/Helper.cpp \
src/Workflow/MainWorkflow.cpp \
src/Workflow/SequenceWorkflow.cpp \
+ src/Workflow/ThumbnailWorker.cpp \
$(NULL)
vlmc_SOURCES += \
@@ -100,6 +101,7 @@ vlmc_SOURCES += \
nodist_vlmc_SOURCES = \
src/Media/Clip.moc.cpp \
src/Workflow/SequenceWorkflow.moc.cpp \
+ src/Workflow/ThumbnailWorker.moc.cpp \
src/Services/YouTube/YouTubeService.moc.cpp \
src/EffectsEngine/EffectHelper.moc.cpp \
src/Workflow/Helper.moc.cpp \
diff --git a/src/Workflow/ThumbnailWorker.cpp b/src/Workflow/ThumbnailWorker.cpp
new file mode 100644
index 0000000..e454957
--- /dev/null
+++ b/src/Workflow/ThumbnailWorker.cpp
@@ -0,0 +1,26 @@
+#include "ThumbnailWorker.h"
+
+#include <QPixmap>
+#include <QUuid>
+
+#include "Backend/MLT/MLTInput.h"
+
+ThumbnailWorker::ThumbnailWorker( QObject* parent )
+ : QObject( parent )
+{
+
+}
+
+void
+ThumbnailWorker::run( const QString& uuid, const QString& filePath, qint64 pos, quint32 width, quint32 height )
+{
+ Backend::MLT::MLTInput input( qPrintable( filePath ) );
+ input.setPosition( pos );
+ auto image = input.image( width, height );
+ QImage qImg( image, width, height,
+ QImage::Format_RGBA8888, []( void* buf ){ delete[] (uchar*) buf; } );
+ auto qPix = QPixmap::fromImage( qImg );
+
+ // Use Qt::DirectConnection or the pixmap will be deleted!
+ emit imageReady( uuid, pos, qPix );
+}
diff --git a/src/Workflow/ThumbnailWorker.h b/src/Workflow/ThumbnailWorker.h
new file mode 100644
index 0000000..e055734
--- /dev/null
+++ b/src/Workflow/ThumbnailWorker.h
@@ -0,0 +1,21 @@
+#ifndef THUMBNAILWORKER_H
+#define THUMBNAILWORKER_H
+
+#include <QObject>
+
+class QPixmap;
+
+class ThumbnailWorker : public QObject
+{
+ Q_OBJECT
+public:
+ explicit ThumbnailWorker( QObject* parent = 0 );
+
+signals:
+ void imageReady( const QString& uuid, qint64 pos, const QPixmap& pixmap );
+
+public slots:
+ void run( const QString& uuid, const QString& filePath, qint64 pos, quint32 width, quint32 height );
+};
+
+#endif // THUMBNAILWORKER_H
More information about the Vlmc-devel
mailing list