OpenShot Library | libopenshot  0.3.3
ImageReader.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_IMAGE_READER_H
14 #define OPENSHOT_IMAGE_READER_H
15 
16 // Require ImageMagick support
17 #ifdef USE_IMAGEMAGICK
18 
19 #include <memory>
20 #include <string>
21 
22 #include "ReaderBase.h"
23 #include "Json.h"
24 
25 // Forward decls
26 namespace Magick {
27  class Image;
28 }
29 namespace openshot {
30  class CacheBase;
31  class Frame;
32 }
33 
34 namespace openshot
35 {
55  class ImageReader : public ReaderBase
56  {
57  private:
58  std::string path;
59  std::shared_ptr<Magick::Image> image;
60  bool is_open;
61 
62  public:
71  ImageReader(const std::string& path, bool inspect_reader=true);
72 
74  void Close() override;
75 
77  CacheBase* GetCache() override { return NULL; };
78 
84  std::shared_ptr<Frame> GetFrame(int64_t requested_frame) override;
85 
87  bool IsOpen() override { return is_open; };
88 
90  std::string Name() override { return "ImageReader"; };
91 
92  // Get and Set JSON methods
93  std::string Json() const override;
94  void SetJson(const std::string value) override;
95  Json::Value JsonValue() const override;
96  void SetJsonValue(const Json::Value root) override;
97 
99  void Open() override;
100  };
101 
102 }
103 
104 #endif //USE_IMAGEMAGICK
105 #endif //OPENSHOT_IMAGE_READER_H
openshot::ImageReader::SetJsonValue
void SetJsonValue(const Json::Value root) override
Load Json::Value into this object.
Definition: ImageReader.cpp:150
openshot::ImageReader::Open
void Open() override
Open File - which is called by the constructor automatically.
Definition: ImageReader.cpp:35
openshot
This namespace is the default namespace for all code in the openshot library.
Definition: Compressor.h:28
openshot::ImageReader::Close
void Close() override
Close File.
Definition: ImageReader.cpp:83
openshot::ImageReader::ImageReader
ImageReader(const std::string &path, bool inspect_reader=true)
Constructor for ImageReader.
Definition: ImageReader.cpp:25
openshot::CacheBase
All cache managers in libopenshot are based on this CacheBase class.
Definition: CacheBase.h:34
openshot::ImageReader::JsonValue
Json::Value JsonValue() const override
Generate Json::Value for this object.
Definition: ImageReader.cpp:122
openshot::ImageReader::Json
std::string Json() const override
Generate JSON string of this object.
Definition: ImageReader.cpp:115
openshot::ImageReader
This class uses the ImageMagick++ libraries, to open image files, and return openshot::Frame objects ...
Definition: ImageReader.h:55
openshot::ImageReader::GetFrame
std::shared_ptr< Frame > GetFrame(int64_t requested_frame) override
Definition: ImageReader.cpp:94
openshot::ImageReader::Name
std::string Name() override
Return the type name of the class.
Definition: ImageReader.h:90
path
path
Definition: FFmpegWriter.cpp:1479
openshot::ImageReader::SetJson
void SetJson(const std::string value) override
Load JSON string into this object.
Definition: ImageReader.cpp:133
ReaderBase.h
Header file for ReaderBase class.
openshot::ImageReader::IsOpen
bool IsOpen() override
Determine if reader is open or closed.
Definition: ImageReader.h:87
Magick
Definition: ImageReader.h:26
openshot::ReaderBase
This abstract class is the base class, used by all readers in libopenshot.
Definition: ReaderBase.h:75
openshot::ImageReader::GetCache
CacheBase * GetCache() override
Get the cache object used by this reader (always returns NULL for this object)
Definition: ImageReader.h:77
Json.h
Header file for JSON class.