PHP imageantialias - 是否使用抗鋸齒(antialias)功能
imageantialias — 是否使用抗鋸齒(antialias)功能。
語法
bool imageantialias ( resource $image , bool $enabled )
對線段和多邊形啟用快速畫圖抗鋸齒方法。不支持 alpha 部分。使用直接混色操作。僅用於真彩色圖像。
不支持線寬和風格。
使用抗鋸齒和透明背景色可能出現未預期的結果。混色方法把背景色當成任何其他顏色使用。缺乏 alpha 部分的支持導致不允許基於 alpha 抗鋸齒方法。
參數
- image: 由圖象創建函數(例如imagecreatetruecolor())返回的圖象資源。
- enabled: 是否啟用抗鋸齒。
返回值
成功時返回 TRUE, 或者在失敗時返回 FALSE。
實例
<?php // 使用抗鋸齒圖片和一個普通圖片 $aa = imagecreatetruecolor(400, 100); $normal = imagecreatetruecolor(200, 100); // 使用抗鋸齒功能 imageantialias($aa, true); // 設置顏色 $red = imagecolorallocate($normal, 255, 0, 0); $red_aa = imagecolorallocate($aa, 255, 0, 0); // 畫兩條線 imageline($normal, 0, 0, 200, 100, $red); imageline($aa, 0, 0, 200, 100, $red_aa); // 合併圖像 imagecopymerge($aa, $normal, 200, 0, 0, 0, 200, 100, 100); // 輸出圖像 header('Content-type: image/png'); imagepng($aa); imagedestroy($aa); imagedestroy($normal); ?>
以上實例輸出結果的圖片如下:
