OpenShot Library | libopenshot 0.2.7
Pixelate.h
Go to the documentation of this file.
1/**
2 * @file
3 * @brief Header file for Pixelate effect class
4 * @author Jonathan Thomas <jonathan@openshot.org>
5 *
6 * @ref License
7 */
8
9/* LICENSE
10 *
11 * Copyright (c) 2008-2019 OpenShot Studios, LLC
12 * <http://www.openshotstudios.com/>. This file is part of
13 * OpenShot Library (libopenshot), an open-source project dedicated to
14 * delivering high quality video editing and animation solutions to the
15 * world. For more information visit <http://www.openshot.org/>.
16 *
17 * OpenShot Library (libopenshot) is free software: you can redistribute it
18 * and/or modify it under the terms of the GNU Lesser General Public License
19 * as published by the Free Software Foundation, either version 3 of the
20 * License, or (at your option) any later version.
21 *
22 * OpenShot Library (libopenshot) is distributed in the hope that it will be
23 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU Lesser General Public License for more details.
26 *
27 * You should have received a copy of the GNU Lesser General Public License
28 * along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
29 */
30
31#ifndef OPENSHOT_PIXELATE_EFFECT_H
32#define OPENSHOT_PIXELATE_EFFECT_H
33
34#include "../EffectBase.h"
35
36#include "../Frame.h"
37#include "../Json.h"
38#include "../KeyFrame.h"
39
40#include <memory>
41#include <string>
42
43namespace openshot
44{
45
46 /**
47 * @brief This class pixelates an image, and can be animated with openshot::Keyframe curves over time.
48 *
49 * Pixelating the image is the process of increasing the size of visible pixels, thus loosing visual
50 * clarity of the image. The area to pixelate can be set and animated with keyframes also.
51 */
52 class Pixelate : public EffectBase
53 {
54 private:
55 /// Init effect settings
56 void init_effect_details();
57
58
59 public:
60 Keyframe pixelization; ///< Amount of pixelization
61 Keyframe left; ///< Size of left margin
62 Keyframe top; ///< Size of top margin
63 Keyframe right; ///< Size of right margin
64 Keyframe bottom; ///< Size of bottom margin
65
66 /// Default constructor, useful when using Json to load the effect properties
67 Pixelate();
68
69 /// Cnstructor which takes 5 curves. These curves animate the pixelization effect over time.
70 ///
71 /// @param pixelization The curve to adjust the amount of pixelization (0 to 1)
72 /// @param left The curve to adjust the left margin size (between 0 and 1)
73 /// @param top The curve to adjust the top margin size (between 0 and 1)
74 /// @param right The curve to adjust the right margin size (between 0 and 1)
75 /// @param bottom The curve to adjust the bottom margin size (between 0 and 1)
77
78 /// @brief This method is required for all derived classes of ClipBase, and returns a
79 /// new openshot::Frame object. All Clip keyframes and effects are resolved into
80 /// pixels.
81 ///
82 /// @returns A new openshot::Frame object
83 /// @param frame_number The frame number (starting at 1) of the clip or effect on the timeline.
84 std::shared_ptr<openshot::Frame> GetFrame(int64_t frame_number) override { return GetFrame(std::make_shared<openshot::Frame>(), frame_number); }
85
86 /// @brief This method is required for all derived classes of ClipBase, and returns a
87 /// modified openshot::Frame object
88 ///
89 /// The frame object is passed into this method and used as a starting point (pixels and audio).
90 /// All Clip keyframes and effects are resolved into pixels.
91 ///
92 /// @returns The modified openshot::Frame object
93 /// @param frame The frame object that needs the clip or effect applied to it
94 /// @param frame_number The frame number (starting at 1) of the clip or effect on the timeline.
95 std::shared_ptr<openshot::Frame> GetFrame(std::shared_ptr<openshot::Frame> frame, int64_t frame_number) override;
96
97 // Get and Set JSON methods
98 std::string Json() const override; ///< Generate JSON string of this object
99 void SetJson(const std::string value) override; ///< Load JSON string into this object
100 Json::Value JsonValue() const override; ///< Generate Json::Value for this object
101 void SetJsonValue(const Json::Value root) override; ///< Load Json::Value into this object
102
103 /// Get all properties for a specific frame (perfect for a UI to display the current state
104 /// of all properties at any time)
105 std::string PropertiesJSON(int64_t requested_frame) const override;
106 };
107
108}
109
110#endif
This abstract class is the base class, used by all effects in libopenshot.
Definition: EffectBase.h:71
A Keyframe is a collection of Point instances, which is used to vary a number or property over time.
Definition: KeyFrame.h:72
This class pixelates an image, and can be animated with openshot::Keyframe curves over time.
Definition: Pixelate.h:53
Pixelate()
Default constructor, useful when using Json to load the effect properties.
Definition: Pixelate.cpp:43
Keyframe right
Size of right margin.
Definition: Pixelate.h:63
std::string Json() const override
Generate JSON string of this object.
Definition: Pixelate.cpp:110
std::string PropertiesJSON(int64_t requested_frame) const override
Definition: Pixelate.cpp:169
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: Pixelate.h:84
Keyframe pixelization
Amount of pixelization.
Definition: Pixelate.h:60
Keyframe left
Size of left margin.
Definition: Pixelate.h:61
Json::Value JsonValue() const override
Generate Json::Value for this object.
Definition: Pixelate.cpp:117
void SetJson(const std::string value) override
Load JSON string into this object.
Definition: Pixelate.cpp:133
void SetJsonValue(const Json::Value root) override
Load Json::Value into this object.
Definition: Pixelate.cpp:150
Keyframe top
Size of top margin.
Definition: Pixelate.h:62
Keyframe bottom
Size of bottom margin.
Definition: Pixelate.h:64
This namespace is the default namespace for all code in the openshot library.
Definition: Compressor.h:47