ฟังก์ชัน imageantialias() ใช้เปิด/ปิด และตรวจสอบสถานะ anti-aliasing สำหรับการวาดเส้นและ polygon แบบ wireframe ทำงานได้เฉพาะ true-color images ไม่รองรับ alpha component
รูปแบบการใช้งาน (Syntax)
bool imageantialias(GdImage $image, bool $enabled)
พารามิเตอร์
- $image – GdImage object จาก imagecreatetruecolor()
- $enabled – true เพื่อเปิด anti-aliasing, false เพื่อปิด
ค่าที่คืนกลับ
คืน true เมื่อสำเร็จ false เมื่อล้มเหลว
ตัวอย่าง: เปรียบเทียบ Anti-aliased vs Normal
<?php
$img = imagecreatetruecolor(700, 300);
$normal = imagecreatetruecolor(700, 300);
imageantialias($img, true);
$blue = imagecolorallocate($normal, 0, 0, 255);
$blue_aa = imagecolorallocate($img, 0, 0, 255);
imageline($normal, 0, 0, 400, 200, $blue);
imageline($img, 0, 0, 400, 200, $blue_aa);
imagecopymerge($img, $normal, 400, 0, 0, 0, 400, 200, 200);
header('Content-type: image/png');
imagepng($img);
imagedestroy($img);
imagedestroy($normal);
?>
ผลลัพธ์
