From ab4069464a13aef4e522f1170188a3bc95ea7c08 Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Thu, 29 Nov 2012 17:28:22 -0600 Subject: [PATCH] Added curve-based color as the canvas background color (red, green, and blue), so it can be animated now. --- include/Timeline.h | 11 ++++++++++- src/Main.cpp | 6 ++++-- src/Timeline.cpp | 23 +++++++++++++++++++---- 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/include/Timeline.h b/include/Timeline.h index 1c67a5e0..b5500455 100644 --- a/include/Timeline.h +++ b/include/Timeline.h @@ -30,6 +30,12 @@ namespace openshot { return lhs->Position() <= rhs->Position() && lhs->Layer() < rhs->Layer(); }}; + struct Color{ + Keyframe red; /// new_frame, Clip* source_clip, int clip_frame_number); + void add_layer(tr1::shared_ptr new_frame, Clip* source_clip, int clip_frame_number, int timeline_frame_number); /// Calculate time of a frame number, based on a framerate float calculate_time(int number, Framerate rate); @@ -98,6 +104,9 @@ namespace openshot { Keyframe viewport_x; /// new_frame, Clip* source_clip, int clip_frame_number) +void Timeline::add_layer(tr1::shared_ptr new_frame, Clip* source_clip, int clip_frame_number, int timeline_frame_number) { // Get the clip's frame & image tr1::shared_ptr source_frame; @@ -60,7 +65,12 @@ void Timeline::add_layer(tr1::shared_ptr new_frame, Clip* source_clip, in /* CREATE BACKGROUND COLOR - needed if this is the 1st layer */ if (new_frame->GetImage()->columns() == 1) - new_frame->AddColor(width, height, "#000000"); + { + int red = color.red.GetInt(timeline_frame_number); + int green = color.green.GetInt(timeline_frame_number); + int blue = color.blue.GetInt(timeline_frame_number); + new_frame->AddColor(width, height, Magick::Color(red, green, blue)); + } /* COPY AUDIO - with correct volume */ for (int channel = 0; channel < source_frame->GetAudioChannelsCount(); channel++) @@ -334,14 +344,19 @@ tr1::shared_ptr Timeline::GetFrame(int requested_frame) throw(ReaderClose int clip_frame_number = round(time_diff * fps.GetFPS()) + 1; // Add clip's frame as layer - add_layer(new_frame, clip, clip_frame_number); + add_layer(new_frame, clip, clip_frame_number, frame_number); } else cout << "FRAME NOT IN CLIP DURATION: frame: " << frame_number << ", pos: " << clip->Position() << ", end: " << clip->End() << endl; // Check for empty frame image (and fill with color) if (new_frame->GetImage()->columns() == 1) - new_frame->AddColor(width, height, "#000000"); + { + int red = color.red.GetInt(frame_number); + int green = color.green.GetInt(frame_number); + int blue = color.blue.GetInt(frame_number); + new_frame->AddColor(width, height, Magick::Color(red, green, blue)); + } // Add final frame to cache #pragma omp critical (timeline_cache)