Apply background image to the current clip image (i.e. flatten this image onto previous layer)
| 1276 | |
| 1277 | // Apply background image to the current clip image (i.e. flatten this image onto previous layer) |
| 1278 | void 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) |
| 1297 | void Clip::apply_effects(std::shared_ptr<Frame> frame, int64_t timeline_frame_number, TimelineInfoStruct* options, bool before_keyframes) |