File: WaveEffect.cpp

package info (click to toggle)
libopenshot 0.5.0%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 31,228 kB
  • sloc: cpp: 32,692; python: 92; sh: 67; makefile: 21; ruby: 5
file content (41 lines) | stat: -rw-r--r-- 1,027 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/**
 * @file
 * @brief Unit tests for openshot::Wave effect
 * @author OpenAI ChatGPT
 */

// Copyright (c) 2008-2025 OpenShot Studios, LLC
//
// SPDX-License-Identifier: LGPL-3.0-or-later

#include <memory>
#include <QImage>
#include <QColor>

#include "Frame.h"
#include "effects/Wave.h"
#include "openshot_catch.h"

using namespace openshot;

TEST_CASE("Wave uses original pixel buffer", "[effect][wave]")
{
	// Create 1x10 image with increasing red channel
	QImage img(10, 1, QImage::Format_ARGB32);
	for (int x = 0; x < 10; ++x)
		img.setPixelColor(x, 0, QColor(x, 0, 0, 255));
	auto f = std::make_shared<Frame>();
	*f->GetImage() = img;

	Wave w;
	w.wavelength = Keyframe(0.0);
	w.amplitude = Keyframe(1.0);
	w.multiplier = Keyframe(0.01);
	w.shift_x = Keyframe(-1.0); // negative shift to copy from previous pixel
	w.speed_y = Keyframe(0.0);

	auto out_img = w.GetFrame(f, 1)->GetImage();
	int expected[10] = {0,0,1,2,3,4,5,6,7,8};
	for (int x = 0; x < 10; ++x)
		CHECK(out_img->pixelColor(x,0).red() == expected[x]);
}