这个 imagecreatetruecolor() 函数是PHP中的一个内置函数,用于创建新的真彩色图像。此函数返回给定大小的空白图像。
null
语法:
resource imagecreatetruecolor( $width, $height )
参数: 该函数接受两个参数,如下所述:
- $width: 此参数用于设置图像的宽度。
- $height: 此参数用于设置图像的高度。
返回值: 此函数在成功时返回图像资源标识符,在错误时返回False。
下面的程序说明了 imagecreatetruecolor() PHP中的函数:
项目1:
<?php // Set the vertices of polygon $values = array ( 150, 50, // Point 1 (x, y) 50, 250, // Point 2 (x, y) 250, 250 // Point 3 (x, y) ); // Create the size of image or blank image $image = imagecreatetruecolor(300, 300); // Set the background color of image $background_color = imagecolorallocate( $image , 0, 153, 0); // Fill background with above selected color imagefill( $image , 0, 0, $background_color ); // Allocate a color for the polygon $image_color = imagecolorallocate( $image , 255, 255, 255); // Draw the polygon imagepolygon( $image , $values , 3, $image_color ); // Output the picture to the browser header( 'Content-type: image/png' ); imagepng( $image ); ?> |
输出:
项目2:
<?php // Create the size of image or blank image. $image = imagecreatetruecolor(500, 300); // Display the height of image. echo imagesy( $image ); ?> |
输出:
300
相关文章:
参考: http://php.net/manual/en/function.imagecreatetruecolor.php
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END