File indexing completed on 2025-01-05 03:57:24

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2017-05-24
0007  * Description : video frame effects manager.
0008  *
0009  * SPDX-FileCopyrightText: 2017-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0010  *
0011  * SPDX-License-Identifier: GPL-2.0-or-later
0012  *
0013  * ============================================================ */
0014 
0015 #include "effectmngr_p.h"
0016 
0017 namespace Digikam
0018 {
0019 
0020 int EffectMngr::Private::effectKenBurnsPanLR(bool aInit)
0021 {
0022     if (aInit)
0023     {
0024         eff_step = 0;
0025     }
0026 
0027     QRectF fRect(eff_image.rect());
0028 
0029     // This effect zoom to 80 percents and pan from left to right.
0030 
0031     double nx = eff_step * ((eff_image.width() - eff_image.width() * 0.8) / eff_imgFrames);
0032     double ny = (eff_image.height() - eff_image.height() * 0.8) / 2.0;
0033     double nh = eff_image.height() * 0.8;
0034     double nw = eff_image.width()  * 0.8;
0035     fRect.setTopLeft(QPointF(nx, ny));
0036     fRect.setSize(QSize(nw, nh));
0037 
0038     updateCurrentFrame(fRect);
0039 
0040     eff_step++;
0041 
0042     if (eff_step != eff_imgFrames)
0043     {
0044         return 15;
0045     }
0046 
0047     return -1;
0048 }
0049 
0050 int EffectMngr::Private::effectKenBurnsPanRL(bool aInit)
0051 {
0052     if (aInit)
0053     {
0054         eff_step = 0;
0055     }
0056 
0057     QRectF fRect(eff_image.rect());
0058 
0059     // This effect zoom to 80 percents and pan from right to left.
0060 
0061     double nx = eff_step * ((eff_image.width() - eff_image.width() * 0.8) / eff_imgFrames);
0062     double ny = (eff_image.height() - eff_image.height() * 0.8) / 2.0;
0063     double nh = eff_image.height() * 0.8;
0064     double nw = eff_image.width()  * 0.8;
0065     fRect.setTopLeft(QPointF(eff_image.width() - nw - nx, ny));
0066     fRect.setSize(QSize(nw, nh));
0067 
0068     updateCurrentFrame(fRect);
0069 
0070     eff_step++;
0071 
0072     if (eff_step != eff_imgFrames)
0073     {
0074         return 15;
0075     }
0076 
0077     return -1;
0078 }
0079 
0080 int EffectMngr::Private::effectKenBurnsPanTB(bool aInit)
0081 {
0082     if (aInit)
0083     {
0084         eff_step = 0;
0085     }
0086 
0087     QRectF fRect(eff_image.rect());
0088 
0089     // This effect zoom to 80 percents and pan from top to bottom.
0090 
0091     double nx = (eff_image.width() - eff_image.width() * 0.8) / 2.0;
0092     double ny = eff_step * ((eff_image.height() - eff_image.height() * 0.8) / eff_imgFrames);
0093     double nh = eff_image.height() * 0.8;
0094     double nw = eff_image.width()  * 0.8;
0095     fRect.setTopLeft(QPointF(nx, ny));
0096     fRect.setSize(QSize(nw, nh));
0097 
0098     updateCurrentFrame(fRect);
0099 
0100     eff_step++;
0101 
0102     if (eff_step != eff_imgFrames)
0103     {
0104         return 15;
0105     }
0106 
0107     return -1;
0108 }
0109 
0110 int EffectMngr::Private::effectKenBurnsPanBT(bool aInit)
0111 {
0112     if (aInit)
0113     {
0114         eff_step = 0;
0115     }
0116 
0117     QRectF fRect(eff_image.rect());
0118 
0119     // This effect zoom to 80 percents and pan from bottom to top.
0120 
0121     double nx = (eff_image.width() - eff_image.width() * 0.8) / 2.0;
0122     double ny = eff_step * ((eff_image.height() - eff_image.height() * 0.8) / eff_imgFrames);
0123     double nh = eff_image.height() * 0.8;
0124     double nw = eff_image.width()  * 0.8;
0125     fRect.setTopLeft(QPointF(nx, eff_image.height() - nh - ny));
0126     fRect.setSize(QSize(nw, nh));
0127 
0128     updateCurrentFrame(fRect);
0129 
0130     eff_step++;
0131 
0132     if (eff_step != eff_imgFrames)
0133     {
0134         return 15;
0135     }
0136 
0137     return -1;
0138 }
0139 
0140 } // namespace Digikam