ฟังก์ชัน imagecolortransparent() ใช้สำหรับกำหนดสีของภาพที่โปร่งใส
ไวยากรณ์
imagecolortransparent ( img, color )
พารามิเตอร์
-
img :สร้างภาพด้วยฟังก์ชัน imagecreatetruecolor()
-
สี :ตัวระบุสีที่สร้างด้วย imagecolorallocate()
คืนสินค้า
ฟังก์ชัน imagecolortransparent() จะคืนค่าตัวระบุของสีโปร่งใสใหม่ ค่าที่ส่งคืนคือ -1 หากไม่ได้ระบุสีและรูปภาพไม่มีสีโปร่งใส
ตัวอย่าง
ต่อไปนี้เป็นตัวอย่าง
<?php
$img = imagecreatetruecolor(500, 400);
$blue = imagecolorallocate($img, 0, 0, 255);
$transparent = imagecolorallocate($img, 0, 0, 0);
imagecolortransparent($img, $transparent);
imagefilledrectangle($img, 80, 90, 400, 220, $blue);
header('Content-Type: image/png');
imagepng($img);
imagedestroy($img);
?> ผลลัพธ์
ต่อไปนี้เป็นผลลัพธ์:
