PHP imagecolorresolvealpha - Get the index of the specified color + alpha or its closest possible alternative values
imagecolorresolvealpha - Get the index of the specified color + alpha or its closest possible alternative values.
grammar
int imagecolorresolvealpha ( resource $image , int $red , int $green , int $blue , int $alpha )
This function ensures that the color of the requested return a color index, either the exact value can either get the closest substitute value.
Note: This function requires GD 2.0.1 or later (2.0.28 or later recommended).
parameter
- image created by the image function (for example imagecreatetruecolor ()) image resource returned.
- valuered red component.
- green value for the green component.
- blue blue component value.
- alpha a value of between 0 and 127.0 means completely opaque, 127 means completely transparent.
Color parameter is an integer between 0 and 255, or between a hexadecimal number between 0x00 and 0xFF.
return value
Returns a color index.
Examples
Get color from the logo in this tutorial.
<?php // 创建图像 $im = imagecreatefrompng('w3big-logo.png'); // 从图像中获取最接近的颜色 $colors = array(); $colors[] = imagecolorresolvealpha($im, 255, 255, 255, 0); $colors[] = imagecolorresolvealpha($im, 0, 0, 200, 127); // 输出 print_r($colors); imagedestroy($im); ?>
Output similar to the above example:
Array ( [0] => 16777215 [1] => 2130706632 )
related articles
- imagecolorclosestalpha () to obtain the specified color + alpha closest color.