本文整理汇总了PHP中imagecolorexact函数的典型用法代码示例。如果您正苦于以下问题:PHP imagecolorexact函数的具体用法?PHP imagecolorexact怎么用?PHP imagecolorexact使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了imagecolorexact函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: list
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
-->
<?php
list($width, $height) = getimagesize('./marker.png');
$img = imagecreatetruecolor($width, $height);
$srcimg = imagecreatefrompng('./marker.png');
$white = imagecolorexact($img, 255, 255, 255);
imagefilledrectangle($img, 0, 0, 20, 34, $white);
imagecopyresampled($img, $srcimg, 0, 0, 0, 0, $width, $height, $width, $height);
imagecolortransparent($img, $white);
if (isset($_REQUEST['color'])) {
$cols = $_REQUEST['color'];
$cols = explode(",", $_REQUEST['color']);
$color = imagecolorallocate($img, $cols[0], $cols[1], $cols[2]);
} else {
$color = imagecolorallocate($img, 0, 101, 255);
}
imagefill($img, 5, 5, $color);
header("Content-type: image/png");
imagepng($img);
imagecolordeallocate($color);
imagedestroy($srcimg);
开发者ID:nickavv,项目名称:iSENSE,代码行数:31,代码来源:v3icon.php
示例17: getImage
public function getImage($scale = NULL)
{
if (!$scale) {
$scale = max(1, floor(600 / $this->som->width));
}
$img = imagecreate($this->som->width * $scale, $this->som->height * $scale);
$bg = imagecolorallocate($img, 0, 0, 0);
for ($i = 0; $i < $this->som->width; $i++) {
for ($j = 0; $j < $this->som->height; $j++) {
$r = 255 * $this->map[$i][$j];
$g = intval($r / 3);
$b = 255 * ((1 - $this->map[$i][$j]) / 2);
$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);
}
}
$green = imagecolorexact($img, 0, 255, 0);
if ($green == -1) {
$green = imagecolorallocate($img, 0, 255, 0);
}
$x = $this->max_x * $scale;
$y = $this->max_y * $scale;
imagefilledrectangle($img, $x, $y, $x + $scale, $y + $scale, $green);
$yellow = imagecolorexact($img, 255, 255, 0);
if ($yellow == -1) {
$yellow = imagecolorallocate($img, 255, 255, 0);
}
$x = $this->min_x * $scale;
$y = $this->min_y * $scale;
imagefilledrectangle($img, $x, $y, $x + $scale, $y + $scale, $yellow);
return $img;
}
开发者ID:manuasir,项目名称:php-som,代码行数:37,代码来源:trainer.php
示例18: imagecreatefrombmp
function imagecreatefrombmp($filename)
{
global $gd2;
$fp = fopen($filename, 'rb');
$errors = error_reporting(0);
$header = unpack('vtype/Vsize/Vreserved/Voffset', fread($fp, 14));
$info = unpack('Vsize/Vwidth/Vheight/vplanes/vbits/Vcompression/Vimagesize/Vxres/Vyres/Vncolor/Vcolorimportant', fread($fp, 40));
if ($header['type'] != 0x4d42) {
false;
}
if ($gd2) {
$dst_img = imagecreatetruecolor($info['width'], $info['height']);
} else {
$dst_img = imagecreate($info['width'], $info['height']);
}
$palette_size = $header['offset'] - 54;
$info['ncolor'] = $palette_size / 4;
$palette = array();
$palettedata = fread($fp, $palette_size);
$n = 0;
for ($j = 0; $j < $palette_size; $j++) {
$b = ord($palettedata[$j++]);
$g = ord($palettedata[$j++]);
$r = ord($palettedata[$j++]);
$palette[$n++] = imagecolorallocate($dst_img, $r, $g, $b);
}
$scan_line_size = $info['bits'] * $info['width'] + 7 >> 3;
$scan_line_align = $scan_line_size & 3 ? 4 - ($scan_line_size & 3) : 0;
for ($y = 0, $l = $info['height'] - 1; $y < $info['height']; $y++, $l--) {
fseek($fp, $header['offset'] + ($scan_line_size + $scan_line_align) * $l);
$scan_line = fread($fp, $scan_line_size);
if (strlen($scan_line) < $scan_line_size) {
continue;
}
if ($info['bits'] == 32) {
$x = 0;
for ($j = 0; $j < $scan_line_size; $x++) {
$b = ord($scan_line[$j++]);
$g = ord($scan_line[$j++]);
$r = ord($scan_line[$j++]);
$j++;
$color = imagecolorexact($dst_img, $r, $g, $b);
if ($color == -1) {
$color = imagecolorallocate($dst_img, $r, $g, $b);
// Gah! Out of colors? Stupid GD 1... try anyhow.
if ($color == -1) {
$color = imagecolorclosest($dst_img, $r, $g, $b);
}
}
imagesetpixel($dst_img, $x, $y, $color);
}
} elseif ($info['bits'] == 24) {
$x = 0;
for ($j = 0; $j < $scan_line_size; $x++) {
$b = ord($scan_line[$j++]);
$g = ord($scan_line[$j++]);
$r = ord($scan_line[$j++]);
$color = imagecolorexact($dst_img, $r, $g, $b);
if ($color == -1) {
$color = imagecolorallocate($dst_img, $r, $g, $b);
// Gah! Out of colors? Stupid GD 1... try anyhow.
if ($color == -1) {
$color = imagecolorclosest($dst_img, $r, $g, $b);
}
}
imagesetpixel($dst_img, $x, $y, $color);
}
} elseif ($info['bits'] == 16) {
$x = 0;
for ($j = 0; $j < $scan_line_size; $x++) {
$b1 = ord($scan_line[$j++]);
$b2 = ord($scan_line[$j++]);
$word = $b2 * 256 + $b1;
$b = ($word & 31) * 255 / 31;
$g = ($word >> 5 & 31) * 255 / 31;
$r = ($word >> 10 & 31) * 255 / 31;
// Scale the image colors up properly.
$color = imagecolorexact($dst_img, $r, $g, $b);
if ($color == -1) {
$color = imagecolorallocate($dst_img, $r, $g, $b);
// Gah! Out of colors? Stupid GD 1... try anyhow.
if ($color == -1) {
$color = imagecolorclosest($dst_img, $r, $g, $b);
}
}
imagesetpixel($dst_img, $x, $y, $color);
}
} elseif ($info['bits'] == 8) {
$x = 0;
for ($j = 0; $j < $scan_line_size; $x++) {
imagesetpixel($dst_img, $x, $y, $palette[ord($scan_line[$j++])]);
}
} elseif ($info['bits'] == 4) {
$x = 0;
for ($j = 0; $j < $scan_line_size; $x++) {
$byte = ord($scan_line[$j++]);
imagesetpixel($dst_img, $x, $y, $palette[(int) ($byte / 16)]);
if (++$x < $info['width']) {
imagesetpixel($dst_img, $x, $y, $palette[$byte & 15]);
}
//.........这里部分代码省略.........
开发者ID:valek0972,项目名称:hackits,代码行数:101,代码来源:Subs-Graphics.php
示例19: Allocate
function Allocate($color)
{
list($r, $g, $b) = $this->color($color);
$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:eguicciardi,项目名称:ada,代码行数:12,代码来源:jpgraph.php
示例20: testColorExists
private function testColorExists($colorArray)
{
$r = $colorArray['r'];
$g = $colorArray['g'];
$b = $colorArray['b'];
if (imagecolorexact($this->imageResized, $r, $g, $b) == -1) {
return false;
} else {
return true;
}
}
开发者ID:WebPassions,项目名称:2015,代码行数:11,代码来源:php_image_magician.php
注:本文中的imagecolorexact函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论