Overte C++ Documentation
SnapshotAnimated.h
1 //
2 // SnapshotAnimated.h
3 // interface/src/ui
4 //
5 // Created by Zach Fox on 11/14/16.
6 // Copyright 2016 High Fidelity, Inc.
7 //
8 // Distributed under the Apache License, Version 2.0.
9 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
10 //
11 
12 #ifndef hifi_SnapshotAnimated_h
13 #define hifi_SnapshotAnimated_h
14 
15 #include <QtCore/QSharedPointer>
16 #include <QtCore/QVector>
17 #include <Application.h>
18 #include <DependencyManager.h>
19 #include <GifCreator.h>
20 #include <qtimer.h>
21 #include <SettingHandle.h>
22 #include "scripting/WindowScriptingInterface.h"
23 
24 // If the snapshot width or the framerate are too high for the
25 // computer to handle, the framerate of the output GIF will drop.
26 #define SNAPSNOT_ANIMATED_WIDTH (720)
27 // This value should divide evenly into 100. Snapshot framerate is NOT guaranteed.
28 #define SNAPSNOT_ANIMATED_TARGET_FRAMERATE (25)
29 #define SNAPSNOT_ANIMATED_DURATION_SECS (3)
30 #define SNAPSNOT_ANIMATED_DURATION_MSEC (SNAPSNOT_ANIMATED_DURATION_SECS*1000)
31 
32 #define SNAPSNOT_ANIMATED_FRAME_DELAY_MSEC (1000/SNAPSNOT_ANIMATED_TARGET_FRAMERATE)
33 
34 class SnapshotAnimated {
35 private:
36  static QTimer* snapshotAnimatedTimer;
37  static qint64 snapshotAnimatedTimestamp;
38  static qint64 snapshotAnimatedFirstFrameTimestamp;
39  static bool snapshotAnimatedTimerRunning;
40  static QString snapshotStillPath;
41 
42  static QString snapshotAnimatedPath;
43  static QVector<QImage> snapshotAnimatedFrameVector;
44  static QVector<qint64> snapshotAnimatedFrameDelayVector;
45  static QSharedPointer<WindowScriptingInterface> snapshotAnimatedDM;
46  static float aspectRatio;
47 
48  static GifWriter snapshotAnimatedGifWriter;
49 
50  static void captureFrames();
51  static void processFrames();
52  static void clearTempVariables();
53 public:
54  static void saveSnapshotAnimated(QString pathStill, float aspectRatio, QSharedPointer<WindowScriptingInterface> dm);
55  static bool isAlreadyTakingSnapshotAnimated() { return snapshotAnimatedFirstFrameTimestamp != 0; };
56  static Setting::Handle<bool> alsoTakeAnimatedSnapshot;
57  static Setting::Handle<float> snapshotAnimatedDuration;
58 };
59 
60 #endif // hifi_SnapshotAnimated_h