= 4.0.6, PHP 5, PHP 7, PHP 8)imagealphablending — 設(shè)定圖像的混色模式說明imagealphablending(resource $image, bool $blendmode): boolimage">

imagealphablending

(PHP 4 >= 4.0.6, PHP 5, PHP 7, PHP 8)

imagealphablending設(shè)定圖像的混色模式

說明

imagealphablending(resource $image, bool $blendmode): bool

imagealphablending() 允許在真彩色圖像上使用兩種不同的繪畫模式。在混色(blending)模式下,alpha 通道色彩成分提供給所有的繪畫函數(shù),例如 imagesetpixel() 決定底層的顏色應(yīng)在何種程度上被允許照射透過。作為結(jié)果,GD 自動將該點(diǎn)現(xiàn)有的顏色和畫筆顏色混合,并將結(jié)果儲存在圖像中。結(jié)果的像素是不透明的。在非混色模式下,畫筆顏色連同其 alpha 通道信息一起被拷貝,替換掉目標(biāo)像素。混色模式在畫調(diào)色板圖像時不可用。如果 blendmodetrue,則啟用混色模式,否則關(guān)閉。成功時返回 true, 或者在失敗時返回 false。

參數(shù)

image

由圖象創(chuàng)建函數(shù)(例如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

返回值

成功時返回 true, 或者在失敗時返回 false

范例

示例 #1 imagealphablending() usage example

<?php
// Create image
$im imagecreatetruecolor(100100);

// Set alphablending to on
imagealphablending($imtrue);

// Draw a square
imagefilledrectangle($im30307070imagecolorallocate($im25500));

// Output
header('Content-type: image/png');

imagepng($im);
imagedestroy($im);
?>

注釋