diff --git a/src/Clip.cpp b/src/Clip.cpp
index 8c669042..bddcd0c9 100644
--- a/src/Clip.cpp
+++ b/src/Clip.cpp
@@ -79,9 +79,9 @@ void Clip::init_settings()
wave_color = Color((unsigned char)0, (unsigned char)123, (unsigned char)255, (unsigned char)255);
// Init crop settings
- crop_gravity = GRAVITY_CENTER;
- crop_width = Keyframe(-1.0);
- crop_height = Keyframe(-1.0);
+ crop_gravity = GRAVITY_TOP_LEFT;
+ crop_width = Keyframe(1.0);
+ crop_height = Keyframe(1.0);
crop_x = Keyframe(0.0);
crop_y = Keyframe(0.0);
@@ -716,6 +716,11 @@ string Clip::PropertiesJSON(int64_t requested_frame) {
root["has_audio"] = add_property_json("Enable Audio", has_audio.GetValue(requested_frame), "int", "", &has_audio, -1, 1.0, false, requested_frame);
root["has_video"] = add_property_json("Enable Video", has_video.GetValue(requested_frame), "int", "", &has_video, -1, 1.0, false, requested_frame);
+ root["crop_x"] = add_property_json("Crop X", crop_x.GetValue(requested_frame), "float", "", &crop_x, -1.0, 1.0, false, requested_frame);
+ root["crop_y"] = add_property_json("Crop Y", crop_y.GetValue(requested_frame), "float", "", &crop_y, -1.0, 1.0, false, requested_frame);
+ root["crop_width"] = add_property_json("Crop Width", crop_width.GetValue(requested_frame), "float", "", &crop_width, 0.0, 1.0, false, requested_frame);
+ root["crop_height"] = add_property_json("Crop Height", crop_height.GetValue(requested_frame), "float", "", &crop_height, 0.0, 1.0, false, requested_frame);
+
root["wave_color"] = add_property_json("Wave Color", 0.0, "color", "", &wave_color.red, 0, 255, false, requested_frame);
root["wave_color"]["red"] = add_property_json("Red", wave_color.red.GetValue(requested_frame), "float", "", &wave_color.red, 0, 255, false, requested_frame);
root["wave_color"]["blue"] = add_property_json("Blue", wave_color.blue.GetValue(requested_frame), "float", "", &wave_color.blue, 0, 255, false, requested_frame);
diff --git a/src/Timeline.cpp b/src/Timeline.cpp
index c04cb291..7636de7d 100644
--- a/src/Timeline.cpp
+++ b/src/Timeline.cpp
@@ -460,6 +460,43 @@ void Timeline::add_layer(std::shared_ptr new_frame, Clip* source_clip, in
}
}
+ float crop_x = source_clip->crop_x.GetValue(clip_frame_number);
+ float crop_y = source_clip->crop_y.GetValue(clip_frame_number);
+ float crop_w = source_clip->crop_width.GetValue(clip_frame_number);
+ float crop_h = source_clip->crop_height.GetValue(clip_frame_number);
+ switch(source_clip->crop_gravity)
+ {
+ case (GRAVITY_TOP):
+ crop_x += 0.5;
+ break;
+ case (GRAVITY_TOP_RIGHT):
+ crop_x += 1.0;
+ break;
+ case (GRAVITY_LEFT):
+ crop_y += 0.5;
+ break;
+ case (GRAVITY_CENTER):
+ crop_x += 0.5;
+ crop_y += 0.5;
+ break;
+ case (GRAVITY_RIGHT):
+ crop_x += 1.0;
+ crop_y += 0.5;
+ break;
+ case (GRAVITY_BOTTOM_LEFT):
+ crop_y += 1.0;
+ break;
+ case (GRAVITY_BOTTOM):
+ crop_x += 0.5;
+ crop_y += 1.0;
+ break;
+ case (GRAVITY_BOTTOM_RIGHT):
+ crop_x += 1.0;
+ crop_y += 1.0;
+ break;
+ }
+
+
/* GRAVITY LOCATION - Initialize X & Y to the correct values (before applying location curves) */
float x = 0.0; // left
float y = 0.0; // top
@@ -567,7 +604,7 @@ void Timeline::add_layer(std::shared_ptr new_frame, Clip* source_clip, in
// Composite a new layer onto the image
painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
- painter.drawImage(0, 0, *source_image);
+ painter.drawImage(0, 0, *source_image, crop_x * source_image->width(), crop_y * source_image->height(), crop_w * source_image->width(), crop_h * source_image->height());
// Draw frame #'s on top of image (if needed)
if (source_clip->display != FRAME_DISPLAY_NONE) {