• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP imagecolorat函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: imagehex

 /**
  * Get image hash
  * @param array $image
  * @return array
  */
 private function imagehex($image)
 {
     $size = getimagesize($image['path']);
     $func = 'imagecreatefrom'.$image['type'];
     $imageres = $func($image['path']);
     $zone = imagecreate(20, 20);
     imagecopyresized($zone, $imageres, 0, 0, 0, 0, 20, 20, $size[0], $size[1]);
     $colormap = array();
     $average = 0;
     $result = array();
     for($x=0; $x < 20; $x++)
     {
         for($y=0; $y < 20; $y++)
         {
             $color = imagecolorat($zone, $x, $y);
             $color = imagecolorsforindex($zone, $color);
             $colormap[$x][$y]= 0.212671 * $color['red'] + 0.715160 * $color['green'] + 0.072169 * $color['blue'];
             $average += $colormap[$x][$y];
         }
     }
     $average /= 400;
     for($x=0; $x < 20; $x++)
     {
         for($y=0; $y < 20; $y++)
         {
             $result[]=($x < 10 ? $x : chr($x+97)) . ($y < 10 ? $y : chr($y+97)) . ($colormap[$x][$y]==0 ? '0' : round(2*($colormap[$x][$y] > $average ? $colormap[$x][$y]/$average:-1*$average/$colormap[$x][$y])));
         }
     }
     return $result;
 }
开发者ID:ranvijayj,项目名称:htmlasa,代码行数:35,代码来源:ImageDiff.php


示例2: colorImageBottom

/**
 *  Retourne la couleur du pixel en bas a gauche de l'image
 **/
function colorImageBottom($imageName)
{
    // recuperer le type et la taille de l'image
    // Pb sur certains JPG qui retourne ''
    list($imgW, $imgH, $imgTyp) = getimagesize($imageName);
    switch ($imgTyp) {
        case 1:
            $im = imagecreatefromgif($imageName);
            break;
        case 2:
        case ' ':
            $im = imagecreatefromjpeg($imageName);
            break;
        case 3:
            $im = imagecreatefrompng($imageName);
            break;
        default:
            $app = JFactory::getApplication();
            $app->enqueueMessage(JTEXT::_('IMGNAME_ERROR') . '[name=' . $imageName . '] [ type=' . $imgTyp . '] [ format= ' . $imgW . 'x' . $imgH, 'error');
            var_dump(gd_info());
            return "";
    }
    $rgb = imagecolorat($im, 2, $imgH - 2);
    $hex = sprintf("%06X", $rgb);
    return $hex;
}
开发者ID:sansandeep143,项目名称:av,代码行数:29,代码来源:helper.php


示例3: execute

 /**
  * Method to apply a filter to an image resource.
  *
  * @param   array  $options  An array of options for the filter.
  *
  * @return  void
  * 
  * @throws  InvalidArgumentException
  * @throws  RuntimeException
  */
 public function execute(array $options = array())
 {
     // Verify that image filter support for PHP is available.
     if (!function_exists('imagefilter')) {
         throw new RuntimeException('The imagefilter function for PHP is not available.');
     }
     if (empty($options)) {
         throw new InvalidArgumentException('No valid amount was given.  Expected float.');
     }
     $value = (int) array_shift($options);
     if ($value == 0) {
         $value = 128;
     }
     $width = imagesx($this->handle);
     $height = imagesy($this->handle);
     for ($x = 0; $x < $width; ++$x) {
         for ($y = 0; $y < $height; ++$y) {
             $index = imagecolorat($this->handle, $x, $y);
             $rgb = imagecolorsforindex($this->handle, $index);
             $r = $rgb['red'];
             $g = $rgb['green'];
             $b = $rgb['blue'];
             $a = $rgb['alpha'];
             $v = round(($r + $g + $b) / 3) >= $value ? 255 : 0;
             $color = imagecolorallocatealpha($this->handle, $v, $v, $v, $a);
             if ($color === false) {
                 $color = imagecolorclosestalpha($this->handle, $v, $v, $v, $a);
             }
             imagesetpixel($this->handle, $x, $y, $color);
         }
     }
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:42,代码来源:threshold.php


示例4: getAverageColor

 protected function getAverageColor()
 {
     $im = $this->image;
     //Begin getting average
     $width = imagesx($im);
     $height = imagesy($im);
     $total = $r = $g = $b = $a = 0;
     for ($x = 0; $x < $width; $x++) {
         for ($y = 0; $y < $height; $y++) {
             //get rgba array at index
             $index = imagecolorat($im, $x, $y);
             $rgba = imagecolorsforindex($im, $index);
             //add total for each color
             $r += $rgba['red'];
             $g += $rgba['green'];
             $b += $rgba['blue'];
             $a += $rgba['alpha'];
             $total++;
             unset($index);
             unset($rgba);
         }
         // end for $y
     }
     // end for $x
     unset($im);
     $avg = array('red' => round($r / $total), 'green' => round($g / $total), 'blue' => round($b / $total), 'alpha' => round($a / $total));
     $rgb = new Rgba($avg['red'], $avg['green'], $avg['blue'], $avg['alpha'], $this->url);
     unset($r);
     unset($g);
     unset($b);
     unset($a);
     $this->rgba = $rgb;
     return $this;
 }
开发者ID:aaronbullard,项目名称:litmus,代码行数:34,代码来源:RemoteImage.php


示例5: GetPartialImage

function GetPartialImage($url)
{
	$W = 150;
	$H = 130;
	$F = 80;
	$STEP = 1.0 / $F;
	$im = imagecreatefromjpeg($url);
	$dest = imagecreatetruecolor($W, $H);
	imagecopy($dest, $im, 0, 0, 35, 40, $W, $H);
	
	$a = 1;
	for( $y = $H - $F; $y < $H; $y++ )
	{
		for ( $x = 0; $x < $W; $x++ )
		{
			$i = imagecolorat($dest, $x, $y);
			$c = imagecolorsforindex($dest, $i);
			$c = imagecolorallocate($dest, 
				a($c['red'], $a),
				a($c['green'], $a), 
				a($c['blue'], $a)
			);
			imagesetpixel($dest, $x, $y, $c);
		}
		$a -= $STEP;
	}
	
	header('Content-type: image/png');
	imagepng($dest);
	imagedestroy($dest);
	imagedestroy($im);
}
开发者ID:ryanknu,项目名称:Cuber,代码行数:32,代码来源:image.php


示例6: applyFilter

 /**
  * Applies the sepia filter to an image resource
  *
  * @param ImageResource $aResource
  */
 public function applyFilter(ImageResource $aResource)
 {
     if ($this->offset === 0) {
         return;
     }
     $resource = $aResource->getResource();
     $imagex = imagesx($resource);
     $imagey = imagesy($resource);
     for ($x = 0; $x < $imagex; ++$x) {
         for ($y = 0; $y < $imagey; ++$y) {
             $distx = rand($this->offset * -1, $this->offset);
             $disty = rand($this->offset * -1, $this->offset);
             if ($x + $distx >= $imagex) {
                 continue;
             }
             if ($x + $distx < 0) {
                 continue;
             }
             if ($y + $disty >= $imagey) {
                 continue;
             }
             if ($y + $disty < 0) {
                 continue;
             }
             $oldcol = imagecolorat($resource, $x, $y);
             $newcol = imagecolorat($resource, $x + $distx, $y + $disty);
             imagesetpixel($resource, $x, $y, $newcol);
             imagesetpixel($resource, $x + $distx, $y + $disty, $oldcol);
         }
     }
 }
开发者ID:dreamsxin,项目名称:imagemanipulation,代码行数:36,代码来源:ImageFilterScatter.php


示例7: extractPalette

 /**
  * Extracts the colour palette of the set image
  *
  * @return array
  * @throws Exception
  */
 public function extractPalette()
 {
     if (is_null($this->image)) {
         throw new Exception('An image must be set before its palette can be extracted.');
     }
     if (($size = getimagesize($this->image)) === false) {
         throw new Exception("Unable to get image size data");
     }
     if (($img = imagecreatefromstring(file_get_contents($this->image))) === false) {
         throw new Exception("Unable to open image file");
     }
     $colors = array();
     for ($x = 0; $x < $size[0]; $x += $this->granularity) {
         for ($y = 0; $y < $size[1]; $y += $this->granularity) {
             $rgb = imagecolorsforindex($img, imagecolorat($img, $x, $y));
             $red = round(round($rgb['red'] / 0x33) * 0x33);
             $green = round(round($rgb['green'] / 0x33) * 0x33);
             $blue = round(round($rgb['blue'] / 0x33) * 0x33);
             $thisRGB = sprintf('%02X%02X%02X', $red, $green, $blue);
             if (array_key_exists($thisRGB, $colors)) {
                 $colors[$thisRGB]++;
             } else {
                 $colors[$thisRGB] = 1;
             }
         }
     }
     arsort($colors);
     return array_slice(array_keys($colors), 0, $this->totalColors);
 }
开发者ID:bensquire,项目名称:php-color-extractor,代码行数:35,代码来源:PHPColorExtractor.php


示例8: getHec

 public function getHec()
 {
     $res = imagecreatefromjpeg($this->ImagePath);
     $size = getimagesize($this->ImagePath);
     $data = array();
     for ($i = 0; $i < $size[1]; ++$i) {
         for ($j = 0; $j < $size[0]; ++$j) {
             $rgb = imagecolorat($res, $j, $i);
             $rgbarray = imagecolorsforindex($res, $rgb);
             // =========================================================
             // 任何验证码的数字和字母部分为了和验证码图片背景有所区别
             // 都必须对文字和背景图片的RGB进行区分,下面的值是我根据
             // 验证码的图片进行区分的,您可以分析您的图片,找到如下规律
             // =========================================================
             if ($rgbarray['red'] < 125 || $rgbarray['green'] < 125 || $rgbarray['blue'] < 125) {
                 $data[$i][$j] = 1;
             } else {
                 $data[$i][$j] = 0;
             }
         }
     }
     // 首列1
     for ($j = 0; $j < $size[1]; ++$j) {
         $data[$j][0] = 0;
     }
     $this->DataArray = $data;
     $this->ImageSize = $size;
 }
开发者ID:j178,项目名称:crack-neu-php,代码行数:28,代码来源:Valite.php


示例9: process_pixels

 function process_pixels()
 {
     $this->min = 255;
     $this->max = 0;
     for ($x = 0; $x < $this->resize_width; $x++) {
         for ($y = 0; $y < $this->resize_height; $y++) {
             $rgb = imagecolorat($this->resized, $x, $y);
             $r = $rgb >> 16 & 0xff;
             $g = $rgb >> 8 & 0xff;
             $b = $rgb & 0xff;
             $this->pixels[$x][$y] = array($r, $g, $b);
             $grey = round(($r + $g + $b) / 3);
             if ($grey > $this->max) {
                 $this->max = $grey;
             }
             if ($grey < $this->min) {
                 $this->min = $grey;
             }
             $this->pixels_processed_grey[$x][$y] = $grey;
         }
     }
     $this->normalize_pixels();
     //$this->median_pixels();
     $this->further_process();
 }
开发者ID:joelr,项目名称:ImageFingerPrinter,代码行数:25,代码来源:imageprocess.class.php


示例10: imagecopybicubic

/**
 * Copies a rectangular portion of the source image to another rectangle in the destination image
 *
 * This function calls imagecopyresampled() if it is available and GD version is 2 at least.
 * Otherwise it reimplements the same behaviour. See the PHP manual page for more info.
 *
 * @link http://php.net/manual/en/function.imagecopyresampled.php
 * @param resource $dst_img the destination GD image resource
 * @param resource $src_img the source GD image resource
 * @param int $dst_x vthe X coordinate of the upper left corner in the destination image
 * @param int $dst_y the Y coordinate of the upper left corner in the destination image
 * @param int $src_x the X coordinate of the upper left corner in the source image
 * @param int $src_y the Y coordinate of the upper left corner in the source image
 * @param int $dst_w the width of the destination rectangle
 * @param int $dst_h the height of the destination rectangle
 * @param int $src_w the width of the source rectangle
 * @param int $src_h the height of the source rectangle
 * @return bool tru on success, false otherwise
 */
function imagecopybicubic($dst_img, $src_img, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h)
{
    global $CFG;
    if (function_exists('imagecopyresampled') and $CFG->gdversion >= 2) {
        return imagecopyresampled($dst_img, $src_img, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
    }
    $totalcolors = imagecolorstotal($src_img);
    for ($i = 0; $i < $totalcolors; $i++) {
        if ($colors = imagecolorsforindex($src_img, $i)) {
            imagecolorallocate($dst_img, $colors['red'], $colors['green'], $colors['blue']);
        }
    }
    $scalex = ($src_w - 1) / $dst_w;
    $scaley = ($src_h - 1) / $dst_h;
    $scalex2 = $scalex / 2.0;
    $scaley2 = $scaley / 2.0;
    for ($j = 0; $j < $dst_h; $j++) {
        $sy = $j * $scaley;
        for ($i = 0; $i < $dst_w; $i++) {
            $sx = $i * $scalex;
            $c1 = imagecolorsforindex($src_img, imagecolorat($src_img, (int) $sx, (int) $sy + $scaley2));
            $c2 = imagecolorsforindex($src_img, imagecolorat($src_img, (int) $sx, (int) $sy));
            $c3 = imagecolorsforindex($src_img, imagecolorat($src_img, (int) $sx + $scalex2, (int) $sy + $scaley2));
            $c4 = imagecolorsforindex($src_img, imagecolorat($src_img, (int) $sx + $scalex2, (int) $sy));
            $red = (int) (($c1['red'] + $c2['red'] + $c3['red'] + $c4['red']) / 4);
            $green = (int) (($c1['green'] + $c2['green'] + $c3['green'] + $c4['green']) / 4);
            $blue = (int) (($c1['blue'] + $c2['blue'] + $c3['blue'] + $c4['blue']) / 4);
            $color = imagecolorclosest($dst_img, $red, $green, $blue);
            imagesetpixel($dst_img, $i + $dst_x, $j + $dst_y, $color);
        }
    }
}
开发者ID:JP-Git,项目名称:moodle,代码行数:51,代码来源:gdlib.php


示例11: execute

 public function execute()
 {
     $this->media->asImage();
     $gdimage = $this->media->getImage();
     $w = $this->media->getWidth();
     $h = $this->media->getHeight();
     $src_x = ceil($w);
     $src_y = ceil($h);
     $dst_x = $src_x;
     $dst_y = $src_y;
     $dst_im = imagecreatetruecolor($dst_x, $dst_y);
     imagecopyresampled($dst_im, $gdimage, 0, 0, 0, 0, $dst_x, $dst_y, $src_x, $src_y);
     for ($c = 0; $c < 256; ++$c) {
         $palette[$c] = imagecolorallocate($dst_im, $c, $c, $c);
     }
     for ($y = 0; $y < $src_y; ++$y) {
         for ($x = 0; $x < $src_x; ++$x) {
             $rgb = imagecolorat($dst_im, $x, $y);
             $r = $rgb >> 16 & 0xff;
             $g = $rgb >> 8 & 0xff;
             $b = $rgb & 0xff;
             $gs = $r * 0.299 + $g * 0.587 + $b * 0.114;
             imagesetpixel($dst_im, $x, $y, $palette[$gs]);
         }
     }
     $this->media->setImage($dst_im);
 }
开发者ID:DECAF,项目名称:redaxo,代码行数:27,代码来源:effect_filter_greyscale.php


示例12: imagecharx

function imagecharx($img, $char, $x0, $y0, $ylist)
{
    global $bk_color, $fg_color;
    $da = @imagecreate(10, 20) or die("Cannot Initialize new GD image stream");
    $background_color = imagecolorallocate($da, $bk_color[0], $bk_color[1], $bk_color[2]);
    $text_color = imagecolorallocate($da, $fg_color[0], $fg_color[1], $fg_color[2]);
    $color = imagecolorallocate($img, $fg_color[0], $fg_color[1], $fg_color[2]);
    $arg = rand(0, 18) / 100.0 * pi();
    imagestring($da, 18, 0, 0, $char, $text_color);
    for ($i = 0; $i < 200; $i++) {
        $y = @floor($i / 10);
        $x = $i % 10;
        $point_color = imagecolorat($da, $x, $y);
        if ($point_color == $text_color) {
            for ($j = 0; $j < 12; $j++) {
                $dx = 0;
                $dy = 0;
                $p = 6;
                for ($s = 0; $s < $p; $s++) {
                    $dx += rand(0, 1000 / $p) / 100;
                    $dy += rand(0, 1000 / $p) / 100;
                }
                $xx = $x * 5 + $dx - 25;
                $yy = $y * 5 + $dy - 50;
                $x1 = cos($arg) * $xx - sin($arg) * $yy + 25;
                $y1 = sin($arg) * $xx + cos($arg) * $yy + 50;
                imagesetpixel($img, $x0 + $x1, $y0 + $y1, $color);
            }
        }
    }
    imagedestroy($da);
}
开发者ID:sdgdsffdsfff,项目名称:json-db,代码行数:32,代码来源:spray.php


示例13: hash

 /**
  * {@inheritDoc}
  */
 public function hash($resource)
 {
     // Resize the image.
     $resized = imagecreatetruecolor(static::SIZE, static::SIZE);
     imagecopyresampled($resized, $resource, 0, 0, 0, 0, static::SIZE, static::SIZE, imagesx($resource), imagesy($resource));
     // Create an array of greyscale pixel values.
     $pixels = [];
     for ($y = 0; $y < static::SIZE; $y++) {
         for ($x = 0; $x < static::SIZE; $x++) {
             $rgb = imagecolorsforindex($resized, imagecolorat($resized, $x, $y));
             $pixels[] = floor(($rgb['red'] + $rgb['green'] + $rgb['blue']) / 3);
         }
     }
     // Free up memory.
     imagedestroy($resized);
     // Get the average pixel value.
     $average = floor(array_sum($pixels) / count($pixels));
     // Each hash bit is set based on whether the current pixels value is above or below the average.
     $hash = 0;
     $one = 1;
     foreach ($pixels as $pixel) {
         if ($pixel > $average) {
             $hash |= $one;
         }
         $one = $one << 1;
     }
     return $hash;
 }
开发者ID:minhkiller,项目名称:imagehash,代码行数:31,代码来源:AverageHash.php


示例14: execute

 function execute()
 {
     $gdimage =& $this->image->getImage();
     $w = $this->image->getWidth();
     $h = $this->image->getHeight();
     $im = $gdimage;
     $width = imagesx($im);
     $height = imagesy($im);
     $output_image_resource = imagecreatetruecolor($width, $height);
     // --------------- Flip X
     if ($this->params['flip'] == "X") {
         $y = 0;
         $x = 1;
         while ($x <= $width) {
             for ($i = 0; $i < $height; $i++) {
                 imagesetpixel($output_image_resource, $x, $i, imagecolorat($im, $width - $x, $i));
             }
             $x++;
         }
         $gdimage = $output_image_resource;
     }
     // --------------- Flip Y
     if ($this->params['flip'] == "Y") {
         $y = 1;
         $x = 0;
         while ($y < $height) {
             for ($i = 0; $i < $width; $i++) {
                 imagesetpixel($output_image_resource, $i, $y, imagecolorat($im, $i, $height - $y));
             }
             $y++;
         }
         $gdimage = $output_image_resource;
     }
 }
开发者ID:BackupTheBerlios,项目名称:redaxo-svn,代码行数:34,代码来源:class.rex_effect_flip.inc.php


示例15: check_box

function check_box($r, $g, $b, $error = 0)
{
    $cwd = dirname(__FILE__);
    $im2 = imagecreatefromgif($cwd . '/test_gif.gif');
    $c = imagecolorsforindex($im2, imagecolorat($im2, 8, 8));
    if ($error > 0) {
        $r_min = $r - $error;
        $r_max = $r + $error;
        $g_min = $g - $error;
        $g_max = $g + $error;
        $b_min = $b - $error;
        $b_max = $b + $error;
        if (($c['red'] >= $r_min || $c['red'] <= $r_max) && ($c['green'] >= $g_min || $c['green'] <= $g_max) && ($c['blue'] >= $b_min || $c['blue'] <= $b_max)) {
            return true;
        } else {
            return false;
        }
    } else {
        if ($c['red'] == $r && $c['green'] == $g && $c['blue'] == $b) {
            return true;
        } else {
            return false;
        }
    }
}
开发者ID:badlamer,项目名称:hhvm,代码行数:25,代码来源:gif.php


示例16: run

 public function run($file)
 {
     $res = $this->open_image($file);
     if ($res != TRUE) {
         return FALSE;
     }
     $this->image_progressive = isset($this->settings['field_settings']['progressive_jpeg']) === TRUE && $this->settings['field_settings']['progressive_jpeg'] == 'yes' ? TRUE : FALSE;
     if (function_exists('imagefilter') === TRUE) {
         @imagefilter($this->EE->channel_images->image, IMG_FILTER_GRAYSCALE);
     } else {
         $img_width = imageSX($this->EE->channel_images->image);
         $img_height = imageSY($this->EE->channel_images->image);
         // convert to grayscale
         $palette = array();
         for ($c = 0; $c < 256; $c++) {
             $palette[$c] = imagecolorallocate($this->EE->channel_images->image, $c, $c, $c);
         }
         for ($y = 0; $y < $img_height; $y++) {
             for ($x = 0; $x < $img_width; $x++) {
                 $rgb = imagecolorat($this->EE->channel_images->image, $x, $y);
                 $r = $rgb >> 16 & 0xff;
                 $g = $rgb >> 8 & 0xff;
                 $b = $rgb & 0xff;
                 $gs = $r * 0.299 + $g * 0.587 + $b * 0.114;
                 imagesetpixel($this->EE->channel_images->image, $x, $y, $palette[$gs]);
             }
         }
     }
     $this->save_image($file);
     return TRUE;
 }
开发者ID:ayuinc,项目名称:laboratoria-v2,代码行数:31,代码来源:action.greyscale.php


示例17: transform

 /**
  * Apply the transform to the sfImage object.
  *
  * @param sfImage
  * @return sfImage
  */
 protected function transform(sfImage $image)
 {
     $resource = $image->getAdapter()->getHolder();
     $resourcex = imagesx($resource);
     $resourcey = imagesy($resource);
     for ($x = 0; $x < $resourcex; ++$x) {
         for ($y = 0; $y < $resourcey; ++$y) {
             $distx = rand(-$this->scatter_factor, $this->scatter_factor);
             $disty = rand(-$this->scatter_factor, $this->scatter_factor);
             // keep inside the image boundaries
             if ($x + $distx >= $resourcex) {
                 continue;
             }
             if ($x + $distx < 0) {
                 continue;
             }
             if ($y + $disty >= $resourcey) {
                 continue;
             }
             if ($y + $disty < 0) {
                 continue;
             }
             $oldcol = imagecolorat($resource, $x, $y);
             $newcol = imagecolorat($resource, $x + $distx, $y + $disty);
             imagesetpixel($resource, $x, $y, $newcol);
             imagesetpixel($resource, $x + $distx, $y + $disty, $oldcol);
         }
     }
     return $image;
 }
开发者ID:valerio-bozzolan,项目名称:openparlamento,代码行数:36,代码来源:sfImageScatterGD.class.php


示例18: CopyTextCanvasIntoCaptcha

 protected function CopyTextCanvasIntoCaptcha($text3dHeight, $rotationMatrix)
 {
     $color = $this->AllocateColorByRgbArray($this->image, $this->_conf['color']);
     $textCanvasHeight = imagesy($this->textCanvas);
     $textCanvasWidth = imagesx($this->textCanvas);
     for ($y = 0; $y < $textCanvasHeight; $y++) {
         for ($x = 0; $x < $textCanvasWidth; $x++) {
             $pixel = imagecolorat($this->textCanvas, $x, $y);
             $pixelColor = ($pixel >> 16 & 0xff) + ($pixel >> 8 & 0xff) + ($pixel & 0xff);
             // calculate new (stertched) values
             $newX = ($x / $textCanvasWidth - 0.5) * $this->_conf['width'];
             $newY = ($y / $textCanvasHeight - 0.5) * $this->_conf['height'];
             $newZ = $pixelColor * $text3dHeight;
             $grid[$x][$y] = array($newX, $newY, $newZ);
             $grid[$x][$y] = self::MultiplyMatrices($grid[$x][$y], $rotationMatrix);
             // fix  position
             $grid[$x][$y][0] += $this->_conf['width'] / 2;
             $grid[$x][$y][1] += $this->_conf['height'] / 2;
             // draw vertical line
             if ($y > 0) {
                 imageline($this->image, $grid[$x][$y - 1][0], $grid[$x][$y - 1][1], $grid[$x][$y][0], $grid[$x][$y][1], $color);
             }
             // draw horizontal lines
             if ($x > 0) {
                 imageline($this->image, $grid[$x - 1][$y][0], $grid[$x - 1][$y][1], $grid[$x][$y][0], $grid[$x][$y][1], $color);
             }
         }
     }
 }
开发者ID:xuecai,项目名称:3Dcaptcha,代码行数:29,代码来源:captcha3D.php


示例19: Get_Color

 /**
  * Returns the colors of the image in an array, ordered in descending order, where the keys are the colors, and the values are the count of the color.
  *
  * @return array
  */
 function Get_Color()
 {
     if (isset($this->image)) {
         $im = $this->image;
         $imgWidth = imagesx($im);
         $imgHeight = imagesy($im);
         for ($y = 0; $y < $imgHeight; $y++) {
             for ($x = 0; $x < $imgWidth; $x++) {
                 $index = imagecolorat($im, $x, $y);
                 $Colors = imagecolorsforindex($im, $index);
                 $Colors['red'] = intval(($Colors['red'] + 15) / 32) * 32;
                 //ROUND THE COLORS, TO REDUCE THE NUMBER OF COLORS, SO THE WON'T BE ANY NEARLY DUPLICATE COLORS!
                 $Colors['green'] = intval(($Colors['green'] + 15) / 32) * 32;
                 $Colors['blue'] = intval(($Colors['blue'] + 15) / 32) * 32;
                 if ($Colors['red'] >= 256) {
                     $Colors['red'] = 240;
                 }
                 if ($Colors['green'] >= 256) {
                     $Colors['green'] = 240;
                 }
                 if ($Colors['blue'] >= 256) {
                     $Colors['blue'] = 240;
                 }
                 $hexarray[] = substr("0" . dechex($Colors['red']), -2) . substr("0" . dechex($Colors['green']), -2) . substr("0" . dechex($Colors['blue']), -2);
             }
         }
         $hexarray = array_count_values($hexarray);
         natsort($hexarray);
         $hexarray = array_reverse($hexarray, true);
         return $hexarray;
     } else {
         die("You must enter a filename! (\$image parameter)");
     }
 }
开发者ID:Apothems,项目名称:naranai,代码行数:39,代码来源:colors.inc.php


示例20: applyFilter

 /**
  * Applies filter effects to the given image
  *
  * @param Image\Image $image The image to filter.
  *
  * @return Image\Image The filtered image.
  *
  * @throws FilterException if the image filter algorithm fails.
  */
 public function applyFilter(Image\Image $image)
 {
     if ($this->level <= 0) {
         $gd = $image->getCore();
         $width = imagesx($gd);
         $height = imagesy($gd);
         for ($x = 0; $x < $width; ++$x) {
             for ($y = 0; $y < $height; ++$y) {
                 $rgba = imagecolorsforindex($gd, imagecolorat($gd, $x, $y));
                 $r = $rgba['red'];
                 $g = $rgba['green'];
                 $b = $rgba['blue'];
                 $a = $rgba['alpha'];
                 $level = $this->level * -1;
                 $max = max($r, $g, $b);
                 $avg = ($r + $g + $b) / 3;
                 $amt = abs($max - $avg) * 2 / 255 * $level / 100;
                 if ($r !== $max) {
                     $r += ($max - $r) * $amt;
                 }
                 if ($g !== $max) {
                     $g += ($max - $g) * $amt;
                 }
                 if ($b !== $max) {
                     $b += ($max - $b) * $amt;
                 }
                 imagesetpixel($gd, $x, $y, imagecolorallocatealpha($gd, $r, $g, $b, $a));
             }
         }
         $image->setCore($gd);
     } else {
         $image->filter(new SaturateFilter($this->level));
     }
     return $image;
 }
开发者ID:BitmanNL,项目名称:traffictower-cms,代码行数:44,代码来源:VibranceFilter.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP imagecolorclosest函数代码示例发布时间:2022-05-15
下一篇:
PHP imagecolorallocatealpha函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap