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


PHP imageString函数代码示例

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


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

示例1: createImage

 public function createImage($text = '', $fontSize = 5)
 {
     // GD's built-in fonts are numbered from 1 - 5
     $font_size = $fontSize;
     // Calculate the appropriate image size
     $image_height = intval(imageFontHeight($font_size) * 2);
     $image_width = intval(strlen($text) * imageFontWidth($font_size) * 1.3);
     // Create the image
     $image = imageCreate($image_width, $image_height);
     // Create the colors to use in the image
     // gray background
     $back_color = imageColorAllocate($image, 216, 216, 216);
     // blue text
     $text_color = imageColorAllocate($image, 0, 0, 255);
     // black border
     $rect_color = imageColorAllocate($image, 0, 0, 0);
     // Figure out where to draw the text
     // (Centered horizontally and vertically
     $x = ($image_width - imageFontWidth($font_size) * strlen($text)) / 2;
     $y = ($image_height - imageFontHeight($font_size)) / 2;
     // Draw the text
     imageString($image, $font_size, $x, $y, $text, $text_color);
     // Draw a black border
     imageRectangle($image, 0, 0, imageSX($image) - 1, imageSY($image) - 1, $rect_color);
     // Send the image to the browser
     header('Content-Type: image/png');
     imagePNG($image);
     imageDestroy($image);
 }
开发者ID:puncoz,项目名称:presentation,代码行数:29,代码来源:images.php

示例2: create

 function create($text)
 {
     $img = imagecreatefrompng("skins/icon.png");
     $black = imageColorAllocate($img, 0, 0, 0);
     $white = imageColorAllocate($img, 255, 255, 255);
     imageString($img, 5, 20, 3, $text, $white);
     imagePNG($img);
 }
开发者ID:Parashutik,项目名称:ReloadCMS,代码行数:8,代码来源:captcha.php

示例3: creat_images

 public function creat_images($num)
 {
     $type = 2;
     header("Content-type: image/PNG");
     // 產生種子, 作圖形干擾用
     srand((double) microtime() * 10000000000);
     // 產生圖檔, 及定義顏色
     $img_x = 120;
     $img_y = 28;
     $im = imageCreate($img_x, $img_y);
     //ImageColorAllocate 分配圖形的顏色
     $back = ImageColorAllocate($im, rand(200, 255), rand(200, 255), rand(200, 255));
     $authText = $this->num2adb($num);
     imageFill($im, 0, 0, $back);
     // imageString($im, 5, rand(0,55), rand(0,40), $authText, $font);
     $str_x = 0;
     $str_y = 0;
     for ($i = 0; $i < strlen($authText); $i++) {
         $str_x += rand(10, 20);
         $str_y = rand(0, $img_y / 2);
         $font = ImageColorAllocate($im, rand(0, 100), rand(0, 100), rand(0, 100));
         imageString($im, 5, $str_x, $str_y, $authText[$i], $font);
     }
     // 插入圖形干擾點共 50 點, 可插入更多, 但可能會使圖形太過混雜
     for ($i = 0; $i < rand(50, 200); $i++) {
         $point = ImageColorAllocate($im, rand(0, 255), rand(0, 255), rand(0, 255));
         imagesetpixel($im, rand(0, $img_x), rand(0, $img_y), $point);
     }
     for ($i = 1; $i <= rand(2, 5); $i++) {
         $point = ImageColorAllocate($im, rand(0, 255), rand(0, 255), rand(0, 255));
         imageline($im, rand(0, $img_x), rand(0, $img_y), rand(0, $img_x), rand(0, $img_y), $point);
     }
     // 定義圖檔類型並輸入, 最後刪除記憶體
     if ($type == 1) {
         ob_start();
         ImagePNG($im);
         $output = ob_get_contents();
         ob_end_clean();
         echo base64_encode($output);
     } else {
         ImagePNG($im);
     }
     ImageDestroy($im);
 }
开发者ID:SamLaio,项目名称:mymvc,代码行数:44,代码来源:LibCaptcha.php

示例4: imageLine

$labelH = 10;
$wnd = $wnds_max;
/* start with max wind speed */
$dwnd = ($wnds_max - $wnds_min) / $tics;
$flag = false;
/* use this to only display every other tic label */
for ($i = $dy, $ii = 0; $i <= $gyb + $dy; $i += $gyb / $tics) {
    /* y axis2 tics */
    imageLine($im, $dx + $gxb - $ticW, $i, $dx + $gxb + $ticW, $i, $black);
    /* y axis2 horizontal graph lines */
    if ($i + 1 < $gyb + $dy) {
        imageLine($im, $dx, $i, $dx + $gxb - $ticW, $i, $ltGrey);
    }
    /* y axis2 labels */
    //  if($flag=!$flag){
    imageString($im, 5, $dx + $gxb + 2 * $ticW, $i - $labelH, sprintf("%3.1f", $wnd), $blue);
    //}
    $wnd -= $dwnd;
    if ($wnd < 0) {
        $wnd = -$wnd;
    }
}
/* draw the wind direction graph */
$scale = $gyb / 360;
/* wind direction can only go from 0 to 360 degrees */
for ($i = 0; $i + 1 < $row_count; $i++) {
    $x1 = $i * $gxb / $row_count + $dx;
    $y1 = $gyb + $dy - $windd[$i] * $scale;
    $x2 = ($i + 1) * $gxb / $row_count + $dx;
    $y2 = $gyb + $dy - $windd[$i + 1] * $scale;
    imageLine($im, $x1, $y1, $x2, $y2, $red);
开发者ID:BackupTheBerlios,项目名称:wth-svn,代码行数:31,代码来源:wind.gif.php

示例5: appendSourceInfo

 /**
  * Appends information about the source image to the thumbnail.
  * 
  * @param	string		$thumbnail
  * @return	string
  */
 protected function appendSourceInfo($thumbnail)
 {
     if (!function_exists('imageCreateFromString') || !function_exists('imageCreateTrueColor')) {
         return $thumbnail;
     }
     $imageSrc = imageCreateFromString($thumbnail);
     // get image size
     $width = imageSX($imageSrc);
     $height = imageSY($imageSrc);
     // increase height
     $heightDst = $height + self::$sourceInfoLineHeight * 2;
     // create new image
     $imageDst = imageCreateTrueColor($width, $heightDst);
     imageAlphaBlending($imageDst, false);
     // set background color
     $background = imageColorAllocate($imageDst, 102, 102, 102);
     imageFill($imageDst, 0, 0, $background);
     // copy image
     imageCopy($imageDst, $imageSrc, 0, 0, 0, 0, $width, $height);
     imageSaveAlpha($imageDst, true);
     // get font size
     $font = 2;
     $fontWidth = imageFontWidth($font);
     $fontHeight = imageFontHeight($font);
     $fontColor = imageColorAllocate($imageDst, 255, 255, 255);
     // write source info
     $line1 = $this->sourceName;
     // imageString supports only ISO-8859-1 encoded strings
     if (CHARSET != 'ISO-8859-1') {
         $line1 = StringUtil::convertEncoding(CHARSET, 'ISO-8859-1', $line1);
     }
     // truncate text if necessary
     $maxChars = floor($width / $fontWidth);
     if (strlen($line1) > $maxChars) {
         $line1 = $this->truncateSourceName($line1, $maxChars);
     }
     $line2 = $this->sourceWidth . 'x' . $this->sourceHeight . ' ' . FileUtil::formatFilesize($this->sourceSize);
     // write line 1
     // calculate text position
     $textX = 0;
     $textY = 0;
     if ($fontHeight < self::$sourceInfoLineHeight) {
         $textY = intval(round((self::$sourceInfoLineHeight - $fontHeight) / 2));
     }
     if (strlen($line1) * $fontWidth < $width) {
         $textX = intval(round(($width - strlen($line1) * $fontWidth) / 2));
     }
     imageString($imageDst, $font, $textX, $height + $textY, $line1, $fontColor);
     // write line 2
     // calculate text position
     $textX = 0;
     $textY = 0;
     if ($fontHeight < self::$sourceInfoLineHeight) {
         $textY = self::$sourceInfoLineHeight + intval(round((self::$sourceInfoLineHeight - $fontHeight) / 2));
     }
     if (strlen($line2) * $fontWidth < $width) {
         $textX = intval(round(($width - strlen($line2) * $fontWidth) / 2));
     }
     imageString($imageDst, $font, $textX, $height + $textY, $line2, $fontColor);
     // output image
     ob_start();
     if ($this->imageType == 1 && function_exists('imageGIF')) {
         @imageGIF($imageDst);
         $this->mimeType = 'image/gif';
     } else {
         if (($this->imageType == 1 || $this->imageType == 3) && function_exists('imagePNG')) {
             @imagePNG($imageDst);
             $this->mimeType = 'image/png';
         } else {
             if (function_exists('imageJPEG')) {
                 @imageJPEG($imageDst, null, 90);
                 $this->mimeType = 'image/jpeg';
             } else {
                 return false;
             }
         }
     }
     @imageDestroy($imageDst);
     $thumbnail = ob_get_contents();
     ob_end_clean();
     return $thumbnail;
 }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:88,代码来源:Thumbnail.class.php

示例6: codes_f

 function codes_f()
 {
     $x_size = 76;
     $y_size = 23;
     if (!defined("SYS_VCODE_VAR")) {
         define("SYS_VCODE_VAR", "phpok_login_chk");
     }
     $aimg = imagecreate($x_size, $y_size);
     $back = imagecolorallocate($aimg, 255, 255, 255);
     $border = imagecolorallocate($aimg, 0, 0, 0);
     imagefilledrectangle($aimg, 0, 0, $x_size - 1, $y_size - 1, $back);
     $txt = "0123456789";
     $txtlen = strlen($txt);
     $thetxt = "";
     for ($i = 0; $i < 4; $i++) {
         $randnum = mt_rand(0, $txtlen - 1);
         $randang = mt_rand(-10, 10);
         //文字旋转角度
         $rndtxt = substr($txt, $randnum, 1);
         $thetxt .= $rndtxt;
         $rndx = mt_rand(1, 5);
         $rndy = mt_rand(1, 4);
         $colornum1 = $rndx * $rndx * $randnum % 255;
         $colornum2 = $rndy * $rndy * $randnum % 255;
         $colornum3 = $rndx * $rndy * $randnum % 255;
         $newcolor = imagecolorallocate($aimg, $colornum1, $colornum2, $colornum3);
         imageString($aimg, 3, $rndx + $i * 21, 5 + $rndy, $rndtxt, $newcolor);
     }
     unset($txt);
     $thetxt = strtolower($thetxt);
     $_SESSION[SYS_VCODE_VAR] = md5($thetxt);
     #[写入session中]
     @session_write_close();
     #[关闭session写入]
     imagerectangle($aimg, 0, 0, $x_size - 1, $y_size - 1, $border);
     $newcolor = "";
     $newx = "";
     $newy = "";
     $pxsum = 30;
     //干扰像素个数
     for ($i = 0; $i < $pxsum; $i++) {
         $newcolor = imagecolorallocate($aimg, mt_rand(0, 254), mt_rand(0, 254), mt_rand(0, 254));
         imagesetpixel($aimg, mt_rand(0, $x_size - 1), mt_rand(0, $y_size - 1), $newcolor);
     }
     header("Pragma:no-cache");
     header("Cache-control:no-cache");
     header("Content-type: image/png");
     imagepng($aimg);
     imagedestroy($aimg);
     exit;
 }
开发者ID:helloyuanyuan,项目名称:ReferralBonus,代码行数:51,代码来源:login.php

示例7: intval

<?php

// GD's built-in fonts are numbered from 1 - 5
$font_size = 5;
// Calculate the appropriate image size
$image_height = intval(imageFontHeight($font_size) * 2);
$image_width = intval(strlen($_GET['text']) * imageFontWidth($font_size) * 1.3);
// Create the image
$image = imageCreate($image_width, $image_height);
// Create the colors to use in the image
// gray background
$back_color = imageColorAllocate($image, 216, 216, 216);
// blue text
$text_color = imageColorAllocate($image, 0, 0, 255);
// black border
$rect_color = imageColorAllocate($image, 0, 0, 0);
// Figure out where to draw the text
// (Centered horizontally and vertically
$x = ($image_width - imageFontWidth($font_size) * strlen($_GET['text'])) / 2;
$y = ($image_height - imageFontHeight($font_size)) / 2;
// Draw the text
imageString($image, $font_size, $x, $y, $_GET['text'], $text_color);
// Draw a black border
imageRectangle($image, 0, 0, imageSX($image) - 1, imageSY($image) - 1, $rect_color);
// Send the image to the browser
header('Content-Type: image/png');
imagePNG($image);
imageDestroy($image);
开发者ID:puncoz,项目名称:ingnepal.org,代码行数:28,代码来源:sec_key_image.php

示例8: drawFixedTextLine

 /**
  * Function: drawFixedTextLine
  *
  * Draws the given fixed text line.
  */
 function drawFixedTextLine($text, $font, $left, $top, $color, $horizontal = true)
 {
     if ($horizontal) {
         imageString($this->image, $font, $left, $top, $text, $color);
     } else {
         imageStringUp($this->image, $font, $left, $top, $text, $color);
     }
 }
开发者ID:maojinhui,项目名称:mxgraph,代码行数:13,代码来源:mxGdCanvas.php

示例9: skyview

function skyview($im, $sz, $C)
{
    $a = 90;
    $a = $sz * 0.95 * ($a / 180);
    imageFilledArc($im, $sz / 2, $sz / 2, $a * 2, $a * 2, 0, 360, $C['mdgray'], 0);
    imageArc($im, $sz / 2, $sz / 2, $a * 2, $a * 2, 0, 360, $C['black']);
    $x = $sz / 2 - 16;
    $y = $sz / 2 - $a;
    imageString($im, 2, $x, $y, "0", $C['ltgray']);
    $a = 85;
    $a = $sz * 0.95 * ($a / 180);
    imageFilledArc($im, $sz / 2, $sz / 2, $a * 2, $a * 2, 0, 360, $C['white'], 0);
    imageArc($im, $sz / 2, $sz / 2, $a * 2, $a * 2, 0, 360, $C['ltgray']);
    imageString($im, 1, $sz / 2 - 6, $sz + $a, '5', $C['black']);
    $x = $sz / 2 - 16;
    $y = $sz / 2 - $a;
    imageString($im, 2, $x, $y, "5", $C['ltgray']);
    skygrid($im, $sz, $C);
    $x = $sz / 2 - 16;
    $y = $sz / 2 - 8;
    /* imageString($im, 2, $x, $y, "90", $C['ltgray']); */
    imageString($im, 4, $sz / 2 + 4, 2, 'N', $C['black']);
    imageString($im, 4, $sz / 2 + 4, $sz - 16, 'S', $C['black']);
    imageString($im, 4, 4, $sz / 2 + 4, 'E', $C['black']);
    imageString($im, 4, $sz - 10, $sz / 2 + 4, 'W', $C['black']);
}
开发者ID:leearmstrong,项目名称:gpsd,代码行数:26,代码来源:skyview.php

示例10: errorGif

 /**
  * Creates error image based on gfx/notfound_thumb.png
  * Requires GD lib enabled, otherwise it will exit with the three textstrings outputted as text.
  * Outputs the image stream to browser and exits!
  *
  * @param string $l1 Text line 1
  * @param string $l2 Text line 2
  * @param string $l3 Text line 3
  * @return void
  * @todo Define visibility
  */
 public function errorGif($l1, $l2, $l3)
 {
     if (!$GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib']) {
         throw new \RuntimeException('TYPO3 Fatal Error: No gdlib. ' . $l1 . ' ' . $l2 . ' ' . $l3, 1270853954);
     }
     // Creates the basis for the error image
     if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib_png']) {
         header('Content-type: image/png');
         $im = imagecreatefrompng(PATH_typo3 . 'gfx/notfound_thumb.png');
     } else {
         header('Content-type: image/gif');
         $im = imagecreatefromgif(PATH_typo3 . 'gfx/notfound_thumb.gif');
     }
     // Sets background color and print color.
     $white = imageColorAllocate($im, 255, 255, 255);
     $black = imageColorAllocate($im, 0, 0, 0);
     // Prints the text strings with the build-in font functions of GD
     $x = 0;
     $font = 0;
     if ($l1) {
         imagefilledrectangle($im, $x, 9, 56, 16, $white);
         imageString($im, $font, $x, 9, $l1, $black);
     }
     if ($l2) {
         imagefilledrectangle($im, $x, 19, 56, 26, $white);
         imageString($im, $font, $x, 19, $l2, $black);
     }
     if ($l3) {
         imagefilledrectangle($im, $x, 29, 56, 36, $white);
         imageString($im, $font, $x, 29, substr($l3, -14), $black);
     }
     // Outputting the image stream and exit
     if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib_png']) {
         imagePng($im);
     } else {
         imageGif($im);
     }
     imagedestroy($im);
     die;
 }
开发者ID:khanhdeux,项目名称:typo3test,代码行数:51,代码来源:ThumbnailView.php

示例11: process

 /**
  * Controller
  */
 public function process()
 {
     if (\Core\Route\Controller::$isApi) {
         header('Content-type: application/json');
         echo json_encode(['error' => 404, 'uri' => $_SERVER['REQUEST_URI']]);
         exit;
     }
     $aRequests = Phpfox_Request::instance()->getRequests();
     if ($sPlugin = Phpfox_Plugin::get('error.component_controller_notfound_1')) {
         eval($sPlugin);
         if (isset($mReturnPlugin)) {
             return $mReturnPlugin;
         }
     }
     $aNewRequests = array();
     $iCnt = 0;
     foreach ($aRequests as $sKey => $sValue) {
         if (!preg_match('/req[0-9]/', $sKey)) {
             $aNewRequests[$sKey] = $sValue;
             continue;
         }
         if ($sValue == 'public') {
             continue;
         }
         $iCnt++;
         $aNewRequests['req' . $iCnt] = $sValue;
     }
     if (isset($aNewRequests['req1'])) {
         if ($aNewRequests['req1'] == 'gallery') {
             $aNewRequests['req1'] = 'photo';
         } elseif ($aNewRequests['req1'] == 'browse') {
             $aNewRequests['req1'] = 'user';
         } elseif ($aNewRequests['req1'] == 'groups') {
             $aNewRequests['req1'] = 'group';
         } elseif ($aNewRequests['req1'] == 'videos') {
             $aNewRequests['req1'] = 'video';
         } elseif ($aNewRequests['req1'] == 'listing') {
             $aNewRequests['req1'] = 'marketplace';
         }
     }
     if (isset($aNewRequests['req1']) && Phpfox::isModule($aNewRequests['req1']) && Phpfox::hasCallback($aNewRequests['req1'], 'legacyRedirect')) {
         $sRedirect = Phpfox::callback($aNewRequests['req1'] . '.legacyRedirect', $aNewRequests);
     }
     if (isset($sRedirect) && $sRedirect !== false && !defined('PHPFOX_IS_FORCED_404')) {
         header('HTTP/1.1 301 Moved Permanently');
         if (is_array($sRedirect)) {
             $this->url()->send($sRedirect[0], $sRedirect[1]);
         }
         $this->url()->send($sRedirect);
     }
     if (Phpfox::getParam(array('balancer', 'enabled'))) {
         $sDo = $this->request()->get(PHPFOX_GET_METHOD);
         if (preg_match('/\\/file\\/css\\/(.*)_(.*)/i', $sDo, $aMatches)) {
             $sContent = file_get_contents(Phpfox::getLib('server')->getServerUrl($aMatches[1]) . ltrim($sDo, '/'));
             $hFile = fopen(PHPFOX_DIR . ltrim($sDo, '/'), 'w+');
             fwrite($hFile, $sContent);
             fclose($hFile);
             header("Content-type: text/css");
             echo $sContent;
             exit;
         }
     }
     header("HTTP/1.0 404 Not Found");
     $sUrl = isset($_SERVER['REDIRECT_URL']) ? $_SERVER['REDIRECT_URL'] : '';
     $sCurrentUrl = $_SERVER['REQUEST_URI'];
     $aParts = explode('?', $sCurrentUrl);
     $sNewUrl = $aParts[0];
     if (substr($sNewUrl, -3) == '.js') {
         exit('JavaScript file not found.');
     } elseif (substr($sNewUrl, -4) == '.css') {
         exit('CSS file not found.');
     }
     if ($sUrl) {
         // If its an image lets create a small "not found" image
         if (substr($sUrl, -4) == '.gif' || substr($sUrl, -4) == '.png' || substr($sUrl, -4) == '.jpg' || substr($sUrl, -5) == '.jpeg') {
             // Log any missing images if the setting is enabled (Mostly used when developing new themes)
             if (Phpfox::getParam('core.log_missing_images')) {
                 if ($hFile = @fopen(PHPFOX_DIR . 'file/log/phpfox_missing_images.log', 'a+')) {
                     $sData = $sUrl . (isset($_SERVER['HTTP_REFERER']) ? " ({$_SERVER['HTTP_REFERER']})" : "");
                     fwrite($hFile, $sUrl . "\n");
                     fclose($hFile);
                 }
             }
             $sText = 'Not Found!';
             $nW = 100;
             $nH = 30;
             $nLeft = 5;
             $nTop = 5;
             $hImg = imageCreate($nW, $nH);
             $nBgColor = imageColorAllocate($hImg, 0, 0, 0);
             $nTxtColor = imageColorAllocate($hImg, 255, 255, 255);
             imageString($hImg, 5, $nLeft, $nTop, $sText, $nTxtColor);
             ob_clean();
             header('Content-Type: image/jpeg');
             imagejpeg($hImg);
             exit;
         }
//.........这里部分代码省略.........
开发者ID:nima7r,项目名称:phpfox-dist,代码行数:101,代码来源:404.class.php

示例12: drawText

 /**
  * Draws text on the image
  * @param Point $leftTop Point of the upper left corner
  * @param Color $color
  * @param string $text
  * @return null
  */
 public function drawText(Point $leftTop, Color $color, $text)
 {
     $color = $this->allocateColor($color);
     imageString($this->resource, 2, $leftTop->getX(), $leftTop->getY(), $text, $color);
 }
开发者ID:BGCX261,项目名称:zibo-svn-to-git,代码行数:12,代码来源:Image.php

示例13: rand

<?php

require_once 'inc.config.php';
// $code = mysql_result(mysql_query("SELECT code FROM $TABLE[logincodes] WHERE id='".$_GET['cid']."';"),0,'code');
$code = " " . rand(11111, 99999);
$_SESSION['ps_logincode'] = $code;
$plaatje = ImageCreateTrueColor(84, 30);
$color_border = ImageColorAllocate($plaatje, 0, 0, 0);
$color_bg = ImageColorAllocate($plaatje, 255, 255, 255);
$color_text = ImageColorAllocate($plaatje, 0, 0, 0);
ImageFilledRectangle($plaatje, 0, 0, 84, 30, $color_border);
ImageFilledRectangle($plaatje, 1, 1, 82, 28, $color_bg);
for ($i = 0; $i < strlen($code); $i++) {
    $fontnum = rand(2, 5);
    $color_text = ImageColorAllocate($plaatje, rand(50, 205), rand(50, 205), rand(50, 205));
    $x = 4 + 10 * $i;
    $y = rand(0, 12);
    imageString($plaatje, $fontnum, $x, $y, $code[$i], $color_text);
}
// Twee lijnen voor de onduidelijkheid
ImageLine($plaatje, rand(0, 84), rand(0, 30), rand(0, 84), rand(0, 30), $color_border);
ImageLine($plaatje, rand(0, 84), rand(0, 30), rand(0, 84), rand(0, 30), $color_border);
Header("Content-type: image/jpeg");
ImagePNG($plaatje);
ImageDestroy($plaatje);
开发者ID:rudiedirkx,项目名称:Pornstars,代码行数:25,代码来源:logincode.php

示例14: imageLine

            if ($count > $max2) {
                $max2 = $count;
            }
            if ($count > 0) {
                imageLine($image, $i, $j * $va + $vs - $count, $i, $j * $va + $vs, $green);
            }
            $j++;
        }
        //while
        $i++;
        $i++;
    }
    //for $mo
    imageLine($image, $i, $vs - $va * 2, $i, $diagramHeight - 1, $black);
}
//for $y
$j = 0;
foreach ($cats as $cat) {
    imageFilledRectangle($image, 1, $j * $va + $vs - ($va - 1), $hs - 1, $j * $va + $vs - ($va - 11), $colorBackgr);
    imageString($image, 3, 2, $j * $va + $vs - $va, "{$cats[$j]}", $black);
    $j++;
}
pg_close($dbconn);
echo "max records/month= {$max} max2 pixels= {$max2}<br>\n";
//create an interlaced image for better loadingin the browser
imageInterlace($image, 1);
//mark background coloras being transparent
//imageColorTransparent($image,$colorBackgr);
imagePNG($image, "{$secdir}/hec.png");
//exec ("chmod 777 $secdir/temp.png");
echo "<br><IMG SRC=\"hec.png\">\n";
开发者ID:helio-vo,项目名称:helio,代码行数:31,代码来源:hec_graph.php

示例15: Show

/**
 * 直接顯示圖片
 *
 * 詳細說明
 * @形參      字元串      $ImageType   設定顯示圖片的格式
 *            10進制數字  $ImageWidth  設定顯示圖片的高度
 *            10進制數字  $ImageHeight 設定顯示圖片的寬度
 * @開始      1.0
 * @最後修改  1.0
 * @瀏覽      公開
 * @返回值    無
 * @throws
 */
function Show($ImageType = "", $ImageWidth = "", $ImageHeight = "")
{
    global $UseSession;
    global $_SessionNum;
    global $CodeLength;
    global $CodeWithChar;
    global $ImageType;
    global $ImageWidth;
    global $ImageHeight;
    global $AuthResult;
    global $FontColor;
    global $BGColor;
    global $Transparent;
    global $NoiseBG;
    global $NoiseChar;
    global $TotalNoiseChar;
    global $JpegQuality;
    // 生成驗證碼
    if ($CodeWithChar) {
        for ($i = 0; $i < $CodeLength; $i++) {
            $AuthResult .= dechex(rand(1, 15));
        }
    } else {
        for ($i = 0; $i < $CodeLength; $i++) {
            $AuthResult .= rand(1, 9);
        }
    }
    // 檢查有沒有設定圖片的輸出格式,如果沒有,則使用類庫的預設值作為最終結果。
    if ($ImageType == "") {
        $ImageType = $ImageType;
    }
    // 檢查有沒有設定圖片的輸出寬度,如果沒有,則使用類庫的預設值作為最終結果。
    if ($ImageWidth == "") {
        $ImageWidth = $ImageWidth;
    }
    // 檢查有沒有設定圖片的輸出高度,如果沒有,則使用類庫的預設值作為最終結果。
    if ($ImageHeight == "") {
        $ImageHeight = $ImageHeight;
    }
    // 建立圖片流
    $im = imagecreate($ImageWidth, $ImageHeight);
    // 取得背景色
    list($bgR, $bgG, $bgB) = $BGColor;
    // 設定背景色
    $background_color = imagecolorallocate($im, $bgR, $bgG, $bgB);
    // 取得文字顏色
    list($fgR, $fgG, $fgB) = $FontColor;
    // 設定字型顏色
    $font_color = imagecolorallocate($im, $fgR, $fgG, $fgB);
    // 檢查是否需要將背景色透明
    if ($Transparent) {
        ImageColorTransparent($im, $background_color);
    }
    if ($NoiseBG) {
        //            ImageRectangle($im, 0, 0, $ImageHeight - 1, $ImageWidth - 1, $background_color);//先成一黑色的矩形把圖片包圍
        //下面該生成雪花背景了,其實就是在圖片上生成一些符號
        for ($i = 1; $i <= $TotalNoiseChar; $i++) {
            imageString($im, 1, mt_rand(1, $ImageWidth), mt_rand(1, $ImageHeight), $NoiseChar, imageColorAllocate($im, mt_rand(200, 255), mt_rand(200, 255), mt_rand(200, 255)));
        }
    }
    // 為了區別於背景,這裡的顏色不超過200,上面的不小於200
    for ($i = 0; $i < strlen($AuthResult); $i++) {
        //mt_rand(3,5)
        //imageString( $im, mt_rand(3,5), $i*$ImageWidth/strlen( $AuthResult )+mt_rand(1,5), mt_rand(1, $ImageHeight/2), $AuthResult[$i], imageColorAllocate( $im, mt_rand(0, 100), mt_rand(0, 150), mt_rand(0, 200) ) );
        $tt = imageColorAllocate($im, mt_rand(150, 255), mt_rand(150, 255), mt_rand(100, 255));
        //字型顏色設定
        ImageTTFText($im, 18, mt_rand(-45, 45), 12 + $i * $ImageWidth / strlen($AuthResult) + mt_rand(1, 5), $ImageHeight * 5 / 7, $tt, "photo/DFFN_Y7.TTC", $AuthResult[$i]);
    }
    // 檢查輸出格式
    if ($ImageType == "PNG") {
        header("Content-type: image/png");
        imagepng($im);
    }
    // 檢查輸出格式
    if ($ImageType == "JPEG") {
        header("Content-type: image/jpeg");
        imagejpeg($im, null, $JpegQuality);
    }
    // 釋放圖片流
    imagedestroy($im);
}
开发者ID:shadowjohn,项目名称:myppt,代码行数:94,代码来源:include.php


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