How to implement anti-aliasing in php: First create a PHP sample file; then implement the anti-aliasing function through the "imageantialias($aa, true);" method.
#The operating environment of this article: Windows7 system, PHP7.1, Dell G3 computer.
PHP imageantialias - Whether to use antialiasing (antialias) function
Syntax
bool imageantialias ( resource $image , bool $enabled )
Enable fast drawing antialiasing method for line segments and polygons. The alpha part is not supported. Use direct color mixing operations. For true color images only.
Line width and style are not supported.
Using anti-aliasing and transparent background colors may produce unexpected results. The color blending method treats the background color as if it were any other color. Lack of support for the alpha part results in alpha-based antialiasing methods being disallowed.
Parameters
image: The image resource returned by the image creation function (such as imagecreatetruecolor()).
enabled: Whether to enable anti-aliasing.
Return value
Returns TRUE on success, or FALSE on failure.
[Recommended learning: "PHP Video Tutorial"]
Example
<?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 picture of the output result of the above example is as follows:
The above is the detailed content of How to achieve anti-aliasing in php. For more information, please follow other related articles on the PHP Chinese website!