MCPcopy Create free account
hub / github.com/OpenShot/libopenshot / apply_background

Method apply_background

src/Clip.cpp:1278–1294  ·  view source on GitHub ↗

Apply background image to the current clip image (i.e. flatten this image onto previous layer)

Source from the content-addressed store, hash-verified

1276
1277// Apply background image to the current clip image (i.e. flatten this image onto previous layer)
1278void Clip::apply_background(std::shared_ptr<openshot::Frame> frame,
1279 std::shared_ptr<openshot::Frame> background_frame,
1280 bool update_frame_image) {
1281 // Add background canvas
1282 std::shared_ptr<QImage> background_canvas = background_frame->GetImage();
1283 QPainter painter(background_canvas.get());
1284
1285 // Composite a new layer onto the image
1286 painter.setCompositionMode(static_cast<QPainter::CompositionMode>(composite));
1287 painter.drawImage(0, 0, *frame->GetImage());
1288 painter.end();
1289
1290 // Standalone clip requests update frame->image, but timeline composition
1291 // draws onto the timeline-owned background frame only.
1292 if (update_frame_image)
1293 frame->AddImage(background_canvas);
1294}
1295
1296// Apply effects to the source frame (if any)
1297void Clip::apply_effects(std::shared_ptr<Frame> frame, int64_t timeline_frame_number, TimelineInfoStruct* options, bool before_keyframes)

Callers

nothing calls this directly

Calls 3

GetImageMethod · 0.80
AddImageMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected