forked from quiet2/network-weathermap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-multipass.php
54 lines (43 loc) · 1.33 KB
/
test-multipass.php
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
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
/**
* Created by PhpStorm.
* User: howie
* Date: 27/12/16
* Time: 13:24
*/
$im = imagecreatefrompng('test-suite/data/greybox32.png');
print (has_transparency($im) ? "TRUE" : "FALSE");
print "\n\n\n";
function has_transparency($imageRef)
{
$width = imagesx($imageRef);
$height = imagesy($imageRef);
$im2 = imagecreate($width, $height);
$white = imagecolorallocate($im2, 255, 255, 255);
$step_colours = array(
imagecolorallocate($im2, 255, 0, 0),
imagecolorallocate($im2, 0, 255, 0),
imagecolorallocate($im2, 0, 0, 255),
imagecolorallocate($im2, 255, 255, 0),
imagecolorallocate($im2, 0, 255, 255),
imagecolorallocate($im2, 255, 0, 255),
imagecolorallocate($im2, 128, 0, 255),
imagecolorallocate($im2, 255, 0, 128),
imagecolorallocate($im2, 255, 128, 128),
imagecolorallocate($im2, 128, 255, 128)
);
$black = imagefill($im2, 0, 0, $white);
$step = 7;
$start = 0;
$npixels = $width * $height;
for ($start = 0; $start < $step; $start++) {
$colour = $step_colours[$start];
for ($n = $start; $n < $npixels; $n += $step) {
$y = $n % $width;
$x = floor($n / $width);
imagesetpixel($im2, $x, $y, $colour);
}
}
imagepng($im2, "test.png");
return false;
}