cvs: php-src(PHP_5_2) /ext/gd/tests colorat.phpt colorclosest.phpt colorexact.phpt colorresolve.phpt copy.phpt copyresized.phpt createfromgd2.phpt
createfromwbmp.phpt dashedlines.phpt gif.phpt imagewbmp.phpt lines.phpt src.gd2 src.wbmp test_gif_2.gif truecolor.phpt types.phpt

From: Date: Mon, 17 Jul 2006 12:54:10 +0000
Subject: cvs: php-src(PHP_5_2) /ext/gd/tests colorat.phpt colorclosest.phpt colorexact.phpt colorresolve.phpt copy.phpt copyresized.phpt createfromgd2.phpt
createfromwbmp.phpt dashedlines.phpt gif.phpt imagewbmp.phpt lines.phpt src.gd2 src.wbmp test_gif_2.gif truecolor.phpt types.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-39312@lists.php.net to get a copy of this message
pajoye Mon Jul 17 12:54:10 2006 UTC Added files: (Branch: PHP_5_2) /php-src/ext/gd/tests colorat.phpt colorclosest.phpt colorexact.phpt colorresolve.phpt copy.phpt copyresized.phpt createfromgd2.phpt createfromwbmp.phpt dashedlines.phpt gif.phpt imagewbmp.phpt lines.phpt src.gd2 src.wbmp test_gif_2.gif truecolor.phpt types.phpt Log: - sync tests with HEAD

http://cvs.php.net/viewvc.cgi/php-src/ext/gd/tests/colorat.phpt?view=markup&rev=1.1 Index: php-src/ext/gd/tests/colorat.phpt +++ php-src/ext/gd/tests/colorat.phpt --TEST-- imagecolorat --SKIPIF-- <?php if (!function_exists('imagecolorat')) die("skip gd extension not available\n"); ?> --FILE-- <?php $file = dirname(__FILE__) . '/im.wbmp'; $im = imagecreatetruecolor(6,6); imagefill($im, 0,0, 0xffffff); imagesetpixel($im, 3,3, 0x0); echo 'test colorat truecolor: '; $c = imagecolorat($im, 3,3); echo $c == 0x0 ? 'ok' : 'failed'; echo "\n"; imagedestroy($im); $im = imagecreate(6,6); $c1 = imagecolorallocate($im, 255,255,255); $c2 = imagecolorallocate($im, 0,0,0); imagefill($im, 0,0, $c1); imagesetpixel($im, 3,3, $c2); echo 'test colorat palette: '; $c = imagecolorsforindex($im, imagecolorat($im, 3,3)); $failed = false; foreach ($c as $v) { if ($v != 0) { $failed = true; } } echo !$failed ? 'ok' : 'failed'; echo "\n"; ?> --EXPECT-- test colorat truecolor: ok test colorat palette: ok http://cvs.php.net/viewvc.cgi/php-src/ext/gd/tests/colorclosest.phpt?view=markup&rev=1.1 Index: php-src/ext/gd/tests/colorclosest.phpt +++ php-src/ext/gd/tests/colorclosest.phpt --TEST-- imagecopy --SKIPIF-- <?php if (!function_exists('imagecopy')) die("skip gd extension not available\n"); ?> --FILE-- <?php $im = imagecreatetruecolor(5,5); $c = imagecolorclosest($im, 255,0,255); printf("%X\n", $c); imagedestroy($im); $im = imagecreate(5,5); $c = imagecolorclosest($im, 255,0,255); print_r(imagecolorsforindex($im, $c)); imagedestroy($im); $im = imagecreate(5,5); imagecolorallocate($im, 255, 0, 255); $c = imagecolorclosest($im, 255,0,255); print_r(imagecolorsforindex($im, $c)); imagedestroy($im); $im = imagecreate(5,5); for ($i=0; $i<255; $i++) imagecolorresolve($im, $i,0,0); $c = imagecolorclosest($im, 255,0,0); print_r(imagecolorsforindex($im, $c)); $im = imagecreate(5,5); for ($i=0; $i<256; $i++) { if ($i == 246) { imagecolorallocate($im, $i,10,10); } else { imagecolorallocate($im, $i,0,0); } } $c = imagecolorclosest($im, 255,10,10); print_r(imagecolorsforindex($im, $c)); ?> --EXPECTF-- FF00FF Warning: imagecolorsforindex(): Color index -1 out of range in %s on line %d Array ( [red] => 255 [green] => 0 [blue] => 255 [alpha] => 0 ) Array ( [red] => 254 [green] => 0 [blue] => 0 [alpha] => 0 ) Array ( [red] => 246 [green] => 10 [blue] => 10 [alpha] => 0 ) http://cvs.php.net/viewvc.cgi/php-src/ext/gd/tests/colorexact.phpt?view=markup&rev=1.1 Index: php-src/ext/gd/tests/colorexact.phpt +++ php-src/ext/gd/tests/colorexact.phpt --TEST-- imagecolorexact --SKIPIF-- <?php if (!function_exists('imagecolorexact')) die("skip gd extension not available\n"); ?> --FILE-- <?php $im = imagecreatetruecolor(5,5); $c = imagecolorexact($im, 255,0,255); $c2 = imagecolorexactalpha($im, 255,0,255, 100); printf("%X\n", $c); printf("%X\n", $c2); imagedestroy($im); $im = imagecreate(5,5); $c = imagecolorallocate($im, 255,0,255); $c2 = imagecolorallocate($im, 255,200,0); $c3 = imagecolorallocatealpha($im, 255,200,0,100); echo imagecolorexact($im, 255,0,255) . "\n"; echo imagecolorexact($im, 255,200,0) . "\n"; echo imagecolorexactalpha($im, 255,200,0,100) . "\n"; // unallocated index echo imagecolorexact($im, 12,12,12) . "\n"; imagedestroy($im); ?> --EXPECTF-- FF00FF 64FF00FF 0 1 2 -1 http://cvs.php.net/viewvc.cgi/php-src/ext/gd/tests/colorresolve.phpt?view=markup&rev=1.1 Index: php-src/ext/gd/tests/colorresolve.phpt +++ php-src/ext/gd/tests/colorresolve.phpt --TEST-- imagecopy --SKIPIF-- <?php if (!function_exists('imagecopy')) die("skip gd extension not available\n"); ?> --FILE-- <?php $im = imagecreatetruecolor(5,5); $c = imagecolorresolve($im, 255,0,255); printf("%X\n", $c); imagedestroy($im); $im = imagecreate(5,5); $c = imagecolorresolve($im, 255,0,255); print_r(imagecolorsforindex($im, $c)); imagedestroy($im); $im = imagecreate(5,5); for ($i=0; $i<255; $i++) imagecolorresolve($im, $i,0,0); $c = imagecolorresolve($im, 255,0,0); print_r(imagecolorsforindex($im, $c)); $im = imagecreate(5,5); for ($i=0; $i<256; $i++) { if ($i == 246) { imagecolorresolve($im, $i,10,10); } else { imagecolorresolve($im, $i,0,0); } } $c = imagecolorresolve($im, 255,10,10); print_r(imagecolorsforindex($im, $c)); ?> --EXPECTF-- FF00FF Array ( [red] => 255 [green] => 0 [blue] => 255 [alpha] => 0 ) Array ( [red] => 255 [green] => 0 [blue] => 0 [alpha] => 0 ) Array ( [red] => 246 [green] => 10 [blue] => 10 [alpha] => 0 ) http://cvs.php.net/viewvc.cgi/php-src/ext/gd/tests/copy.phpt?view=markup&rev=1.1 Index: php-src/ext/gd/tests/copy.phpt +++ php-src/ext/gd/tests/copy.phpt --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 http://cvs.php.net/viewvc.cgi/php-src/ext/gd/tests/copyresized.phpt?view=markup&rev=1.1 Index: php-src/ext/gd/tests/copyresized.phpt +++ php-src/ext/gd/tests/copyresized.phpt --TEST-- imagecopy --SKIPIF-- <?php if (!function_exists('imagecopy')) die("skip gd extension not available\n"); ?> --FILE-- <?php function get_hexcolor($im, $c) { if (imageistruecolor($im)) { return $c; } $colors = imagecolorsforindex($im, $c); return ($colors['red'] << 16) + ($colors['green'] << 8) + ($colors['blue']); } function check_doublesize($dst) { $im = imagecreatetruecolor(38,38); imagefill($im,0,0, 0xffffff); imagefilledrectangle($im, 0,0,9,9, 0xff0000); imagefilledrectangle($im, 0,28,9,37, 0xff0000); imagefilledrectangle($im, 28,0,37,9, 0xff0000); imagefilledrectangle($im, 28,28,37,37, 0xff0000); imagefilledrectangle($im, 14,14,23,23, 0xff0000); for ($x = 0; $x < 38; $x++) { for ($y = 0; $y < 38; $y++) { $p1 = imagecolorat($im, $x, $y); $p2 = imagecolorat($dst, $x, $y); if (get_hexcolor($im, $p1) != get_hexcolor($dst, $p2)) { return false; } } } return true; } $src_tc = imagecreatetruecolor(19,19); imagefill($src_tc, 0,0, 0xffffff); imagefilledrectangle($src_tc, 0,0,4,4, 0xff0000); imagefilledrectangle($src_tc, 14,0,18,4, 0xff0000); imagefilledrectangle($src_tc, 0,14,4,18, 0xff0000); imagefilledrectangle($src_tc, 14,14,18,18, 0xff0000); imagefilledrectangle($src_tc, 7,7,11,11, 0xff0000); $dst_tc = imagecreatetruecolor(38,38); imagecopyresized($dst_tc, $src_tc, 0,0, 0,0, imagesx($dst_tc), imagesy($dst_tc), 19,19); if (!check_doublesize($dst_tc)) exit("1 failed\n"); echo "TC->TC: ok\n"; $src_tc = imagecreate(19,19); $white = imagecolorallocate($src_tc, 255,255,255); $red = imagecolorallocate($src_tc, 255,0,0); imagefilledrectangle($src_tc, 0,0,4,4, $red); imagefilledrectangle($src_tc, 14,0,18,4, $red); imagefilledrectangle($src_tc, 0,14,4,18, $red); imagefilledrectangle($src_tc, 14,14,18,18, $red); imagefilledrectangle($src_tc, 7,7,11,11, $red); $dst_tc = imagecreatetruecolor(38,38); imagecopyresized($dst_tc, $src_tc, 0,0, 0,0, imagesx($dst_tc), imagesy($dst_tc), 19,19); if (!check_doublesize($dst_tc)) exit("2 failed\n"); echo "P->TC: ok\n"; $src_tc = imagecreate(19,19); $white = imagecolorallocate($src_tc, 255,255,255); $red = imagecolorallocate($src_tc, 255,0,0); imagefilledrectangle($src_tc, 0,0,4,4, $red); imagefilledrectangle($src_tc, 14,0,18,4, $red); imagefilledrectangle($src_tc, 0,14,4,18, $red); imagefilledrectangle($src_tc, 14,14,18,18, $red); imagefilledrectangle($src_tc, 7,7,11,11, $red); $dst_tc = imagecreate(38,38); $white = imagecolorallocate($src_tc, 255,255,255); $red = imagecolorallocate($src_tc, 255,0,0); imagecopyresized($dst_tc, $src_tc, 0,0, 0,0, imagesx($dst_tc), imagesy($dst_tc), 19,19); if (!check_doublesize($dst_tc)) exit("3 failed\n"); echo "P->P: ok\n"; ?> --EXPECTF-- TC->TC: ok P->TC: ok P->P: ok http://cvs.php.net/viewvc.cgi/php-src/ext/gd/tests/createfromgd2.phpt?view=markup&rev=1.1 Index: php-src/ext/gd/tests/createfromgd2.phpt +++ php-src/ext/gd/tests/createfromgd2.phpt --TEST-- Bug #27582 (ImageFillToBorder() on alphablending image looses alpha on fill color) --SKIPIF-- <?php if (!function_exists('imagecreatefromgd2')) die("skip gd extension not available\n"); if (!GD_BUNDLED) die('skip external GD libraries always fail'); ?> --FILE-- <?php $file = dirname(__FILE__) . '/src.gd2'; $im2 = imagecreatefromgd2($file); echo 'test create from gd2: '; echo imagecolorat($im2, 4,4) == 0xffffff ? 'ok' : 'failed'; echo "\n"; $im3 = imagecreatefromgd2part($file, 4,4, 2,2); echo 'test create from gd2 part: '; echo imagecolorat($im2, 4,4) == 0xffffff ? 'ok' : 'failed'; echo "\n"; ?> --EXPECT-- test create from gd2: ok test create from gd2 part: ok http://cvs.php.net/viewvc.cgi/php-src/ext/gd/tests/createfromwbmp.phpt?view=markup&rev=1.1 Index: php-src/ext/gd/tests/createfromwbmp.phpt +++ php-src/ext/gd/tests/createfromwbmp.phpt --TEST-- imagecreatefromwbmp --SKIPIF-- <?php if (!function_exists('imagecreatefromwbmp')) die("skip gd extension not available\n"); if (!GD_BUNDLED) die('skip external GD libraries always fail'); ?> --FILE-- <?php $file = dirname(__FILE__) . '/src.wbmp'; $im2 = imagecreatefromwbmp($file); echo 'test create from wbmp: '; echo imagecolorat($im2, 3,3) == 0x0 ? 'ok' : 'failed'; echo "\n"; ?> --EXPECT-- test create from wbmp: ok http://cvs.php.net/viewvc.cgi/php-src/ext/gd/tests/dashedlines.phpt?view=markup&rev=1.1 Index: php-src/ext/gd/tests/dashedlines.phpt +++ php-src/ext/gd/tests/dashedlines.phpt --TEST-- imageline, dashed --SKIPIF-- <?php if (!function_exists('imagecreatefromstring')) die("skip gd extension not available\n"); ?> --FILE-- <?php $im = imagecreatetruecolor(6,6); imagefill($im, 0,0, 0xffffff); $r = 0xff0000; $b = 0x0000ff; $style = array($r, $b); imagesetstyle($im, $style); // Horizontal line imageline($im, 0,5, 5,5, IMG_COLOR_STYLED); $p1 = imagecolorat($im, 0,5) == $r; $p2 = imagecolorat($im, 1,5) == $b; $p3 = imagecolorat($im, 2,5) == $r; $p4 = imagecolorat($im, 3,5) == $b; $p5 = imagecolorat($im, 4,5) == $r; $p5 = imagecolorat($im, 5,5) == $b; if ($p1 && $p2 && $p3 && $p4 && $p5) { echo "Horizontal: ok\n"; } imagedestroy($im); $im = imagecreatetruecolor(6,6); imagefill($im, 0,0, 0xffffff); $style = array($r, $b); imagesetstyle($im, $style); imageline($im, 2,0, 2,5, IMG_COLOR_STYLED); $p1 = imagecolorat($im, 2,0) == $r; $p2 = imagecolorat($im, 2,1) == $b; $p3 = imagecolorat($im, 2,2) == $r; $p4 = imagecolorat($im, 2,3) == $b; $p5 = imagecolorat($im, 2,4) == $r; $p6 = imagecolorat($im, 2,5) == $b; imagepng($im, 'b.png'); if ($p1 && $p2 && $p3 && $p4 && $p5 && $p6) { echo "Vertical: ok\n"; } imagedestroy($im); $im = imagecreatetruecolor(6,6); imagefill($im, 0,0, 0xffffff); $style = array($r, $b); imagesetstyle($im, $style); imageline($im, 0,0, 5,5, IMG_COLOR_STYLED); $p1 = imagecolorat($im, 0,0) == $r; $p2 = imagecolorat($im, 1,1) == $b; $p3 = imagecolorat($im, 2,2) == $r; $p4 = imagecolorat($im, 3,3) == $b; $p5 = imagecolorat($im, 4,4) == $r; $p6 = imagecolorat($im, 5,5) == $b; if ($p1 && $p2 && $p3 && $p4 && $p5 && $p6) { echo "Diagonal: ok\n"; } imagedestroy($im); ?> --EXPECTF-- Horizontal: ok Vertical: ok Diagonal: ok http://cvs.php.net/viewvc.cgi/php-src/ext/gd/tests/gif.phpt?view=markup&rev=1.1 Index: php-src/ext/gd/tests/gif.phpt +++ php-src/ext/gd/tests/gif.phpt --TEST-- gif in/out --SKIPIF-- <?php // $Id: gif.phpt,v 1.1 2005/12/26 19:11:51 pajoye Exp $ if (!extension_loaded('gd')) { die("skip gd extension not available."); } if (!function_exists("imagegif") || !function_exists("imagecreatefromgif")) { die("skip gif support unavailable"); } ?> --FILE-- <?php function check_box($r,$g,$b, $error=0) { $cwd = dirname(__FILE__); $im2 = imagecreatefromgif($cwd . '/test_gif.gif'); $c = imagecolorsforindex($im2, imagecolorat($im2, 8,8)); if ($error>0) { $r_min = $r - $error; $r_max = $r + $error; $g_min = $g - $error; $g_max = $g + $error; $b_min = $b - $error; $b_max = $b + $error; if ( ($c['red'] >= $r_min || $c['red'] <= $r_max) && ($c['green'] >= $g_min || $c['green'] <= $g_max) && ($c['blue'] >= $b_min || $c['blue'] <= $b_max) ) { return true; } else { return false; } } else { if ($c['red']==$r && $c['green']==$g && $c['blue']==$b) { return true; } else { return false; } } } $cwd = dirname(__FILE__); $im = imagecreate(10,10); $c = imagecolorallocate($im, 255,255,255); imagefilledrectangle($im, 5,5, 10,10, $c); imagegif($im, $cwd . '/test_gif.gif'); if (check_box(255,255,255)) { echo "<4 cols: ok\n"; } $im = imagecreate(10,10); for ($i=0; $i<7; $i++) { $c = imagecolorallocate($im, $i,$i,$i); } imagefilledrectangle($im, 5,5, 10,10, $c); imagegif($im, $cwd . '/test_gif.gif'); $i--; if (check_box($i,$i,$i)) { echo "<8 cols: ok\n"; } $im = imagecreate(10,10); for ($i=0; $i<15; $i++) { $c = imagecolorallocate($im, $i,$i,$i); } imagefilledrectangle($im, 5,5, 10,10, $c); imagegif($im, $cwd . '/test_gif.gif'); $i--; if (check_box($i,$i,$i)) { echo "<16 cols: ok\n"; } $im = imagecreate(10,10); for ($i=0; $i<31; $i++) { $c = imagecolorallocate($im, $i,$i,$i); } imagefilledrectangle($im, 5,5, 10,10, $c); imagegif($im, $cwd . '/test_gif.gif'); $i--; if (check_box($i,$i,$i)) { echo "<32 cols: ok\n"; } $im = imagecreate(10,10); for ($i=0; $i<63; $i++) { $c = imagecolorallocate($im, $i,$i,$i); } imagefilledrectangle($im, 5,5, 10,10, $c); imagegif($im, $cwd . '/test_gif.gif'); $i--; if (check_box($i,$i,$i)) { echo "<64 cols: ok\n"; } $im = imagecreate(10,10); for ($i=0; $i<127; $i++) { $c = imagecolorallocate($im, $i,$i,$i); } imagefilledrectangle($im, 5,5, 10,10, $c); imagegif($im, $cwd . '/test_gif.gif'); $i--; if (check_box($i,$i,$i)) { echo "<128 cols: ok\n"; } $im = imagecreate(10,10); for ($i=0; $i<255; $i++) { $c = imagecolorallocate($im, $i,$i,$i); } imagefilledrectangle($im, 5,5, 10,10, $c); imagegif($im, $cwd . '/test_gif.gif'); $i--; if (check_box($i,$i,$i)) { echo "<256 cols: ok\n"; } $im = imagecreatefromjpeg($cwd . '/conv_test.jpeg'); imagefilledrectangle($im, 5,5, 10,10, 0xffffff); imagegif($im, $cwd . '/test_gif.gif'); imagegif($im, $cwd . '/test_gif_2.gif'); if (check_box(255,255,255, 10)) { echo ">256 cols: ok\n"; } @unlink($cwd . "/test_gif.gif"); ?> --EXPECT-- <4 cols: ok <8 cols: ok <16 cols: ok <32 cols: ok <64 cols: ok <128 cols: ok <256 cols: ok >256 cols: ok http://cvs.php.net/viewvc.cgi/php-src/ext/gd/tests/imagewbmp.phpt?view=markup&rev=1.1 Index: php-src/ext/gd/tests/imagewbmp.phpt +++ php-src/ext/gd/tests/imagewbmp.phpt --TEST-- imagewbmp --SKIPIF-- <?php if (!function_exists('imagecreatefromwbmp')) die("skip gd extension not available\n"); if (!GD_BUNDLED) die('skip external GD libraries always fail'); ?> --FILE-- <?php $file = dirname(__FILE__) . '/im.wbmp'; $im = imagecreatetruecolor(6,6); imagefill($im, 0,0, 0xffffff); imagesetpixel($im, 3,3, 0x0); imagewbmp($im, $file); $im2 = imagecreatefromwbmp($file); echo 'test create wbmp: '; $c = imagecolorsforindex($im2, imagecolorat($im2, 3,3)); $failed = false; foreach ($c as $v) { if ($v != 0) { $failed = true; } } echo !$failed ? 'ok' : 'failed'; echo "\n"; unlink($file); ?> --EXPECT-- test create wbmp: ok http://cvs.php.net/viewvc.cgi/php-src/ext/gd/tests/lines.phpt?view=markup&rev=1.1 Index: php-src/ext/gd/tests/lines.phpt +++ php-src/ext/gd/tests/lines.phpt --TEST-- imageline no AA --SKIPIF-- <?php if (!function_exists('imageline')) die("skip gd extension not available\n"); ?> --FILE-- <?php $im = imagecreatetruecolor(6,6); imagefill($im, 0,0, 0xffffff); // Wrong argument count imageline($im, 0,0, 5,5); // Horizontal line imageline($im, 0,5, 5,5, 0x00ff00); $p1 = imagecolorat($im, 0,5)==0x00ff00; $p2 = imagecolorat($im, 5,5)==0x00ff00; $p3 = true; for ($x=1; $x<5; $x++) { $p3 = $p3 && (imagecolorat($im, $x,5)==0x00ff00); } if ($p1 && $p2 && $p3) { echo "Horizontal: ok\n"; } $im = imagecreatetruecolor(6,6); imagefill($im, 0,0, 0xffffff); imageline($im, 0,0, 0,5, 0x00ff00); $p1 = imagecolorat($im, 0,0)==0x00ff00; $p2 = imagecolorat($im, 0,5)==0x00ff00; $p3 = true; for ($y=1; $y<5; $y++) { $p3 = $p3 && (imagecolorat($im, 0,$y)==0x00ff00); } if ($p1 && $p2 && $p3) { echo "Vertical: ok\n"; } $im = imagecreatetruecolor(6,6); imagefill($im, 0,0, 0xffffff); imageline($im, 0,0, 5,5, 0x00ff00); // Diagonal $p1 = imagecolorat($im, 0,0)==0x00ff00; $p2 = imagecolorat($im, 5,5)==0x00ff00; $x=1; $p3 = true; for ($y=1; $y<5; $y++) { $p3 = $p3 && (imagecolorat($im, $x,$y)==0x00ff00); $x++; } if ($p1 && $p2 && $p3) { echo "Diagonal: ok\n"; } imagepng($im, 'a.png'); // Outside $im = imagecreatetruecolor(6,6); imagefill($im, 0,0, 0xffffff); imageline($im, 12, 12, 23,23, 0x00ff00); $p3 = true; for ($x=0; $x<6; $x++) { for ($y=0; $y<6; $y++) { $p3 = $p3 && (imagecolorat($im, $x,$y)!=0x00ff00); } } if ($p3) { echo "Outside 1: ok\n"; } $im = imagecreatetruecolor(6,6); imagefill($im, 0,0, 0xffffff); imageline($im, -12, -12, -23,-23, 0x00ff00); $p3 = true; for ($x=0; $x<6; $x++) { for ($y=0; $y<6; $y++) { $p3 = $p3 && (imagecolorat($im, $x,$y)!=0x00ff00); } } if ($p3) { echo "Outside 2: ok\n"; } $im = imagecreatetruecolor(6,6); imagefill($im, 0,0, 0xffffff); imageline($im, -1, -1, 4,4, 0x00ff00); $p3 = true; for ($x=0; $x<5; $x++) { for ($y=0; $y<5; $y++) { $p3 = $p3 && (imagecolorat($im, $x,$y)==0x00ff00); } } if ($p3) { echo "Outside 2: ok\n"; } ?> --EXPECTF-- Warning: Wrong parameter count for imageline() in %s on line %d Horizontal: ok Vertical: ok Diagonal: ok Outside 1: ok Outside 2: ok http://cvs.php.net/viewvc.cgi/php-src/ext/gd/tests/src.gd2?view=markup&rev=1.1 Index: php-src/ext/gd/tests/src.gd2 +++ php-src/ext/gd/tests/src.gd2 gd2 http://cvs.php.net/viewvc.cgi/php-src/ext/gd/tests/src.wbmp?view=markup&rev=1.1 Index: php-src/ext/gd/tests/src.wbmp +++ php-src/ext/gd/tests/src.wbmp http://cvs.php.net/viewvc.cgi/php-src/ext/gd/tests/truecolor.phpt?view=markup&rev=1.1 Index: php-src/ext/gd/tests/truecolor.phpt +++ php-src/ext/gd/tests/truecolor.phpt --TEST-- imageistruecolor, truecolortopalette --SKIPIF-- <?php if (!function_exists('imagetruecolortopalette')) die("skip gd extension not available\n"); ?> --FILE-- <?php $im = imagecreatetruecolor(1,1); if (imageistruecolor($im)) echo "ok\n"; if (imagetruecolortopalette($im, 1,2)) echo "ok\n"; if (!imageistruecolor($im)) echo "ok\n"; ?> --EXPECTF-- ok ok ok http://cvs.php.net/viewvc.cgi/php-src/ext/gd/tests/types.phpt?view=markup&rev=1.1 Index: php-src/ext/gd/tests/types.phpt +++ php-src/ext/gd/tests/types.phpt --TEST-- imagetypes --SKIPIF-- <?php if (!function_exists('imagetypes')) die("skip gd extension not available\n"); ?> --FILE-- <?php $flags = imagetypes(); if ($flags&0x1 && !function_exists("imagegif")) { echo "gif failed\n"; } if ($flags&0x2 && !function_exists("imagejpeg")) { echo "jpeg failed\n"; } if ($flags&0x4 && !function_exists("imagepng")) { echo "png failed\n"; } if ($flags&0x8 && !function_exists("imagewbmp")) { echo "wbmp failed\n"; } if ($flags&16 && !function_exists("imagecreatefromxpm")) { echo "xom failed\n"; } echo "ok\n"; ?> --EXPECTF-- ok
« previous php.cvs (#39312) next »