21 init_effect_details();
28 init_effect_details();
32 void Hue::init_effect_details()
47 std::shared_ptr<openshot::Frame>
Hue::GetFrame(std::shared_ptr<openshot::Frame> frame, int64_t frame_number)
50 std::shared_ptr<QImage> frame_image = frame->GetImage();
52 int pixel_count = frame_image->width() * frame_image->height();
55 double degrees = 360.0 *
hue.
GetValue(frame_number);
56 float cosA = cos(degrees*3.14159265f/180);
57 float sinA = sin(degrees*3.14159265f/180);
61 cosA + (1.0f - cosA) / 3.0f,
62 1.0f/3.0f * (1.0f - cosA) - sqrtf(1.0f/3.0f) * sinA,
63 1.0f/3.0f * (1.0f - cosA) + sqrtf(1.0f/3.0f) * sinA
67 unsigned char *pixels = (
unsigned char *) frame_image->bits();
69 #pragma omp parallel for shared (pixels)
70 for (
int pixel = 0; pixel < pixel_count; ++pixel)
73 int R = pixels[pixel * 4];
74 int G = pixels[pixel * 4 + 1];
75 int B = pixels[pixel * 4 + 2];
78 pixels[pixel * 4] =
constrain(R * matrix[0] + G * matrix[1] + B * matrix[2]);
79 pixels[pixel * 4 + 1] =
constrain(R * matrix[2] + G * matrix[0] + B * matrix[1]);
80 pixels[pixel * 4 + 2] =
constrain(R * matrix[1] + G * matrix[2] + B * matrix[0]);
116 catch (
const std::exception& e)
119 throw InvalidJSON(
"JSON is invalid (missing keys or invalid data types)");
130 if (!root[
"hue"].isNull())
139 root[
"id"] =
add_property_json(
"ID", 0.0,
"string",
Id(), NULL, -1, -1,
true, requested_frame);
140 root[
"position"] =
add_property_json(
"Position",
Position(),
"float",
"", NULL, 0, 1000 * 60 * 30,
false, requested_frame);
142 root[
"start"] =
add_property_json(
"Start",
Start(),
"float",
"", NULL, 0, 1000 * 60 * 30,
false, requested_frame);
143 root[
"end"] =
add_property_json(
"End",
End(),
"float",
"", NULL, 0, 1000 * 60 * 30,
false, requested_frame);
144 root[
"duration"] =
add_property_json(
"Duration",
Duration(),
"float",
"", NULL, 0, 1000 * 60 * 30,
true, requested_frame);
153 return root.toStyledString();
Header file for all Exception classes.
Header file for Hue effect class.
float Start() const
Get start position (in seconds) of clip (trim start of video)
float Duration() const
Get the length of this clip (in seconds)
virtual float End() const
Get end position (in seconds) of clip (trim end of video)
std::string Id() const
Get the Id of this clip object.
int Layer() const
Get layer of clip on timeline (lower number is covered by higher numbers)
float Position() const
Get position on timeline (in seconds)
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.
virtual Json::Value JsonValue() const
Generate Json::Value for this object.
int constrain(int color_value)
Constrain a color value from 0 to 255.
virtual void SetJsonValue(const Json::Value root)
Load Json::Value into this object.
EffectInfoStruct info
Information about the current effect.
This class shifts the hue of an image, and can be animated with openshot::Keyframe curves over time.
Keyframe hue
Shift the hue coordinates (left or right)
void SetJsonValue(const Json::Value root) override
Load Json::Value into this object.
Hue()
Default constructor, useful when using Json to load the effect properties.
void SetJson(const std::string value) override
Load JSON string into this object.
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...
std::string PropertiesJSON(int64_t requested_frame) const override
std::string Json() const override
Generate JSON string of this object.
Json::Value JsonValue() const override
Generate Json::Value for this object.
Exception for invalid JSON.
A Keyframe is a collection of Point instances, which is used to vary a number or property over time.
void SetJsonValue(const Json::Value root)
Load Json::Value into this object.
double GetValue(int64_t index) const
Get the value at a specific index.
Json::Value JsonValue() const
Generate Json::Value for this object.
This namespace is the default namespace for all code in the openshot library.
const Json::Value stringToJson(const std::string value)
bool has_video
Determines if this effect manipulates the image of a frame.
std::string parent_effect_id
Id of the parent effect (if there is one)
bool has_audio
Determines if this effect manipulates the audio of a frame.
std::string class_name
The class name of the effect.
std::string name
The name of the effect.
std::string description
The description of this effect and what it does.