diff --git a/src/Clip.cpp b/src/Clip.cpp
index 2099705d..48085655 100644
--- a/src/Clip.cpp
+++ b/src/Clip.cpp
@@ -76,9 +76,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);
diff --git a/src/Timeline.cpp b/src/Timeline.cpp
index 37d3f71c..3d96c002 100644
--- a/src/Timeline.cpp
+++ b/src/Timeline.cpp
@@ -457,6 +457,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
@@ -564,7 +601,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 * scaled_source_width, crop_y * scaled_source_height, crop_w * scaled_source_width, crop_h * scaled_source_height);
// Draw frame #'s on top of image (if needed)
if (source_clip->display != FRAME_DISPLAY_NONE) {