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


PHP imagecolortransparent函数代码示例

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


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

示例1: getAvatar

 public function getAvatar($string, $widthHeight = 12, $theme = 'default')
 {
     $widthHeight = max($widthHeight, 12);
     $md5 = md5($string);
     $fileName = _TMP_DIR_ . '/' . $md5 . '.png';
     if ($this->tmpFileExists($fileName)) {
         return $fileName;
     }
     // Create seed.
     $seed = intval(substr($md5, 0, 6), 16);
     mt_srand($seed);
     $body = array('legs' => mt_rand(0, count($this->availableParts[$theme]['legs']) - 1), 'hair' => mt_rand(0, count($this->availableParts[$theme]['hair']) - 1), 'arms' => mt_rand(0, count($this->availableParts[$theme]['arms']) - 1), 'body' => mt_rand(0, count($this->availableParts[$theme]['body']) - 1), 'eyes' => mt_rand(0, count($this->availableParts[$theme]['eyes']) - 1), 'mouth' => mt_rand(0, count($this->availableParts[$theme]['mouth']) - 1));
     // Avatar random parts.
     $parts = array('legs' => $this->availableParts[$theme]['legs'][$body['legs']], 'hair' => $this->availableParts[$theme]['hair'][$body['hair']], 'arms' => $this->availableParts[$theme]['arms'][$body['arms']], 'body' => $this->availableParts[$theme]['body'][$body['body']], 'eyes' => $this->availableParts[$theme]['eyes'][$body['eyes']], 'mouth' => $this->availableParts[$theme]['mouth'][$body['mouth']]);
     $avatar = imagecreate($widthHeight, $widthHeight);
     imagesavealpha($avatar, true);
     imagealphablending($avatar, false);
     $background = imagecolorallocate($avatar, 0, 0, 0);
     $line_colour = imagecolorallocate($avatar, mt_rand(0, 200) + 55, mt_rand(0, 200) + 55, mt_rand(0, 200) + 55);
     imagecolortransparent($avatar, $background);
     imagefilledrectangle($avatar, 0, 0, $widthHeight, $widthHeight, $background);
     // Fill avatar with random parts.
     foreach ($parts as &$part) {
         $this->drawPart($part, $avatar, $widthHeight, $line_colour, $background);
     }
     imagepng($avatar, $fileName);
     imagecolordeallocate($avatar, $line_colour);
     imagecolordeallocate($avatar, $background);
     imagedestroy($avatar);
     return $fileName;
 }
开发者ID:recallfx,项目名称:monsterid.php,代码行数:31,代码来源:MonsterId.php

示例2: save

 function save($file)
 {
     // 透過処理
     if ($this->info[2] == IMAGETYPE_GIF || $this->info[2] == IMAGETYPE_PNG) {
         // 元画像の透過色を取得する。
         $trnprt_indx = imagecolortransparent($this->image);
         // 透過色が設定されている場合は透過処理を行う。
         if ($trnprt_indx < 0 && $this->info[2] == IMAGETYPE_PNG) {
             // アルファブレンディングをOFFにする。
             imagealphablending($this->image, false);
             // 生成した透過色を変換後画像の透過色として設定
             imagesavealpha($this->image, true);
         }
     }
     switch ($this->info[2]) {
         case IMAGETYPE_GIF:
             imagegif($this->image, $file);
             break;
         case IMAGETYPE_JPEG:
         case IMAGETYPE_JPEG2000:
             imagejpeg($this->image, $file, 100);
             break;
         case IMAGETYPE_PNG:
             imagepng($this->image, $file);
             break;
         default:
             break;
     }
 }
开发者ID:naonaox1126,项目名称:vizualizer,代码行数:29,代码来源:Converter.php

示例3: execute

 /**
  * Reduces colors of a given image
  *
  * @param  \Intervention\Image\Image $image
  * @return boolean
  */
 public function execute($image)
 {
     $count = $this->argument(0)->value();
     $matte = $this->argument(1)->value();
     // get current image size
     $size = $image->getSize();
     // create empty canvas
     $resource = imagecreatetruecolor($size->width, $size->height);
     // define matte
     if (is_null($matte)) {
         $matte = imagecolorallocatealpha($resource, 255, 255, 255, 127);
     } else {
         $matte = $image->getDriver()->parseColor($matte)->getInt();
     }
     // fill with matte and copy original image
     imagefill($resource, 0, 0, $matte);
     // set transparency
     imagecolortransparent($resource, $matte);
     // copy original image
     imagecopy($resource, $image->getCore(), 0, 0, 0, 0, $size->width, $size->height);
     if (is_numeric($count) && $count <= 256) {
         // decrease colors
         imagetruecolortopalette($resource, true, $count);
     }
     // set new resource
     $image->setCore($resource);
     return true;
 }
开发者ID:shubhomoy,项目名称:evolve,代码行数:34,代码来源:LimitColorsCommand.php

示例4: get

 /**
  * 生成验证码
  * @param  string $file 图片保存文件名,不指定则图片会被直接输出
  * @return null
  */
 public function get($file = "")
 {
     $support = $this->support();
     list($code, $answer) = $this->generateCode();
     $image = null;
     @session_start();
     $_SESSION['vitex.captcha.answer'] = strtolower($answer);
     if ($support == 'imagick') {
         $image = new \Imagick();
         $image->newImage($this->width, $this->height, "none");
         $image->setImageFormat('png');
         $image = $this->imagickLine($image, $this->linenum);
         $image = $this->imagickDrawText($image, $code);
         $image->swirlImage(30);
         $image->oilPaintImage(1);
         if ($file) {
             $image->writeImage($file);
         } else {
             header("Content-type:image/png");
             echo $image->getImageBlob();
         }
     } else {
         $image = imagecreate($this->width, $this->height);
         $color = imagecolorallocate($image, 255, 255, 255);
         imagecolortransparent($image, $color);
         $this->gdLine($image, $this->linenum);
         $this->gdDrawText($image, $code);
         if ($file) {
             imagepng($image, $file);
         } else {
             header("Content-type: image/jpeg; Cache-Control: no-store, no-cache, must-revalidate");
             imagepng($image);
         }
     }
 }
开发者ID:feixingbeibao,项目名称:vitexframework,代码行数:40,代码来源:Captcha.php

示例5: createMask

 protected function createMask(sfImage $image, $w, $h)
 {
     // Create a mask png image of the area you want in the circle/ellipse (a 'magicpink' image with a black shape on it, with black set to the colour of alpha transparency) - $mask
     $mask = $image->getAdapter()->getTransparentImage($w, $h);
     // Set the masking colours
     if (false === $this->getColor() || 'image/png' == $image->getMIMEType()) {
         $mask_black = imagecolorallocate($mask, 0, 0, 0);
     } else {
         $mask_black = $image->getAdapter()->getColorByHex($mask, $this->getColor());
     }
     // Cannot use white as transparent mask if color is set to white
     if ($this->getColor() === '#FFFFFF' || $this->getColor() === false) {
         $mask_transparent = imagecolorallocate($mask, 255, 0, 0);
     } else {
         $mask_color = imagecolorsforindex($mask, imagecolorat($image->getAdapter()->getHolder(), 0, 0));
         $mask_transparent = imagecolorallocate($mask, $mask_color['red'], $mask_color['green'], $mask_color['blue']);
     }
     imagecolortransparent($mask, $mask_transparent);
     imagefill($mask, 0, 0, $mask_black);
     // Draw the rounded rectangle for the mask
     $this->imagefillroundedrect($mask, 0, 0, $w, $h, $this->getRadius(), $mask_transparent);
     $mask_image = clone $image;
     $mask_image->getAdapter()->setHolder($mask);
     return $mask_image;
 }
开发者ID:thefkboss,项目名称:ZenTracker,代码行数:25,代码来源:sfImageRoundedCornersGD.class.php

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

示例7: setResource

 protected function setResource()
 {
     $this->resource = imagecreatetruecolor($this->background->width, $this->background->height);
     if (isset($this->fill) === true) {
         $backgroundindex = imagecolorallocate($this->resource, $this->fill['red'], $this->fill['green'], $this->fill['blue']);
         imagefill($this->resource, 0, 0, $backgroundindex);
     } else {
         if ($this->format === 'gif') {
             $backgroundindex = imagecolorallocatealpha($this->resource, 255, 255, 255, 127);
             imagefill($this->resource, 0, 0, $backgroundindex);
             imagecolortransparent($this->resource, $backgroundindex);
         } else {
             if ($this->format === 'jpeg') {
                 $backgroundindex = imagecolorallocate($this->resource, 255, 255, 255);
                 imagefill($this->resource, 0, 0, $backgroundindex);
             } else {
                 if ($this->format === 'png') {
                     imagealphablending($this->resource, false);
                     imagesavealpha($this->resource, true);
                     $backgroundindex = imagecolorallocatealpha($this->resource, 255, 255, 255, 127);
                     imagefill($this->resource, 0, 0, $backgroundindex);
                     imagealphablending($this->resource, true);
                 }
             }
         }
     }
 }
开发者ID:feeel1,项目名称:akina,代码行数:27,代码来源:Output.php

示例8: PrintReport

 function PrintReport()
 {
     header("Content-type: image/png");
     //建立画布大小
     $this->IMAGE = imagecreate($this->X, $this->Y);
     //设定画布背景色
     $background = imagecolorallocate($this->IMAGE, $this->R, $this->G, $this->B);
     //背影透明与否
     if ($this->TRANSPARENT == "1") {
         imagecolortransparent($this->IMAGE, $background);
     } else {
         //如不要透明时可填充背景色
         imagefilledrectangle($this->IMAGE, 0, 0, $this->X, $this->Y, $background);
     }
     //参数字体大小及颜色
     $this->FONTCOLOR = imagecolorallocate($this->IMAGE, 255 - $this->R, 255 - $this->G, 255 - $this->B);
     //根据REPORTTYPE选择是竖柱状、横柱状还是线状
     switch ($this->REPORTTYPE) {
         case "0":
             break;
         case "1":
             $this->imageColumnS();
             break;
         case "2":
             $this->imageColumnH();
             break;
         case "3":
             $this->imageLine();
             break;
     }
     //调用print打印xy坐标轴、图片
     $this->printXY();
     $this->printAll();
 }
开发者ID:dalinhuang,项目名称:ozgweb,代码行数:34,代码来源:ImageReport.php

示例9: reldis_createFile

function reldis_createFile($filename, $uga_part, $agga_part)
{
    $im_uga = @ImageCreateFromPng("good.png");
    $im_agga = @ImageCreateFromPng("bad.png");
    if (!$im_uga || !$im_agga) {
        die("Cannot Initialize new GD image stream");
    }
    $width = imagesx($im_uga);
    $sum = $uga_part + $agga_part;
    $uga_part /= $sum;
    $agga_part /= $sum;
    $uga_part *= $width;
    $agga_part *= $width;
    $im = @ImageCreate($width, $width);
    $white = imagecolorallocate($im, 0xff, 0xff, 0xff);
    imagefill($im, 0, 0, $white);
    imagecolortransparent($im, $white);
    $left = 0;
    imagecopy($im, $im_uga, $left, 0, $left, 0, $uga_part + 1, $width);
    $left += $uga_part;
    imagecopy($im, $im_agga, $left, 0, $left, 0, $agga_part + 1, $width);
    header("Content-type: image/png");
    imagepng($im, $filename);
    imagedestroy($im);
}
开发者ID:norter,项目名称:Game,代码行数:25,代码来源:religious_distribution.php

示例10: resizeThumbnailImage

function resizeThumbnailImage($thumb_image_name, $image, $width, $height, $start_width, $start_height, $scale)
{
    list($imagewidth, $imageheight, $imageType) = getimagesize($image);
    $imageType = image_type_to_mime_type($imageType);
    $newImageWidth = ceil($width * $scale);
    $newImageHeight = ceil($height * $scale);
    $newImage = imagecreatetruecolor($newImageWidth, $newImageHeight);
    switch ($imageType) {
        case "image/png":
        case "image/x-png":
            $source = imagecreatefrompng($image);
            break;
    }
    imagecopyresampled($newImage, $source, 0, 0, $start_width, $start_height, $newImageWidth, $newImageHeight, $width, $height);
    switch ($imageType) {
        case "image/png":
        case "image/x-png":
            $transcol = imagecolorallocatealpha($newImage, 255, 0, 255, 127);
            $trans = imagecolortransparent($newImage, $transcol);
            imagefill($newImage, 0, 0, $transcol);
            imagesavealpha($newImage, true);
            imagealphablending($newImage, true);
            imagepng($newImage, $thumb_image_name);
            break;
    }
    chmod($thumb_image_name, 0777);
}
开发者ID:kershan,项目名称:Crysandrea,代码行数:27,代码来源:avatar_helper.php

示例11: loadFile

 public function loadFile($thumbnail, $image)
 {
     $imgData = @GetImageSize($image);
     if (!$imgData) {
         throw new Exception(sprintf('Could not load image %s', $image));
     }
     if (in_array($imgData['mime'], $this->imgTypes)) {
         $loader = $this->imgLoaders[$imgData['mime']];
         if (!function_exists($loader)) {
             throw new Exception(sprintf('Function %s not available. Please enable the GD extension.', $loader));
         }
         $this->source = $loader($image);
         $this->sourceWidth = $imgData[0];
         $this->sourceHeight = $imgData[1];
         $this->sourceMime = $imgData['mime'];
         $thumbnail->initThumb($this->sourceWidth, $this->sourceHeight, $this->maxWidth, $this->maxHeight, $this->scale, $this->inflate);
         $this->thumb = imagecreatetruecolor($thumbnail->getThumbWidth(), $thumbnail->getThumbHeight());
         imagecolortransparent($this->thumb, imagecolorallocate($this->thumb, 0, 0, 0));
         imagealphablending($this->thumb, false);
         imagesavealpha($this->thumb, true);
         if ($imgData[0] == $this->maxWidth && $imgData[1] == $this->maxHeight) {
             $this->thumb = $this->source;
         } else {
             imagecopyresampled($this->thumb, $this->source, 0, 0, 0, 0, $thumbnail->getThumbWidth(), $thumbnail->getThumbHeight(), $imgData[0], $imgData[1]);
         }
         return true;
     } else {
         throw new Exception(sprintf('Image MIME type %s not supported', $imgData['mime']));
     }
 }
开发者ID:silky,项目名称:littlesis,代码行数:30,代码来源:LsGDAdapter.class.php

示例12: a

function a(&$g)
{
    $a = imagecolorallocate($g, 0, 0, 0);
    imagecolortransparent($g, $a);
    imagealphablending($g, 0);
    imagesavealpha($g, 1);
}
开发者ID:timmyrs,项目名称:stack,代码行数:7,代码来源:outline.short.php

示例13: Create_pics

 function Create_pics($thumbnail, $source, $path, $ext)
 {
     global $CONFIG_GALLERY;
     imagecolortransparent($source, imagecolorallocate($source, 0, 0, 0));
     imagealphablending($source, false);
     $path_mini = str_replace('pics', 'pics/thumbnails', $path);
     if (function_exists('imagegif') && $ext === 'gif') {
         imagegif($thumbnail, $path_mini);
     } elseif (function_exists('imagejpeg') && $ext === 'jpg') {
         imagejpeg($thumbnail, $path_mini, $CONFIG_GALLERY['quality']);
     } elseif (function_exists('imagepng') && $ext === 'png') {
         imagepng($thumbnail, $path_mini);
     } else {
         $this->error = 'e_no_graphic_support';
     }
     switch ($ext) {
         case 'jpg':
             @imagejpeg($source, $path);
             break;
         case 'gif':
             @imagegif($source, $path);
             break;
         case 'png':
             @imagepng($source, $path);
             break;
         default:
             $this->error = 'e_no_graphic_support';
     }
 }
开发者ID:janus57,项目名称:PHPBoost_v3c,代码行数:29,代码来源:gallery.class.php

示例14: generate_image_memetext

function generate_image_memetext($text, $width = 400, $height = 400)
{
    global $submit, $ppath, $textpos, $updown, $textcaps, $mainimg;
    if ($submit) {
        $txt_img = imagecreatefromjpeg($ppath . 'images/main/' . basename($mainimg, '.jpg') . '.jpg');
    } else {
        $txt_img = imagecreatetruecolor($width, $height);
    }
    $transbak = imagecolorallocate($txt_img, 0, 0, 0);
    $trans = imagecolorallocatealpha($txt_img, 255, 255, 255, 255);
    if ($submit === false) {
        imagecolortransparent($txt_img, $transbak);
        imagefill($txt_img, 0, 0, $trans);
        imagealphablending($txt_img, true);
    }
    $pos = 1;
    $i = 0;
    foreach ($text as $tx) {
        if ($textcaps[$i] === 'caps') {
            $tx = strtoupper($tx);
        } elseif ($textcaps[$i] === 'small') {
            $tx = strtolower($tx);
        }
        meme_text($txt_img, $tx, $pos++, (int) $textpos[$i], $updown[$i]);
        $i++;
    }
    if ($submit) {
        imagejpeg($txt_img, $ppath . 'images/meme/' . $_POST['mid'] . '.jpg', 100);
    } else {
        imagepng($txt_img);
    }
    imagedestroy($txt_img);
}
开发者ID:maesson,项目名称:lyft,代码行数:33,代码来源:meme-text.php

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


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