Skip to content

Commit

Permalink
Fixing some regressions on image merging
Browse files Browse the repository at this point in the history
  • Loading branch information
jonoomph authored and ferdnyc committed Oct 19, 2020
1 parent 8387b12 commit b3ad76d
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 2 deletions.
10 changes: 9 additions & 1 deletion include/ClipBase.h
Expand Up @@ -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()); }
Expand Down
3 changes: 3 additions & 0 deletions include/TimelineBase.h
Expand Up @@ -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();
};
}

Expand Down
23 changes: 22 additions & 1 deletion src/Timeline.cpp
Expand Up @@ -568,8 +568,29 @@ void Timeline::add_layer(std::shared_ptr<Frame> 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<QImage> 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());
Expand Down
8 changes: 8 additions & 0 deletions src/TimelineBase.cpp
Expand Up @@ -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;
}

0 comments on commit b3ad76d

Please sign in to comment.