这个 imagecolorset() 函数是PHP中的一个内置函数,用于为指定的调色板索引设置颜色。它用于将调色板中的索引指定为指定的颜色。要执行实际的整体填充,在托盘图像中创建类似整体填充的效果非常有用,而不需要额外的开销。 语法:
null
void imagecolorset ( $image, $index, $red, $green, $blue, $alpha )
参数: 此函数接受六个参数,如下所述:
- $image: 它由图像创建函数之一返回,例如 imagecreatetruecolor() .它用于创建图像的大小。
- $index: 此参数是调色板图像中的索引值。
- $red: 此参数用于设置红色分量的值。
- $green: 此参数用于设置绿色分量的值。
- $blue: 此参数用于设置蓝色组件的值。
- $alpha: 此参数用于设置图像的透明度。$alpha的值介于0到127之间,其中0表示完全不透明,而127表示完全透明。
返回值: 此函数不返回任何值。 下面的程序说明了 imagecolorset() PHP中的函数: 项目1:
php
<?php // Create an image of given size $image = imagecreate(500, 300); // Set the background imagecolorallocate( $image , 0, 0, 0); // Get the color index for the background $bg = imagecolorat( $image , 150, 100); // Change the background color imagecolorset( $image , $bg , 0, 153, 0); // Output of the image header( 'Content-Type: image/png' ); imagepng( $image ); imagedestroy( $image ); ?> |
输出:
项目2:
php
<?php // Create an image of given size $image = imagecreate(500, 300); // Set the background imagecolorallocate( $image , 0, 0, 0); // set the colors of image $white_color = imagecolorallocate( $image , 255, 255, 255); // draw the head imagearc( $image , 200, 150, 200, 200, 0, 360, $white_color ); // Get the color index for the background $bg = imagecolorat( $image , 150, 100); // Set the background imagecolorset( $image , $bg , 0, 153, 0); // Output the image to the browser header( 'Content-Type: image/png' ); imagepng( $image ); imagedestroy( $image ); ?> |
输出:
相关文章:
参考: http://php.net/manual/en/function.imagecolorset.php
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END