Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> PHP

Hàm imagecolorresolvealpha() trong PHP

imagecolorresolvealpha() giống imagecolorresolve() nhưng có thêm tham số alpha (độ trong suốt).

Cú pháp

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

Tham số

  • alpha: 0 (đặc) đến 127 (hoàn toàn trong suốt).

Ví dụ

<?php
$img = imagecreatefromgif('https://example.com/image.gif');
$colors[] = imagecolorresolvealpha($img, 120, 0, 190, 0);
$colors[] = imagecolorresolvealpha($img, 110, 0, 140, 0);
$colors[] = imagecolorresolvealpha($img, 120, 190, 0, 0);
print_r($colors); // Array([0]=>128 [1]=>129 [2]=>130)
imagedestroy($img);
?>