PHP 中的 imagecolortransparent() 函数
imagecolortransparent() 函数用于设置透明图像的颜色。
语法
imagecolortransparent ( img, color )
参数
img:使用 imagecreatetruecolor() 函数创建图像。
color:使用 imagecolorallocate() 创建的颜色标识符。
返回值
imagecolortransparent() 函数返回新透明颜色的标识符。如果未指定 color 且图像没有透明颜色,则返回值为 -1。
示例
以下是一个示例
<?php
$img = imagecreatetruecolor(500, 400);
$blue = imagecolorallocate($img, 0, 0, 255);
$transparent = imagecolorallocate($img, 0, 0, 0);
imagecolortransparent($img, $transparent);
imagefilledrectangle($img, 80, 90, 400, 220, $blue);
header('Content-Type: image/png');
imagepng($img);
imagedestroy($img);
?>输出
以下为输出

广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 语言
C++
C#
MongoDB
MySQL
Javascript
PHP