File: copy.phpt

package info (click to toggle)
php5 5.6.7%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 150,376 kB
  • sloc: ansic: 727,510; php: 21,966; sh: 12,356; cpp: 8,763; xml: 6,105; yacc: 1,551; exp: 1,514; makefile: 1,461; pascal: 1,048; awk: 538; perl: 315; sql: 22
file content (109 lines) | stat: -rw-r--r-- 3,065 bytes parent folder | download | duplicates (10)
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
--TEST--
imagecopy
--SKIPIF--
<?php
        if (!function_exists('imagecopy')) die("skip gd extension not available\n");
?>
--FILE--
<?php

$src_tc = imagecreatetruecolor(5,5);
imagefill($src_tc, 0,0, 0xffffff);
imagesetpixel($src_tc, 3,3, 0xff0000);
imagesetpixel($src_tc, 0,0, 0x0000ff);
imagesetpixel($src_tc, 4,4, 0x00ff00);


$dst_tc = imagecreatetruecolor(5,5);
imagecopy($dst_tc, $src_tc, 0,0, 0,0, imagesx($src_tc), imagesy($src_tc));
$p1 = imagecolorat($dst_tc, 3,3) == 0xff0000;
$p2 = imagecolorat($dst_tc, 0,0) == 0x0000ff;
$p3 = imagecolorat($dst_tc, 4,4) == 0x00ff00;

if ($p1 && $p2 && $p3) {
	echo "TC/TC: ok\n";
}

imagedestroy($src_tc); imagedestroy($dst_tc);


$src_tc = imagecreatetruecolor(5,5);
imagefill($src_tc, 0,0, 0xffffff);
imagesetpixel($src_tc, 3,3, 0xff0000);
imagesetpixel($src_tc, 0,0, 0x0000ff);
imagesetpixel($src_tc, 4,4, 0x00ff00);


$dst_tc = imagecreate(5,5);
imagecopy($dst_tc, $src_tc, 0,0, 0,0, imagesx($src_tc), imagesy($src_tc));

$c1 = imagecolorsforindex($dst_tc, imagecolorat($dst_tc, 3,3));
$c2 = imagecolorsforindex($dst_tc, imagecolorat($dst_tc, 0,0));
$c3 = imagecolorsforindex($dst_tc, imagecolorat($dst_tc, 4,4));

$p1 = $c1['red'] == 0xff && $c1['blue']==0x00 && $c1['green']==0x00;
$p2 = $c2['red'] == 0x00 && $c2['blue']==0xff && $c2['green']==0x00;
$p3 = $c3['red'] == 0x00 && $c3['blue']==0x00 && $c3['green']==0xff;

if ($p1 && $p2 && $p3) {
	echo "TC/P: ok\n";
}
imagedestroy($src_tc); imagedestroy($dst_tc);



$src_tc = imagecreate(5,5);
$c0 = imagecolorallocate($src_tc, 0xff, 0xff, 0xff);
$c1 = imagecolorallocate($src_tc, 0xff, 0x00, 0x00);
$c2 = imagecolorallocate($src_tc, 0x00, 0x00, 0xff);
$c3 = imagecolorallocate($src_tc, 0x00, 0xff, 0x00);

imagesetpixel($src_tc, 3,3, $c1);
imagesetpixel($src_tc, 0,0, $c2);
imagesetpixel($src_tc, 4,4, $c3);


$dst_tc = imagecreate(5,5);
imagecopy($dst_tc, $src_tc, 0,0, 0,0, imagesx($src_tc), imagesy($src_tc));

$c1 = imagecolorsforindex($dst_tc, imagecolorat($dst_tc, 3,3));
$c2 = imagecolorsforindex($dst_tc, imagecolorat($dst_tc, 0,0));
$c3 = imagecolorsforindex($dst_tc, imagecolorat($dst_tc, 4,4));

$p1 = $c1['red'] == 0xff && $c1['blue']==0x00 && $c1['green']==0x00;
$p2 = $c2['red'] == 0x00 && $c2['blue']==0xff && $c2['green']==0x00;
$p3 = $c3['red'] == 0x00 && $c3['blue']==0x00 && $c3['green']==0xff;


if ($p1 && $p2 && $p3) {
	echo "P/P: ok\n";
}



$src_tc = imagecreate(5,5);
$c0 = imagecolorallocate($src_tc, 0xff, 0xff, 0xff);
$c1 = imagecolorallocate($src_tc, 0xff, 0x00, 0x00);
$c2 = imagecolorallocate($src_tc, 0x00, 0x00, 0xff);
$c3 = imagecolorallocate($src_tc, 0x00, 0xff, 0x00);

imagesetpixel($src_tc, 3,3, $c1);
imagesetpixel($src_tc, 0,0, $c2);
imagesetpixel($src_tc, 4,4, $c3);


$dst_tc = imagecreatetruecolor(5,5);
imagecopy($dst_tc, $src_tc, 0,0, 0,0, imagesx($src_tc), imagesy($src_tc));
$p1 = imagecolorat($dst_tc, 3,3) == 0xff0000;
$p2 = imagecolorat($dst_tc, 0,0) == 0x0000ff;
$p3 = imagecolorat($dst_tc, 4,4) == 0x00ff00;

if ($p1 && $p2 && $p3) {
	echo "P/TC: ok\n";
}
?>
--EXPECTF--
TC/TC: ok
TC/P: ok
P/P: ok
P/TC: ok