OpenShot Library | libopenshot
0.3.3
|
Go to the documentation of this file.
19 Bars::Bars() : color(
"#000000"), left(0.0), top(0.1), right(0.0), bottom(0.1) {
21 init_effect_details();
26 color(color), left(left), top(top), right(right), bottom(bottom)
29 init_effect_details();
33 void Bars::init_effect_details()
48 std::shared_ptr<openshot::Frame>
Bars::GetFrame(std::shared_ptr<openshot::Frame> frame, int64_t frame_number)
51 std::shared_ptr<QImage> frame_image = frame->GetImage();
54 auto tempColor = std::make_shared<QImage>(
55 frame_image->width(), 1, QImage::Format_RGBA8888_Premultiplied);
56 tempColor->fill(QColor(QString::fromStdString(
color.
GetColorHex(frame_number))));
65 unsigned char *pixels = (
unsigned char *) frame_image->bits();
66 unsigned char *color_pixels = (
unsigned char *) tempColor->bits();
69 int top_bar_height = top_value * frame_image->height();
70 int bottom_bar_height = bottom_value * frame_image->height();
71 int left_bar_width = left_value * frame_image->width();
72 int right_bar_width = right_value * frame_image->width();
75 for (
int row = 0; row < frame_image->height(); row++) {
78 if ((top_bar_height > 0.0 && row <= top_bar_height) || (bottom_bar_height > 0.0 && row >= frame_image->height() - bottom_bar_height)) {
79 memcpy(&pixels[row * frame_image->width() * 4], color_pixels,
sizeof(
char) * frame_image->width() * 4);
82 if (left_bar_width > 0.0) {
83 memcpy(&pixels[row * frame_image->width() * 4], color_pixels,
sizeof(
char) * left_bar_width * 4);
87 if (right_bar_width > 0.0) {
88 memcpy(&pixels[((row * frame_image->width()) + (frame_image->width() - right_bar_width)) * 4], color_pixels,
sizeof(
char) * right_bar_width * 4);
133 catch (
const std::exception& e)
136 throw InvalidJSON(
"JSON is invalid (missing keys or invalid data types)");
147 if (!root[
"color"].isNull())
149 if (!root[
"left"].isNull())
151 if (!root[
"top"].isNull())
153 if (!root[
"right"].isNull())
155 if (!root[
"bottom"].isNull())
176 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.