超越PHP PHP动态 | 经典文章 | CLASS | 相关下载 | 常见问题 | FORUM | WIKI | 在线手册
Site search:    
<image2wbmpimageantialias>
Last updated: Fri, 22 Jun 2007

imagealphablending

(PHP 4 >= 4.0.6, PHP 5)

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

说明

int imagealphablending ( resource image, bool blendmode)

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

注: 本函数是 PHP 4.0.6 添加的,需要 GD 2.0.1。




add a note add a note User Contributed Notes
imagealphablending
barnabas at kendall dot NOSPAM dot net
12-Oct-2001 08:56
If you are trying to copy a transparant image on to another image, you might assume that you should apply the ImageAlphaBlending function to the image that has the transparancy, the source image. In reality, you must apply the ImageAlphaBlending function to the destination image. Basically it's saying, "make the specified image respect transparancy".

Here's a real world example. Suppose you want to put your logo on the upper left corner of a photograph. Your logo is a PNG with transparancy, and the photo is a JPEG. Here's what you would do:

<?php
$photoImage = ImageCreateFromJPEG('photo.jpg');
ImageAlphaBlending($photoImage, true);

$logoImage = ImageCreateFromPNG('logo.png');
$logoW = ImageSX($logoImage);
$logoH = ImageSY($logoImage);

ImageCopy($photoImage, $logoImage, 0, 0, 0, 0, $logoW, $logoH);

ImageJPEG($photoImage); // output to browser

ImageDestroy($photoImage);
ImageDestroy($logoImage);
?>

<image2wbmpimageantialias>
 Last updated: Fri, 22 Jun 2007
view source | feedback | send page | sitemap | aboutus   
Copyright ® 2002-2003 PHPE.NET. All rights reserved
Last updated:2002-11-22