当前位置: 首页>>代码示例>>PHP>>正文


PHP ImageTTFBBox函数代码示例

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


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

示例1: _createTTFImage

 protected static function _createTTFImage($txt)
 {
     if (!self::getInstance()) {
         return NULL;
     }
     /* else */
     $bounds = ImageTTFBBox(self::$_font["size"], 0, self::$_font["family"], "W");
     $fontHeight = abs($bounds[7] - $bounds[1]);
     $bounds = ImageTTFBBox(self::$_font["size"], 0, self::$_font["family"], $txt);
     $width = abs($bounds[4] - $bounds[6]);
     $height = abs($bounds[7] - $bounds[1]);
     $offsetY = $fontHeight;
     $offsetX = 0;
     $image = imagecreate($width + self::$_padding * 2 + 1, $height + self::$_padding * 2 + 1);
     $background = ImageColorAllocate($image, self::$_backgroundColor["color"]["red"], self::$_backgroundColor["color"]["green"], self::$_backgroundColor["color"]["blue"]);
     $foreground = ImageColorAllocate($image, self::$_font["color"]["red"], self::$_font["color"]["green"], self::$_font["color"]["blue"]);
     if (self::$_transparent) {
         ImageColorTransparent($image, $background);
     }
     ImageInterlace($image, false);
     // render the image
     ImageTTFText($image, self::$_font["size"], 0, $offsetX + self::$_padding, $offsetY + self::$_padding, $foreground, self::$_font["family"], $txt);
     // print_r( self::$_font );
     return $image;
 }
开发者ID:nirwander,项目名称:holkinsengine,代码行数:25,代码来源:textImg.class.php

示例2: JPGText

function JPGText($str, $fontname, $fontsize, $backcol, $txtcol)
{
    global $layout;
    Header("Last-Modified: " . gmDate("D, d M Y H:i:s", Time()) . " GMT");
    Header("Expires: " . gmDate("D, d M Y H:i:s", Time() - 3601) . " GMT");
    Header("Pragma: no-cache");
    Header("Cache-control: no-cache");
    Header("Content-Type: image/jpeg");
    $a = ImageTTFBBox($fontsize, 0, $fontname, $str);
    $width = $a[2] + 4;
    $bla = get_maximum_height($fontname, $fontsize);
    $height = $bla[0] + 3;
    $bl = $bla[1];
    $im = ImageCreate($width, $height);
    $bgcol = ImageColorAllocate($im, $backcol['red'], $backcol['green'], $backcol['blue']);
    $fgcol = ImageColorAllocate($im, $txtcol['red'], $txtcol['green'], $txtcol['blue']);
    if (!function_exists(imagegif)) {
        imageTTFText($im, $fontsize, 0, 2, $bl + $fontsize / 6 + 2, $fgcol, $fontname, $str);
        imagejpeg($im, "", 80);
    } else {
        ImageColorTransparent($im, $bgcol);
        imageTTFText($im, $fontsize, 0, 2, $bl + $fontsize / 6 + 2, $fgcol, $fontname, $str);
        imagegif($im);
    }
    ImageDestroy($im);
}
开发者ID:netzhuffle,项目名称:mainchat,代码行数:26,代码来源:userinfo.php

示例3: TextToImage

function TextToImage($text, $separate_line_after_chars = 40, $size = 24, $rotate = 0, $padding = 2, $transparent = true, $color = array('red' => 0, 'grn' => 0, 'blu' => 0), $bg_color = array('red' => 255, 'grn' => 255, 'blu' => 255))
{
    $amount_of_lines = ceil(strlen($text) / $separate_line_after_chars);
    $x = explode("\n", $text);
    $final = '';
    foreach ($x as $key => $value) {
        $returnes = '';
        do {
            $first_part = mb_substr($value, 0, $separate_line_after_chars, 'utf-8');
            $value = "\n" . mb_substr($value, $separate_line_after_chars, null, 'utf-8');
            $returnes .= $first_part;
        } while (mb_strlen($value, 'utf-8') > $separate_line_after_chars);
        $final .= $returnes . "\n";
    }
    $text = $final;
    $width = $height = $offset_x = $offset_y = 0;
    $font = $_SERVER['DOCUMENT_ROOT'] . '/assets/css/journal.ttf';
    // get the font height.
    $bounds = ImageTTFBBox($size, $rotate, $font, "W");
    if ($rotate < 0) {
        $font_height = abs($bounds[7] - $bounds[1]);
    } elseif ($rotate > 0) {
        $font_height = abs($bounds[1] - $bounds[7]);
    } else {
        $font_height = abs($bounds[7] - $bounds[1]);
    }
    // determine bounding box.
    $bounds = ImageTTFBBox($size, $rotate, $font, $text);
    if ($rotate < 0) {
        $width = abs($bounds[4] - $bounds[0]);
        $height = abs($bounds[3] - $bounds[7]);
        $offset_y = $font_height;
        $offset_x = 0;
    } elseif ($rotate > 0) {
        $width = abs($bounds[2] - $bounds[6]);
        $height = abs($bounds[1] - $bounds[5]);
        $offset_y = abs($bounds[7] - $bounds[5]) + $font_height;
        $offset_x = abs($bounds[0] - $bounds[6]);
    } else {
        $width = abs($bounds[4] - $bounds[6]);
        $height = abs($bounds[7] - $bounds[1]);
        $offset_y = $font_height;
        $offset_x = 0;
    }
    $image = imagecreate($width + $padding * 2 + 1, $height + $padding * 2 + 1);
    $background = ImageColorAllocate($image, $bg_color['red'], $bg_color['grn'], $bg_color['blu']);
    $foreground = ImageColorAllocate($image, $color['red'], $color['grn'], $color['blu']);
    if ($transparent) {
        ImageColorTransparent($image, $background);
    }
    ImageInterlace($image, true);
    // render the image
    ImageTTFText($image, $size, $rotate, $offset_x + $padding, $offset_y + $padding, $foreground, $font, $text);
    imagealphablending($image, true);
    imagesavealpha($image, true);
    // output PNG object.
    imagePNG($image, 'signature.png');
    imagedestroy($image);
}
开发者ID:kevwaddell,项目名称:tlw-echosign,代码行数:59,代码来源:text-to-img.php

示例4: draw

 function draw()
 {
     $width = 0;
     $height = 0;
     $offset_x = 0;
     $offset_y = 0;
     $bounds = array();
     $image = "";
     // get the font height.
     $bounds = ImageTTFBBox($this->size, $this->rot, $this->font, "W");
     if ($this->rot < 0) {
         $font_height = abs($bounds[7] - $bounds[1]);
     } else {
         if ($this->rot > 0) {
             $font_height = abs($bounds[1] - $bounds[7]);
         } else {
             $font_height = abs($bounds[7] - $bounds[1]);
         }
     }
     // determine bounding box.
     $bounds = ImageTTFBBox($this->size, $this->rot, $this->font, $this->msg);
     if ($this->rot < 0) {
         $width = abs($bounds[4] - $bounds[0]);
         $height = abs($bounds[3] - $bounds[7]);
         $offset_y = $font_height;
         $offset_x = 0;
     } else {
         if ($this->rot > 0) {
             $width = abs($bounds[2] - $bounds[6]);
             $height = abs($bounds[1] - $bounds[5]);
             $offset_y = abs($bounds[7] - $bounds[5]) + $font_height;
             $offset_x = abs($bounds[0] - $bounds[6]);
         } else {
             $width = abs($bounds[4] - $bounds[6]);
             $height = abs($bounds[7] - $bounds[1]);
             $offset_y = $font_height;
             $offset_x = 0;
         }
     }
     $image = imagecreate($width + $this->padX * 2 + 1, $height + $this->padY * 2 + 1);
     $background = ImageColorAllocate($image, $this->bg_red, $this->bg_grn, $this->bg_blu);
     $foreground = ImageColorAllocate($image, $this->red, $this->grn, $this->blu);
     if ($this->transparent) {
         ImageColorTransparent($image, $background);
     }
     ImageInterlace($image, false);
     // render the image
     ImageTTFText($image, $this->size, $this->rot, $offset_x + $this->padX, $offset_y + $this->padY, $foreground, $this->font, $this->msg);
     // output PNG object.
     imagePNG($image);
 }
开发者ID:pankajsinghjarial,项目名称:SYLC-AMERICAN,代码行数:51,代码来源:toImage.php

示例5: pc_ImageTTFCenter

function pc_ImageTTFCenter($image, $text, $font, $size)
{
    // find the size of the image
    $xi = ImageSX($image);
    $yi = ImageSY($image);
    // find the size of the text
    $box = ImageTTFBBox($size, 0, $font, $text);
    $xr = abs(max($box[2], $box[4]));
    $yr = abs(max($box[5], $box[7]));
    // compute centering
    $x = intval(($xi - $xr) / 2);
    $y = intval(($yi + $yr) / 2);
    return array($x, $y);
}
开发者ID:moodboom,项目名称:Reusable,代码行数:14,代码来源:pugsly_pdu.php

示例6: draw

 public function draw()
 {
     $font = $this->_getFont();
     $htexte = 'dg' . $this->getText();
     $hdim = ImageTTFBBox($this->getSize(), 0, $font, $htexte);
     $wdim = ImageTTFBBox($this->getSize(), 0, $font, $this->getText());
     $dx = max($wdim[2], $wdim[4]) - min($wdim[0], $wdim[6]) + ceil($this->getSize() / 8);
     $dy = max($hdim[1], $hdim[3]) - min($hdim[5], $hdim[7]) + ceil($this->getSize() / 8);
     $img = ImageCreate(max($dx, 1), max($dy, 1));
     $noir = ImageColorAllocate($img, 0, 0, 0);
     $blanc = ImageColorAllocate($img, 255, 255, 255);
     $blanc = imagecolortransparent($img, $blanc);
     ImageFilledRectangle($img, 0, 0, $dx, $dy, $blanc);
     ImageTTFText($img, $this->getSize(), $angle, 0, -min($hdim[5], $hdim[7]), $noir, $font, $this->getText());
     return $img;
 }
开发者ID:nike-17,项目名称:formula-publish,代码行数:16,代码来源:Text.php

示例7: rw_cryptx_init_tinyurl

function rw_cryptx_init_tinyurl()
{
    global $cryptX_var;
    $url = $_SERVER['REQUEST_URI'];
    $params = explode('/', $url);
    if (count($params) > 1) {
        $tiny_url = $params[count($params) - 2];
        if ($tiny_url == md5(get_bloginfo('url'))) {
            $font = $cryptX_var['c2i_font'];
            $msg = $params[count($params) - 1];
            $size = $cryptX_var['c2i_fontSize'];
            $pad = 1;
            $transparent = 1;
            $red = hexdec(substr($cryptX_var['c2i_fontRGB'], 0, 2));
            $grn = hexdec(substr($cryptX_var['c2i_fontRGB'], 2, 2));
            $blu = hexdec(substr($cryptX_var['c2i_fontRGB'], 4, 2));
            $bg_red = 255 - $red;
            $bg_grn = 255 - $grn;
            $bg_blu = 255 - $blu;
            $width = 0;
            $height = 0;
            $offset_x = 0;
            $offset_y = 0;
            $bounds = array();
            $image = "";
            $bounds = ImageTTFBBox($size, 0, $font, "W");
            $font_height = abs($bounds[7] - $bounds[1]);
            $bounds = ImageTTFBBox($size, 0, $font, $msg);
            $width = abs($bounds[4] - $bounds[6]);
            $height = abs($bounds[7] - $bounds[1]);
            $offset_y = $font_height + abs(($height - $font_height) / 2) - 1;
            $offset_x = 0;
            $image = imagecreatetruecolor($width + $pad * 2, $height + $pad * 2);
            imagesavealpha($image, true);
            $foreground = ImageColorAllocate($image, $red, $grn, $blu);
            $background = imagecolorallocatealpha($image, 0, 0, 0, 127);
            imagefill($image, 0, 0, $background);
            ImageTTFText($image, $size, 0, $offset_x + $pad, $offset_y + $pad, $foreground, $font, $msg);
            Header("Content-type: image/png");
            imagePNG($image);
            die;
        }
    }
}
开发者ID:adisonc,项目名称:MaineLearning,代码行数:44,代码来源:functions.php

示例8: process

 function process()
 {
     global $CONFIG;
     $matches = array();
     if (!preg_match("/^([0-9a-zA-Z]+)\\.png\$/", $this->file, $matches)) {
         error_exit("Invalid image request for {$this->file}");
     }
     $code = $matches[1];
     $basepath = trim($CONFIG['paths']['base_url'], '/') . '/image/pins';
     $basefile = trim($CONFIG['paths']['file_path'], '/') . '/image/pins';
     $localfile = "{$basefile}/{$code}.png";
     if (file_exists($localfile)) {
         header("Location: http://{$_SERVER['HTTP_HOST']}/{$basepath}/{$code}.png");
     } else {
         if (!function_exists('ImageCreateFromPNG')) {
             header("Location: http://{$_SERVER['HTTP_HOST']}/{$basepath}/blank-marker.png");
         } else {
             $font = 'ttf-bitstream-vera/Vera';
             $size = 6;
             if (strlen($code) < 3) {
                 # Bigger image for number-only pins
                 $size = 8;
             }
             $im = ImageCreateFromPNG("{$basefile}/blank-marker.png");
             imageSaveAlpha($im, true);
             $tsize = ImageTTFBBox($size, 0, $font, $code);
             $textbg = ImageColorAllocate($im, 255, 119, 207);
             $black = ImageColorAllocate($im, 0, 0, 0);
             $dx = abs($tsize[2] - $tsize[0]);
             $dy = abs($tsize[5] - $tsize[3]);
             $x = (ImageSx($im) - $dx) / 2 + 1;
             $y = (ImageSy($im) - $dy) / 2;
             ImageTTFText($im, $size, 0, $x, $y, $black, $font, $code);
             header('Content-Type: image/png');
             ImagePNG($im);
             ImagePNG($im, $localfile);
             ImageDestroy($im);
         }
     }
     exit;
 }
开发者ID:roboshed,项目名称:leaguerunner,代码行数:41,代码来源:pins.php

示例9: textHeight

 /**
  * Get the height of a text.
  * 
  * Note! This method can give some peculiar results, since ImageTTFBBox() returns the total
  * bounding box of a text, where ImageTTF() writes the text on the baseline of the text, that
  * is 'g', 'p', 'q' and other letters that dig under the baseline will appear to have a larger
  * height than they actually do. Have a look at the tests/text.php test case - the first two
  * columns, 'left and 'center', both look alright, whereas the last column, 'right', appear
  * with a larger space between the first text and the second. This is because the total height
  * is actually smaller by exactly the number of pixels that the 'g' digs under the baseline.
  * Remove the 'g' from the text and they appear correct. 
  *
  * @param string $text The text to get the height of
  * @param bool $force Force the method to calculate the size
  * @return int The height of the text
  */
 function textHeight($text, $force = false)
 {
     if (isset($this->_font['file'])) {
         $angle = 0;
         if (isset($this->_font['angle'])) {
             $angle = $this->_font['angle'];
         }
         $linebreaks = substr_count($text, "\n");
         if ($angle == 0 && $force === false) {
             /*
              * if the angle is 0 simply return the size, due to different
              * heights for example for x-axis labels, making the labels
              * _not_ appear as written on the same baseline
              */
             return $this->_font['size'] + ($this->_font['size'] + 2) * $linebreaks;
         }
         $height = 0;
         $lines = explode("\n", $text);
         foreach ($lines as $line) {
             $bounds = ImageTTFBBox($this->_font['size'], $angle, $this->_font['file'], $line);
             $y0 = min($bounds[1], $bounds[3], $bounds[5], $bounds[7]);
             $y1 = max($bounds[1], $bounds[3], $bounds[5], $bounds[7]);
             $height += abs($y0 - $y1);
         }
         return $height + $linebreaks * 2;
     } else {
         if (isset($this->_font['vertical']) && $this->_font['vertical']) {
             $width = 0;
             $lines = explode("\n", $text);
             foreach ($lines as $line) {
                 $width = max($width, ImageFontWidth($this->_font['font']) * strlen($line));
             }
             return $width;
         } else {
             return ImageFontHeight($this->_font['font']) * (substr_count($text, "\n") + 1);
         }
     }
 }
开发者ID:chiranjeevjain,项目名称:agilebill,代码行数:54,代码来源:GD.php

示例10: ImageTTFText

ImageTTFText($im, $title_size, 0, $title_x, $title_y, $text_color, $font, $title);
// Draw a base line from a little above first bar location
// to a little below last
ImageLine($im, $x, $y - 5, $x, $height - 15, $line_color);
/*******************************************
  Draw data into graph 
*******************************************/
// Get each line of db data and draw corresponding bars
while ($row = mysql_fetch_object($result)) {
    if ($total_votes > 0) {
        $percent = intval(round($row->num_votes / $total_votes * 100));
    } else {
        $percent = 0;
    }
    // display percent for this value
    $percent_dimensions = ImageTTFBBox($main_size, 0, $font, $percent . '%');
    $percent_length = $percent_dimensions[2] - $percent_dimensions[0];
    ImageTTFText($im, $main_size, 0, $width - $percent_length - $text_indent, $y + $bar_height / 2, $percent_color, $font, $percent . '%');
    if ($total_votes > 0) {
        $right_value = intval(round($row->num_votes / $total_votes * 100));
    } else {
        $right_value = 0;
    }
    // length of bar for this value
    $bar_length = $x + $right_value * $bar_unit;
    // draw bar for this value
    ImageFilledRectangle($im, $x, $y - 2, $bar_length, $y + $bar_height, $bar_color);
    // draw title for this value
    ImageTTFText($im, $main_size, 0, $text_indent, $y + $bar_height / 2, $text_color, $font, "{$row->candidate}");
    // draw outline showing 100%
    ImageRectangle($im, $bar_length + 1, $y - 2, $x + 100 * $bar_unit, $y + $bar_height, $line_color);
开发者ID:kmfb21,项目名称:A290CGI-PHP,代码行数:31,代码来源:show_poll.php

示例11: cforms2_reset_captcha

function cforms2_reset_captcha()
{
    check_admin_referer('cforms2_reset_captcha');
    $cformsSettings = get_option('cforms_settings');
    $cap = $cformsSettings['global']['cforms_captcha_def'];
    ### overwrite for admin demo purposes, no cookie set though
    if (count($_GET) > 4) {
        $cap = $_GET;
    }
    $min = cforms2_prepVal($cap['c1'], 4);
    $max = cforms2_prepVal($cap['c2'], 5);
    $src = cforms2_prepVal($cap['ac'], 'abcdefghijkmnpqrstuvwxyz23456789');
    $img_sz_type = 0;
    $img_sz_width = cforms2_prepVal($cap['w'], 115);
    $img_sz_height = cforms2_prepVal($cap['h'], 25);
    $im_bg_type = 1;
    $im_bg_url = plugin_dir_path(__FILE__) . 'captchabg/' . cforms2_prepVal($cap['bg'], '1.gif');
    $font_url = plugin_dir_path(__FILE__) . 'captchafonts/' . cforms2_prepVal($cap['f'], 'font4.ttf');
    $min_font_size = cforms2_prepVal($cap['f1'], 17);
    $max_font_size = cforms2_prepVal($cap['f2'], 19);
    $min_angle = cforms2_prepVal($cap['a1'], -12);
    $max_angle = cforms2_prepVal($cap['a2'], 12);
    $col_txt_type = 4;
    $col = cforms2_prepVal($cap['c'], '#000066');
    $col_txt_r = hexdec(substr($col, 1, 2));
    $col_txt_g = hexdec(substr($col, 3, 2));
    $col_txt_b = hexdec(substr($col, 5, 2));
    $border = cforms2_prepVal($cap['l'], '#000066');
    $border_r = hexdec(substr($border, 1, 2));
    $border_g = hexdec(substr($border, 3, 2));
    $border_b = hexdec(substr($border, 5, 2));
    $char_padding = 2;
    $output_type = 'png';
    $no = cforms2_prepVal($_GET['ts'], '');
    ### captcha random code
    $srclen = strlen($src) - 1;
    $length = mt_rand($min, $max);
    $turing = '';
    for ($i = 0; $i < $length; $i++) {
        $turing .= substr($src, mt_rand(0, $srclen), 1);
    }
    $tu = $cap['i'] == 'i' ? strtolower($turing) : $turing;
    if (!(isset($_GET['c1']) || isset($_GET['c2']) || isset($_GET['ac']))) {
        setcookie("turing_string_" . $no, $cap['i'] . '+' . md5($tu), time() + 60 * 60 * 5, "/");
    }
    $font = $font_url;
    ### initialize variables
    $length = strlen($turing);
    $data = array();
    $image_width = $image_height = 0;
    $codelen = 0;
    ### build the data array of the characters, size, placement, etc.
    for ($i = 0; $i < $length; $i++) {
        $char = substr($turing, $i, 1);
        $size = mt_rand($min_font_size, $max_font_size);
        $angle = mt_rand($min_angle, $max_angle);
        $bbox = ImageTTFBBox($size, $angle, $font, $char);
        $char_width = max($bbox[2], $bbox[4]) - min($bbox[0], $bbox[6]);
        $char_height = max($bbox[1], $bbox[3]) - min($bbox[7], $bbox[5]);
        $codelen = $codelen + $char_width + $char_padding;
        $image_width += $char_width + $char_padding;
        $image_height = max($image_height, $char_height);
        $data[] = array('char' => $char, 'size' => $size, 'angle' => $angle, 'height' => $char_height, 'width' => $char_width);
    }
    ### calculate the final image size, adding some padding
    $x_padding = 12;
    if ($img_sz_type == 1) {
        $image_width += $x_padding * 2;
        $image_height = $image_height * 1.5 + 2;
    } else {
        $image_width = $img_sz_width;
        $image_height = $img_sz_height;
    }
    ### build the image, and allocte the colors
    $im = ImageCreate($image_width, $image_height);
    $d1 = $d2 = $d3 = 0;
    while ($d1 < 50 and $d2 < 50 and $d3 < 50) {
        $r = mt_rand(200, 255);
        $g = mt_rand(200, 255);
        $b = mt_rand(200, 255);
        $d1 = abs($r - $g);
        $d2 = abs($r - $b);
        $d3 = abs($g - $b);
    }
    ImageColorAllocate($im, $r, $g, $b);
    $color_border = ImageColorAllocate($im, $border_r, $border_g, $border_b);
    ImageColorAllocate($im, round($r * 0.85), round($g * 0.85), round($b * 0.85));
    ImageColorAllocate($im, round($r * 0.95), round($g * 0.95), round($b * 0.95));
    ImageColorAllocate($im, round($r * 0.9), round($g * 0.9), round($b * 0.9));
    $d1 = mt_rand(0, 50);
    $d2 = mt_rand(0, 50);
    $d3 = mt_rand(0, 50);
    $d1 = $d2 = $d3 = 0;
    while ($d1 < 100 and $d2 < 100 and $d3 < 100) {
        $r = mt_rand(0, 150);
        $g = mt_rand(0, 150);
        $b = mt_rand(0, 150);
        $d1 = abs($r - $g);
        $d2 = abs($r - $b);
        $d3 = abs($g - $b);
//.........这里部分代码省略.........
开发者ID:vanie3,项目名称:sierra-wordpress,代码行数:101,代码来源:cforms-captcha.php

示例12: ImageTTFTextWrapper

 /**
  * Wrapper for ImageTTFText
  *
  * @param resource $im (See argument for PHP function imageTTFtext())
  * @param int $fontSize (See argument for PHP function imageTTFtext())
  * @param int $angle (See argument for PHP function imageTTFtext())
  * @param int $x (See argument for PHP function imageTTFtext())
  * @param int $y (See argument for PHP function imageTTFtext())
  * @param int $color (See argument for PHP function imageTTFtext())
  * @param string $fontFile (See argument for PHP function imageTTFtext())
  * @param string $string (See argument for PHP function imageTTFtext()). UTF-8 string, possibly with entities in.
  * @param array $splitRendering Split-rendering configuration
  * @param int $sF Scale factor
  * @return void
  */
 public function ImageTTFTextWrapper($im, $fontSize, $angle, $x, $y, $color, $fontFile, $string, $splitRendering, $sF = 1)
 {
     // Initialize:
     $stringParts = $this->splitString($string, $splitRendering, $fontSize, $fontFile);
     $x = ceil($sF * $x);
     $y = ceil($sF * $y);
     // Traverse string parts:
     foreach ($stringParts as $i => $strCfg) {
         // Initialize:
         $colorIndex = $color;
         // Set custom color if any (only when niceText is off):
         if ($strCfg['color'] && $sF == 1) {
             $cols = $this->convertColor($strCfg['color']);
             $colorIndex = ImageColorAllocate($im, $cols[0], $cols[1], $cols[2]);
             $colorIndex = $color >= 0 ? $colorIndex : -$colorIndex;
         }
         // Setting xSpaceBefore
         if ($i) {
             $x += (int) $strCfg['xSpaceBefore'];
             $y -= (int) $strCfg['ySpaceBefore'];
         }
         $fontFile = self::prependAbsolutePath($strCfg['fontFile']);
         if (is_readable($fontFile)) {
             // Render part:
             ImageTTFText($im, GeneralUtility::freetypeDpiComp($sF * $strCfg['fontSize']), $angle, $x, $y, $colorIndex, $fontFile, $strCfg['str']);
             // Calculate offset to apply:
             $wordInf = ImageTTFBBox(GeneralUtility::freetypeDpiComp($sF * $strCfg['fontSize']), $angle, self::prependAbsolutePath($strCfg['fontFile']), $strCfg['str']);
             $x += $wordInf[2] - $wordInf[0] + (int) $splitRendering['compX'] + (int) $strCfg['xSpaceAfter'];
             $y += $wordInf[5] - $wordInf[7] - (int) $splitRendering['compY'] - (int) $strCfg['ySpaceAfter'];
         } else {
             debug('cannot read file: ' . $fontFile, GraphicalFunctions::class . '::ImageTTFTextWrapper()');
         }
     }
 }
开发者ID:TYPO3Incubator,项目名称:TYPO3.CMS,代码行数:49,代码来源:GraphicalFunctions.php

示例13: _createImage

 /**
  * @param  string
  * @param  integer
  * @return string
  * @access private
  */
 function _createImage($word, $baseline)
 {
     $font = isset($this->_gtextAttributes['font']) ? $this->_gtextAttributes['font'] : 'arial.ttf';
     $fh = isset($this->_gtextAttributes['fontsize']) ? $this->_gtextAttributes['fontsize'] : 12;
     $bgcolor = isset($this->_gtextAttributes['bgcolor']) ? $this->_gtextAttributes['bgcolor'] : '#ffffff';
     $fgcolor = isset($this->_gtextAttributes['fgcolor']) ? $this->_gtextAttributes['fgcolor'] : '#ffffff';
     $antialias = isset($this->_gtextAttributes['antialias']) ? $this->_gtextAttributes['antialias'] : 'yes';
     $transparency = isset($this->_gtextAttributes['transparency']) ? $this->_gtextAttributes['transparency'] : 'yes';
     $cacheable = isset($this->_gtextAttributes['cacheable']) ? $this->_gtextAttributes['cacheable'] : 'yes';
     $spacing = isset($this->_gtextAttributes['spacing']) ? $this->_gtextAttributes['spacing'] : 2;
     $border = isset($this->_gtextAttributes['border']) ? $this->_gtextAttributes['border'] : 0;
     $bordercolor = isset($this->_gtextAttributes['bordercolor']) ? $this->_gtextAttributes['bordercolor'] : '#ff0000';
     /* The cache name is derived from all attributes and cdata.
      * This is very conserative and may create to many cachefiles,
      * but better to err on the safe side.
      */
     $cachefile = md5(XML_Util::attributesToString($this->_gtextAttributes) . ':' . $word) . '.png';
     $cacheDir = $_SERVER['DOCUMENT_ROOT'] . PEAR_XML_TRANSFORMER_IMAGE_cacheDir;
     $cacheName = "{$cacheDir}/{$cachefile}";
     $cacheURL = PEAR_XML_TRANSFORMER_IMAGE_cacheDir . "/{$cachefile}";
     if (!is_dir($cacheDir)) {
         mkdir($cacheDir, 01777);
     }
     /* Don't do the same work twice. */
     if (file_exists($cacheName) && $cacheable != 'no') {
         return $cacheURL;
     }
     $r = ImageTTFBBox($fh, 0, $font, $word);
     $w = max(1 / 10 * $fh, abs($r[2] - $r[0]));
     $h = max(1, abs($r[7] - $r[1]));
     $x = $r[0];
     $y = $baseline;
     $www = $w + 2 * ($spacing + $border);
     $hhh = $fh + 2 * ($spacing + $border);
     $im = ImageCreate($www, $hhh);
     list($r, $g, $b) = $this->_colorString($bgcolor);
     $bg = ImageColorAllocate($im, $r, $g, $b);
     if ($transparency != 'no') {
         ImageColorTransparent($im, $bg);
     }
     list($r, $g, $b) = $this->_colorString($fgcolor);
     $fg = ImageColorAllocate($im, $r, $g, $b);
     if ($antialias == 'no') {
         $fg = -$fg;
     }
     list($r, $g, $b) = $this->_colorString($bordercolor);
     $bo = ImageColorAllocate($im, $r, $g, $b);
     ImageFilledRectangle($im, 0, 0, $www, $hhh, $bg);
     if ($border > 0) {
         for ($i = $border; $i >= 0; $i--) {
             $x1 = $y1 = $i;
             $x2 = $www - $i - 1;
             $y2 = $hhh - $i - 1;
             ImageRectangle($im, $x1, $y1, $x2, $y2, $bo);
         }
     }
     ImageTTFText($im, $fh, 0, -$x + $spacing + $border, $hhh - (2 + $y + $spacing + $border), $fg, $font, $word);
     ImagePNG($im, $cacheName);
     ImageDestroy($im);
     return $cacheURL;
 }
开发者ID:Esleelkartea,项目名称:kz-adeada-talleres-electricos-,代码行数:67,代码来源:Image.php

示例14: bwg_imagettfbboxdimensions

 function bwg_imagettfbboxdimensions($font_size, $font_angle, $font, $text)
 {
     $box = @ImageTTFBBox($font_size, $font_angle, $font, $text) or die;
     $max_x = max(array($box[0], $box[2], $box[4], $box[6]));
     $max_y = max(array($box[1], $box[3], $box[5], $box[7]));
     $min_x = min(array($box[0], $box[2], $box[4], $box[6]));
     $min_y = min(array($box[1], $box[3], $box[5], $box[7]));
     return array("width" => $max_x - $min_x, "height" => $max_y - $min_y);
 }
开发者ID:shieldsdesignstudio,项目名称:trilogic,代码行数:9,代码来源:WDSControllerSliders_wds.php

示例15: _StrokeTTF

 function _StrokeTTF($x, $y, $txt, $dir = 0, $paragraph_align = "left", $debug = false)
 {
     // Setupo default inter line margin for paragraphs to
     // 25% of the font height.
     $ConstLineSpacing = 0.25;
     // Remember the anchor point before adjustment
     if ($debug) {
         $ox = $x;
         $oy = $y;
     }
     if (!ereg("\n", $txt) || $dir > 0 && ereg("\n", $txt)) {
         // Format a single line
         $txt = $this->AddTxtCR($txt);
         $bbox = $this->GetBBoxTTF($txt, $dir);
         // Align x,y ot lower left corner of bbox
         $x -= $bbox[0];
         $y -= $bbox[1];
         // Note to self: "topanchor" is deprecated after we changed the
         // bopunding box stuff.
         if ($this->text_halign == "right" || $this->text_halign == "topanchor") {
             $x -= $bbox[2] - $bbox[0];
         } elseif ($this->text_halign == "center") {
             $x -= ($bbox[2] - $bbox[0]) / 2;
         }
         if ($this->text_valign == "top") {
             $y += abs($bbox[5]) + $bbox[1];
         } elseif ($this->text_valign == "center") {
             $y -= ($bbox[5] - $bbox[1]) / 2;
         }
         ImageTTFText($this->img, $this->font_size, $dir, $x, $y, $this->current_color, $this->font_file, $txt);
         if ($debug) {
             // Draw the bounding rectangle and the bounding box
             $box = @ImageTTFBBox($this->font_size, $dir, $this->font_file, $txt);
             $p = array();
             $p1 = array();
             for ($i = 0; $i < 4; ++$i) {
                 $p[] = $bbox[$i * 2] + $x;
                 $p[] = $bbox[$i * 2 + 1] + $y;
                 $p1[] = $box[$i * 2] + $x;
                 $p1[] = $box[$i * 2 + 1] + $y;
             }
             // Draw bounding box
             $this->PushColor('green');
             $this->Polygon($p1, true);
             $this->PopColor();
             // Draw bounding rectangle
             $this->PushColor('darkgreen');
             $this->Polygon($p, true);
             $this->PopColor();
             // Draw a cross at the anchor point
             $this->PushColor('red');
             $this->Line($ox - 15, $oy, $ox + 15, $oy);
             $this->Line($ox, $oy - 15, $ox, $oy + 15);
             $this->PopColor();
         }
     } else {
         // Format a text paragraph
         $fh = $this->GetFontHeight();
         // Line margin is 25% of font height
         $linemargin = round($fh * $ConstLineSpacing);
         $fh += $linemargin;
         $w = $this->GetTextWidth($txt);
         $y -= $linemargin / 2;
         $tmp = split("\n", $txt);
         $nl = count($tmp);
         $h = $nl * $fh;
         if ($this->text_halign == "right") {
             $x -= $dir == 0 ? $w : $h;
         } elseif ($this->text_halign == "center") {
             $x -= $dir == 0 ? $w / 2 : $h / 2;
         }
         if ($this->text_valign == "top") {
             $y += $dir == 0 ? $h : $w;
         } elseif ($this->text_valign == "center") {
             $y += $dir == 0 ? $h / 2 : $w / 2;
         }
         // Here comes a tricky bit.
         // Since we have to give the position for the string at the
         // baseline this means thaht text will move slightly up
         // and down depending on any of it's character descend below
         // the baseline, for example a 'g'. To adjust the Y-position
         // we therefore adjust the text with the baseline Y-offset
         // as used for the current font and size. This will keep the
         // baseline at a fixed positoned disregarding the actual
         // characters in the string.
         $standardbox = $this->GetTTFBBox('Gg', $dir);
         $yadj = $standardbox[1];
         $xadj = $standardbox[0];
         for ($i = 0; $i < $nl; ++$i) {
             $wl = $this->GetTextWidth($tmp[$i]);
             $bbox = $this->GetTTFBBox($tmp[$i], $dir);
             if ($paragraph_align == "left") {
                 $xl = $x;
             } elseif ($paragraph_align == "right") {
                 $xl = $x + ($w - $wl);
             } else {
                 // Center
                 $xl = $x + $w / 2 - $wl / 2;
             }
             $xl -= $bbox[0];
//.........这里部分代码省略.........
开发者ID:hostellerie,项目名称:nexpro,代码行数:101,代码来源:jpgraph.php


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