Passed
Push — master ( 3c6756...8b3b37 )
by Michael
20:43 queued 12:59
created

AsNegativeTest::testTransparentGIF()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 10
c 2
b 0
f 0
nc 1
nop 0
dl 0
loc 17
rs 9.9332
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 Test\WideImage_TestCase;
25
26
/**
27
 * @package Tests
28
 */
29
class AsNegativeTest extends WideImage_TestCase
30
{
31
	public function skip()
32
	{
33
		$this->skipUnless(function_exists('imagefilter'));
34
	}
35
	
36
	public function testTransparentGIF()
37
	{
38
		$img = $this->load('100x100-color-hole.gif');
39
		
40
		$res = $img->asNegative();
41
		
42
		$this->assertDimensions($res, 100, 100);
43
		$this->assertInstanceOf("WideImage\\PaletteImage", $res);
44
		
45
		$this->assertRGBNear($res->getRGBAt(10, 10), 0, 0, 255);
46
		$this->assertRGBNear($res->getRGBAt(90, 10), 255, 255, 0);
47
		$this->assertRGBNear($res->getRGBAt(90, 90), 255, 0, 255);
48
		$this->assertRGBNear($res->getRGBAt(10, 90), 0, 255, 255);
49
		
50
		// preserves transparency
51
		$this->assertTrue($res->isTransparent());
52
		$this->assertTransparentColorAt($res, 50, 50);
53
	}
54
	
55
	public function testTransparentLogoGIF()
56
	{
57
		$img = $this->load('logo.gif');
58
		$this->assertTransparentColorAt($img, 1, 1);
59
		
60
		$res = $img->asNegative();
61
		$this->assertDimensions($res, 150, 23);
62
		$this->assertInstanceOf("WideImage\\PaletteImage", $res);
63
		
64
		// preserves transparency
65
		$this->assertTrue($res->isTransparent());
66
		$this->assertTransparentColorAt($res, 1, 1);
67
	}
68
	
69
	public function testPNGAlpha()
70
	{
71
		$img = $this->load('100x100-blue-alpha.png');
72
		
73
		$res = $img->asNegative();
74
		
75
		$this->assertDimensions($res, 100, 100);
76
		$this->assertInstanceOf("WideImage\\TrueColorImage", $res);
77
		
78
		$this->assertRGBNear($res->getRGBAt(25, 25), 255, 255, 0, 32);
79
		$this->assertRGBNear($res->getRGBAt(75, 25), 255, 255, 0, 64);
80
		$this->assertRGBNear($res->getRGBAt(75, 75), 255, 255, 0, 96);
81
		$this->assertRGBNear($res->getRGBAt(25, 75), 255, 255, 255, 127);
82
		
83
		$this->assertFalse($res->isTransparent());
84
	}
85
}
86