ฟังก์ชัน imagecolorsforindex() รับสีสำหรับดัชนี
ไวยากรณ์
imagecolorsforindex ( img, index )
พารามิเตอร์
-
img :สร้างภาพด้วย imagecreatetruecolor()
-
ดัชนี :ตั้งค่าดัชนีสี
คืนสินค้า
ฟังก์ชัน imagecolorsforindex() ส่งคืนอาร์เรย์ที่เชื่อมโยงด้วยปุ่มสีแดง สีเขียว สีฟ้า และอัลฟ่าที่มีค่าที่เหมาะสมสำหรับดัชนีสีที่ระบุ
ตัวอย่าง
ต่อไปนี้เป็นตัวอย่าง
<?php
$img = imagecreatefrompng('http://www.tutorialspoint.com/images/tp-logo-diamond.png');
$x = 25;
$y = 45;
$rgb = imagecolorat($img, 25, 45);
$colors = imagecolorsforindex($img, $rgb);
var_dump($colors);
?> ผลลัพธ์
ต่อไปนี้เป็นผลลัพธ์:
array(4) { ["red"]=> int(255) ["green"]=> int(255) ["blue"]=> int(255) ["alpha"]=> int(127) }