OpenShot Library | libopenshot
0.2.5
|
Go to the documentation of this file.
31 #include "../../include/effects/Pixelate.h"
38 init_effect_details();
43 pixelization(pixelization), left(left), top(top), right(right), bottom(bottom)
46 init_effect_details();
50 void Pixelate::init_effect_details()
58 info.
description =
"Pixelate (increase or decrease) the number of visible pixels.";
68 std::shared_ptr<QImage> frame_image = frame->
GetImage();
77 if (pixelization_value > 0.0) {
78 int w = frame_image->width();
79 int h = frame_image->height();
82 QRect area(QPoint(0,0), frame_image->size());
83 area = area.marginsRemoved({int(left_value * w), int(top_value * h), int(right_value * w), int(bottom_value * h)});
86 auto frame_scaled = frame_image->copy(area).scaledToWidth(area.width() * pixelization_value, Qt::SmoothTransformation);
89 QPainter painter(frame_image.get());
90 painter.drawImage(area, frame_scaled);
131 catch (
const std::exception& e)
134 throw InvalidJSON(
"JSON is invalid (missing keys or invalid data types)");
145 if (!root[
"pixelization"].isNull())
147 if (!root[
"left"].isNull())
149 if (!root[
"top"].isNull())
151 if (!root[
"right"].isNull())
153 if (!root[
"bottom"].isNull())
162 root[
"id"] =
add_property_json(
"ID", 0.0,
"string",
Id(), NULL, -1, -1,
true, requested_frame);
163 root[
"position"] =
add_property_json(
"Position", Position(),
"float",
"", NULL, 0, 1000 * 60 * 30,
false, requested_frame);
164 root[
"layer"] =
add_property_json(
"Track", Layer(),
"int",
"", NULL, 0, 20,
false, requested_frame);
165 root[
"start"] =
add_property_json(
"Start", Start(),
"float",
"", NULL, 0, 1000 * 60 * 30,
false, requested_frame);
166 root[
"end"] =
add_property_json(
"End", End(),
"float",
"", NULL, 0, 1000 * 60 * 30,
false, requested_frame);
167 root[
"duration"] =
add_property_json(
"Duration", Duration(),
"float",
"", NULL, 0, 1000 * 60 * 30,
true, requested_frame);
177 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::string PropertiesJSON(int64_t requested_frame) const override
This namespace is the default namespace for all code in the openshot library.
Keyframe pixelization
Amount of pixelization.
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.
std::string Json() const override
Get and Set JSON methods.
Json::Value JsonValue() const
Generate Json::Value for this object.
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...
Keyframe bottom
Size of bottom margin.
A Keyframe is a collection of Point instances, which is used to vary a number or property over time.
Exception for invalid JSON.
void SetJsonValue(const Json::Value root)
Load Json::Value into this object.
bool has_audio
Determines if this effect manipulates the audio of a frame.
Keyframe right
Size of right margin.
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.
Keyframe left
Size of left margin.
Pixelate()
Blank constructor, useful when using Json to load the effect properties.
void Id(std::string value)
Set basic properties.
std::shared_ptr< QImage > GetImage()
Get pointer to Qt QImage image object.
std::string name
The name of the effect.
Json::Value JsonValue() const override
Generate Json::Value for this object.
Keyframe top
Size of top margin.
void SetJson(const std::string value)
Load JSON string into this object.
double GetValue(int64_t index) const
Get the value at a specific index.