OpenShot Library | libopenshot  0.3.3
QtImageReader.h
Go to the documentation of this file.
1 
9 // Copyright (c) 2008-2019 OpenShot Studios, LLC
10 //
11 // SPDX-License-Identifier: LGPL-3.0-or-later
12 
13 #ifndef OPENSHOT_QIMAGE_READER_H
14 #define OPENSHOT_QIMAGE_READER_H
15 
16 #include <memory>
17 #include <string>
18 
19 #include <QString>
20 #include <QSize>
21 
22 #include "ReaderBase.h"
23 #include "Json.h"
24 
25 #if USE_RESVG == 1
26  // If defined and found in CMake, utilize the libresvg for parsing
27  // SVG files and rasterizing them to QImages.
28  #include "ResvgQt.h"
29 
30  #define RESVG_VERSION_MIN(a, b) (\
31  RESVG_MAJOR_VERSION > a \
32  || (RESVG_MAJOR_VERSION == a && RESVG_MINOR_VERSION >= b) \
33  )
34 #else
35  #define RESVG_VERSION_MIN(a, b) 0
36 #endif
37 
38 class QImage;
39 
40 #include <QImage>
41 #include <QSize>
42 #include <QString>
43 
44 #include <QSize>
45 #include <QString>
46 
47 class QImage;
48 
49 namespace openshot
50 {
51  // Forward decl
52  class CacheBase;
53  class Frame;
54 
74  class QtImageReader : public ReaderBase
75  {
76  private:
77  QString path;
78  std::shared_ptr<QImage> image;
79  std::shared_ptr<QImage> cached_image;
80  bool is_open;
81  QSize max_size;
82 
83 #if RESVG_VERSION_MIN(0, 11)
84  ResvgOptions resvg_options;
85 #endif
86 
91  QSize load_svg_path(QString path);
92 
94  QSize calculate_max_size();
95 
96  public:
105  QtImageReader(std::string path, bool inspect_reader=true);
106 
107  virtual ~QtImageReader();
108 
110  void Close() override;
111 
113  CacheBase* GetCache() override { return NULL; };
114 
120  std::shared_ptr<Frame> GetFrame(int64_t requested_frame) override;
121 
123  bool IsOpen() override { return is_open; };
124 
126  std::string Name() override { return "QtImageReader"; };
127 
128  // Get and Set JSON methods
129  std::string Json() const override;
130  void SetJson(const std::string value) override;
131  Json::Value JsonValue() const override;
132  void SetJsonValue(const Json::Value root) override;
133 
135  void Open() override;
136  };
137 
138 }
139 
140 #endif
openshot::QtImageReader::SetJsonValue
void SetJsonValue(const Json::Value root) override
Load Json::Value into this object.
Definition: QtImageReader.cpp:356
openshot
This namespace is the default namespace for all code in the openshot library.
Definition: Compressor.h:28
openshot::QtImageReader::GetCache
CacheBase * GetCache() override
Get the cache object used by this reader (always returns NULL for this object)
Definition: QtImageReader.h:113
openshot::QtImageReader::JsonValue
Json::Value JsonValue() const override
Generate Json::Value for this object.
Definition: QtImageReader.cpp:327
openshot::CacheBase
All cache managers in libopenshot are based on this CacheBase class.
Definition: CacheBase.h:34
openshot::QtImageReader::SetJson
void SetJson(const std::string value) override
Load JSON string into this object.
Definition: QtImageReader.cpp:339
openshot::QtImageReader
This class uses the Qt library, to open image files, and return openshot::Frame objects containing th...
Definition: QtImageReader.h:74
openshot::QtImageReader::Json
std::string Json() const override
Generate JSON string of this object.
Definition: QtImageReader.cpp:320
openshot::QtImageReader::Close
void Close() override
Close File.
Definition: QtImageReader.cpp:130
path
path
Definition: FFmpegWriter.cpp:1479
ReaderBase.h
Header file for ReaderBase class.
openshot::QtImageReader::Name
std::string Name() override
Return the type name of the class.
Definition: QtImageReader.h:126
openshot::QtImageReader::IsOpen
bool IsOpen() override
Determine if reader is open or closed.
Definition: QtImageReader.h:123
openshot::QtImageReader::GetFrame
std::shared_ptr< Frame > GetFrame(int64_t requested_frame) override
Definition: QtImageReader.cpp:148
openshot::ReaderBase
This abstract class is the base class, used by all readers in libopenshot.
Definition: ReaderBase.h:75
openshot::QtImageReader::QtImageReader
QtImageReader(std::string path, bool inspect_reader=true)
Constructor for QtImageReader.
Definition: QtImageReader.cpp:28
Json.h
Header file for JSON class.
openshot::QtImageReader::Open
void Open() override
Open File - which is called by the constructor automatically.
Definition: QtImageReader.cpp:43
openshot::QtImageReader::~QtImageReader
virtual ~QtImageReader()
Definition: QtImageReader.cpp:37