imagealphablending

(PHP 4 >= 4.0.6, PHP 5, PHP 7)

imagealphablending设定图像的混色模式

说明

imagealphablending ( resource $image , bool $blendmode ) : bool

imagealphablending() 允许在真彩色图像上使用两种不同的绘画模式。在混色(blending)模式下,alpha 通道色彩成分提供给所有的绘画函数,例如 imagesetpixel() 决定底层的颜色应在何种程度上被允许照射透过。作为结果,GD 自动将该点现有的颜色和画笔颜色混合,并将结果储存在图像中。结果的像素是不透明的。在非混色模式下,画笔颜色连同其 alpha 通道信息一起被拷贝,替换掉目标像素。混色模式在画调色板图像时不可用。如果 blendmodeTRUE,则启用混色模式,否则关闭。成功时返回 TRUE, 或者在失败时返回 FALSE

Note: 此函数需要 GD 2.0.1 或更高版本(推荐 2.0.28 及更高版本)。

参数

image

由图象创建函数(例如imagecreatetruecolor())返回的图象资源。

blendmode

Whether to enable the blending mode or not. On true color images the default value is TRUE otherwise the default value is FALSE

返回值

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

范例

Example #1 imagealphablending() usage example

<?php
// Create image
$im imagecreatetruecolor(100100);

// Set alphablending to on
imagealphablending($imtrue);

// Draw a square
imagefilledrectangle($im30307070imagecolorallocate($im25500));

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

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

注释

Note: 此函数需要 GD 2.0.1 或更高版本(推荐 2.0.28 及更高版本)。

相关文章
php gd 和图像处理 函数 从字符串中获取图像尺寸信息php gd 和图像处理 函数 取得图像类型的文件后缀php gd 和图像处理 函数 取得 getimagesize,exif read data,exif thumbnail,exif imagetype 所返回的图像类型的 mime 类型php gd 和图像处理 函数 设定图像的混色模式php gd 和图像处理 函数 为一幅图像分配颜色 + alphaphp gd 和图像处理 函数 拷贝图像的一部分php gd 和图像处理 函数 拷贝并合并图像的一部分php gd 和图像处理 函数 用灰度拷贝并合并图像的一部分php gd 和图像处理 函数 重采样拷贝部分图像并调整大小php gd 和图像处理 函数 拷贝部分图像并调整大小php gd 和图像处理 函数 新建一个真彩色图像php gd 和图像处理 函数 使用 freetype 2 字体将文本写入图像php gd 和图像处理 函数 将调色板从一幅图像拷贝到另一幅php gd 和图像处理 函数 设置标记以在保存 png 图像时保存完整的 alpha 通道信息(与单一透明色相反)php gd 和图像处理 函数 设定画线用的画笔图像php gd 和图像处理 函数 返回当前 php 版本所支持的图像类型php gd 和图像处理 函数 以 wbmp 格式将图像输出到浏览器或文件php gd 和图像处理 函数 将 webp 格式的图像输出到浏览器或文件php gd 和图像处理 函数 将 xbm 图像输出到浏览器或文件php gd 和图像处理 函数 将 png 图像文件转换为 wbmp 图像文件
关注编程学问公众号