PHP imagealphablending - 设定图像的混色模式

PHP 教程 · 2019-01-31 08:43:30

imagealphablending — 设定图像的混色模式。

语法

bool imagealphablending ( resource $image , bool $blendmode )

imagealphablending() 允许在真彩色图像上使用两种不同的绘画模式。

在混色(blending)模式下,alpha 通道色彩成分提供给所有的绘画函数,例如 imagesetpixel() 决定底层的颜色应在何种程度上被允许照射透过。作为结果,GD 自动将该点现有的颜色和画笔颜色混合,并将结果储存在图像中。结果的像素是不透明的。

在非混色模式下,画笔颜色连同其 alpha 通道信息一起被拷贝,替换掉目标像素。混色模式在画调色板图像时不可用。

如果 blendmode 为 TRUE,则启用混色模式,否则关闭。成功时返回 TRUE, 或者在失败时返回 FALSE。

参数

  • image 由图象创建函数(例如imagecreatetruecolor())返回的图象资源。
  • blendmode 不管是否启用混色模式。真彩色图像默认为 True, 否则为 FALSE。

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE。

实例

<?php
//  创建图像
$im = imagecreatetruecolor(100, 100);

// 启用混色模式
imagealphablending($im, true);

// 画一个正方形
imagefilledrectangle($im, 30, 30, 70, 70, imagecolorallocate($im, 255, 0, 0));

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

imagepng($im);
imagedestroy($im);
?>

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

查看所有标签

Fluent Python

Fluent Python

Luciano Ramalho / O'Reilly Media / 2015-8-20 / USD 39.99

Learn how to write idiomatic, effective Python code by leveraging its best features. Python's simplicity quickly lets you become productive with it, but this often means you aren’t using everything th......一起来看看 《Fluent Python》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

MD5 加密
MD5 加密

MD5 加密工具

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

UNIX 时间戳转换