1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
This file is part of WideImage. |
4
|
|
|
|
5
|
|
|
WideImage is free software; you can redistribute it and/or modify |
6
|
|
|
it under the terms of the GNU Lesser General Public License as published by |
7
|
|
|
the Free Software Foundation; either version 2.1 of the License, or |
8
|
|
|
(at your option) any later version. |
9
|
|
|
|
10
|
|
|
WideImage is distributed in the hope that it will be useful, |
11
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
12
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13
|
|
|
GNU Lesser General Public License for more details. |
14
|
|
|
|
15
|
|
|
You should have received a copy of the GNU Lesser General Public License |
16
|
|
|
along with WideImage; if not, write to the Free Software |
17
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
18
|
|
|
|
19
|
|
|
* @package Tests |
20
|
|
|
**/ |
21
|
|
|
|
22
|
|
|
namespace Test\WideImage\Operation; |
23
|
|
|
|
24
|
|
|
use WideImage\WideImage; |
25
|
|
|
use Test\WideImage_TestCase; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @package Tests |
29
|
|
|
*/ |
30
|
|
|
class RotateTest extends WideImage_TestCase |
31
|
|
|
{ |
32
|
|
|
public function skip() |
33
|
|
|
{ |
34
|
|
|
$this->skipUnless(function_exists('imagerotate')); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
public function testRotateAlphaSafe() |
38
|
|
|
{ |
39
|
|
|
$img = WideImage::load(IMG_PATH . '100x100-blue-alpha.png'); |
40
|
|
|
$this->assertRGBEqual($img->getRGBAt(25, 25), 0, 0, 255, round(128 / 4)); |
41
|
|
|
$this->assertRGBEqual($img->getRGBAt(75, 25), 0, 0, 255, round(2 * 128 / 4)); |
42
|
|
|
$this->assertRGBEqual($img->getRGBAt(75, 75), 0, 0, 255, round(3 * 128 / 4)); |
43
|
|
|
$this->assertRGBEqual($img->getRGBAt(25, 75), 0, 0, 0, 127); |
44
|
|
|
$new = $img->rotate(90, null); |
45
|
|
|
$this->assertEquals(100, $new->getWidth()); |
46
|
|
|
$this->assertEquals(100, $new->getHeight()); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function testRotateCounterClockwise90() |
50
|
|
|
{ |
51
|
|
|
$img = WideImage::load(IMG_PATH . 'fgnl.jpg'); |
52
|
|
|
$new = $img->rotate(-90); |
53
|
|
|
$this->assertEquals(287, $new->getWidth()); |
54
|
|
|
$this->assertEquals(174, $new->getHeight()); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public function testRotate45() |
58
|
|
|
{ |
59
|
|
|
$img = WideImage::load(IMG_PATH . '100x100-rainbow.png'); |
60
|
|
|
$new = $img->rotate(45); |
61
|
|
|
$this->assertEquals(141, $new->getWidth()); |
62
|
|
|
$this->assertEquals(141, $new->getHeight()); |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|