PHP imageantialias - Whether to use antialias functionality
imageantialias — Whether to use antialias functionality.
Syntax
bool imageantialias ( resource $image , bool $enabled )
Enables fast drawing antialiasing methods for lines and polygons. Does not support alpha components. Uses direct blending operations. Only for truecolor images.
Line widths and styles are not supported.
Using antialiasing with transparent background colors may produce unexpected results. The blending method treats the background color like any other color. The lack of alpha component support does not allow alpha-based antialiasing methods.
Parameters
- image: The image resource returned by an image creation function (e.g., imagecreatetruecolor()).
- enabled: Whether to enable antialiasing.
Return Values
Returns TRUE on success, or FALSE on failure.
Examples
<?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);
?>
The image output of the above example is as follows:
Other Extensions
PHP Image Processing