Latest web development tutorials

PHP imageantialias - whether to use anti-aliasing (antialias) function

PHP Image Processing PHP Image Processing

imageantialias - whether to use anti-aliasing (antialias) function.

grammar

bool imageantialias ( resource $image , bool $enabled )

To enable the fast line and polygon drawing anti-aliasing methods. It does not support alpha part. Direct blending operation. Only for true color images.

It does not support line widths and styles.

Use anti-aliasing transparent background color and unexpected results may occur. The method of blending the background color to use as any other color. Lack of support leads to alpha part is not allowed based on alpha antialiasing method.

parameter

  • image: the image created by the function (for example imagecreatetruecolor ()) returns an image resource.
  • enabled: whether anti-aliasing is enabled.

return value

Successful return TRUE, or on failure returns FALSE.

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 above example of the output picture is as follows:

PHP Image Processing PHP Image Processing