PHP imageantialias - 是否使用抗锯齿(antialias)功能

PHP 教程 · 2019-01-31 08:56:48

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);
?>

以上实例输出结果的图片如下:

点击查看所有 PHP 教程 文章: https://www.codercto.com/courses/l/5.html

查看所有标签

亮剑.NET

亮剑.NET

2009-3 / 55.00元

《亮剑.NET:SharePoint Server 2007开发实战》共分为8章,详细讲解了SharePoint上常见的开发任务,讲述了各种开发场景下需要了解的知识,并提供了丰富的实例。《亮剑.NET:SharePoint Server 2007开发实战》第1章为基础知识,讲述SharePoint的基本概念,基本的对象模型,代码编写注意事项,并讲解了一个集开发和部署打包为一体的项目结构的创建;第2......一起来看看 《亮剑.NET》 这本书的介绍吧!

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换