本文整理汇总了PHP中imageFill函数的典型用法代码示例。如果您正苦于以下问题:PHP imageFill函数的具体用法?PHP imageFill怎么用?PHP imageFill使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了imageFill函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* Method to apply a background color to an image resource.
*
* @param array $options An array of options for the filter.
* color Background matte color
*
* @return void
*
* @since 3.4
* @throws InvalidArgumentException
* @deprecated 5.0 Use Joomla\Image\Filter\Backgroundfill::execute() instead
*/
public function execute(array $options = array())
{
// Validate that the color value exists and is an integer.
if (!isset($options['color'])) {
throw new InvalidArgumentException('No color value was given. Expected string or array.');
}
$colorCode = !empty($options['color']) ? $options['color'] : null;
// Get resource dimensions
$width = imagesX($this->handle);
$height = imagesY($this->handle);
// Sanitize color
$rgba = $this->sanitizeColor($colorCode);
// Enforce alpha on source image
if (imageIsTrueColor($this->handle)) {
imageAlphaBlending($this->handle, false);
imageSaveAlpha($this->handle, true);
}
// Create background
$bg = imageCreateTruecolor($width, $height);
imageSaveAlpha($bg, empty($rgba['alpha']));
// Allocate background color.
$color = imageColorAllocateAlpha($bg, $rgba['red'], $rgba['green'], $rgba['blue'], $rgba['alpha']);
// Fill background
imageFill($bg, 0, 0, $color);
// Apply image over background
imageCopy($bg, $this->handle, 0, 0, 0, 0, $width, $height);
// Move flattened result onto curent handle.
// If handle was palette-based, it'll stay like that.
imageCopy($this->handle, $bg, 0, 0, 0, 0, $width, $height);
// Free up memory
imageDestroy($bg);
return;
}
开发者ID:Rai-Ka,项目名称:joomla-cms,代码行数:45,代码来源:backgroundfill.php
示例2: generate
/**
* @param string $name
* @param int $colorScheme
* @param int $backgroundStyle
*
* @return $this
*/
public function generate($name, $colorScheme, $backgroundStyle = null)
{
$name = strtoupper(substr($name, 0, $this->chars));
$bgColor = $this->colorSchemes[$colorScheme];
$this->avatar = imageCreateTrueColor($this->width, $this->height);
imageFill($this->avatar, 0, 0, $bgColor);
$this->drawString($name, 0xffffff);
return $this;
}
开发者ID:vinicius73,项目名称:laravel-instantavatar,代码行数:16,代码来源:FlatAvatar.php
示例3: generate
/**
* @param string $name
* @param int $colorScheme
* @param int $backgroundStyle
*
* @return $this
*/
public function generate($name, $colorScheme, $backgroundStyle)
{
list($bgColor1, $bgColor2, $textColor) = $this->colorSchemes[$colorScheme];
$this->avatar = imageCreateTrueColor($this->width, $this->height);
imageFill($this->avatar, 0, 0, $bgColor1);
$this->drawBG($bgColor2, $backgroundStyle);
$this->drawString($name, $textColor);
$this->copyOverlay();
return $this;
}
开发者ID:vinicius73,项目名称:laravel-instantavatar,代码行数:17,代码来源:InstantAvatar.php
示例4: Captcha
function Captcha($text, $font, $color)
{
$C = HexDec($color);
$R = floor($C / pow(256, 2));
$G = floor($C % pow(256, 2) / pow(256, 1));
$B = floor($C % pow(256, 2) % pow(256, 1) / pow(256, 0));
$fsize = 32;
$bound = array();
$bound = imageTTFBbox($fsize, 0, $font, $text);
$this->image = imageCreateTrueColor($bound[4] + 5, abs($bound[5]) + 15);
imageFill($this->image, 0, 0, ImageColorAllocate($this->image, 255, 255, 255));
imagettftext($this->image, $fsize, 0, 2, abs($bound[5]) + 5, ImageColorAllocate($this->image, $R, $G, $B), $font, $text);
}
开发者ID:joly,项目名称:web2project,代码行数:13,代码来源:Captcha.class.php
示例5: indexAction
public function indexAction()
{
$size = 300;
$image = imagecreatetruecolor($size, $size);
// something to get a white background with black border
$back = imagecolorallocate($image, 255, 255, 255);
$border = imagecolorallocate($image, 0, 0, 0);
imagefilledrectangle($image, 0, 0, $size - 1, $size - 1, $back);
imagerectangle($image, 0, 0, $size - 1, $size - 1, $border);
$yellow_x = 100;
$yellow_y = 75;
$red_x = 120;
$red_y = 165;
$blue_x = 187;
$blue_y = 125;
$radius = 150;
// allocate colors with alpha values
$yellow = imagecolorallocatealpha($image, 255, 255, 0, 75);
$red = imagecolorallocatealpha($image, 255, 0, 0, 75);
$blue = imagecolorallocatealpha($image, 0, 0, 255, 75);
// drawing 3 overlapped circle
imagefilledellipse($image, $yellow_x, $yellow_y, $radius, $radius, $yellow);
imagefilledellipse($image, $red_x, $red_y, $radius, $radius, $red);
imagefilledellipse($image, $blue_x, $blue_y, $radius, $radius, $blue);
// don't forget to output a correct header!
header('Content-type: image/png');
// and finally, output the result
imagepng($image);
imagedestroy($image);
exit;
$im1 = imagecreatetruecolor(300, 100) or die("Error");
imagealphablending($im1, true);
imageSaveAlpha($im1, true);
$color = '#FF0000';
$textColorAllocated = ImageColorAllocate($im1, hexdec(substr($color, 1, 2)), hexdec(substr($color, 3, 2)), hexdec(substr($color, 5, 2)));
$backgroundColor = '#FFFF00';
// $bgColor = ImageColorAllocate ($im1, hexdec(substr($backgroundColor,1,2)), hexdec(substr($backgroundColor,3,2)), hexdec(substr($backgroundColor,5,2)));
$bgColor = imagecolorallocatealpha($im1, 255, 255, 255, 126);
imageFill($im1, 0, 0, $bgColor);
imageline($im1, 0, 0, 100, 100, $textColorAllocated);
imagettftext($im1, 50, 0, 50, 50, $textColorAllocated, dirname(__FILE__) . '/Headline/arial.ttf', 'asdf');
header('Content-Type: image/png');
imagepng($im1);
imagedestroy($im1);
exit;
}
开发者ID:xiaoguizhidao,项目名称:koala-framework,代码行数:46,代码来源:GdLibTestController.php
示例6: creat_images
public function creat_images($num)
{
$type = 2;
header("Content-type: image/PNG");
// 產生種子, 作圖形干擾用
srand((double) microtime() * 10000000000);
// 產生圖檔, 及定義顏色
$img_x = 120;
$img_y = 28;
$im = imageCreate($img_x, $img_y);
//ImageColorAllocate 分配圖形的顏色
$back = ImageColorAllocate($im, rand(200, 255), rand(200, 255), rand(200, 255));
$authText = $this->num2adb($num);
imageFill($im, 0, 0, $back);
// imageString($im, 5, rand(0,55), rand(0,40), $authText, $font);
$str_x = 0;
$str_y = 0;
for ($i = 0; $i < strlen($authText); $i++) {
$str_x += rand(10, 20);
$str_y = rand(0, $img_y / 2);
$font = ImageColorAllocate($im, rand(0, 100), rand(0, 100), rand(0, 100));
imageString($im, 5, $str_x, $str_y, $authText[$i], $font);
}
// 插入圖形干擾點共 50 點, 可插入更多, 但可能會使圖形太過混雜
for ($i = 0; $i < rand(50, 200); $i++) {
$point = ImageColorAllocate($im, rand(0, 255), rand(0, 255), rand(0, 255));
imagesetpixel($im, rand(0, $img_x), rand(0, $img_y), $point);
}
for ($i = 1; $i <= rand(2, 5); $i++) {
$point = ImageColorAllocate($im, rand(0, 255), rand(0, 255), rand(0, 255));
imageline($im, rand(0, $img_x), rand(0, $img_y), rand(0, $img_x), rand(0, $img_y), $point);
}
// 定義圖檔類型並輸入, 最後刪除記憶體
if ($type == 1) {
ob_start();
ImagePNG($im);
$output = ob_get_contents();
ob_end_clean();
echo base64_encode($output);
} else {
ImagePNG($im);
}
ImageDestroy($im);
}
开发者ID:SamLaio,项目名称:mymvc,代码行数:44,代码来源:LibCaptcha.php
示例7: 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
示例8: imageCreateFromJpeg
<?php
## Увеличение картинки со сглаживанием.
$tile = imageCreateFromJpeg("sample1.jpg");
$im = imageCreateTrueColor(800, 600);
imageFill($im, 0, 0, imageColorAllocate($im, 0, 255, 0));
imageSetTile($im, $tile);
// Создаем массив точек со случайными координатами.
$p = [];
for ($i = 0; $i < 4; $i++) {
array_push($p, mt_rand(0, imageSX($im)), mt_rand(0, imageSY($im)));
}
// Рисуем закрашенный многоугольник.
imageFilledPolygon($im, $p, count($p) / 2, IMG_COLOR_TILED);
// Выводим результат.
header("Content-type: image/jpeg");
// Выводим картинку с максимальным качеством (100).
imageJpeg($im, '', 100);
// Можно было сжать с помощью PNG.
#header("Content-type: image/png");
#imagePng($im);
开发者ID:igorsimdyanov,项目名称:php7,代码行数:21,代码来源:tile.php
示例9: confirmImage
/**
* Функция генерирует и выводит хидер PNG и изображение с кодом подтверждения (код берется из массива полей)
* Возвращает результат выполнения imagePNG
* @return bool
*/
function confirmImage() {
$width = ajaxform::$captcha[width];
$height = ajaxform::$captcha[height];
$multi = 4;
$xwidth = $width * $multi;
$xheight = $height * $multi;
$code = $this->fields[confirm][value];
$im = imageCreateTrueColor($xwidth, $xheight);
$w = imageColorAllocate($im, 255, 255, 255);
$b = imageColorAllocate($im, 000, 000, 000);
$g = imageColorAllocate($im, 100, 100, 100);
imageFill($im, 1, 1, $w);
$w = imageColorTransparent($im, $w);
$r = mt_rand(0, $xheight);
for ($x = 0; $x < $xwidth + $xheight; $x += 4 * $multi) {
for ($i = 0; $i < $multi; $i++)
imageLine($im, $x + $i, 0, $x + $i - $xheight, $xheight + $r, $g);
}
$arr = preg_split('//', $code, -1, PREG_SPLIT_NO_EMPTY);
for ($i = 0; $i < count($arr); $i++) {
$x = ($xwidth * 0.04) + (floor(($xwidth * 0.97) * 0.167)) * $i; // разрядка
$y = ($xheight * 0.8);
$s = ($xheight * 0.5) * (96 / 72); // 96 — res
$a = mt_rand(-20, 20);
imageTTFText($im, $s, $a, $x, $y, $b, $_SERVER[DOCUMENT_ROOT] . "/lib/core/classes/form_ajax/consolas.ttf", $arr[$i]); //
}
$temp = imageCreateTrueColor($xwidth, $xheight);
$w = imageColorAllocate($temp, 255, 255, 255);
imageFill($temp, 1, 1, $w);
$w = imageColorTransparent($temp, $w);
$phase = rand(-M_PI, M_PI);
$frq = 2 * M_PI / $xheight;
$amp = $xwidth * 0.02;
for ($y = 0; $y < $xheight; $y++) {
$dstx = $amp + sin($y * $frq + $phase) * $amp;
imagecopy($temp, $im, $dstx, $y, 0, $y, $xwidth, 1);
//imagesetpixel($im, $dstx, $y, $b);
}
$res = imageCreateTrueColor($width, $height);
$w = imageColorAllocate($res, 255, 255, 255);
imageFill($res, 1, 1, $w);
$w = imageColorTransparent($res, $w);
imageCopyResampled($res, $temp, 0, 0, 0, 0, $width, $height, $xwidth, $xheight);
imageTrueColorToPalette($res, true, 256);
header("CONTENT-TYPE: IMAGE/PNG");
return imagePNG($res);
}
开发者ID:GGF,项目名称:baza4,代码行数:70,代码来源:ajaxform.class.php
示例10: generate_part
/**
* @param $part_type
* @param $part_id
* @param $part_color
* @param string $format
* @return string
*/
public function generate_part($part_type, $part_id, $part_color, $format = "png")
{
$time_start = microtime(true);
$this->is_head_only = $part_type == "hd";
$avatar_image = imageCreateTrueColor($this->rect_width, $this->rect_height);
imageAlphaBlending($avatar_image, false);
imageSaveAlpha($avatar_image, true);
$rect_mask = imageColorAllocateAlpha($avatar_image, 255, 0, 255, 127);
imageFill($avatar_image, 0, 0, $rect_mask);
$draw_parts = $this->get_draw_order("std", $this->direction);
$active_parts['rect'] = $this->get_active_part_set($this->is_head_only ? "head" : "figure", true);
$active_parts['eye'] = $this->get_active_part_set("eye");
if ($part_type == 'ri' || $part_type == 'li') {
$set_parts[$part_type][0] = ['id' => $part_id, 'colorable' => false];
} else {
$set_parts = $this->get_part_color($part_type, $part_id, $part_color);
}
imageAlphaBlending($avatar_image, true);
$draw_count = 0;
foreach ($draw_parts as $id => $type) {
if (isset($set_parts[$type])) {
$draw_part_array = $set_parts[$type];
} else {
continue;
}
foreach ($draw_part_array as $draw_part) {
if (!is_array($draw_part)) {
continue;
}
if ($this->get_part_unique_name($type, $draw_part['id']) == '') {
continue;
}
if ($this->is_head_only && !$active_parts['rect'][$type]['active']) {
continue;
}
if ($active_parts['eye'][$type]['active']) {
$draw_part['colorable'] = false;
}
$unique_name = $this->get_part_unique_name($type, $draw_part['id']);
$draw_part_rect = $this->get_part_resource($unique_name, $this->action, $type, $draw_part['id'], $this->direction);
$draw_count++;
if ($draw_part_rect === false) {
$this->debug .= "PART[" . $this->action . "][" . $type . "][" . $draw_part['id'] . "][" . $this->direction . "][0]/";
continue;
} else {
$this->debug .= $draw_part_rect['lib'] . ":" . $draw_part_rect['name'] . "(" . $draw_part_rect['width'] . "x" . $draw_part_rect['height'] . ":" . $draw_part_rect['offset']['x'] . "," . $draw_part_rect['offset']['y'] . ")/";
}
$draw_part_transparent_color = imageColorTransparent($draw_part_rect['resource']);
if ($draw_part['colorable']) {
$this->set_part_color($draw_part_rect['resource'], $draw_part['color']);
}
$_posX = -$draw_part_rect['offset']['x'];
$_posY = $this->rect_height / 2 - $draw_part_rect['offset']['y'] + $this->rect_height / 2.5;
if ($draw_part_rect['isFlip']) {
$_posX = -($_posX + $draw_part_rect['width'] - ($this->rect_width + 1));
}
imageCopy($avatar_image, $draw_part_rect['resource'], $_posX, $_posY, 0, 0, $draw_part_rect['width'], $draw_part_rect['height']);
imageDestroy($draw_part_rect['resource']);
}
}
$this->debug .= "DRAWCOUNT: " . $draw_count;
ob_start();
if ($format == "gif") {
$rect_mask = imageColorAllocateAlpha($avatar_image, 255, 0, 255, 127);
imageColorTransparent($avatar_image, $rect_mask);
imageGIF($avatar_image);
} elseif ($format == "png") {
imagePNG($avatar_image);
} else {
ob_end_clean();
exit;
}
$resource = ob_get_contents();
ob_end_clean();
imageDestroy($avatar_image);
$time_end = microtime(true);
$this->process_time += $time_end - $time_start;
return $resource;
}
开发者ID:Zortex04,项目名称:habbo-web-cms,代码行数:86,代码来源:AvatarImager.php
示例11: 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
示例12: appendSourceInfo
/**
* Appends information about the source image to the thumbnail.
*
* @param string $thumbnail
* @return string
*/
protected function appendSourceInfo($thumbnail)
{
if (!function_exists('imageCreateFromString') || !function_exists('imageCreateTrueColor')) {
return $thumbnail;
}
$imageSrc = imageCreateFromString($thumbnail);
// get image size
$width = imageSX($imageSrc);
$height = imageSY($imageSrc);
// increase height
$heightDst = $height + self::$sourceInfoLineHeight * 2;
// create new image
$imageDst = imageCreateTrueColor($width, $heightDst);
imageAlphaBlending($imageDst, false);
// set background color
$background = imageColorAllocate($imageDst, 102, 102, 102);
imageFill($imageDst, 0, 0, $background);
// copy image
imageCopy($imageDst, $imageSrc, 0, 0, 0, 0, $width, $height);
imageSaveAlpha($imageDst, true);
// get font size
$font = 2;
$fontWidth = imageFontWidth($font);
$fontHeight = imageFontHeight($font);
$fontColor = imageColorAllocate($imageDst, 255, 255, 255);
// write source info
$line1 = $this->sourceName;
// imageString supports only ISO-8859-1 encoded strings
if (CHARSET != 'ISO-8859-1') {
$line1 = StringUtil::convertEncoding(CHARSET, 'ISO-8859-1', $line1);
}
// truncate text if necessary
$maxChars = floor($width / $fontWidth);
if (strlen($line1) > $maxChars) {
$line1 = $this->truncateSourceName($line1, $maxChars);
}
$line2 = $this->sourceWidth . 'x' . $this->sourceHeight . ' ' . FileUtil::formatFilesize($this->sourceSize);
// write line 1
// calculate text position
$textX = 0;
$textY = 0;
if ($fontHeight < self::$sourceInfoLineHeight) {
$textY = intval(round((self::$sourceInfoLineHeight - $fontHeight) / 2));
}
if (strlen($line1) * $fontWidth < $width) {
$textX = intval(round(($width - strlen($line1) * $fontWidth) / 2));
}
imageString($imageDst, $font, $textX, $height + $textY, $line1, $fontColor);
// write line 2
// calculate text position
$textX = 0;
$textY = 0;
if ($fontHeight < self::$sourceInfoLineHeight) {
$textY = self::$sourceInfoLineHeight + intval(round((self::$sourceInfoLineHeight - $fontHeight) / 2));
}
if (strlen($line2) * $fontWidth < $width) {
$textX = intval(round(($width - strlen($line2) * $fontWidth) / 2));
}
imageString($imageDst, $font, $textX, $height + $textY, $line2, $fontColor);
// output image
ob_start();
if ($this->imageType == 1 && function_exists('imageGIF')) {
@imageGIF($imageDst);
$this->mimeType = 'image/gif';
} else {
if (($this->imageType == 1 || $this->imageType == 3) && function_exists('imagePNG')) {
@imagePNG($imageDst);
$this->mimeType = 'image/png';
} else {
if (function_exists('imageJPEG')) {
@imageJPEG($imageDst, null, 90);
$this->mimeType = 'image/jpeg';
} else {
return false;
}
}
}
@imageDestroy($imageDst);
$thumbnail = ob_get_contents();
ob_end_clean();
return $thumbnail;
}
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:88,代码来源:Thumbnail.class.php
示例13: session_start
<?php
session_start();
$my_img = imageCreateFromPng("../icons/marker-icon-red-empty.png");
imageAlphaBlending($my_img, true);
imageSaveAlpha($my_img, true);
$overlayImage = imageCreateFromPng("../icon.png");
imageAlphaBlending($overlayImage, true);
imageSaveAlpha($overlayImage, true);
$overlayImageSmall = imageCreateTrueColor(19, 19);
imageSaveAlpha($overlayImageSmall, true);
$color = imageColorAllocateAlpha($overlayImageSmall, 0, 0, 0, 127);
imageFill($overlayImageSmall, 0, 0, $color);
imageCopyResampled($overlayImageSmall, $overlayImage, 0, 0, 0, 0, 19, 19, imagesx($overlayImage), imagesy($overlayImage));
imagecopy($my_img, $overlayImageSmall, 3, 5, 0, 0, imagesx($overlayImageSmall), imagesy($overlayImageSmall));
header("Content-type: image/png");
imagepng($my_img);
imageDestroy($my_img);
开发者ID:Jugendhackt,项目名称:Eventkarte,代码行数:18,代码来源:target-marker.php
示例14: imageCreate
<?php
## Создание изображений с областями прозрачности.
$im = imageCreate(620, 241);
$t = imageColorAllocate($im, 0, 0, 0);
$c = imageColorAllocate($im, 0, 255, 0);
imageFill($im, 0, 0, $c);
imageFilledRectangle($im, 180, 20, 420, 220, $t);
imageColorTransparent($im, $t);
Header("Content-type: image/png");
imagePng($im);
开发者ID:igorsimdyanov,项目名称:php7,代码行数:11,代码来源:transparent.php
示例15: _555
function _555()
{
$b1 = imageTTFBbox($this->_112, 0, $this->_111, $this->_113);
$b2 = $b1[4];
$b3 = abs($b1[5]);
$im = imageCreateTrueColor($b1[4], abs($b1[5]) + 2);
imageFill($im, 0, 0, imageColorAllocate($im, 255, 255, 255));
imagettftext($im, $this->_112, 0, 0, $b3, imageColorAllocate($im, 0, 0, 0), $this->_111, $this->_113);
$this->_114 = $x = imageSX($im);
$this->_115 = $y = imageSY($im);
$c = 0;
$q = 1;
$this->_057[0] = 0;
for ($i = 0; $i < $x; $i++) {
for ($j = 0; $j < $y; $j++) {
$p = imageColorsForIndex($im, imageColorAt($im, $i, $j));
if ($p['red'] < 128 && $p['green'] < 128 && $p['blue'] < 128) {
$this->_057[$q] = $i;
$this->_057[$q + 1] = $j;
$q += 2;
$c += 2;
}
}
}
$this->_057[0] = $c;
$this->_435($this->_116);
}
开发者ID:oussamaruon,项目名称:Homosapiensonly.com,代码行数:27,代码来源:Text3D.class.php
示例16: resize
/**
* @param int $maxX
* @param int $maxY
* @param bool $ignoreAspectRatio 画像の縦横比を維持するか。
* @return Image
*/
public function resize($maxX = 180, $maxY = 180, $ignoreAspectRatio = false)
{
$width = $this->getWidth();
$height = $this->getHeight();
if ($ignoreAspectRatio === false) {
$resizeX = $maxX;
$resizeY = $maxY;
} elseif ($width < $height) {
$resizeX = ceil($maxX * $width / $height);
$resizeY = $maxY;
} else {
$resizeX = $maxX;
$resizeY = ceil($maxY * $height / $width);
}
// 透明色が指定されているとjpg保存時に透明色部が黒くなるのでその対策。
// MEMO: PNGで保存するなら
// imagealphablending($resize, false);
// imagesavealpha($resize, true);
$resizeGD = @imageCreateTrueColor($resizeX, $resizeY);
$alpha = imagecolortransparent($this->gd);
if ($alpha !== -1) {
$color = imagecolorallocate($resizeGD, 255, 255, 255);
imageFill($resizeGD, 0, 0, $color);
imageColorTransparent($resizeGD, $alpha);
} else {
imageAlphaBlending($resizeGD, true);
imageSaveAlpha($resizeGD, true);
$fill_color = imagecolorallocate($resizeGD, 255, 255, 255);
imageFill($resizeGD, 0, 0, $fill_color);
}
imageCopyResampled($resizeGD, $this->gd, 0, 0, 0, 0, $resizeX, $resizeY, $width, $height);
return new Image($resizeGD);
}
开发者ID:ootori,项目名称:aulait,代码行数:39,代码来源:Image.php
示例17: imageReflect
function imageReflect($im, $dir = 1, $spread = 0.55, $decay = 15, $spacing = 0)
{
// Reflect an image pointer, returning a slightly larger image
//
// $dir: 1 == "vertical" reflection, 2 == "horizontal"
// $spread: % to reflect. defaults to 0.55, or 55% original image
// $decay: A value to adjust initial opacity and decaying visibility. lower == more visible
$w = imagesx($im);
$h = imagesy($im);
$vert = $dir & 1;
$hori = $dir & 2;
// calculate the size of our attachment
$nw = $vert ? $w : $w * $spread;
$nh = $hori ? $h : $h * $spread;
// add our reflection size to the height or width
$fw = $w + ($vert ? 0 : $nw);
$fh = $h + ($hori ? 0 : $nh);
$reflect = imagecreatetruecolor($fw, $fh);
imagealphablending($reflect, false);
$trans = imagecolorallocatealpha($reflect, 0, 0, 0, 127);
imageFill($reflect, 0, 0, $trans);
// put the orig on canvas at 0x0
imagecopy($reflect, $im, 0, 0, 0, 0, $w, $h);
if ($vert) {
// vertical
for ($y = 0; $y < $nh; $y++) {
$opacity = $decay + ceil(127 * (($y + $decay) / $h));
if ($opacity > 127) {
$opacity = 127;
}
for ($x = 0; $x < $nw; $x++) {
$rgba = imagecolorat($im, $x, $h - $y - 1);
// break out to function:
$r = ($rgba & 0xff0000) >> 16;
$g = ($rgba & 0xff00) >> 8;
$b = $rgba & 0xff;
$ttrans = imagecolorallocatealpha($reflect, $r, $g, $b, $rgba >> 24 >= 124 ? 127 : $opacity);
imagesetpixel($reflect, $x, $y + $h + $spacing, $ttrans);
}
}
}
if ($hori) {
// horizontal
for ($x = 0; $x < $nw; $x++) {
$opacity = $decay + ceil(127 * (($x + $decay) / $nw));
if ($opacity > 127) {
$opacity = 127;
}
for ($y = 0; $y < $nh; $y++) {
$rgba = imagecolorat($im, $w - $x - 1, $y);
// FIXME: if $rgba >> 24 === 127, we need to muck opacity and keep it invisible,
// otherwise our decay makes it visible but slightly opaque?
// break into funciton:
$red = ($rgba & 0xff0000) >> 16;
$green = ($rgba & 0xff00) >> 8;
$blue = $rgba & 0xff;
$ttrans = imagecolorallocatealpha($reflect, $red, $green, $blue, $rgba >> 24 >= 124 ? 127 : $opacity);
imagesetpixel($reflect, $x + $w + $spacing, $y, $ttrans);
}
}
}
imagesavealpha($reflect, true);
return $reflect;
}
开发者ID:modulexcite,项目名称:frameworks,代码行数:64,代码来源:image-lib.php
示例18: imageCreateTrueColor
<?php
//$i = imageCreate(500, 300);
$i = imageCreateTrueColor(500, 300);
imageAntiAlias($i, true);
$green = imageColorAllocate($i, 156, 14, 200);
imageFill($i, 0, 0, $green);
$white = imageColorAllocate($i, 255, 255, 255);
/*
$j=0;
while(++$j<1000)
imageSetPixel($i,rand(1,500), rand(1,300), $white);
*/
/*
$j=0;
while(++$j<1000)
imageLine($i, 250, 150, rand(1,500), rand(1,300), $white);
*/
/*
$j=0;
while(++$j<100)
imageRectangle($i, rand(1,500), rand(1,300), rand(1,500), rand(1,300), $white);
*/
/*
$j=0;
while(++$j<10)
imageFilledRectangle($i, rand(1,500), rand(1,300), rand(1,500), rand(1,300), $white);
*/
/*
$points = array(0,0,100,200,300,200);
imagePolygon($i, $points, 3, $white);
开发者ID:kapsilon,项目名称:Specialist,代码行数:31,代码来源:image_create.php
示例19: 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
示例20: rand
$chars = rand(3, 5);
$s = strlen($chars_list) - 1;
for ($i = 0; $i < $chars; $i++) {
$string .= $chars_list[rand(0, $s)];
}
// Set the image parameters
$img = imageCreate($img_width, $img_height);
$white = imageColorAllocate($img, 255, 255, 255);
$black = imageColorAllocate($img, 0, 0, 0);
// Background
if ($img_use_background) {
$r = rand($img_rgb_min, $img_rgb_max);
$g = rand($img_rgb_min, $img_rgb_max);
$b = rand($img_rgb_min, $img_rgb_max);
$bg = imageColorAllocate($img, $r, $g, $b);
imageFill($img, 0, 0, $bg);
}
// Circles
if ($img_use_circles) {
for ($i = 1; $i <= $img_circles; $i++) {
$cx = rand(0, $img_width - 10);
$cy = rand(0, $img_height - 3);
$w = rand(20, 70);
$h = rand(20, 70);
$r = rand($img_rgb_min, $img_rgb_max);
$g = rand($img_rgb_min, $img_rgb_max);
$b = rand($img_rgb_min, $img_rgb_max);
$color = imageColorAllocate($img, $r, $g, $b);
imageFilledEllipse($img, $cx, $cy, $w, $h, $color);
}
}
开发者ID:mmr,项目名称:b1n,代码行数:31,代码来源:createimg.php
注:本文中的imageFill函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论