imagecolorresolvealpha

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

imagecolorresolvealpha 取锟斤拷指锟斤拷锟斤拷色 + alpha 锟斤拷锟斤拷锟斤拷值锟斤拷锟叫匡拷锟杰得碉拷锟斤拷锟斤拷咏锟斤拷锟斤拷锟斤拷值

说锟斤拷

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

锟斤拷锟斤拷锟斤拷锟斤拷锟皆憋拷证锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟缴拷锟斤拷锟揭伙拷锟斤拷锟缴拷锟斤拷锟斤拷锟揭达拷锟饺凤拷锟街狄达拷锟斤拷锟斤拷艿玫锟斤拷锟接斤拷锟斤拷锟斤拷锟街碉拷锟�

锟斤拷锟斤拷

image

锟斤拷图锟襟创斤拷锟斤拷锟斤拷(锟斤拷锟斤拷imagecreatetruecolor())锟斤拷锟截碉拷图锟斤拷锟斤拷源锟斤拷

red

锟斤拷色锟缴分碉拷值锟斤拷

green

锟斤拷色锟缴分碉拷值锟斤拷

blue

锟斤拷色锟缴分碉拷值锟斤拷

alpha

A value between 0 and 127. 0 indicates completely opaque while 127 indicates completely transparent.

The colors parameters are integers between 0 and 255 or hexadecimals between 0x00 and 0xFF.

锟斤拷锟斤拷值

Returns a color index.

锟斤拷锟斤拷

Example #1 Using imagecoloresolvealpha() to get colors from an image

<?php
// Load an image
$im imagecreatefromgif('phplogo.gif');

// Get closest colors from the image
$colors = array();
$colors[] = imagecolorresolvealpha($im2552552550);
$colors[] = imagecolorresolvealpha($im00200127);

// Output
print_r($colors);

imagedestroy($im);
?>

锟斤拷锟斤拷锟斤拷锟教碉拷锟斤拷锟斤拷锟斤拷锟斤拷冢锟�

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

注锟斤拷

Note: 锟剿猴拷锟斤拷锟斤拷要 GD 2.0.1 锟斤拷锟斤拷甙姹�(锟狡硷拷 2.0.28 锟斤拷锟斤拷锟竭版本)锟斤拷

锟轿硷拷

  • imagecolorclosestalpha() - 取锟斤拷锟斤拷指锟斤拷锟斤拷锟斤拷色锟斤拷透锟斤拷锟斤拷锟斤拷咏锟斤拷锟斤拷锟缴�