• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP imageftbbox函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: text2etc

function text2etc($text, $CP, $mode = "png", $trans = 1)
{
    global $TTF_LOCATION, $FONT_SIZE;
    //$outputtext = implode('',file($f));
    $outputtext = $text;
    $outputtext = Conv2UTF8($outputtext, 1, $CP);
    $outputtext = str_replace("\r\n", "\n", $outputtext);
    $outputtext = str_replace("\r", "\n", $outputtext);
    $outputtext = str_replace("\n", "\r\n", $outputtext);
    $outputtext = str_replace("<br />", "\r\n", $outputtext);
    $outputtext = str_replace("&nbsp;", " ", $outputtext);
    $outputtext = unhtmlentities($outputtext);
    if ($mode == "png") {
        $dim = imageftbbox($FONT_SIZE, 0, $TTF_LOCATION, $outputtext, array("linespacing" => 1.0));
        #		$dim= imagettfbbox($FONT_SIZE, 0, $TTF_LOCATION, $outputtext);
        $min_x = min($dim[0], $dim[2], $dim[4], $dim[6]);
        $max_x = max($dim[0], $dim[2], $dim[4], $dim[6]);
        $width = $max_x - $min_x + 1;
        $min_y = min($dim[1], $dim[3], $dim[5], $dim[7]);
        $max_y = max($dim[1], $dim[3], $dim[5], $dim[7]);
        $height = $max_y - $min_y + 1;
        $img = imagecreate($width + 1, $height + 1);
        $white = ImageColorAllocate($img, 255, 255, 255);
        if ($trans) {
            $twhite = imagecolortransparent($img, $white);
        }
        $black = ImageColorAllocate($img, 0, 0, 0);
        #		ImageTTFText($img, $FONT_SIZE, 0, -$min_x+$dim[0],-$min_y, $black, $TTF_LOCATION, $outputtext);
        ImageFTText($img, $FONT_SIZE, 0, -$min_x + $dim[0], -$min_y, $black, $TTF_LOCATION, $outputtext, array("linespacing" => 1.0));
        Header("Content-type: image/png");
        ImagePng($img);
        ImageDestroy($img);
    } else {
        if ($mode == "pre") {
            echo "<pre>\n{$outputtext}\n</pre>";
        } else {
            if ($mode == "text") {
                Header("Content-type: text/plain");
                echo utf8Encode($outputtext);
            }
        }
    }
}
开发者ID:h16o2u9u,项目名称:rtoss,代码行数:43,代码来源:txtrender.php


示例2: strtag

/**
 *
 * @copyright  2010-2012 izend.org
 * @version    2
 * @link       http://www.izend.org
 */
function strtag($text)
{
    $len = strlen($text);
    $fontfile = ROOT_DIR . DIRECTORY_SEPARATOR . 'font.ttf';
    $fontsize = 24.0;
    $bbox = imageftbbox($fontsize, 0, $fontfile, $text);
    $w = $bbox[2] + $len * 15;
    $h = 40;
    $img = @imagecreatetruecolor($w, $h) or die;
    $bg = imagecolorallocate($img, 255, 255, 224);
    $fg = imagecolorallocate($img, 64, 64, 64);
    imagefill($img, 0, 0, $bg);
    // print text unevenly
    for ($x = 15, $i = 0; $i < $len; $i++) {
        $y = rand($h / 2, $h / 2 + 15);
        $r = rand(-45, 45);
        imagettftext($img, $fontsize, $r, $x, $y, $fg, $fontfile, $text[$i]);
        $x += rand(25, 35);
    }
    // blur with colored dots
    for ($i = 0; $i < $w * $h / 2.0; $i++) {
        $color = imagecolorallocate($img, rand(128, 255), rand(128, 255), rand(128, 255));
        imagesetpixel($img, rand(0, $w - 1), rand(0, $h - 1), $color);
    }
    return $img;
}
开发者ID:RazorMarx,项目名称:izend,代码行数:32,代码来源:strtag.php


示例3: CenteredText

 /**
  *
  * @param <type> $string
  * @param <type> $cl
  * @param <type> $size
  * @return img
  */
 public function CenteredText($string, $size = 10)
 {
     $axes = imageftbbox($size, 0, $this->font, $string);
     $x = $this->w / 2 - ($axes[2] - $axes[0]) / 2;
     $y = $this->h / 2 - ($axes[7] - $axes[1]) / 2;
     imagefttext($this->im, $size, 0, $x, $y, $this->color, $this->font, $string);
     return $this;
 }
开发者ID:google-code-backups,项目名称:eude,代码行数:15,代码来源:img.class.php


示例4: wfPChart4mwtextboxSize

/**
 * Determines the height and width of a specified string on screen
 *
 * @param $font		String	Name of font (with file extension) used
 * @param $text		String	Text of which the size should be determined
 * @param $angle	String	Angle for showing the text
 * @param $size		Int		Text size for printing the text
 * @return			Array	Array with two elements: first element is the width of the textbox, second is the height
 */
function wfPChart4mwtextboxSize($font, $text, $angle = 0, $size = 0)
{
    global $wgPChart4mwFontPath;
    // Determine the bounding box using the GD library
    $bbox = imageftbbox($size, $angle, $wgPChart4mwFontPath . "/" . $font, $text);
    // Compute the size
    return array(max($bbox[0], $bbox[2], $bbox[4], $bbox[6]) - min($bbox[0], $bbox[2], $bbox[4], $bbox[6]), max($bbox[1], $bbox[3], $bbox[5], $bbox[7]) - min($bbox[1], $bbox[3], $bbox[5], $bbox[7]));
}
开发者ID:hystrix,项目名称:pchart4mw,代码行数:17,代码来源:library.inc.php


示例5: box

 /**
  * (non-PHPdoc)
  * @see Imagine\Image\FontInterface::box()
  */
 public function box($string, $angle = 0)
 {
     $angle = -1 * $angle;
     $info = imageftbbox($this->size, $angle, $this->file, $string);
     $xs = array($info[0], $info[2], $info[4], $info[6]);
     $ys = array($info[1], $info[3], $info[5], $info[7]);
     $width = abs(max($xs) - min($xs));
     $height = abs(max($ys) - min($ys));
     return new Box($width, $height);
 }
开发者ID:SerdarSanri,项目名称:laravel-imagine-bundle,代码行数:14,代码来源:Font.php


示例6: get_legend_height

/**
 * Determines an appropriate height for the legend
 *
 * @param  $dataset   Our dataset containing the values we need to check for sizes
 * @param  $font      A reference to the font file used
 * @param  $fontsize  The fontsize used
 *
 * @return            The vertical height of the text, plus a small margin
 */
function get_legend_height($dataset, $font, $fontsize)
{
    $description = $dataset->GetDataDescription();
    $total_value = 0;
    foreach ($description["Description"] as $key => $value) {
        $position = imageftbbox($fontsize, 0, $font, $value);
        $textheight = $position[1] - $position[7];
        $total_value += abs($textheight);
    }
    return $total_value + 20;
}
开发者ID:remotelearner,项目名称:elis.reporting,代码行数:20,代码来源:bargraph_output.php


示例7: box

 /**
  * {@inheritdoc}
  */
 public function box($string, $angle = 0)
 {
     if (!function_exists('imageftbbox')) {
         throw new RuntimeException('GD must have been compiled with `--with-freetype-dir` option to use the Font feature.');
     }
     $angle = -1 * $angle;
     $info = imageftbbox($this->size, $angle, $this->file, $string);
     $xs = array($info[0], $info[2], $info[4], $info[6]);
     $ys = array($info[1], $info[3], $info[5], $info[7]);
     $width = abs(max($xs) - min($xs));
     $height = abs(max($ys) - min($ys));
     return new Box($width, $height);
 }
开发者ID:ccq18,项目名称:EduSoho,代码行数:16,代码来源:Font.php


示例8: getBbox

 /**
  * Calculate text bbox using size, angle, font and value
  *
  * {@inheritdoc}
  */
 function getBbox()
 {
     $bbox = imageftbbox($this->size, $this->angle, $this->font, $this->value);
     $boxWidth = $bbox[4] - $bbox[0];
     $boxHeight = $bbox[1] - $bbox[5];
     $boxX = 0;
     $boxY = 0;
     $lines = explode("\n", $this->value);
     if (count($lines) > 1) {
         $boxY = -($bbox[1] / count($lines));
     }
     return array($boxX, $boxY, $boxWidth, $boxHeight);
 }
开发者ID:nimetu,项目名称:ryzom_bmaker,代码行数:18,代码来源:TextElement.php


示例9: create

 /**
  * Description: a creation of a cookie
  * Example:     $config = [
  *       			'path'       => 'files/images/captcha',
  *       			'text'       => 'Some text...',
  *       			'expiration' => 60,
  *       			'font'       => 'app/fonts/simple.ttf',
  *       			'angle'      => 0,
  *       			'width'      => 300,
  *       			'height'     => 50,
  *              	'fontSize'   => 18,
  *       			'colors'     => [
  *                  	'text'       => [255, 200, 168],
  *           			'background' => [255, 255, 255]
  *       			]
  *              ];
  *              Captcha::create($config);
  * @param       array|$config
  * @return      array
  *				(
  *				    [path]     => files/images/captcha/1438642230.5518.png
  *				    [fullPath] => C:/OpenServer/domains/localhost/framework/files/images/captcha/1438642230.5518.png
  *				    [name]     => 1438642230.5518.png
  *				)
  */
 public static function create(array $config)
 {
     $colors = ['text' => [0, 0, 0], 'background' => [255, 255, 255]];
     $param = ['path' => 'files/images/captcha', 'text' => 'Some text', 'expiration' => '3600', 'font' => VENDIR . 'simple/fonts/simple.ttf', 'angle' => 0, 'width' => 300, 'height' => 50, 'fontSize' => 16, 'colors' => $colors];
     //set the config
     foreach ($config as $key => $value) {
         $param[$key] = $config[$key];
     }
     //set the colors
     foreach ($param['colors'] as $key => $value) {
         $colors[$key] = $config['colors'][$key];
     }
     //set the colors array
     $colors = $config['colors'];
     //the removal of the old captcha images
     $now = microtime(true);
     if (file_exists('files/images/captcha/')) {
         foreach (glob('files/images/captcha/*') as $file) {
             $fileName = explode('.', basename($file));
             $fileName = (int) $fileName[0];
             if ($fileName + $param['expiration'] < $now) {
                 unlink($file);
             }
         }
     }
     //set the captcha name
     $captchaName = $now . '.png';
     //set the image path
     $imgPath = ROOT . $config['path'];
     $fullImgPath = str_replace(DIRECTORY_SEPARATOR, '/', $imgPath) . '/';
     $fullImgPath = str_replace('//', '/', $fullImgPath);
     $localPath = $config['path'] . '/';
     $localPath = str_replace('//', '/', $localPath);
     $imgTrueColor = imagecreatetruecolor($config['width'], $config['height']);
     //set the text color
     $textColor = imagecolorallocate($imgTrueColor, $colors['text'][0], $colors['text'][1], $colors['text'][2]);
     //set the background color
     $backgroundColor = imagecolorallocate($imgTrueColor, $colors['background'][0], $colors['background'][1], $colors['background'][2]);
     imagefilledrectangle($imgTrueColor, 0, 0, $param['width'], $param['height'], $backgroundColor);
     //set the font path
     $fontPath = str_replace(DIRECTORY_SEPARATOR, '/', ROOT . $config['font']);
     //create a text
     $bbox = imageftbbox(18, 0, $param['font'], $param['text']);
     $x = (imagesx($imgTrueColor) - $bbox[4]) / 2;
     $y = (imagesy($imgTrueColor) - $bbox[5]) / 2;
     imagettftext($imgTrueColor, $param['fontSize'], $param['angle'], $x, $y, $textColor, $fontPath, $param['text']);
     //create a png image
     imagepng($imgTrueColor, $fullImgPath . $captchaName);
     $result = ['path' => $localPath . $captchaName, 'fullPath' => $fullImgPath . $captchaName, 'name' => $captchaName];
     return $result;
 }
开发者ID:sew810i9,项目名称:Simple,代码行数:76,代码来源:Captcha.php


示例10: apply

 public function apply($resource)
 {
     // Find original dimensions:
     $imageWidth = imagesx($resource->image);
     $imageHeight = imagesy($resource->image);
     $fontbox = imageftbbox($this->settings->size, 0, realpath($this->settings->font), $this->settings->text);
     $width = $fontbox[4] - $fontbox[6];
     $width += $this->settings->padding * 2;
     $height = $fontbox[1] - $fontbox[7];
     $height += $this->settings->padding * 2;
     $image = imagecreatetruecolor($width, $height);
     $bg = new Colour($this->settings->bg);
     $fg = new Colour($this->settings->fg);
     $bg = $bg->allocate($image);
     $fg = $fg->allocate($image);
     imagesavealpha($image, true);
     imagesavealpha($resource->image, true);
     imagefill($image, 0, 0, $bg);
     imagefttext($image, $this->settings->size, 0, $this->settings->padding, $this->settings->size + $this->settings->padding, $fg, realpath($this->settings->font), $this->settings->text);
     $margin = $this->settings->margin;
     // Calculate X alignment:
     if ($this->settings->xalign == 'left') {
         $offsetX = $margin;
     } else {
         if ($this->settings->xalign == 'right') {
             $offsetX = round(max($imageWidth, $width) - min($imageWidth, $width)) - $margin;
         } else {
             $offsetX = 0 - round((min($imageWidth, $width) - max($imageWidth, $width)) / 2);
         }
     }
     // Invert X:
     //if ($imageWidth < $width) {
     //	$offsetX = 0 - $offsetX;
     //}
     // Calculate Y alignment:
     if ($this->settings->yalign == 'top') {
         $offsetY = $margin;
     } else {
         if ($this->settings->yalign == 'bottom') {
             $offsetY = round(max($imageHeight, $height) - min($imageHeight, $height)) - $margin;
         } else {
             $offsetY = 0 - round((min($imageHeight, $height) - max($imageHeight, $height)) / 2);
         }
     }
     // Invert Y:
     //if ($imageHeight < $height) {
     //	$offsetY = 0 - $offsetY;
     //}
     imagecopyresampled($resource->image, $image, $offsetX, $offsetY, 0, 0, $width, $height, $width, $height);
 }
开发者ID:psychoticmeowArchives,项目名称:Imaje,代码行数:50,代码来源:text.php


示例11: writeText

 /**
  * Writes text onto an image.
  *
  * @param WideImage_Image $image
  * @param mixed           $x     smart coordinate
  * @param mixed           $y     smart coordinate
  * @param string          $text
  * @param int             $angle Angle in degrees clockwise
  */
 public function writeText($image, $x, $y, $text, $angle = 0)
 {
     if ($image->isTrueColor()) {
         $image->alphaBlending(true);
     }
     $box = imageftbbox($this->size, $angle, $this->face, $text);
     $obox = ['left' => min($box[0], $box[2], $box[4], $box[6]), 'top' => min($box[1], $box[3], $box[5], $box[7]), 'right' => max($box[0], $box[2], $box[4], $box[6]) - 1, 'bottom' => max($box[1], $box[3], $box[5], $box[7]) - 1];
     $obox['width'] = abs($obox['left']) + abs($obox['right']);
     $obox['height'] = abs($obox['top']) + abs($obox['bottom']);
     $x = WideImage_Coordinate::fix($x, $image->getWidth(), $obox['width']);
     $y = WideImage_Coordinate::fix($y, $image->getHeight(), $obox['height']);
     $fixed_x = $x - $obox['left'];
     $fixed_y = $y - $obox['top'];
     imagettftext($image->getHandle(), $this->size, $angle, $fixed_x, $fixed_y, $this->color, $this->face, $text);
 }
开发者ID:dongilbert,项目名称:mautic,代码行数:24,代码来源:TTF.php


示例12: setResource

 protected function setResource()
 {
     $ftbbox = imageftbbox($this->fontsize, 0, $this->fontfile, $this->text, array('linespacing' => $this->linespacing));
     $bugfix = ceil($this->fontsize / 5);
     $ftboxwidth = abs($ftbbox[0] - $ftbbox[2]) + $bugfix;
     $ftboxheight = abs($ftbbox[1] - $ftbbox[7]);
     $blockwidth = $ftboxwidth + $this->blockpadding[1] + $this->blockpadding[3];
     $blockheight = $ftboxheight + $this->blockpadding[0] + $this->blockpadding[2];
     $texttempx = $this->blockpadding[3];
     $texttempy = $this->blockpadding[0] - $ftbbox[7] - 1;
     $anglerad = deg2rad($this->angle);
     $textradius = sqrt(pow(abs($texttempx - $blockwidth / 2), 2) + pow(abs($texttempy - $blockheight / 2), 2));
     $blockradius = sqrt(pow($blockwidth, 2) + pow($blockheight, 2)) / 2;
     $blockx[0] = cos(atan2($blockheight / 2, -$blockwidth / 2) - $anglerad) * $blockradius + $blockwidth / 2;
     $blockx[1] = cos(atan2($blockheight / 2, $blockwidth / 2) - $anglerad) * $blockradius + $blockwidth / 2;
     $blockx[2] = cos(atan2(-$blockheight / 2, $blockwidth / 2) - $anglerad) * $blockradius + $blockwidth / 2;
     $blockx[3] = cos(atan2(-$blockheight / 2, -$blockwidth / 2) - $anglerad) * $blockradius + $blockwidth / 2;
     $blocky[0] = sin(atan2($blockheight / 2, -$blockwidth / 2) - $anglerad) * $blockradius + $blockheight / 2;
     $blocky[1] = sin(atan2($blockheight / 2, $blockwidth / 2) - $anglerad) * $blockradius + $blockheight / 2;
     $blocky[2] = sin(atan2(-$blockheight / 2, $blockwidth / 2) - $anglerad) * $blockradius + $blockheight / 2;
     $blocky[3] = sin(atan2(-$blockheight / 2, -$blockwidth / 2) - $anglerad) * $blockradius + $blockheight / 2;
     $minblockx = min($blockx[0], $blockx[1], $blockx[2], $blockx[3]);
     $minblocky = min($blocky[0], $blocky[1], $blocky[2], $blocky[3]);
     $blockx[0] = (int) round($blockx[0] - $minblockx);
     $blockx[1] = (int) round($blockx[1] - $minblockx);
     $blockx[2] = (int) round($blockx[2] - $minblockx);
     $blockx[3] = (int) round($blockx[3] - $minblockx);
     $blocky[0] = (int) round($blocky[0] - $minblocky);
     $blocky[1] = (int) round($blocky[1] - $minblocky);
     $blocky[2] = (int) round($blocky[2] - $minblocky);
     $blocky[3] = (int) round($blocky[3] - $minblocky);
     $textx = (int) round(cos(atan2($texttempy - $blockheight / 2, $texttempx - $blockwidth / 2) - $anglerad) * $textradius + $blockwidth / 2 - $minblockx);
     $texty = (int) round(sin(atan2($texttempy - $blockheight / 2, $texttempx - $blockwidth / 2) - $anglerad) * $textradius + $blockheight / 2 - $minblocky);
     $this->width = max(abs($blockx[0] - $blockx[2]), abs($blockx[1] - $blockx[3]));
     $this->height = max(abs($blocky[0] - $blocky[2]), abs($blocky[1] - $blocky[3]));
     $this->resource = imagecreatetruecolor($this->width, $this->height);
     $transparentcolor = imagecolorallocatealpha($this->resource, 255, 255, 255, 127);
     imagefill($this->resource, 0, 0, $transparentcolor);
     if (isset($this->blockcolor) === true) {
         $blockcolor = imagecolorallocate($this->resource, $this->blockcolor['red'], $this->blockcolor['green'], $this->blockcolor['blue']);
         if (function_exists('imageantialias')) {
             imageantialias($this->resource, true);
         }
         imagefilledpolygon($this->resource, array($blockx[0], $blocky[0], $blockx[1], $blocky[1], $blockx[2], $blocky[2], $blockx[3], $blocky[3]), 4, $blockcolor);
     }
     $fontcolor = imagecolorallocate($this->resource, $this->fontcolor['red'], $this->fontcolor['green'], $this->fontcolor['blue']);
     imagefttext($this->resource, $this->fontsize, $this->angle, $textx, $texty, $fontcolor, $this->fontfile, $this->text, array('linespacing' => $this->linespacing));
 }
开发者ID:feeel1,项目名称:akina,代码行数:48,代码来源:LayerText.php


示例13: render

 /**
  * Outputs the Captcha image.
  *
  * @param   boolean  html output
  * @return  mixed
  */
 public function render()
 {
     // Init Challenge;
     $this->initChallenge();
     // Creates $this->image
     $this->createImage(Captcha::$config['background']);
     // Add a random gradient
     if (empty(Captcha::$config['background'])) {
         $color1 = imagecolorallocate($this->image, mt_rand(0, 100), mt_rand(0, 100), mt_rand(0, 100));
         $color2 = imagecolorallocate($this->image, mt_rand(0, 100), mt_rand(0, 100), mt_rand(0, 100));
         $this->gradientImage($color1, $color2);
     }
     // Add a few random circles
     for ($i = 0, $count = mt_rand(10, Captcha::$config['complexity'] * 3); $i < $count; $i++) {
         $color = imagecolorallocatealpha($this->image, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255), mt_rand(80, 120));
         $size = mt_rand(5, Captcha::$config['height'] / 3);
         imagefilledellipse($this->image, mt_rand(0, Captcha::$config['width']), mt_rand(0, Captcha::$config['height']), $size, $size, $color);
     }
     // Calculate character font-size and spacing
     $default_size = min(Captcha::$config['width'], Captcha::$config['height'] * 2) / strlen($this->response);
     $spacing = (int) (Captcha::$config['width'] * 0.9 / strlen($this->response));
     // Background alphabetic character attributes
     $color_limit = mt_rand(96, 160);
     $chars = 'ABEFGJKLPQRTVY';
     // Draw each Captcha character with varying attributes
     for ($i = 0, $strlen = strlen($this->response); $i < $strlen; $i++) {
         // Use different fonts if available
         $font = Captcha::$config['fontpath'] . Captcha::$config['fonts'][array_rand(Captcha::$config['fonts'])];
         $angle = mt_rand(-40, 20);
         // Scale the character size on image height
         $size = $default_size / 10 * mt_rand(8, 12);
         $box = imageftbbox($size, $angle, $font, $this->response[$i]);
         // Calculate character starting coordinates
         $x = $spacing / 4 + $i * $spacing;
         $y = Captcha::$config['height'] / 2 + ($box[2] - $box[5]) / 4;
         // Draw captcha text character
         // Allocate random color, size and rotation attributes to text
         $color = imagecolorallocate($this->image, mt_rand(150, 255), mt_rand(200, 255), mt_rand(0, 255));
         // Write text character to image
         imagefttext($this->image, $size, $angle, $x, $y, $color, $font, $this->response[$i]);
         // Draw "ghost" alphabetic character
         $text_color = imagecolorallocatealpha($this->image, mt_rand($color_limit + 8, 255), mt_rand($color_limit + 8, 255), mt_rand($color_limit + 8, 255), mt_rand(70, 120));
         $char = substr($chars, mt_rand(0, 14), 1);
         imagettftext($this->image, $size * 2, mt_rand(-45, 45), $x - mt_rand(5, 10), $y + mt_rand(5, 10), $text_color, $font, $char);
     }
     // Output
     return $this->renderImage();
 }
开发者ID:atlas1308,项目名称:testtesttestfarm,代码行数:54,代码来源:alpha.php


示例14: strlogo

/**
 *
 * @copyright  2010-2011 izend.org
 * @version    1
 * @link       http://www.izend.org
 */
function strlogo($name)
{
    $waspfile = ROOT_DIR . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'wasp.png';
    $fontfile = ROOT_DIR . DIRECTORY_SEPARATOR . 'font.ttf';
    $fontsize = 24.0;
    $bbox = imageftbbox($fontsize, 0, $fontfile, $name);
    $w = $bbox[2] + 48 + 5;
    $h = 40;
    $wasp = @imagecreatefrompng($waspfile) or die;
    $img = @imagecreatetruecolor($w, $h) or die;
    $bg = imagecolorallocate($img, 255, 255, 255);
    $fg = imagecolorallocate($img, 0x33, 0x33, 0x33);
    imagecolortransparent($img, $bg);
    imagefill($img, 0, 0, $bg);
    imagettftext($img, $fontsize, 0, 0, 30, $fg, $fontfile, $name);
    imagecopy($img, $wasp, $w - 48, 0, 0, 0, 48, 48);
    return $img;
}
开发者ID:RazorMarx,项目名称:izend,代码行数:24,代码来源:strlogo.php


示例15: setAnnotation

 function setAnnotation($Data, $DataDescription, $SerieName, $ValueName, $Caption, $R = 210, $G = 210, $B = 210)
 {
     /* Validate the Data and DataDescription array */
     $this->validateDataDescription("setLabel", $DataDescription);
     $this->validateData("setLabel", $Data);
     $ShadowFactor = 100;
     $C_Label = $this->AllocateColor($this->Picture, $R, $G, $B);
     $C_Shadow = $this->AllocateColor($this->Picture, $R - $ShadowFactor, $G - $ShadowFactor, $B - $ShadowFactor);
     $C_TextColor = $this->AllocateColor($this->Picture, 0, 0, 0);
     $Cp = 0;
     $Found = FALSE;
     foreach ($Data as $Key => $Value) {
         if ($Data[$Key][$DataDescription["Position"]] == $ValueName) {
             $NumericalValue = $Data[$Key][$SerieName];
             $Found = TRUE;
         }
         if (!$Found) {
             $Cp++;
         }
     }
     $XPos = $this->GArea_X1 + $this->GAreaXOffset + $this->DivisionWidth * $Cp + 2;
     $YPos = $this->GArea_Y2 - ($NumericalValue - $this->VMin) * $this->DivisionRatio;
     $Position = imageftbbox($this->FontSize, 0, $this->FontName, $Caption);
     $TextHeight = $Position[3] - $Position[5];
     $TextWidth = $Position[2] - $Position[0] + 2;
     $TextOffset = floor($TextHeight / 2);
     // Shadow
     /*
          $Poly = array($XPos+1,$YPos+1,$XPos + 9,$YPos - $TextOffset,$XPos + 8,$YPos + $TextOffset + 2);
          imagefilledpolygon($this->Picture,$Poly,3,$C_Shadow);
          $this->drawLine($XPos,$YPos+1,$XPos + 9,$YPos - $TextOffset - .2,$R-$ShadowFactor,$G-$ShadowFactor,$B-$ShadowFactor);
          $this->drawLine($XPos,$YPos+1,$XPos + 9,$YPos + $TextOffset + 2.2,$R-$ShadowFactor,$G-$ShadowFactor,$B-$ShadowFactor);
          $this->drawFilledRectangle($XPos + 9,$YPos - $TextOffset-.2,$XPos + 13 + $TextWidth,$YPos + $TextOffset + 2.2,$R-$ShadowFactor,$G-$ShadowFactor,$B-$ShadowFactor);
     
          // Label background
          $Poly = array($XPos,$YPos,$XPos + 8,$YPos - $TextOffset - 1,$XPos + 8,$YPos + $TextOffset + 1);
          imagefilledpolygon($this->Picture,$Poly,3,$C_Label);
          $this->drawLine($XPos-1,$YPos,$XPos + 8,$YPos - $TextOffset - 1.2,$R,$G,$B);
          $this->drawLine($XPos-1,$YPos,$XPos + 8,$YPos + $TextOffset + 1.2,$R,$G,$B);
          $this->drawFilledRectangle($XPos + 8,$YPos - $TextOffset - 1.2,$XPos + 12 + $TextWidth,$YPos + $TextOffset + 1.2,$R,$G,$B);
     */
     $this->drawLine($XPos - 2, $YPos, $XPos - 2, $YPos - 50, 200, 200, 200);
     imagettftext($this->Picture, $this->FontSize, 90, $XPos, $YPos - 50, $C_TextColor, $this->FontName, $Caption);
 }
开发者ID:robschmidt,项目名称:XProt,代码行数:44,代码来源:PChartExt.php


示例16: render

 /**
  * Outputs the Captcha image.
  *
  * @param   boolean  html output
  * @return  mixed
  */
 public function render()
 {
     // Init Challenge;
     $this->initChallenge();
     // Creates $this->image
     $this->createImage(Captcha::$config['background']);
     // Add a random gradient
     if (empty(Captcha::$config['background'])) {
         $color1 = imagecolorallocate($this->image, mt_rand(200, 255), mt_rand(200, 255), mt_rand(150, 255));
         $color2 = imagecolorallocate($this->image, mt_rand(200, 255), mt_rand(200, 255), mt_rand(150, 255));
         $this->gradientImage($color1, $color2);
     }
     // Add a few random lines
     for ($i = 0, $count = mt_rand(5, Captcha::$config['complexity'] * 4); $i < $count; $i++) {
         $color = imagecolorallocatealpha($this->image, mt_rand(0, 255), mt_rand(0, 255), mt_rand(100, 255), mt_rand(50, 120));
         imageline($this->image, mt_rand(0, Captcha::$config['width']), 0, mt_rand(0, Captcha::$config['width']), Captcha::$config['height'], $color);
     }
     // Calculate character font-size and spacing
     $default_size = min(Captcha::$config['width'], Captcha::$config['height'] * 2) / (strlen($this->response) + 1);
     $spacing = (int) (Captcha::$config['width'] * 0.9 / strlen($this->response));
     // Draw each Captcha character with varying attributes
     for ($i = 0, $strlen = strlen($this->response); $i < $strlen; $i++) {
         // Use different fonts if available
         $font = Captcha::$config['fontpath'] . Captcha::$config['fonts'][array_rand(Captcha::$config['fonts'])];
         // Allocate random color, size and rotation attributes to text
         $color = imagecolorallocate($this->image, mt_rand(0, 150), mt_rand(0, 150), mt_rand(0, 150));
         $angle = mt_rand(-40, 20);
         // Scale the character size on image height
         $size = $default_size / 10 * mt_rand(8, 12);
         $box = imageftbbox($size, $angle, $font, $this->response[$i]);
         // Calculate character starting coordinates
         $x = $spacing / 4 + $i * $spacing;
         $y = Captcha::$config['height'] / 2 + ($box[2] - $box[5]) / 4;
         // Write text character to image
         imagefttext($this->image, $size, $angle, $x, $y, $color, $font, $this->response[$i]);
     }
     // Output
     return $this->renderImage();
 }
开发者ID:atlas1308,项目名称:testtesttestfarm,代码行数:45,代码来源:basic.php


示例17: render

 public function render()
 {
     if (empty($this->response)) {
         $this->creat_code();
     }
     $this->image_create($this->config['background']);
     if (empty($this->config['background'])) {
         $color1 = imagecolorallocate($this->image, mt_rand(0, 100), mt_rand(0, 100), mt_rand(0, 100));
         $color2 = imagecolorallocate($this->image, mt_rand(0, 100), mt_rand(0, 100), mt_rand(0, 100));
         $this->image_gradient($color1, $color2);
     }
     for ($i = 0, $count = mt_rand(10, $this->config['complexity'] * 3); $i < $count; $i++) {
         $color = imagecolorallocatealpha($this->image, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255), mt_rand(80, 120));
         $size = mt_rand(5, $this->config['height'] / 3);
         imagefilledellipse($this->image, mt_rand(0, $this->config['width']), mt_rand(0, $this->config['height']), $size, $size, $color);
     }
     $default_size = min($this->config['width'], $this->config['height'] * 2) / strlen($this->response);
     $spacing = (int) ($this->config['width'] * 0.9 / strlen($this->response));
     $color_limit = mt_rand(96, 160);
     $chars = 'ABEFGJKLPQRTVY';
     for ($i = 0, $strlen = strlen($this->response); $i < $strlen; $i++) {
         $font = FW_PATH . 'resource' . DIRECTORY_SEPARATOR . 'font' . DIRECTORY_SEPARATOR . $this->config['fonts'][array_rand($this->config['fonts'])];
         $angle = mt_rand(-40, 20);
         $size = $default_size / 10 * mt_rand(8, 12);
         if (!function_exists('imageftbbox')) {
             throw new Exception('function imageftbbox not exist.');
         }
         $box = imageftbbox($size, $angle, $font, $this->response[$i]);
         $x = $spacing / 4 + $i * $spacing;
         $y = $this->config['height'] / 2 + ($box[2] - $box[5]) / 4;
         $color = imagecolorallocate($this->image, mt_rand(150, 255), mt_rand(200, 255), mt_rand(0, 255));
         imagefttext($this->image, $size, $angle, $x, $y, $color, $font, $this->response[$i]);
         $text_color = imagecolorallocatealpha($this->image, mt_rand($color_limit + 8, 255), mt_rand($color_limit + 8, 255), mt_rand($color_limit + 8, 255), mt_rand(70, 120));
         $char = substr($chars, mt_rand(0, 14), 1);
         imagettftext($this->image, $size * 1.4, mt_rand(-45, 45), $x - mt_rand(5, 10), $y + mt_rand(5, 10), $text_color, $font, $char);
     }
     return $this->image_render();
 }
开发者ID:hubs,项目名称:yuncms,代码行数:38,代码来源:Captcha.php


示例18: addWrappedTextToImage

 /**
  * Add text to an image, wrapping based on number of characters.
  */
 private function addWrappedTextToImage($imageHandle, $font, $text, $fontSize, $lineSpacing, $startY, $color)
 {
     //Get the total string length
     $textBox = imageftbbox($fontSize, 0, $font, $text);
     $totalTextWidth = abs($textBox[4] - $textBox[6]);
     //Determine how many lines we will need to break the text into
     $numLines = (double) $totalTextWidth / (double) $this->imagePrintableAreaWidth;
     $charactersPerLine = strlen($text) / $numLines;
     //Wrap based on the number of lines
     $lines = explode("\n", wordwrap($text, $charactersPerLine, "\n"));
     foreach ($lines as $line) {
         //Get the width of this line
         $lineBox = imageftbbox($fontSize, 0, $font, $line);
         $lineWidth = abs($lineBox[4] - $lineBox[6]);
         $lineHeight = abs($lineBox[3] - $lineBox[5]);
         //Get the starting position for the text
         $x = ($this->imageWidth - $lineWidth) / 2;
         $startY += $lineHeight;
         //Write the text to the image
         imagefttext($imageHandle, $fontSize, 0, $x, $startY, $color, $font, $line);
         $startY += $lineSpacing;
     }
     return $startY;
 }
开发者ID:victorfcm,项目名称:VuFind-Plus,代码行数:27,代码来源:DefaultCoverImageBuilder.php


示例19: draw

 public function draw($text)
 {
     $this->lineHeight = $this->lineHeight * $this->fontSize;
     $this->leading = $this->leading * $this->lineHeight - $this->lineHeight;
     $lines = array();
     // Split text explicitly into lines by \n, \r\n and \r
     $explicitLines = preg_split('/\\n|\\r\\n?/', $text);
     foreach ($explicitLines as $line) {
         // Check every line if it needs to be wrapped
         $words = explode(" ", $line);
         $line = $words[0];
         for ($i = 1; $i < count($words); $i++) {
             $box = imageftbbox($this->fontSize, 0, $this->fontFace, $line . " " . $words[$i]);
             if ($box[4] - $box[6] >= $this->box['width']) {
                 $lines[] = $line;
                 $line = $words[$i];
             } else {
                 $line .= " " . $words[$i];
             }
         }
         $lines[] = $line;
     }
     if ($this->debug == true) {
         imagefilledrectangle($this->im, $this->box['x'], $this->box['y'], $this->box['x'] + $this->box['width'], $this->box['y'] + $this->box['height'], imagecolorallocatealpha($this->im, rand(180, 255), rand(180, 255), rand(180, 255), 80));
     }
     $textHeight = count($lines) * $this->lineHeight;
     switch ($this->alignY) {
         case 'top':
             $yAlign = 0;
             break;
         case 'center':
             $yAlign = $this->box['height'] / 2 - $textHeight / 2;
             break;
         case 'bottom':
             $yAlign = $this->box['height'] - $textHeight;
             break;
     }
     $n = 0;
     foreach ($lines as $line) {
         $box = imageftbbox($this->fontSize, 0, $this->fontFace, $line);
         switch ($this->alignX) {
             case 'left':
                 $xAlign = 0;
                 break;
             case 'center':
                 $xAlign = ($this->box['width'] - ($box[2] - $box[0])) / 2;
                 break;
             case 'right':
                 $xAlign = $this->box['width'] - ($box[2] - $box[0]);
                 break;
         }
         $yShift = $this->lineHeight * $this->baseline;
         $xMOD = $this->box['x'] + $xAlign;
         $yMOD = $this->box['y'] + $yAlign + $yShift + $n * $this->lineHeight + $n * $this->leading;
         if ($this->debug == true) {
             imagefilledrectangle($this->im, $xMOD, $this->box['y'] + $yAlign + $n * $this->lineHeight + $n * $this->leading, $xMOD + ($box[2] - $box[0]), $this->box['y'] + $yAlign + $n * $this->lineHeight + $n * $this->leading + $this->lineHeight, $this->getColorIndex(array(rand(1, 180), rand(1, 180), rand(1, 180))));
         }
         if ($this->textShadow !== false) {
             imagefttext($this->im, $this->fontSize, 0, $xMOD + $this->textShadow['x'], $yMOD + $this->textShadow['y'], $this->textShadow['color'], $this->fontFace, $line);
         }
         imagefttext($this->im, $this->fontSize, 0, $xMOD, $yMOD, $this->fontColor, $this->fontFace, $line);
         $n++;
     }
 }
开发者ID:shapik2004,项目名称:album2,代码行数:64,代码来源:Box.php


示例20: calculate_font_box

 function calculate_font_box($text)
 {
     $font = $this->fonts_dir . $this->font;
     $rect = imageftbbox($this->font_size, 0, $font, $text);
     $minX = min(array($rect[0], $rect[2], $rect[4], $rect[6]));
     $maxX = max(array($rect[0], $rect[2], $rect[4], $rect[6]));
     $minY = min(array($rect[1], $rect[3], $rect[5], $rect[7]));
     $maxY = max(array($rect[1], $rect[3], $rect[5], $rect[7]));
     return array("left" => abs($minX) - 1, "top" => abs($minY) - 1, "width" => $maxX - $minX, "height" => $maxY - $minY, "box" => $rect);
 }
开发者ID:reactvideos,项目名称:Website,代码行数:10,代码来源:resizer.class.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP imagefttext函数代码示例发布时间:2022-05-15
下一篇:
PHP imagefontwidth函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap