|
OpenShot Library | libopenshot
0.7.0
|
Go to the documentation of this file.
21 double clamp_margin(
double value) {
31 Bars::Bars() : color(
"#000000"), left(0.0), top(0.1), right(0.0), bottom(0.1) {
33 init_effect_details();
38 color(color), left(left), top(top), right(right), bottom(bottom)
41 init_effect_details();
45 void Bars::init_effect_details()
60 std::shared_ptr<openshot::Frame>
Bars::GetFrame(std::shared_ptr<openshot::Frame> frame, int64_t frame_number)
63 std::shared_ptr<QImage> frame_image = frame->GetImage();
64 const int width = frame_image->width();
65 const int height = frame_image->height();
66 if (width <= 0 || height <= 0)
70 auto tempColor = std::make_shared<QImage>(
71 width, 1, QImage::Format_RGBA8888_Premultiplied);
72 tempColor->fill(QColor(QString::fromStdString(
color.
GetColorHex(frame_number))));
81 unsigned char *pixels = (
unsigned char *) frame_image->bits();
82 unsigned char *color_pixels = (
unsigned char *) tempColor->bits();
85 int top_bar_height = clamp_margin(top_value) * height;
86 int bottom_bar_height = clamp_margin(bottom_value) * height;
87 int left_bar_width = clamp_margin(left_value) * width;
88 int right_bar_width = clamp_margin(right_value) * width;
91 for (
int row = 0; row < height; row++) {
94 if ((top_bar_height > 0.0 && row <= top_bar_height) || (bottom_bar_height > 0.0 && row >= height - bottom_bar_height)) {
95 memcpy(&pixels[row * width * 4], color_pixels,
sizeof(
char) * width * 4);
98 if (left_bar_width > 0.0) {
99 memcpy(&pixels[row * width * 4], color_pixels,
sizeof(
char) * left_bar_width * 4);
103 if (right_bar_width > 0.0) {
104 memcpy(&pixels[((row * width) + (width - right_bar_width)) * 4], color_pixels,
sizeof(
char) * right_bar_width * 4);
149 catch (
const std::exception& e)
152 throw InvalidJSON(
"JSON is invalid (missing keys or invalid data types)");
163 if (!root[
"color"].isNull())
165 if (!root[
"left"].isNull())
167 if (!root[
"top"].isNull())
169 if (!root[
"right"].isNull())
171 if (!root[
"bottom"].isNull())
192 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)
void SetJsonValue(const Json::Value root) override
Load Json::Value into this object.
EffectInfoStruct info
Information about the current effect.
This namespace is the default namespace for all code in the openshot library.
virtual Json::Value JsonValue() const
Generate Json::Value for this object.
std::string Json() const override
Generate JSON string of this object.
void SetJsonValue(const Json::Value root)
Load Json::Value into this object.
Keyframe left
Size of left bar.
Json::Value JsonValue() const
Generate Json::Value for this object.
This class represents a color (used on the timeline and clips)
Bars()
Blank constructor, useful when using Json to load the effect properties.
Json::Value BasePropertiesJSON(int64_t requested_frame) const
Generate JSON object of base properties (recommended to be used by all effects)
Header file for Bars effect class.
A Keyframe is a collection of Point instances, which is used to vary a number or property over time.
void SetJson(const std::string value) override
Load JSON string into this object.
void SetJsonValue(const Json::Value root)
Load Json::Value into this object.
Keyframe bottom
Size of bottom bar.
Exception for invalid JSON.
openshot::Keyframe green
Curve representing the green value (0 - 255)
bool has_audio
Determines if this effect manipulates the audio of a frame.
Keyframe right
Size of right bar.
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...
Color color
Color of bars.
std::string PropertiesJSON(int64_t requested_frame) const override
Json::Value JsonValue() const override
Generate Json::Value for this object.
std::string class_name
The class name of the effect.
Json::Value JsonValue() const
Generate Json::Value for this object.
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.
std::string name
The name of the effect.
Keyframe top
Size of top bar.
openshot::Keyframe red
Curve representing the red value (0 - 255)
std::string GetColorHex(int64_t frame_number)
Get the HEX value of a color at a specific frame.
openshot::Keyframe blue
Curve representing the red value (0 - 255)
Header file for all Exception classes.
virtual 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.