OpenShot Library | libopenshot  0.5.0
Mask.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_MASK_EFFECT_H
14 #define OPENSHOT_MASK_EFFECT_H
15 
16 #include "../EffectBase.h"
17 
18 #include "../Json.h"
19 #include "../KeyFrame.h"
20 
21 #include <string>
22 #include <memory>
23 
24 namespace openshot
25 {
26  // Forward declaration
27  class ReaderBase;
28 
36  class Mask : public EffectBase
37  {
38  private:
40  void init_effect_details();
41 
42  protected:
43  bool HandlesMaskInternally() const override { return true; }
44 
45  public:
49 
51  Mask();
52 
60  Mask(ReaderBase *mask_reader, Keyframe mask_brightness, Keyframe mask_contrast);
61 
68  std::shared_ptr<openshot::Frame> GetFrame(int64_t frame_number) override { return GetFrame(std::make_shared<openshot::Frame>(), frame_number); }
69 
79  std::shared_ptr<openshot::Frame> GetFrame(std::shared_ptr<openshot::Frame> frame, int64_t frame_number) override;
80 
81  // Get and Set JSON methods
82  std::string Json() const override;
83  void SetJson(const std::string value) override;
84  Json::Value JsonValue() const override;
85  void SetJsonValue(const Json::Value root) override;
86 
89  std::string PropertiesJSON(int64_t requested_frame) const override;
90 
92  ReaderBase* Reader() { return MaskReader(); };
93 
95  void Reader(ReaderBase *new_reader);
96  };
97 
98 }
99 
100 #endif
openshot::Mask::JsonValue
Json::Value JsonValue() const override
Generate Json::Value for this object.
Definition: Mask.cpp:175
openshot::EffectBase
This abstract class is the base class, used by all effects in libopenshot.
Definition: EffectBase.h:56
openshot::Mask
This class uses the image libraries to apply alpha (or transparency) masks to any frame....
Definition: Mask.h:36
openshot
This namespace is the default namespace for all code in the openshot library.
Definition: Compressor.h:28
openshot::Mask::GetFrame
std::shared_ptr< openshot::Frame > GetFrame(int64_t frame_number) override
This method is required for all derived classes of ClipBase, and returns a new openshot::Frame object...
Definition: Mask.h:68
openshot::Mask::contrast
Keyframe contrast
Contrast keyframe to control the hardness of the wipe effect / mask.
Definition: Mask.h:48
openshot::Mask::Mask
Mask()
Blank constructor, useful when using Json to load the effect properties.
Definition: Mask.cpp:24
openshot::Mask::PropertiesJSON
std::string PropertiesJSON(int64_t requested_frame) const override
Definition: Mask.cpp:226
openshot::Keyframe
A Keyframe is a collection of Point instances, which is used to vary a number or property over time.
Definition: KeyFrame.h:53
openshot::EffectBase::MaskReader
ReaderBase * MaskReader()
Get the common mask reader.
Definition: EffectBase.h:175
openshot::Mask::replace_image
bool replace_image
Replace the frame image with a grayscale image representing the mask. Great for debugging a mask.
Definition: Mask.h:46
openshot::Mask::Json
std::string Json() const override
Generate JSON string of this object.
Definition: Mask.cpp:168
openshot::ReaderBase
This abstract class is the base class, used by all readers in libopenshot.
Definition: ReaderBase.h:75
openshot::Mask::HandlesMaskInternally
bool HandlesMaskInternally() const override
Optional override for effects that apply mask processing inside GetFrame().
Definition: Mask.h:43
openshot::Mask::Reader
ReaderBase * Reader()
Get the reader object of the mask grayscale image.
Definition: Mask.h:92
openshot::Mask::SetJson
void SetJson(const std::string value) override
Load JSON string into this object.
Definition: Mask.cpp:189
openshot::Mask::brightness
Keyframe brightness
Brightness keyframe to control the wipe / mask effect. A constant value here will prevent animation.
Definition: Mask.h:47
openshot::Mask::SetJsonValue
void SetJsonValue(const Json::Value root) override
Load Json::Value into this object.
Definition: Mask.cpp:206