update page now
Laravel Live Japan

imagecolorresolvealpha

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

imagecolorresolvealpha指定した色+アルファ値または最も近い色のインデックスを取得する

説明

imagecolorresolvealpha(
    GdImage $image,
    int $red,
    int $green,
    int $blue,
    int $alpha
): int

この関数は、指定した色のインデックスを必ず返します。そうでない場合、 正確な色または最も近い別の色のどちらかを返します。

パラメータ

image

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

red

赤コンポーネントの値。

green

緑コンポーネントの値。

blue

青コンポーネントの値。

alpha

0 から 127 までの値。 0 は完全に不透明な状態。 127 は完全に透明な状態を表します。

色のパラメータは、0 から 255 までの整数値か 0x00 から 0xFF までの十六進値を指定します。

戻り値

色インデックスを返します。

変更履歴

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

例1 imagecoloresolvealpha() による画像からの色の取得

<?php
/ 画像を読み込みます
$im = imagecreatefromgif('phplogo.gif');

/ 最も近い色を画像から取得します
$colors = array();
$colors[] = imagecolorresolvealpha($im, 255, 255, 255, 0);
$colors[] = imagecolorresolvealpha($im, 0, 0, 200, 127);

/ 出力します
print_r($colors);
?>

上の例の出力は、 たとえば以下のようになります。

Array
(
    [0] => 89
    [1] => 85
)

参考

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top

Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant