(PHP 4 >= 4.0.6, PHP 5)
imagealphablending — 設定圖像的混色模式
說明
bool imagealphablending ( resource$image
, bool $blendmode
)
imagealphablending()
允許在真彩色圖像上使用兩種不同的繪畫模式。在混色(blending)模式下,alpha
通道色彩成分提供給所有的繪畫函數,例如 imagesetpixel()
決定底層的顏色應在何種程度上被允許照射透過。作為結果,GD
自動將該點現有的顏色和畫筆顏色混合,并將結果儲存在圖像中。結果的像素是不透明的。在非混色模式下,畫筆顏色連同其
alpha 通道信息一起被拷貝,替換掉目標像素。混色模式在畫調色板圖像時不可用。如果
blendmode
為 TRUE
,則啟用混色模式,否則關閉。成功時返回 TRUE
, 或者在失敗時返回 FALSE
。
Note: 此函數需要 GD 2.0.1 或更高版本(推薦 2.0.28 及更高版本)。
參數
image
由圖象創建函數(例如imagecreatetruecolor())返回的圖象資源。
blendmode
Whether to enable the blending mode or not. On true color images
the default value is TRUE
otherwise the default value is FALSE
返回值
成功時返回 TRUE
, 或者在失敗時返回 FALSE
。
范例
Example #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);
?>
注釋
Note: 此函數需要 GD 2.0.1 或更高版本(推薦 2.0.28 及更高版本)。