From 206578df3fd31ddd2122e99a6d3cde6ff546456c Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Mon, 5 Oct 2020 23:08:31 -0500 Subject: [PATCH] Fixing some regressions on image merging --- include/ClipBase.h | 10 +++++++++- include/TimelineBase.h | 3 +++ src/Timeline.cpp | 23 ++++++++++++++++++++++- src/TimelineBase.cpp | 8 ++++++++ 4 files changed, 42 insertions(+), 2 deletions(-) diff --git a/include/ClipBase.h b/include/ClipBase.h index e335c501b..11d2271fa 100644 --- a/include/ClipBase.h +++ b/include/ClipBase.h @@ -69,7 +69,15 @@ namespace openshot { CacheMemory cache; /// Constructor for the base clip - ClipBase() { }; + ClipBase() { + // Initialize values + position = 0.0; + layer = 0; + start = 0.0; + end = 0.0; + previous_properties = ""; + timeline = NULL; + }; // Compare a clip using the Position() property bool operator< ( ClipBase& a) { return (Position() < a.Position()); } diff --git a/include/TimelineBase.h b/include/TimelineBase.h index d065a6de1..af6a65a20 100644 --- a/include/TimelineBase.h +++ b/include/TimelineBase.h @@ -41,6 +41,9 @@ namespace openshot { public: int preview_width; ///< Optional preview width of timeline image. If your preview window is smaller than the timeline, it's recommended to set this. int preview_height; ///< Optional preview width of timeline image. If your preview window is smaller than the timeline, it's recommended to set this. + + /// Constructor for the base timeline + TimelineBase(); }; } diff --git a/src/Timeline.cpp b/src/Timeline.cpp index 8c1429b2e..f75becaf0 100644 --- a/src/Timeline.cpp +++ b/src/Timeline.cpp @@ -495,8 +495,29 @@ void Timeline::add_layer(std::shared_ptr new_frame, Clip* source_clip, in // Skip the rest of the image processing for performance reasons return; + // Debug output + ZmqLogger::Instance()->AppendDebugMethod("Timeline::add_layer (Get Source Image)", "source_frame->number", source_frame->number, "source_clip->Waveform()", source_clip->Waveform(), "clip_frame_number", clip_frame_number); + + // Get actual frame image data + source_image = source_frame->GetImage(); + + // Debug output + ZmqLogger::Instance()->AppendDebugMethod("Timeline::add_layer (Transform: Composite Image Layer: Prepare)", "source_frame->number", source_frame->number, "new_frame->GetImage()->width()", new_frame->GetImage()->width(), "source_image->width()", source_image->width()); + + /* COMPOSITE SOURCE IMAGE (LAYER) ONTO FINAL IMAGE */ + std::shared_ptr new_image; + new_image = new_frame->GetImage(); + + // Load timeline's new frame image into a QPainter + QPainter painter(new_image.get()); + + // Composite a new layer onto the image + painter.setCompositionMode(QPainter::CompositionMode_SourceOver); + painter.drawImage(0, 0, *source_image, 0, 0, source_image->width(), source_image->height()); + painter.end(); + // Add new QImage to frame - new_frame->AddImage(source_frame->GetImage()); + new_frame->AddImage(new_image); // Debug output ZmqLogger::Instance()->AppendDebugMethod("Timeline::add_layer (Transform: Composite Image Layer: Completed)", "source_frame->number", source_frame->number, "new_frame->GetImage()->width()", new_frame->GetImage()->width()); diff --git a/src/TimelineBase.cpp b/src/TimelineBase.cpp index f75e1ddb9..cc59a2433 100644 --- a/src/TimelineBase.cpp +++ b/src/TimelineBase.cpp @@ -31,3 +31,11 @@ #include "../include/TimelineBase.h" using namespace openshot; + +/// Constructor for the base timeline +TimelineBase::TimelineBase() +{ + // Init preview size (default) + preview_width = 1920; + preview_height = 1080; +}