xref: /PHP-7.0/ext/gd/tests/bug66005.phpt (revision dc09f309)
1--TEST--
2Bug #66005 (imagecopy does not support 1bit transparency on truecolor images)
3--SKIPIF--
4<?php
5if (!extension_loaded('gd')) die('skip gd extension not available');
6?>
7--FILE--
8<?php
9$dest = imagecreatetruecolor(150, 50);
10$transparent = imagecolorallocatealpha($dest, 255, 255, 255, 127);
11imagealphablending($dest, false);
12imagefill($dest, 1, 1, $transparent);
13imagesavealpha($dest, true);
14
15// Palette image with transparent color
16$png_palette = imagecreatefromstring(base64_decode('iVBORw0KGgoAAAANSUhEUgAAADIAAAAyAgMAAABjUWAiAAAACVBMVEUAAAD/AAD///9nGWQeAAAAAXRSTlMAQObYZgAAAEFJREFUKM9jYBimIASZIxoagOAwhoaGInisQJ4DksJQJKWoPCAnNIQYHsgChBX4eMSbiddlqH5A9R+q39HCZWgDAFxFGyOrmguhAAAAAElFTkSuQmCCPHP'));
17
18// 24 bit with transparent color
19$png_24 = imagecreatefromstring(base64_decode('iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAIAAACRXR/mAAAABnRSTlMAAAAAAABupgeRAAAAVklEQVRYw+3UQQqAMBAEwf3/p9eTBxEPiWAmWMU8oGFJqgAAuOpzWTX3xQUti+uRJTZ9V5aY1bOTFZLV7yZr9zt6ibv/qPXfrMpsGipbIy7oqQ8AYJED1plDy5PCu2sAAAAASUVORK5CYII='));
20
21// 32 bit with full alpha channel
22$png_full = imagecreatefromstring(base64_decode('iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAXklEQVRo3u3XMQrAIBBFwb3/pU2VwiJNIvjdzMD2PlBwqwAAAGajatxz9OGf5viA+KA3EXExXyKiYlqErIiIiBGSFLIyYmuMkO7Xy2MX4ovS/ONoH7Eh/m1nBwCASBe3VYeVaAy8PwAAAABJRU5ErkJggg=='));
23
24imagecopy($dest, $png_palette, 0, 0, 0, 0, 50, 50);
25imagecopy($dest, $png_24, 50, 0, 0, 0, 50, 50);
26imagecopy($dest, $png_full, 100, 0, 0, 0, 50, 50);
27
28include_once __DIR__ . '/func.inc';
29test_image_equals_file(__DIR__ . '/bug66005.png', $dest);
30?>
31==DONE==
32--EXPECT--
33The images are equal.
34==DONE==
35