本文整理汇总了PHP中imagecolorallocate函数的典型用法代码示例。如果您正苦于以下问题:PHP imagecolorallocate函数的具体用法?PHP imagecolorallocate怎么用?PHP imagecolorallocate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了imagecolorallocate函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Génère l'avatar
*/
public function run()
{
//On créer l'image avec les dimentions données
$image = imagecreate($this->_size, $this->_size);
//On créer la couleur en fonction du hash de la chaine de caractères
$color = imagecolorallocate($image, hexdec(substr($this->_color, 0, 2)), hexdec(substr($this->_color, 2, 2)), hexdec(substr($this->_color, 4, 2)));
//on défini le fond de l'image (blanc)
$bg = imagecolorallocate($image, 255, 255, 255);
//nombre de blocs à placer dans l'image (taille de l'image/taille des blocs)
$c = $this->_size / $this->_blockSize;
for ($x = 0; $x < ceil($c / 2); $x++) {
for ($y = 0; $y < $c; $y++) {
// Si le nombre est pair $pixel vaut true sinon $pixel vaut false
$pixel = hexdec($this->_hash[(int) ($x * ceil($c / 2)) + $y]) % 2 == 0;
if ($pixel) {
$pixelColor = $color;
} else {
$pixelColor = $bg;
}
// On place chaque bloc de l'image
//imagefilledrectangle($image, $x*$this->_blockSize, $y*$this->_blockSize, ($x+1)*$this->_blockSize, ($y+1)*$this->_blockSize, $pixelColor);
//imagefilledrectangle($image, $this->_size-$x*$this->_blockSize, $y*$this->_blockSize, $this->_size-($x+1)*$this->_blockSize, ($y+1)*$this->_blockSize, $pixelColor);
imagefilledrectangle($image, $x * $this->_blockSize, $y * $this->_blockSize, ($x + 1) * $this->_blockSize, ($y + 1) * $this->_blockSize, $pixelColor);
imagefilledrectangle($image, $this->_size - $x * $this->_blockSize, $y * $this->_blockSize, $this->_size - ($x + 1) * $this->_blockSize, ($y + 1) * $this->_blockSize, $pixelColor);
}
}
ob_start();
imagepng($image);
//on place l'image en mémoire
$this->_image = ob_get_contents();
ob_clean();
}
开发者ID:JulienCoutault,项目名称:Web,代码行数:35,代码来源:RandomAvatar.php
示例2: getAvatar
public function getAvatar($string, $widthHeight = 12, $theme = 'default')
{
$widthHeight = max($widthHeight, 12);
$md5 = md5($string);
$fileName = _TMP_DIR_ . '/' . $md5 . '.png';
if ($this->tmpFileExists($fileName)) {
return $fileName;
}
// Create seed.
$seed = intval(substr($md5, 0, 6), 16);
mt_srand($seed);
$body = array('legs' => mt_rand(0, count($this->availableParts[$theme]['legs']) - 1), 'hair' => mt_rand(0, count($this->availableParts[$theme]['hair']) - 1), 'arms' => mt_rand(0, count($this->availableParts[$theme]['arms']) - 1), 'body' => mt_rand(0, count($this->availableParts[$theme]['body']) - 1), 'eyes' => mt_rand(0, count($this->availableParts[$theme]['eyes']) - 1), 'mouth' => mt_rand(0, count($this->availableParts[$theme]['mouth']) - 1));
// Avatar random parts.
$parts = array('legs' => $this->availableParts[$theme]['legs'][$body['legs']], 'hair' => $this->availableParts[$theme]['hair'][$body['hair']], 'arms' => $this->availableParts[$theme]['arms'][$body['arms']], 'body' => $this->availableParts[$theme]['body'][$body['body']], 'eyes' => $this->availableParts[$theme]['eyes'][$body['eyes']], 'mouth' => $this->availableParts[$theme]['mouth'][$body['mouth']]);
$avatar = imagecreate($widthHeight, $widthHeight);
imagesavealpha($avatar, true);
imagealphablending($avatar, false);
$background = imagecolorallocate($avatar, 0, 0, 0);
$line_colour = imagecolorallocate($avatar, mt_rand(0, 200) + 55, mt_rand(0, 200) + 55, mt_rand(0, 200) + 55);
imagecolortransparent($avatar, $background);
imagefilledrectangle($avatar, 0, 0, $widthHeight, $widthHeight, $background);
// Fill avatar with random parts.
foreach ($parts as &$part) {
$this->drawPart($part, $avatar, $widthHeight, $line_colour, $background);
}
imagepng($avatar, $fileName);
imagecolordeallocate($avatar, $line_colour);
imagecolordeallocate($avatar, $background);
imagedestroy($avatar);
return $fileName;
}
开发者ID:recallfx,项目名称:monsterid.php,代码行数:31,代码来源:MonsterId.php
示例3: load
static function load($filename)
{
$info = getimagesize($filename);
list($width, $height) = $info;
if (!$width || !$height) {
return null;
}
$image = null;
switch ($info['mime']) {
case 'image/gif':
$image = imagecreatefromgif($filename);
break;
case 'image/jpeg':
$image = imagecreatefromjpeg($filename);
break;
case 'image/png':
$image = imagecreatetruecolor($width, $height);
$white = imagecolorallocate($image, 255, 255, 255);
imagefill($image, 0, 0, $white);
$png = imagecreatefrompng($filename);
imagealphablending($png, true);
imagesavealpha($png, true);
imagecopy($image, $png, 0, 0, 0, 0, $width, $height);
imagedestroy($png);
break;
}
if ($image) {
return new image($image, $width, $height);
} else {
return null;
}
}
开发者ID:nyan-cat,项目名称:easyweb,代码行数:32,代码来源:image.php
示例4: 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
示例5: hacknrollify
function hacknrollify($picfilename)
{
$logofilename = "logo.png";
$logoPicPath = "logopics/" . $logofilename;
$originalPicPath = "originalpics/" . $picfilename;
$editedfilename = "hnr_" . $picfilename;
$editedPicPath = "editedpics/" . $editedfilename;
// read the original image from file
$profilepic = imagecreatefromjpeg($originalPicPath);
$profilepicWidth = imagesx($profilepic);
$profilepicHeight = imagesy($profilepic);
// create the black image overlay
$blackoverlay = imagecreate($profilepicWidth, $profilepicHeight);
imagecolorallocate($blackoverlay, 0, 0, 0);
// then merge the black and profilepic
imagecopymerge($profilepic, $blackoverlay, 0, 0, 0, 0, $profilepicWidth, $profilepicHeight, 50);
imagedestroy($blackoverlay);
// merge the resized logo
$logo = resizeImage($logoPicPath, $profilepicWidth - 80, 999999);
imageAlphaBlending($logo, false);
imageSaveAlpha($logo, true);
$logoWidth = imagesx($logo);
$logoHeight = imagesy($logo);
$verticalOffset = $profilepicHeight / 2 - $logoHeight / 2;
$horizontalOffset = 40;
imagecopyresampled($profilepic, $logo, $horizontalOffset, $verticalOffset, 0, 0, $logoWidth, $logoHeight, $logoWidth, $logoHeight);
$mergeSuccess = imagejpeg($profilepic, $editedPicPath);
if (!$mergeSuccess) {
echo "Image merge failed!";
}
imagedestroy($profilepic);
imagedestroy($logo);
return $editedPicPath;
}
开发者ID:nicholaslum444,项目名称:HacknRollify,代码行数:34,代码来源:lib_hacknrollify.php
示例6: createImage
/**
* @param $text
* @return resource
*/
private function createImage($text)
{
if (!is_string($text) || trim($text) == '') {
$text = 'ERROR';
}
// Create an image from captchaBackground.png
$image = imagecreatefrompng(realpath('bundles/comun/images/captchaBackground.png'));
// Set the font colour
$colour = imagecolorallocate($image, 183, 178, 152);
// Set the font
//$font = '../fonts/Anorexia.ttf';
$font = realpath('bundles/comun/fonts/Anorexia.ttf');
// Set a random integer for the rotation between -15 and 15 degrees
$rotate = rand(-15, 15);
// Create an image using our original image and adding the detail
imagettftext($image, 14, $rotate, 18, 30, $colour, $font, $text);
// Output the image as a png
//imagepng($image);
/*return new Response(
$captchaText,
200,
array(
'Content-Type' => 'image/png',
'Cache-Control' => 'no-cache'
)
);*/
return $image;
}
开发者ID:jorgemunoz8807,项目名称:ociosos,代码行数:32,代码来源:Captcha.php
示例7: prepareRowAsPng
/**
* Adds to the PNG image object, the data related to a row in the GIS dataset.
*
* @param string $spatial GIS MULTILINESTRING object
* @param string $label Label for the GIS MULTILINESTRING object
* @param string $line_color Color for the GIS MULTILINESTRING object
* @param array $scale_data Array containing data related to scaling
* @param object $image Image object
*
* @return object the modified image object
* @access public
*/
public function prepareRowAsPng($spatial, $label, $line_color, $scale_data, $image)
{
// allocate colors
$black = imagecolorallocate($image, 0, 0, 0);
$red = hexdec(mb_substr($line_color, 1, 2));
$green = hexdec(mb_substr($line_color, 3, 2));
$blue = hexdec(mb_substr($line_color, 4, 2));
$color = imagecolorallocate($image, $red, $green, $blue);
// Trim to remove leading 'MULTILINESTRING((' and trailing '))'
$multilinestirng = mb_substr($spatial, 17, mb_strlen($spatial) - 19);
// Separate each linestring
$linestirngs = explode("),(", $multilinestirng);
$first_line = true;
foreach ($linestirngs as $linestring) {
$points_arr = $this->extractPoints($linestring, $scale_data);
foreach ($points_arr as $point) {
if (!isset($temp_point)) {
$temp_point = $point;
} else {
// draw line section
imageline($image, $temp_point[0], $temp_point[1], $point[0], $point[1], $color);
$temp_point = $point;
}
}
unset($temp_point);
// print label if applicable
if (isset($label) && trim($label) != '' && $first_line) {
imagestring($image, 1, $points_arr[1][0], $points_arr[1][1], trim($label), $black);
}
$first_line = false;
}
return $image;
}
开发者ID:flash1452,项目名称:phpmyadmin,代码行数:45,代码来源:GISMultilinestring.php
示例8: codeimage
static function codeimage()
{
$image = imagecreatetruecolor(100, 30);
$bgcolor = imagecolorallocate($image, 255, 255, 255);
imagefill($image, 0, 0, $bgcolor);
$code = '';
for ($i = 0; $i < 4; $i++) {
$fontsize = 6;
$fontcolor = imagecolorallocate($image, rand(0, 120), rand(0, 120), rand(0, 120));
$data = "abcdefghjkmnpqrstuvwxy3456789";
$fontcontent = substr($data, rand(1, strlen($data) - 1), 1);
$code .= $fontcontent;
$x = $i * 100 / 4 + rand(5, 10);
$y = rand(5, 10);
imagestring($image, $fontsize, $x, $y, $fontcontent, $fontcolor);
}
for ($i = 0; $i < 200; $i++) {
$pointcolor = imagecolorallocate($image, rand(50, 200), rand(50, 200), rand(50, 200));
imagesetpixel($image, rand(1, 99), rand(1, 29), $pointcolor);
}
for ($i = 0; $i < 2; $i++) {
$linecolor = imagecolorallocate($image, rand(80, 220), rand(80, 220), rand(80, 220));
imageline($image, rand(1, 99), rand(1, 29), rand(1, 99), rand(1, 29), $linecolor);
}
$return['code'] = $code;
$return['image'] = $image;
return $return;
// header('content-type:image/png');
// imagepng($image);
}
开发者ID:HivenKay,项目名称:ESalon,代码行数:30,代码来源:LfCodeimage.php
示例9: render
/**
* Outputs the Captcha image.
*
* @param boolean html output
* @return mixed
*/
public function render($html)
{
// Creates a black image to start from
$this->image_create(Captcha::$config['background']);
// Add random white/gray arcs, amount depends on complexity setting
$count = (Captcha::$config['width'] + Captcha::$config['height']) / 2;
$count = $count / 5 * min(10, Captcha::$config['complexity']);
for ($i = 0; $i < $count; $i++) {
imagesetthickness($this->image, mt_rand(1, 2));
$color = imagecolorallocatealpha($this->image, 255, 255, 255, mt_rand(0, 120));
imagearc($this->image, mt_rand(-Captcha::$config['width'], Captcha::$config['width']), mt_rand(-Captcha::$config['height'], Captcha::$config['height']), mt_rand(-Captcha::$config['width'], Captcha::$config['width']), mt_rand(-Captcha::$config['height'], Captcha::$config['height']), mt_rand(0, 360), mt_rand(0, 360), $color);
}
// Use different fonts if available
$font = Captcha::$config['fontpath'] . Captcha::$config['fonts'][array_rand(Captcha::$config['fonts'])];
// Draw the character's white shadows
$size = (int) min(Captcha::$config['height'] / 2, Captcha::$config['width'] * 0.8 / strlen($this->response));
$angle = mt_rand(-15 + strlen($this->response), 15 - strlen($this->response));
$x = mt_rand(1, Captcha::$config['width'] * 0.9 - $size * strlen($this->response));
$y = (Captcha::$config['height'] - $size) / 2 + $size;
$color = imagecolorallocate($this->image, 255, 255, 255);
imagefttext($this->image, $size, $angle, $x + 1, $y + 1, $color, $font, $this->response);
// Add more shadows for lower complexities
Captcha::$config['complexity'] < 10 and imagefttext($this->image, $size, $angle, $x - 1, $y - 1, $color, $font, $this->response);
Captcha::$config['complexity'] < 8 and imagefttext($this->image, $size, $angle, $x - 2, $y + 2, $color, $font, $this->response);
Captcha::$config['complexity'] < 6 and imagefttext($this->image, $size, $angle, $x + 2, $y - 2, $color, $font, $this->response);
Captcha::$config['complexity'] < 4 and imagefttext($this->image, $size, $angle, $x + 3, $y + 3, $color, $font, $this->response);
Captcha::$config['complexity'] < 2 and imagefttext($this->image, $size, $angle, $x - 3, $y - 3, $color, $font, $this->response);
// Finally draw the foreground characters
$color = imagecolorallocate($this->image, 0, 0, 0);
imagefttext($this->image, $size, $angle, $x, $y, $color, $font, $this->response);
// Output
return $this->image_render($html);
}
开发者ID:momoim,项目名称:momo-api,代码行数:39,代码来源:Black.php
示例10: resize
function resize($photo_src, $width, $name)
{
$parametr = getimagesize($photo_src);
list($width_orig, $height_orig) = getimagesize($photo_src);
$ratio_orig = $width_orig / $height_orig;
$new_width = $width;
$new_height = $width / $ratio_orig;
$newpic = imagecreatetruecolor($new_width, $new_height);
$col2 = imagecolorallocate($newpic, 255, 255, 255);
imagefilledrectangle($newpic, 0, 0, $new_width, $new_width, $col2);
switch ($parametr[2]) {
case 1:
$image = imagecreatefromgif($photo_src);
break;
case 2:
$image = imagecreatefromjpeg($photo_src);
break;
case 3:
$image = imagecreatefrompng($photo_src);
break;
}
imagecopyresampled($newpic, $image, 0, 0, 0, 0, $new_width, $new_height, $width_orig, $height_orig);
imagejpeg($newpic, $name, 100);
return true;
}
开发者ID:pioytazsko,项目名称:garantmarket,代码行数:25,代码来源:new_item.php
示例11: createMask
protected function createMask(sfImage $image, $w, $h)
{
// Create a mask png image of the area you want in the circle/ellipse (a 'magicpink' image with a black shape on it, with black set to the colour of alpha transparency) - $mask
$mask = $image->getAdapter()->getTransparentImage($w, $h);
// Set the masking colours
if (false === $this->getColor() || 'image/png' == $image->getMIMEType()) {
$mask_black = imagecolorallocate($mask, 0, 0, 0);
} else {
$mask_black = $image->getAdapter()->getColorByHex($mask, $this->getColor());
}
// Cannot use white as transparent mask if color is set to white
if ($this->getColor() === '#FFFFFF' || $this->getColor() === false) {
$mask_transparent = imagecolorallocate($mask, 255, 0, 0);
} else {
$mask_color = imagecolorsforindex($mask, imagecolorat($image->getAdapter()->getHolder(), 0, 0));
$mask_transparent = imagecolorallocate($mask, $mask_color['red'], $mask_color['green'], $mask_color['blue']);
}
imagecolortransparent($mask, $mask_transparent);
imagefill($mask, 0, 0, $mask_black);
// Draw the rounded rectangle for the mask
$this->imagefillroundedrect($mask, 0, 0, $w, $h, $this->getRadius(), $mask_transparent);
$mask_image = clone $image;
$mask_image->getAdapter()->setHolder($mask);
return $mask_image;
}
开发者ID:thefkboss,项目名称:ZenTracker,代码行数:25,代码来源:sfImageRoundedCornersGD.class.php
示例12: 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
示例13: testUploadFile
public function testUploadFile()
{
$album = $this->Album->init();
$tmp_file = "/tmp/111111111.jpg";
# Generate custom image to test upload
$im = imagecreatetruecolor(120, 20);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5, 'A Simple Text String', $text_color);
imagejpeg($im, $tmp_file);
# Generate path to save file
$file_path = $this->Picture->generateFilePath($album['Album']['id'], 'picturetests.jpg');
$file = new File($file_path);
# Get resize options
$resize_attrs = $this->Picture->getResizeToSize();
# Upload and save
$should_return_3 = $this->Picture->uploadFile($file_path, $album['Album']['id'], 'samplepicture.jpg', $tmp_file, $resize_attrs['width'], $resize_attrs['height'], $resize_attrs['action'], true);
# File was saved?
$this->assertEqual(3, $should_return_3);
# File was uploaded?
$this->assertTrue($file->exists());
# Should rise exception
try {
$this->Picture->uploadFile($file_path, null, 'samplepicture.jpg', $tmp_file, $resize_attrs['width'], $resize_attrs['height'], $resize_attrs['action'], true);
} catch (ForbiddenException $e) {
$this->assertEqual($e->getMessage(), "The album ID is required");
}
}
开发者ID:brnagn7,项目名称:spydercake,代码行数:27,代码来源:PictureTest.php
示例14: action_index
/**
* Processes incoming text
*/
public function action_index()
{
$this->request->headers['Content-type'] = 'image/png';
// Grab text and styles
$text = arr::get($_GET, 'text');
$styles = $_GET;
$hover = FALSE;
try {
// Create image
$img = new PNGText($text, $styles);
foreach ($styles as $key => $value) {
if (substr($key, 0, 6) == 'hover-') {
// Grab hover associated styles and override existing styles
$hover = TRUE;
$styles[substr($key, 6)] = $value;
}
}
if ($hover) {
// Create new hover image and stack it
$hover = new PNGText($text, $styles);
$img->stack($hover);
}
echo $img->draw();
} catch (Exception $e) {
if (Kohana::config('pngtext.debug')) {
// Dump error message in an image form
$img = imagecreatetruecolor(strlen($e->getMessage()) * 6, 16);
imagefill($img, 0, 0, imagecolorallocate($img, 255, 255, 255));
imagestring($img, 2, 0, 0, $e->getMessage(), imagecolorallocate($img, 0, 0, 0));
echo imagepng($img);
}
}
}
开发者ID:andygoo,项目名称:kohana-pngtext,代码行数:36,代码来源:pngtext.php
示例15: graph_error
function graph_error($string)
{
global $vars, $config, $debug, $graphfile;
$vars['bg'] = 'FFBBBB';
include 'includes/graphs/common.inc.php';
$rrd_options .= ' HRULE:0#555555';
$rrd_options .= " --title='" . $string . "'";
rrdtool_graph($graphfile, $rrd_options);
if ($height > '99') {
shell_exec($rrd_cmd);
d_echo('<pre>' . $rrd_cmd . '</pre>');
if (is_file($graphfile) && !$debug) {
header('Content-type: image/png');
$fd = fopen($graphfile, 'r');
fpassthru($fd);
fclose($fd);
unlink($graphfile);
exit;
}
} else {
if (!$debug) {
header('Content-type: image/png');
}
$im = imagecreate($width, $height);
$px = (imagesx($im) - 7.5 * strlen($string)) / 2;
imagestring($im, 3, $px, $height / 2 - 8, $string, imagecolorallocate($im, 128, 0, 0));
imagepng($im);
imagedestroy($im);
exit;
}
}
开发者ID:greggcz,项目名称:librenms,代码行数:31,代码来源:graph.inc.php
示例16: index
public function index()
{
$code = substr(sha1(mt_rand()), 17, 6);
$this->session->set_userdata('captcha_code', $code);
$width = '120';
$height = '40';
$font = APPPATH . 'modules/contact/assets/fonts/monofont.ttf';
$font_size = $height * 0.75;
$image = @imagecreate($width, $height) or die('Cannot initialize new GD image stream');
/* set the colours */
$background_color = imagecolorallocate($image, 255, 255, 255);
$text_color = imagecolorallocate($image, 20, 40, 100);
$noise_color = imagecolorallocate($image, 100, 120, 180);
/* generate random dots in background */
for ($i = 0; $i < $width * $height / 3; $i++) {
imagefilledellipse($image, mt_rand(0, $width), mt_rand(0, $height), 1, 1, $noise_color);
}
/* generate random lines in background */
for ($i = 0; $i < $width * $height / 150; $i++) {
imageline($image, mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $height), $noise_color);
}
/* create textbox and add text */
$textbox = imagettfbbox($font_size, 0, $font, $code) or die('Error in imagettfbbox function');
$x = ($width - $textbox[4]) / 2;
$y = ($height - $textbox[5]) / 2;
imagettftext($image, $font_size, 0, $x, $y, $text_color, $font, $code) or die('Error in imagettftext function');
/* output captcha image to browser */
header('Content-Type: image/jpeg');
imagejpeg($image);
imagedestroy($image);
}
开发者ID:binaek89,项目名称:cms-canvas,代码行数:31,代码来源:captcha.php
示例17: prepareRowAsPng
/**
* Adds to the PNG image object, the data related to a row in the GIS dataset.
*
* @param string $spatial GIS MULTIPOINT object
* @param string $label Label for the GIS MULTIPOINT object
* @param string $point_color Color for the GIS MULTIPOINT object
* @param array $scale_data Array containing data related to scaling
* @param object $image Image object
*
* @return object the modified image object
* @access public
*/
public function prepareRowAsPng($spatial, $label, $point_color, $scale_data, $image)
{
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// allocate colors
$black = imagecolorallocate($image, 0, 0, 0);
$red = hexdec($pmaString->substr($point_color, 1, 2));
$green = hexdec($pmaString->substr($point_color, 3, 2));
$blue = hexdec($pmaString->substr($point_color, 4, 2));
$color = imagecolorallocate($image, $red, $green, $blue);
// Trim to remove leading 'MULTIPOINT(' and trailing ')'
$multipoint = $pmaString->substr($spatial, 11, $pmaString->strlen($spatial) - 12);
$points_arr = $this->extractPoints($multipoint, $scale_data);
foreach ($points_arr as $point) {
// draw a small circle to mark the point
if ($point[0] != '' && $point[1] != '') {
imagearc($image, $point[0], $point[1], 7, 7, 0, 360, $color);
}
}
// print label for each point
if (isset($label) && trim($label) != '' && ($points_arr[0][0] != '' && $points_arr[0][1] != '')) {
imagestring($image, 1, $points_arr[0][0], $points_arr[0][1], trim($label), $black);
}
return $image;
}
开发者ID:FilipeRamosFernandes,项目名称:phpmyadmin,代码行数:37,代码来源:GIS_Multipoint.class.php
示例18: foundation_process_image_file
function foundation_process_image_file($file_name, $setting_name)
{
if ($setting_name->domain == FOUNDATION_SETTING_DOMAIN && $setting_name->name == 'logo_image') {
// Need to make sure this isn't too big
if (function_exists('getimagesize') && function_exists('imagecreatefrompng') && function_exists('imagecopyresampled') && function_exists('imagepng')) {
$size = getimagesize($file_name);
if ($size) {
$width = $size[0];
$height = $size[1];
if ($size['mime'] == 'image/png') {
if ($width > FOUNDATION_MAX_LOGO_SIZE) {
$new_width = FOUNDATION_MAX_LOGO_SIZE;
$new_height = $height * $new_width / $width;
$src_image = imagecreatefrompng($file_name);
$saved_image = imagecreatetruecolor($new_width, $new_height);
// Preserve Transparency
imagecolortransparent($saved_image, imagecolorallocate($saved_image, 0, 0, 0));
imagecopyresampled($saved_image, $src_image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
// Get rid of the old file
unlink($file_name);
// New image, compression level 5 (make it a bit smaller)
imagepng($saved_image, $file_name, 5);
}
}
}
}
}
}
开发者ID:sb-xs,项目名称:que-pour-elle,代码行数:28,代码来源:root-functions.php
示例19: CaptchaSecurityImages
function CaptchaSecurityImages($width = '120', $height = '40', $characters = '6')
{
$code = $this->generateCode($characters);
/* font size will be 75% of the image height */
$font_size = $height * 0.5;
$image = @imagecreate($width, $height) or die('Cannot initialize new GD image stream');
/* set the colours */
$background_color = imagecolorallocate($image, 20, 20, 20);
$text_color = imagecolorallocate($image, 230, 197, 89);
$noise_color = imagecolorallocate($image, 0, 0, 0);
/* generate random dots in background */
for ($i = 0; $i < $width * $height / 3; $i++) {
imagefilledellipse($image, mt_rand(0, $width), mt_rand(0, $height), 1, 1, $noise_color);
}
/* generate random lines in background */
/*for( $i=0; $i<($width*$height)/150; $i++ ) {
imageline($image, mt_rand(0,$width), mt_rand(0,$height), mt_rand(0,$width), mt_rand(0,$height), $noise_color);
}*/
/* create textbox and add text */
$textbox = imagettfbbox($font_size, 0, $this->font, $code) or die('Error in imagettfbbox function');
$x = ($width - $textbox[4]) / 2;
$y = ($height - $textbox[5]) / 2;
imagettftext($image, $font_size, 0, $x, $y, $text_color, $this->font, $code) or die('Error in imagettftext function');
/* output captcha image to browser */
header('Content-Type: image/jpeg');
imagejpeg($image);
imagedestroy($image);
$_SESSION['security_code'] = $code;
}
开发者ID:jassimtalat,项目名称:KMRD_2010,代码行数:29,代码来源:CaptchaSecurityImages.php
示例20: image
/**
* Displays the captcha image
*
* @access public
* @param int $key Captcha key
* @return mixed Captcha raw image data
*/
function image($key)
{
$value = Jaws_Utils::RandomText();
$result = $this->update($key, $value);
if (Jaws_Error::IsError($result)) {
$value = '';
}
$bg = dirname(__FILE__) . '/resources/simple.bg.png';
$im = imagecreatefrompng($bg);
imagecolortransparent($im, imagecolorallocate($im, 255, 255, 255));
// Write it in a random position..
$darkgray = imagecolorallocate($im, 0x10, 0x70, 0x70);
$x = 5;
$y = 20;
$text_length = strlen($value);
for ($i = 0; $i < $text_length; $i++) {
$fnt = rand(7, 10);
$y = rand(6, 10);
imagestring($im, $fnt, $x, $y, $value[$i], $darkgray);
$x = $x + rand(15, 25);
}
header("Content-Type: image/png");
ob_start();
imagepng($im);
$content = ob_get_contents();
ob_end_clean();
imagedestroy($im);
return $content;
}
开发者ID:Dulciane,项目名称:jaws,代码行数:36,代码来源:Simple.php
注:本文中的imagecolorallocate函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论