xref: /PHP-7.4/ext/gd/tests/imagegd_truecolor.phpt (revision 45f7b2bc)
1--TEST--
2imagegd() writes truecolor images without palette conversion
3--SKIPIF--
4<?php
5if (!extension_loaded('gd')) die('skip gd extension not available');
6?>
7--FILE--
8<?php
9require_once __DIR__ . DIRECTORY_SEPARATOR . 'func.inc';
10
11$im = imagecreatetruecolor(10, 10);
12$white = imagecolorallocate($im, 255, 255, 255);
13imagefilledrectangle($im, 0,0, 9,9, $white);
14$blue = imagecolorallocate($im, 0, 0, 255);
15imagefilledrectangle($im, 3,3, 6,6, $blue);
16
17ob_start();
18imagegd($im);
19$buffer = ob_get_clean();
20
21$header = unpack('nsignature/nwidth/nheight/Ctruecolor', $buffer);
22printf("signature: %d\n", $header['signature']);
23printf("truecolor: %d\n", $header['truecolor']);
24printf("size: %d\n", strlen($buffer));
25
26test_image_equals_file(__DIR__ . DIRECTORY_SEPARATOR . 'imagegd_truecolor.png', $im);
27?>
28===DONE===
29--EXPECT--
30signature: 65534
31truecolor: 1
32size: 411
33The images are equal.
34===DONE===
35