当前位置: 首页>>代码示例>>PHP>>正文


PHP imagecolorexact函数代码示例

本文整理汇总了PHP中imagecolorexact函数的典型用法代码示例。如果您正苦于以下问题:PHP imagecolorexact函数的具体用法?PHP imagecolorexact怎么用?PHP imagecolorexact使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了imagecolorexact函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getIndex

 /**
  * @param resource $image GD image resource
  * @return int Returns the index of the specified color+alpha in the palette of the image,
  *             or -1 if the color does not exist in the image's palette.
  */
 public function getIndex($image)
 {
     if ($this->hasAlphaChannel()) {
         return imagecolorexactalpha($image, $this->red, $this->green, $this->blue, $this->alpha);
     } else {
         return imagecolorexact($image, $this->red, $this->green, $this->blue);
     }
 }
开发者ID:si2info,项目名称:cinda-server,代码行数:13,代码来源:Color.php

示例2: getColorIndex

 protected function getColorIndex($v)
 {
     if (count($v) == 3) {
         $color = imagecolorexact($this->im, $v[0], $v[1], $v[2]);
     } elseif (count($v) == 4) {
         $color = imagecolorexactalpha($this->im, $v[0], $v[1], $v[2], $v[3]);
     }
     return $color;
 }
开发者ID:shapik2004,项目名称:album2,代码行数:9,代码来源:Box.php

示例3: rgb_allocate

function rgb_allocate($image, $color)
{
    list($r, $g, $b) = rgb_color($color);
    $index = imagecolorexact($image, $r, $g, $b);
    if ($index == -1) {
        return imagecolorallocate($image, $r, $g, $b);
    } else {
        return $index;
    }
}
开发者ID:ruNovel,项目名称:sams2,代码行数:10,代码来源:rgb.php

示例4: color

 protected function color(array $color, $image = false)
 {
     if (!is_array($image)) {
         $image = $this->map;
     }
     list($r, $g, $b) = $color;
     $colorRes = imagecolorexact($image['image'], $r, $g, $b);
     if ($colorRes == -1) {
         $colorRes = imageColorAllocate($image['image'], $r, $g, $b);
     }
     return $colorRes;
 }
开发者ID:Yoyoyozo,项目名称:webDiplomacy,代码行数:12,代码来源:drawMap.php

示例5: toPngColor

 public function toPngColor($img)
 {
     $color = imagecolorexact($img, $this->red, $this->green, $this->blue);
     if ($color == -1) {
         if (imagecolorstotal($img) >= 255) {
             $color = imagecolorclosest($img, $this->red, $this->green, $this->blue);
         } else {
             $color = imagecolorallocate($img, $this->red, $this->green, $this->blue);
         }
     }
     return $color;
 }
开发者ID:eXcomm,项目名称:3D-PHP-Class,代码行数:12,代码来源:Color.class.php

示例6: _get_image_color

 function _get_image_color($im, $r, $g, $b)
 {
     $c = imagecolorexact($im, $r, $g, $b);
     if ($c != -1) {
         return $c;
     }
     $c = imagecolorallocate($im, $r, $g, $b);
     if ($c != -1) {
         return $c;
     }
     return imagecolorclosest($im, $r, $g, $b);
 }
开发者ID:villos,项目名称:tree_admin,代码行数:12,代码来源:Watermark.php

示例7: drawQR

 public function drawQR()
 {
     if (!($qr = $this->getQR())) {
         return false;
     }
     $this->_qrW = imagesx($qr);
     $this->_qrH = imagesy($qr);
     imagecolortransparent($qr, imagecolorexact($qr, 255, 255, 255));
     imagecopy($this->getImg(), $qr, $this->_contentStartX, $this->_contentStartY, 0, 0, $this->_qrW, $this->_qrH);
     //space after qr
     $this->_qrW += 71;
     return true;
 }
开发者ID:kemeice,项目名称:Giftcards,代码行数:13,代码来源:Default.php

示例8: setup

 function setup()
 {
     $this->map = array();
     $nthis->umStarts = 0;
     $this->numBases = 0;
     $this->numPills = 0;
     $this->img = ImageCreate(255, 255);
     $this->pens = array();
     $this->pens[0] = ImageColorAllocate($this->img, 179, 121, 15);
     /* BUILDING */
     $this->pens[1] = ImageColorAllocate($this->img, 0, 255, 255);
     /* RIVER */
     $this->pens[2] = ImageColorAllocate($this->img, 0, 128, 128);
     /* SWAMP */
     $this->pens[3] = ImageColorAllocate($this->img, 128, 64, 0);
     /* CRATER */
     $this->pens[4] = ImageColorAllocate($this->img, 0, 0, 0);
     /* ROAD */
     $this->pens[5] = ImageColorAllocate($this->img, 0, 128, 0);
     /* FOREST */
     $this->pens[6] = ImageColorAllocate($this->img, 234, 165, 123);
     /* RUBBLE */
     $this->pens[7] = ImageColorAllocate($this->img, 0, 255, 0);
     /* GRASS */
     $this->pens[8] = ImageColorAllocate($this->img, 223, 152, 19);
     /* SHOT_BUILDING */
     $this->pens[9] = ImageColorAllocate($this->img, 0, 0, 121);
     /* BOAT */
     $this->pens[10] = ImageColorAllocate($this->img, 0, 128, 128);
     /* SWAMP + MINE */
     $this->pens[11] = ImageColorAllocate($this->img, 128, 64, 0);
     /* CRATER_MINE */
     $this->pens[12] = ImageColorAllocate($this->img, 0, 0, 0);
     /* ROAD_MINE  */
     $this->pens[13] = ImageColorAllocate($this->img, 0, 128, 0);
     /* FOREST_MINE */
     $this->pens[14] = ImageColorAllocate($this->img, 234, 165, 123);
     /* RUBBLE_MINE */
     $this->pens[15] = ImageColorAllocate($this->img, 0, 255, 0);
     /* GrassMine */
     $this->pens[16] = ImageColorAllocate($this->img, 0, 0, 255);
     /* DEEP_SEA */
     $this->pens[18] = ImageColorAllocate($this->img, 255, 0, 0);
     /* PILLBOX */
     $this->pens[17] = ImageColorAllocate($this->img, 255, 255, 0);
     /* BASE */
     $this->pens[19] = ImageColorAllocate($this->img, 128, 128, 128);
     /* START */
     ImageFilledRectangle($this->img, 0, 0, 255, 255, $this->pens[16]);
     $this->water = imagecolorexact($this->img, 0, 0, 255);
 }
开发者ID:andrewroth,项目名称:winbolo,代码行数:51,代码来源:mapimageclass.php

示例9: myimagecolorallocate

function myimagecolorallocate($image, $red, $green, $blue)
{
    // it's possible that we're being called early - just return straight away, in that case
    if (!isset($image)) {
        return -1;
    }
    if (1 == 0) {
        $existing = imagecolorexact($image, $red, $green, $blue);
        if ($existing > -1) {
            return $existing;
        }
    }
    return imagecolorallocate($image, $red, $green, $blue);
}
开发者ID:jiangxilong,项目名称:network-weathermap,代码行数:14,代码来源:image-functions.php

示例10: set_reasonable_image_size

function set_reasonable_image_size($image, $filename)
{
	global $CONF;
	list($width, $height) = getimagesize($filename);
	if ($width <= $CONF['user_temp_avatar_max_width'] && $height <= $CONF['user_temp_avatar_max_height'])
		return $image;
	$size = resize_dimensions($CONF['user_temp_avatar_max_width'],$CONF['user_temp_avatar_max_height'],$width,$height);

	$fwidth = $size['width'];
	$fheight = $size['height'];

	$thumb = imagecreatetruecolor($fwidth, $fheight); setTransparency($thumb,$image); 
	$index = imagecolorexact($thumb, 255, 255, 255); imagecolortransparent($thumb, $index);
	imagecopyresampled($thumb, $image, 0, 0, 0, 0, $fwidth, $fheight, $width, $height);
	imagepng($thumb,$filename);
	return $thumb;
}
开发者ID:rczeus,项目名称:Rapid-Coffee,代码行数:17,代码来源:upload_temp_avatar.php

示例11: createcolor

 /**
  * Insert a color to the palet or return the color if the color exist
  *
  * @param image $pic the picture where we work on it
  * @param int $c1 red part of the color
  * @param int $c2 green part of the color
  * @param int $c3 blue part of the color
  * @return color the color that we want
  */
 public static function createcolor($pic, $c1, $c2, $c3)
 {
     //get color from palette
     $color = imagecolorexact($pic, $c1, $c2, $c3);
     if ($color == -1) {
         //color does not exist...
         //test if we have used up palette
         if (imagecolorstotal($pic) >= 255) {
             //palette used up; pick closest assigned color
             $color = imagecolorclosest($pic, $c1, $c2, $c3);
         } else {
             //palette NOT used up; assign new color
             $color = imagecolorallocate($pic, $c1, $c2, $c3);
         }
     }
     return $color;
 }
开发者ID:jonathan-vallet,项目名称:craftanat,代码行数:26,代码来源:ColorTool.class.php

示例12: img2array

function img2array($im, $width, $height)
{
    $black = abs(intval(imagecolorexact($im, 0, 0, 0)));
    $white = imagecolorexact($im, 255, 255, 255);
    $imgarray = array();
    for ($x = 0; $x < $width; $x++) {
        for ($y = 0; $y < $height; $y++) {
            // echo imagecolorat($im,$x,$y).'<br />';
            if (imagecolorat($im, $x, $y) == $black) {
                $imgarray[$y][$x] = 1;
            } else {
                $imgarray[$y][$x] = 0;
            }
            //			$imgarray[$y][$x] = imagecolorat($im,$x,$y);
        }
    }
    return $imgarray;
}
开发者ID:andrewsalveson,项目名称:asciirender,代码行数:18,代码来源:asciirender.php

示例13: update_user_avatar

function update_user_avatar($file, $x1, $y1, $x2, $y2){

	//file_put_contents('aa.txt',$file);
	preg_match('/\/(\d+\.png)$/', $file, $matches); // this is for security reasons
	$file = 'imgs/temp/'.$matches[1];

	global $_FILES;
	global $_USER;
	global $CONF;

	$user = $_SESSION['user'];

	$result='ok';

	$image = imagecreatefrompng($file);

	$thumbb = imagecreatetruecolor($CONF['user_avatar_width_big'], $CONF['user_avatar_width_big']); setTransparency($thumbb,$image); 
	$thumbm = imagecreatetruecolor($CONF['user_avatar_width_med'], $CONF['user_avatar_width_med']);	setTransparency($thumbm,$image); 
	$thumbs = imagecreatetruecolor($CONF['user_avatar_width_small'], $CONF['user_avatar_width_small']);setTransparency($thumbs,$image); 

	$index = imagecolorexact($thumbb, 255, 255, 255); imagecolortransparent($thumbb, $index);
	$index = imagecolorexact($thumbm, 255, 255, 255); imagecolortransparent($thumbm, $index);
	$index = imagecolorexact($thumbs, 255, 255, 255); imagecolortransparent($thumbs, $index);

	imagecopyresampled($thumbb, $image, 0, 0, $x1, $y1, $CONF['user_avatar_width_big'], $CONF['user_avatar_width_big'], $x2-$x1, $y2-$y1);
	imagepng($thumbb,$file."-big");
	imagecopyresampled($thumbm, $image, 0, 0, $x1, $y1, $CONF['user_avatar_width_med'], $CONF['user_avatar_width_med'], $x2-$x1, $y2-$y1);
	imagepng($thumbm,$file."-med");
	imagecopyresampled($thumbs, $image, 0, 0, $x1, $y1, $CONF['user_avatar_width_small'], $CONF['user_avatar_width_small'], $x2-$x1, $y2-$y1);
	imagepng($thumbs,$file."-small");

	$user->setAvatarFile($file);
	$result = $user->save();

	unlink($file);
	unlink($file."-big");
	unlink($file."-med");
	unlink($file."-small");

	if ($result=='ok') return array('ok'=>true, 'error'=>'');
	else return array('ok'=>false, 'error'=>"$result");
}
开发者ID:rczeus,项目名称:Rapid-Coffee,代码行数:42,代码来源:update_user_avatar.php

示例14: getImage

 public function getImage($scale = NULL)
 {
     if (!$scale) {
         $scale = max(1, floor(600 / $this->width));
     }
     $img = imagecreatetruecolor($this->width * $scale, $this->height * $scale);
     $bg = imagecolorallocate($img, 0, 0, 0);
     for ($i = 0; $i < $this->width; $i++) {
         for ($j = 0; $j < $this->height; $j++) {
             list($r, $g, $b) = $this->grid[$i][$j];
             $color = imagecolorexact($img, $r, $g, $b);
             if ($color == -1) {
                 $color = imagecolorallocate($img, $r, $g, $b);
             }
             $x = $i * $scale;
             $y = $j * $scale;
             imagefilledrectangle($img, $x, $y, $x + $scale, $y + $scale, $color);
         }
     }
     return $img;
 }
开发者ID:manuasir,项目名称:php-som,代码行数:21,代码来源:rgbtrainer.php

示例15: cap_show

 public static function cap_show()
 {
     $mainDir = SettingsManager::getInstance()->getMainDir();
     if (!file_exists($mainDir . '/tmp')) {
         mkdir($mainDir . '/tmp');
     }
     $filename = 'cap_' . rand(44, 888888) . '.png';
     $op[0] = '+';
     $op[1] = '-';
     $cap_r1 = rand(0, 99);
     $cap_op = $op[rand(0, 1)];
     $cap_r2 = rand(0, 22);
     eval('$cap_result = ' . $cap_r1 . $cap_op . $cap_r2 . ';');
     $_SESSION['captcha_result'] = md5($cap_result);
     $img = imagecreatetruecolor(50, 30);
     imagettftext($img, 12, rand(-30, 30), 2, 20, imagecolorexact($img, rand(150, 255), rand(150, 255), rand(150, 255)), $mainDir . '/resources/arial.ttf', $cap_r1);
     imagettftext($img, 12, rand(-15, 15), 20, 20, imagecolorexact($img, rand(150, 255), rand(150, 255), rand(150, 255)), $mainDir . '/resources/arial.ttf', $cap_op);
     imagettftext($img, 12, rand(-35, 35), 30, 20, imagecolorexact($img, rand(150, 255), rand(150, 255), rand(150, 255)), $mainDir . '/resources/arial.ttf', $cap_r2);
     imagepng($img, $mainDir . '/tmp/' . $filename);
     imagedestroy($img);
     echo '<img src="' . SettingsManager::getInstance()->getMainUrl() . '/tmp/' . $filename . '" alt=""/>';
     self::cap_cleanup();
 }
开发者ID:nicolasjoly,项目名称:MumPI,代码行数:23,代码来源:Captcha.php


注:本文中的imagecolorexact函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。