本文整理汇总了PHP中imageColorAllocate函数的典型用法代码示例。如果您正苦于以下问题:PHP imageColorAllocate函数的具体用法?PHP imageColorAllocate怎么用?PHP imageColorAllocate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了imageColorAllocate函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: getCreateImage
private function getCreateImage()
{
$this->image = imageCreate($this->width, $this->height);
$back = imageColorAllocate($this->image, 255, 255, 255);
$border = imagecolorallocate($this->image, 0, 0, 0);
imageRectangle($this->image, 0, 0, $this->width - 1, $this->height - 1, $border);
}
开发者ID:laiello,项目名称:ffphp,代码行数:7,代码来源:verify.class.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:kktsvetkov,项目名称:asido,代码行数:34,代码来源:class.driver.gd_hack.php
示例3: 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
示例4: createImage
public function createImage($text = '', $fontSize = 5)
{
// GD's built-in fonts are numbered from 1 - 5
$font_size = $fontSize;
// Calculate the appropriate image size
$image_height = intval(imageFontHeight($font_size) * 2);
$image_width = intval(strlen($text) * imageFontWidth($font_size) * 1.3);
// Create the image
$image = imageCreate($image_width, $image_height);
// Create the colors to use in the image
// gray background
$back_color = imageColorAllocate($image, 216, 216, 216);
// blue text
$text_color = imageColorAllocate($image, 0, 0, 255);
// black border
$rect_color = imageColorAllocate($image, 0, 0, 0);
// Figure out where to draw the text
// (Centered horizontally and vertically
$x = ($image_width - imageFontWidth($font_size) * strlen($text)) / 2;
$y = ($image_height - imageFontHeight($font_size)) / 2;
// Draw the text
imageString($image, $font_size, $x, $y, $text, $text_color);
// Draw a black border
imageRectangle($image, 0, 0, imageSX($image) - 1, imageSY($image) - 1, $rect_color);
// Send the image to the browser
header('Content-Type: image/png');
imagePNG($image);
imageDestroy($image);
}
开发者ID:puncoz,项目名称:presentation,代码行数:29,代码来源:images.php
示例5: create
/**
* 显示验证码
*/
function create()
{
$this->image = imageCreate($this->width, $this->height);
$this->back = $this->getColor($this->bgcolor);
imageFilledRectangle($this->image, 0, 0, $this->width, $this->height, $this->back);
$size = $this->width / $this->charLen - 4;
if ($size > $this->height) {
$size = $this->height;
}
$left = ($this->width - $this->charLen * ($size + $size / 10)) / $size + 5;
$code = '';
for ($i = 0; $i < $this->charLen; $i++) {
$randKey = rand(0, count($this->arrChr) - 1);
$randText = $this->arrChr[$randKey];
$code .= $randText;
$textColor = imageColorAllocate($this->image, rand(0, 100), rand(0, 100), rand(0, 100));
$font = $this->fontPath . '/' . rand(1, 5) . ".ttf";
$randsize = rand($size - $size / 10, $size + $size / 10);
$location = $left + ($i * $size + $size / 10);
@imagettftext($this->image, $randsize, rand(-18, 18), $location, rand($size - $size / 10, $size + $size / 10) + 2, $textColor, $font, $randText);
}
if ($this->showNoisePix == true) {
$this->setNoisePix();
}
if ($this->showNoiseLine == true) {
$this->setNoiseLine();
}
if ($this->showBorder == true) {
$this->borderColor = $this->getColor($this->borderColor);
imageRectangle($this->image, 0, 0, $this->width - 1, $this->height - 1, $this->borderColor);
}
$this->text = strtolower($code);
}
开发者ID:beyondye,项目名称:ENPHP,代码行数:36,代码来源:authcode.php
示例6: createAICode
function createAICode()
{
global $bBlog;
$code = $this->randomString();
$bBlog->db->query("\n\tDELETE FROM `" . T_CHECKCODE . "` WHERE `timestamp`+3000<NOW()");
$bBlog->db->query("\n\tINSERT INTO `" . T_CHECKCODE . "` ( `id` , `checksum` , `timestamp` )\n\tVALUES ('', '" . md5($code . $_SERVER["REMOTE_ADDR"]) . "', NOW( ))");
if (!isset($plugins_dir)) {
$plugins_dir = dirname(__FILE__) . '/';
}
$fontfile = "atomicclockradio.ttf";
$font = $plugins_dir . $fontfile;
$im = @imageCreate(110, 50) or die("Cannot Initialize new GD image stream");
$background_color = imageColorAllocate($im, 195, 217, 255);
$text_color = imageColorAllocate($im, 168, 18, 19);
ImageTTFText($im, 20, 5, 18, 38, $text_color, $font, $code);
// Date in the past
header("Expires: Thu, 28 Aug 1997 05:00:00 GMT");
// always modified
$timestamp = gmdate("D, d M Y H:i:s");
header("Last-Modified: " . $timestamp . " GMT");
// HTTP/1.1
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
// HTTP/1.0
header("Pragma: no-cache");
// dump out the image
header("Content-type: image/png");
ImagePNG($im);
}
开发者ID:BackupTheBerlios,项目名称:bblog-svn,代码行数:29,代码来源:authimage.class.php
示例7: Graph
function Graph($res)
{
if ($res == "svga") {
$wd = "800";
$ht = "600";
} elseif ($res == "xga") {
$wd = "1024";
$ht = "768";
} elseif ($res == "sxga") {
$wd = "1280";
$ht = "1024";
} elseif ($res == "uxga") {
$wd = "1600";
$ht = "1200";
} else {
$wd = "640";
$ht = "480";
}
$this->img = imageCreate($wd, $ht);
$this->wte = imageColorAllocate($this->img, 255, 255, 255);
$this->blk = imageColorAllocate($this->img, 0, 0, 0);
$this->gry = imageColorAllocate($this->img, 100, 100, 100);
$this->red = imageColorAllocate($this->img, 150, 0, 0);
$this->grn = imageColorAllocate($this->img, 0, 150, 0);
$this->blu = imageColorAllocate($this->img, 0, 0, 150);
imagestring($this->img, 2, 5, 5, $res, $this->blu);
}
开发者ID:pl0o0f,项目名称:nedi-puppet,代码行数:27,代码来源:libgraph.php
示例8: 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
示例9: create
function create($text)
{
$img = imagecreatefrompng("skins/icon.png");
$black = imageColorAllocate($img, 0, 0, 0);
$white = imageColorAllocate($img, 255, 255, 255);
imageString($img, 5, 20, 3, $text, $white);
imagePNG($img);
}
开发者ID:Parashutik,项目名称:ReloadCMS,代码行数:8,代码来源:captcha.php
示例10: getCreateImage
private function getCreateImage()
{
//用来创建图像资源,并初使化背影
$this->image = imagecreatetruecolor($this->width, $this->height);
$backColor = imagecolorallocate($this->image, rand(225, 255), rand(225, 255), rand(225, 255));
//背景色(随机)
@imagefill($this->image, 0, 0, $backColor);
$border = imageColorAllocate($this->image, 0, 0, 0);
imageRectangle($this->image, 0, 0, $this->width - 1, $this->height - 1, $border);
}
开发者ID:mikelkl,项目名称:online_exam,代码行数:10,代码来源:vcode.class.php
示例11: code
function code()
{
$fontSize = 20;
//定义字体大小
$length = 5;
//定义字符串长度
$strNum = GetVerify($length);
//获取一个随机字符串
$_SESSION['verify'] = $strNum;
//付值给session
$width = 90;
//定义图片宽度
$height = 30;
//定义图片高度
$im = imagecreate($width, $height);
//生成一张指定宽高的图片
$backgroundcolor = imagecolorallocate($im, 255, 255, 255);
//生成背景色
$frameColor = imageColorAllocate($im, 150, 150, 150);
//生成边框色
$font = './system/fonts/arial.ttf';
//提取字体文件,开始写字
for ($i = 0; $i < $length; $i++) {
$charY = ($height + 9) / 2 + rand(-1, 1);
//定义字符Y坐标
$charX = $i * 15 + 8;
//定义字符X坐标
//生成字符颜色
$text_color = imagecolorallocate($im, mt_rand(50, 200), mt_rand(50, 128), mt_rand(50, 200));
$angle = rand(-20, 20);
//生成字符角度
//写入字符
imageTTFText($im, $fontSize, $angle, $charX, $charY, $text_color, $font, $strNum[$i]);
}
for ($i = 0; $i <= 5; $i++) {
//循环画背景线
$linecolor = imagecolorallocate($im, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
$linex = mt_rand(1, $width - 1);
$liney = mt_rand(1, $height - 1);
imageline($im, $linex, $liney, $linex + mt_rand(0, 4) - 2, $liney + mt_rand(0, 4) - 2, $linecolor);
}
for ($i = 0; $i <= 32; $i++) {
//循环画背景点,生成麻点效果
$pointcolor = imagecolorallocate($im, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
imagesetpixel($im, mt_rand(1, $width - 1), mt_rand(1, $height - 1), $pointcolor);
}
imagerectangle($im, 0, 0, $width - 1, $height - 1, $frameColor);
//画边框
//ob_clean();
//header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
return $strNum;
}
开发者ID:wcgh,项目名称:shixian,代码行数:54,代码来源:captcha_helper.php
示例12: GenColors
function GenColors()
{
$colorR = rand(100, 230);
$colorG = rand(100, 230);
$colorB = rand(100, 230);
$colorG2 = (rand(100, 230) + $colorG) / 2;
$colorB2 = (rand(100, 230) + $colorB) / 2;
$this->colorBg = imageColorAllocate($this->img, $colorR, $colorG, $colorB);
$this->colorTxt[0] = imageColorAllocate($this->img, $colorR - 80, $colorG2 - 70, $colorB - 80);
$this->colorTxt[1] = imageColorAllocate($this->img, $colorR - 70, $colorG - 80, $colorB2 - 70);
$this->colorLine = imageColorAllocate($this->img, $colorR - 10, $colorG2 - 20, $colorB2 - 10);
}
开发者ID:askovorodka,项目名称:sqc,代码行数:12,代码来源:captcha.class.php
示例13: color
protected function color(array $color, $image = false)
{
if (!is_array($image)) {
$image = $this->map;
}
list($r, $g, $b) = $color;
$colorRes = imagecolorexact($image['image'], $r, $g, $b);
if ($colorRes == -1) {
$colorRes = imageColorAllocate($image['image'], $r, $g, $b);
}
return $colorRes;
}
开发者ID:Yoyoyozo,项目名称:webDiplomacy,代码行数:12,代码来源:drawMap.php
示例14: text2image
function text2image($height, $text)
{
header("Content-type: image/png");
$width = $height * strlen($text)/ 5 * 2;
$font = "/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf";
$image = imageCreate($width, $height);
$backgroundColor = imageColorAllocate($image, 255, 255, 255);
$textColor = imageColorAllocate($image, 0, 0, 0);
imagefttext($image, $height/2, 0, 0, $height/10*9, $textColor, $font, $text);
imageInterlace($image, 1);
imageColorTransparent($image, $backgroundColor);
imagePNG($image);
}
开发者ID:pier22,项目名称:Band-Page-FB,代码行数:13,代码来源:text2image.php
示例15: execute
public function execute()
{
$cachePath = SJB_BASE_DIR . "system/cache/markers";
if (SJB_Request::isAjax()) {
$fileSystem = new SJB_Filesystem();
$markers = $fileSystem->getFileNames($cachePath);
$response = count($markers) ? json_encode($markers) : '';
exit($response);
}
$grayImage = SJB_BASE_DIR . "templates/_system/main/images/marker_gray.gif";
$greenImage = SJB_BASE_DIR . "templates/_system/main/images/marker_green.gif";
$orangeImage = SJB_BASE_DIR . "templates/_system/main/images/marker_orange.gif";
$blueImage = SJB_BASE_DIR . "templates/_system/main/images/marker_blue.gif";
$pinkImage = SJB_BASE_DIR . "templates/_system/main/images/marker_pink.gif";
$type = SJB_Request::getVar('type', 'Job');
$text = SJB_Request::getVar('text', '');
$filename = '';
$assets = array('Job' => $orangeImage, 'priority' => $orangeImage, 'indeed' => $blueImage, 'simplyHired' => $greenImage, 'beyond' => $grayImage, 'Resume' => $orangeImage);
if (array_key_exists($type, $assets)) {
$filename = $assets[$type];
} else {
$filename = $grayImage;
}
$cacheFilename = $cachePath . "/marker_" . $type . '_' . $text . ".gif";
$img = null;
if (!file_exists($cacheFilename)) {
if ($filename == $pinkImage || !empty($text) && is_string($text) && !empty($filename)) {
$img = imagecreatefromgif($filename);
$imageSx = imagesx($img);
$imageSy = imagesy($img);
$fontSize = 8;
$textLen = strlen($text);
$black = imageColorAllocate($img, 0, 0, 0);
$white = imageColorAllocate($img, 255, 255, 255);
if (!empty($text)) {
imagettftext($img, $fontSize, 0, $imageSx / 2 - floor($fontSize / 2 * $textLen) + 2, 13, $black, SJB_BASE_DIR . "templates/_system/main/images/arial.ttf", $text);
}
if (!file_exists($cachePath)) {
mkdir($cachePath, 0777);
}
imagegif($img, $cachePath . "/marker_" . $type . '_' . $text . ".gif");
}
} else {
$img = imagecreatefromgif($cacheFilename);
}
if (!is_null($img)) {
header("Content-type: image/gif");
imagegif($img);
}
exit;
}
开发者ID:Maxlander,项目名称:shixi,代码行数:51,代码来源:get_image_marker.php
示例16: mainColor
function mainColor($image)
{
$i = 0;
for ($x = 0; $x < imagesx($image); $x++) {
for ($y = 0; $y < imagesy($image); $y++) {
$rgb = ImageColorAt($image, $x, $y);
$r += $rgb >> 16 & 0xff;
$g += $rgb >> 8 & 0xff;
$b += $rgb & 0xff;
$i++;
}
}
return imageColorAllocate($image, $r / $i, $g / $i, $b / $i);
}
开发者ID:BackupTheBerlios,项目名称:ascore,代码行数:14,代码来源:lib_image.php
示例17: 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
示例18: img
function img($text)
{
$img_height = 50;
$img_width = 18;
$img = imagecreate($img_height, $img_width);
ImageColorAllocate($img, 255, 255, 255);
$black = ImageColorAllocate($img, 0, 0, 0);
for ($i = 0; $i < 10; $i++) {
ImageString($img, 1, mt_rand(1, $img_height), mt_rand(0, $img_width), "Q", imageColorAllocate($img, mt_rand(200, 255), mt_rand(200, 255), mt_rand(200, 255)));
}
ImageRectangle($img, 0, 0, $img_height - 1, $img_width - 1, $black);
//
Imagestring($img, 5, 5, 2, $text, imageColorAllocate($img, mt_rand(0, 100), mt_rand(0, 150), mt_rand(0, 200)));
Imagepng($img);
ImageDestroy($img);
}
开发者ID:jyyy410team,项目名称:hts,代码行数:16,代码来源:getcodes.php
示例19: _image
/**
* Make image
*
*/
protected function _image()
{
$this->_image = imagecreate($this->config['width'], $this->config['height']);
imageFilledRectangle($this->_image, 0, 0, $this->config['width'], $this->config['height'], $this->_color($this->config['bgColor']));
$seed = $this->_seed();
$fonts = $this->_fonts();
$_SESSION[$this->config['sessionValueKey']] = $seed;
$_SESSION[$this->config['sessionTtlKey']] = time() + $this->config['ttl'];
for ($i = 0; $i < $this->config['length']; $i++) {
$char = substr($seed, $i, 1);
$x = $this->config['padding'] + $i * ($this->config['size'] + $this->config['space']);
$y = mt_rand(0.7 * $this->config['height'], 0.9 * $this->config['height']);
$charColor = imageColorAllocate($this->_image, mt_rand(50, 155), mt_rand(50, 155), mt_rand(50, 155));
imagettftext($this->_image, $this->config['size'], mt_rand(-18, 18), $x, $y, $charColor, $fonts[$i], $char);
}
$this->_noise();
}
开发者ID:jianchengdu,项目名称:dangjia,代码行数:21,代码来源:Captcha.php
示例20: placeholder
/**
* Placeholder code adapted from dummyimage.com
*/
public static function placeholder($width, $height)
{
$file_format = 'gif';
$width = $width;
$height = $height;
$text_angle = 0;
$font = Load::getModulePath('media') . 'assets/mplus-1c-medium.ttf';
$img = imageCreate($width, $height);
$bg_color = imageColorAllocate($img, 196, 196, 196);
$fg_color = imageColorAllocate($img, 94, 94, 94);
$lines = 1;
$text = $width . 'x' . $height;
$fontsize = max(min($width / strlen($text) * 1.15, $height * 0.5), 5);
$textBox = self::_imagettfbbox_t($fontsize, $text_angle, $font, $text);
$textWidth = ceil(($textBox[4] - $textBox[1]) * 1.07);
$textHeight = ceil((abs($textBox[7]) + abs($textBox[1])) * 1);
$textX = ceil(($width - $textWidth) / 2);
$textY = ceil(($height - $textHeight) / 2 + $textHeight);
imageFilledRectangle($img, 0, 0, $width, $height, $bg_color);
imagettftext($img, $fontsize, $text_angle, $textX, $textY, $fg_color, $font, $text);
$offset = 60 * 60 * 24 * 14;
//14 Days
$ExpStr = "Expires: " . gmdate("D, d M Y H:i:s", time() + $offset) . " GMT";
header($ExpStr);
//Set a far future expire date. This keeps the image locally cached by the user for less hits to the server.
header('Cache-Control: max-age=120');
header("Last-Modified: " . gmdate("D, d M Y H:i:s", time() - $offset) . " GMT");
header('Content-type: image/' . $file_format);
//Set the header so the browser can interpret it as an image and not a bunch of weird text.
switch ($file_format) {
case 'gif':
imagegif($img);
break;
case 'png':
imagepng($img);
break;
case 'jpg':
imagejpeg($img);
break;
case 'jpeg':
imagejpeg($img);
break;
}
imageDestroy($img);
exit;
}
开发者ID:simudream,项目名称:caffeine,代码行数:49,代码来源:image.php
注:本文中的imageColorAllocate函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论