OpenShot Library | libopenshot
1.1.1
Toggle main menu visibility
Loading...
Searching...
No Matches
Negate.cpp
Go to the documentation of this file.
1
8
9
// Copyright (c) 2008-2019 OpenShot Studios, LLC
10
//
11
// SPDX-License-Identifier: LGPL-3.0-or-later
12
13
#include "
Negate.h
"
14
#include "
Exceptions.h
"
15
16
using namespace
openshot
;
17
18
// Default constructor
19
Negate::Negate
()
20
{
22
InitEffectInfo
();
23
25
info
.class_name =
"Negate"
;
26
info
.name =
"Negative"
;
27
info
.description =
"Negates the colors, producing a negative of the image."
;
28
info
.has_audio =
false
;
29
info
.has_video =
true
;
30
}
31
32
// This method is required for all derived classes of EffectBase, and returns a
33
// modified openshot::Frame object
34
std::shared_ptr<openshot::Frame>
Negate::GetFrame
(std::shared_ptr<openshot::Frame> frame, int64_t frame_number)
35
{
36
// Make a negative of the images pixels
37
frame->GetImage()->invertPixels();
38
39
// return the modified frame
40
return
frame;
41
}
42
43
// Generate JSON string of this object
44
std::string
Negate::Json
()
const
{
45
46
// Return formatted string
47
return
JsonValue
().toStyledString();
48
}
49
50
// Generate Json::Value for this object
51
Json::Value
Negate::JsonValue
()
const
{
52
53
// Create root json object
54
Json::Value root =
EffectBase::JsonValue
();
// get parent properties
55
root[
"type"
] =
info
.class_name;
56
57
// return JsonValue
58
return
root;
59
}
60
61
// Load JSON string into this object
62
void
Negate::SetJson
(
const
std::string value) {
63
64
// Parse JSON string into JSON objects
65
try
66
{
67
const
Json::Value root =
openshot::stringToJson
(value);
68
// Set all values that match
69
SetJsonValue
(root);
70
}
71
catch
(
const
std::exception& e)
72
{
73
// Error parsing JSON (or missing keys)
74
throw
InvalidJSON
(
"JSON is invalid (missing keys or invalid data types)"
);
75
}
76
}
77
78
// Load Json::Value into this object
79
void
Negate::SetJsonValue
(
const
Json::Value root) {
80
81
// Set parent data
82
EffectBase::SetJsonValue
(root);
83
84
}
85
86
// Get all properties for a specific frame
87
std::string
Negate::PropertiesJSON
(int64_t requested_frame)
const
{
88
89
// Generate JSON properties list
90
Json::Value root =
BasePropertiesJSON
(requested_frame);
91
92
// Return formatted string
93
return
root.toStyledString();
94
}
Exceptions.h
Header file for all Exception classes.
Negate.h
Header file for Negate class.
openshot::EffectBase::JsonValue
virtual Json::Value JsonValue() const
Generate Json::Value for this object.
Definition
EffectBase.cpp:106
openshot::EffectBase::InitEffectInfo
void InitEffectInfo()
Definition
EffectBase.cpp:46
openshot::EffectBase::BasePropertiesJSON
Json::Value BasePropertiesJSON(int64_t requested_frame) const
Generate JSON object of base properties (recommended to be used by all effects).
Definition
EffectBase.cpp:261
openshot::EffectBase::SetJsonValue
virtual void SetJsonValue(const Json::Value root)
Load Json::Value into this object.
Definition
EffectBase.cpp:150
openshot::EffectBase::info
EffectInfoStruct info
Information about the current effect.
Definition
EffectBase.h:114
openshot::InvalidJSON
Exception for invalid JSON.
Definition
Exceptions.h:224
openshot::Negate::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
Negate.h:47
openshot::Negate::SetJson
void SetJson(const std::string value) override
Load JSON string into this object.
Definition
Negate.cpp:62
openshot::Negate::JsonValue
Json::Value JsonValue() const override
Generate Json::Value for this object.
Definition
Negate.cpp:51
openshot::Negate::Negate
Negate()
Default constructor.
Definition
Negate.cpp:19
openshot::Negate::SetJsonValue
void SetJsonValue(const Json::Value root) override
Load Json::Value into this object.
Definition
Negate.cpp:79
openshot::Negate::Json
std::string Json() const override
Generate JSON string of this object.
Definition
Negate.cpp:44
openshot::Negate::PropertiesJSON
std::string PropertiesJSON(int64_t requested_frame) const override
Definition
Negate.cpp:87
openshot
This namespace is the default namespace for all code in the openshot library.
Definition
AnimatedCurve.h:24
openshot::stringToJson
const Json::Value stringToJson(const std::string value)
Definition
Json.cpp:16
effects
Negate.cpp
Generated by
1.17.0