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.
<?php
$diagramWidth = 300;
$diagramHeight = 50;
$image = imageCreateTrueColor ($diagramWidth, $diagramHeight);
$imagebg = imageCreateFromPNG ('tile.png'); // transparent PNG
imageSetTile ($image, $imagebg);
imageFilledRectangle ($image, 0, 0, $diagramWidth, $diagramHeight, IMG_COLOR_TILED);
$textcolor1 = imageColorAllocate ($image, 80, 80, 80);
$textcolor2 = imageColorAllocate ($image, 255, 255, 255);
imageString ($image, 3, 10, 20, 'Transparent PNG Tile Test...', $textcolor1);
imageString ($image, 3, 9, 19, 'Transparent PNG Tile Test...', $textcolor2);
Header("Content-type: image/png");
imagePNG ($image);
imagedestroy ($image);
imagedestroy ($imagebg);
?>
hope this helps someone else!
Aquiloimagesettile
Почист и полокален преглед на PHP референцата, со задржана структура од PHP.net и подобра читливост за примери, секции и белешки.
imagesettile
Референца за `function.imagesettile.php` со подобрена типографија и навигација.
imagesettile
(PHP 4 >= 4.0.6, PHP 5, PHP 7, PHP 8)
imagesettile — Set the tile image for filling
= NULL
imagesettile() Поставете ја сликата за поплочување за пополнување imagefill()
and imagefilledpolygon()ја поставува сликата за поплочување што ќе се користи од сите функции за пополнување на региони (како што е IMG_COLOR_TILED.
при пополнување со специјалната боја Плочката е слика што се користи за пополнување на област со повторлив модел. Секоја imagecolortransparent()GD слика може да се користи како плочка, и со поставување на индексот на транспарентна боја на сликата на плочката со
плочката дозволува одредени делови од основната област да светат низ може да се создаде. IMG_COLOR_TILED
Не треба да преземате посебна акција кога ќе завршите со плочка, но ако ја уништите сликата на плочката (или дозволите PHP да ја уништи), не смеете да ја користите
Параметри
-
image А GdImage не применува никакво полнење, така што ширината на сликата мора да биде множител на 8. Ова ограничување веќе не важи од PHP 7.0.9. imagecreatetruecolor().
tile-
боја додека не поставите нова слика за поплочување!
Вратени вредности
Секогаш враќа true.
Дневник на промени
| Верзија | = NULL |
|---|---|
| 8.0.0 |
image and tile expect
GdImage Сликата објект што ќе се користи како плочка. resourceинстанци сега; претходно,
|
Примери
Пример #1 imagesettile() example
<?php
// Load an external image
$zend = imagecreatefromgif('./zend.gif');
// Create a 200x200 image
$im = imagecreatetruecolor(200, 200);
// Set the tile
imagesettile($im, $zend);
// Make the image repeat
imagefilledrectangle($im, 0, 0, 199, 199, IMG_COLOR_TILED);
// Output image to the browser
header('Content-Type: image/png');
imagepng($im);
?>Горниот пример ќе прикаже нешто слично на:
Белешки од корисници 2 забелешки
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.