ฟังก์ชัน imagecolorresolvealpha() หา index ของสีที่ระบุพร้อมค่า alpha (ความโปร่งใส)
ไวยากรณ์
imagecolorresolvealpha (img, red, green, blue, alpha)
พารามิเตอร์
- img: ภาพจาก imagecreatetruecolor()
- red: สีแดง
- green: สีเขียว
- blue: สีน้ำเงิน
- alpha: 0-127 (0 = โปร่งใสเต็มที่, 127 = ทึบเต็มที่)
คืนค่า
Color index
ตัวอย่าง
<?php
$img = imagecreatefromgif('https://www.tutorialspoint.com/images/html.gif');
$colors = array();
$colors[] = imagecolorresolvealpha($img, 120, 0, 190, 0);
$colors[] = imagecolorresolvealpha($img, 110, 0, 140, 0);
$colors[] = imagecolorresolvealpha($img, 120, 190, 0, 0);
print_r($colors);
imagedestroy($img);
?>
ผลลัพธ์
Array ( [0] => 128 [1] => 129 [2] => 130 )