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 // Qt includes
0018 
0019 #include <QTime>
0020 
0021 // KDE includes
0022 
0023 #include <klocalizedstring.h>
0024 
0025 // Local includes
0026 
0027 #include "digikam_config.h"
0028 #include "digikam_debug.h"
0029 
0030 namespace Digikam
0031 {
0032 
0033 EffectMngr::EffectMngr()
0034     : d(new Private)
0035 {
0036 }
0037 
0038 EffectMngr::~EffectMngr()
0039 {
0040     delete d;
0041 }
0042 
0043 void EffectMngr::setOutputSize(const QSize& size)
0044 {
0045     d->eff_outSize  = size;
0046     d->eff_curFrame = QImage(d->eff_outSize, QImage::Format_ARGB32);
0047     d->eff_curFrame.fill(Qt::black);
0048 }
0049 
0050 void EffectMngr::setEffect(EffectType type)
0051 {
0052     if (type == Random)
0053     {
0054         d->eff_curEffect = d->getRandomEffect();
0055     }
0056     else
0057     {
0058         d->eff_curEffect = type;
0059     }
0060 
0061     d->eff_isRunning = false;
0062 }
0063 
0064 void EffectMngr::setImage(const QImage& img)
0065 {
0066     d->eff_image = img;
0067 }
0068 
0069 void EffectMngr::setFrames(int ifrms)
0070 {
0071     d->eff_imgFrames = ifrms;
0072 }
0073 
0074 QImage EffectMngr::currentFrame(int& tmout)
0075 {
0076     if (!d->eff_isRunning)
0077     {
0078         d->eff_curFrame  = d->eff_image;
0079         tmout            = (this->d->*d->eff_effectList[d->eff_curEffect])(true);
0080         d->eff_isRunning = true;
0081     }
0082     else
0083     {
0084         tmout = (this->d->*d->eff_effectList[d->eff_curEffect])(false);
0085     }
0086 
0087     if (tmout == -1)
0088     {
0089         d->eff_isRunning = false;
0090     }
0091 
0092     return d->eff_curFrame;
0093 }
0094 
0095 QMap<EffectMngr::EffectType, QString> EffectMngr::effectNames()
0096 {
0097     QMap<EffectType, QString> eff;
0098 
0099     eff[None]            = i18nc("Effect: No Effect",       "None");
0100     eff[KenBurnsZoomIn]  = i18nc("Effect: KenBurnsZoomIn",  "Ken Burns - Camera Zoom In");
0101     eff[KenBurnsZoomOut] = i18nc("Effect: KenBurnsZoomOut", "Ken Burns - Camera Zoom Out");
0102     eff[KenBurnsPanLR]   = i18nc("Effect: KenBurnsPanLR",   "Ken Burns - Camera Pan Left to Right");
0103     eff[KenBurnsPanRL]   = i18nc("Effect: KenBurnsPanRL",   "Ken Burns - Camera Pan Right to Left");
0104     eff[KenBurnsPanTB]   = i18nc("Effect: KenBurnsPanTB",   "Ken Burns - Camera Pan Top to Bottom");
0105     eff[KenBurnsPanBT]   = i18nc("Effect: KenBurnsPanBT",   "Ken Burns - Camera Pan Bottom to Top");
0106     eff[Random]          = i18nc("Effect: Random Effect",   "Random");
0107 
0108     return eff;
0109 }
0110 
0111 } // namespace Digikam