(PHP 4 >= 4.0.6, PHP 5, PHP 7, PHP 8)
imagealphablending — 設定圖像的混色模式
$image
, bool $blendmode
): bool
imagealphablending()
允許在真彩色圖像上使用兩種不同的繪畫(huà)模式。在混色(blending)模式下,alpha
通道色彩成分提供給所有的繪畫(huà)函數,例如 imagesetpixel()
決定底層的顏色應在何種程度上被允許照射透過(guò)。作為結果,GD
自動(dòng)將該點(diǎn)現有的顏色和畫(huà)筆顏色混合,并將結果儲存在圖像中。結果的像素是不透明的。在非混色模式下,畫(huà)筆顏色連同其
alpha 通道信息一起被拷貝,替換掉目標像素?;焐J皆诋?huà)調色板圖像時(shí)不可用。如果
blendmode
為 true
,則啟用混色模式,否則關(guān)閉。成功時(shí)返回 true
, 或者在失敗時(shí)返回 false
。
image
由圖象創(chuàng )建函數(例如imagecreatetruecolor())返回的 GdImage 對象。
blendmode
Whether to enable the blending mode or not. On true color images
the default value is true
otherwise the default value is false
成功時(shí)返回 true
, 或者在失敗時(shí)返回 false
。
示例 #1 imagealphablending() usage example
<?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);
?>