1 /* ============================================================ 2 * 3 * This file is a part of digiKam project 4 * https://www.digikam.org 5 * 6 * Date : 2017-05-24 7 * Description : video frame effects manager. 8 * 9 * Copyright (C) 2017-2021 by Gilles Caulier <caulier dot gilles at gmail dot com> 10 * 11 * This program is free software; you can redistribute it 12 * and/or modify it under the terms of the GNU General 13 * Public License as published by the Free Software Foundation; 14 * either version 2, or (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * ============================================================ */ 22 23 #include "effectmngr_p.h" 24 25 namespace Digikam 26 { 27 effectKenBurnsZoomIn(bool aInit)28int EffectMngr::Private::effectKenBurnsZoomIn(bool aInit) 29 { 30 if (aInit) 31 { 32 eff_step = 0; 33 } 34 35 QRectF fRect(eff_image.rect()); 36 37 // This effect zoom in on the center of image from 100 to 80 percents. 38 double nx = eff_step * ((eff_image.width() - eff_image.width() * 0.8) / eff_imgFrames); 39 double ny = nx / ((double)eff_image.width() / (double)eff_image.height()); 40 fRect.setTopLeft(QPointF(nx, ny)); 41 fRect.setBottomRight(QPointF((double)eff_image.width()-nx, (double)eff_image.height()-ny)); 42 43 updateCurrentFrame(fRect); 44 45 eff_step++; 46 47 if (eff_step != eff_imgFrames) 48 { 49 return 15; 50 } 51 52 return -1; 53 } 54 effectKenBurnsZoomOut(bool aInit)55int EffectMngr::Private::effectKenBurnsZoomOut(bool aInit) 56 { 57 if (aInit) 58 { 59 eff_step = eff_imgFrames; 60 } 61 62 QRectF fRect(eff_image.rect()); 63 64 // This effect zoom out on the center of image from 80 to 100 percents. 65 double nx = eff_step * ((eff_image.width() - eff_image.width() * 0.8) / eff_imgFrames); 66 double ny = nx / ((double)eff_image.width() / (double)eff_image.height()); 67 fRect.setTopLeft(QPointF(nx, ny)); 68 fRect.setBottomRight(QPointF((double)eff_image.width()-nx, (double)eff_image.height()-ny)); 69 70 updateCurrentFrame(fRect); 71 72 eff_step--; 73 74 if (eff_step != 0) 75 { 76 return 15; 77 } 78 79 return -1; 80 } 81 82 } // namespace Digikam 83