OpenShot Library | libopenshot
0.2.5
|
Go to the documentation of this file.
31 #include "../../include/effects/Hue.h"
38 init_effect_details();
45 init_effect_details();
49 void Hue::init_effect_details()
64 std::shared_ptr<Frame>
Hue::GetFrame(std::shared_ptr<Frame> frame, int64_t frame_number)
67 std::shared_ptr<QImage> frame_image = frame->
GetImage();
69 int pixel_count = frame_image->width() * frame_image->height();
72 double degrees = 360.0 *
hue.
GetValue(frame_number);
73 float cosA = cos(degrees*3.14159265f/180);
74 float sinA = sin(degrees*3.14159265f/180);
78 cosA + (1.0f - cosA) / 3.0f,
79 1.0f/3.0f * (1.0f - cosA) - sqrtf(1.0f/3.0f) * sinA,
80 1.0f/3.0f * (1.0f - cosA) + sqrtf(1.0f/3.0f) * sinA
84 unsigned char *pixels = (
unsigned char *) frame_image->bits();
86 #pragma omp parallel for shared (pixels)
87 for (
int pixel = 0; pixel < pixel_count; ++pixel)
90 int R = pixels[pixel * 4];
91 int G = pixels[pixel * 4 + 1];
92 int B = pixels[pixel * 4 + 2];
95 pixels[pixel * 4] =
constrain(R * matrix[0] + G * matrix[1] + B * matrix[2]);
96 pixels[pixel * 4 + 1] =
constrain(R * matrix[2] + G * matrix[0] + B * matrix[1]);
97 pixels[pixel * 4 + 2] =
constrain(R * matrix[1] + G * matrix[2] + B * matrix[0]);
133 catch (
const std::exception& e)
136 throw InvalidJSON(
"JSON is invalid (missing keys or invalid data types)");
147 if (!root[
"hue"].isNull())
156 root[
"id"] =
add_property_json(
"ID", 0.0,
"string",
Id(), NULL, -1, -1,
true, requested_frame);
157 root[
"position"] =
add_property_json(
"Position",
Position(),
"float",
"", NULL, 0, 1000 * 60 * 30,
false, requested_frame);
159 root[
"start"] =
add_property_json(
"Start",
Start(),
"float",
"", NULL, 0, 1000 * 60 * 30,
false, requested_frame);
160 root[
"end"] =
add_property_json(
"End",
End(),
"float",
"", NULL, 0, 1000 * 60 * 30,
false, requested_frame);
161 root[
"duration"] =
add_property_json(
"Duration",
Duration(),
"float",
"", NULL, 0, 1000 * 60 * 30,
true, requested_frame);
167 return root.toStyledString();
Json::Value add_property_json(std::string name, float value, std::string type, std::string memo, const Keyframe *keyframe, float min_value, float max_value, bool readonly, int64_t requested_frame) const
Generate JSON for a property.
const Json::Value stringToJson(const std::string value)
EffectInfoStruct info
Information about the current effect.
std::shared_ptr< Frame > GetFrame(std::shared_ptr< Frame > frame, int64_t frame_number)
This method is required for all derived classes of EffectBase, and returns a modified openshot::Frame...
This namespace is the default namespace for all code in the openshot library.
float End() const
Get end position (in seconds) of clip (trim end of video)
Json::Value JsonValue() const override
Generate Json::Value for this object.
void SetJsonValue(const Json::Value root)
Load Json::Value into this object.
virtual void SetJsonValue(const Json::Value root)=0
Load Json::Value into this object.
virtual Json::Value JsonValue() const =0
Generate Json::Value for this object.
int Layer() const
Get layer of clip on timeline (lower number is covered by higher numbers)
Json::Value JsonValue() const
Generate Json::Value for this object.
std::string PropertiesJSON(int64_t requested_frame) const override
std::string Id() const
Get basic properties.
Keyframe hue
Shift the hue coordinates (left or right)
void SetJson(const std::string value)
Load JSON string into this object.
A Keyframe is a collection of Point instances, which is used to vary a number or property over time.
Exception for invalid JSON.
std::string Json() const override
Get and Set JSON methods.
bool has_audio
Determines if this effect manipulates the audio of a frame.
float Duration() const
Get the length of this clip (in seconds)
Hue()
Blank constructor, useful when using Json to load the effect properties.
This class shifts the hue of an image, and can be animated with openshot::Keyframe curves over time.
std::string class_name
The class name of the effect.
std::string description
The description of this effect and what it does.
bool has_video
Determines if this effect manipulates the image of a frame.
void SetJsonValue(const Json::Value root)
Load Json::Value into this object.
std::shared_ptr< QImage > GetImage()
Get pointer to Qt QImage image object.
int constrain(int color_value)
Constrain a color value from 0 to 255.
float Position() const
Get position on timeline (in seconds)
std::string name
The name of the effect.
float Start() const
Get start position (in seconds) of clip (trim start of video)
double GetValue(int64_t index) const
Get the value at a specific index.