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

PHP imageTTFBbox函数代码示例

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

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



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

示例1: watermarkImage

function watermarkImage($SourceFile, $WaterMarkText, $DestinationFile)
{
    list($width, $height) = getimagesize($SourceFile);
    $image_p = imagecreatetruecolor($width, $height);
    $image = imagecreatefromjpeg($SourceFile);
    imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width, $height);
    $black = imagecolorallocate($image_p, 255, 255, 255);
    $font = 'lib/arial.ttf';
    $font_size = 13;
    $font_angle = 0;
    $box = @imageTTFBbox($font_size, $font_angle, $font, $WaterMarkText);
    $textwidth = abs($box[4] - $box[0]);
    $textheight = abs($box[5] - $box[1]);
    $xcord = $width - 120 - $textwidth / 2 - 2;
    $ycord = $height - 20 + $textheight / 2;
    imagettftext($image_p, $font_size, 0, $xcord, $ycord, $black, $font, $WaterMarkText);
    if ($DestinationFile != '') {
        imagejpeg($image_p, $DestinationFile, 100);
    } else {
        header('Content-Type: image/jpeg');
        imagejpeg($image_p, null, 100);
    }
    imagedestroy($image);
    imagedestroy($image_p);
}
开发者ID:kimoudev,项目名称:winegate,代码行数:25,代码来源:imageManipulation.php


示例2: 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


示例3: generateVerticalString

function generateVerticalString($string, $id, $doc, $invert = false)
{
    $string = '     ' . iconv('UTF-8', 'macintosh', $string);
    $doc_exploded = explode(DCTL_RESERVED_INFIX, $doc);
    $db_collection = isset($doc_exploded[0]) ? $doc_exploded[0] : '';
    $dest = '';
    $dest .= DCTL_DBCTL_BASEPATH . 'coste';
    if (!is_dir($dest)) {
        mkdir($dest, CHMOD);
    }
    @chmod($dest, CHMOD);
    $dest .= SYS_PATH_SEP . $doc . '-' . $id . '.gif';
    $font = 'font/Georgia.ttf';
    $fontsize = 12;
    $bolder = false;
    $fontangle = 0;
    $rotateangle = 90;
    $x_cord = 0;
    $y_cord = $fontsize * 2;
    $box = @imageTTFBbox($fontsize, $fontangle, $font, $string);
    $g_iw = abs($box[4] - $box[0]) + $fontsize + $x_cord;
    $g_ih = $fontsize * 2.3;
    $img_dst = imagecreatetruecolor($g_iw, $g_ih);
    $fg = imagecolorallocate($img_dst, 0, 0, 0);
    $bg = imagecolorallocate($img_dst, 127, 127, 127);
    if ($invert) {
        $bg = $fg;
        $fg = imagecolorallocate($img_dst, 255, 255, 255);
    }
    imagecolortransparent($img_dst, $bg);
    imagefilledrectangle($img_dst, 0, 0, $g_iw, $g_ih, $bg);
    if ($bolder) {
        imagettftext($img_dst, $fontsize, $fontangle, $x_cord + 2, $y_cord + 2, $bg, $font, $string);
        $_x = array(1, 0, 1, 0, -1, -1, 1, 0, -1);
        $_y = array(0, -1, -1, 0, 0, -1, 1, 1, 1);
        for ($n = 0; $n <= 8; $n++) {
            imagettftext($img_dst, $fontsize, $fontangle, $x_cord + $_x[$n], $y_cord + $_y[$n], $fg, $font, $string);
        }
    } else {
        //		imagettftext($img_dst, $fontsize, $fontangle, $x_cord+1, $y_cord+1, $bg, $font, $string);
        imagettftext($img_dst, $fontsize, $fontangle, $x_cord, $y_cord, $fg, $font, $string);
    }
    // 	$icon_src = imagecreatefromgif(DCTL_IMAGES.'box_opened.gif');
    // 	imagecopy($img_dst, $icon_src, 3, 9, 0, 0, 20, 20);
    $img_dst = imagerotate($img_dst, $rotateangle, 0);
    imagegif($img_dst, $dest);
    imagedestroy($img_dst);
}
开发者ID:noveopiu,项目名称:dCTL,代码行数:48,代码来源:functions.inc.php


示例4: getTextSize

 private function getTextSize($fontSize, $angle, $font, $text)
 {
     // *** Define box (so we can get the width)
     $box = @imageTTFBbox($fontSize, $angle, $font, $text);
     // ***  Get width of text from dimensions
     $textWidth = abs($box[4] - $box[0]);
     // ***  Get height of text from dimensions (should also be same as $fontSize)
     $textHeight = abs($box[5] - $box[1]);
     return array('height' => $textHeight, 'width' => $textWidth);
 }
开发者ID:WebPassions,项目名称:2015,代码行数:10,代码来源:php_image_magician.php


示例5: renderPlaceholder

 static function renderPlaceholder($width, $height, $bg_color = false, $text_color = false, $icon_path = false, $text_string = false)
 {
     // Check size
     $width = $width > 2000 ? 2000 : $width;
     $height = $height > 2000 ? 2000 : $height;
     // Check colors
     $bg_color = !$bg_color && $bg_color != "000" && $bg_color != "000000" ? "CCCCCC" : ltrim($bg_color, "#");
     $text_color = !$text_color && $text_color != "000" && $text_color != "000000" ? "666666" : ltrim($text_color, "#");
     // Set text
     $text = $text_string;
     if ($icon_path) {
         $text = "";
     } else {
         if (!$text_string) {
             $text = $width . " X " . $height;
         }
     }
     // Create image
     $image = imagecreatetruecolor($width, $height);
     // Build rgba from hex
     $bg_color = imagecolorallocate($image, base_convert(substr($bg_color, 0, 2), 16, 10), base_convert(substr($bg_color, 2, 2), 16, 10), base_convert(substr($bg_color, 4, 2), 16, 10));
     $text_color = imagecolorallocate($image, base_convert(substr($text_color, 0, 2), 16, 10), base_convert(substr($text_color, 2, 2), 16, 10), base_convert(substr($text_color, 4, 2), 16, 10));
     // Fill image
     imagefill($image, 0, 0, $bg_color);
     /*
     		if ($icon_path) {
     $icon_size = getimagesize($icon_path);
     $icon_width = $icon_size[0];
     $icon_height = $icon_size[1];
     $icon_x = ($width - $icon_width) / 2;
     $icon_y = ($height - $icon_height) / 2;
     
     $icon = imagecreatefrompng($icon_path);
     imagesavealpha($icon, true);
     imagealphablending($icon, true);
     imagecopyresampled($image, $icon, $icon_x, $icon_y, 0, 0, $icon_width, $icon_height, $icon_width, $icon_height);
     */
     //} elseif ($text) {
     if ($text) {
         $font = ROOT_DIR . "vendor/nano_placeholder/arial.ttf";
         $fontsize = $width > $height ? $height / 15 : $width / 15;
         $textpos = imageTTFBbox($fontsize, 0, $font, $text);
         imagettftext($image, $fontsize, 0, ($width - $textpos[2]) / 2, ($height - $textpos[5]) / 2, $text_color, $font, $text);
     }
     // Serve image and die
     header("Content-Type: image/png");
     imagepng($image);
     imagedestroy($image);
     die;
 }
开发者ID:rajdsouza,项目名称:Formstone.it,代码行数:50,代码来源:nano_placeholder.php


示例6: create_image

/**
 * Generate a random string, and create a CAPTCHA image out of it
 */
function create_image()
{
    // generate pronouncable pass
    $pass = genPassword(5, 6);
    $font = './captcha.ttf';
    $maxsize = 50;
    $sizeVar = 25;
    $rotate = 20;
    $bgcol = 50;
    // + 50
    $bgtextcol = 80;
    // + 50
    $textcol = 205;
    // + 50
    // remember the pass
    $_SESSION["captcha"] = $pass;
    // calculate dimentions required for pass
    $box = @imageTTFBbox($maxsize, 0, $font, $pass);
    $minwidth = abs($box[4] - $box[0]);
    $minheight = abs($box[5] - $box[1]);
    // allow spacing for rotating letters
    $width = $minwidth + 100;
    $height = $minheight + rand(5, 15);
    // give some air for the letters to breathe
    // create initial image
    $image = ImageCreatetruecolor($width, $height);
    if (function_exists('imageantialias')) {
        imageantialias($image, true);
    }
    // define background color - never the same, close to black
    $clr_black = ImageColorAllocate($image, rand($bgcol, $bgcol + 30), rand($bgcol, $bgcol + 30), rand($bgcol, $bgcol + 30));
    imagefill($image, 0, 0, $clr_black);
    // calculate starting positions for letters
    $x = rand(10, 25);
    //($width / 2) - ($minwidth / 2);
    $xinit = $x;
    $y = $minheight - abs($box[1]) + ($height - $minheight) / 2;
    // fill the background with big letters, colored a bit lightly, to vary the bg.
    $bgx = $x / 2;
    $size = rand($maxsize - 10, $maxsize);
    for ($i = 0; $i < strlen($pass); $i++) {
        // modify color a bit
        $clr_white = ImageColorAllocate($image, rand($bgtextcol, $bgtextcol + 50), rand($bgtextcol, $bgtextcol + 50), rand($bgtextcol, $bgtextcol + 50));
        $angle = rand(0 - $rotate, $rotate);
        $letter = substr($pass, $i, 1);
        imagettftext($image, $size * 2, $angle, $bgx, $y, $clr_white, $font, $letter);
        list($x1, $a, $a, $a, $x2) = @imageTTFBbox($size, $angle, $font, $letter);
        $bgx += abs($x2 - $x1);
    }
    // for each letter, decide a color, decide a rotation, put it on the image,
    //     and figure out width to place next letter correctly
    for ($i = 0; $i < strlen($pass); $i++) {
        // modify color a bit
        $clr_white = ImageColorAllocate($image, rand($textcol, $textcol + 50), rand($textcol, $textcol + 50), rand($textcol, $textcol + 50));
        $angle = rand(0 - $rotate, $rotate);
        $letter = substr($pass, $i, 1);
        $size = rand($maxsize - $sizeVar, $maxsize);
        $tempbox = @imageTTFBbox($size, $angle, $font, $letter);
        $y = abs($tempbox[5] - $tempbox[1]) + ($height - abs($tempbox[5] - $tempbox[1])) / 2;
        imagettftext($image, $size, $angle, $x, $y, $clr_white, $font, $letter);
        $x += abs($tempbox[4] - $tempbox[0]);
    }
    // figure out final width (same space at the end as there was at the beginning)
    $width = $xinit + $x;
    // throw in some lines
    $clr_white = ImageColorAllocate($image, rand(160, 200), rand(160, 200), rand(160, 200));
    imagelinethick($image, rand(0, 10), rand(0, $height / 2), rand($width - 10, $width), rand($height / 2, $height), $clr_white, rand(1, 2));
    $clr_white = ImageColorAllocate($image, rand(160, 200), rand(160, 200), rand(160, 200));
    imagelinethick($image, rand($width / 2 - 10, $width / 2), rand($height / 2, $height), rand($width / 2 + 10, $width), rand(0, $height / 2), $clr_white, rand(1, 2));
    // generate final image by cropping initial image to the proper width,
    //     which we didn't know till now.
    $finalimage = ImageCreatetruecolor($width, $height);
    if (function_exists('imageantialias')) {
        imageantialias($finalimage, true);
    }
    imagecopy($finalimage, $image, 0, 0, 0, 0, $width, $height);
    // clear some memory
    imagedestroy($image);
    // dump image
    imagepng($finalimage);
    // clear some more memory
    imagedestroy($finalimage);
}
开发者ID:alanhaggai,项目名称:plogger,代码行数:86,代码来源:plog-captcha.php


示例7: wplan_imagettfJustifytext

/**
 * @name                    : makeImageF
 *
 * Function for create image from text with selected font. Justify text in image (0-Left, 1-Right, 2-Center).
 *
 * @param String $text     : String to convert into the Image.
 * @param String $font     : Font name of the text. Kip font file in same folder.
 * @param int    $Justify  : Justify text in image (0-Left, 1-Right, 2-Center).
 * @param int    $Leading  : Space between lines.
 * @param int    $W        : Width of the Image.
 * @param int    $H        : Hight of the Image.
 * @param int    $X        : x-coordinate of the text into the image.
 * @param int    $Y        : y-coordinate of the text into the image.
 * @param int    $fsize    : Font size of text.
 * @param array  $color    : RGB color array for text color.
 * @param array  $bgcolor  : RGB color array for background.
 *
 */
function wplan_imagettfJustifytext($text, $font = "pub/adg/Vera.ttf", $Justify = 2, $Leading = 0, $W = 0, $H = 0, $X = 0, $Y = 0, $fsize = 12, $color = array(0x0, 0x0, 0x0), $bgcolor = array(0xff, 0xff, 0xff))
{
    $angle = 0;
    $_bx = imageTTFBbox($fsize, 0, $font, $text);
    $s = split("[\n]+", $text);
    // Array of lines
    $nL = count($s);
    // Number of lines
    $W = $W == 0 ? abs($_bx[2] - $_bx[0]) : $W;
    // If Width not initialized by programmer then it will detect and assign perfect width.
    $H = $H == 0 ? abs($_bx[5] - $_bx[3]) + ($nL > 1 ? $nL * $Leading : 0) : $H;
    // If Height not initialized by programmer then it will detect and assign perfect height.
    $im = @imagecreate($W, $H) or die("Cannot Initialize new GD image stream");
    $background_color = imagecolorallocate($im, $bgcolor[0], $bgcolor[1], $bgcolor[2]);
    // RGB color background.
    $text_color = imagecolorallocate($im, $color[0], $color[1], $color[2]);
    // RGB color text.
    if ($Justify == 0) {
        //Justify Left
        imagettftext($im, $fsize, $angle, $X, $fsize, $text_color, $font, $text);
    } else {
        // Create alpha-nummeric string with all international characters - both upper- and lowercase
        $alpha = range("a", "z");
        $alpha = $alpha . strtoupper($alpha) . range(0, 9);
        // Use the string to determine the height of a line
        $_b = imageTTFBbox($fsize, 0, $font, $alpha);
        $_H = abs($_b[5] - $_b[3]);
        $__H = 0;
        for ($i = 0; $i < $nL; $i++) {
            $_b = imageTTFBbox($fsize, 0, $font, $s[$i]);
            $_W = abs($_b[2] - $_b[0]);
            //Defining the X coordinate.
            if ($Justify == 1) {
                $_X = $W - $_W;
            } else {
                $_X = abs($W / 2) - abs($_W / 2);
            }
            // Justify Center
            //Defining the Y coordinate.
            $__H += $_H;
            imagettftext($im, $fsize, $angle, $_X, $__H, $text_color, $font, $s[$i]);
            $__H += $Leading;
        }
    }
    return $im;
}
开发者ID:vladdu,项目名称:weekplan,代码行数:64,代码来源:wplan_util.php


示例8: _generate

 /**
  * Generates the barcode data
  * @param  string  $string  The string to encode
  * @param  integer $width   The width of the image
  * @param  integer $height  The height of the image
  * @return data
  */
 private function _generate($string, $width = NULL, $height = NULL)
 {
     //	Prep the string
     $string = strtoupper($string);
     $string = preg_replace('/[^A-Z0-9]/', '', $string);
     // --------------------------------------------------------------------------
     if (empty($string)) {
         $this->_set_error('String cannot be empty');
         return FALSE;
     }
     // --------------------------------------------------------------------------
     //	Create an oversized image first. We're going to generate the barcode with
     //	the text centered then crop it to fit into an image of the requested size.
     $_width = 2000;
     $_height = 60;
     $_img = imagecreate($_width, $_height);
     //	Define the colours
     $background = imagecolorallocate($_img, 255, 255, 255);
     $black = imagecolorallocate($_img, 0, 0, 0);
     // --------------------------------------------------------------------------
     //	Write the barcode text, centered
     $_fontsize = 36;
     $_font = $this->_font_barcode;
     $_box = @imageTTFBbox($_fontsize, 0, $_font, $string);
     $_textw = abs($_box[4] - $_box[0]);
     $_texth = abs($_box[5] - $_box[1]);
     $_xcord = $_width / 2 - $_textw / 2 - 2;
     $_ycord = $_texth;
     imagettftext($_img, $_fontsize, 0, $_xcord, $_ycord, $black, $_font, $string);
     $_barcode_height = $_texth;
     $_barcode_width = $_textw;
     $_barcode_xcord = $_xcord;
     // --------------------------------------------------------------------------
     //	Write the number text, also centered
     $_fontsize = 14;
     $_font = $this->_font_plain;
     $_box = @imageTTFBbox($_fontsize, 0, $_font, $string);
     $_textw = abs($_box[4] - $_box[0]);
     $_texth = abs($_box[5] - $_box[1]);
     $_xcord = $_width / 2 - $_textw / 2 - 2;
     $_ycord = $_barcode_height + $_texth;
     //	If the string contains a J or a Q then the positioning of the string is
     //	skewed, adjust accordingly.
     if (strpos($string, 'J') == FALSE && strpos($string, 'Q') == FALSE) {
         $_ycord += 5;
     }
     imagettftext($_img, $_fontsize, 0, $_xcord, $_ycord, $black, $_font, $string);
     $_text_height = $_texth;
     $_text_width = $_textw;
     $_text_xcord = $_xcord;
     // --------------------------------------------------------------------------
     //	Crop image to fit barcode; it seems there's a PHP bug however - image crop
     //	creates black lines when cropping: https://bugs.php.net/bug.php?id=67447
     $_options = array();
     $_options['height'] = $_height;
     $_options['width'] = max($_barcode_width, $_text_width);
     $_options['y'] = 0;
     $_options['x'] = min($_barcode_xcord, $_text_xcord);
     $_img_cropped = imagecrop($_img, $_options);
     imagedestroy($_img);
     // --------------------------------------------------------------------------
     //	If a user defined width or height has been supplied then resize to those
     //	dimensions.
     if (!is_null($width) || !is_null($height)) {
         $width = is_null($width) ? $_options['width'] : $width;
         $height = is_null($height) ? $_options['height'] : $height;
         $_width = min($width, $_options['width']);
         $_height = min($height, $_options['height']);
         $_img_user = imagecreate($width, $height);
         $background = imagecolorallocate($_img_user, 255, 255, 255);
         //	Copy and resample the image
         imagecopyresampled($_img_user, $_img_cropped, 0, 0, 0, 0, $_width, $_height, $_options['width'], $_options['height']);
         return $_img_user;
     } else {
         return $_img_cropped;
     }
 }
开发者ID:nailsapp,项目名称:module-barcode,代码行数:84,代码来源:Barcode_generator.php


示例9: writeLine

 protected function writeLine($image, $text)
 {
     $resource = $image->getAdapter()->getHolder();
     $box = imageTTFBbox($this->size, $this->angle, $this->font, $this->text);
     $textwidth = abs($box[4] - $box[0]) - 4;
     $textheight = abs($box[5] - $box[1]) - 4;
     $rgb = sscanf($this->color, '#%2x%2x%2x');
     $color = imagecolorallocate($resource, $rgb[0], $rgb[1], $rgb[2]);
     // disable alpha handling to enable font rendering
     imagealphablending($resource, true);
     imagettftext($resource, $this->size, $this->angle, $this->x, $this->y + $textheight, $color, $this->font, $this->text);
     return $image;
 }
开发者ID:kidh0,项目名称:tiagotrespach,代码行数:13,代码来源:sfImageTextGD.class.php


示例10: transform

 /**
  * Apply the transform to the sfImage object.
  *
  * @access protected
  * @param sfImage
  * @return sfImage
  */
 protected function transform(sfImage $image)
 {
     $resource = $image->getAdapter()->getHolder();
     $this->font = $this->font_dir . DIRECTORY_SEPARATOR . $this->font . '.ttf';
     $box = imageTTFBbox($this->size, $this->angle, $this->font, $this->text);
     $textwidth = abs($box[4] - $box[0]) - 4;
     $textheight = abs($box[5] - $box[1]) - 4;
     $rgb = sscanf($this->color, '#%2x%2x%2x');
     $color = imagecolorallocate($resource, $rgb[0], $rgb[1], $rgb[2]);
     imagettftext($resource, $this->size, $this->angle, $this->x, $this->y + $textheight, $color, $this->font, $this->text);
     return $image;
 }
开发者ID:nageshwar545,项目名称:PluginsKit,代码行数:19,代码来源:sfImageTextGD.class.php


示例11: placeholderImage

 static function placeholderImage($width, $height, $bg_color = false, $text_color = false, $icon_path = false, $text_string = false)
 {
     // Check size
     $width = $width > 2000 ? 2000 : $width;
     $height = $height > 2000 ? 2000 : $height;
     // Check colors
     $bg_color = !$bg_color && $bg_color != "000" && $bg_color != "000000" ? "CCCCCC" : ltrim($bg_color, "#");
     $text_color = !$text_color && $text_color != "000" && $text_color != "000000" ? "666666" : ltrim($text_color, "#");
     // Set text
     $text = $text_string;
     if ($icon_path) {
         $text = "";
     } else {
         if (!$text_string) {
             $text = $width . " X " . $height;
         }
     }
     // Create image
     $image = imagecreatetruecolor($width, $height);
     // Build rgba from hex
     $bg_color = imagecolorallocate($image, base_convert(substr($bg_color, 0, 2), 16, 10), base_convert(substr($bg_color, 2, 2), 16, 10), base_convert(substr($bg_color, 4, 2), 16, 10));
     $text_color = imagecolorallocate($image, base_convert(substr($text_color, 0, 2), 16, 10), base_convert(substr($text_color, 2, 2), 16, 10), base_convert(substr($text_color, 4, 2), 16, 10));
     // Fill image
     imagefill($image, 0, 0, $bg_color);
     // Add icon if provided
     if ($icon_path) {
         $icon_size = getimagesize($icon_path);
         $icon_width = $icon_size[0];
         $icon_height = $icon_size[1];
         $icon_x = ($width - $icon_width) / 2;
         $icon_y = ($height - $icon_height) / 2;
         $ext = strtolower(substr($icon_path, -3));
         if ($ext == "jpg" || $ext == "peg") {
             $icon = imagecreatefromjpeg($icon_path);
         } elseif ($ext == "gif") {
             $icon = imagecreatefromgif($icon_path);
         } else {
             $icon = imagecreatefrompng($icon_path);
         }
         imagesavealpha($icon, true);
         imagealphablending($icon, true);
         imagecopyresampled($image, $icon, $icon_x, $icon_y, 0, 0, $icon_width, $icon_height, $icon_width, $icon_height);
         // Add text if provided or default to size
     } elseif ($text) {
         $font = BigTree::path("inc/lib/fonts/arial.ttf");
         $fontsize = $width > $height ? $height / 15 : $width / 15;
         $textpos = imageTTFBbox($fontsize, 0, $font, $text);
         imagettftext($image, $fontsize, 0, ($width - $textpos[2]) / 2, ($height - $textpos[5]) / 2, $text_color, $font, $text);
     }
     // Serve image and die
     header("Content-Type: image/png");
     imagepng($image);
     imagedestroy($image);
     die;
 }
开发者ID:matthisamoto,项目名称:Graphfan,代码行数:55,代码来源:utils.php


示例12: _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


示例13: showGArea


//.........这里部分代码省略.........
         $percent = 2 * (450 + 18 * $nb_bar) / (18 * $nb_bar * 100);
     } else {
         $percent = 0.2;
     }
     $height = $percent * 450 + 18 * $nb_bar;
     $delta = 450 - $height;
     $height_tot = 450 + $height;
     $width_line = ($width - 45) / $nb;
     $index1 = 0;
     $index3 = 1;
     $step = ceil($nb / 20);
     //create image
     $image = imagecreatetruecolor($width, $height_tot);
     if ($show_graph) {
         //colors
         $palette = self::getPalette($nb_bar);
         $alphapalette = self::getPalette($nb_bar, "50");
         $darkerpalette = self::getDarkerPalette($nb_bar);
         //background
         $bg_color = $this->white;
         imagefilledrectangle($image, 0, 0, $width - 1, $height_tot - 1, $bg_color);
         //draw x-axis grey step line and value ticks
         $xstep = round(($height + $delta + 40) / 13);
         for ($i = 0; $i < 13; $i++) {
             $yaxis = $height_tot - 30 - $xstep * $i;
             //horizontal grey lines
             imageLine($image, 30, $yaxis, 30 + $width_line * ($nb - 1), $yaxis, $this->grey);
             //value ticks
             if ($i * $max / 12 < 10) {
                 $val = round($i * $max / 12, 1);
             } else {
                 $val = round($i * $max / 12);
             }
             $box = @imageTTFBbox($this->fontsize - 1, $this->fontangle, $this->font, $val);
             $textwidth = abs($box[4] - $box[0]);
             imagettftext($image, $this->fontsize - 1, $this->fontangle, 25 - $textwidth, $yaxis + 5, $this->darkgrey, $this->font, $val);
         }
         //draw y-axis vertical grey step line
         for ($i = 0; $i < $nb; $i++) {
             $xaxis = 30 + $width_line * $i;
             imageLine($image, $xaxis, $height - 40, $xaxis, $height_tot, $this->grey);
         }
         //draw y-axis
         imageLine($image, 30, $height - 40, 30, $height_tot - 25, $this->black);
         //draw y-axis
         imageLine($image, 30, $height_tot - 30, $width - 50, $height_tot - 30, $this->black);
         //create border on export
         if ($export) {
             imagerectangle($image, 0, 0, $width - 1, $height_tot - 1, $this->black);
         }
         //on png graph, no way to draw curved polygons, force area reports to be linear
         if ($area) {
             $spline = false;
         }
         //add title on export
         if ($export) {
             imagettftext($image, $this->fontsize + 1, $this->fontangle, 10, 20, $this->black, $this->font, $title);
         }
         //parse datas
         foreach ($datas as $label => $data) {
             $aCoords = array();
             $index2 = 0;
             $old_data = 0;
             //parse line
             foreach ($data as $subdata) {
                 //if first index, continue
开发者ID:geldarr,项目名称:hack-space,代码行数:67,代码来源:graphpng.class.php


示例14: textoverlay

 function textoverlay($text, $image_p, $new_width, $new_height)
 {
     $fontstyle = 5;
     // 1,2,3,4 or 5
     $fontcolor = $this->gvar['text_color'];
     $fontshadowcolor = $this->gvar['text_shadow_color'];
     $ttfont = isset($this->set['map_text_font']) ? $this->set['map_text_font'] : WP_PLUGIN_DIR . '/visitor-maps/vmfont.ttf';
     $fontsize = 11;
     # size for True Type Font $ttfont only (8-18 recommended)
     $textalign = $this->gvar['text_align'];
     $xmargin = 5;
     $ymargin = 0;
     if (!preg_match('#[a-z0-9]{6}#i', $fontcolor)) {
         $fontcolor = 'FFFFFF';
     }
     # default white
     if (!preg_match('#[a-z0-9]{6}#i', $fontshadowcolor)) {
         $fontshadowcolor = '808080';
     }
     # default grey
     $fcint = hexdec("#{$fontcolor}");
     $fsint = hexdec("#{$fontshadowcolor}");
     $fcarr = array("red" => 0xff & $fcint >> 0x10, "green" => 0xff & $fcint >> 0x8, "blue" => 0xff & $fcint);
     $fsarr = array("red" => 0xff & $fsint >> 0x10, "green" => 0xff & $fsint >> 0x8, "blue" => 0xff & $fsint);
     $fcolor = imagecolorallocate($image_p, $fcarr["red"], $fcarr["green"], $fcarr["blue"]);
     $fscolor = imagecolorallocate($image_p, $fsarr["red"], $fsarr["green"], $fsarr["blue"]);
     if ($ttfont != '') {
         # using ttf fonts
         $_b = imageTTFBbox($fontsize, 0, $ttfont, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789');
         $fontheight = abs($_b[7] - $_b[1]);
     } else {
         $font = $fontstyle;
         # using built in fonts, find alignment
         if ($font < 0 || $font > 5) {
             $font = 1;
         }
         $fontwidth = ImageFontWidth($font);
         $fontheight = ImageFontHeight($font);
     }
     $text = preg_replace("/\r/", '', $text);
     # wordwrap line if too many characters on one line
     if ($ttfont != '') {
         # array lines
         $lines = explode("\n", $text);
         $lines = $this->ttf_wordwrap($lines, $ttfont, $fontsize, floor($new_width - $xmargin * 2));
     } else {
         $maxcharsperline = floor(($new_width - $xmargin * 2) / $fontwidth);
         $text = wordwrap($text, $maxcharsperline, "\n", 1);
         # array lines
         $lines = explode("\n", $text);
     }
     # determine alignment
     $align = 'ul';
     # default upper left
     if ($textalign == 'll') {
         $align = 'll';
     }
     // lowerleft
     if ($textalign == 'ul') {
         $align = 'ul';
     }
     // upperleft
     if ($textalign == 'lr') {
         $align = 'lr';
     }
     // lowerright
     if ($textalign == 'ur') {
         $align = 'ur';
     }
     // upperright
     if ($textalign == 'c') {
         $align = 'c';
     }
     // center
     if ($textalign == 'ct') {
         $align = 'ct';
     }
     // centertop
     if ($textalign == 'cb') {
         $align = 'cb';
     }
     // centerbottom
     # find start position for each text position type
     if ($align == 'ul') {
         $x = $xmargin;
         $y = $ymargin;
     }
     if ($align == 'll') {
         $x = $xmargin;
         $y = $new_height - ($fontheight + $ymargin);
         $lines = array_reverse($lines);
     }
     if ($align == 'ur') {
         $y = $ymargin;
     }
     if ($align == 'lr') {
         $x = $xmargin;
         $y = $new_height - ($fontheight + $ymargin);
         $lines = array_reverse($lines);
     }
//.........这里部分代码省略.........
开发者ID:kraczo,项目名称:pracowniapizzy,代码行数:101,代码来源:class-wo-worldmap.php


示例15: ImageCreateTrueColor

$im = ImageCreateTrueColor($imgmaxxroom, $imgmaxyroom);
$black = ImageColorAllocate($im, 0, 0, 0);
$bg1p = ImageColorAllocate($im, $bg1_R, $bg1_G, $bg1_B);
$bg2p = ImageColorAllocate($im, $buttonBg_R, $buttonBg_G, $buttonBg_B);
$bg3p = ImageColorAllocate($im, $fontcol_grap_R, $fontcol_grap_G, $fontcol_grap_B);
$white = ImageColorAllocate($im, 255, 255, 255);
$gray = ImageColorAllocate($im, 133, 133, 133);
$red = ImageColorAllocate($im, 255, 0, 0);
$green = ImageColorAllocate($im, 0, 255, 0);
$yellow = ImageColorAllocate($im, 255, 255, 0);
$orange = ImageColorAllocate($im, 255, 230, 25);
if ($room == $showroom) {
    $imgcolor = $bg1p;
    $txtcolor = $white;
} else {
    $imgcolor = $bg2p;
    $txtcolor = $bg3p;
}
ImageFill($im, 0, 0, $imgcolor);
ImageRectangle($im, 0, 0, $imgmaxxroom - 1, $imgmaxyroom - 1, $white);
###ttf
$text = $room;
$box = @imageTTFBbox($roomfontsizetitel, 0, $fontttfb, $text);
$textwidth = abs($box[4] - $box[0]);
$textheight = abs($box[5] - $box[1]);
$xcord = $imgmaxxroom / 2 - $textwidth / 2 - 2;
#	$ycord = ($imgmaxyroom/2)+($textheight/2);
$ycord = $imgmaxyroom / 3 + $roomfontsizetitel;
ImageTTFText($im, $roomfontsizetitel, 0, $xcord, $ycord, $txtcolor, $fontttfb, $text);
header("Content-type: image/png");
imagePng($im);
开发者ID:DirtyNative,项目名称:fhem-mirror,代码行数:31,代码来源:room.php


示例16: abs

$fontsize = 7;
$box = @imageTTFBbox($fontsize, 0, $fontttfb, $text);
$textwidth = abs($box[4] - $box[0]);
$textheight = abs($box[5] - $box[1]);
$xcord = $imgmaxxfs20 / 2 - $textwidth / 2 - 2;
$ycord = $imgmaxyfs20 / 2 + 23;
ImageTTFText($im, $fontsize, 0, $xcord, $ycord, $txtcolor, $fontttfb, $text);
$text = $date_button;
$box = @imageTTFBbox($fontsize, 0, $fontttf, $text);
$textwidth = abs($box[4] - $box[0]);
$textheight = abs($box[5] - $box[1]);
#$xcord = ($imgmaxxfs20/2)-($textwidth/2)+53;
$xcord = $imgmaxxfs20 - $textwidth - 2;
$ycord = $imgmaxyfs20 / 2 + 33;
ImageTTFText($im, $fontsize, 0, $xcord, $ycord, $txtcolor, $fontttf, $text);
$text = $time_button;
$box = @imageTTFBbox($fontsize, 0, $fontttf, $text);
$textwidth = abs($box[4] - $box[0]);
$textheight = abs($box[5] - $box[1]);
#$xcord = ($imgmaxxfs20/2)-($textwidth/2)-58;
$xcord = 3;
$ycord = $imgmaxyfs20 / 2 + 33;
ImageTTFText($im, $fontsize, 0, $xcord, $ycord, $txtcolor, $fontttf, $text);
$txtcolor = $bg3p;
ImageTTFText($im, $fs20fontsizetitel, 0, 5, 15, $txtcolor, $fontttfb, $drawfs20);
if ($room != '' and $roomname == '1') {
    ImageTTFText($im, 7, 0, 5, 26, $txtcolor, $fontttf, $txtroom . $room);
}
imagePng($im, $savefile);
header("Content-type: image/png");
imagePng($im);
开发者ID:holack,项目名称:fhemack,代码行数:31,代码来源:fs20.php


示例17: displayMessage

 /**
  * Diplay a given message as png image 
  *
  * @param String $msg Message to display
  *
  * @return Void
  */
 public function displayMessage($msg)
 {
     //ttf from jpgraph
     $ttf = new TTF();
     Chart_TTFFactory::setUserFont($ttf);
     //Calculate the baseline
     // @see http://www.php.net/manual/fr/function.imagettfbbox.php#75333
     //this should be above baseline
     $test2 = "H";
     //some of these additional letters should go below it
     $test3 = "Hjgqp";
     //get the dimension for these two:
     $box2 = imageTTFBbox(10, 0, $ttf->File(FF_USERFONT), $test2);
     $box3 = imageTTFBbox(10, 0, $ttf->File(FF_USERFONT), $test3);
     $baseline = abs(abs($box2[5]) + abs($box2[1]) - (abs($box3[5]) + abs($box3[1])));
     $bbox = imageTTFBbox(10, 0, $ttf->File(FF_USERFONT), $msg);
     if ($im = @imagecreate($bbox[2] - $bbox[6], $bbox[3] - $bbox[5])) {
         $backgroundColor = imagecolorallocate($im, 255, 255, 255);
         $textColor = imagecolorallocate($im, 64, 64, 64);
         imagettftext($im, 10, 0, 0, $bbox[3] - $bbox[5] - $baseline, $textColor, $ttf->File(FF_USERFONT), $msg);
         header("Content-type: image/png");
         imagepng($im);
         imagedestroy($im);
     }
 }
开发者ID:pombredanne,项目名称:tuleap,代码行数:32,代码来源:Chart.class.php


示例18: transform

 /**
  * Apply the transform to the sfImage object.
  *
  * @access protected
  * @param sfImage
  * @return sfImage
  */
 protected function transform(sfImage $image)
 {
     $resource = $image->getAdapter()->getHolder();
     $this->font = $this->font_dir . DIRECTORY_SEPARATOR . $this->font . '.ttf';
     $box = imageTTFBbox($this->size, $this->angle, $this->font, $this->text);
     $textwidth = abs($box[4] - $box[0]);
     $textheight = abs($box[5] - $box[1]);
     $rgb = sscanf($this->color, '#%2x%2x%2x');
     $color = imagecolorallocate($resource, $rgb[0], $rgb[1], $rgb[2]);
     // disable alpha handling to enable font rendering
     imagealphablending($resource, true);
     // textheight nem korrekt, mert ékezetes és száras betűk esetén ez nagyobb lesz, mint a font méret
     imagettftext($resource, $this->size, $this->angle, $this->x, $this->y + $this->size, $color, $this->font, $this->text);
     return $image;
 }
开发者ID:hgabka,项目名称:imagerepo-bundle,代码行数:22,代码来源:ImageText.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP imageText函数代码示例发布时间:2022-05-15
下一篇:
PHP imageString函数代码示例发布时间: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