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

PHP imageSetPixel函数代码示例

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

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



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

示例1: setnoise

function setnoise($image, $width, $height, $back, $noisenum)
{
    for ($i = 0; $i < $noisenum; $i++) {
        $randColor = imageColorAllocate($image, rand(0, 255), rand(0, 255), rand(0, 255));
        imageSetPixel($image, rand(0, $width), rand(0, $height), $randColor);
    }
}
开发者ID:caidongyun,项目名称:CS,代码行数:7,代码来源:verify.php


示例2: __grayscale

	/**
	* Make the image greyscale
	*
	* @param Asido_TMP &$tmp
	* @return boolean
	* @access protected
	*/
	function __grayscale(&$tmp) {

		// the longer path: do it pixel by pixel
		// 
		if (parent::__grayscale(&$tmp)) {
			return true;
			}

		// create 256 color palette
		//
		$palette = array();
		for ($c=0; $c<256; $c++) {
			$palette[$c] = imageColorAllocate($tmp->target, $c, $c, $c);
			}

		// read origonal colors pixel by pixel
		//
		for ($y=0; $y<$tmp->image_height; $y++) {
			for ($x=0; $x<$tmp->image_width; $x++) {

				$rgb = imageColorAt($tmp->target, $x, $y);

				$r = ($rgb >> 16) & 0xFF;
				$g = ($rgb >> 8) & 0xFF;
				$b = $rgb & 0xFF;

				$gs = (($r*0.299)+($g*0.587)+($b*0.114));
				imageSetPixel($tmp->target, $x, $y, $palette[$gs]);
				}
			}

		return true;
		}
开发者ID:rkern21,项目名称:videoeditor,代码行数:40,代码来源:class.driver.gd_hack.php


示例3: setNoisePix

 function setNoisePix()
 {
     for ($i = 0; $i < $this->noiseNumPix; $i++) {
         $randColor = imageColorAllocate($this->image, rand(0, 255), rand(0, 255), rand(0, 255));
         imageSetPixel($this->image, rand(0, $this->width), rand(0, $this->height), $randColor);
     }
 }
开发者ID:beyondye,项目名称:ENPHP,代码行数:7,代码来源:Authcode.php


示例4: king_def

function king_def()
{
    global $king;
    header("Cache-Control: no-cache, must-revalidate");
    // HTTP/1.1
    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
    // 过去的时间
    header("Content-type: image/png");
    $salt = kc_get('salt', 1, 1);
    $width = $king->config('verifywidth');
    //图片长度
    $height = $king->config('verifyheight');
    //图片高度
    $size = $king->config('verifysize');
    //文字大小
    $num = $king->config('verifynum');
    //文字数量
    $content = $king->config('verifycontent');
    //随机字符
    $array_content = explode('|', $content);
    $array_content = array_diff($array_content, array(null));
    $array_font = kc_f_getdir('system/verify_font', 'ttf|ttc');
    $str = '';
    $img = imageCreate($width, $height);
    //创建一个空白图像
    imageFilledRectangle($img, 0, 0, $width, $height, imagecolorallocate($img, 255, 255, 255));
    //写字
    for ($i = 0; $i < $num; $i++) {
        $code = $array_content[array_rand($array_content)];
        $str .= $code;
        //验证码字符
        $color = imageColorAllocate($img, rand(0, 128), rand(0, 128), rand(0, 128));
        $font = 'verify_font/' . $array_font[array_rand($array_font)];
        //随机读取一个字体
        $left = rand(round($size * 0.2), round($size * 0.4)) + $i * $size;
        imagettftext($img, rand(round($size * 0.7), $size), rand(-20, 20), $left, rand(round($size * 1.2), $size * 1.4), $color, $font, $code);
    }
    //画星号
    $max = $width * $height / 400;
    for ($i = 0; $i < $max; $i++) {
        imagestring($img, 15, rand(0, $width), rand(0, $height), '*', rand(192, 250));
    }
    //画点
    $max = $width * $height / 40;
    for ($i = 0; $i < $max; $i++) {
        imageSetPixel($img, rand(0, $width), rand(0, $height), rand(1, 200));
    }
    //画线
    $max = $width * $height / 800;
    for ($i = 0; $i < $max; $i++) {
        imageline($img, rand(0, $width), rand(0, $height), rand(0, $width), rand(0, $height), rand(0, 255));
    }
    //写验证码到verify中
    $verify = new KC_Verify_class();
    $verify->Put($salt, $str);
    imagePng($img);
    imageDestroy($img);
    $verify->Clear();
}
开发者ID:jonycookie,项目名称:projectm2,代码行数:59,代码来源:verify.php


示例5: imagesmoothcircle

/**
 * Credits goes to an anonymous at http://usphp.com/manual/ro/function.imageantialias.php
 */
function imagesmoothcircle(&$img, $cx, $cy, $cr, $color)
{
    $ir = $cr;
    $ix = 0;
    $iy = $ir;
    $ig = 2 * $ir - 3;
    $idgr = -6;
    $idgd = 4 * $ir - 10;
    $fill = imageColorExactAlpha($img, $color['R'], $color['G'], $color['B'], 0);
    imageLine($img, $cx + $cr - 1, $cy, $cx, $cy, $fill);
    imageLine($img, $cx - $cr + 1, $cy, $cx - 1, $cy, $fill);
    imageLine($img, $cx, $cy + $cr - 1, $cx, $cy + 1, $fill);
    imageLine($img, $cx, $cy - $cr + 1, $cx, $cy - 1, $fill);
    $draw = imageColorExactAlpha($img, $color['R'], $color['G'], $color['B'], 42);
    imageSetPixel($img, $cx + $cr, $cy, $draw);
    imageSetPixel($img, $cx - $cr, $cy, $draw);
    imageSetPixel($img, $cx, $cy + $cr, $draw);
    imageSetPixel($img, $cx, $cy - $cr, $draw);
    while ($ix <= $iy - 2) {
        if ($ig < 0) {
            $ig += $idgd;
            $idgd -= 8;
            $iy--;
        } else {
            $ig += $idgr;
            $idgd -= 4;
        }
        $idgr -= 4;
        $ix++;
        imageLine($img, $cx + $ix, $cy + $iy - 1, $cx + $ix, $cy + $ix, $fill);
        imageLine($img, $cx + $ix, $cy - $iy + 1, $cx + $ix, $cy - $ix, $fill);
        imageLine($img, $cx - $ix, $cy + $iy - 1, $cx - $ix, $cy + $ix, $fill);
        imageLine($img, $cx - $ix, $cy - $iy + 1, $cx - $ix, $cy - $ix, $fill);
        imageLine($img, $cx + $iy - 1, $cy + $ix, $cx + $ix, $cy + $ix, $fill);
        imageLine($img, $cx + $iy - 1, $cy - $ix, $cx + $ix, $cy - $ix, $fill);
        imageLine($img, $cx - $iy + 1, $cy + $ix, $cx - $ix, $cy + $ix, $fill);
        imageLine($img, $cx - $iy + 1, $cy - $ix, $cx - $ix, $cy - $ix, $fill);
        $filled = 0;
        for ($xx = $ix - 0.45; $xx < $ix + 0.5; $xx += 0.2) {
            for ($yy = $iy - 0.45; $yy < $iy + 0.5; $yy += 0.2) {
                if (sqrt(pow($xx, 2) + pow($yy, 2)) < $cr) {
                    $filled += 4;
                }
            }
        }
        $draw = imageColorExactAlpha($img, $color['R'], $color['G'], $color['B'], 100 - $filled);
        imageSetPixel($img, $cx + $ix, $cy + $iy, $draw);
        imageSetPixel($img, $cx + $ix, $cy - $iy, $draw);
        imageSetPixel($img, $cx - $ix, $cy + $iy, $draw);
        imageSetPixel($img, $cx - $ix, $cy - $iy, $draw);
        imageSetPixel($img, $cx + $iy, $cy + $ix, $draw);
        imageSetPixel($img, $cx + $iy, $cy - $ix, $draw);
        imageSetPixel($img, $cx - $iy, $cy + $ix, $draw);
        imageSetPixel($img, $cx - $iy, $cy - $ix, $draw);
    }
}
开发者ID:bishopm,项目名称:circuit,代码行数:59,代码来源:gdext.inc.php


示例6: imageSmoothArcDrawSegment

function imageSmoothArcDrawSegment(&$img, $cx, $cy, $a, $b, $color, $start, $stop, $seg)
{
    // Originally written from scratch by Ulrich Mierendorff, 06/2006
    // Rewritten and improved, 04/2007, 07/2007
    // Optimized circle version: 03/2008
    // Please do not use THIS function directly. Scroll down to imageSmoothArc(...).
    $fillColor = imageColorExactAlpha($img, $color[0], $color[1], $color[2], $color[3]);
    switch ($seg) {
        case 0:
            $xp = +1;
            $yp = -1;
            $xa = 1;
            $ya = -1;
            break;
        case 1:
            $xp = -1;
            $yp = -1;
            $xa = 0;
            $ya = -1;
            break;
        case 2:
            $xp = -1;
            $yp = +1;
            $xa = 0;
            $ya = 0;
            break;
        case 3:
            $xp = +1;
            $yp = +1;
            $xa = 1;
            $ya = 0;
            break;
    }
    for ($x = 0; $x <= $a; $x += 1) {
        $y = $b * sqrt(1 - $x * $x / ($a * $a));
        $error = $y - (int) $y;
        $y = (int) $y;
        $diffColor = imageColorExactAlpha($img, $color[0], $color[1], $color[2], 127 - (127 - $color[3]) * $error);
        imageSetPixel($img, $cx + $xp * $x + $xa, $cy + $yp * ($y + 1) + $ya, $diffColor);
        imageLine($img, $cx + $xp * $x + $xa, $cy + $yp * $y + $ya, $cx + $xp * $x + $xa, $cy + $ya, $fillColor);
    }
    for ($y = 0; $y < $b; $y += 1) {
        $x = $a * sqrt(1 - $y * $y / ($b * $b));
        $error = $x - (int) $x;
        $x = (int) $x;
        $diffColor = imageColorExactAlpha($img, $color[0], $color[1], $color[2], 127 - (127 - $color[3]) * $error);
        imageSetPixel($img, $cx + $xp * ($x + 1) + $xa, $cy + $yp * $y + $ya, $diffColor);
    }
}
开发者ID:rainbow-studio,项目名称:cmsms,代码行数:49,代码来源:imageSmoothArc_optimized.php


示例7: renderFrame

 public function renderFrame(float $t, int $width, int $height)
 {
     $image = \imageCreate($width, $height);
     $palette = [];
     foreach (self::PICO_8_PALETTE as list($red, $green, $blue)) {
         $palette[] = \imageColorAllocate($image, $red, $green, $blue);
     }
     for ($x = 0; $x < $width; $x++) {
         for ($y = 0; $y < $height; $y++) {
             $value = ($this->function)($x - $width / 2, $y - $height / 2, $t);
             \imageSetPixel($image, $x, $y, $palette[self::mod(abs(floor($value)), count($palette))]);
         }
     }
     return $image;
 }
开发者ID:TazeTSchnitzel,项目名称:pico8bot.php,代码行数:15,代码来源:Renderer.php


示例8: make_img

function make_img($content)
{
    $timage = array(strlen($content) * 20 + 10, 28);
    // array(largeur, hauteur) de l'image; ici la largeur est fonction du nombre de lettre du contenu, on peut bien sur mettre une largeur fixe.
    $content = preg_replace('/(\\w)/', '\\1 ', $content);
    // laisse plus d'espace entre les lettres
    $image = imagecreatetruecolor($timage[0], $timage[1]);
    // création de l'image
    // definition des couleurs
    $fond = imageColorAllocate($image, 240, 255, 240);
    $grey = imageColorAllocate($image, 210, 210, 210);
    $text_color = imageColorAllocate($image, rand(0, 100), rand(0, 50), rand(0, 60));
    imageFill($image, 0, 0, $fond);
    // on remplit l'image de blanc
    //On remplit l'image avec des polygones
    for ($i = 0, $imax = mt_rand(3, 5); $i < $imax; $i++) {
        $x = mt_rand(3, 10);
        $poly = array();
        for ($j = 0; $j < $x; $j++) {
            $poly[] = mt_rand(0, $timage[0]);
            $poly[] = mt_rand(0, $timage[1]);
        }
        imageFilledPolygon($image, $poly, $x, imageColorAllocate($image, mt_rand(150, 255), mt_rand(150, 255), mt_rand(150, 255)));
    }
    // Création des pixels gris
    for ($i = 0; $i < $timage[0] * $timage[1] / rand(15, 18); $i++) {
        imageSetPixel($image, rand(0, $timage[0]), rand(0, $timage[1]), $grey);
    }
    // affichage du texte demandé; on le centre en hauteur et largeur (à peu près ^^")
    //imageString($image, 5, ceil($timage[0]-strlen($content)*8)/2, ceil($timage[1]/2)-9, $content, $text_color);
    $longueur_chaine = strlen($content);
    for ($ch = 0; $ch < $longueur_chaine; $ch++) {
        imagettftext($image, 18, mt_rand(-30, 30), 10 * ($ch + 1), mt_rand(18, 20), $text_color, 'res/georgia.ttf', $content[$ch]);
    }
    $type = function_exists('imageJpeg') ? 'jpeg' : 'png';
    @header('Content-Type: image/' . $type);
    @header('Cache-control: no-cache, no-store');
    $type == 'png' ? imagePng($image) : imageJpeg($image);
    ImageDestroy($image);
    exit;
}
开发者ID:shiooooooookun,项目名称:Nouweo_PHP,代码行数:41,代码来源:captcha.php


示例9: DoNoise

 function DoNoise($image, $G0, $C0)
 {
     $W = imageSX($image);
     $H = imageSY($image);
     for ($i = 0; $i < 768; $i++) {
         $arrLUT[$i] = $i < 512 ? $i < 255 ? 0 : $i - 256 : 255;
     }
     $G1 = $G0 / 2;
     $C1 = $C0 / 2;
     for ($y = 0; $y < $H; $y++) {
         for ($x = 0; $x < $W; $x++) {
             $P = imageColorAt($image, $x, $y);
             $R = $P >> 16 & 0xff;
             $G = $P >> 8 & 0xff;
             $B = $P >> 0 & 0xff;
             $N = rand(0, $G0) - $G1;
             $R += 255 + $N + mt_rand(0, $C0) - $C1;
             $G += 255 + $N + mt_rand(0, $C0) - $C1;
             $B += 255 + $N + mt_rand(0, $C0) - $C1;
             imageSetPixel($image, $x, $y, $arrLUT[$R] << 16 | $arrLUT[$G] << 8 | $arrLUT[$B]);
         }
     }
 }
开发者ID:joly,项目名称:web2project,代码行数:23,代码来源:Captcha.class.php


示例10: Cartoonfy

 function Cartoonfy($p_image, $p_triplevel, $p_diffspace)
 {
     $this->triplevel = (int) (2000.0 + 5000.0 * $p_triplevel);
     $this->diffspace = (int) ($p_diffspace * 32.0);
     $this->i0 = imageCreateFromString(file_get_contents($p_image));
     if ($this->i0) {
         $this->i1 = imageCreateTrueColor(imageSx($this->i0), imageSy($this->i0));
         for ($x = (int) $this->diffspace; $x < imageSx($this->i0) - (1 + (int) $this->diffspace); $x++) {
             for ($y = (int) $this->diffspace; $y < imageSy($this->i0) - (1 + (int) $this->diffspace); $y++) {
                 $t = Cartoonfy::GetMaxContrast($x, $y);
                 if ($t > $this->triplevel) {
                     imageSetPixel($this->i1, $x, $y, 0);
                 } else {
                     imageSetPixel($this->i1, $x, $y, Cartoonfy::FlattenColor(imageColorAt($this->i0, $x, $y)));
                 }
             }
             //usleep(1000);
         }
         imageDestroy($this->i0);
     } else {
         print "<b>" . $p_image . "</b> is not supported image format!";
         exit;
     }
 }
开发者ID:BGCX067,项目名称:facebookpiccartoonizer-svn-to-git,代码行数:24,代码来源:Cartoonfy.class.php


示例11: valiCode

/**
 * 生成验证码图片
 *
 * @param String $word 验证码在session中的变量名称
 */
function valiCode($word = 'randcode')
{
    Header("Content-type: image/png");
    $border = 1;
    //是否要边框 1要:0不要
    $how = 4;
    //验证码位数
    $w = $how * 15;
    //图片宽度
    $h = 25;
    //图片高度
    $fontsize = 32;
    //字体大小
    $alpha = "abcdefghijkmnpqrstuvwxyz";
    //验证码内容1:字母
    $number = "23456789";
    //验证码内容2:数字
    $randcode = "";
    //验证码字符串初始化
    srand((double) microtime() * 1000000);
    //初始化随机数种子
    $im = imagecreate($w, $h);
    //创建验证图片
    /*
     * 绘制基本框架
     */
    $bgcolor = imagecolorallocate($im, 255, 255, 255);
    //设置背景颜色
    imageFill($im, 0, 0, $bgcolor);
    //填充背景色
    if ($border) {
        $black = imagecolorallocate($im, 9, 9, 9);
        //设置边框颜色
        imagerectangle($im, 0, 0, $w - 1, $h - 1, $black);
        //绘制边框
    }
    /*
     * 逐位产生随机字符
     */
    for ($i = 0; $i < $how; $i++) {
        $alpha_or_number = mt_rand(0, 1);
        //字母还是数字
        $str = $alpha_or_number ? $alpha : $number;
        $which = mt_rand(0, strlen($str) - 1);
        //取哪个字符
        $code = substr($str, $which, 1);
        //取字符
        $j = !$i ? 4 : $j + 15;
        //绘字符位置
        $color3 = imagecolorAllocate($im, mt_rand(0, 100), mt_rand(0, 100), mt_rand(0, 100));
        //字符随即颜色
        imagechar($im, $fontsize, $j, 3, $code, $color3);
        //绘字符
        $randcode .= $code;
        //逐位加入验证码字符串
    }
    /*
     * 如果需要添加干扰就将注释去掉
     *
     * 以下for()循环为绘背景干扰线代码
     */
    /* + -------------------------------绘背景干扰线 开始-------------------------------------------- + */
    for ($i = 0; $i < 5; $i++) {
        $color1 = imagecolorallocate($im, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
        //干扰线颜色
        imagearc($im, mt_rand(-5, $w), mt_rand(-5, $h), mt_rand(20, 300), mt_rand(20, 200), 55, 44, $color1);
        //干扰线
    }
    /* + -------------------------------绘背景干扰线 结束-------------------------------------- + */
    /*
     * 如果需要添加干扰就将注释去掉
     *
     * 以下for()循环为绘背景干扰点代码
     */
    /* + --------------------------------绘背景干扰点 开始------------------------------------------ + */
    for ($i = 0; $i < $how * 40; $i++) {
        $color2 = imagecolorallocate($im, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
        //干扰点颜色
        imageSetPixel($im, mt_rand(0, $w), mt_rand(0, $h), $color2);
        //干扰点
    }
    /* + --------------------------------绘背景干扰点 结束------------------------------------------ + */
    //把验证码字符串写入session  方便提交登录信息时检验验证码是否正确  例如:$_POST['randcode'] = $_SESSION['randcode']
    session_start();
    $_SESSION[$word] = $randcode;
    /*绘图结束*/
    imagepng($im);
    imagedestroy($im);
    /*绘图结束*/
}
开发者ID:syalr,项目名称:vitime-meeting,代码行数:95,代码来源:captcha.php


示例12: imageCopyMergeAlpha

 /**
  * Copy an image on another one and converse transparency
  *
  * @param resource $destImg
  * @param resource $srcImg
  * @param integer $destX
  * @param integer $destY
  * @param integer $srcX
  * @param integer $srcY
  * @param integer $srcW
  * @param integer $srcH
  * @param integer $pct
  */
 public static function imageCopyMergeAlpha(&$destImg, &$srcImg, $destX, $destY, $srcX, $srcY, $srcW, $srcH, $pct = 0)
 {
     $destX = (int) $destX;
     $destY = (int) $destY;
     $srcX = (int) $srcX;
     $srcY = (int) $srcY;
     $srcW = (int) $srcW;
     $srcH = (int) $srcH;
     $pct = (int) $pct;
     $destW = imageSX($destImg);
     $destH = imageSY($destImg);
     for ($y = 0; $y < $srcH + $srcY; $y++) {
         for ($x = 0; $x < $srcW + $srcX; $x++) {
             if ($x + $destX >= 0 && $x + $destX < $destW && $x + $srcX >= 0 && $x + $srcX < $srcW && $y + $destY >= 0 && $y + $destY < $destH && $y + $srcY >= 0 && $y + $srcY < $srcH) {
                 $destPixel = imageColorsForIndex($destImg, imageColorat($destImg, $x + $destX, $y + $destY));
                 $srcImgColorat = imageColorat($srcImg, $x + $srcX, $y + $srcY);
                 if ($srcImgColorat > 0) {
                     $srcPixel = imageColorsForIndex($srcImg, $srcImgColorat);
                     $srcAlpha = 1 - $srcPixel['alpha'] / 127;
                     $destAlpha = 1 - $destPixel['alpha'] / 127;
                     $opacity = $srcAlpha * $pct / 100;
                     if ($destAlpha >= $opacity) {
                         $alpha = $destAlpha;
                     }
                     if ($destAlpha < $opacity) {
                         $alpha = $opacity;
                     }
                     if ($alpha > 1) {
                         $alpha = 1;
                     }
                     if ($opacity > 0) {
                         $destRed = round($destPixel['red'] * $destAlpha * (1 - $opacity));
                         $destGreen = round($destPixel['green'] * $destAlpha * (1 - $opacity));
                         $destBlue = round($destPixel['blue'] * $destAlpha * (1 - $opacity));
                         $srcRed = round($srcPixel['red'] * $opacity);
                         $srcGreen = round($srcPixel['green'] * $opacity);
                         $srcBlue = round($srcPixel['blue'] * $opacity);
                         $red = round(($destRed + $srcRed) / ($destAlpha * (1 - $opacity) + $opacity));
                         $green = round(($destGreen + $srcGreen) / ($destAlpha * (1 - $opacity) + $opacity));
                         $blue = round(($destBlue + $srcBlue) / ($destAlpha * (1 - $opacity) + $opacity));
                         if ($red > 255) {
                             $red = 255;
                         }
                         if ($green > 255) {
                             $green = 255;
                         }
                         if ($blue > 255) {
                             $blue = 255;
                         }
                         $alpha = round((1 - $alpha) * 127);
                         $color = imageColorAllocateAlpha($destImg, $red, $green, $blue, $alpha);
                         imageSetPixel($destImg, $x + $destX, $y + $destY, $color);
                     }
                 }
             }
         }
     }
 }
开发者ID:TahsinGokalp,项目名称:L3-Eticaret,代码行数:71,代码来源:ImageWorkshopLib.php


示例13: setnoise

 protected function setnoise()
 {
     for ($i = 0; $i < $this->noisenum; $i++) {
         $randColor = imageColorAllocate($this->image, rand(0, 255), rand(0, 255), rand(0, 255));
         imageSetPixel($this->image, rand(0, $this->width), rand(0, $this->height), $randColor);
     }
 }
开发者ID:eon-hong,项目名称:anypay,代码行数:7,代码来源:spVerifyCode.php


示例14: imageSmoothArcDrawSegment

function imageSmoothArcDrawSegment(&$img, $cx, $cy, $a, $b, $aaAngleX, $aaAngleY, $color, $start, $stop, $seg)
{
    // Originally written from scratch by Ulrich Mierendorff, 06/2006
    // Rewritten and improved, 04/2007, 07/2007
    // Please do not use THIS function directly. Scroll down to imageSmoothArc(...).
    $fillColor = imageColorExactAlpha($img, $color[0], $color[1], $color[2], $color[3]);
    $xStart = abs($a * cos($start));
    $yStart = abs($b * sin($start));
    $xStop = abs($a * cos($stop));
    $yStop = abs($b * sin($stop));
    $dxStart = 0;
    $dyStart = 0;
    $dxStop = 0;
    $dyStop = 0;
    if ($xStart != 0) {
        $dyStart = $yStart / $xStart;
    }
    if ($xStop != 0) {
        $dyStop = $yStop / $xStop;
    }
    if ($yStart != 0) {
        $dxStart = $xStart / $yStart;
    }
    if ($yStop != 0) {
        $dxStop = $xStop / $yStop;
    }
    if (abs($xStart) >= abs($yStart)) {
        $aaStartX = true;
    } else {
        $aaStartX = false;
    }
    if ($xStop >= $yStop) {
        $aaStopX = true;
    } else {
        $aaStopX = false;
    }
    //$xp = +1; $yp = -1; $xa = +1; $ya = 0;
    for ($x = 0; $x < $a; $x += 1) {
        /*$y = $b * sqrt( 1 - ($x*$x)/($a*$a) );
          
          $error = $y - (int)($y);
          $y = (int)($y);
          
          $diffColor = imageColorExactAlpha( $img, $color[0], $color[1], $color[2], 127-(127-$color[3])*$error );*/
        $_y1 = $dyStop * $x;
        $_y2 = $dyStart * $x;
        if ($xStart > $xStop) {
            $error1 = $_y1 - (int) $_y1;
            $error2 = 1 - $_y2 + (int) $_y2;
            $_y1 = $_y1 - $error1;
            $_y2 = $_y2 + $error2;
        } else {
            $error1 = 1 - $_y1 + (int) $_y1;
            $error2 = $_y2 - (int) $_y2;
            $_y1 = $_y1 + $error1;
            $_y2 = $_y2 - $error2;
        }
        /*
        if ($aaStopX)
            $diffColor1 = imageColorExactAlpha( $img, $color[0], $color[1], $color[2], 127-(127-$color[3])*$error1 );
        if ($aaStartX)
            $diffColor2 = imageColorExactAlpha( $img, $color[0], $color[1], $color[2], 127-(127-$color[3])*$error2 );
        */
        if ($seg == 0 || $seg == 2) {
            $i = $seg;
            if (!($start > $i * M_PI / 2 && $x > $xStart)) {
                if ($i == 0) {
                    $xp = +1;
                    $yp = -1;
                    $xa = +1;
                    $ya = 0;
                } else {
                    $xp = -1;
                    $yp = +1;
                    $xa = 0;
                    $ya = +1;
                }
                if ($stop < ($i + 1) * (M_PI / 2) && $x <= $xStop) {
                    $diffColor1 = imageColorExactAlpha($img, $color[0], $color[1], $color[2], 127 - (127 - $color[3]) * $error1);
                    $y1 = $_y1;
                    if ($aaStopX) {
                        imageSetPixel($img, $cx + $xp * $x + $xa, $cy + $yp * ($y1 + 1) + $ya, $diffColor1);
                    }
                } else {
                    $y = $b * sqrt(1 - $x * $x / ($a * $a));
                    $error = $y - (int) $y;
                    $y = (int) $y;
                    $diffColor = imageColorExactAlpha($img, $color[0], $color[1], $color[2], 127 - (127 - $color[3]) * $error);
                    $y1 = $y;
                    if ($x < $aaAngleX) {
                        imageSetPixel($img, $cx + $xp * $x + $xa, $cy + $yp * ($y1 + 1) + $ya, $diffColor);
                    }
                }
                if ($start > $i * M_PI / 2 && $x <= $xStart) {
                    $diffColor2 = imageColorExactAlpha($img, $color[0], $color[1], $color[2], 127 - (127 - $color[3]) * $error2);
                    $y2 = $_y2;
                    if ($aaStartX) {
                        imageSetPixel($img, $cx + $xp * $x + $xa, $cy + $yp * ($y2 - 1) + $ya, $diffColor2);
                    }
                } else {
//.........这里部分代码省略.........
开发者ID:gdbhosale,项目名称:fancy-qr-code-generator,代码行数:101,代码来源:imageSmoothArc.php


示例15: osc_gd_resize

function osc_gd_resize($original_image, $dest_image, $dest_width, $dest_height, $force_size = '0')
{
    $img_type = false;
    switch (strtolower(substr(basename($original_image), strrpos(basename($original_image), '.') + 1))) {
        case 'jpg':
        case 'jpeg':
            if (imagetypes() & IMG_JPG) {
                $img_type = 'jpg';
            }
            break;
        case 'gif':
            if (imagetypes() & IMG_GIF) {
                $img_type = 'gif';
            }
            break;
        case 'png':
            if (imagetypes() & IMG_PNG) {
                $img_type = 'png';
            }
            break;
    }
    if ($img_type !== false) {
        list($orig_width, $orig_height) = getimagesize($original_image);
        $width = $dest_width;
        $height = $dest_height;
        $factor = max($orig_width / $width, $orig_height / $height);
        if ($force_size == '1') {
            $width = $dest_width;
        } else {
            $width = round($orig_width / $factor);
            $height = round($orig_height / $factor);
        }
        $im_p = imageCreateTrueColor($dest_width, $dest_height);
        imageAntiAlias($im_p, true);
        imagealphablending($im_p, false);
        imagesavealpha($im_p, true);
        $transparent = imagecolorallocatealpha($im_p, 255, 255, 255, 127);
        for ($x = 0; $x < $dest_width; $x++) {
            for ($y = 0; $y < $dest_height; $y++) {
                imageSetPixel($im_p, $x, $y, $transparent);
            }
        }
        $x = 0;
        $y = 0;
        if ($force_size == '1') {
            $width = round($orig_width * $dest_height / $orig_height);
            if ($width < $dest_width) {
                $x = floor(($dest_width - $width) / 2);
            }
        } else {
            $x = floor(($dest_width - $width) / 2);
            $y = floor(($dest_height - $height) / 2);
        }
        switch ($img_type) {
            case 'jpg':
                $im = imagecreatefromjpeg($original_image);
                break;
            case 'gif':
                $im = imagecreatefromgif($original_image);
                break;
            case 'png':
                $im = imagecreatefrompng($original_image);
                break;
        }
        imagecopyresampled($im_p, $im, $x, $y, 0, 0, $width, $height, $orig_width, $orig_height);
        switch ($img_type) {
            case 'jpg':
                imagejpeg($im_p, $dest_image);
                break;
            case 'gif':
                imagegif($im_p, $dest_image);
                break;
            case 'png':
                imagepng($im_p, $dest_image);
                break;
        }
        imagedestroy($im_p);
        imagedestroy($im);
        @chmod($dest_image, 0777);
    } else {
        return false;
    }
}
开发者ID:Doluci,项目名称:tomatocart,代码行数:83,代码来源:general.php


示例16: imageCreateTrueColor

<?php

$im = imageCreateTrueColor(150, 50);
$color = imageColorAllocate($im, 128, 128, 128);
imageFill($im, 10, 10, $color);
$color = imageColorAllocate($im, 255, 255, 255);
for ($i = 0; $i < 800; $i++) {
    $randW = mt_rand(0, imageSX($im));
    $randH = mt_rand(0, imageSY($im));
    imageSetPixel($im, $randW, $randH, $color);
}
imageSetThickness($im, 2);
$color = imageColorAllocate($im, 100, 100, 100);
imageLine($im, 10, 30, 130, 20, $color);
$color = imageColorAllocate($im, 70, 70, 70);
$n1 = mt_rand(0, 9);
imageTtfText($im, 25, 10, mt_rand(2, 10), mt_rand(25, 45), $color, "times.ttf", $n1);
$color = imageColorAllocate($im, 255, 0, 50);
$str = "ABCDIFGHIJKLMNOPKASTUVWXYZ";
$nw = mt_rand(0, 15);
$n2 = $str[$nw];
imageTtftext($im, 22, -10, mt_rand(25, 35), mt_rand(25, 45), $color, "times.ttf", $n2);
$color = imageColorAllocate($im, 50, 50, 50);
$n3 = mt_rand(0, 9);
imageTtfText($im, 25, 15, mt_rand(60, 70), mt_rand(25, 45), $color, "times.ttf", $n3);
$color = imageColorAllocate($im, 250, 250, 250);
$nw2 = mt_rand(15, 25);
$n4 = $str[$nw2];
imageTtfText($im, 22, 30, mt_rand(90, 100), mt_rand(25, 45), $color, "times.ttf", $n4);
$color = imageColorAllocate($im, 255, 220, 70);
$n5 = mt_rand(0, 9);
开发者ID:echmaster,项目名称:data,代码行数:31,代码来源:dzim.php


示例17: foreach

//}
foreach ($matrice as $i => $ligne) {
    $max_ligne = max($ligne);
    foreach ($ligne as $j => $val) {
        $max_ligne == 0 ? $d = 0 : ($d = $val / $max_ligne);
        if ($d >= $discretisation_max) {
            $d = 1;
        } elseif ($d <= $discretisation_min) {
            $d = 0;
        }
        $color = dictionnaire_color($image, $dico_color, $d);
        for ($sc = $i * $zoom + $margin_left; $sc < ($i + 1) * $zoom + $margin_left; ++$sc) {
            for ($sl = $j * $zoom + $margin_top; $sl < ($j + 1) * $zoom + $margin_top; ++$sl) {
                imageSetPixel($image, $sc, $sl, $color);
            }
        }
    }
}
for ($i = 0; $i < 10; ++$i) {
    $x = ($height - $margin_top) / 10 * $i + $margin_top;
    $y = ($lengh - $margin_left) / 10 * $i + $margin_left;
    imagestring($image, 1, 0, $x + 2, "{$i}" . '0%', $dico_color['red']);
    for ($j = 0; $j < $margin_left; ++$j) {
        imageSetPixel($image, $j, $x, $dico_color['red']);
    }
    imagestring($image, 1, $y + 2, 0, "{$i}" . '0%', $dico_color['red']);
    for ($j = 0; $j < $margin_top; ++$j) {
        imageSetPixel($image, $y, $j, $dico_color['red']);
    }
}
imagepng($image, "out.png");
开发者ID:BGCX261,项目名称:zone-align-svn-to-git,代码行数:31,代码来源:read2matrix_detailed.php


示例18: array_merge

require_once '../../../../../wp-load.php';
// Captcha image size
$imageWidth = 320;
$imageHeight = 50;
// Number of characters in captcha image - captcha length
$charsNumber = 6;
// Random characters array
$characters = array_merge(range(0, 9), range('a', 'z'));
shuffle($characters);
// Create captcha image
$captchaImage = imageCreateTrueColor($imageWidth, $imageHeight);
for ($pixelX = 0; $pixelX < $imageWidth; $pixelX++) {
    for ($pixelY = 0; $pixelY < $imageHeight; $pixelY++) {
        $randomPixelColor = imageColorAllocate($captchaImage, 255, 255, 255);
        imageSetPixel($captchaImage, $pixelX, $pixelY, $randomPixelColor);
    }
}
$captchaText = "";
// Full captcha text
$charImageStep = $imageWidth / ($charsNumber + 1);
$charWritePoint = $charImageStep;
// Write captcha characters to the image
for ($i = 0; $i < $charsNumber; $i++) {
    $nextChar = $characters[mt_rand(0, count($characters) - 1)];
    $captchaText .= $nextChar;
    // Font properties
    $randomFontSize = mt_rand(25, 30);
    // Random character size to spice things a little bit :)
    $randomFontAngle = mt_rand(-25, 25);
    // Twist the character a little bit
开发者ID:Alimir,项目名称:ajax-bootmodal-login,代码行数:30,代码来源:log-captcha.php


示例19: create_images


//.........这里部分代码省略.........
             $max_top = $top;
         }
         $fragments[] = array($w, $width, $height, $left, $top);
     }
     // Create images for each word.
     $count = 1;
     $return = array();
     foreach ($fragments as $f) {
         list($w, $width, $height, $left, $top) = $f;
         $img_width = $width + $padding_left + $padding_right;
         $img_height = $this->image_height ? $this->image_height : $max_height + $padding_top + $padding_bottom;
         $text_left = $left + $padding_left;
         $text_top = $max_top + $padding_top;
         // Adjust image size and text location if there's a shadow.
         if ($this->shadow) {
             if ($this->shadow_offset[0] < 0) {
                 $shadow_space_left = $this->shadow_blur - $this->shadow_offset[0];
                 $shadow_space_right = max(0, $this->shadow_blur + abs($this->shadow_offset[0]));
                 $shadow_left = $text_left + $shadow_space_left;
                 $text_left = $text_left + $shadow_space_left - $this->shadow_offset[0];
             } else {
                 $shadow_space_left = max(0, $this->shadow_blur - $this->shadow_offset[0]);
                 $shadow_space_right = $this->shadow_blur + $this->shadow_offset[0];
                 $shadow_left = $text_left + $shadow_space_left + $this->shadow_offset[0];
                 $text_left = $text_left + $shadow_space_left;
             }
             if ($this->shadow_offset[1] < 0) {
                 $shadow_space_top = $this->shadow_blur - $this->shadow_offset[1];
                 $shadow_space_bottom = max(0, $this->shadow_blur + abs($this->shadow_offset[1]));
                 $shadow_top = $text_top + $shadow_space_top;
                 $text_top = $text_top + $shadow_space_top - $this->shadow_offset[1];
             } else {
                 $shadow_space_top = max(0, $this->shadow_blur - $this->shadow_offset[1]);
                 $shadow_space_bottom = $this->shadow_blur + $this->shadow_offset[1];
                 $shadow_top = $text_top + $shadow_space_top + $this->shadow_offset[1];
                 $text_top = $text_top + $shadow_space_top;
             }
             $img_width += $shadow_space_left + $shadow_space_right;
             $img_height += $shadow_space_top + $shadow_space_bottom;
         }
         // Initialize the image and draw the background.
         $img = imageCreateTrueColor($img_width, $img_height);
         if ($this->background_color === false) {
             imageSaveAlpha($img, true);
             imageAlphaBlending($img, false);
             $img_background_color = imageColorAllocateAlpha($img, 255, 255, 255, 127);
             imageFilledRectangle($img, 0, 0, $img_width, $img_height, $img_background_color);
             imageAlphaBlending($img, true);
         } else {
             $img_background_colors = $this->hex2rgb($this->background_color);
             $img_background_color = imageColorAllocate($img, $img_background_colors[0], $img_background_colors[1], $img_background_colors[2]);
             imageFilledRectangle($img, 0, 0, $img_width, $img_height, $img_background_color);
         }
         // Draw the shadow.
         if ($this->shadow) {
             // Blurred shadow on a transparent background needs special treatment because of GD's limitations.
             if ($this->shadow_blur && $this->background_color === false) {
                 // Create a temporary image for the shadow.
                 $temp = imageCreateTrueColor($img_width, $img_height);
                 imageSaveAlpha($temp, true);
                 imageFilledRectangle($temp, 0, 0, $img_width, $img_height, imageColorAllocate($temp, 127, 127, 127));
                 // Draw the shadow text on the temporary image, and blur it.
                 $temp_text_color = imageColorAllocate($temp, $this->shadow_opacity, $this->shadow_opacity, $this->shadow_opacity);
                 imageTTFText($temp, $font_size, 0, $shadow_left, $shadow_top, $temp_text_color, $font_filename, $w);
                 for ($i = 0; $i < $this->shadow_blur; $i++) {
                     imageFilter($temp, IMG_FILTER_GAUSSIAN_BLUR);
                 }
                 // Use the blurred shadow as an alpha mask on the original image.
                 $shadow_colors = $this->hex2rgb($this->shadow_color);
                 for ($x = 0; $x < $img_width; $x++) {
                     for ($y = 0; $y < $img_height; $y++) {
                         $alpha = imageColorAt($temp, $x, $y) & 0xff;
                         imageSetPixel($img, $x, $y, imageColorAllocateAlpha($img, $shadow_colors[0], $shadow_colors[1], $shadow_colors[2], $alpha));
                     }
                 }
                 imageDestroy($temp);
             } else {
                 $shadow_colors = $this->hex2rgb($this->shadow_color);
                 $shadow_color = imageColorAllocateAlpha($img, $shadow_colors[0], $shadow_colors[1], $shadow_colors[2], $this->shadow_opacity);
                 imageTTFText($img, $font_size, 0, $shadow_left, $shadow_top, $shadow_color, $font_filename, $w);
                 for ($i = 0; $i < $this->shadow_blur; $i++) {
                     imageFilter($img, IMG_FILTER_GAUSSIAN_BLUR);
                 }
             }
         }
         // Draw the word.
         $text_colors = $this->hex2rgb($this->color);
         $text_color = imageColorAllocate($img, $text_colors[0], $text_colors[1], $text_colors[2]);
         imageTTFText($img, $font_size, 0, $text_left, $text_top, $text_color, $font_filename, $w);
         // Save to a PNG file.
         $filename = '/imgtext.' . $hash . '.word-' . str_pad($count, 3, '0', STR_PAD_LEFT) . '.png';
         imagePNG($img, $this->cache_local_dir . $filename);
         imageDestroy($img);
         // Add information about this word to the return array.
         $return[] = array('word' => $w, 'path' => $this->cache_url_prefix . $filename);
         $count++;
     }
     // Returns a list of dictionaries, each containing a word and the corresponding image URL.
     return $return;
 }
开发者ID:kijin,项目名称:imgtext,代码行数:101,代码来源:imgtext.php


示例20: setnoise

 static function setnoise()
 {
     for ($i = 0; $i < self::$noisenum; $i++) {
         $randColor = imageColorAllocate(self::$_image, rand(0, 255), rand(0, 255), rand(0, 255));
         imageSetPixel(self::$_image, rand(0, self 

鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP imageSmoothArc函数代码示例发布时间:2022-05-15
下一篇:
PHP imageSaveAlpha函数代码示例发布时间: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