百科狗-知识改变命运!

imagesettile() - gd函数(图像处理)

百变鹏仔2年前 (2023-11-21)阅读数 26#技术干货
文章标签贴图

imagesettile()

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

设定用于填充的贴图

说明

imagesettile(resource $image,resource $tile): bool

imagesettile()设定所有区域填充函数(例如imagefill()和imagefilledpolygon())在使用特殊颜色IMG_COLOR_TILED填充时所使用的贴图。

imagesettile() - gd函数(图像处理)

贴图是指用重复的样式来填充一块区域所使用的图像。任何GD 图像都能用作贴图,并且通过使用imagecolortransparent()来设定贴图的透明色,贴图可以使底层的特定区域透上来。

Note:

使用完贴图后不需要采取什么特殊动作。但如果销毁了贴图,在设定一个新的贴图之前不能使用IMG_COLOR_TILED

There is very little information about this function so I thought I'd add a few notes I found while trying to get this 
working.
First make sure your version of PHP is above 4.3.2 I spent an hour searching goggles 13000+ mirrors of this same page and 
finally found the info I needed at AltaVista, there is a bug in PHP 4.3.2 that makes this none functional.
if your creating the base image you need to create it with imageCreateTrueColor() if your using a PNG with transparency, I 
found even nullifying the PNG's transparency with GD doesn't work. the tiling PNG has to be created without transparency to work with imageCreate(). but from what I've seen imageCreateFromXXX() can use transparent and nonetransparent PNG's.
here is an example.

hope this helps someone else!
Aquilo
If you're using a tile image that has some form of transparency you'll need to make sure your destination image is set to use alpha blending. By default it will be, but if for any reason you've changed it you'll need to do:
imagealphablending($image,true);
before any operation using IMG_COLOR_TILED.

内容声明:本文中引用的各种信息及资料(包括但不限于文字、数据、图表及超链接等)均来源于该信息及资料的相关主体(包括但不限于公司、媒体、协会等机构)的官方网站或公开发表的信息。部分内容参考包括:(百度百科,百度知道,头条百科,中国民法典,刑法,牛津词典,新华词典,汉语词典,国家院校,科普平台)等数据,内容仅供参考使用,不准确地方联系删除处理!本站为非盈利性质站点,本着为中国教育事业出一份力,发布内容不收取任何费用也不接任何广告!)
{if $zbp->Config('yd1125')->foot}