本文整理汇总了PHP中imagealphablending函数的典型用法代码示例。如果您正苦于以下问题:PHP imagealphablending函数的具体用法?PHP imagealphablending怎么用?PHP imagealphablending使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了imagealphablending函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: load
static function load($filename)
{
$info = getimagesize($filename);
list($width, $height) = $info;
if (!$width || !$height) {
return null;
}
$image = null;
switch ($info['mime']) {
case 'image/gif':
$image = imagecreatefromgif($filename);
break;
case 'image/jpeg':
$image = imagecreatefromjpeg($filename);
break;
case 'image/png':
$image = imagecreatetruecolor($width, $height);
$white = imagecolorallocate($image, 255, 255, 255);
imagefill($image, 0, 0, $white);
$png = imagecreatefrompng($filename);
imagealphablending($png, true);
imagesavealpha($png, true);
imagecopy($image, $png, 0, 0, 0, 0, $width, $height);
imagedestroy($png);
break;
}
if ($image) {
return new image($image, $width, $height);
} else {
return null;
}
}
开发者ID:nyan-cat,项目名称:easyweb,代码行数:32,代码来源:image.php
示例2: getAvatar
public function getAvatar($string, $widthHeight = 12, $theme = 'default')
{
$widthHeight = max($widthHeight, 12);
$md5 = md5($string);
$fileName = _TMP_DIR_ . '/' . $md5 . '.png';
if ($this->tmpFileExists($fileName)) {
return $fileName;
}
// Create seed.
$seed = intval(substr($md5, 0, 6), 16);
mt_srand($seed);
$body = array('legs' => mt_rand(0, count($this->availableParts[$theme]['legs']) - 1), 'hair' => mt_rand(0, count($this->availableParts[$theme]['hair']) - 1), 'arms' => mt_rand(0, count($this->availableParts[$theme]['arms']) - 1), 'body' => mt_rand(0, count($this->availableParts[$theme]['body']) - 1), 'eyes' => mt_rand(0, count($this->availableParts[$theme]['eyes']) - 1), 'mouth' => mt_rand(0, count($this->availableParts[$theme]['mouth']) - 1));
// Avatar random parts.
$parts = array('legs' => $this->availableParts[$theme]['legs'][$body['legs']], 'hair' => $this->availableParts[$theme]['hair'][$body['hair']], 'arms' => $this->availableParts[$theme]['arms'][$body['arms']], 'body' => $this->availableParts[$theme]['body'][$body['body']], 'eyes' => $this->availableParts[$theme]['eyes'][$body['eyes']], 'mouth' => $this->availableParts[$theme]['mouth'][$body['mouth']]);
$avatar = imagecreate($widthHeight, $widthHeight);
imagesavealpha($avatar, true);
imagealphablending($avatar, false);
$background = imagecolorallocate($avatar, 0, 0, 0);
$line_colour = imagecolorallocate($avatar, mt_rand(0, 200) + 55, mt_rand(0, 200) + 55, mt_rand(0, 200) + 55);
imagecolortransparent($avatar, $background);
imagefilledrectangle($avatar, 0, 0, $widthHeight, $widthHeight, $background);
// Fill avatar with random parts.
foreach ($parts as &$part) {
$this->drawPart($part, $avatar, $widthHeight, $line_colour, $background);
}
imagepng($avatar, $fileName);
imagecolordeallocate($avatar, $line_colour);
imagecolordeallocate($avatar, $background);
imagedestroy($avatar);
return $fileName;
}
开发者ID:recallfx,项目名称:monsterid.php,代码行数:31,代码来源:MonsterId.php
示例3: overlay
/**
* Overlay an image onto the current image.
*
* @param string $image
* @param int $x
* @param int $y
* @throws Exception
* @return Gd
*/
public function overlay($image, $x = 0, $y = 0)
{
imagealphablending($this->image->resource(), true);
// Create an image resource from the overlay image.
if (stripos($image, '.gif') !== false) {
$overlay = imagecreatefromgif($image);
} else {
if (stripos($image, '.png') !== false) {
$overlay = imagecreatefrompng($image);
} else {
if (stripos($image, '.jp') !== false) {
$overlay = imagecreatefromjpeg($image);
} else {
throw new Exception('Error: The overlay image must be either a JPG, GIF or PNG.');
}
}
}
if ($this->opacity > 0) {
if ($this->opacity == 100) {
imagecopy($this->image->resource(), $overlay, $x, $y, 0, 0, imagesx($overlay), imagesy($overlay));
} else {
imagecopymerge($this->image->resource(), $overlay, $x, $y, 0, 0, imagesx($overlay), imagesy($overlay), $this->opacity);
}
}
return $this;
}
开发者ID:Nnadozieomeonu,项目名称:lacecart,代码行数:35,代码来源:Gd.php
示例4: prepare
public function prepare()
{
if (!isset($this->img['src'])) {
$this->gifsupport = function_exists('imagegif');
// if mimetype detected and in imagemap -> change format
if (class_exists("finfo") && ($finfo = new finfo(FILEINFO_MIME_TYPE))) {
if ($ftype = @$finfo->file($this->img['filepath'])) {
if (array_key_exists($ftype, $this->image_mimetype_map)) {
$this->img['format'] = $this->image_mimetype_map[$ftype];
}
}
}
// ----- detect image format
if ($this->img['format'] == 'jpg' || $this->img['format'] == 'jpeg') {
$this->img['format'] = 'jpeg';
$this->img['src'] = @imagecreatefromjpeg($this->img['filepath']);
} elseif ($this->img['format'] == 'png') {
$this->img['src'] = @imagecreatefrompng($this->img['filepath']);
imagealphablending($this->img['src'], false);
imagesavealpha($this->img['src'], true);
} elseif ($this->img['format'] == 'gif') {
if ($this->gifsupport) {
$this->img['src'] = @imagecreatefromgif($this->img['filepath']);
}
} elseif ($this->img['format'] == 'wbmp') {
$this->img['src'] = @imagecreatefromwbmp($this->img['filepath']);
}
if (isset($this->img['src'])) {
$this->refreshDimensions();
}
}
}
开发者ID:Barnhiac,项目名称:MTW_REDAXO,代码行数:32,代码来源:class.rex_image.inc.php
示例5: showImg
/**
+----------------------------------------------------------
* 显示服务器图像文件
* 支持URL方式
+----------------------------------------------------------
* @static
* @access public
+----------------------------------------------------------
* @param string $imgFile 图像文件名
* @param string $text 文字字符串
* @param string $width 图像宽度
* @param string $height 图像高度
+----------------------------------------------------------
* @return void
+----------------------------------------------------------
*/
static function showImg($imgFile, $text = '', $width = 80, $height = 30)
{
//获取图像文件信息
$info = Image::getImageInfo($imgFile);
if ($info !== false) {
$createFun = str_replace('/', 'createfrom', $info['mime']);
$im = $createFun($imgFile);
if ($im) {
$ImageFun = str_replace('/', '', $info['mime']);
if (!empty($text)) {
$tc = imagecolorallocate($im, 0, 0, 0);
imagestring($im, 3, 5, 5, $text, $tc);
}
if ($info['type'] == 'png' || $info['type'] == 'gif') {
imagealphablending($im, false);
//取消默认的混色模式
imagesavealpha($im, true);
//设定保存完整的 alpha 通道信息
}
Header("Content-type: " . $info['mime']);
$ImageFun($im);
@ImageDestroy($im);
return;
}
}
//获取或者创建图像文件失败则生成空白PNG图片
$im = imagecreatetruecolor($width, $height);
$bgc = imagecolorallocate($im, 255, 255, 255);
$tc = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 150, 30, $bgc);
imagestring($im, 4, 5, 5, "NO PIC", $tc);
Image::output($im);
return;
}
开发者ID:kerneltravel,项目名称:QuoraCms,代码行数:50,代码来源:Image.class.php
示例6: fill_watermark
public function fill_watermark()
{
$image = $this->editor->get_image();
$size = $this->editor->get_size();
list($mask_width, $mask_height, $mask_type, $mask_attr) = getimagesize($this->args['mask']);
switch ($mask_type) {
case 1:
$mask = imagecreatefromgif($this->args['mask']);
break;
case 2:
$mask = imagecreatefromjpeg($this->args['mask']);
break;
case 3:
$mask = imagecreatefrompng($this->args['mask']);
break;
}
imagealphablending($image, true);
if (strpos($this->args['position'], 'left') !== false) {
$left = $this->args['padding'];
} else {
$left = $size['width'] - $mask_width - $this->args['padding'];
}
if (strpos($this->args['position'], 'top') !== false) {
$top = $this->args['padding'];
} else {
$top = $size['height'] - $mask_height - $this->args['padding'];
}
imagecopy($image, $mask, $left, $top, 0, 0, $mask_width, $mask_height);
$this->editor->update_image($image);
imagedestroy($mask);
}
开发者ID:BlessySoftwares,项目名称:anvelocom,代码行数:31,代码来源:wpthumb.watermark.php
示例7: zoom
namespace common;
class upload
{
//从tmp中移动upload
public static function zoom(&$file, &$maxWidth = 0, &$maxHeight = 0)
{
list($width, $height, $im, $func, $ext) = self::_init($file);
if (!$im) {
\yk\log::runlog('file upload error: im not found', 'upload');
return false;
}
if ($maxWidth > 0) {
$p = max($width / $maxWidth, $height / $maxHeight);
$dstwidth = intval($width / $p);
$dstheight = intval($height / $p);
} else {
$dstwidth = $width;
$dstheight = $height;
}
$maxWidth = $dstwidth;
$maxHeight = $dstheight;
$dstim = imagecreatetruecolor($dstwidth, $dstheight);
imagealphablending($dstim, false);
//关闭混杂模式,不可缺少, PHP文档中说明: (在非混色模式下,画笔颜色连同其 alpha 通道信息一起被拷贝,替换掉目标像素。混色模式在画调色板图像时不可用。) 而且是imagesavealpha方法起作用的前置步骤.
imagesavealpha($dstim, true);
//保存 PNG 图像时保存完整的 alpha 通道信息
$transparent = imagecolorallocatealpha($dstim, 255, 255, 255, 127);
//取得一个透明的颜色, 透明度在 0-127 间
imagefill($dstim, 0, 0, $transparent);
imagecopyresampled($dstim, $im, 0, 0, 0, 0, $dstwidth, $dstheight, $width, $height);
$file = uniqid() . $ext;
开发者ID:xiaoniainiu,项目名称:php-yaf-yk,代码行数:32,代码来源:upload.php
示例8: render_block
function render_block($left_side, $top_side, $right_side)
{
global $size;
$size = 2048;
$x1 = (2 - sqrt(3)) * 0.25 * $size;
$x2 = 0.5 * $size;
$x3 = (2 + sqrt(3)) * 0.25 * $size;
$y1 = 0;
$y2 = 0.25 * $size;
$y3 = 0.5 * $size;
$y4 = 0.75 * $size;
$y5 = $size;
$first_poligon = array($x1, $y2, $x2, $y3, $x2, $y5, $x1, $y4);
$second_poligon = array($x1, $y2, $x2, $y1, $x3, $y2, $x2, $y3);
$third_poligon = array($x2, $y3, $x3, $y2, $x3, $y4, $x2, $y5);
$im = imagecreatetruecolor($size, $size);
// Transparentbackground
imagealphablending($im, true);
imagesavealpha($im, true);
$trans = imagecolorallocatealpha($im, 0, 0, 0, 127);
imagefill($im, 0, 0, $trans);
imagetranslatedtexture($im, $first_poligon, imagelight(load_png($left_side), 96));
imagetranslatedtexture($im, $second_poligon, load_png($top_side));
imagetranslatedtexture($im, $third_poligon, imagelight(load_png($right_side), 64));
return $im;
}
开发者ID:mcenderdragon,项目名称:Icon-Craft,代码行数:26,代码来源:block_renderer.php
示例9: imagemergealpha
function imagemergealpha($i)
{
//create a new image
$s = imagecreatetruecolor(imagesx($i[0]), imagesy($i[1]));
$back_color = imagecolorallocate($s, 0xa9, 0xb1, 0xd3);
//merge all images
imagealphablending($s, true);
$z = $i;
while ($d = each($z)) {
imagecopy($s, $d[1], 0, 0, 0, 0, imagesx($d[1]), imagesy($d[1]));
}
//restore the transparency
imagealphablending($s, false);
$w = imagesx($s);
$h = imagesy($s);
for ($x = 0; $x < $w; $x++) {
for ($y = 0; $y < $h; $y++) {
$c = imagecolorat($s, $x, $y);
$c = imagecolorsforindex($s, $c);
$z = $i;
$t = 0;
while ($d = each($z)) {
$ta = imagecolorat($d[1], $x, $y);
$ta = imagecolorsforindex($d[1], $ta);
$t += 127 - $ta['alpha'];
}
$t = $t > 127 ? 127 : $t;
$t = 127 - $t;
$c = imagecolorallocatealpha($s, $c['red'], $c['green'], $c['blue'], $t);
imagesetpixel($s, $x, $y, $c);
}
}
imagesavealpha($s, true);
return $s;
}
开发者ID:relaismago,项目名称:outils,代码行数:35,代码来源:wanted.php
示例10: Resize
public function Resize($image, $newWidth, $targetName)
{
if (!file_exists(PUBLIC_ROOT . $image)) {
$image = '/assets/images/not-found.gif';
}
$imgInfo = getimagesize(PUBLIC_ROOT . $image);
$oldWidth = $imgInfo[0];
$oldHeight = $imgInfo[1];
$changeRatio = $oldWidth / $newWidth;
$newHeight = round($oldHeight / $changeRatio);
$newImage = imagecreatetruecolor($newWidth, $newHeight);
$source = $this->load(PUBLIC_ROOT . $image);
if ($this->imageType == IMAGETYPE_PNG) {
imagealphablending($newImage, false);
imagesavealpha($newImage, true);
$transparent = imagecolorallocatealpha($newImage, 255, 255, 255, 127);
imagefilledrectangle($newImage, 0, 0, $newWidth, $newHeight, $transparent);
}
imagecopyresampled($newImage, $this->image, 0, 0, 0, 0, $newWidth, $newHeight, $oldWidth, $oldHeight);
header('Content-Type: image/jpeg');
imagejpeg($newImage, $targetName, 100);
Debugger::debug($targetName, 'TARGET');
//$this->save($targetName);
$this->image = $newImage;
imagedestroy($newImage);
}
开发者ID:lenlyle1,项目名称:lightupdating,代码行数:26,代码来源:Resize.php
示例11: run
public static function run($res, $width = NULL, $height = NULL)
{
$dst_w = Image::width($res);
$dst_h = Image::height($res);
if (!empty($width) && !empty($height)) {
$dst_w = $width;
$dst_h = $height;
} elseif (empty($height)) {
$ratio = $dst_h / $dst_w;
$dst_w = $width;
$dst_h = round($dst_w * $ratio);
} elseif (empty($width)) {
$ratio = $dst_w / $dst_h;
$dst_h = $height;
$dst_w = round($dst_h * $ratio);
}
$dst = imagecreatetruecolor($dst_w, $dst_h);
/* making the new image transparent */
$background = imagecolorallocate($dst, 0, 0, 0);
ImageColorTransparent($dst, $background);
// make the new temp image all transparent
imagealphablending($dst, false);
imagesavealpha($dst, true);
imageAntiAlias($dst, true);
self::__fill($dst);
imagecopyresampled($dst, $res, 0, 0, 0, 0, $dst_w, $dst_h, Image::width($res), Image::height($res));
@imagedestroy($res);
return $dst;
}
开发者ID:bauhouse,项目名称:sym-barebones,代码行数:29,代码来源:filter.resize.php
示例12: getImage
public function getImage($data)
{
$pngData = $this->encode($data);
if ($pngData == null) {
return null;
}
$h = count($pngData);
$w = strlen($pngData[0]);
$imgW = $w + 2 * $this->outerFrame;
$imgH = $h + 2 * $this->outerFrame;
$qrcode_image = imagecreatetruecolor($imgW, $imgH);
imagealphablending($qrcode_image, false);
$qrBackColor = imagecolorallocatealpha($qrcode_image, 255, 255, 255, 127);
imagefill($qrcode_image, 0, 0, $qrBackColor);
imagesavealpha($qrcode_image, true);
if (!empty($this->fgcolor) && (substr($this->fgcolor, 0, 1) == '#' && strlen(trim($this->fgcolor)) == 7 || strlen(trim($this->fgcolor)) == 6)) {
$rgb = str_split(ltrim($this->fgcolor, '#'), 2);
$qrColor = imagecolorallocatealpha($qrcode_image, hexdec($rgb[0]), hexdec($rgb[1]), hexdec($rgb[2]), 0);
} else {
$qrColor = imagecolorallocatealpha($qrcode_image, 0, 0, 0, 0);
}
for ($y = 0; $y < $h; $y++) {
for ($x = 0; $x < $w; $x++) {
if ($pngData[$y][$x] == '1') {
imagesetpixel($qrcode_image, $x + $this->outerFrame, $y + $this->outerFrame, $qrColor);
}
}
}
return $qrcode_image;
}
开发者ID:q0821,项目名称:esportshop,代码行数:30,代码来源:qrcode.php
示例13: createImage
function createImage($name, $filename, $new_w, $new_h)
{
$system2 = explode('.', strtolower(basename($filename)));
$system2[1] = $system2[1];
$src_img = imagecreatefromstring(readFileData($name));
$old_w = imageSX($src_img);
$old_h = imageSY($src_img);
$thumb_w = $new_w;
$thumb_h = $new_h;
if ($new_w > $old_w) {
$thumb_w = $old_w;
$thumb_h = $thumb_w / $old_w * $old_h;
} else {
$thumb_w = $new_w;
$thumb_h = $thumb_w / $old_w * $old_h;
}
if ($thumb_h > $new_h) {
$thumb_h = $new_h;
$thumb_w = $thumb_h / $old_h * $old_w;
}
$dst_img = ImageCreateTrueColor($thumb_w, $thumb_h);
imagealphablending($dst_img, false);
imagesavealpha($dst_img, true);
$transparent = imagecolorallocatealpha($dst_img, 255, 255, 255, 127);
imagefilledrectangle($dst_img, 0, 0, $thumb_w, $thumb_h, $transparent);
imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $thumb_w, $thumb_h, $old_w, $old_h);
if (preg_match("/png/", $system2[1])) {
imagepng($dst_img, $filename);
} else {
imagejpeg($dst_img, $filename, 90);
}
imagedestroy($dst_img);
imagedestroy($src_img);
}
开发者ID:qichangjun,项目名称:HTMLLearn,代码行数:34,代码来源:upload.php
示例14: scale
/**
* @param int $width Target width
* @param int $height Target height
* @param bool $toFit If true, image fill fit to given dimensions, if false, it will cover them
* @param bool $force If true, image will be resized even if target dimensions are larger than original
*/
protected function scale($width, $height, $toFit, $force)
{
if (null === $this->_image) {
return;
}
$rawWidth = $this->_getWidth();
$rawHeight = $this->_getHeight();
$widthOver = $rawWidth / $width;
$heightOver = $rawHeight / $height;
if ($toFit) {
$scalingFactor = max($widthOver, $heightOver);
} else {
$scalingFactor = min($widthOver, $heightOver);
}
if ($scalingFactor > 1 || $force) {
$destWidth = $rawWidth / $scalingFactor;
$destHeight = $rawHeight / $scalingFactor;
$destImage = imagecreatetruecolor($destWidth, $destHeight);
imagealphablending($destImage, false);
imagesavealpha($destImage, true);
$transparent = imagecolorallocatealpha($destImage, 255, 255, 255, 127);
imagefill($destImage, 0, 0, $transparent);
imagecopyresampled($destImage, $this->_image, 0, 0, 0, 0, $destWidth, $destHeight, $rawWidth, $rawHeight);
$this->_image = $destImage;
}
}
开发者ID:appsco,项目名称:component-share,代码行数:32,代码来源:ImageResizer.php
示例15: resize
function resize($src,$dst,$dstw,$dsth,$scala,$percorsosave) {
$src = $percorsosave.$src;
$dst = $percorsosave.$dst;
list($width, $height, $type, $attr) = getimagesize($src);
switch($type){
case 1:$im = imagecreatefromgif($src);break;
case 2:$im = imagecreatefromjpeg($src);break;
case 3:$im = imagecreatefrompng($src);break;
case 8:$im = imagecreatefromwbmp($src);break;
default:break;
}
If ($dstw == "0" && $dsth == "0") {
$dstw = $width;
$dsth = $height;
}
switch($scala){
//scala in base alla lunghezza
case 1:
$dsth=($height*$dstw)/$width;
break;
//scala in base all'altezza
case 2:
$dstw=($width*$dsth)/$height;
break;
default:break;
};
$tim = imagecreatetruecolor($dstw,$dsth);
imagesavealpha($tim,true);
imagealphablending($tim,false);
imagecopyresampled($tim,$im,0,0,0,0,$dstw,$dsth,$width,$height);
ImageJPEG($tim,$dst,90);
imagedestroy($tim);
}
开发者ID:arkosoft,项目名称:sitoweb-sadmin,代码行数:34,代码来源:functions.php
示例16: action_thumb
public function action_thumb()
{
if (!preg_match('/^image\\/.*$/i', $this->attachment['mime'])) {
$ext = File::ext_by_mime($this->attachment['mime']);
if (file_exists(DOCROOT . 'img/icons/' . $ext . '-icon-128x128.png')) {
$this->redirect('/img/icons/' . $ext . '-icon-128x128.png');
} else {
$this->redirect('http://stdicon.com/' . $this->attachment['mime'] . '?size=96&default=http://stdicon.com/text');
}
}
if (!file_exists(DOCROOT . 'storage/' . $this->attachment['id'] . '.thumb')) {
if (!file_exists(DOCROOT . 'storage/' . $this->attachment['id'])) {
$this->redirect('http://stdicon.com/' . $this->attachment['mime'] . '?size=96&default=http://stdicon.com/text');
}
$data = file_get_contents(DOCROOT . 'storage/' . $this->attachment['id']);
$image = imagecreatefromstring($data);
$x = imagesx($image);
$y = imagesy($image);
$size = max($x, $y);
$x = round($x / $size * 96);
$y = round($y / $size * 96);
$thumb = imagecreatetruecolor($x, $y);
imagealphablending($thumb, false);
imagesavealpha($thumb, true);
imagecopyresampled($thumb, $image, 0, 0, 0, 0, $x, $y, imagesx($image), imagesy($image));
imagepng($thumb, DOCROOT . 'storage/' . $this->attachment['id'] . '.thumb', 9);
}
header('Content-type: image/png');
header('Content-disposition: filename="thumbnail.png"');
header('Content-length: ' . filesize(DOCROOT . 'storage/' . $this->attachment['id'] . '.thumb'));
readfile(DOCROOT . 'storage/' . $this->attachment['id'] . '.thumb');
die;
}
开发者ID:Alex-AG,项目名称:exeltek-po,代码行数:33,代码来源:Download.php
示例17: modify
/**
* Wrapper function for 'imagecopyresampled'
*
* @param Image $image
* @param integer $dst_x
* @param integer $dst_y
* @param integer $src_x
* @param integer $src_y
* @param integer $dst_w
* @param integer $dst_h
* @param integer $src_w
* @param integer $src_h
* @return boolean
*/
protected function modify($image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h)
{
foreach ($image as $frame) {
// create new image
$modified = imagecreatetruecolor($dst_w, $dst_h);
// get current image
$resource = $frame->getCore();
// preserve transparency
$transIndex = imagecolortransparent($resource);
if ($transIndex != -1) {
$rgba = imagecolorsforindex($modified, $transIndex);
$transColor = imagecolorallocatealpha($modified, $rgba['red'], $rgba['green'], $rgba['blue'], 127);
imagefill($modified, 0, 0, $transColor);
imagecolortransparent($modified, $transColor);
} else {
imagealphablending($modified, false);
imagesavealpha($modified, true);
}
// copy content from resource
imagecopyresampled($modified, $resource, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
// free memory of old core
imagedestroy($resource);
// set new content as recource
$frame->setCore($modified);
}
return true;
}
开发者ID:EdgarPost,项目名称:image,代码行数:41,代码来源:ResizeCommand.php
示例18: build
/**
* Build the CSS sprite in memory
* @return Tinyfier_Image_Tool
*/
public function build()
{
//Sort images inside the sprite
$y = 0;
foreach ($this->_images as $image) {
$image->top = $y;
$image->left = 0;
$y += $image->image->height();
}
//Draw sprite
$w = 0;
$h = 0;
foreach ($this->_images as $image) {
$w = max($w, $image->left + $image->image->width());
$h = max($w, $image->top + $image->image->height());
}
$sprite = imagecreatetruecolor($w, $h);
imagealphablending($sprite, false);
//Soporte de transparencias
imagefill($sprite, 0, 0, imagecolorallocatealpha($sprite, 0, 0, 0, 127));
//Fondo transparente
foreach ($this->_images as $image) {
imagecopy($sprite, $image->image->handle(), $image->left, $image->top, 0, 0, $image->image->width(), $image->image->height());
}
return new Tinyfier_Image_Tool($sprite);
}
开发者ID:ideatic,项目名称:tinyfier,代码行数:30,代码来源:Sprite.php
示例19: image
private static function image($frame, $pixelPerPoint = 4, $outerFrame = 4)
{
$h = count($frame);
$w = strlen($frame[0]);
$imgW = $w + 2 * $outerFrame;
$imgH = $h + 2 * $outerFrame;
$base_image = imagecreatetruecolor($imgW, $imgH);
$col[0] = ImageColorAllocate($base_image, 255, 0, 255);
$col[1] = ImageColorAllocate($base_image, 0, 0, 0);
imagecolortransparent($base_image, $col[0]);
imagealphablending($base_image, true);
imagesavealpha($base_image, true);
// imagefill($base_image, 0, 0, $col[0]);
imagefill($base_image, 0, 0, 0x7fff0000);
for ($y = 0; $y < $h; $y++) {
for ($x = 0; $x < $w; $x++) {
if ($frame[$y][$x] == '1') {
ImageSetPixel($base_image, $x + $outerFrame, $y + $outerFrame, $col[1]);
}
}
}
$target_image = ImageCreate($imgW * $pixelPerPoint, $imgH * $pixelPerPoint);
ImageCopyResized($target_image, $base_image, 0, 0, 0, 0, $imgW * $pixelPerPoint, $imgH * $pixelPerPoint, $imgW, $imgH);
ImageDestroy($base_image);
return $target_image;
}
开发者ID:aplitax,项目名称:PHPQRCode,代码行数:26,代码来源:QRimage.php
示例20: merge
function merge($width, $height)
{
$array_variable = get_variable();
$bg = $array_variable[0];
$over = $array_variable[1];
$outputFile = $array_variable[2];
$result = $array_variable[3];
$path_to_save = $array_variable[4];
$n = $array_variable[5];
$tmp_img = $path_to_save . "/tmp_" . $n . ".png";
// $result_jpg_compressed = $path_to_save.'/'.$n.'.JPG';
// $base_image = imagecreatefrompng($bg);
jpg2png($bg, $outputFile);
$base_image = imagecreatefrompng($outputFile);
$top_image = imagecreatefrompng($over);
// $merged_image = $result;
imagesavealpha($top_image, true);
imagealphablending($top_image, true);
imagecopy($base_image, $top_image, 0, 0, 0, 0, $width, $height);
imagepng($base_image, $result);
// rename to temp for compression
rename($result, $path_to_save . "/tmp_" . $n . ".png");
// compress IMG
$img = imagecreatefrompng($tmp_img);
// imagejpeg($img,$result_jpg_compressed,75);
imagejpeg($img, $result, 75);
unlink($tmp_img);
unlink($tmp_img);
// if necessery !!!!!!!!!!!!!!!!!!!
unlink($outputFile);
unlink($over);
}
开发者ID:vincseize,项目名称:GDC,代码行数:32,代码来源:saveCanvas_OLD1.php
注:本文中的imagealphablending函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论