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

PHP imagecolortransparent函数代码示例

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

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



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


示例16: fixart

function fixart($id, $hue, $show)
{
    if (!file_exists("images/art/fixedart_" . $id . "_" . $hue . ".png")) {
        if (!file_exists("images/art/art_" . $id . "_" . $hue . ".png")) {
            include "art.php";
            createart($id, $hue, 0);
        }
        $imgurl = "images/art/art_" . $id . "_" . $hue . ".png";
        $img = imagecreatefrompng("{$imgurl}");
        $box = imageTrimBox($img);
        $img2 = imagecreatetruecolor($box['w'], $box['h']);
        imagecopy($img2, $img, 0, 0, $box['l'], $box['t'], $box['w'], $box['h']);
        imagepng($img2, 'images/art/fixedart_' . $id . '_' . $hue . '.png', 0, NULL);
        imagedestroy($img);
        imagedestroy($img2);
    }
    if ($show == 1) {
        Header("Content-type: image/png");
        Header("Content-disposition: inline; filename=art_" . $id . "_" . $hue . ".png");
        $img = imagecreatefrompng("images/art/fixedart_" . $id . "_" . $hue . ".png");
        $black = imagecolorallocate($img, 0, 0, 0);
        imagecolortransparent($img, $black);
        imagepng($img);
        imagedestroy($img);
        return;
    }
}
开发者ID:GODEXTREME,项目名称:UO-PHP-Files,代码行数:27,代码来源:itemlink.php


示例17: create_error

 function create_error($text)
 {
     $text = $text;
     $size = "8";
     $font = "classes/fonts/trebuchet.ttf";
     $TextBoxSize = imagettfbbox($size, 0, $font, preg_replace("/\\[br\\]/is", "\r\n", $text));
     $TxtBx_Lwr_L_x = $TextBoxSize[0];
     $TxtBx_Lwr_L_y = $TextBoxSize[1];
     $TxtBx_Lwr_R_x = $TextBoxSize[2];
     $TxtBx_Lwr_R_y = $TextBoxSize[3];
     $TxtBx_Upr_R_x = $TextBoxSize[4];
     $TxtBx_Upr_R_y = $TextBoxSize[5];
     $TxtBx_Upr_L_x = $TextBoxSize[6];
     $TxtBx_Upr_L_y = $TextBoxSize[7];
     $width = max($TxtBx_Lwr_R_x, $TxtBx_Upr_R_x) - min($TxtBx_Lwr_L_x, $TxtBx_Upr_L_x);
     $height = max($TxtBx_Lwr_L_y, $TxtBx_Lwr_R_y) - min($TxtBx_Upr_R_y, $TxtBx_Upr_L_y);
     $x = -min($TxtBx_Upr_L_x, $TxtBx_Lwr_L_x);
     $y = -min($TxtBx_Upr_R_y, $TxtBx_Upr_L_y);
     $img = imagecreate($width + 2, $height + 1);
     // Only PHP-Version 4.3.2 or higher
     if (function_exists('imageantialias')) {
         imageantialias($img, FALSE);
     }
     $white = imagecolorallocate($img, 255, 255, 255);
     $black = imagecolorallocate($img, 0, 0, 0);
     imagecolortransparent($img, $white);
     ImageTTFText($img, $size, 0, $x, $y, $black, $font, preg_replace("/<br>/is", "\r\n", $text));
     header("Content-Type: image/png");
     ImagePNG($img);
     ImageDestroy($img);
     exit;
 }
开发者ID:BackupTheBerlios,项目名称:viscacha-svn,代码行数:32,代码来源:class.thumbnail.php


示例18: render

 /**
  * @param Frame $frame
  * @param $index
  * @return resource
  */
 protected function render(Frame $frame, $index)
 {
     if ($index == 0) {
         $screenSize = $this->decoder->getScreenSize();
         $im = imagecreatetruecolor($screenSize->getWidth(), $screenSize->getHeight());
         imagealphablending($im, false);
         imagesavealpha($im, true);
         $transColor = imagecolortransparent($im, imagecolorallocatealpha($im, 255, 255, 255, 127));
         imagefill($im, 0, 0, $transColor);
         $this->frameCurrent = $im;
         $this->framePrevious = $frame;
         $this->copyFrameToBuffer($frame);
         return $this->frameCurrent;
     }
     imagepalettetotruecolor($this->frameCurrent);
     $disposalMethod = $this->framePrevious->getDisposalMethod();
     if ($disposalMethod === 0 || $disposalMethod === 1) {
         $this->copyFrameToBuffer($frame);
     } elseif ($disposalMethod === 2) {
         $this->restoreToBackground($this->framePrevious, imagecolortransparent($this->frameCurrent));
         $this->copyFrameToBuffer($frame);
     } else {
         throw new \RuntimeException("Disposal method {$disposalMethod} is not implemented.");
     }
     $this->framePrevious = $frame;
     return $this->frameCurrent;
 }
开发者ID:Nasawa,项目名称:regif,代码行数:32,代码来源:Renderer.php


示例19: add_image

 /**
  * Add an image to the generator.
  *
  * This function adds a source image to the generator. It serves two main purposes: add a source image if one was
  * not supplied to the constructor and to add additional source images so that different images can be supplied for
  * different sized images in the resulting ICO file. For instance, a small source image can be used for the small
  * resolutions while a larger source image can be used for large resolutions.
  *
  * @param string $file Path to the source image file.
  * @param array $sizes Optional. An array of sizes (each size is an array with a width and height) that the source image should be rendered at in the generated ICO file. If sizes are not supplied, the size of the source image will be used.
  * @return boolean true on success and false on failure.
  */
 public function add_image($file, $sizes = array())
 {
     if (!$this->_has_requirements) {
         return false;
     }
     if (false === ($im = $this->_load_image_file($file))) {
         return false;
     }
     if (empty($sizes)) {
         $sizes = array(imagesx($im), imagesy($im));
     }
     // If just a single size was passed, put it in array.
     if (!is_array($sizes[0])) {
         $sizes = array($sizes);
     }
     foreach ((array) $sizes as $size) {
         list($width, $height) = $size;
         $new_im = imagecreatetruecolor($width, $height);
         imagecolortransparent($new_im, imagecolorallocatealpha($new_im, 0, 0, 0, 127));
         imagealphablending($new_im, false);
         imagesavealpha($new_im, true);
         $source_width = imagesx($im);
         $source_height = imagesy($im);
         if (false === imagecopyresampled($new_im, $im, 0, 0, 0, 0, $width, $height, $source_width, $source_height)) {
             continue;
         }
         $this->_add_image_data($new_im);
     }
     return true;
 }
开发者ID:elvyrra,项目名称:hawk,代码行数:42,代码来源:PHPICO.php


示例20: makeThumb

 /**
  * 生成略缩图
  * 
  * @param string $srcFile     		源图片
  * @param string $dstFile     		略缩图保存位置
  * @param int $dstW           		略缩图宽度
  * @param string $dstH        		略缩图高度
  * @param string $isProportion      略缩图是否等比略缩,默认为false
  * @return array|boolean
  */
 public static function makeThumb($srcFile, $dstFile, $dstW, $dstH, $isProportion = FALSE)
 {
     if (false === ($minitemp = self::getThumbInfo($srcFile, $dstW, $dstH, $isProportion))) {
         return false;
     }
     list($imagecreate, $imagecopyre) = self::getImgcreate($minitemp['type']);
     if (!$imagecreate) {
         return false;
     }
     $imgwidth = $minitemp['width'];
     $imgheight = $minitemp['height'];
     $srcX = $srcY = $dstX = $dstY = 0;
     if (!$isProportion) {
         $dsDivision = $imgheight / $imgwidth;
         $fixDivision = $dstH / $dstW;
         if ($dsDivision > $fixDivision) {
             $tmp = $imgwidth * $fixDivision;
             $srcY = round(($imgheight - $tmp) / 2);
             $imgheight = $tmp;
         } else {
             $tmp = $imgheight / $fixDivision;
             $srcX = round(($imgwidth - $tmp) / 2);
             $imgwidth = $tmp;
         }
     }
     $thumb = $imagecreate($minitemp['dstW'], $minitemp['dstH']);
     if (function_exists('imagecolorallocate') && function_exists('imagecolortransparent')) {
         $black = imagecolorallocate($thumb, 0, 0, 0);
         imagecolortransparent($thumb, $black);
     }
     $imagecopyre($thumb, $minitemp['source'], $dstX, $dstY, $srcX, $srcY, $minitemp['dstW'], $minitemp['dstH'], $imgwidth, $imgheight);
     self::makeImg($minitemp['type'], $thumb, $dstFile);
     imagedestroy($thumb);
     return array('width' => $minitemp['dstW'], 'height' => $minitemp['dstH'], 'type' => $minitemp['type']);
 }
开发者ID:ccq18,项目名称:EduSoho,代码行数:45,代码来源:WindImage.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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