nicholsr                Fri Feb  1 16:32:38 2008 UTC

  Added files:                 
    /php-src/ext/gd/tests       imagedashedline_basic.phpt gd_info_basic.phpt 
                                imagepolygon_basic.phpt 
                                imagefilledpolygon_basic.phpt 
                                imagecopyresampled_basic.phpt 
                                image_type_to_mime_type_basic.phpt 
  Log:
  - a few more gd tests (committed on behalf of andy wharmby)
  
http://cvs.php.net/viewvc.cgi/php-src/ext/gd/tests/imagedashedline_basic.phpt?view=markup&rev=1.1
Index: php-src/ext/gd/tests/imagedashedline_basic.phpt
+++ php-src/ext/gd/tests/imagedashedline_basic.phpt
--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
--UEXPECT--
Simple test of imagedashedline() function
array(4) {
  [u"red"]=>
  int(255)
  [u"green"]=>
  int(0)
  [u"blue"]=>
  int(0)
  [u"alpha"]=>
  int(0)
}
array(4) {
  [u"red"]=>
  int(0)
  [u"green"]=>
  int(0)
  [u"blue"]=>
  int(0)
  [u"alpha"]=>
  int(0)
}
Done
http://cvs.php.net/viewvc.cgi/php-src/ext/gd/tests/gd_info_basic.phpt?view=markup&rev=1.1
Index: php-src/ext/gd/tests/gd_info_basic.phpt
+++ php-src/ext/gd/tests/gd_info_basic.phpt
--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

http://cvs.php.net/viewvc.cgi/php-src/ext/gd/tests/imagepolygon_basic.phpt?view=markup&rev=1.1
Index: php-src/ext/gd/tests/imagepolygon_basic.phpt
+++ php-src/ext/gd/tests/imagepolygon_basic.phpt
--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
--UEXPECT--
Simple test of imagepolygon() function
array(4) {
  [u"red"]=>
  int(255)
  [u"green"]=>
  int(0)
  [u"blue"]=>
  int(0)
  [u"alpha"]=>
  int(0)
}
array(4) {
  [u"red"]=>
  int(0)
  [u"green"]=>
  int(0)
  [u"blue"]=>
  int(0)
  [u"alpha"]=>
  int(0)
}
Done

http://cvs.php.net/viewvc.cgi/php-src/ext/gd/tests/imagefilledpolygon_basic.phpt?view=markup&rev=1.1
Index: php-src/ext/gd/tests/imagefilledpolygon_basic.phpt
+++ php-src/ext/gd/tests/imagefilledpolygon_basic.phpt
--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
--UEXPECT--
Simple test of imagefilledpolygon() function
array(4) {
  [u"red"]=>
  int(0)
  [u"green"]=>
  int(255)
  [u"blue"]=>
  int(0)
  [u"alpha"]=>
  int(0)
}
array(4) {
  [u"red"]=>
  int(0)
  [u"green"]=>
  int(255)
  [u"blue"]=>
  int(0)
  [u"alpha"]=>
  int(0)
}
array(4) {
  [u"red"]=>
  int(0)
  [u"green"]=>
  int(0)
  [u"blue"]=>
  int(0)
  [u"alpha"]=>
  int(0)
}
Done

http://cvs.php.net/viewvc.cgi/php-src/ext/gd/tests/imagecopyresampled_basic.phpt?view=markup&rev=1.1
Index: php-src/ext/gd/tests/imagecopyresampled_basic.phpt
+++ php-src/ext/gd/tests/imagecopyresampled_basic.phpt
--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

http://cvs.php.net/viewvc.cgi/php-src/ext/gd/tests/image_type_to_mime_type_basic.phpt?view=markup&rev=1.1
Index: php-src/ext/gd/tests/image_type_to_mime_type_basic.phpt
+++ php-src/ext/gd/tests/image_type_to_mime_type_basic.phpt
--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
--UEXPECT--
Starting image_type_to_mime_type() test

unicode(9) "image/gif"
unicode(10) "image/jpeg"
unicode(9) "image/png"
unicode(29) "application/x-shockwave-flash"
unicode(9) "image/psd"
unicode(9) "image/bmp"
unicode(10) "image/tiff"
unicode(10) "image/tiff"
unicode(24) "application/octet-stream"
unicode(9) "image/jp2"
unicode(24) "application/octet-stream"
unicode(24) "application/octet-stream"
unicode(9) "image/iff"
unicode(18) "image/vnd.wap.wbmp"
unicode(24) "application/octet-stream"
unicode(9) "image/xbm"

Done image_type_to_mime_type() test
-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to