« imageaffinematrixget
imageantialias »

imagealphablending

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

imagealphablending — イメージのブレンドモードを設定する

説明

function imagealphablending(GdImage $image, bool $enable): true

imagealphablending() によりTrueColorイメージに 二つの異なる描画モードを使用可能となります。ブレンドモードでは、 全ての描画関数に指定される色のalphaチャネル要素として使用され、 例えばimagesetpixel()では背景色の透過割合を定 義します。結果として、gd は描画色に関してその点に存在する色を自動 的にブレンドし、イメージに結果を保存します。結果のピクセルは、透 明になります。ブレンドモードでない場合、描画色は形式的にそのアル ファチャネル情報にコピーされ、出力ピクセルを置換します。ブレンド モードは、パレットイメージを描画している際には使用できません。

パラメータ

image

imagecreatetruecolor()のような画像作成関数が返す GdImage オブジェクト。

enable

ブレンドモードを有効にするかどうか。True Color 画像の場合のデフォルトは true、それ以外の場合のデフォルトは false です。

戻り値

常に true を返します。

変更履歴

バージョン 説明
8.0.0 image は、 GdImage クラスのインスタンスを期待するようになりました。 これより前のバージョンでは、有効な gd resource が期待されていました。

例

例1 imagealphablending() の使用例

<?php
// 画像を作成します
$im = imagecreatetruecolor(100, 100);

// アルファブレンディングをオンにします
imagealphablending($im, true);

// 正方形を描画します
imagefilledrectangle($im, 30, 30, 70, 70, imagecolorallocate($im, 255, 0, 0));

// 出力します
header('Content-Type: image/png');

imagepng($im);
?>
関連キーワード:
ブレンド   モード   イメージ   imagealphablending   描画   image   GdImage   画像   enable   ピクセル   imagecreatetruecolor   期待   imageaffinematrixget   imageantialias   Image   TrueColor   alpha   チャネル   imagesetpixel   背景色   透過   割合   形式的   ファチャネル   コピー
関連する関数・ページ:
function.imagecreatetruecolor   ref.image   book.image   function.imageantialias   function.imagecolormatch   function.imagetruecolortopalette