本文整理汇总了PHP中imagesetpixel函数的典型用法代码示例。如果您正苦于以下问题:PHP imagesetpixel函数的具体用法?PHP imagesetpixel怎么用?PHP imagesetpixel使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了imagesetpixel函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: create_captcha
/**
* +----------------------------------------------------------
* 图片上传的处理函数
* +----------------------------------------------------------
*/
function create_captcha()
{
$word = $this->create_word();
// 把验证码字符串写入session
$_SESSION['captcha'] = md5($word . DOU_SHELL);
// 绘制基本框架
$im = imagecreatetruecolor($this->captcha_width, $this->captcha_height);
$bg_color = imagecolorallocate($im, 235, 236, 237);
imagefilledrectangle($im, 0, 0, $this->captcha_width, $this->captcha_height, $bg_color);
$border_color = imagecolorallocate($im, 118, 151, 199);
imagerectangle($im, 0, 0, $this->captcha_width - 1, $this->captcha_height - 1, $border_color);
// 添加干扰
for ($i = 0; $i < 5; $i++) {
$rand_color = imagecolorallocate($im, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
imagearc($im, mt_rand(-$this->captcha_width, $this->captcha_width), mt_rand(-$this->captcha_height, $this->captcha_height), mt_rand(30, $this->captcha_width * 2), mt_rand(20, $this->captcha_height * 2), mt_rand(0, 360), mt_rand(0, 360), $rand_color);
}
for ($i = 0; $i < 50; $i++) {
$rand_color = imagecolorallocate($im, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
imagesetpixel($im, mt_rand(0, $this->captcha_width), mt_rand(0, $this->captcha_height), $rand_color);
}
// 生成验证码图片
$text_color = imagecolorallocate($im, mt_rand(0, 200), mt_rand(0, 120), mt_rand(0, 120));
imagestring($im, 6, 18, 5, $word, $text_color);
// header
header("Cache-Control: max-age=1, s-maxage=1, no-cache, must-revalidate");
header("Content-type: image/png;charset=utf-8");
/* 绘图结束 */
imagepng($im);
imagedestroy($im);
return true;
}
开发者ID:phphonor,项目名称:companycms,代码行数:36,代码来源:captcha.class.php
示例2: create
public static function create()
{
$image = imagecreatetruecolor(100, 40) or die('cannot create canvas.<br>');
$red = imagecolorallocate($image, 255, 0, 0);
$green = imagecolorallocate($image, 0, 255, 0);
$blue = imagecolorallocate($image, 0, 0, 255);
$white = imagecolorallocate($image, 255, 255, 255);
$black = imagecolorallocate($image, 0, 0, 0);
imagefill($image, 0, 0, $white);
imagerectangle($image, 1, 1, 99, 39, $black);
$color = [$red, $green, $blue];
for ($i = 1; $i <= 100; $i++) {
imagesetpixel($image, mt_rand(2, 98), mt_rand(2, 38), $color[mt_rand(0, 2)]);
}
$source = "abcdefghigklmnopqrstuvwxyz0123456789ABCDEFGHIGKLMNOPQRSTUVWXYZ";
$first = $source[mt_rand(0, 61)];
$second = $source[mt_rand(0, 61)];
$third = $source[mt_rand(0, 61)];
$fourth = $source[mt_rand(0, 61)];
$_SESSION['captcha'] = $first . $second . $third . $fourth;
$font = dirname(dirname(__DIR__)) . '/../public/assets/fonts/SpicyRice.ttf';
imagettftext($image, 20, mt_rand(-20, 20), 10, 30, $blue, $font, $first);
imagettftext($image, 20, mt_rand(-20, 20), 30, 30, $blue, $font, $second);
imagettftext($image, 20, mt_rand(-20, 20), 50, 30, $blue, $font, $third);
imagettftext($image, 20, mt_rand(-20, 20), 70, 30, $blue, $font, $fourth);
return imagejpeg($image);
}
开发者ID:marious,项目名称:talkingspace_forum,代码行数:27,代码来源:Captcha.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: 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
示例5: ImageHue
public static function ImageHue(&$image, $hue, $saturation)
{
$width = imagesx($image);
$height = imagesy($image);
for ($x = 0; $x < $width; $x++) {
for ($y = 0; $y < $height; $y++) {
$rgb = imagecolorat($image, $x, $y);
$r = $rgb >> 16 & 0xff;
$g = $rgb >> 8 & 0xff;
$b = $rgb & 0xff;
$alpha = ($rgb & 0x7f000000) >> 24;
$hsl = ColorUtils::rgb2hsl(array('r' => $r, 'g' => $g, 'b' => $b));
$h = $hsl['h'] / 360;
$s = $hsl['s'] / 100;
$h += $hue / 360;
$s += $saturation / 100;
if ($h > 1) {
$h--;
}
if ($s > 1) {
$s--;
}
$hsl['h'] = $h * 360;
$hsl['s'] = $s * 100;
$rgb = ColorUtils::hsl2rgb($hsl);
imagesetpixel($image, $x, $y, imagecolorallocatealpha($image, $rgb['r'], $rgb['g'], $rgb['b'], $alpha));
}
}
}
开发者ID:rsids,项目名称:bright_api,代码行数:29,代码来源:ImageUtils.php
示例6: execute
function execute()
{
$gdimage =& $this->image->getImage();
$w = $this->image->getWidth();
$h = $this->image->getHeight();
$src_x = ceil($w);
$src_y = ceil($h);
$dst_x = $src_x;
$dst_y = $src_y;
// http://php.about.com/od/gdlibrary/ss/grayscale_gd.htm
function yiq($r, $g, $b)
{
return $r * 0.299 + $g * 0.587 + $b * 0.114;
}
$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 = yiq($r, $g, $b);
imagesetpixel($dst_im, $x, $y, $palette[$gs]);
}
}
$gdimage = $dst_im;
}
开发者ID:BackupTheBerlios,项目名称:redaxo-svn,代码行数:31,代码来源:class.rex_effect_filter_greyscale.inc.php
示例7: SetDisturbColor
/**
*
* @brief 设置图片的干扰像素
*
*/
private function SetDisturbColor()
{
for ($i = 0; $i <= 128; $i++) {
$this->mDisturbColor = imagecolorallocate($this->mCheckImage, rand(0, 255), rand(0, 255), rand(0, 255));
imagesetpixel($this->mCheckImage, rand(2, 128), rand(2, 38), $this->mDisturbColor);
}
}
开发者ID:BGCX261,项目名称:zhwphp-svn-to-git,代码行数:12,代码来源:CheckCodeFile.class.php
示例8: getCaptcha
/**
* 生成验证码
* @param int $width 验证码图片宽度.默认130
* @param int $height 验证码图片高度.默认40
* @param int $fontSize 验证码字体大小.默认20
* @param int $length 验证码字符个数.默认4
* @return string 验证码中的字符串
*/
public static function getCaptcha($width = '130', $height = '40', $fontSize = '20', $length = '4')
{
$chars = '0123456789abcdefghijklmnopqrstuvwxyz';
$randStr = substr(str_shuffle($chars), 0, $length);
$image = imagecreatetruecolor($width, $height);
// 定义背景色
$bgColor = imagecolorallocate($image, 0xff, 0xff, 0xff);
// 定义文字及边框颜色
$blackColor = imagecolorallocate($image, 0x0, 0x0, 0x0);
//生成矩形边框
imagefilledrectangle($image, 0, 0, $width, $height, $bgColor);
// 循环生成雪花点
for ($i = 0; $i < 200; $i++) {
$grayColor = imagecolorallocate($image, 128 + rand(0, 128), 128 + rand(0, 128), 128 + rand(0, 128));
imagesetpixel($image, rand(1, $width - 2), rand(4, $height - 2), $grayColor);
}
$font = ROOT_PATH . 'resources/fonts/acidic.ttf';
// 把随机字符串输入图片
$i = -1;
while (isset($randStr[++$i])) {
$fontColor = imagecolorallocate($image, rand(0, 100), rand(0, 100), rand(0, 100));
if (!function_exists('imagettftext')) {
imagechar($image, $fontSize, 15 + $i * 30, rand(5, 20), $randStr[$i], $fontColor);
} else {
imagettftext($image, $fontSize, 0, 10 + $i * 30, rand(25, 35), $fontColor, $font, $randStr[$i]);
}
}
imagepng($image);
$image = $bgColor = $blackColor = $grayColor = $fontColor = null;
return $randStr;
}
开发者ID:hellocc2,项目名称:crmht,代码行数:39,代码来源:Image.php
示例9: imagemergealpha
function imagemergealpha($i)
{
//create a new image
$s = imagecreatetruecolor(imagesx($i[0]), imagesy($i[1]));
$back_color = imagecolorallocate($s, 0xa9, 0xb1, 0xd3);
//merge all images
imagealphablending($s, true);
$z = $i;
while ($d = each($z)) {
imagecopy($s, $d[1], 0, 0, 0, 0, imagesx($d[1]), imagesy($d[1]));
}
//restore the transparency
imagealphablending($s, false);
$w = imagesx($s);
$h = imagesy($s);
for ($x = 0; $x < $w; $x++) {
for ($y = 0; $y < $h; $y++) {
$c = imagecolorat($s, $x, $y);
$c = imagecolorsforindex($s, $c);
$z = $i;
$t = 0;
while ($d = each($z)) {
$ta = imagecolorat($d[1], $x, $y);
$ta = imagecolorsforindex($d[1], $ta);
$t += 127 - $ta['alpha'];
}
$t = $t > 127 ? 127 : $t;
$t = 127 - $t;
$c = imagecolorallocatealpha($s, $c['red'], $c['green'], $c['blue'], $t);
imagesetpixel($s, $x, $y, $c);
}
}
imagesavealpha($s, true);
return $s;
}
开发者ID:relaismago,项目名称:outils,代码行数:35,代码来源:wanted.php
示例10: 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
示例11: 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
示例12: draw
/**
* draw point on map
*
* @param Map $map
*/
public function draw(Map $map)
{
$image = $map->getImage();
$color = $this->_getDrawColor($image);
$pointInPixels = $map->getPixelPointFromCoordinates($this->_coordinates['lon'], $this->_coordinates['lat']);
imagesetpixel($image, $pointInPixels['x'], $pointInPixels['y'], $color);
}
开发者ID:pafciu17,项目名称:gsoc-os-static-maps-api,代码行数:12,代码来源:Point.php
示例13: getVerify
public function getVerify()
{
//创建画布
$img = imagecreatetruecolor($this->config['width'], $this->config['height']);
//设置背景颜色
$bgColor = imagecolorallocate($img, 255, 255, 255);
imagefill($img, 0, 0, $bgColor);
$_x = ceil(($this->config['width'] - 20) / $this->config['lenght']);
$code = '';
//写入验证码
for ($i = 0; $i < $this->config['lenght']; $i++) {
$str = random();
$code .= $str;
$x = 10 + $i * $_x;
$fontSize = mt_rand($this->config['fontsize'] - 10, $this->config['fontsize']);
$fontH = imagefontheight($this->config['fontsize']);
$y = mt_rand($fontH + 10, $this->config['height'] - 5);
$fontColor = imagecolorallocate($img, mt_rand(0, 200), mt_rand(0, 200), mt_rand(0, 200));
imagettftext($img, $fontSize, 0, $x, $y, $fontColor, $this->config['fontfile'], $str);
}
//增加干扰点
for ($i = 0; $i < $this->config['point']; $i++) {
$pointColor = imagecolorallocate($img, rand(150, 200), rand(150, 200), rand(100, 200));
imagesetpixel($img, mt_rand(1, $this->config['width']), mt_rand(1, $this->config['height']), $pointColor);
}
//增加线干扰
for ($i = 0; $i < $this->config['line']; $i++) {
$linColor = imagecolorallocate($img, rand(0, 200), rand(0, 200), rand(0, 200));
imageline($img, rand(0, $this->config['width']), rand(0, $this->config['height']), rand(0, $this->config['width']), rand(0, $this->config['height']), $linColor);
}
$_SESSION['Verify'] = md5(strtoupper($code));
header('Content-type: image/png');
imagepng($img);
imagedestroy($img);
}
开发者ID:lxpfigo,项目名称:blog,代码行数:35,代码来源:Verify.class.php
示例14: getCode
function getCode($w, $h)
{
$im = imagecreate($w, $h);
//imagecolorallocate($im, 14, 114, 180); // background color
$red = imagecolorallocate($im, 255, 0, 0);
$white = imagecolorallocate($im, 255, 255, 255);
$num1 = rand(1, 20);
$num2 = rand(1, 20);
$_SESSION['helloweba_math'] = $num1 + $num2;
$gray = imagecolorallocate($im, 118, 151, 199);
$black = imagecolorallocate($im, mt_rand(0, 100), mt_rand(0, 100), mt_rand(0, 100));
//画背景
imagefilledrectangle($im, 0, 0, 100, 24, $black);
//在画布上随机生成大量点,起干扰作用;
for ($i = 0; $i < 80; $i++) {
imagesetpixel($im, rand(0, $w), rand(0, $h), $gray);
}
imagestring($im, 5, 5, 4, $num1, $red);
imagestring($im, 5, 30, 3, "+", $red);
imagestring($im, 5, 45, 4, $num2, $red);
imagestring($im, 5, 70, 3, "=", $red);
imagestring($im, 5, 80, 2, "?", $white);
header("Content-type: image/png");
imagepng($im);
imagedestroy($im);
}
开发者ID:CodingJason,项目名称:totemvision,代码行数:26,代码来源:code_math.php
示例15: 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
示例16: getAuthImage
function getAuthImage($text)
{
$this->setpin($text);
$im_x = 160;
$im_y = 40;
$im = imagecreatetruecolor($im_x, $im_y);
$text_c = ImageColorAllocate($im, mt_rand(0, 100), mt_rand(0, 100), mt_rand(0, 100));
$tmpC0 = mt_rand(100, 255);
$tmpC1 = mt_rand(100, 255);
$tmpC2 = mt_rand(100, 255);
$buttum_c = ImageColorAllocate($im, $tmpC0, $tmpC1, $tmpC2);
imagefill($im, 16, 13, $buttum_c);
$font = PATH_SYS_PUBLIC . 'font-awesome/fonts/verdana.ttf';
for ($i = 0; $i < strlen($text); $i++) {
$tmp = substr($text, $i, 1);
$array = array(-1, 1);
$p = array_rand($array);
$an = $array[$p] * mt_rand(1, 10);
//角度
$size = 28;
imagettftext($im, $size, $an, 15 + $i * $size, 35, $text_c, $font, $tmp);
}
$distortion_im = imagecreatetruecolor($im_x, $im_y);
imagefill($distortion_im, 16, 13, $buttum_c);
for ($i = 0; $i < $im_x; $i++) {
for ($j = 0; $j < $im_y; $j++) {
$rgb = imagecolorat($im, $i, $j);
if ((int) ($i + 20 + sin($j / $im_y * 2 * M_PI) * 10) <= imagesx($distortion_im) && (int) ($i + 20 + sin($j / $im_y * 2 * M_PI) * 10) >= 0) {
imagesetpixel($distortion_im, (int) ($i + 10 + sin($j / $im_y * 2 * M_PI - M_PI * 0.1) * 4), $j, $rgb);
}
}
}
//加入干扰象素;
$count = 160;
//干扰像素的数量
for ($i = 0; $i < $count; $i++) {
$randcolor = ImageColorallocate($distortion_im, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
imagesetpixel($distortion_im, mt_rand() % $im_x, mt_rand() % $im_y, $randcolor);
}
$rand = mt_rand(5, 30);
$rand1 = mt_rand(15, 25);
$rand2 = mt_rand(5, 10);
for ($yy = $rand; $yy <= +$rand + 2; $yy++) {
for ($px = -80; $px <= 80; $px = $px + 0.1) {
$x = $px / $rand1;
if ($x != 0) {
$y = sin($x);
}
$py = $y * $rand2;
imagesetpixel($distortion_im, $px + 80, $py + $yy, $text_c);
}
}
//设置文件头;
Header("Content-type: image/JPEG");
//以PNG格式将图像输出到浏览器或文件;
ImagePNG($distortion_im);
//销毁一图像,释放与image关联的内存;
ImageDestroy($distortion_im);
ImageDestroy($im);
}
开发者ID:nanfs,项目名称:lt,代码行数:60,代码来源:pin.class.php
示例17: index
public function index()
{
header("content-type:image/gif");
$this->load->library('session');
$width = 60;
$height = 30;
$img = imagecreatetruecolor($width, $height);
$white = imagecolorallocate($img, 255, 255, 255);
$color = imagecolorallocate($img, rand(0, 255), rand(0, 255), rand(0, 255));
$str = "123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
$code = "";
for ($i = 0; $i < 5; $i++) {
$code .= $str[rand(0, strlen($str) - 1)];
}
$this->session->set_userdata(array('myCode' => strtolower($code)));
imagefilledrectangle($img, 0, 0, 60, 30, $color);
for ($i = 0; $i < 100; $i++) {
imagesetpixel($img, rand(0, 60), rand(0, 30), imagecolorallocate($img, rand(0, 255), rand(0, 255), rand(0, 255)));
}
for ($i = 0; $i < 10; $i++) {
imageline($img, rand(0, 60), rand(0, 30), rand(0, 60), rand(0, 30), imagecolorallocate($img, rand(0, 255), rand(0, 255), rand(0, 255)));
}
imagestring($img, 5, 10, 5, $code, $white);
return imagegif($img);
//imagedestroy($img);
}
开发者ID:804485808,项目名称:local_motors,代码行数:26,代码来源:imgcode.php
示例18: draw_dots
private function draw_dots()
{
$pixel_color = imagecolorallocate($this->image, rand(0, 255), rand(0, 255), rand(0, 255));
for ($i = 0; $i < $this->dots_no; $i++) {
imagesetpixel($this->image, rand(0, $this->width), rand(0, $this->height), $pixel_color);
}
}
开发者ID:code-fury,项目名称:laravel-captcha,代码行数:7,代码来源:CaptchaGenerator.php
示例19: applyFilter
/**
* Applies the sepia filter to an image resource
*
* @param ImageResource $aResource
*/
public function applyFilter(ImageResource $aResource)
{
if ($this->degrees === 0) {
return;
}
$width = $aResource->getX();
$height = $aResource->getY();
// cache calculated colors in a map...
$colorMap = array();
for ($x = 0; $x < $width; ++$x) {
for ($y = 0; $y < $height; ++$y) {
$color = ColorUtil::getColorAt($aResource, Coordinate::create($x, $y));
if (!isset($colorMap[$color->getColorIndex()])) {
// calculate the new color
$hsl = ColorUtil::rgb2hsl($color->getRed(), $color->getGreen(), $color->getBlue());
$hsl[0] += $this->degrees;
$rgb = ColorUtil::hsl2rgb($hsl[0], $hsl[1], $hsl[2]);
$newcol = imagecolorallocate($aResource->getResource(), $rgb[0], $rgb[1], $rgb[2]);
$colorMap[$color->getColorIndex()] = $newcol;
} else {
$newcol = $colorMap[$color->getColorIndex()];
}
imagesetpixel($aResource->getResource(), $x, $y, $newcol);
}
}
$colorMap = null;
}
开发者ID:elgervb,项目名称:imagemanipulation,代码行数:32,代码来源:ImageFilterHueRotate.php
示例20: show
public function show()
{
$captchaText = strtoupper(substr(md5(microtime()), 0, 7));
$this->Session->write('captcha', $captchaText);
$image = imagecreate(190, 70);
$background = imagecolorallocate($image, 255, 255, 255);
$textColor = imagecolorallocatealpha($image, 0, 0, 0, 1);
$x = 5;
$y = 50;
for ($i = 0; $i < 3000; $i++) {
$fontSize = mt_rand(15, 28);
$text = substr($captchaText, $i, 1);
imagettftext($image, $fontSize, 0, $x, $y, $textColor, './impact.ttf', $text);
$x = $x + 17 + mt_rand(0, 10);
$y = mt_rand(40, 65);
imagesetpixel($image, rand() % 235, rand() % 85, 3000000);
}
$line_color = imagecolorallocate($image, 4, rand() % 110, rand() % 220);
for ($i = 0; $i < 10; $i++) {
imageline($image, 0, rand() % 50, 200, rand() % 120, $line_color);
}
header("Content-type: application/jpeg");
return imagejpeg($image);
imagedestroy($image);
}
开发者ID:mehdi-fathi,项目名称:Captcha-Component,代码行数:25,代码来源:CaptchaComponent.php
注:本文中的imagesetpixel函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论