本文整理汇总了PHP中imagecolorresolvealpha函数的典型用法代码示例。如果您正苦于以下问题:PHP imagecolorresolvealpha函数的具体用法?PHP imagecolorresolvealpha怎么用?PHP imagecolorresolvealpha使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了imagecolorresolvealpha函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: zbx_colormix
/**
* Calculate new color based on bg/fg colors and transparency index
*
* @param resource $image image reference
* @param array $bgColor background color, array of RGB
* @param array $fgColor foreground color, array of RGB
* @param float $alpha transparency index in range of 0-1, 1 returns unchanged fgColor color
*
* @return array new color
*/
function zbx_colormix($image, $bgColor, $fgColor, $alpha)
{
$r = $bgColor[0] + ($fgColor[0] - $bgColor[0]) * $alpha;
$g = $bgColor[1] + ($fgColor[1] - $bgColor[1]) * $alpha;
$b = $bgColor[2] + ($fgColor[2] - $bgColor[2]) * $alpha;
return imagecolorresolvealpha($image, $r, $g, $b, 0);
}
开发者ID:TonywalkerCN,项目名称:Zabbix,代码行数:17,代码来源:draw.inc.php
示例2: fromBlank
/**
* Creates blank image.
* @param int
* @param int
* @param array
* @return self
*/
public static function fromBlank($width, $height, $color = NULL)
{
if (!extension_loaded('gd')) {
throw new Exception('PHP extension GD is not loaded.');
}
$width = (int) $width;
$height = (int) $height;
if ($width < 1 || $height < 1) {
throw new InvalidArgumentException('Image width and height must be greater than zero.');
}
$image = imagecreatetruecolor($width, $height);
if (is_array($color)) {
$color += ['alpha' => 0];
$color = imagecolorresolvealpha($image, $color['red'], $color['green'], $color['blue'], $color['alpha']);
imagealphablending($image, FALSE);
imagefilledrectangle($image, 0, 0, $width - 1, $height - 1, $color);
imagealphablending($image, TRUE);
}
return new static($image);
}
开发者ID:vojtabiberle,项目名称:MediaStorage,代码行数:27,代码来源:Image.php
示例3: __construct
/**
* Возвращает новый экземпляр GDImage
* @param string $source Путь к исходному файлу. NULL - создание пустого изображения
* @param Size $s Размер изображения. NULL - использовать размеры исходного файла
* @param int $resizeMode Режим изменения размера. Используется, если $s не совпадает с размерами исходного изображения
* @throws GDException
*/
function __construct($source = NULL, Size $s = NULL, $resizeMode = self::RESIZE_FIT)
{
$s !== NULL or $s = new Size(100, 100);
if (!empty($source)) {
$this->source = (string) $source;
if (!($sizes = @getimagesize($source))) {
throw new GDException('Файл не является допустимым форматом изображения.');
}
list($type, $subtype) = explode('/', $sizes['mime']);
if ($type != 'image') {
throw new GDException('Файл не является допустимым форматом изображения.');
}
switch ($subtype) {
case 'gif':
$this->handle = @imagecreatefromgif($source);
break;
case 'jpeg':
$this->handle = @imagecreatefromjpeg($source);
break;
case 'png':
$this->handle = @imagecreatefrompng($source);
break;
default:
throw new GDException('Файл не является допустимым форматом изображения.');
}
if ($this->handle === FALSE) {
$this->handle = NULL;
throw new GDException('Невозможно инициализировать GD поток');
}
$this->format = (string) $subtype;
if ($s !== NULL) {
$this->size($s, $resizeMode);
}
} else {
if (($this->handle = @imagecreatetruecolor($s->width, $s->height)) === FALSE) {
$this->handle = NULL;
throw new GDException('Невозможно инициализировать GD поток');
}
imagefill($this->handle, 0, 0, imagecolorresolvealpha($this->handle, 0, 0, 0, 127));
}
}
开发者ID:shevtsov-s,项目名称:planetsbook,代码行数:48,代码来源:GDImage.php
示例4: GetDarkColorIndex
protected function GetDarkColorIndex($color)
{
list($r, $g, $b, $a) = $color;
$r = max(0, $r - 0x30);
$g = max(0, $g - 0x30);
$b = max(0, $b - 0x30);
return imagecolorresolvealpha($this->img, $r, $g, $b, $a);
}
开发者ID:danorama,项目名称:orsee,代码行数:8,代码来源:class.phplot.php
示例5: Allocate
function Allocate($aColor)
{
list($r, $g, $b) = $this->color($aColor);
if ($GLOBALS['gd2'] == true) {
return imagecolorresolvealpha($this->img, $r, $g, $b, 0);
} else {
$index = imagecolorexact($this->img, $r, $g, $b);
if ($index == -1) {
$index = imagecolorallocate($this->img, $r, $g, $b);
if (USE_APPROX_COLORS && $index == -1) {
$index = imagecolorresolve($this->img, $r, $g, $b);
}
}
return $index;
}
}
开发者ID:rrsc,项目名称:freemed,代码行数:16,代码来源:jpgraph.php
示例6: __call
/**
* Call to undefined method.
*
* @param string method name
* @param array arguments
* @return mixed
* @throws Nette\MemberAccessException
*/
public function __call($name, $args)
{
$function = 'image' . $name;
if (!function_exists($function)) {
return parent::__call($name, $args);
}
foreach ($args as $key => $value) {
if ($value instanceof self) {
$args[$key] = $value->getImageResource();
} elseif (is_array($value) && isset($value['red'])) {
// rgb
$args[$key] = imagecolorallocatealpha($this->image, $value['red'], $value['green'], $value['blue'], $value['alpha']) ?: imagecolorresolvealpha($this->image, $value['red'], $value['green'], $value['blue'], $value['alpha']);
}
}
array_unshift($args, $this->image);
$res = $function(...$args);
return is_resource($res) && get_resource_type($res) === 'gd' ? $this->setImageResource($res) : $res;
}
开发者ID:radekdostal,项目名称:utils,代码行数:26,代码来源:Image.php
示例7: Allocate
function Allocate($aColor, $aAlpha = 0.0)
{
list($r, $g, $b, $a) = $this->color($aColor);
if ($a > 0) {
$aAlpha = $a;
}
if ($aAlpha < 0 || $aAlpha > 1) {
JpGraphError::RaiseL(25080);
}
return imagecolorresolvealpha($this->img, $r, $g, $b, round($aAlpha * 127));
}
开发者ID:natanoj,项目名称:nuBuilderPro,代码行数:11,代码来源:gd_image.inc.php
示例8: header
<?php
header('content-type:image/jpeg');
//在白色背景上绘制一个椭圆
$image = imagecreatetruecolor(150, 150);
$white = imagecolorallocate($image, 255, 255, 255);
imagealphablending($image, false);
imagefilledrectangle($image, 0, 0, 150, 150, $white);
$red = imagecolorresolvealpha($image, 255, 50, 0, 50);
imagefilledellipse($image, 75, 75, 80, 63, $red);
imagejpeg($image);
imagedestroy($image);
开发者ID:denson7,项目名称:phpstudy,代码行数:12,代码来源:image5.php
示例9: print_r
print_r(imagecolorsforindex($im, $c));
// with alpha
$im = imagecreatetruecolor(5, 5);
$c = imagecolorclosestalpha($im, 255, 0, 255, 100);
printf("%X\n", $c);
imagedestroy($im);
$im = imagecreate(5, 5);
$c = imagecolorclosestalpha($im, 255, 0, 255, 100);
print_r(imagecolorsforindex($im, $c));
imagedestroy($im);
$im = imagecreate(5, 5);
imagecolorallocatealpha($im, 255, 0, 255, 1);
$c = imagecolorclosestalpha($im, 255, 0, 255, 1);
print_r(imagecolorsforindex($im, $c));
imagedestroy($im);
$im = imagecreate(5, 5);
for ($i = 0; $i < 255; $i++) {
imagecolorresolvealpha($im, $i, 0, 0, 1);
}
$c = imagecolorclosestalpha($im, 255, 0, 0, 1);
print_r(imagecolorsforindex($im, $c));
$im = imagecreate(5, 5);
for ($i = 0; $i < 256; $i++) {
if ($i == 246) {
imagecolorallocatealpha($im, $i, 10, 10, 1);
} else {
imagecolorallocatealpha($im, $i, 0, 0, 100);
}
}
$c = imagecolorclosestalpha($im, 255, 10, 10, 1);
print_r(imagecolorsforindex($im, $c));
开发者ID:badlamer,项目名称:hhvm,代码行数:31,代码来源:colorclosest.php
示例10: Allocate
function Allocate($aImg, $aColor, $aAlpha = 0.0)
{
$res = $this->Color($aColor);
if ($res === false) {
return false;
}
list($r, $g, $b, $a) = $res;
if ($a > 0) {
$aAlpha = $a;
}
if ($aAlpha < 0 || $aAlpha > 1) {
return false;
}
return imagecolorresolvealpha($aImg, $r, $g, $b, round($aAlpha * 127));
}
开发者ID:natanoj,项目名称:nuBuilderPro,代码行数:15,代码来源:rgb_colors.inc.php
示例11: resolve
public function resolve($rgb = '')
{
if (!!is_string($rgb)) {
Error::set(lang('Error', 'stringParameter', '1.(rgb)'));
return false;
}
$rgb = explode('|', $rgb);
$red = isset($rgb[0]) ? $rgb[0] : 0;
$green = isset($rgb[1]) ? $rgb[1] : 0;
$blue = isset($rgb[2]) ? $rgb[2] : 0;
$alpha = isset($rgb[3]) ? $rgb[3] : 0;
return imagecolorresolvealpha($this->canvas, $red, $green, $blue, $alpha);
}
开发者ID:Allopa,项目名称:ZN-Framework-Starter,代码行数:13,代码来源:GD.php
示例12: render
/**
* Apply tools to image.
*
* This function scan for mask color and closes colors position, grab color
* at found the position on sample image, then set the pixel color at the same
* position on destination image.
*
* @return bool|PEAR_Error TRUE on success or PEAR_Error on failure.
* @access private
* @see Image_Tools_Mask::_getNearestColors()
*/
function render()
{
if (!Image_Tools::isGDImageResource($this->_maskImage)) {
return PEAR::raiseError('Invalid image resource Image_Tools_Mask::$_maskImage');
}
if (!Image_Tools::isGDImageResource($this->_sampleImage)) {
return PEAR::raiseError('Invalid image resource Image_Tools_Mask::$_sampleImage');
}
if (!Image_Tools::isGDImageResource($this->resultImage)) {
return PEAR::raiseError('Invalid image resource Image_Tools_Mask::$_resultImage');
}
$maskWidth = imagesx($this->_maskImage);
$maskHeight = imagesy($this->_maskImage);
$sampleWidth = imagesx($this->_sampleImage);
$sampleHeight = imagesy($this->_sampleImage);
if ($this->options['antialias']) {
$closesColors = $this->_getNearestColors();
} else {
$closesColors = array($this->options['maskColor']);
}
imagealphablending($this->resultImage, true);
// scan for mask color or closes colors position
for ($x = 0; $x < $maskWidth; $x++) {
for ($y = 0; $y < $maskHeight; $y++) {
if ($x >= $sampleWidth || $y >= $sampleHeight) {
continue;
}
// grab color at x, y and convert to hex color format
$index = imagecolorat($this->_maskImage, $x, $y);
$maskRGBA = imagecolorsforindex($this->_maskImage, $index);
$maskColor = Image_Color::rgb2hex(array_values($maskRGBA));
// check color in closes colors collection
if (in_array($maskColor, $closesColors)) {
// grab color at x, y from sample image
$index = imagecolorat($this->_sampleImage, $x, $y);
$sampleRGBA = imagecolorsforindex($this->_sampleImage, $index);
// allocate color on destination image
$color = imagecolorresolvealpha($this->resultImage, $sampleRGBA['red'], $sampleRGBA['green'], $sampleRGBA['blue'], $sampleRGBA['alpha']);
// set a pixel color at destination image
imagesetpixel($this->resultImage, $x, $y, $color);
}
}
}
return true;
}
开发者ID:Esleelkartea,项目名称:kz-adeada-talleres-electricos-,代码行数:56,代码来源:Mask.php
示例13: imagecolorresolve
} else {
imagecolorresolve($im, $i, 0, 0);
}
}
$c = imagecolorresolve($im, 255, 10, 10);
print_r(imagecolorsforindex($im, $c));
// with alpha
$im = imagecreatetruecolor(5, 5);
$c = imagecolorresolvealpha($im, 255, 0, 255, 100);
printf("%X\n", $c);
imagedestroy($im);
$im = imagecreate(5, 5);
$c = imagecolorresolvealpha($im, 255, 0, 255, 100);
print_r(imagecolorsforindex($im, $c));
imagedestroy($im);
$im = imagecreate(5, 5);
for ($i = 0; $i < 255; $i++) {
imagecolorresolvealpha($im, $i, 0, 0, 1);
}
$c = imagecolorresolvealpha($im, 255, 0, 0, 1);
print_r(imagecolorsforindex($im, $c));
$im = imagecreate(5, 5);
for ($i = 0; $i < 256; $i++) {
if ($i == 246) {
imagecolorresolvealpha($im, $i, 10, 10, 1);
} else {
imagecolorresolvealpha($im, $i, 0, 0, 100);
}
}
$c = imagecolorresolvealpha($im, 255, 10, 10, 0);
print_r(imagecolorsforindex($im, $c));
开发者ID:badlamer,项目名称:hhvm,代码行数:31,代码来源:colorresolve.php
示例14: generate
//.........这里部分代码省略.........
$sys[4] = $row2['sys_id'];
$sys[5] = $row2['sys_name'];
$sys[6] = $row2['sys_sec'];
$fp = fopen($regioncache . ".txt", "r");
// getting offset data from file
$maxx = fgets($fp);
$minx = fgets($fp);
$maxz = fgets($fp);
$minz = fgets($fp);
fclose($fp);
$dx = abs($maxx - $minx);
$dz = abs($maxz - $minz);
$xscale = 1 / ($dx / ($this->imgwidth_ - $this->offset_ * 2));
$yscale = 1 / ($dz / ($this->imgheight_ - $this->offset_ * 2));
$px = round($this->offset_ + ($sys[0] - $minx) * $xscale);
$py = round($this->offset_ + ($sys[1] - $minz) * $yscale);
if ($kills == 1) {
// If there is only one kill we use normal highlight color
$ratio = 1;
if (config::get('map_act_cl_hl')) {
$hscolor = explode(",", config::get('map_act_cl_hl'));
$color = imagecolorallocate($img, $hscolor[0], $hscolor[1], $hscolor[2]);
} else {
$color = imagecolorallocate($img, '255', '209', '57');
}
} else {
//more then one kill...
$ratio = $kills + 5;
// ...then we add a bit to the ratio
if (config::get('map_act_cl_hl2')) {
// Set the color to Highlight 2 and the sphere color with alpha
$hscolor = explode(",", config::get('map_act_cl_hl2'));
$color = imagecolorallocate($img, $hscolor[0], $hscolor[1], $hscolor[2]);
$color4 = imagecolorresolvealpha($img, $hscolor[0], $hscolor[1], $hscolor[2], '117');
} else {
$color = imagecolorallocate($img, '255', '0', '0');
$color4 = imagecolorresolvealpha($img, 255, 0, 0, 117);
}
}
if ($ratio > 100) {
//now we limit the max-size of the sphere so it doesnt grow to big
$ratio = 100;
}
imagefilledellipse($img, $px, $py, $ratio, $ratio, $color4);
//paint the sphere -- can not use AA function cause it doesnt work with alpha
imagefilledellipseaa($img, $px, $py, 6, 6, $color);
// use AA function to paint the system dot
if ($ratio > 10) {
// extend the sphere
$ratio2 = $ratio - 10;
imagefilledellipse($img, $px, $py, $ratio2, $ratio2, $color4);
}
if ($ratio > 20) {
// add another inner layer to the sphere, if it gets big enough
$ratio3 = $ratio - 20;
imagefilledellipse($img, $px, $py, $ratio3, $ratio3, $color4);
}
if ($paint_name == 1) {
$tlen = 5 * strlen($sys[5]);
if ($px + $tlen > $this->imgwidth_ - 20) {
$sx = $px - $tlen;
} else {
$sx = $px + 5;
}
if ($py + 5 > $this->imgheight_ - 20) {
$sy = $py - 5;
开发者ID:biow0lf,项目名称:evedev-kb,代码行数:67,代码来源:map.php
示例15: resolve
public function resolve(string $rgb) : int
{
$rgb = explode('|', $rgb);
$red = isset($rgb[0]) ? $rgb[0] : 0;
$green = isset($rgb[1]) ? $rgb[1] : 0;
$blue = isset($rgb[2]) ? $rgb[2] : 0;
$alpha = isset($rgb[3]) ? $rgb[3] : 0;
return imagecolorresolvealpha($this->canvas, $red, $green, $blue, $alpha);
}
开发者ID:znframework,项目名称:znframework,代码行数:9,代码来源:InternalGD.php
示例16: imagecolorresolvealpha
<?php
imagecolorresolvealpha();
?>
开发者ID:gleamingthecube,项目名称:php,代码行数:4,代码来源:ext_gd_tests_imagecolorresolvealpha_error3.php
示例17: resolve
function resolve($image)
{
return imagecolorresolvealpha($image, $this->red, $this->green, $this->blue, $this->alpha);
}
开发者ID:shevtsov-s,项目名称:planetsbook,代码行数:4,代码来源:GDHelpers.php
示例18: Allocate
function Allocate($aColor, $aAlpha = 0.0)
{
list($r, $g, $b, $a) = $this->color($aColor);
// If alpha is specified in the color string then this
// takes precedence over the second argument
if ($a > 0) {
$aAlpha = $a;
}
if (@$GLOBALS['gd2'] == true) {
if ($aAlpha < 0 || $aAlpha > 1) {
JpGraphError::Raise('Alpha parameter for color must be between 0.0 and 1.0');
exit(1);
}
return imagecolorresolvealpha($this->img, $r, $g, $b, round($aAlpha * 127));
} else {
$index = imagecolorexact($this->img, $r, $g, $b);
if ($index == -1) {
$index = imagecolorallocate($this->img, $r, $g, $b);
if (USE_APPROX_COLORS && $index == -1) {
$index = imagecolorresolve($this->img, $r, $g, $b);
}
}
return $index;
}
}
开发者ID:hostellerie,项目名称:nexpro,代码行数:25,代码来源:jpgraph.php
示例19: MakeGradientFilledButtonPolygon
//.........这里部分代码省略.........
// we limit svg conversions to TWO colors only because there is no way to disable
// antialiasing and antialiased images look like hell when we do color conversions
// at a later step.. so, SVG images are relatively useless at this time
$execarg = IMCONVERT . " -resize 10000" . "x{$image_height} -colors 2 {$img_path} {$destfile}";
@exec($execarg);
$img_overlay = imagecreatefrompng($destfile);
@unlink($destfile);
$img_size[0] = imagesx($img_overlay);
$img_size[1] = imagesy($img_overlay);
break;
default:
break;
}
// image and text!
$img_newh = 0;
$img_neww = 0;
$img_x = 0;
$img_y = 0;
if ($img_overlay !== "invalid") {
$img_newh = $image_height;
$img_neww = $img_newh * $img_size[0] / $img_size[1];
// palettize the user image if not already
imagetruecolortopalette($img_overlay, FALSE, 256);
// find the "foreground" color index, if configured to do so
if (!$foreground_none) {
$foregroundindex = imagecolorclosest($img_overlay, $cicolor->red, $cicolor->green, $cicolor->blue);
// and set it to the text color
if ($foregroundindex > -1) {
imagecolorset($img_overlay, $foregroundindex, $ctcolor->red, $ctcolor->green, $ctcolor->blue);
}
}
// find the transparent "background" color index, if configured to do so
if (!$transparent_none) {
$backgroundindex = imagecolorclosest($img_overlay, $citcolor->red, $citcolor->green, $citcolor->blue);
if ($backgroundindex > -1) {
imagecolortransparent($img_overlay, $backgroundindex);
}
}
$img_y = $acthoa / 2 - $img_newh / 2;
$img_x = $actwoa / 2 - $img_neww / 2;
}
// make adjustments for relative positions
if (strcmp($image_locate, "left") == 0) {
$img_x -= $maxwidth / 2 + 5;
foreach ($textlines as &$textline) {
$textline['x'] += $img_neww / 2;
}
unset($textline);
} else {
if (strcmp($image_locate, "right") == 0) {
$img_x += $maxwidth / 2 + 5;
foreach ($textlines as &$textline) {
$textline['x'] -= $img_neww / 2;
}
unset($textline);
}
}
if ($img_overlay !== "invalid" && strcmp($image_locate, "none") != 0) {
imagecopyresampled($baseimage, $img_overlay, $img_x, $img_y, 0, 0, $img_neww, $img_newh, $img_size[0], $img_size[1]);
}
@imagedestroy($img_overlay);
foreach ($textlines as $textline) {
ImageTTFText($baseimage, $text_height, 0, $textline['x'], $textline['y'], $blk, $fontname, $textline['text']);
}
unset($textline);
if ($radius > 0) {
$radiusstart = floor($radius / 1.2);
$radiuslimit = floor($radius / 2.2);
$outersteps = $radiusstart - $radiuslimit;
$blendfactor = 100;
if ($outersteps) {
$blendfactor = 100 * sqrt(1 / $outersteps);
}
// construct a hilight for this button
// $chilitecolor = imagecolorresolvealpha ( $baseimage, 255, 255, 255, 80);
for ($newr = $radiusstart; $newr >= $radiuslimit; $newr--) {
$chilitecolor = imagecolorresolvealpha($baseimage, 255, 255, 255, 100 - floor(100 * ($newr - $radiuslimit) / ($radiusstart - $radiuslimit)));
MyImageArc($baseimage, $radius - 1, $radius, 2 * $radiusstart, 2 * $newr, 180, 270, $chilitecolor);
if ($actwoa > 2 * $radius) {
ImageLine($baseimage, $radius, $radius - $newr, $actwoa - $radius - 1, $radius - $newr, $chilitecolor);
}
MyImageArc($baseimage, $actwoa - $radius, $radius, 2 * $radiusstart, 2 * $newr, 270, 0, $chilitecolor);
}
}
$imagetemp = tempnam(IMGPATH, "");
ImagePNG($baseimage, $imagetemp);
imagedestroy($baseimage);
// experimental, fill the corners with transparent color
if (strcmp(strtoupper($bkcolor), "CLEAR") == 0) {
$execarg = IMMOGRIFY . " -transparent #454545 {$imagetemp}";
@exec($execarg);
}
if ($qualityfactor > 1) {
$neww = $actwoa / $qualityfactor;
$newh = $acthoa / $qualityfactor;
$execarg = IMMOGRIFY . " -resize " . $neww . "x" . $newh . " {$imagetemp}";
@exec($execarg);
}
return $imagetemp;
}
开发者ID:tiggerntatie,项目名称:Buttonmill-glassy-buttons,代码行数:101,代码来源:buttonincludes.php
注:本文中的imagecolorresolvealpha函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论