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

PHP imagefilledrectangle函数代码示例

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

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



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

示例1: run

 /**
  *	Génère l'avatar
  */
 public function run()
 {
     //On créer l'image avec les dimentions données
     $image = imagecreate($this->_size, $this->_size);
     //On créer la couleur en fonction du hash de la chaine de caractères
     $color = imagecolorallocate($image, hexdec(substr($this->_color, 0, 2)), hexdec(substr($this->_color, 2, 2)), hexdec(substr($this->_color, 4, 2)));
     //on défini le fond de l'image (blanc)
     $bg = imagecolorallocate($image, 255, 255, 255);
     //nombre de blocs à placer dans l'image (taille de l'image/taille des blocs)
     $c = $this->_size / $this->_blockSize;
     for ($x = 0; $x < ceil($c / 2); $x++) {
         for ($y = 0; $y < $c; $y++) {
             // Si le nombre est pair $pixel vaut true sinon $pixel vaut false
             $pixel = hexdec($this->_hash[(int) ($x * ceil($c / 2)) + $y]) % 2 == 0;
             if ($pixel) {
                 $pixelColor = $color;
             } else {
                 $pixelColor = $bg;
             }
             // On place chaque bloc de l'image
             //imagefilledrectangle($image, $x*$this->_blockSize, $y*$this->_blockSize, ($x+1)*$this->_blockSize, ($y+1)*$this->_blockSize, $pixelColor);
             //imagefilledrectangle($image, $this->_size-$x*$this->_blockSize, $y*$this->_blockSize, $this->_size-($x+1)*$this->_blockSize, ($y+1)*$this->_blockSize, $pixelColor);
             imagefilledrectangle($image, $x * $this->_blockSize, $y * $this->_blockSize, ($x + 1) * $this->_blockSize, ($y + 1) * $this->_blockSize, $pixelColor);
             imagefilledrectangle($image, $this->_size - $x * $this->_blockSize, $y * $this->_blockSize, $this->_size - ($x + 1) * $this->_blockSize, ($y + 1) * $this->_blockSize, $pixelColor);
         }
     }
     ob_start();
     imagepng($image);
     //on place l'image en mémoire
     $this->_image = ob_get_contents();
     ob_clean();
 }
开发者ID:JulienCoutault,项目名称:Web,代码行数:35,代码来源:RandomAvatar.php


示例2: Resize

 public function Resize($image, $newWidth, $targetName)
 {
     if (!file_exists(PUBLIC_ROOT . $image)) {
         $image = '/assets/images/not-found.gif';
     }
     $imgInfo = getimagesize(PUBLIC_ROOT . $image);
     $oldWidth = $imgInfo[0];
     $oldHeight = $imgInfo[1];
     $changeRatio = $oldWidth / $newWidth;
     $newHeight = round($oldHeight / $changeRatio);
     $newImage = imagecreatetruecolor($newWidth, $newHeight);
     $source = $this->load(PUBLIC_ROOT . $image);
     if ($this->imageType == IMAGETYPE_PNG) {
         imagealphablending($newImage, false);
         imagesavealpha($newImage, true);
         $transparent = imagecolorallocatealpha($newImage, 255, 255, 255, 127);
         imagefilledrectangle($newImage, 0, 0, $newWidth, $newHeight, $transparent);
     }
     imagecopyresampled($newImage, $this->image, 0, 0, 0, 0, $newWidth, $newHeight, $oldWidth, $oldHeight);
     header('Content-Type: image/jpeg');
     imagejpeg($newImage, $targetName, 100);
     Debugger::debug($targetName, 'TARGET');
     //$this->save($targetName);
     $this->image = $newImage;
     imagedestroy($newImage);
 }
开发者ID:lenlyle1,项目名称:lightupdating,代码行数:26,代码来源:Resize.php


示例3: getImage

 /**
  * Return label image for product
  * @param <type> $productId
  */
 public function getImage($productId)
 {
     $product = Mage::getModel('catalog/product')->load($productId);
     //create base image
     $labelSize = Mage::helper('BarcodeLabel')->getlabelSize();
     $height = $labelSize['height'] * $this->_coef;
     $width = $labelSize['width'] * $this->_coef;
     $im = imagecreatetruecolor($width, $height);
     $white = imagecolorallocate($im, 255, 255, 255);
     imagefilledrectangle($im, 0, 0, $width, $height, $white);
     //add barcode
     $this->addBarcode($im, $product);
     //add product name
     $this->addName($im, $product);
     //add product attributes
     $this->addProductAttributes($im, $product);
     //add manufacturer
     $this->addManufacturer($im, $product);
     //add logo
     $this->addLogo($im);
     // add product image
     $this->addProductPicture($im, $product);
     //add product sku
     $this->addSku($im, $product);
     //add price
     $this->addPrice($im, $product);
     //add price
     $this->addCustoms($im, $product);
     //return image
     return $im;
 }
开发者ID:xiaoguizhidao,项目名称:devfashion,代码行数:35,代码来源:Label.php


示例4: getCode

function getCode($num, $w, $h)
{
    // 去掉了 0 1 O l 等
    $str = "23456789abcdefghijkmnpqrstuvwxyz";
    $code = '';
    for ($i = 0; $i < $num; $i++) {
        $code .= $str[mt_rand(0, strlen($str) - 1)];
    }
    //将生成的验证码写入session,备验证页面使用
    $_SESSION["my_checkcode"] = $code;
    //创建图片,定义颜色值
    Header("Content-type: image/PNG");
    $im = imagecreate($w, $h);
    $black = imagecolorallocate($im, mt_rand(0, 200), mt_rand(0, 120), mt_rand(0, 120));
    $gray = imagecolorallocate($im, 118, 151, 199);
    $bgcolor = imagecolorallocate($im, 235, 236, 237);
    //画背景
    imagefilledrectangle($im, 0, 0, $w, $h, $bgcolor);
    //画边框
    imagerectangle($im, 0, 0, $w - 1, $h - 1, $gray);
    //imagefill($im, 0, 0, $bgcolor);
    //在画布上随机生成大量点,起干扰作用;
    for ($i = 0; $i < 80; $i++) {
        imagesetpixel($im, rand(0, $w), rand(0, $h), $black);
    }
    //将字符随机显示在画布上,字符的水平间距和位置都按一定波动范围随机生成
    $strx = rand(5, 10);
    for ($i = 0; $i < $num; $i++) {
        $strpos = rand(1, 6);
        imagestring($im, 20, $strx, $strpos, substr($code, $i, 1), $black);
        $strx += $w / 5;
    }
    imagepng($im);
    imagedestroy($im);
}
开发者ID:hanpc,项目名称:chushen,代码行数:35,代码来源:code_char.php


示例5: fill_color

 /**
  * Background fill an image using the provided color
  *
  * @param int $width The desired width of the new image
  * @param int $height The desired height of the new image
  * @param Array the desired pad colors in RGB format, array should be array( 'top' => '', 'right' => '', 'bottom' => '', 'left' => '' );
  */
 private function fill_color(array $colors)
 {
     $current_size = $this->editor->get_size();
     $size = array('width' => $this->args['width'], 'height' => $this->args['height']);
     $offsetLeft = ($size['width'] - $current_size['width']) / 2;
     $offsetTop = ($size['height'] - $current_size['height']) / 2;
     $new_image = imagecreatetruecolor($size['width'], $size['height']);
     // This is needed to support alpha
     imagesavealpha($new_image, true);
     imagealphablending($new_image, false);
     // Check if we are padding vertically or horizontally
     if ($current_size['width'] != $size['width']) {
         $colorToPaint = imagecolorallocatealpha($new_image, substr($colors['left'], 0, 3), substr($colors['left'], 3, 3), substr($colors['left'], 6, 3), substr($colors['left'], 9, 3));
         // Fill left color
         imagefilledrectangle($new_image, 0, 0, $offsetLeft + 5, $size['height'], $colorToPaint);
         $colorToPaint = imagecolorallocatealpha($new_image, substr($colors['right'], 0, 3), substr($colors['right'], 3, 3), substr($colors['right'], 6, 3), substr($colors['left'], 9, 3));
         // Fill right color
         imagefilledrectangle($new_image, $offsetLeft + $current_size['width'] - 5, 0, $size['width'], $size['height'], $colorToPaint);
     } elseif ($current_size['height'] != $size['height']) {
         $colorToPaint = imagecolorallocatealpha($new_image, substr($colors['top'], 0, 3), substr($colors['top'], 3, 3), substr($colors['top'], 6, 3), substr($colors['left'], 9, 3));
         // Fill top color
         imagefilledrectangle($new_image, 0, 0, $size['width'], $offsetTop + 5, $colorToPaint);
         $colorToPaint = imagecolorallocatealpha($new_image, substr($colors['bottom'], 0, 3), substr($colors['bottom'], 3, 3), substr($colors['bottom'], 6, 3), substr($colors['left'], 9, 3));
         // Fill bottom color
         imagefilledrectangle($new_image, 0, $offsetTop - 5 + $current_size['height'], $size['width'], $size['height'], $colorToPaint);
     }
     imagecopy($new_image, $this->editor->get_image(), $offsetLeft, $offsetTop, 0, 0, $current_size['width'], $current_size['height']);
     $this->editor->update_image($new_image);
     $this->editor->update_size();
 }
开发者ID:shads196770,项目名称:cbox-theme,代码行数:37,代码来源:wpthumb.background-fill.php


示例6: resize

function resize($photo_src, $width, $name)
{
    $parametr = getimagesize($photo_src);
    list($width_orig, $height_orig) = getimagesize($photo_src);
    $ratio_orig = $width_orig / $height_orig;
    $new_width = $width;
    $new_height = $width / $ratio_orig;
    $newpic = imagecreatetruecolor($new_width, $new_height);
    $col2 = imagecolorallocate($newpic, 255, 255, 255);
    imagefilledrectangle($newpic, 0, 0, $new_width, $new_width, $col2);
    switch ($parametr[2]) {
        case 1:
            $image = imagecreatefromgif($photo_src);
            break;
        case 2:
            $image = imagecreatefromjpeg($photo_src);
            break;
        case 3:
            $image = imagecreatefrompng($photo_src);
            break;
    }
    imagecopyresampled($newpic, $image, 0, 0, 0, 0, $new_width, $new_height, $width_orig, $height_orig);
    imagejpeg($newpic, $name, 100);
    return true;
}
开发者ID:pioytazsko,项目名称:garantmarket,代码行数:25,代码来源:new_item.php


示例7: init

 /**
  * Init Image and color background
  */
 private function init()
 {
     if ($this->im === null) {
         $this->im = imagecreatetruecolor($this->w, $this->h) or die('Can\'t Initialize the GD Libraty');
         imagefilledrectangle($this->im, 0, 0, $this->w - 1, $this->h - 1, $this->color->allocate($this->im));
     }
 }
开发者ID:roquebrasilia,项目名称:sgdoc-codigo,代码行数:10,代码来源:BCGDrawing.php


示例8: createThumb

 /**
  * Create thumbnail image by php using the GD Library
  *
  * @since   1.0.0
  */
 public static function createThumb($source_image, $destination_image_url, $width, $height, $quality, $crop = null, $prefix = null, $checksize = null)
 {
     //Set image ratio
     list($w, $h) = getimagesize($source_image);
     // resize
     if ($crop === true) {
         if ($checksize && ($w < $width or $h < $height)) {
             $width = $w + 1;
             $height = $h + 1;
             $x = 0;
         } else {
             $ratio = max($width / $w, $height / $h);
             $h = $height / $ratio;
             $x = ($w - $width / $ratio) / 2;
             $w = $width / $ratio;
         }
     } else {
         if ($checksize && ($w < $width or $h < $height)) {
             $width = $w;
             $height = $h;
             $x = 0;
         } else {
             $ratio = min($width / $w, $height / $h);
             $width = $w * $ratio;
             $height = $h * $ratio;
             $x = 0;
         }
     }
     if (preg_match("/.jpg/i", "{$source_image}") or preg_match("/.jpeg/i", "{$source_image}")) {
         //JPEG type thumbnail
         $destImage = imagecreatetruecolor($width, $height);
         $sourceImage = imagecreatefromjpeg($source_image);
         imagecopyresampled($destImage, $sourceImage, 0, 0, $x, 0, $width, $height, $w, $h);
         imagejpeg($destImage, $destination_image_url, $quality);
         imagedestroy($destImage);
     } elseif (preg_match("/.png/i", "{$source_image}")) {
         //PNG type thumbnail
         $destImage = imagecreatetruecolor($width, $height);
         $sourceImage = imagecreatefrompng($source_image);
         imagealphablending($destImage, false);
         imagecopyresampled($destImage, $sourceImage, 0, 0, $x, 0, $width, $height, $w, $h);
         imagesavealpha($destImage, true);
         imagepng($destImage, $destination_image_url);
     } elseif (preg_match("/.gif/i", "{$source_image}")) {
         //GIF type thumbnail
         $destImage = imagecreatetruecolor($width, $height);
         $sourceImage = imagecreatefromgif($source_image);
         $bgc = imagecolorallocate($destImage, 255, 255, 255);
         imagefilledrectangle($destImage, 0, 0, $width, $height, $bgc);
         imagecopyresampled($destImage, $sourceImage, 0, 0, $x, 0, $width, $height, $w, $h);
         if (function_exists('imagegif')) {
             // Pour GIF
             header('Content-Type: image/gif');
             imagegif($destImage, $destination_image_url, $quality);
         }
         imagedestroy($destImage);
     } else {
         echo 'unable to load image source';
     }
 }
开发者ID:esorone,项目名称:efcpw,代码行数:65,代码来源:create.php


示例9: create_image

function create_image()
{
    $image = imagecreatetruecolor(200, 50);
    $background_color = imagecolorallocate($image, 255, 255, 255);
    imagefilledrectangle($image, 0, 0, 200, 50, $background_color);
    $line_color = imagecolorallocate($image, 255, 0, 255);
    for ($i = 0; $i < 10; $i++) {
        imageline($image, 0, rand() % 50, 200, rand() % 25, $line_color);
    }
    $pixel_color = imagecolorallocate($image, 255, 0, 255);
    for ($i = 0; $i < 1000; $i++) {
        imagesetpixel($image, rand() % 200, rand() % 50, $pixel_color);
    }
    $letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
    $len = strlen($letters);
    $letter = $letters[rand(0, $len - 1)];
    $text_color = imagecolorallocate($image, 0, 0, 0);
    $word = "";
    for ($i = 0; $i < 6; $i++) {
        $letter = $letters[rand(0, $len - 1)];
        imagestring($image, 5, 5 + $i * 30, 20, $letter, $text_color);
        $word .= $letter;
    }
    $_SESSION['security_key'] = $word;
    imagepng($image);
}
开发者ID:matrixdevuk,项目名称:SweatyCaptcha,代码行数:26,代码来源:gen.php


示例10: refresh

 /**
  * @param Thumbnail $thumbnail
  * @return void
  * @throws Exception\NoThumbnailAvailableException
  */
 public function refresh(Thumbnail $thumbnail)
 {
     $temporaryPathAndFilename = null;
     try {
         $filename = pathinfo($thumbnail->getOriginalAsset()->getResource()->getFilename(), PATHINFO_FILENAME);
         $temporaryLocalCopyFilename = $thumbnail->getOriginalAsset()->getResource()->createTemporaryLocalCopy();
         $temporaryPathAndFilename = $this->environment->getPathToTemporaryDirectory() . uniqid('ProcessedFontThumbnail-') . '.' . $filename . '.jpg';
         $width = 1000;
         $height = 1000;
         $im = imagecreate($width, $height);
         $red = imagecolorallocate($im, 0xff, 0xff, 0xff);
         $black = imagecolorallocate($im, 0x0, 0x0, 0x0);
         imagefilledrectangle($im, 0, 0, 1000, 1000, $red);
         imagefttext($im, 48, 0, 80, 150, $black, $temporaryLocalCopyFilename, 'Neos Font Preview');
         imagefttext($im, 32, 0, 80, 280, $black, $temporaryLocalCopyFilename, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ');
         imagefttext($im, 32, 0, 80, 360, $black, $temporaryLocalCopyFilename, 'abcdefghijklmopqrstuvwxyz');
         imagefttext($im, 32, 0, 80, 440, $black, $temporaryLocalCopyFilename, '1234567890');
         imagefttext($im, 32, 0, 80, 560, $black, $temporaryLocalCopyFilename, '+ " * ç % & / ( ) = ? @ €');
         imagejpeg($im, $temporaryPathAndFilename);
         $resource = $this->resourceManager->importResource($temporaryPathAndFilename);
         $processedImageInfo = $this->resize($thumbnail, $resource);
         $thumbnail->setResource($processedImageInfo['resource']);
         $thumbnail->setWidth($processedImageInfo['width']);
         $thumbnail->setHeight($processedImageInfo['height']);
         Files::unlink($temporaryPathAndFilename);
     } catch (\Exception $exception) {
         Files::unlink($temporaryPathAndFilename);
         $filename = $thumbnail->getOriginalAsset()->getResource()->getFilename();
         $sha1 = $thumbnail->getOriginalAsset()->getResource()->getSha1();
         $message = sprintf('Unable to generate thumbnail for the given font (filename: %s, SHA1: %s)', $filename, $sha1);
         throw new Exception\NoThumbnailAvailableException($message, 1433109653, $exception);
     }
 }
开发者ID:mgoldbeck,项目名称:neos-development-collection,代码行数:38,代码来源:FontDocumentThumbnailGenerator.php


示例11: generateImage

 private function generateImage()
 {
     // prepare image
     $this->generatedImage = imagecreatetruecolor($this->getPixelRatio() * 5, $this->getPixelRatio() * 5);
     $rgbBackgroundColor = $this->getBackgroundColor();
     if (null === $rgbBackgroundColor) {
         $background = imagecolorallocate($this->generatedImage, 0, 0, 0);
         imagecolortransparent($this->generatedImage, $background);
     } else {
         $background = imagecolorallocate($this->generatedImage, $rgbBackgroundColor[0], $rgbBackgroundColor[1], $rgbBackgroundColor[2]);
         imagefill($this->generatedImage, 0, 0, $background);
     }
     // prepage color
     $rgbColor = $this->getColor();
     $gdColor = imagecolorallocate($this->generatedImage, $rgbColor[0], $rgbColor[1], $rgbColor[2]);
     // draw content
     foreach ($this->getArrayOfSquare() as $lineKey => $lineValue) {
         foreach ($lineValue as $colKey => $colValue) {
             if (true === $colValue) {
                 imagefilledrectangle($this->generatedImage, $colKey * $this->getPixelRatio(), $lineKey * $this->getPixelRatio(), ($colKey + 1) * $this->getPixelRatio(), ($lineKey + 1) * $this->getPixelRatio(), $gdColor);
             }
         }
     }
     return $this;
 }
开发者ID:chinazan,项目名称:zzcrm,代码行数:25,代码来源:GdGenerator.php


示例12: create_captcha

 function create_captcha($time)
 {
     @session_start();
     $image;
     global $image;
     $word_1 = '';
     $word_2 = "";
     for ($i = 0; $i < 4; $i++) {
         $word_1 .= chr(rand(97, 122));
     }
     for ($i = 0; $i < 4; $i++) {
         $word_2 .= chr(rand(97, 122));
     }
     $_SESSION['random_number'] = $word_1 . ' ' . $word_2;
     $dir = './fonts/';
     $image = imagecreatetruecolor(165, 50);
     $font = "recaptchaFont.ttf";
     // font style
     $color = imagecolorallocate($image, 0, 0, 0);
     // color
     $white = imagecolorallocate($image, 255, 255, 255);
     // background color white
     imagefilledrectangle($image, 0, 0, 709, 99, $white);
     imagettftext($image, 22, 0, 5, 30, $color, $dir . $font, $_SESSION['random_number']);
     $_SESSION['count'] = $_SESSION['random_number'];
     $_SESSION['captcha_string'] = $_SESSION['random_number'];
     $images = glob("./style/captcha/*.png");
     foreach ($images as $image_to_delete) {
         @unlink($image_to_delete);
     }
     imagepng($image, "./style/captcha/" . $time . ".png");
     //return array('image'=>$image,'count'=>$_SESSION['count']);
 }
开发者ID:nationalbroadband,项目名称:nationalbroadband,代码行数:33,代码来源:captcha_helper.php


示例13: getCaptcha

 /**
  * 生成验证码
  * @param int $width 验证码图片宽度.默认130
  * @param int $height 验证码图片高度.默认40
  * @param int $fontSize 验证码字体大小.默认20
  * @param int $length 验证码字符个数.默认4
  * @return string  验证码中的字符串
  */
 public static function getCaptcha($width = '130', $height = '40', $fontSize = '20', $length = '4')
 {
     $chars = '0123456789abcdefghijklmnopqrstuvwxyz';
     $randStr = substr(str_shuffle($chars), 0, $length);
     $image = imagecreatetruecolor($width, $height);
     // 定义背景色
     $bgColor = imagecolorallocate($image, 0xff, 0xff, 0xff);
     // 定义文字及边框颜色
     $blackColor = imagecolorallocate($image, 0x0, 0x0, 0x0);
     //生成矩形边框
     imagefilledrectangle($image, 0, 0, $width, $height, $bgColor);
     // 循环生成雪花点
     for ($i = 0; $i < 200; $i++) {
         $grayColor = imagecolorallocate($image, 128 + rand(0, 128), 128 + rand(0, 128), 128 + rand(0, 128));
         imagesetpixel($image, rand(1, $width - 2), rand(4, $height - 2), $grayColor);
     }
     $font = ROOT_PATH . 'resources/fonts/acidic.ttf';
     // 把随机字符串输入图片
     $i = -1;
     while (isset($randStr[++$i])) {
         $fontColor = imagecolorallocate($image, rand(0, 100), rand(0, 100), rand(0, 100));
         if (!function_exists('imagettftext')) {
             imagechar($image, $fontSize, 15 + $i * 30, rand(5, 20), $randStr[$i], $fontColor);
         } else {
             imagettftext($image, $fontSize, 0, 10 + $i * 30, rand(25, 35), $fontColor, $font, $randStr[$i]);
         }
     }
     imagepng($image);
     $image = $bgColor = $blackColor = $grayColor = $fontColor = null;
     return $randStr;
 }
开发者ID:hellocc2,项目名称:crmht,代码行数:39,代码来源:Image.php


示例14: CreateCaptchaCanvas

 protected function CreateCaptchaCanvas()
 {
     // Create the image
     $this->image = imagecreatetruecolor($this->_conf['width'], $this->_conf['height']);
     $white = imagecolorallocate($this->image, 255, 255, 255);
     imagefilledrectangle($this->image, 0, 0, $this->_conf['width'], $this->_conf['height'], $white);
 }
开发者ID:xuecai,项目名称:3Dcaptcha,代码行数:7,代码来源:captcha3D.php


示例15: generate

 public function generate()
 {
     foreach ($this->__shapes as $shape) {
         $type = array_shift($shape);
         $color = array_shift($shape);
         $color = $this->_owner->imagecolorallocate(!isset($color) || is_null($color) ? $this->__base_color : $color, $this->__base_alpha);
         switch ($type) {
             case self::LINE:
                 imageline($this->_owner->image, $shape[0], $shape[1], $shape[2], $shape[3], $color);
                 break;
             case self::RECTANGLE:
                 imagerectangle($this->_owner->image, $shape[0], $shape[1], $shape[2], $shape[3], $color);
                 break;
             case self::FILLED_RECTANGLE:
                 imagefilledrectangle($this->_owner->image, $shape[0], $shape[1], $shape[2], $shape[3], $color);
                 break;
             case self::ELLIPSE:
                 imageellipse($this->_owner->image, $shape[0], $shape[1], $shape[2], $shape[3], $color);
                 break;
             case self::FILLED_ELLIPSE:
                 imagefilledellipse($this->_owner->image, $shape[0], $shape[1], $shape[2], $shape[3], $color);
                 break;
             case self::SPIRAL:
                 $angle = $r = 0;
                 while ($r <= $shape[2]) {
                     imagearc($this->_owner->image, $shape[0], $shape[1], $r, $r, $angle - $shape[3], $angle, $color);
                     $angle += $shape[3];
                     $r++;
                 }
                 break;
         }
     }
     return true;
 }
开发者ID:npetrovski,项目名称:php5-image,代码行数:34,代码来源:Primitive.php


示例16: resize

 public function resize($width = 0, $height = 0)
 {
     if (!$this->info['width'] || !$this->info['height']) {
         return;
     }
     $scale = min($width / $this->info['width'], $height / $this->info['height']);
     if ($scale == 1 && $this->info['mime'] != 'image/png') {
         return;
     }
     $new_width = (int) ($this->info['width'] * $scale);
     $new_height = (int) ($this->info['height'] * $scale);
     $xpos = (int) (($width - $new_width) / 2);
     $ypos = (int) (($height - $new_height) / 2);
     $image_old = $this->image;
     $this->image = imagecreatetruecolor($width, $height);
     if (isset($this->info['mime']) && $this->info['mime'] == 'image/png') {
         imagealphablending($this->image, false);
         imagesavealpha($this->image, true);
         $background = imagecolorallocatealpha($this->image, 255, 255, 255, 127);
         imagecolortransparent($this->image, $background);
     } else {
         $background = imagecolorallocate($this->image, 255, 255, 255);
     }
     imagefilledrectangle($this->image, 0, 0, $width, $height, $background);
     imagecopyresampled($this->image, $image_old, $xpos, $ypos, 0, 0, $new_width, $new_height, $this->info['width'], $this->info['height']);
     imagedestroy($image_old);
     $this->info['width'] = $width;
     $this->info['height'] = $height;
 }
开发者ID:laiello,项目名称:hecart,代码行数:29,代码来源:image.php


示例17: doImage

 function doImage()
 {
     if ($this->use_transparent_text == true || $this->bgimg != "") {
         $this->im = imagecreatetruecolor($this->image_width, $this->image_height);
         $bgcolor = imagecolorallocate($this->im, hexdec(substr($this->image_bg_color, 1, 2)), hexdec(substr($this->image_bg_color, 3, 2)), hexdec(substr($this->image_bg_color, 5, 2)));
         imagefilledrectangle($this->im, 0, 0, imagesx($this->im), imagesy($this->im), $bgcolor);
     } else {
         $this->im = imagecreate($this->image_width, $this->image_height);
         $bgcolor = imagecolorallocate($this->im, hexdec(substr($this->image_bg_color, 1, 2)), hexdec(substr($this->image_bg_color, 3, 2)), hexdec(substr($this->image_bg_color, 5, 2)));
     }
     if ($this->bgimg != "") {
         $this->setBackground();
     }
     $this->createCode();
     if (!$this->draw_lines_over_text && $this->draw_lines) {
         $this->drawLines();
     }
     $this->drawWord();
     if ($this->arc_linethrough == true) {
         $this->arcLines();
     }
     if ($this->draw_lines_over_text && $this->draw_lines) {
         $this->drawLines();
     }
     $this->output();
 }
开发者ID:pengfeiaaa,项目名称:web,代码行数:26,代码来源:Secode_class.php


示例18: img_bundle

 function img_bundle()
 {
     $sources = func_get_args();
     $target = array_shift($sources);
     $this->sizeinfo = array();
     $this->vpos = 0;
     $this->wpos = 0;
     foreach ($sources as $src) {
         $this->_bundle_index($src);
     }
     $target_img = imagecreatetruecolor($this->wpos, $this->vpos);
     $bg_color = imagecolorallocate($target_img, 255, 0, 255);
     //牺牲掉这个最丑的颜色做透明背景
     //todo:智能选择调色板中没有的颜色
     imagefilledrectangle($target_img, 0, 0, $this->wpos, $this->vpos, $bg_color);
     $app = $params['app'] ? app::get($params['app']) : $this->app;
     foreach ($this->sizeinfo as $file => $info) {
         $src_img = imagecreatefromgif($app->res_dir . '/' . $file);
         $rst = imagecopy($target_img, $src_img, 0, $info[0], 0, 0, $info[1], $info[2]);
         //            $rst = imagecopyresampled($target_img,$src_img,0,$info[0],0,0,$info[1],$info[2],$info[1],$info[2]);
         //            $rst = imagecopyresized($target_img,$src_img,0,$info[0],0,0,$info[1],$info[2],$info[1],$info[2]);
         $src_img = null;
     }
     imagecolortransparent($target_img, $bg_color);
     //        imagetruecolortopalette($target_img,true,256);
     //todo:优化显示效果
     imagegif($target_img, $app->res_dir . '/' . $target);
     $target_img = null;
     $rs = fopen($app->res_dir . '/' . $target, 'a');
     $info = serialize($this->sizeinfo);
     fwrite($rs, pack('a*V', $info, strlen($info)));
     fclose($rs);
     $this->sizeinfo = null;
 }
开发者ID:dalinhuang,项目名称:shopexts,代码行数:34,代码来源:ui.php


示例19: testImage

 public function testImage()
 {
     $size = 300;
     $this->image = imagecreatetruecolor($size, $size);
     //用白色背景,黑色边框画方框
     $back = imagecolorallocate($this->image, 255, 255, 255);
     $border = imagecolorallocate($this->image, 0, 0, 0);
     imagefilledrectangle($this->image, 0, 0, $size, $size, $back);
     //画出白色背景
     imagerectangle($this->image, 0, 0, $size - 1, $size - 1, $border);
     //画出黑色边框
     $yellow_x = 150;
     $yellow_y = 75;
     $red_x = 100;
     $red_y = 160;
     $blue_x = 200;
     $blue_y = 160;
     $radius = 150;
     $yellow = imagecolorallocatealpha($this->image, 255, 255, 0, 75);
     //此函数将黄色的alpha值调为75,就是透明度
     $red = imagecolorallocatealpha($this->image, 255, 0, 0, 75);
     $blue = imagecolorallocatealpha($this->image, 0, 0, 255, 75);
     //画三个交叠的圆
     imagefilledellipse($this->image, $yellow_x, $yellow_y, $radius, $radius, $yellow);
     //此函数就是我要在$image上画一个圆心($yellow_x,$yellow_y)半径为$radius/2颜色为$yellow的圆
     imagefilledellipse($this->image, $red_x, $red_y, $radius, $radius, $red);
     imagefilledellipse($this->image, $blue_x, $blue_y, $radius, $radius, $blue);
     //输出正确的header
     header("Content-type: image/png");
     //输出结果
     imagepng($this->image);
     imagedestroy($this->image);
 }
开发者ID:commiunty,项目名称:Mytest,代码行数:33,代码来源:index.php


示例20: verifyImage

function verifyImage($type = 1, $length = 4, $pixel = 0, $line = 10, $sses_name = "verify")
{
    // 创建画布
    $width = 80;
    $height = 28;
    $image = imagecreatetruecolor($width, $height);
    $white = imagecolorallocate($image, 255, 255, 255);
    $balck = imagecolorallocate($image, 0, 0, 0);
    // 用填充矩形填充画布
    imagefilledrectangle($image, 1, 1, $width - 2, $height - 2, $white);
    $chars = buildRandomString($type, $length);
    $_SESSION[$sses_name] = $chars;
    for ($i = 0; $i < $length; $i++) {
        $size = mt_rand(14, 18);
        $angle = mt_rand(-15, 15);
        $x = 3 + $i * $size;
        $y = mt_rand(18, 22);
        $fontfile = "../fonts/" . "STFANGSO.TTF";
        $color = imagecolorallocate($image, mt_rand(50, 90), mt_rand(80, 200), mt_rand(90, 180));
        $text = substr($chars, $i, 1);
        imagettftext($image, $size, $angle, $x, $y, $color, $fontfile, $text);
    }
    // 加点
    for ($i = 0; $i < $pixel; $i++) {
        imagesetpixel($image, mt_rand(0, $width - 1), mt_rand(0, $height - 1), $balck);
    }
    // 加直线
    for ($i = 0; $i < $line; $i++) {
        $color = imagecolorallocate($image, mt_rand(50, 90), mt_rand(80, 200), mt_rand(90, 180));
        imageline($image, mt_rand(0, $width - 1), mt_rand(0, $height - 1), mt_rand(0, $width - 1), mt_rand(0, $height - 1), $color);
    }
    header("content-type:image/jpg");
    imagegif($image);
    imagedestroy($image);
}
开发者ID:hiden2,项目名称:shopImooc-1,代码行数:35,代码来源:image.func.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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