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
effectKenBurnsPanLR(bool aInit)28 int EffectMngr::Private::effectKenBurnsPanLR(bool aInit)
29 {
30 if (aInit)
31 {
32 eff_step = 0;
33 }
34
35 QRectF fRect(eff_image.rect());
36
37 // This effect zoom to 80 percents and pan from left to right.
38
39 double nx = eff_step * ((eff_image.width() - eff_image.width() * 0.8) / eff_imgFrames);
40 double ny = (eff_image.height() - eff_image.height() * 0.8) / 2.0;
41 double nh = eff_image.height() * 0.8;
42 double nw = eff_image.width() * 0.8;
43 fRect.setTopLeft(QPointF(nx, ny));
44 fRect.setSize(QSize(nw, nh));
45
46 updateCurrentFrame(fRect);
47
48 eff_step++;
49
50 if (eff_step != eff_imgFrames)
51 {
52 return 15;
53 }
54
55 return -1;
56 }
57
effectKenBurnsPanRL(bool aInit)58 int EffectMngr::Private::effectKenBurnsPanRL(bool aInit)
59 {
60 if (aInit)
61 {
62 eff_step = 0;
63 }
64
65 QRectF fRect(eff_image.rect());
66
67 // This effect zoom to 80 percents and pan from right to left.
68
69 double nx = eff_step * ((eff_image.width() - eff_image.width() * 0.8) / eff_imgFrames);
70 double ny = (eff_image.height() - eff_image.height() * 0.8) / 2.0;
71 double nh = eff_image.height() * 0.8;
72 double nw = eff_image.width() * 0.8;
73 fRect.setTopLeft(QPointF(eff_image.width() - nw - nx, ny));
74 fRect.setSize(QSize(nw, nh));
75
76 updateCurrentFrame(fRect);
77
78 eff_step++;
79
80 if (eff_step != eff_imgFrames)
81 {
82 return 15;
83 }
84
85 return -1;
86 }
87
effectKenBurnsPanTB(bool aInit)88 int EffectMngr::Private::effectKenBurnsPanTB(bool aInit)
89 {
90 if (aInit)
91 {
92 eff_step = 0;
93 }
94
95 QRectF fRect(eff_image.rect());
96
97 // This effect zoom to 80 percents and pan from top to bottom.
98
99 double nx = (eff_image.width() - eff_image.width() * 0.8) / 2.0;
100 double ny = eff_step * ((eff_image.height() - eff_image.height() * 0.8) / eff_imgFrames);
101 double nh = eff_image.height() * 0.8;
102 double nw = eff_image.width() * 0.8;
103 fRect.setTopLeft(QPointF(nx, ny));
104 fRect.setSize(QSize(nw, nh));
105
106 updateCurrentFrame(fRect);
107
108 eff_step++;
109
110 if (eff_step != eff_imgFrames)
111 {
112 return 15;
113 }
114
115 return -1;
116 }
117
effectKenBurnsPanBT(bool aInit)118 int EffectMngr::Private::effectKenBurnsPanBT(bool aInit)
119 {
120 if (aInit)
121 {
122 eff_step = 0;
123 }
124
125 QRectF fRect(eff_image.rect());
126
127 // This effect zoom to 80 percents and pan from bottom to top.
128
129 double nx = (eff_image.width() - eff_image.width() * 0.8) / 2.0;
130 double ny = eff_step * ((eff_image.height() - eff_image.height() * 0.8) / eff_imgFrames);
131 double nh = eff_image.height() * 0.8;
132 double nw = eff_image.width() * 0.8;
133 fRect.setTopLeft(QPointF(nx, eff_image.height() - nh - ny));
134 fRect.setSize(QSize(nw, nh));
135
136 updateCurrentFrame(fRect);
137
138 eff_step++;
139
140 if (eff_step != eff_imgFrames)
141 {
142 return 15;
143 }
144
145 return -1;
146 }
147
148 } // namespace Digikam
149