OpenShot Library | libopenshot  0.5.0
Blur.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_BLUR_EFFECT_H
14 #define OPENSHOT_BLUR_EFFECT_H
15 
16 #include "../EffectBase.h"
17 
18 #include "../Frame.h"
19 #include "../Json.h"
20 #include "../KeyFrame.h"
21 
22 #include <memory>
23 #include <string>
24 
25 namespace openshot
26 {
27  enum BlurMaskMode {
30  };
31 
40  class Blur : public EffectBase
41  {
42  private:
44  void init_effect_details();
45 
46  // Internal blur methods (inspired and credited to http://blog.ivank.net/fastest-gaussian-blur.html)
47  void boxBlurH(unsigned char *scl, unsigned char *tcl, int w, int h, int r);
48  void boxBlurT(unsigned char *scl, unsigned char *tcl, int w, int h, int r);
49 
50  protected:
51  bool UseCustomMaskBlend(int64_t frame_number) const override;
52  void ApplyCustomMaskBlend(std::shared_ptr<QImage> original_image, std::shared_ptr<QImage> effected_image,
53  std::shared_ptr<QImage> mask_image, int64_t frame_number) const override;
54 
55  public:
60  int mask_mode;
61 
63  Blur();
64 
72  Blur(Keyframe new_horizontal_radius, Keyframe new_vertical_radius, Keyframe new_sigma, Keyframe new_iterations);
73 
80  std::shared_ptr<openshot::Frame> GetFrame(int64_t frame_number) override { return GetFrame(std::make_shared<openshot::Frame>(), frame_number); }
81 
91  std::shared_ptr<openshot::Frame> GetFrame(std::shared_ptr<openshot::Frame> frame, int64_t frame_number) override;
92 
93  // Get and Set JSON methods
94  std::string Json() const override;
95  void SetJson(const std::string value) override;
96  Json::Value JsonValue() const override;
97  void SetJsonValue(const Json::Value root) override;
98 
101  std::string PropertiesJSON(int64_t requested_frame) const override;
102  };
103 
104 }
105 
106 #endif
openshot::Blur::UseCustomMaskBlend
bool UseCustomMaskBlend(int64_t frame_number) const override
Optional override for effects that need custom mask behavior.
Definition: Blur.cpp:95
openshot::EffectBase
This abstract class is the base class, used by all effects in libopenshot.
Definition: EffectBase.h:56
openshot::Blur::PropertiesJSON
std::string PropertiesJSON(int64_t requested_frame) const override
Definition: Blur.cpp:255
openshot::Blur::iterations
Keyframe iterations
Iterations keyframe. The # of blur iterations per pixel. 3 iterations = Gaussian.
Definition: Blur.h:59
openshot::Blur::ApplyCustomMaskBlend
void ApplyCustomMaskBlend(std::shared_ptr< QImage > original_image, std::shared_ptr< QImage > effected_image, std::shared_ptr< QImage > mask_image, int64_t frame_number) const override
Optional override for effects with custom mask implementation.
Definition: Blur.cpp:100
openshot
This namespace is the default namespace for all code in the openshot library.
Definition: Compressor.h:28
openshot::Blur::Json
std::string Json() const override
Generate JSON string of this object.
Definition: Blur.cpp:196
openshot::Blur
This class adjusts the blur of an image, and can be animated with openshot::Keyframe curves over time...
Definition: Blur.h:40
openshot::Blur::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: Blur.h:80
openshot::Blur::mask_mode
int mask_mode
How to apply common masks to blur (post-blend or drive-amount).
Definition: Blur.h:60
openshot::Blur::SetJsonValue
void SetJsonValue(const Json::Value root) override
Load Json::Value into this object.
Definition: Blur.cpp:236
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::BlurMaskMode
BlurMaskMode
Definition: Blur.h:27
openshot::BLUR_MASK_DRIVE_AMOUNT
@ BLUR_MASK_DRIVE_AMOUNT
Definition: Blur.h:29
openshot::Blur::vertical_radius
Keyframe vertical_radius
Vertical blur radius keyframe. The size of the vertical blur operation in pixels.
Definition: Blur.h:57
openshot::BLUR_MASK_POST_BLEND
@ BLUR_MASK_POST_BLEND
Definition: Blur.h:28
openshot::Blur::Blur
Blur()
Blank constructor, useful when using Json to load the effect properties.
Definition: Blur.cpp:19
openshot::Blur::horizontal_radius
Keyframe horizontal_radius
Horizontal blur radius keyframe. The size of the horizontal blur operation in pixels.
Definition: Blur.h:56
openshot::Blur::JsonValue
Json::Value JsonValue() const override
Generate Json::Value for this object.
Definition: Blur.cpp:203
openshot::Blur::sigma
Keyframe sigma
Sigma keyframe. The amount of spread in the blur operation. Should be larger than radius.
Definition: Blur.h:58
openshot::Blur::SetJson
void SetJson(const std::string value) override
Load JSON string into this object.
Definition: Blur.cpp:219