本文整理汇总了PHP中imagelayereffect函数的典型用法代码示例。如果您正苦于以下问题:PHP imagelayereffect函数的具体用法?PHP imagelayereffect怎么用?PHP imagelayereffect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了imagelayereffect函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: getOverlay
protected function getOverlay($r, $g, $b)
{
extract($this->driver->getTargetSize());
$image = $this->driver->getResource();
$overlay = imagecreatetruecolor($width, $height);
imagealphablending($image, true);
imagelayereffect($image, IMG_EFFECT_OVERLAY);
imagefilledrectangle($overlay, 0, 0, $width, $height, imagecolorallocatealpha($overlay, $r, $g, $b, 0));
imagecopy($image, $overlay, 0, 0, 0, 0, imagesx($overlay), imagesy($overlay));
}
开发者ID:rulemaker,项目名称:jitimage,代码行数:10,代码来源:GdClrzFilter.php
示例2: ct_colorize_pics
function ct_colorize_pics($sourcePath, $destPath, $r, $g, $b)
{
if (@file_exists($sourcePath) && @is_readable($sourcePath) && @is_dir($sourcePath) && ($handle = @opendir($sourcePath))) {
while (false !== ($file = @readdir($handle))) {
$ext = strtolower(JFile::getExt($sourcePath . $file));
if ($file != "." && $file != ".." && ($ext == 'png' || $ext == 'jpg' || $ext == 'jpeg')) {
if ($ext == 'png') {
$im = imagecreatefrompng($sourcePath . $file);
} else {
$im = imagecreatefromjpeg($sourcePath . $file);
}
// prevent CONEXT updaters from wondering why the background images won't load anymore
if (JFactory::getApplication()->getTemplate() == 'CONEXT' && stripos($sourcePath, 'bg_images_source') !== false) {
// keep alphablending default
} else {
// turn off alphablending for images that are not explicetly marked to use in the filename
if (stripos($file, '_alphablending') === false) {
imagealphablending($im, false);
}
}
imagefilter($im, IMG_FILTER_COLORIZE, intval($r), intval($g), intval($b));
imagesavealpha($im, true);
if (stripos($file, '_multiply') !== false) {
if ($ext == 'png') {
$im2 = imagecreatefrompng($sourcePath . $file);
} else {
$im2 = imagecreatefromjpeg($sourcePath . $file);
}
imagelayereffect($im2, IMG_EFFECT_OVERLAY);
$w = imagesx($im);
$h = imagesy($im);
imagecopy($im2, $im, 0, 0, 0, 0, $w, $h);
imagesavealpha($im2, true);
ob_start();
imagepng($im2);
$c = ob_get_contents();
ob_end_clean();
JFile::write($destPath . $file, $c);
imagedestroy($im);
imagedestroy($im2);
} else {
ob_start();
imagepng($im);
$c = ob_get_contents();
ob_end_clean();
JFile::write($destPath . $file, $c);
imagedestroy($im);
}
}
}
}
}
开发者ID:stritti,项目名称:tpl_dinkelbaeck-mobil,代码行数:52,代码来源:recolor.php
示例3: CaptchaImages
function CaptchaImages($code, $width = 145, $height = 35)
{
/* select the type of font, must be used in directoy in which script is being called into */
$this->font = dirname(__FILE__) . '/CALIBRI.TTF';
$font_size = $height * 0.6;
$image = @imagecreate($width, $height) or die('Cannot initialize new GD image stream');
/* set the colours */
$bgR = mt_rand(0, 255);
$bgG = mt_rand(0, 255);
$bgB = mt_rand(0, 255);
$background_color = imagecolorallocate($image, $bgR, $bgG, $bgB);
$noise_color = imagecolorallocate($image, abs(100 - $bgR), abs(100 - $bgG), abs(100 - $bgB));
$text_color = imagecolorallocate($image, abs(255 - $bgR), abs(255 - $bgG), abs(255 - $bgB));
/* generate random dots in background */
for ($i = 0; $i < $width * $height / 3; $i++) {
imagefilledellipse($image, mt_rand(0, $width), mt_rand(0, $height), 1, 1, $noise_color);
}
/* generate random lines in background */
for ($i = 0; $i < $width * $height / 150; $i++) {
imageline($image, mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $height), $noise_color);
}
/* set random colors */
$w = imagecolorallocate($image, abs(100 - $bgR), abs(100 - $bgG), abs(100 - $bgB));
$r = imagecolorallocate($image, abs(100 - $bgR), abs(100 - $bgG), abs(100 - $bgB));
/* Draw a dashed line, 5 red pixels, 5 white pixels */
$style = array($r, $r, $r, $r, $r, $w, $w, $w, $w, $w);
imagesetstyle($image, $style);
imageline($image, 0, 0, $width, $height, IMG_COLOR_STYLED);
imageline($image, $width, 0, 0, $height, IMG_COLOR_STYLED);
/* create random polygon points */
$values = array(mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $height), mt_rand(0, $width));
/* create Random Colors then set it to $clr */
$r = abs(100 - mt_rand(0, 255));
$g = abs(100 - mt_rand(0, 255));
$b = abs(100 - mt_rand(0, 255));
$clr = imagecolorallocate($image, $r, $g, $b);
/* create filled polygon with random points */
imagefilledpolygon($image, $values, 6, $clr);
$textbox = imagettfbbox($font_size, 0, $this->font, $code) or die('Error in imagettfbbox function');
$x = ($width - $textbox[4]) / 2;
$y = ($height - $textbox[5]) / 2;
imagettftext($image, $font_size, 0, $x, $y, $text_color, $this->font, $code) or die('Error in imagettftext function');
/* pretty it */
imageantialias($image, 100);
imagealphablending($image, 1);
imagelayereffect($image, IMG_EFFECT_OVERLAY);
/* output captcha image to browser */
header('Content-Type: image/jpeg');
imagejpeg($image);
imagedestroy($image);
}
开发者ID:qcww,项目名称:yh_cms,代码行数:51,代码来源:CaptchaSecurityImages.php
示例4: _blend
public function _blend($opacity = 1, $fill = 1, $options = array())
{
// OVERLAY MODE {
$destX = ($this->base->getWidth() - $this->top->getWidth()) / 2;
$destY = ($this->base->getHeight() - $this->top->getHeight()) / 2;
// This line causes all GD operations to use the overlay algorithm
// when blending pixels together.
$baseImg = $this->base->getImage();
imagelayereffect($baseImg, IMG_EFFECT_OVERLAY);
// Blend the top image onto the base image.
imagecopy($baseImg, $this->top->getImage(), $destX, $destY, 0, 0, $this->base->getWidth(), $this->base->getHeight());
// } OVERLAY
return $baseImg;
}
开发者ID:manticorp,项目名称:BlendableImage,代码行数:14,代码来源:Overlay.php
示例5: create_image
function create_image()
{
global $trips, $scale, $offsetX, $offsetY, $alpha, $name;
// create image from map_bg.jpg, which was made in TileMill
$im = imagecreatefromjpeg("map_bg.jpg") or die("Cannot Initialize new GD image stream");
imagelayereffect($im, IMG_EFFECT_ALPHABLEND);
// lines are mostly transparent and we want to blend those alphas
$slow = imagecolorallocatealpha($im, 170, 0, 0, $alpha);
// red
$med = imagecolorallocatealpha($im, 255, 244, 50, $alpha);
// yellow
$fast = imagecolorallocatealpha($im, 0, 240, 128, $alpha);
// green
foreach ($trips as $vehicle) {
for ($i = 1; $i < count($vehicle); $i++) {
$val = floatval($vehicle[$i][2]);
// speed
if ($val < 10) {
$color = $slow;
} else {
if ($val < 25) {
$color = $med;
} else {
$color = $fast;
}
}
// $vehicles[$i][0] is latitude, $vehicles[$i][1] is longitude
imageline($im, $vehicle[$i - 1][1] * $scale + $offsetX, -(projectLat($vehicle[$i - 1][0]) * $scale - $offsetY), $vehicle[$i][1] * $scale + $offsetX, -(projectLat($vehicle[$i][0]) * $scale - $offsetY), $color);
}
}
// titles, etc. for the Bostonography maps
$white = imagecolorallocate($im, 255, 255, 255);
imagettftext($im, 50, 0, 50, 100, $white, "pnbold.otf", "MBTA Bus Speeds");
imagettftext($im, 20, 0, 50, 150, $white, "pnreg.otf", "The speed of buses on " . date("l, F j, Y") . ",");
imagettftext($im, 20, 0, 50, 190, $white, "pnreg.otf", "based on 24 hour of real-time location data.");
imagettftext($im, 20, 0, 50, 250, imagecolorallocate($im, 170, 0, 0), "pnbold.otf", "Red:");
imagettftext($im, 20, 0, 50, 290, imagecolorallocate($im, 255, 244, 50), "pnbold.otf", "Yellow:");
imagettftext($im, 20, 0, 50, 330, imagecolorallocate($im, 0, 240, 128), "pnbold.otf", "Green:");
imagettftext($im, 20, 0, 150, 250, $white, "pnreg.otf", "< 10 mph");
imagettftext($im, 20, 0, 150, 290, $white, "pnreg.otf", "10 to 25 mph");
imagettftext($im, 20, 0, 150, 330, $white, "pnreg.otf", "> 25 mph");
imagettftext($im, 10, 0, 50, 380, $white, "pnreg.otf", "Bostonography.com | Street map data copyright OpenStreetMap.org | MBTA bus data via NextBus");
// Save image twice
imagejpeg($im, "archive/yesterday.jpg");
imagejpeg($im, $name);
// To just output the image instead, comment out the above two lines and use these two
//header('Content-Type: image/jpeg');
//imagejpeg($im);
imagedestroy($im);
}
开发者ID:JonahKE,项目名称:mbta-bus-speed,代码行数:50,代码来源:image.php
示例6: overlay_original
public function overlay_original($layerPath, $posX = 0, $posY = 0, $layerX = 0, $layerY = 0, $layerWidth = 0, $layerHeight = 0)
{
// Load the new layer
$draw = new Image($layerPath);
if (!isset($draw->resource)) {
return;
}
imagelayereffect($this->resource, IMG_EFFECT_OVERLAY);
// Check default sizes
if ($layerWidth == 0) {
$layerWidth = $draw->width;
}
if ($layerHeight == 0) {
$layerHeight = $draw->height;
}
// Copy the layer to the image
imagecopy($this->resource, $draw->resource, $posX, $posY, $layerX, $layerY, $layerWidth, $layerHeight);
}
开发者ID:SkysteedDevelopment,项目名称:Deity,代码行数:18,代码来源:Image.php
示例7: watermark
/**
* @param string $file
* @param int $offsetX
* @param int $offsetY
* @param float $opacity
*
* @return static
* @throws \ManaPHP\Image\Adapter\Exception
*/
public function watermark($file, $offsetX = 0, $offsetY = 0, $opacity = 1.0)
{
$file = $this->alias->resolve($file);
$maskImageInfo = getimagesize($file);
$maskWidth = $maskImageInfo[0];
/** @noinspection MultiAssignmentUsageInspection */
$maskHeight = $maskImageInfo[1];
/** @noinspection MultiAssignmentUsageInspection */
$maskType = $maskImageInfo[2];
if ($maskType === IMAGETYPE_GIF) {
$maskImage = imagecreatefromgif($file);
} elseif ($maskType === IMAGETYPE_JPEG) {
$maskImage = imagecreatefromjpeg($file);
} elseif ($maskType === IMAGETYPE_PNG) {
$maskImage = imagecreatefrompng($file);
} else {
throw new GdException('Installed GD does not support such images');
}
imagesavealpha($maskImage, true);
$image = imagecreatetruecolor($this->_width, $this->_height);
imagealphablending($image, false);
imagesavealpha($image, true);
if ($maskType !== IMAGETYPE_PNG) {
$filedColor = imagecolorallocatealpha($image, 127, 127, 127, (1 - $opacity) * 127);
} else {
$filedColor = imagecolorallocate($image, 127, 127, 127);
}
imagelayereffect($maskImage, IMG_EFFECT_OVERLAY);
imagefilledrectangle($maskImage, 0, 0, $maskWidth, $maskHeight, $filedColor);
imagealphablending($this->_image, true);
imagecopy($this->_image, $maskImage, $offsetX, $offsetY, 0, 0, $maskWidth, $maskHeight);
return $this;
}
开发者ID:manaphp,项目名称:manaphp,代码行数:42,代码来源:Gd.php
示例8: imagecreatetruecolor
<?php
$image = imagecreatetruecolor(180, 30);
$layer = imagelayereffect($image, IMG_EFFECT_REPLACE);
if ($layer) {
ob_start();
imagepng($image, null, 9);
$img = ob_get_contents();
ob_end_clean();
}
echo md5(base64_encode($img));
开发者ID:badlamer,项目名称:hhvm,代码行数:11,代码来源:imagelayereffect_basic.php
示例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);
}
}
开发者ID:art-youth,项目名称:framework,代码行数:35,代码来源:img.php
示例10: _do_watermark
protected function _do_watermark(Image $watermark, $offset_x, $offset_y, $opacity)
{
if (!Image_GD::$_bundled) {
throw new Kohana_Exception('This method requires :function, which is only available in the bundled version of GD', array(':function' => 'imagelayereffect'));
}
// Loads image if not yet loaded
$this->_load_image();
// Create the watermark image resource
$overlay = imagecreatefromstring($watermark->render());
// Get the width and height of the watermark
$width = imagesx($overlay);
$height = imagesy($overlay);
if ($opacity < 100) {
// Convert an opacity range of 0-100 to 127-0
$opacity = round(abs($opacity * 127 / 100 - 127));
// Allocate transparent white
$color = imagecolorallocatealpha($overlay, 255, 255, 255, $opacity);
// The transparent image will overlay the watermark
imagelayereffect($overlay, IMG_EFFECT_OVERLAY);
// Fill the background with transparent white
imagefilledrectangle($overlay, 0, 0, $width, $height, $color);
}
// Alpha blending must be enabled on the background!
imagealphablending($this->_image, TRUE);
if (imagecopy($this->_image, $overlay, $offset_x, $offset_y, 0, 0, $width, $height)) {
// Destroy the overlay image
imagedestroy($overlay);
}
}
开发者ID:homm,项目名称:image,代码行数:29,代码来源:gd.php
示例11: doApply
/**
* {@inheritdoc}
*/
protected function doApply(CanvasInterface $canvas)
{
$box = is_null($this->getBox()) ? new Box($canvas->getDimension()) : $this->getBox();
$compine = new \Jaguar\Canvas($canvas->getDimension());
$compine->paste($canvas);
$compine->paste($this->getOverlay(), null, $box);
imagelayereffect($canvas->getHandler(), IMG_EFFECT_OVERLAY);
imagecopymerge($canvas->getHandler(), $compine->getHandler(), 0, 0, 0, 0, $canvas->getWidth(), $canvas->getHeight(), $this->getAmount());
$canvas->alphaBlending(true);
$compine->destroy();
}
开发者ID:El-Loco-Pinguino,项目名称:FaitesUnVoeu_WF3,代码行数:14,代码来源:Overlay.php
示例12: imagecreatefrompng
// add all the icons to the sprite image
for ($i = 0; $i < $cnt; $i++) {
$base = $i * 90;
$IN = imagecreatefrompng($input[$i]);
imagesavealpha($IN, true);
imagecolorscale($IN, $GAMMA);
imagecopy($DST, $IN, 0, $base, 0, 0, 30, 30);
imagedestroy($IN);
$IN = imagecreatefrompng($input[$i]);
imagesavealpha($IN, true);
imagecolorscale($IN, $GAMMA);
imagecopy($DST, $IN, 0, $base + 45, 0, 0, 30, 30);
imagedestroy($IN);
imagelayereffect($DST, IMG_EFFECT_OVERLAY);
imagefilledrectangle($DST, 0, $base + 45, 30, $base + 45 + 30, $C_active);
imagelayereffect($DST, IMG_EFFECT_NORMAL);
}
// output sprite
imagepng($DST, 'pagetools-sprite.png');
imagedestroy($DST);
// optimize if possible
if (is_executable($OPTIPNG)) {
system("{$OPTIPNG} -o5 'pagetools-sprite.png'");
}
/**
* Convert a hex color code to an rgb array
*/
function hex2rgb($hex)
{
// strip hash
$hex = str_replace('#', '', $hex);
开发者ID:omusico,项目名称:isle-web-framework,代码行数:31,代码来源:pagetools-build.php
示例13: layerEffect
public function layerEffect(string $effect = 'normal') : InternalGD
{
imagelayereffect($this->canvas, Converter::toConstant($effect, 'IMG_EFFECT_'));
return $this;
}
开发者ID:znframework,项目名称:znframework,代码行数:5,代码来源:InternalGD.php
示例14: watermark
/**
* {@inheritdoc}
*/
public function watermark($file, $position = Image::WATERMARK_TOP_LEFT, $opacity = 100)
{
$watermark = $this->createImageResource($file, $this->getImageInfo($file));
$watermarkWidth = imagesx($watermark);
$watermarkHeight = imagesy($watermark);
if ($opacity < 100) {
// Convert alpha to 0-127
$alpha = min(round(abs($opacity * 127 / 100 - 127)), 127);
$transparent = imagecolorallocatealpha($watermark, 0, 0, 0, $alpha);
imagelayereffect($watermark, IMG_EFFECT_OVERLAY);
imagefilledrectangle($watermark, 0, 0, $watermarkWidth, $watermarkHeight, $transparent);
}
// Position the watermark.
switch ($position) {
case Image::WATERMARK_TOP_RIGHT:
$x = imagesx($this->image) - $watermarkWidth;
$y = 0;
break;
case Image::WATERMARK_BOTTOM_LEFT:
$x = 0;
$y = imagesy($this->image) - $watermarkHeight;
break;
case Image::WATERMARK_BOTTOM_RIGHT:
$x = imagesx($this->image) - $watermarkWidth;
$y = imagesy($this->image) - $watermarkHeight;
break;
case Image::WATERMARK_CENTER:
$x = imagesx($this->image) / 2 - $watermarkWidth / 2;
$y = imagesy($this->image) / 2 - $watermarkHeight / 2;
break;
default:
$x = 0;
$y = 0;
}
imagealphablending($this->image, true);
imagecopy($this->image, $watermark, $x, $y, 0, 0, $watermarkWidth, $watermarkHeight);
imagedestroy($watermark);
}
开发者ID:muhammetardayildiz,项目名称:framework,代码行数:41,代码来源:GD.php
示例15: set
static function set(&$image, $value, $style = 'mix')
{
switch ($style) {
case 'border':
//画线粗细
return imagesetthickness($image, (int) $value);
case 'style':
//画线风格
return imagesetstyle($image, (array) $value);
case 'brush':
//画笔图像
return imagesetbrush($image, $value);
case 'pattern':
//填充的贴图 图案
return imagesettile($image, $value);
case 'alias':
//抗锯齿
return imageantialias($image, (bool) $value);
case 'alpha':
//alpha混色标志
return imagelayereffect($image, (int) $value);
case 'transparent':
//透明色
return imagecolortransparent($image, (int) $value);
case 'mix':
//混色模式
//混色模式
default:
return imagealphablending($image, (bool) $value);
}
}
开发者ID:mjiong,项目名称:framework,代码行数:31,代码来源:image.php
示例16: multiplyRun
public function multiplyRun($image1, $image2, $destFile, $opacity = 50)
{
$baseImageType = pathinfo($image1, PATHINFO_EXTENSION);
if ($baseImageType == 'png') {
$baseImage = imagecreatefrompng($image1);
} else {
if ($baseImageType == 'gif') {
$baseImage = imagecreatefromgif($image1);
} else {
$baseImage = imagecreatefromjpeg($image1);
}
}
$baseIsTrueColor = imageistruecolor($baseImage);
$topImageType = pathinfo($image2, PATHINFO_EXTENSION);
if ($topImageType == 'png') {
$topImage = imagecreatefrompng($image2);
} else {
if ($topImageType == 'gif') {
$topImage = imagecreatefromgif($image2);
} else {
$topImage = imagecreatefromjpeg($image2);
}
}
$topIsTrueColor = imageistruecolor($topImage);
$baseWidth = imagesx($baseImage);
$baseHeight = imagesy($baseImage);
$topWidth = imagesx($topImage);
$topHeight = imagesy($topImage);
$destX = ($baseWidth - $topWidth) / 2;
$destY = ($baseHeight - $topHeight) / 2;
if (function_exists('imagelayereffect')) {
switch ($this->alphaBlendMode) {
default:
case 'normal':
imagelayereffect($topImage, IMG_EFFECT_NORMAL);
break;
case 'replace':
imagelayereffect($topImage, IMG_EFFECT_REPLACE);
break;
case 'overlay':
imagelayereffect($topImage, IMG_EFFECT_OVERLAY);
break;
}
}
if ($this->effects != false) {
// negate,grayscale,brightness,contrast,colorize,edges,emboss,gaussBlur,selectiveBlur,meanRemoval,smooth,pixelate
foreach ($this->effects as $effect) {
switch ($effect) {
case 'gammaCorrect':
if (function_exists('imagegammacorrect') && isset($this->gammaCorrect) && !empty($this->gammaCorrect)) {
imagegammacorrect($topImage, $this->gammaInput, $this->gammaOutput);
}
break;
case 'negate':
if (function_exists('imagefilter')) {
imagefilter($topImage, IMG_FILTER_NEGATE);
}
break;
case 'grayscale':
if (function_exists('imagefilter')) {
imagefilter($topImage, IMG_FILTER_GRAYSCALE);
}
break;
case 'brightness':
if (function_exists('imagefilter')) {
imagefilter($topImage, IMG_FILTER_BRIGHTNESS, $this->effectBrightnessLevel);
}
break;
case 'contrast':
if (function_exists('imagefilter')) {
imagefilter($topImage, IMG_FILTER_CONTRAST, $this->effectContrastLevel);
}
break;
case 'colorize':
if (function_exists('imagefilter')) {
imagefilter($topImage, IMG_FILTER_COLORIZE, $this->colorize['red'], $this->colorize['green'], $this->colorize['blue'], $this->colorize['alpha']);
}
break;
case 'edges':
if (function_exists('imagefilter')) {
imagefilter($topImage, IMG_FILTER_EDGEDETECT);
}
break;
case 'emboss':
if (function_exists('imagefilter')) {
imagefilter($topImage, IMG_FILTER_EMBOSS);
}
break;
case 'gaussBlur':
if (function_exists('imagefilter')) {
imagefilter($topImage, IMG_FILTER_GAUSSIAN_BLUR);
}
break;
case 'selectiveBlur':
if (function_exists('imagefilter')) {
imagefilter($topImage, IMG_FILTER_SELECTIVE_BLUR);
}
break;
case 'meanRemoval':
if (function_exists('imagefilter')) {
//.........这里部分代码省略.........
开发者ID:blacksunshineCoding,项目名称:whirl,代码行数:101,代码来源:whirl.class.php
示例17: imagelayereffect
<?php
$layer = imagelayereffect('invalid_resource', IMG_EFFECT_REPLACE);
开发者ID:badlamer,项目名称:hhvm,代码行数:3,代码来源:imagelayereffect_error1.php
示例18: imagecreatetruecolor
<?php
$image = imagecreatetruecolor(180, 30);
$layer = imagelayereffect($image, 'IMG_EFFECT_REPLACE');
开发者ID:badlamer,项目名称:hhvm,代码行数:4,代码来源:imagelayereffect_error2.php
示例19: createEmblem
private function createEmblem($showlevel = TRUE, $width = 215)
{
if (!$this->emblemAdd) {
$imgfile = dirname(__FILE__) . "/cache/" . $this->region . '_' . $this->realm . '_' . $this->name . ".png";
} else {
$imgfile = dirname(__FILE__) . "/cache/" . $this->region . '_' . $this->realm . '_' . $this->name . '_' . $this->emblemAdd . ".png";
}
#$imgfile = dirname(__FILE__)."/cache/".$this->region.$this->realm.$this->name.".png";
#print $imgfile;
if (file_exists($imgfile) and $width == imagesx(imagecreatefrompng($imgfile)) and filemtime($imgfile) + 86000 > time()) {
$finalimg = imagecreatefrompng($imgfile);
imagesavealpha($finalimg, true);
imagealphablending($finalimg, true);
} else {
if ($width > 1 and $width < 215) {
$height = $width / 215 * 230;
$finalimg = imagecreatetruecolor($width, $height);
$trans_colour = imagecolorallocatealpha($finalimg, 0, 0, 0, 127);
imagefill($finalimg, 0, 0, $trans_colour);
imagesavealpha($finalimg, true);
imagealphablending($finalimg, true);
}
if ($this->guildData['side'] == 0) {
$ring = 'alliance';
} else {
$ring = 'horde';
}
$imgOut = imagecreatetruecolor(215, 230);
$emblemURL = dirname(__FILE__) . "/img/emblems/emblem_" . sprintf("%02s", $this->guildData['emblem']['icon']) . ".png";
$borderURL = dirname(__FILE__) . "/img/borders/border_" . sprintf("%02s", $this->guildData['emblem']['border']) . ".png";
$ringURL = dirname(__FILE__) . "/img/static/ring-" . $ring . ".png";
$shadowURL = dirname(__FILE__) . "/img/static/shadow_00.png";
$bgURL = dirname(__FILE__) . "/img/static/bg_00.png";
$overlayURL = dirname(__FILE__) . "/img/static/overlay_00.png";
$hooksURL = dirname(__FILE__) . "/img/static/hooks.png";
$levelURL = dirname(__FILE__) . "/img/static/";
imagesavealpha($imgOut, true);
imagealphablending($imgOut, true);
$trans_colour = imagecolorallocatealpha($imgOut, 0, 0, 0, 127);
imagefill($imgOut, 0, 0, $trans_colour);
$ring = imagecreatefrompng($ringURL);
$ring_size = getimagesize($ringURL);
$emblem = imagecreatefrompng($emblemURL);
$emblem_size = getimagesize($emblemURL);
imagelayereffect($emblem, IMG_EFFECT_OVERLAY);
$emblemcolor = preg_replace('/^ff/i', '', $this->guildData['emblem']['iconColor']);
$color_r = hexdec(substr($emblemcolor, 0, 2));
$color_g = hexdec(substr($emblemcolor, 2, 2));
$color_b = hexdec(substr($emblemcolor, 4, 2));
imagefilledrectangle($emblem, 0, 0, $emblem_size[0], $emblem_size[1], imagecolorallocatealpha($emblem, $color_r, $color_g, $color_b, 0));
$border = imagecreatefrompng($borderURL);
$border_size = getimagesize($borderURL);
imagelayereffect($border, IMG_EFFECT_OVERLAY);
$bordercolor = preg_replace('/^ff/i', '', $this->guildData['emblem']['borderColor']);
$color_r = hexdec(substr($bordercolor, 0, 2));
$color_g = hexdec(substr($bordercolor, 2, 2));
$color_b = hexdec(substr($bordercolor, 4, 2));
imagefilledrectangle($border, 0, 0, $border_size[0] + 100, $border_size[0] + 100, imagecolorallocatealpha($border, $color_r, $color_g, $color_b, 0));
$shadow = imagecreatefrompng($shadowURL);
$bg = imagecreatefrompng($bgURL);
$bg_size = getimagesize($bgURL);
imagelayereffect($bg, IMG_EFFECT_OVERLAY);
$bgcolor = preg_replace('/^ff/i', '', $this->guildData['emblem']['backgroundColor']);
$color_r = hexdec(substr($bgcolor, 0, 2));
$color_g = hexdec(substr($bgcolor, 2, 2));
$color_b = hexdec(substr($bgcolor, 4, 2));
imagefilledrectangle($bg, 0, 0, $bg_size[0] + 100, $bg_size[0] + 100, imagecolorallocatealpha($bg, $color_r, $color_g, $color_b, 0));
$overlay = imagecreatefrompng($overlayURL);
$hooks = imagecreatefrompng($hooksURL);
$x = 20;
$y = 23;
if (!$this->emblemHideRing) {
imagecopy($imgOut, $ring, 0, 0, 0, 0, $ring_size[0], $ring_size[1]);
}
$size = getimagesize($shadowURL);
imagecopy($imgOut, $shadow, $x, $y, 0, 0, $size[0], $size[1]);
imagecopy($imgOut, $bg, $x, $y, 0, 0, $bg_size[0], $bg_size[1]);
imagecopy($imgOut, $emblem, $x + 17, $y + 30, 0, 0, $emblem_size[0], $emblem_size[1]);
imagecopy($imgOut, $border, $x + 13, $y + 15, 0, 0, $border_size[0], $border_size[1]);
$size = getimagesize($overlayURL);
imagecopy($imgOut, $overlay, $x, $y + 2, 0, 0, $size[0], $size[1]);
$size = getimagesize($hooksURL);
imagecopy($imgOut, $hooks, $x - 2, $y, 0, 0, $size[0], $size[1]);
if ($showlevel) {
$level = $this->guildData['level'];
if ($level < 10) {
$levelIMG = imagecreatefrompng($levelURL . $level . ".png");
} else {
$digit[1] = substr($level, 0, 1);
$digit[2] = substr($level, 1, 1);
$digit1 = imagecreatefrompng($levelURL . $digit[1] . ".png");
$digit2 = imagecreatefrompng($levelURL . $digit[2] . ".png");
$digitwidth = imagesx($digit1);
$digitheight = imagesy($digit1);
$levelIMG = imagecreatetruecolor($digitwidth * 2, $digitheight);
$trans_colour = imagecolorallocatealpha($levelIMG, 0, 0, 0, 127);
imagefill($levelIMG, 0, 0, $trans_colour);
imagesavealpha($levelIMG, true);
imagealphablending($levelIMG, true);
// Last image added first because of the shadow need to be behind first digit
//.........这里部分代码省略.........
开发者ID:GlassFace,项目名称:AquaGuildZ,代码行数:101,代码来源:Guild.class.php
示例20: imagecopy
// Rotate and flip it (strip flip method)
for ($y = 0; $y < $new_height; $y++) {
imagecopy($buffer, $output, 0, $y, 0, $new_height - $y - 1, $width, 1);
}
$output = $buffer;
/*
----------------------------------------------------------------
Apply the fade effect
----------------------------------------------------------------
*/
// This is quite simple really. There are 127 available levels of alpha, so we just
// step-through the reflected image, drawing a box over the top, with a set alpha level.
// The end result? A cool fade.
// There are a maximum of 127 alpha fade steps we can use, so work out the alpha step rate
$alpha_length = abs($alpha_start - $alpha_end);
imagelayereffect($output, IMG_EFFECT_OVERLAY);
for ($y = 0; $y <= $new_height; $y++) {
// Get % of reflection height
$pct = $y / $new_height;
// Get % of alpha
if ($alpha_start > $alpha_end) {
$alpha = (int) ($alpha_start - $pct * $alpha_length);
} else {
$alpha = (int) ($alpha_start + $pct * $alpha_length);
}
// Rejig it because of the way in which the image effect overlay works
$final_alpha = 127 - $alpha;
//imagefilledrectangle($output, 0, $y, $width, $y, imagecolorallocatealpha($output, 127, 127, 127, $final_alpha));
imagefilledrectangle($output, 0, $y, $width, $y, imagecolorallocatealpha($output, $red, $green, $blue, $final_alpha));
}
/*
开发者ID:alexscarp,项目名称:middix,代码行数:31,代码来源:reflection.php
注:本文中的imagelayereffect函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论