imagecolorexactalpha

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

imagecolorexactalpha取锟斤拷指锟斤拷锟斤拷锟斤拷色锟斤拷透锟斤拷锟饺碉拷锟斤拷锟斤拷值

说锟斤拷

imagecolorexactalpha ( 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.

锟斤拷锟斤拷值

锟斤拷锟斤拷图锟斤拷锟缴拷锟斤拷锟街革拷锟斤拷锟缴拷锟酵革拷锟斤拷鹊锟斤拷锟斤拷锟街碉拷锟� 锟斤拷锟斤拷锟缴拷锟斤拷锟酵硷拷锟侥碉拷色锟斤拷锟叫o拷锟斤拷锟斤拷 -1锟斤拷

锟斤拷锟斤拷

Example #1 Get colors from the GD logo

<?php

// Setup an image
$im imagecreatefrompng('./gdlogo.png');

$colors   = Array();
$colors[] = imagecolorexactalpha($im255000);
$colors[] = imagecolorexactalpha($im000127);
$colors[] = imagecolorexactalpha($im25525525555);
$colors[] = imagecolorexactalpha($im1002555220);

print_r($colors);

// Free from memory
imagedestroy($im);
?>

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

Array
(
    [0] => 16711680
    [1] => 2130706432
    [2] => 939524095
    [3] => 342163252
)

注锟斤拷

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

锟轿硷拷

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