diff options
| author | Mark A. Hershberger <mah@debian.(none)> | 2009-03-25 00:39:08 -0400 |
|---|---|---|
| committer | Mark A. Hershberger <mah@debian.(none)> | 2009-03-25 00:39:08 -0400 |
| commit | 993e1866df547532a05ab6db76c9ff5aefc9a3df (patch) | |
| tree | 169d3bde0974235d3cde164786ef6f381a4749a7 /ext/gd/tests | |
| parent | 1f589a2bd44ba835ad1b009a5d83abd453724829 (diff) | |
| download | php-upstream/5.2.6.tar.gz | |
Imported Upstream version 5.2.6upstream/5.2.6
Diffstat (limited to 'ext/gd/tests')
| -rw-r--r-- | ext/gd/tests/gd_info_basic.phpt | 29 | ||||
| -rw-r--r-- | ext/gd/tests/image_type_to_mime_type_basic.phpt | 64 | ||||
| -rw-r--r-- | ext/gd/tests/imagecopyresampled_basic.phpt | 71 | ||||
| -rw-r--r-- | ext/gd/tests/imagedashedline_basic.phpt | 78 | ||||
| -rw-r--r-- | ext/gd/tests/imagefilledpolygon_basic.phpt | 102 | ||||
| -rw-r--r-- | ext/gd/tests/imagepolygon_basic.phpt | 80 |
6 files changed, 424 insertions, 0 deletions
diff --git a/ext/gd/tests/gd_info_basic.phpt b/ext/gd/tests/gd_info_basic.phpt new file mode 100644 index 000000000..61a2304e8 --- /dev/null +++ b/ext/gd/tests/gd_info_basic.phpt @@ -0,0 +1,29 @@ +--TEST-- +gd_info() +--SKIPIF-- +<?php + if (!function_exists('gd_info')) { + die('skip gd_info() not available'); + } +?> +--FILE-- +<?php + +/* Prototype : array gd_info ( void ) + * Description: Retrieve information about the currently installed GD library + * Source code: ext/standard/image.c + * Alias to functions: + */ + echo "basic test of gd_info() function\n"; + + var_dump(gd_info()); + + echo "\nDone\n"; +?> +--EXPECTF-- +basic test of gd_info() function +array(%d) { +%a +} + +Done diff --git a/ext/gd/tests/image_type_to_mime_type_basic.phpt b/ext/gd/tests/image_type_to_mime_type_basic.phpt new file mode 100644 index 000000000..7384c4632 --- /dev/null +++ b/ext/gd/tests/image_type_to_mime_type_basic.phpt @@ -0,0 +1,64 @@ +--TEST-- +image_type_to_mime_type() +--SKIPIF-- +<?php + if (!function_exists('image_type_to_mime_type')) die('skip image_type_to_mime_type() not available'); + require_once('skipif_imagetype.inc'); +?> +--FILE-- +<?php + +/* Prototype : string image_type_to_mime_type ( int $imagetype ) + * Description: Get Mime-Type for image-type returned by getimagesize, exif_read_data, exif_thumbnail, exif_imagetype. + * Source code: ext/standard/image.c + * Alias to functions: + */ + +echo "Starting image_type_to_mime_type() test\n\n"; + +$image_types = array ( + IMAGETYPE_GIF, + IMAGETYPE_JPEG, + IMAGETYPE_PNG, + IMAGETYPE_SWF, + IMAGETYPE_PSD, + IMAGETYPE_BMP, + IMAGETYPE_TIFF_II, + IMAGETYPE_TIFF_MM, + IMAGETYPE_JPC, + IMAGETYPE_JP2, + IMAGETYPE_JPX, + IMAGETYPE_JB2, + IMAGETYPE_IFF, + IMAGETYPE_WBMP, + IMAGETYPE_JPEG2000, + IMAGETYPE_XBM +); + + foreach($image_types as $image_type) { + var_dump(image_type_to_mime_type($image_type)); + } + +echo "\nDone image_type_to_mime_type() test\n"; +?> +--EXPECT-- +Starting image_type_to_mime_type() test + +string(9) "image/gif" +string(10) "image/jpeg" +string(9) "image/png" +string(29) "application/x-shockwave-flash" +string(9) "image/psd" +string(9) "image/bmp" +string(10) "image/tiff" +string(10) "image/tiff" +string(24) "application/octet-stream" +string(9) "image/jp2" +string(24) "application/octet-stream" +string(24) "application/octet-stream" +string(9) "image/iff" +string(18) "image/vnd.wap.wbmp" +string(24) "application/octet-stream" +string(9) "image/xbm" + +Done image_type_to_mime_type() test
\ No newline at end of file diff --git a/ext/gd/tests/imagecopyresampled_basic.phpt b/ext/gd/tests/imagecopyresampled_basic.phpt new file mode 100644 index 000000000..12ac15511 --- /dev/null +++ b/ext/gd/tests/imagecopyresampled_basic.phpt @@ -0,0 +1,71 @@ +--TEST-- +imagecopyresampled() +--SKIPIF-- +<?php + if (!function_exists('imagecopyresampled')) die('skip imagecopyresampled() not available'); + require_once('skipif_imagetype.inc'); +?> +--FILE-- +<?php + +/* Prototype : bool imagecopyresampled ( resource $dst_image , resource $src_image , int $dst_x , int $dst_y , int $src_x , int $src_y , int $dst_w , int $dst_h , int $src_w , int $src_h ) + * Description: Copy and resize part of an image with resampling. + * Source code: ext/standard/image.c + * Alias to functions: + */ + +echo "Simple test of imagecopyresampled() function\n"; + +$dest_lge = dirname(realpath(__FILE__)) . '/imagelarge.png'; +$dest_sml = dirname(realpath(__FILE__)) . '/imagesmall.png'; + +// create a blank image +$image_lge = imagecreatetruecolor(400, 300); + +// set the background color to black +$bg = imagecolorallocate($image_lge, 0, 0, 0); + +// fill polygon with blue +$col_ellipse = imagecolorallocate($image_lge, 0, 255, 0); + +// draw the eclipse +imagefilledellipse($image_lge, 200, 150, 300, 200, $col_ellipse); + +// output the picture to a file +imagepng($image_lge, $dest_lge); + +// Get new dimensions +$percent = 0.5; // new image 50% of orginal +list($width, $height) = getimagesize($dest_lge); +echo "Size of orginal: width=". $width . " height=" . $height . "\n"; + +$new_width = $width * $percent; +$new_height = $height * $percent; + +// Resample +$image_sml = imagecreatetruecolor($new_width, $new_height); +imagecopyresampled($image_sml, $image_lge, 0, 0, 0, 0, $new_width, $new_height, $width, $height); + +imagepng($image_sml, $dest_sml); + +list($width, $height) = getimagesize($dest_sml); +echo "Size of copy: width=". $width . " height=" . $height . "\n"; + +imagedestroy($image_lge); +imagedestroy($image_sml); + + +echo "Done\n"; +?> +--CLEAN-- +<?php + $dest_lge = dirname(realpath(__FILE__)) . '/imagelarge.png'; + $dest_sml = dirname(realpath(__FILE__)) . '/imagesmall.png'; + @unlink($dest_lge); + @unlink($dest_sml); +?> +--EXPECT-- +Simple test of imagecopyresampled() function +Size of orginal: width=400 height=300 +Size of copy: width=200 height=150 +Done diff --git a/ext/gd/tests/imagedashedline_basic.phpt b/ext/gd/tests/imagedashedline_basic.phpt new file mode 100644 index 000000000..1d6797520 --- /dev/null +++ b/ext/gd/tests/imagedashedline_basic.phpt @@ -0,0 +1,78 @@ +--TEST-- +imagedashedline() +--SKIPIF-- +<?php + if (!function_exists('imagedashedline')) die('skip imagedashedline() not available'); + require_once('skipif_imagetype.inc'); +?> +--FILE-- +<?php + +/* Prototype : bool imagedashedline ( resource $image , int $x1 , int $y1 , int $x2 , int $y2 , int $color ) + * Description: Draws a dashed line. + * This function is deprecated. Use combination of imagesetstyle() and imageline() instead. + * Source code: ext/standard/image.c + * Alias to functions: + */ + + +echo "Simple test of imagedashedline() function\n"; + +$dest = dirname(realpath(__FILE__)) . '/imagedashedline.png'; + +// create a blank image +$image = imagecreatetruecolor(250, 250); + +// set the background color to black +$bg = imagecolorallocate($image, 0, 0, 0); + +// red dashed lines +$col_line = imagecolorallocate($image, 255, 0, 0); + +// draw a couple of vertical dashed lines +imagedashedline($image, 100, 20, 100, 230, $col_line ); +imagedashedline($image, 150, 20, 150, 230, $col_line ); + +// output the picture to a file +imagepng($image, $dest); + +//check color of a point on edge.. +$col1 = imagecolorat($image, 100, 230); +// ..and a point on background +$col2 = imagecolorat($image, 5, 5); + +$color1 = imagecolorsforindex($image, $col1); +$color2 = imagecolorsforindex($image, $col2); +var_dump($color1, $color2); + +imagedestroy($image); +echo "Done\n"; +?> +--CLEAN-- +<?php + $dest = dirname(realpath(__FILE__)) . '/imagedashedline.png'; + @unlink($dest); +?> +--EXPECT-- +Simple test of imagedashedline() function +array(4) { + ["red"]=> + int(255) + ["green"]=> + int(0) + ["blue"]=> + int(0) + ["alpha"]=> + int(0) +} +array(4) { + ["red"]=> + int(0) + ["green"]=> + int(0) + ["blue"]=> + int(0) + ["alpha"]=> + int(0) +} +Done diff --git a/ext/gd/tests/imagefilledpolygon_basic.phpt b/ext/gd/tests/imagefilledpolygon_basic.phpt new file mode 100644 index 000000000..6871a28b7 --- /dev/null +++ b/ext/gd/tests/imagefilledpolygon_basic.phpt @@ -0,0 +1,102 @@ +--TEST-- +imagefilledpolygon() +--SKIPIF-- +<?php + if (!function_exists('imagefilledpolygon')) die('skip imagefilledpolygon() not available'); + require_once('skipif_imagetype.inc'); +?> +--FILE-- +<?php + +/* Prototype : bool imagefilledpolygon ( resource $image , array $points , int $num_points , int $color ) + * Description: Draws a filled polygon. + * Source code: ext/standard/image.c + * Alias to functions: + */ + +echo "Simple test of imagefilledpolygon() function\n"; + +$dest = dirname(realpath(__FILE__)) . '/imagefilledpolygon.png'; + +$points = array( + 40, 50, + 20, 240, + 60, 60, + 240, 20, + 50, 40, + 10, 10 + ); + +// create a blank image +$image = imagecreatetruecolor(250, 250); + +// set the background color to black +$bg = imagecolorallocate($image, 0, 0, 0); + +// fill polygon with green +$col_poly = imagecolorallocate($image, 0, 255, 0); + +// draw the polygon +imagefilledpolygon($image, $points, count($points)/2, $col_poly); + +// output the picture to a file +imagepng($image, $dest); + +// get it back +$image_in = imagecreatefrompng($dest); + +//check color of a point on edge.. +$col1 = imagecolorat($image_in, 40, 50); +//.. a point in filled body +$col2 = imagecolorat($image_in, 15, 15); +// ..and a point on background +$col3 = imagecolorat($image_in, 5, 5); + +$color1 = imagecolorsforindex($image_in, $col1); +$color2 = imagecolorsforindex($image_in, $col2); +$color3 = imagecolorsforindex($image_in, $col3); +var_dump($color1, $color2, $color3); + +imagedestroy($image); +imagedestroy($image_in); + +echo "Done\n"; +?> +--CLEAN-- +<?php + $dest = dirname(realpath(__FILE__)) . '/imagefilledpolygon.png'; + @unlink($dest); +?> +--EXPECT-- +Simple test of imagefilledpolygon() function +array(4) { + ["red"]=> + int(0) + ["green"]=> + int(255) + ["blue"]=> + int(0) + ["alpha"]=> + int(0) +} +array(4) { + ["red"]=> + int(0) + ["green"]=> + int(255) + ["blue"]=> + int(0) + ["alpha"]=> + int(0) +} +array(4) { + ["red"]=> + int(0) + ["green"]=> + int(0) + ["blue"]=> + int(0) + ["alpha"]=> + int(0) +} +Done diff --git a/ext/gd/tests/imagepolygon_basic.phpt b/ext/gd/tests/imagepolygon_basic.phpt new file mode 100644 index 000000000..5c79cdf5b --- /dev/null +++ b/ext/gd/tests/imagepolygon_basic.phpt @@ -0,0 +1,80 @@ +--TEST-- +imageploygon() +--SKIPIF-- +<?php + if (!function_exists('imagepolygon')) die('skip imagepolygon() not available'); + require_once('skipif_imagetype.inc'); +?> +--FILE-- +<?php + +/* Prototype : bool imagepolygon ( resource $image , array $points , int $num_points , int $color ) + * Description: Draws a polygon. + * Source code: ext/standard/image.c + * Alias to functions: + */ + + +echo "Simple test of imagepolygon() function\n"; + +$dest = dirname(realpath(__FILE__)) . '/imagepolygon.png'; + +// create a blank image +$image = imagecreatetruecolor(400, 300); + +// set the background color to black +$bg = imagecolorallocate($image, 0, 0, 0); + +// draw a red polygon +$col_poly = imagecolorallocate($image, 255, 0, 0); + +// draw the polygon +imagepolygon($image, array ( + 0, 0, + 100, 200, + 300, 200 + ), + 3, + $col_poly); + +// output the picture to a file +imagepng($image, $dest); + +$col1 = imagecolorat($image, 100, 200); +$col2 = imagecolorat($image, 100, 100); +$color1 = imagecolorsforindex($image, $col1); +$color2 = imagecolorsforindex($image, $col2); +var_dump($color1, $color2); + +imagedestroy($image); + +echo "Done\n"; +?> +--CLEAN-- +<?php + $dest = dirname(realpath(__FILE__)) . '/imagepolygon.png'; + @unlink($dest); +?> +--EXPECT-- +Simple test of imagepolygon() function +array(4) { + ["red"]=> + int(255) + ["green"]=> + int(0) + ["blue"]=> + int(0) + ["alpha"]=> + int(0) +} +array(4) { + ["red"]=> + int(0) + ["green"]=> + int(0) + ["blue"]=> + int(0) + ["alpha"]=> + int(0) +} +Done |
