OpenShot Library | libopenshot  0.3.3
TextReader.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_TEXT_READER_H
14 #define OPENSHOT_TEXT_READER_H
15 
16 // Require ImageMagick support
17 #ifdef USE_IMAGEMAGICK
18 
19 #include <memory>
20 
21 #include "ReaderBase.h"
22 #include "Enums.h"
23 #include "MagickUtilities.h"
24 
25 namespace openshot
26 {
27  class CacheBase;
28  class Frame;
29 
62  class TextReader : public ReaderBase
63  {
64  private:
65  int width;
66  int height;
67  int x_offset;
68  int y_offset;
69  std::string text;
70  std::string font;
71  double size;
72  std::string text_color;
73  std::string background_color;
74  std::string text_background_color;
75  std::shared_ptr<Magick::Image> image;
76  MAGICK_DRAWABLE lines;
77  bool is_open;
78  openshot::GravityType gravity;
79 
80  public:
81 
83  TextReader();
84 
96  TextReader(int width, int height, int x_offset, int y_offset, GravityType gravity, std::string text, std::string font, double size, std::string text_color, std::string background_color);
97 
100  void SetTextBackgroundColor(std::string color);
101 
103  void Close() override;
104 
106  openshot::CacheBase* GetCache() override { return nullptr; };
107 
113  std::shared_ptr<openshot::Frame> GetFrame(int64_t requested_frame) override;
114 
116  bool IsOpen() override { return is_open; };
117 
119  std::string Name() override { return "TextReader"; };
120 
121  // Get and Set JSON methods
122  std::string Json() const override;
123  void SetJson(const std::string value) override;
124  Json::Value JsonValue() const override;
125  void SetJsonValue(const Json::Value root) override;
126 
128  void Open() override;
129  };
130 
131 }
132 
133 #endif //USE_IMAGEMAGICK
134 #endif //OPENSHOT_TEXT_READER_H
openshot
This namespace is the default namespace for all code in the openshot library.
Definition: Compressor.h:28
openshot::TextReader::Close
void Close() override
Close Reader.
Definition: TextReader.cpp:141
openshot::GravityType
GravityType
This enumeration determines how clips are aligned to their parent container.
Definition: Enums.h:21
openshot::TextReader::JsonValue
Json::Value JsonValue() const override
Generate Json::Value for this object.
Definition: TextReader.cpp:188
openshot::TextReader::GetCache
openshot::CacheBase * GetCache() override
Get the cache object used by this reader (always returns NULL for this object)
Definition: TextReader.h:106
openshot::TextReader::SetJson
void SetJson(const std::string value) override
Load JSON string into this object.
Definition: TextReader.cpp:210
openshot::CacheBase
All cache managers in libopenshot are based on this CacheBase class.
Definition: CacheBase.h:34
openshot::TextReader::GetFrame
std::shared_ptr< openshot::Frame > GetFrame(int64_t requested_frame) override
Definition: TextReader.cpp:152
openshot::TextReader::Json
std::string Json() const override
Generate JSON string of this object.
Definition: TextReader.cpp:181
openshot::TextReader::SetTextBackgroundColor
void SetTextBackgroundColor(std::string color)
Definition: TextReader.cpp:41
ReaderBase.h
Header file for ReaderBase class.
openshot::TextReader::SetJsonValue
void SetJsonValue(const Json::Value root) override
Load Json::Value into this object.
Definition: TextReader.cpp:225
openshot::TextReader::Name
std::string Name() override
Return the type name of the class.
Definition: TextReader.h:119
openshot::TextReader::Open
void Open() override
Open Reader - which is called by the constructor automatically.
Definition: TextReader.cpp:50
Enums.h
Header file for TextReader class.
MagickUtilities.h
Header file for MagickUtilities (IM6/IM7 compatibility overlay)
openshot::ReaderBase
This abstract class is the base class, used by all readers in libopenshot.
Definition: ReaderBase.h:75
MAGICK_DRAWABLE
#define MAGICK_DRAWABLE
Definition: MagickUtilities.h:53
openshot::TextReader::IsOpen
bool IsOpen() override
Determine if reader is open or closed.
Definition: TextReader.h:116
openshot::TextReader
This class uses the ImageMagick++ libraries, to create frames with "Text", and return openshot::Frame...
Definition: TextReader.h:62
openshot::TextReader::TextReader
TextReader()
Default constructor (blank text)
Definition: TextReader.cpp:26