Annotation of embedaddon/php/ext/gd/tests/copy.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: imagecopy
3: --SKIPIF--
4: <?php
5: if (!function_exists('imagecopy')) die("skip gd extension not available\n");
6: ?>
7: --FILE--
8: <?php
9:
10: $src_tc = imagecreatetruecolor(5,5);
11: imagefill($src_tc, 0,0, 0xffffff);
12: imagesetpixel($src_tc, 3,3, 0xff0000);
13: imagesetpixel($src_tc, 0,0, 0x0000ff);
14: imagesetpixel($src_tc, 4,4, 0x00ff00);
15:
16:
17: $dst_tc = imagecreatetruecolor(5,5);
18: imagecopy($dst_tc, $src_tc, 0,0, 0,0, imagesx($src_tc), imagesy($src_tc));
19: $p1 = imagecolorat($dst_tc, 3,3) == 0xff0000;
20: $p2 = imagecolorat($dst_tc, 0,0) == 0x0000ff;
21: $p3 = imagecolorat($dst_tc, 4,4) == 0x00ff00;
22:
23: if ($p1 && $p2 && $p3) {
24: echo "TC/TC: ok\n";
25: }
26:
27: imagedestroy($src_tc); imagedestroy($dst_tc);
28:
29:
30: $src_tc = imagecreatetruecolor(5,5);
31: imagefill($src_tc, 0,0, 0xffffff);
32: imagesetpixel($src_tc, 3,3, 0xff0000);
33: imagesetpixel($src_tc, 0,0, 0x0000ff);
34: imagesetpixel($src_tc, 4,4, 0x00ff00);
35:
36:
37: $dst_tc = imagecreate(5,5);
38: imagecopy($dst_tc, $src_tc, 0,0, 0,0, imagesx($src_tc), imagesy($src_tc));
39:
40: $c1 = imagecolorsforindex($dst_tc, imagecolorat($dst_tc, 3,3));
41: $c2 = imagecolorsforindex($dst_tc, imagecolorat($dst_tc, 0,0));
42: $c3 = imagecolorsforindex($dst_tc, imagecolorat($dst_tc, 4,4));
43:
44: $p1 = $c1['red'] == 0xff && $c1['blue']==0x00 && $c1['green']==0x00;
45: $p2 = $c2['red'] == 0x00 && $c2['blue']==0xff && $c2['green']==0x00;
46: $p3 = $c3['red'] == 0x00 && $c3['blue']==0x00 && $c3['green']==0xff;
47:
48: if ($p1 && $p2 && $p3) {
49: echo "TC/P: ok\n";
50: }
51: imagedestroy($src_tc); imagedestroy($dst_tc);
52:
53:
54:
55: $src_tc = imagecreate(5,5);
56: $c0 = imagecolorallocate($src_tc, 0xff, 0xff, 0xff);
57: $c1 = imagecolorallocate($src_tc, 0xff, 0x00, 0x00);
58: $c2 = imagecolorallocate($src_tc, 0x00, 0x00, 0xff);
59: $c3 = imagecolorallocate($src_tc, 0x00, 0xff, 0x00);
60:
61: imagesetpixel($src_tc, 3,3, $c1);
62: imagesetpixel($src_tc, 0,0, $c2);
63: imagesetpixel($src_tc, 4,4, $c3);
64:
65:
66: $dst_tc = imagecreate(5,5);
67: imagecopy($dst_tc, $src_tc, 0,0, 0,0, imagesx($src_tc), imagesy($src_tc));
68:
69: $c1 = imagecolorsforindex($dst_tc, imagecolorat($dst_tc, 3,3));
70: $c2 = imagecolorsforindex($dst_tc, imagecolorat($dst_tc, 0,0));
71: $c3 = imagecolorsforindex($dst_tc, imagecolorat($dst_tc, 4,4));
72:
73: $p1 = $c1['red'] == 0xff && $c1['blue']==0x00 && $c1['green']==0x00;
74: $p2 = $c2['red'] == 0x00 && $c2['blue']==0xff && $c2['green']==0x00;
75: $p3 = $c3['red'] == 0x00 && $c3['blue']==0x00 && $c3['green']==0xff;
76:
77:
78: if ($p1 && $p2 && $p3) {
79: echo "P/P: ok\n";
80: }
81:
82:
83:
84: $src_tc = imagecreate(5,5);
85: $c0 = imagecolorallocate($src_tc, 0xff, 0xff, 0xff);
86: $c1 = imagecolorallocate($src_tc, 0xff, 0x00, 0x00);
87: $c2 = imagecolorallocate($src_tc, 0x00, 0x00, 0xff);
88: $c3 = imagecolorallocate($src_tc, 0x00, 0xff, 0x00);
89:
90: imagesetpixel($src_tc, 3,3, $c1);
91: imagesetpixel($src_tc, 0,0, $c2);
92: imagesetpixel($src_tc, 4,4, $c3);
93:
94:
95: $dst_tc = imagecreatetruecolor(5,5);
96: imagecopy($dst_tc, $src_tc, 0,0, 0,0, imagesx($src_tc), imagesy($src_tc));
97: $p1 = imagecolorat($dst_tc, 3,3) == 0xff0000;
98: $p2 = imagecolorat($dst_tc, 0,0) == 0x0000ff;
99: $p3 = imagecolorat($dst_tc, 4,4) == 0x00ff00;
100:
101: if ($p1 && $p2 && $p3) {
102: echo "P/TC: ok\n";
103: }
104: ?>
105: --EXPECTF--
106: TC/TC: ok
107: TC/P: ok
108: P/P: ok
109: P/TC: ok
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>