imageantialias

(PHP 4 >= 4.3.2, PHP 5, PHP 7, PHP 8)

imageantialias是否使用抗鋸齒(antialias)功能

說明

imageantialias(resource $image, bool $enabled): bool

對線段和多邊形啟用快速畫圖抗鋸齒方法。不支持 alpha 部分。使用直接混色操作。僅用于真彩色圖像。

不支持線寬和風格。

使用抗鋸齒和透明背景色可能出現未預期的結果。混色方法把背景色當成任何其它顏色使用。缺乏 alpha 部分的支持導致不允許基于 alpha 抗鋸齒方法。

參數

image

由圖象創(chuàng)建函數(例如imagecreatetruecolor())返回的 GdImage 對象。

enabled

是否啟用抗鋸齒。

返回值

成功時返回 true, 或者在失敗時返回 false

范例

示例 #1 A comparison of two lines, one with anti-aliasing switched on

<?php
// Setup an anti-aliased image and a normal image
$aa imagecreatetruecolor(400100);
$normal imagecreatetruecolor(200100);

// Switch antialiasing on for one image
imageantialias($aatrue);

// Allocate colors
$red imagecolorallocate($normal25500);
$red_aa imagecolorallocate($aa25500);

// Draw two lines, one with AA enabled
imageline($normal00200100$red);
imageline($aa00200100$red_aa);

// Merge the two images side by side for output (AA: left, Normal: Right)
imagecopymerge($aa$normal200000200100100);

// Output image
header('Content-type: image/png');

imagepng($aa);
imagedestroy($aa);
imagedestroy($normal);
?>

以上例程的輸出類似于:

Output of example : A comparison of two lines, one with anti-aliasing switched on

注釋

參見