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


PHP ImageColorAllocate函数代码示例

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


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

示例1: MyImageBlur

function MyImageBlur($im, $pct) {
	// w00t. my very own blur function
	// in GD2, there's a gaussian blur function. smarmy bastards. ;-)
	$width = imagesx($im);
	$height = imagesy($im);
	$temp_im = ImageCreate($width, $height);
	$bg = ImageColorAllocate($temp_im, 255, 255, 255);
	// preserves transparency if in orig image
	ImageColorTransparent($temp_im, $bg);
	// fill bg
	ImageFill($temp_im, 0, 0, $bg);
	$distance = 1;
	// emboss:
	ImageCopyMerge($temp_im, $im, 0, 0, $distance, $distance, $width, $height, $pct);
	ImageCopyMerge($im, $temp_im, -$distance, -$distance, 0, 0, $width, $height, $pct);
	ImageFill($temp_im, 0, 0, $bg);
	ImageCopyMerge($temp_im, $im, 0, $distance, $distance, 0, $width, $height, $pct);
	ImageCopyMerge($im, $temp_im, $distance, 0, 0, $distance, $width, $height, $pct);
	// blur:
	ImageCopyMerge($temp_im, $im, 0, $distance, 0, 0, $width, $height, $pct);
	ImageCopyMerge($im, $temp_im, $distance, 0, 0, 0, $width, $height, $pct);
	ImageCopyMerge($temp_im, $im, 0, 0, 0, $distance, $width, $height, $pct);
	ImageCopyMerge($im, $temp_im, 0, 0, $distance, 0, $width, $height, $pct);
	// remove temp image
	ImageDestroy($temp_im);
	return $im;
}
开发者ID:Naddiseo,项目名称:WW2Game,代码行数:27,代码来源:imageclick.php

示例2: drawRating

function drawRating($rating, $max, $type)
{
    if ($type == 0) {
        $image = imagecreatetruecolor(102, 15);
        $back = ImageColorAllocate($image, 250, 250, 250);
        $border = ImageColorAllocate($image, 0, 0, 0);
        $fill = ImageColorAllocate($image, 0, 235, 0);
        ImageFilledRectangle($image, 0, 0, 101, 14, $back);
        ImageFilledRectangle($image, 1, 1, $rating / $max * 100, 14, $fill);
        ImageRectangle($image, 0, 0, 101, 14, $border);
        $textcolor = imagecolorallocate($image, 0, 0, 0);
        imagestring($image, 5, 35, 0, $rating / $max * 100 . '%', $textcolor);
    } else {
        if ($rating > $max) {
            $rating = $max;
        }
        $image = imagecreatetruecolor(10 * ($rating + 2) + 2, 15);
        $back = ImageColorAllocate($image, 250, 250, 250);
        $border = ImageColorAllocate($image, 0, 0, 0);
        $fill = ImageColorAllocate($image, 235, 0, 0);
        ImageFilledRectangle($image, 0, 0, 10 * ($rating + 2) + 1, 14, $back);
        ImageFilledRectangle($image, 1, 1, 10 * $rating, 14, $fill);
        ImageRectangle($image, 0, 0, 10 * $rating + 1, 14, $border);
        $textcolor = imagecolorallocate($image, 0, 0, 0);
        imagestring($image, 5, 10 * ($rating + 1), 0, $rating, $textcolor);
    }
    imagepng($image);
    imagedestroy($image);
}
开发者ID:noahrichards,项目名称:pb,代码行数:29,代码来源:pngbar.php

示例3: reflect

 public function reflect()
 {
     $transparency_step = (100 - $this->transparency) / $this->gradient_height;
     $background = imagecreatetruecolor($this->imgWidth, $this->gradient_height + $this->imgHeight);
     $gdGradientColor = ImageColorAllocate($background, 255, 255, 255);
     $newImage = imagecreatetruecolor($this->imgWidth, $this->imgHeight);
     for ($x = 0; $x < $this->imgWidth; $x++) {
         for ($y = 0; $y < $this->imgHeight; $y++) {
             imagecopy($newImage, $this->img, $x, $this->imgHeight - $y - 1, $x, $y, 1, 1);
         }
     }
     imagecopymerge($background, $newImage, 0, $this->imgHeight, 0, 0, $this->imgWidth, $this->imgHeight, 100);
     imagecopymerge($background, $this->img, 0, 0, 0, 0, $this->imgWidth, $this->imgHeight, 100);
     $gradient_line = imagecreatetruecolor($this->imgWidth, 1);
     //voir si on garde ça et la suite
     // Next we draw a GD line into our gradient_line
     imageline($gradient_line, 0, 0, $this->imgWidth, 0, $gdGradientColor);
     for ($i = $this->imgHeight; $i < $this->gradient_height + $this->imgHeight; $i++) {
         imagecopymerge($background, $gradient_line, 0, $i, 0, 0, $this->imgWidth, 1, $this->transparency);
         if ($this->transparency != 100) {
             $this->transparency += $transparency_step;
         }
     }
     $this->img = $background;
 }
开发者ID:nchourrout,项目名称:GD-Mirror,代码行数:25,代码来源:mirror_effect.class.php

示例4: capcha

function capcha($salt)
{
    srand(time());
    $md5_hash = md5(rand(0, 9999));
    $security_code = substr($md5_hash, 25, 5);
    $enc = md5($security_code . $salt);
    $_SESSION['count'] = $enc;
    $secure = $_SESSION['count'];
    // echo "--------------------------$secure<br>";
    $width = 50;
    $height = 24;
    $image = ImageCreate($width, $height);
    $white = ImageColorAllocate($image, 255, 255, 255);
    $black = ImageColorAllocate($image, 0, 100, 0);
    $grey = ImageColorAllocate($image, 204, 204, 204);
    ImageFill($image, 0, 0, $white);
    //Add randomly generated string in white to the image
    ImageString($image, 10, 4, 4, $security_code, $black);
    // ImageRectangle($image,0,16,$width-1,$height-1,$grey);
    imageline($image, 0, $height / 2, $width, $height / 2, $grey);
    imageline($image, $width / 2, 0, $width / 2, $height, $grey);
    header("Content-Type: image/jpeg");
    header("Cache-Control: no-cache, must-revalidate");
    ImageJpeg($image);
    ImageDestroy($image);
}
开发者ID:akalend,项目名称:test,代码行数:26,代码来源:capcha.php

示例5: create_image

function create_image()
{
    //Let's generate a totally random string using md5
    $md5_hash = md5(rand(0, 999));
    //We don't need a 32 character long string so we trim it down to 5
    $security_code = substr($md5_hash, 15, 5);
    //Set the session to store the security code
    $_SESSION["captchaCode"] = $security_code;
    //Set the image width and height
    $width = 100;
    $height = 20;
    //Create the image resource
    $image = ImageCreate($width, $height);
    //We are making three colors, white, black and gray
    $white = ImageColorAllocate($image, 255, 255, 255);
    $black = ImageColorAllocate($image, 0, 0, 0);
    $grey = ImageColorAllocate($image, 204, 204, 204);
    //Make the background black
    ImageFill($image, 0, 0, $black);
    //Add randomly generated string in white to the image
    ImageString($image, 3, 30, 3, $security_code, $white);
    //Throw in some lines to make it a little bit harder for any bots to break
    ImageRectangle($image, 0, 0, $width - 1, $height - 1, $grey);
    imageline($image, 0, $height / 2, $width, $height / 2, $grey);
    imageline($image, $width / 2, 0, $width / 2, $height, $grey);
    //Tell the browser what kind of file is come in
    header("Content-Type: image/jpeg");
    //Output the newly created image in jpeg format
    ImageJpeg($image);
    //Free up resources
    ImageDestroy($image);
}
开发者ID:quachvancam,项目名称:sugardating,代码行数:32,代码来源:createImage.php

示例6: drawRating

function drawRating()
{
    $width = $_GET['width'];
    $height = $_GET['height'];
    if ($width == 0) {
        $width = 200;
    }
    if ($height == 0) {
        $height = 7;
    }
    $rating = $_GET['rating'];
    $ratingbar = $rating / 100 * $width - 2;
    $image = imagecreate($width, $height);
    $fill = ImageColorAllocate($image, 0, 255, 0);
    if ($rating > 49) {
        $fill = ImageColorAllocate($image, 255, 255, 0);
    }
    if ($rating > 74) {
        $fill = ImageColorAllocate($image, 255, 128, 0);
    }
    if ($rating > 89) {
        $fill = ImageColorAllocate($image, 255, 0, 0);
    }
    $back = ImageColorAllocate($image, 205, 205, 205);
    $border = ImageColorAllocate($image, 0, 0, 0);
    ImageFilledRectangle($image, 0, 0, $width - 1, $height - 1, $back);
    ImageFilledRectangle($image, 1, 1, $ratingbar, $height - 1, $fill);
    ImageRectangle($image, 0, 0, $width - 1, $height - 1, $border);
    imagePNG($image);
    imagedestroy($image);
}
开发者ID:SheppeR,项目名称:rapidleech,代码行数:31,代码来源:bar.php

示例7: create_captcha

function create_captcha()
{
    session_start();
    //生成验证码图片
    Header("Content-type: image/PNG");
    $im = imagecreate(44, 18);
    // 画一张指定宽高的图片
    $back = ImageColorAllocate($im, 245, 245, 245);
    // 定义背景颜色
    imagefill($im, 0, 0, $back);
    //把背景颜色填充到刚刚画出来的图片中
    $vcodes = "";
    srand((double) microtime() * 1000000);
    //生成4位数字
    for ($i = 0; $i < 4; $i++) {
        $font = ImageColorAllocate($im, rand(100, 255), rand(0, 100), rand(100, 255));
        // 生成随机颜色
        $authnum = rand(1, 9);
        $vcodes .= $authnum;
        imagestring($im, 5, 2 + $i * 10, 1, $authnum, $font);
    }
    $_SESSION['VCODE'] = $vcodes;
    for ($i = 0; $i < 100; $i++) {
        $randcolor = ImageColorallocate($im, rand(0, 255), rand(0, 255), rand(0, 255));
        imagesetpixel($im, rand() % 70, rand() % 30, $randcolor);
        // 画像素点函数
    }
    ImagePNG($im);
    ImageDestroy($im);
}
开发者ID:NingerJohn,项目名称:vfinder,代码行数:30,代码来源:captcha_helper.php

示例8: create_captcha

function create_captcha($width = 60, $height = 32)
{
    session_start();
    //生成验证码图片
    Header("Content-type: image/PNG");
    $im = imagecreate($width, $height);
    // width and height of image
    $back = ImageColorAllocate($im, 245, 245, 245);
    // specify background color
    imagefill($im, 0, 0, $back);
    // fill the background color into image
    $vcodes = "";
    srand((double) microtime() * 1000000);
    //生成4位数字
    for ($i = 0; $i < 4; $i++) {
        $font = ImageColorAllocate($im, rand(100, 255), rand(0, 100), rand(100, 255));
        // 生成随机颜色
        $authnum = rand(1, 9);
        $vcodes .= $authnum;
        imagestring($im, 5, 2 + $i * 10, 1, $authnum, $font);
    }
    for ($i = 0; $i < 100; $i++) {
        // interuppting
        $randcolor = ImageColorallocate($im, rand(0, 255), rand(0, 255), rand(0, 255));
        imagesetpixel($im, rand() % 70, rand() % 30, $randcolor);
        // 画像素点函数
    }
    ImagePNG($im);
    ImageDestroy($im);
    $_SESSION['captcha'] = $vcodes;
}
开发者ID:NingerJohn,项目名称:vfinder,代码行数:31,代码来源:code.php

示例9: captcha_create

function captcha_create($text, $config)
{
    global $cfg;
    // anzahl der zeichen
    $count = strlen($text);
    // schriftarten festlegen
    $ttf = $config["ttf"];
    // schriftgroesse festlegen
    $ttf_size = $config["font"]["size"];
    // schriftabstand rechts
    $ttf_x = $config["font"]["x"];
    // schriftabstand oben
    $ttf_y = $config["font"]["y"];
    // hintergrund erstellen
    $ttf_img = ImageCreate($count * 2 * $ttf_size, 2 * $ttf_size);
    // bgfarbe festlegen
    $bg_color = ImageColorAllocate($ttf_img, $config["bg_color"][0], $config["bg_color"][1], $config["bg_color"][2]);
    // textfarbe festlegen
    $font_color = ImageColorAllocate($ttf_img, $config["font_color"][0], $config["font_color"][1], $config["font_color"][2]);
    // schrift in bild einfuegen
    foreach (str_split($text) as $key => $character) {
        // schriftwinkel festlegen
        $ttf_angle = rand(-25, 25);
        // schriftarten auswaehlen
        $ttf_font = $ttf[rand(0, count($ttf) - 1)];
        imagettftext($ttf_img, $ttf_size, $ttf_angle, $ttf_size * 2 * $key + $ttf_x, $ttf_y, $font_color, $ttf_font, $character);
    }
    // bild temporaer als datei ausgeben
    $captcha_crc = crc32($text . $config["randomize"]);
    $captcha_name = "captcha-" . $captcha_crc . ".png";
    $captcha_path = $cfg["file"]["base"]["maindir"] . $cfg["file"]["base"]["new"];
    imagepng($ttf_img, $captcha_path . $captcha_name);
    // bild loeschen
    imagedestroy($ttf_img);
}
开发者ID:BackupTheBerlios,项目名称:ewebuki-svn,代码行数:35,代码来源:function_captcha.inc.php

示例10: image

 private static function image($frame, $pixelPerPoint = 4, $outerFrame = 4, $back_color = 0xffffff, $fore_color = 0x0)
 {
     $h = count($frame);
     $w = strlen($frame[0]);
     $imgW = $w + 2 * $outerFrame;
     $imgH = $h + 2 * $outerFrame;
     $base_image = ImageCreate($imgW, $imgH);
     // convert a hexadecimal color code into decimal eps format (green = 0 1 0, blue = 0 0 1, ...)
     $r1 = round(($fore_color & 0xff0000) >> 16, 5);
     $b1 = round(($fore_color & 0xff00) >> 8, 5);
     $g1 = round($fore_color & 0xff, 5);
     // convert a hexadecimal color code into decimal eps format (green = 0 1 0, blue = 0 0 1, ...)
     $r2 = round(($back_color & 0xff0000) >> 16, 5);
     $b2 = round(($back_color & 0xff00) >> 8, 5);
     $g2 = round($back_color & 0xff, 5);
     $col[0] = ImageColorAllocate($base_image, $r2, $b2, $g2);
     $col[1] = ImageColorAllocate($base_image, $r1, $b1, $g1);
     imagefill($base_image, 0, 0, $col[0]);
     for ($y = 0; $y < $h; $y++) {
         for ($x = 0; $x < $w; $x++) {
             if ($frame[$y][$x] == '1') {
                 ImageSetPixel($base_image, $x + $outerFrame, $y + $outerFrame, $col[1]);
             }
         }
     }
     $target_image = ImageCreate($imgW * $pixelPerPoint, $imgH * $pixelPerPoint);
     ImageCopyResized($target_image, $base_image, 0, 0, 0, 0, $imgW * $pixelPerPoint, $imgH * $pixelPerPoint, $imgW, $imgH);
     ImageDestroy($base_image);
     return $target_image;
 }
开发者ID:RKathees,项目名称:is-connectors,代码行数:30,代码来源:qrimage.php

示例11: draw_captcha

function draw_captcha($security_code)
{
    //Set the image width and height
    $width = 100;
    $height = 25;
    //Create the image resource
    $image = ImageCreate($width, $height);
    if (function_exists('imageantialias')) {
        imageantialias($image, true);
    }
    //We are making three colors, white, black and gray
    $white = ImageColorAllocate($image, 255, 255, 255);
    $black = ImageColorAllocate($image, 15, 50, 15);
    $grey = ImageColorAllocate($image, 204, 204, 204);
    $ellipsec = ImageColorAllocate($image, 0, 100, 60);
    //Make the background black
    ImageFill($image, 0, 0, $black);
    imagefilledellipse($image, 56, 15, 30, 17, $ellipsec);
    //Add randomly generated string in white to the image
    ImageString($image, 5, 30, 4, $security_code, $white);
    //Throw in some lines to make it a little bit harder for any bots to break
    ImageRectangle($image, 0, 0, $width - 1, $height - 1, $grey);
    imageline($image, 0, $height / 2 + 3, $width, $height / 2 + 5, $grey);
    imageline($image, $width / 2 - 14, 0, $width / 2 + 7, $height, $grey);
    //Tell the browser what kind of file is come in
    header("Content-Type: image/jpeg");
    //Output the newly created image in jpeg format
    ImageJpeg($image);
    //Free up resources
    ImageDestroy($image);
}
开发者ID:kuell,项目名称:chat,代码行数:31,代码来源:captcha.php

示例12: generate

 /**
  * Generates the captcha image
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return	
  */
 public function generate()
 {
     $id = $this->input->get('id', '', 'int');
     // Load up the captcha object
     $captcha = EB::table('Captcha');
     // Clear outdated keys
     $captcha->clear();
     // load the captcha records.
     $captcha->load($id);
     if (!$captcha->id) {
         return false;
     }
     // @task: Generate a very random integer and take only 5 chars max.
     $hash = JString::substr(md5(rand(0, 9999)), 0, 5);
     $captcha->response = $hash;
     $captcha->store();
     // Captcha width and height
     $width = 100;
     $height = 20;
     $image = ImageCreate($width, $height);
     $white = ImageColorAllocate($image, 255, 255, 255);
     $black = ImageColorAllocate($image, 0, 0, 0);
     $gray = ImageColorAllocate($image, 204, 204, 204);
     ImageFill($image, 0, 0, $white);
     ImageString($image, 5, 30, 3, $hash, $black);
     ImageRectangle($image, 0, 0, $width - 1, $height - 1, $gray);
     imageline($image, 0, $height / 2, $width, $height / 2, $gray);
     imageline($image, $width / 2, 0, $width / 2, $height, $gray);
     header('Content-type: image/jpeg');
     ImageJpeg($image);
     ImageDestroy($image);
     exit;
 }
开发者ID:BetterBetterBetter,项目名称:B3App,代码行数:41,代码来源:captcha.php

示例13: colorHex

 public function colorHex($img, $hexColorString)
 {
     $r = hexdec(substr($hexColorString, 0, 2));
     $g = hexdec(substr($hexColorString, 2, 2));
     $b = hexdec(substr($hexColorString, 4, 2));
     return ImageColorAllocate($img, $r, $g, $b);
 }
开发者ID:Ernie69,项目名称:spotweb,代码行数:7,代码来源:Services_Image_Util.php

示例14: ReturnShowKeyColor

function ReturnShowKeyColor($img)
{
    global $public_r;
    //背景色
    if ($public_r['keybgcolor']) {
        $bgcr = ToReturnRGB($public_r['keybgcolor']);
        $r['bgcolor'] = imagecolorallocate($img, $bgcr[0], $bgcr[1], $bgcr[2]);
    } else {
        $r['bgcolor'] = imagecolorallocate($img, 102, 102, 102);
    }
    //文字色
    if ($public_r['keyfontcolor']) {
        $fcr = ToReturnRGB($public_r['keyfontcolor']);
        $r['fontcolor'] = ImageColorAllocate($img, $fcr[0], $fcr[1], $fcr[2]);
    } else {
        $r['fontcolor'] = ImageColorAllocate($img, 255, 255, 255);
    }
    //干扰色
    if ($public_r['keydistcolor']) {
        $dcr = ToReturnRGB($public_r['keydistcolor']);
        $r['distcolor'] = ImageColorAllocate($img, $dcr[0], $dcr[1], $dcr[2]);
    } else {
        $r['distcolor'] = ImageColorAllocate($img, 71, 71, 71);
    }
    return $r;
}
开发者ID:novnan,项目名称:meiju,代码行数:26,代码来源:index.php

示例15: change_grey

 /**
  * 图像二值化
  *
  * @param number $grey
  */
 public function change_grey($grey = 100)
 {
     for ($y = 0; $y < $this->ih; ++$y) {
         for ($x = 0; $x < $this->iw; ++$x) {
             $rgb = imagecolorat($this->image, $x, $y);
             if (($rgb >> 16 & 0xff) > $grey) {
                 $red = 255;
             } else {
                 $red = 0;
             }
             if (($rgb >> 8 & 0xff) > $grey) {
                 $green = 255;
             } else {
                 $green = 0;
             }
             if (($rgb & 0xff) > $grey) {
                 $blue = 255;
             } else {
                 $blue = 0;
             }
             imagesetpixel($this->image, $x, $y, ImageColorAllocate($this->image, $red, $green, $blue));
         }
     }
     $this->fingerprint();
     $this->filter_info();
     $this->dealwith_data();
 }
开发者ID:hubs,项目名称:yuncms,代码行数:32,代码来源:ImageFilter.php


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