array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'function.imagealphablending.php', 1 => 'imagealphablending', ), 'up' => array ( 0 => 'ref.image.php', 1 => 'GD 和图像处理 函数', ), 'prev' => array ( 0 => 'function.imageaffinematrixget.php', 1 => 'imageaffinematrixget', ), 'next' => array ( 0 => 'function.imageantialias.php', 1 => 'imageantialias', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'zh', 'path' => 'reference/image/functions/imagealphablending.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 4 >= 4.0.6, PHP 5, PHP 7, PHP 8)
imagealphablending — 设定图像的混色模式
imagealphablending()
允许在真彩色图像上使用两种不同的绘画模式。在混色(blending)模式下,alpha
通道色彩成分提供给所有的绘画函数,例如 imagesetpixel()
决定底层的颜色应在何种程度上被允许照射透过。作为结果,GD
自动将该点现有的颜色和画笔颜色混合,并将结果储存在图像中。结果的像素是不透明的。在非混色模式下,画笔颜色连同其
alpha 通道信息一起被拷贝,替换掉目标像素。混色模式在画调色板图像时不可用。如果
blendmode
为 true
,则启用混色模式,否则关闭。成功时返回 true
, 或者在失败时返回 false
。
示例 #1 imagealphablending() 用法示例
<?php
// Create image
$im = imagecreatetruecolor(100, 100);
// Set alphablending to on
imagealphablending($im, true);
// Draw a square
imagefilledrectangle($im, 30, 30, 70, 70, imagecolorallocate($im, 255, 0, 0));
// Output
header('Content-Type: image/png');
imagepng($im);
imagedestroy($im);
?>