本文整理汇总了PHP中imagesettile函数的典型用法代码示例。如果您正苦于以下问题:PHP imagesettile函数的具体用法?PHP imagesettile怎么用?PHP imagesettile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了imagesettile函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addBackground
public function addBackground($canvas, $bgImage, $bgWidth, $bgHeight, $bgOriginX, $bgOriginY)
{
$background = imagecreatetruecolor($bgWidth, $bgHeight);
imagesettile($background, $bgImage);
imagefill($background, 0, 0, IMG_COLOR_TILED);
imagecopy($canvas, $background, $bgOriginX, $bgOriginY, 0, 0, $bgWidth, $bgHeight);
}
示例2: apply
/**
* {@inheritdoc}
*/
public function apply(CanvasInterface $canvas, AbstractStyledDrawable $drawable)
{
if (false == @imagesettile($canvas->getHandler(), $this->pattern->getHandler())) {
throw new DrawableException('Could Not Apply The Fill Pattern Style');
}
return new TiledColor();
}
示例3: index
public function index()
{
// Check the request headers; avoid hitting the disk at all if possible. If the Etag
// matches then send a Not-Modified header and terminate execution.
if ($this->_serve_not_modified($this->_cache_file)) {
return;
}
// --------------------------------------------------------------------------
// The browser does not have a local cache (or it's out of date) check the
// cache directory to see if this image has been processed already; serve it up if
// it has.
if (file_exists(DEPLOY_CACHE_DIR . $this->_cache_file)) {
$this->_serve_from_cache($this->_cache_file);
} else {
// Cache object does not exist, create a new one and cache it
// Get and create the placeholder graphic
$_tile = imagecreatefrompng($this->_tile);
// --------------------------------------------------------------------------
// Create the container
$_img = imagecreatetruecolor($this->_width, $this->_height);
// --------------------------------------------------------------------------
// Tile the placeholder
imagesettile($_img, $_tile);
imagefilledrectangle($_img, 0, 0, $this->_width, $this->_height, IMG_COLOR_TILED);
// --------------------------------------------------------------------------
// Draw a border
$_border = imagecolorallocate($_img, 190, 190, 190);
for ($i = 0; $i < $this->_border; $i++) {
// Left
imageline($_img, 0 + $i, 0, 0 + $i, $this->_height, $_border);
// Top
imageline($_img, 0, 0 + $i, $this->_width, 0 + $i, $_border);
// Bottom
imageline($_img, 0, $this->_height - 1 - $i, $this->_width, $this->_height - 1 - $i, $_border);
// Right
imageline($_img, $this->_width - 1 - $i, 0, $this->_width - 1 - $i, $this->_height, $_border);
}
// --------------------------------------------------------------------------
// Set the appropriate cache headers
$this->_set_cache_headers(time(), $this->_cache_file, FALSE);
// --------------------------------------------------------------------------
// Output to browser
header('Content-Type: image/png', TRUE);
imagepng($_img);
// --------------------------------------------------------------------------
// Save local version, make sure cache is writable
imagepng($_img, DEPLOY_CACHE_DIR . $this->_cache_file);
// --------------------------------------------------------------------------
// Destroy the images to free up resource
imagedestroy($_tile);
imagedestroy($_img);
}
// --------------------------------------------------------------------------
// Kill script, th, th, that's all folks.
// Stop the output class from hijacking our headers and
// setting an incorrect Content-Type
exit(0);
}
示例4: apply
public function apply($resource)
{
$imageWidth = imagesx($resource->image);
$imageHeight = imagesy($resource->image);
$width = $imageWidth * $this->settings->xtimes;
$height = $imageHeight * $this->settings->xtimes;
$new = imagecreatetruecolor($width, $height);
imagesettile($new, $resource->image);
imagefill($new, 0, 0, IMG_COLOR_TILED);
$resource->image = $new;
}
示例5: execute
/**
* Fills image with color or pattern
*
* @param \Intervention\Image\Image $image
* @return boolean
*/
public function execute($image)
{
$filling = $this->argument(0)->value();
$x = $this->argument(1)->type('digit')->value();
$y = $this->argument(2)->type('digit')->value();
$width = imagesx($image->getCore());
$height = imagesy($image->getCore());
try {
// set image tile filling
$tile = $image->getDriver()->init($filling);
} catch (\Intervention\Image\Exception\NotReadableException $e) {
// set solid color filling
$color = new Color($filling);
$filling = $color->getInt();
}
foreach ($image as $frame) {
if (isset($tile)) {
imagesettile($frame->getCore(), $tile->getCore());
$filling = IMG_COLOR_TILED;
}
imagealphablending($frame->getCore(), true);
if (is_int($x) && is_int($y)) {
// resource should be visible through transparency
$base = $image->getDriver()->newImage($width, $height)->getCore();
imagecopy($base, $frame->getCore(), 0, 0, 0, 0, $width, $height);
// floodfill if exact position is defined
imagefill($frame->getCore(), $x, $y, $filling);
// copy filled original over base
imagecopy($base, $frame->getCore(), 0, 0, 0, 0, $width, $height);
// set base as new resource-core
imagedestroy($frame->getCore());
$frame->setCore($base);
} else {
// fill whole image otherwise
imagefilledrectangle($frame->getCore(), 0, 0, $width - 1, $height - 1, $filling);
}
}
isset($tile) ? imagedestroy($tile->getCore()) : null;
return true;
}
示例6: generate
public function generate()
{
imagesavealpha($this->_owner->image, true);
imagealphablending($this->_owner->image, true);
imagesavealpha($this->watermark->image, false);
imagealphablending($this->watermark->image, false);
$width = $this->_owner->imagesx();
$height = $this->_owner->imagesy();
$watermark_width = $this->watermark->imagesx();
$watermark_height = $this->watermark->imagesy();
switch ($this->position) {
case "tl":
$x = 0;
$y = 0;
break;
case "tm":
$x = ($width - $watermark_width) / 2;
$y = 0;
break;
case "tr":
$x = $width - $watermark_width;
$y = 0;
break;
case "ml":
$x = 0;
$y = ($height - $watermark_height) / 2;
break;
case "mm":
$x = ($width - $watermark_width) / 2;
$y = ($height - $watermark_height) / 2;
break;
case "mr":
$x = $width - $watermark_width;
$y = ($height - $watermark_height) / 2;
break;
case "bl":
$x = 0;
$y = $height - $watermark_height;
break;
case "bm":
$x = ($width - $watermark_width) / 2;
$y = $height - $watermark_height;
break;
case "br":
$x = $width - $watermark_width;
$y = $height - $watermark_height;
break;
case "user":
$x = $this->position_x - $this->watermark->getHandleX() / 2;
$y = $this->position_y - $this->watermark->getHandleY() / 2;
break;
default:
$x = 0;
$y = 0;
break;
}
if ($this->position != "tile") {
imagecopy($this->_owner->image, $this->watermark->image, $x, $y, 0, 0, $watermark_width, $watermark_height);
} else {
imagesettile($this->_owner->image, $this->watermark->image);
imagefilledrectangle($this->_owner->image, 0, 0, $width, $height, IMG_COLOR_TILED);
}
return true;
}
示例7: show_surface
//.........这里部分代码省略.........
$dminx = $xmin * $difmx / $gdifx;
$poz = array();
$olx = $this->pixel_up($valorix[0], $difmx, $gdifx, $xmin) + $gx;
$oly = $this->pixel_up($valoriy[0], $difm, $gdify, $ymin);
$oly0 = $this->pixel_up(0, $difm, $gdify, $ymin);
$poz[] = $olx;
$poz[] = $gyy - $oly0;
$poz[] = $olx;
$poz[] = $gyy - $oly;
if ($single == false) {
$pozitii[$pos][0] = array($olx, $gyy - $oly, ${$olx}, $gyy - $oly, $valorix[0] . "," . $valoriy[0]);
} else {
$pozitii[$pos][0] = array($olx, $gyy - $oly, ${$olx}, $gyy - $oly, $valoriy[0]);
}
for ($j = 1; $j < $this->count; $j++) {
$lx = $this->pixel_up($valorix[$j], $difmx, $gdifx, $xmin) + $gx;
$ly = $this->pixel_up($valoriy[$j], $difm, $gdify, $ymin);
$poz[] = $lx;
$poz[] = $gyy - $ly;
if ($single == false) {
$textul = $valorix[$j] . "," . $valoriy[$j];
} else {
$textul = $valoriy[$j];
}
$pozitii[$pos][$j] = array($lx, $gyy - $ly, $olx, $gyy - $oly, $textul);
$olx = $lx;
$oly = $ly;
$i++;
}
$poz[] = $lx;
$poz[] = $gyy - $oly0;
if ($this->acolors[$pos][1] == 0) {
imagefilledpolygon($this->imagine, $poz, sizeof($poz) / 2, $this->acolors[$pos][0]);
} else {
imagesettile($this->imagine, $this->acolors[$pos][0]);
imagefilledpolygon($this->imagine, $poz, sizeof($poz) / 2, IMG_COLOR_TILED);
}
if ($this->showcoords) {
foreach ($pozitii as $line) {
foreach ($line as $lin) {
$this->pune_indice($this->imagine, $lin[0], $lin[1], $lin[2], $lin[3], $lin[4]);
}
}
}
$k++;
$pos++;
}
if ($single == true && $this->count > 1 && $this->count / ($this->fonstsize + 1) < 10) {
if ($this->count > 2) {
$pana = min($this->count, sizeof($categories));
} else {
$pana = min($this->count, sizeof($categories)) - 1;
}
for ($j = 0; $j < $pana; $j++) {
$lx = ($this->pixel_up($valorix[$j], $difmx, $gdifx, $xmin) + $this->pixel_up($valorix[$j + 1], $difmx, $gdifx, $xmin)) / 2 + $gx - $this->fontsize * strlen($categories[$j]) / 3.3;
imagefttext($this->imagine, $this->fontsize * 0.8, 0, $lx, $gyy + $this->fontsize * 1.5, $this->bc($this->imagine, "darkgray"), $this->font, $categories[$j]);
}
}
if ($this->showpanel) {
$px = $gx * 0.8;
$pxx = $gxx * 1;
$py = $gyy * 1.06;
$pyy = $gyy * 1.5;
$rand = $this->fontsize * 0.8;
$cc = sizeof($pozitii);
$bordura = "white-brown";
for ($i = 0; $i < $cc; $i++) {
$diferenta = $py * 1.02 - $py;
$this->liniuta($this->imagine, $px, $py + $i * $rand + $i * $diferenta, $px * 3, $py + $i * $rand + ($i + 1) * $diferenta, $this->linewidth, $culori[$i], $i);
imagefttext($this->imagine, $rand, 0, $px * 3 - $rand / 3, $py + $i * $rand + $rand / 1.5 + ($i + 1) * $diferenta, $this->black, $this->font, $catego[$i]);
}
$ttx = $this->width * 0.28;
$tty = $gyy * 1.12;
$cate = ($gxx - $ttx) / $this->fontsize * 1.5;
} else {
$ttx = $this->width * 0.02;
$tty = $gyy * 1.12;
$cate = ($gxx - $ttx) / $this->fontsize * 1.5;
}
if (strlen($this->title) > 0) {
$tlx = $this->width / 2 - strlen($this->title) * $this->fontsize / 2.5;
$tly = $this->height * 0.04 + 3;
imagefttext($this->imagine, $this->fontsize + 3, 0, $tlx, $tly, $this->bc($this->imagine, $this->title_color), $this->font, $this->title);
}
if (strlen($this->text) > 0) {
$textul = array();
for ($i = 1; $i <= $cate; $i++) {
$textul[] = nl2br(substr($this->text, floor(($i - 1) * $cate), ceil($cate)));
}
$i = 0;
foreach ($textul as $linie) {
imagefttext($this->imagine, $this->fontsize - 1, 0, $ttx, $tty + $i, $this->bc($this->imagine, $this->text_color), $this->font, $linie);
$i += $this->fontsize + 1;
}
}
$this->set_filter();
} else {
echo "not enought values";
}
}
示例8: ImageColorAllocate
case 4:
$col_txt = ImageColorAllocate($im, $col_txt_r, $col_txt_g, $col_txt_b);
break;
}
$noiset = mt_rand(1, 2);
$image_data = getimagesize($im_bg_url);
$image_type = $image_data[2];
if ($image_type == 1) {
$img_src = imagecreatefromgif($im_bg_url);
} elseif ($image_type == 2) {
$img_src = imagecreatefromjpeg($im_bg_url);
} elseif ($image_type == 3) {
$img_src = imagecreatefrompng($im_bg_url);
}
if ($im_bg_type == 1) {
imagesettile($im, $img_src);
imageFilledRectangle($im, 0, 0, $image_width, $image_height, IMG_COLOR_TILED);
} else {
imagecopyresampled($im, $img_src, 0, 0, 0, 0, $image_width, $image_height, $image_data[0], $image_data[1]);
}
$pos_x = ($image_width - $codelen) / 2;
foreach ($data as $d) {
$pos_y = ($image_height + $d['height']) / 2;
ImageTTFText($im, $d['size'], $d['angle'], $pos_x, $pos_y, $col_txt, $font, $d['char']);
$pos_x += $d['width'] + $char_padding;
}
### a nice border
ImageRectangle($im, 0, 0, $image_width - 1, $image_height - 1, $color_border);
switch ($output_type) {
case 'jpeg':
Header('Content-type: image/jpeg');
示例9: set
static function set(&$image, $value, $method)
{
if ($method == 'border') {
//画线粗细
return imagesetthickness($image, (int) $value);
}
if ($method == 'style') {
//画线风格
return imagesetstyle($image, (array) $value);
}
if ($method == 'brush') {
//画笔图像
return imagesetbrush($image, $value);
}
if ($method == 'pattern') {
//填充的贴图 图案
return imagesettile($image, $value);
}
if ($method == 'alias') {
//抗锯齿
return imageantialias($image, (bool) $value);
}
if ($method == 'alpha') {
//alpha混色标志
return imagelayereffect($image, (int) $value);
}
if ($method == 'transparent') {
//透明色
return imagecolortransparent($image, (int) $value);
}
if ($method == 'mix') {
//混色模式
return imagealphablending($image, (bool) $value);
}
}
示例10: createImage
/**
* Creates a captcha image.
*
*/
private function createImage()
{
$intWidth = $this->intImageWidth;
$intHeight = $intWidth / 3;
$intFontSize = floor($intWidth / strlen($this->strRandomString)) - 2;
$intAngel = 15;
$intVerticalMove = floor($intHeight / 7);
$image = imagecreatetruecolor($intWidth, $intHeight);
$arrFontColors = array(imagecolorallocate($image, 0, 0, 0), imagecolorallocate($image, 255, 0, 0), imagecolorallocate($image, 0, 180, 0), imagecolorallocate($image, 0, 105, 172), imagecolorallocate($image, 145, 19, 120));
$arrFonts = array($this->strFontDir . 'coprgtb.ttf', $this->strFontDir . 'ltypeb.ttf');
//Draw background
$imagebg = imagecreatefromjpeg($this->strBackgroundDir . rand(1, $this->intNumberOfBackgrounds) . '.jpg');
imagesettile($image, $imagebg);
imagefilledrectangle($image, 0, 0, $intWidth, $intHeight, IMG_COLOR_TILED);
//Draw string
for ($i = 0; $i < strlen($this->strRandomString); ++$i) {
$intColor = rand(0, count($arrFontColors) - 1);
$intFont = rand(0, count($arrFonts) - 1);
$intAngel = rand(-$intAngel, $intAngel);
$intYMove = rand(-$intVerticalMove, $intVerticalMove);
if ($this->boolFreetypeInstalled) {
imagettftext($image, $intFontSize, $intAngel, 6 + $intFontSize * $i, $intHeight / 2 + $intFontSize / 2 + $intYMove, $arrFontColors[$intColor], $arrFonts[$intFont], substr($this->strRandomString, $i, 1));
} else {
imagestring($image, 5, 6 + 25 * $i, 12 + $intYMove, substr($this->strRandomString, $i, 1), $arrFontColors[$intColor]);
}
}
//save the image for further processing
$this->image = $image;
}
示例11: tile
public function tile($tile) : InternalGD
{
if (!is_resource($tile)) {
throw new InvalidArgumentException('Error', 'resourceParameter', '1.($tile)');
}
imagesettile($this->canvas, $tile);
return $this;
}
示例12: fillPattern
/**
* Rellena la imagen con un patrón
* @param resource $tile Identificador de recurso de imagen de la imagen patrón
*/
public function fillPattern($tile)
{
if (!imagesettile($this->imgData, $tile)) {
throw new Exception("imagesettile error", 1);
}
imagefilledrectangle($this->imgData, 0, 0, $this->width(), $this->height(), IMG_COLOR_TILED);
//$this->imgData=$tile;
}
示例13: imageCreateFromPNG
$imbg = imageCreateFromPNG ('tile.png'); // Alpha-transparent PNG
$black = imagecolorallocate($im, 0, 0, 0);
$white = imagecolorallocate($im, 255, 255, 255);
$red = imagecolorallocate($im, 255, 0, 0);
$green = imagecolorallocate($im, 0, 128, 0);
imagestring ($im, 3, 60+$x*4, 40, $nome, $green);
imagestring ($im, 3, 59+$x*4, 39, $nome, $white);
imageline ($im, 0, 20+$x*8, 400, 40+$x*-2, $green);
imagestring($im, 3, 30, 50, microtime(), $white);
imagestring($im, 3, 35, 60, "X: $x", $white);
imagestring($im, 3, 105, 60, date("H:i:s"), $red);
imagesettile ($im, $imbg);
imagefilledrectangle ($im, 0, 0, 400, 200, IMG_COLOR_TILED);
$randFilename = "tempFolder/".uniqid("$x-").".gif";
$generated[] = $randFilename;
imagegif($im, $randFilename);
}
$genEndTime = microtime(true);
$startTime = microtime(true);
/** Instantiate the class to join all the frames into one single GIF **/
$gif = new dGifAnimator();
$gif->setLoop(0); # Loop forever
$gif->setDefaultConfig('delay_ms', '10'); # Delay: 10ms
if(isset($_GET['transparent']))
$gif->setDefaultConfig('transparent_color', 0);
示例14: createTextWatermark
private function createTextWatermark($w, $h)
{
$font = $this->fw->get('ROOT') . '/../' . APP_FOLDER . '/views/' . $this->fw->get('site.tpl') . '/assets/fonts/' . $this->fw->get('site.watermark.font');
// \helpers\Debug::prePrintR($font);
$text = $this->fw->get('site.watermark.text');
$color = $this->fw->get('site.watermark.color');
// $hexcolor = $this->hexToPHPColor($this->fw->get('site.watermark.color'));
$x = $this->fw->get('site.watermark.x');
$y = $this->fw->get('site.watermark.y');
$size = $this->fw->get('site.watermark.size');
$angle = $this->fw->get('site.watermark.angle');
if (is_string($x) || is_string($y)) {
$textsize = imagettfbbox($size, $angle, $font, $text);
$textwidth = abs($textsize[2]);
$textheight = abs($textsize[7]);
list($xalign, $xalign_offset) = explode(" ", $x);
list($yalign, $yalign_offset) = explode(" ", $y);
}
if (is_string($x)) {
switch ($xalign) {
case 'left':
$x = 0 + $xalign_offset;
break;
case 'right':
$x = $w - $textwidth + $xalign_offset;
break;
case 'middle':
case 'center':
$x = ($w - $textwidth) / 2 + $xalign_offset;
break;
}
}
if (is_string($y)) {
switch ($yalign) {
case 'top':
$y = 0 + $textheight + $yalign_offset;
break;
case 'bottom':
$y = $h + $yalign_offset;
break;
case 'middle':
case 'center':
$y = ($h - $textheight) / 2 + $textheight + $yalign_offset;
break;
}
}
$img = imagecreatetruecolor($w, $h);
imagefill($img, 0, 0, IMG_COLOR_TRANSPARENT);
if ($this->fw->get('site.watermark.tile')) {
$tile = imagecreatetruecolor($textwidth * 4, $textwidth * 4);
imagefill($tile, 0, 0, IMG_COLOR_TRANSPARENT);
$color_id = imagecolorallocate($tile, $color[0], $color[1], $color[2]);
imagettftext($tile, $size, $angle, $textwidth, $textwidth * 2, $color_id, $font, $text);
imagesettile($img, $tile);
imagefilledrectangle($img, 0, 0, $w - 1, $h - 1, IMG_COLOR_TILED);
imagedestroy($tile);
} else {
$color_id = imagecolorallocate($img, $color[0], $color[1], $color[2]);
imagettftext($img, $size, $angle, $x, $y, $color_id, $font, $text);
}
imagesavealpha($img, true);
imagepng($img, $this->fw->get('TEMP') . '/watermark.png');
imagedestroy($img);
return $this->fw->get('TEMP') . '/watermark.png';
}
示例15: imagecreate
<?php
$tile = imagecreate(36, 36);
$base = imagecreate(150, 150);
$white = imagecolorallocate($tile, 255, 255, 255);
$black = imagecolorallocate($tile, 0, 0, 0);
$white = imagecolorallocate($base, 255, 255, 255);
$black = imagecolorallocate($base, 0, 0, 0);
/* create the dots pattern */
for ($x = 0; $x < 36; $x += 2) {
for ($y = 0; $y < 36; $y += 2) {
imagesetpixel($tile, $x, $y, $black);
}
}
imagesettile($base, $tile);
imagerectangle($base, 9, 9, 139, 139, $black);
imageline($base, 9, 9, 139, 139, $black);
imagefill($base, 11, 12, IMG_COLOR_TILED);
$res = imagecolorat($base, 0, 10) == $black ? '1' : '0';
$res .= imagecolorat($base, 0, 20) == $black ? '1' : '0';
$res .= imagecolorat($base, 0, 30) == $black ? '1' : '0';
$res .= imagecolorat($base, 0, 40) == $black ? '1' : '0';
$res .= imagecolorat($base, 0, 50) == $black ? '1' : '0';
$res .= imagecolorat($base, 0, 60) == $black ? '1' : '0';
$res .= imagecolorat($base, 11, 12) == $white ? '1' : '0';
$res .= imagecolorat($base, 12, 13) == $white ? '1' : '0';
$res .= imagecolorat($base, 13, 14) == $white ? '1' : '0';
$res .= imagecolorat($base, 14, 15) == $white ? '1' : '0';
$res .= imagecolorat($base, 15, 16) == $white ? '1' : '0';
$res .= imagecolorat($base, 16, 17) == $white ? '1' : '0';
$res .= imagecolorat($base, 10, 12) == $black ? '1' : '0';