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


PHP ImageColorTransparent函数代码示例

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


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

示例1: MyImageBlur

function MyImageBlur($im, $pct) {
	// w00t. my very own blur function
	// in GD2, there's a gaussian blur function. smarmy bastards. ;-)
	$width = imagesx($im);
	$height = imagesy($im);
	$temp_im = ImageCreate($width, $height);
	$bg = ImageColorAllocate($temp_im, 255, 255, 255);
	// preserves transparency if in orig image
	ImageColorTransparent($temp_im, $bg);
	// fill bg
	ImageFill($temp_im, 0, 0, $bg);
	$distance = 1;
	// emboss:
	ImageCopyMerge($temp_im, $im, 0, 0, $distance, $distance, $width, $height, $pct);
	ImageCopyMerge($im, $temp_im, -$distance, -$distance, 0, 0, $width, $height, $pct);
	ImageFill($temp_im, 0, 0, $bg);
	ImageCopyMerge($temp_im, $im, 0, $distance, $distance, 0, $width, $height, $pct);
	ImageCopyMerge($im, $temp_im, $distance, 0, 0, $distance, $width, $height, $pct);
	// blur:
	ImageCopyMerge($temp_im, $im, 0, $distance, 0, 0, $width, $height, $pct);
	ImageCopyMerge($im, $temp_im, $distance, 0, 0, 0, $width, $height, $pct);
	ImageCopyMerge($temp_im, $im, 0, 0, 0, $distance, $width, $height, $pct);
	ImageCopyMerge($im, $temp_im, 0, 0, $distance, 0, $width, $height, $pct);
	// remove temp image
	ImageDestroy($temp_im);
	return $im;
}
开发者ID:Naddiseo,项目名称:WW2Game,代码行数:27,代码来源:imageclick.php

示例2: JPGText

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

示例3: run

 public static function run($res, $width = NULL, $height = NULL)
 {
     $dst_w = Image::width($res);
     $dst_h = Image::height($res);
     if (!empty($width) && !empty($height)) {
         $dst_w = $width;
         $dst_h = $height;
     } elseif (empty($height)) {
         $ratio = $dst_h / $dst_w;
         $dst_w = $width;
         $dst_h = round($dst_w * $ratio);
     } elseif (empty($width)) {
         $ratio = $dst_w / $dst_h;
         $dst_h = $height;
         $dst_w = round($dst_h * $ratio);
     }
     $dst = imagecreatetruecolor($dst_w, $dst_h);
     /* making the new image transparent */
     $background = imagecolorallocate($dst, 0, 0, 0);
     ImageColorTransparent($dst, $background);
     // make the new temp image all transparent
     imagealphablending($dst, false);
     imagesavealpha($dst, true);
     imageAntiAlias($dst, true);
     self::__fill($dst);
     imagecopyresampled($dst, $res, 0, 0, 0, 0, $dst_w, $dst_h, Image::width($res), Image::height($res));
     @imagedestroy($res);
     return $dst;
 }
开发者ID:bauhouse,项目名称:sym-barebones,代码行数:29,代码来源:filter.resize.php

示例4: TextToImage

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

示例5: show_emptyimg

 function show_emptyimg($format = 'gif')
 {
     header('Content-Type: image/' . $format);
     $width = 1;
     $height = 1;
     $img = imageCreate($width, $height);
     //imageFilledRectangle($img, 0, 0, $width, $height, imagecolorallocate($img, 255, 255, 255));
     ImageColorTransparent($img, imagecolorallocate($img, 255, 255, 255));
     imagegif($img);
     imagedestroy($img);
     exit;
 }
开发者ID:GavinLai,项目名称:SimMatch,代码行数:12,代码来源:fst.php

示例6: draw

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

示例7: _unitpng

 /**
  * Create the transparent unitPng and return its URL
  *
  * @return string
  * @access private
  */
 function _unitpng()
 {
     if (file_exists($this->_oboxUnitPngPath)) {
         return $this->_oboxUnitPngURL;
     }
     $im = ImageCreate(1, 1);
     $trans = ImageColorAllocate($im, 128, 128, 128);
     ImageColorTransparent($im, $trans);
     ImageFilledRectangle($im, 0, 0, 1, 1, $trans);
     $this->_makeUnitPngPath();
     ImagePNG($im, $this->_oboxUnitPngPath);
     ImageDestroy($im);
     return $this->_oboxUnitURL;
 }
开发者ID:GeekyNinja,项目名称:LifesavingCAD,代码行数:20,代码来源:Widget.php

示例8: Image_Canvas_GD_PNG

 /**
  * Create the PNG canvas
  *
  * @param array $param Parameter array
  */
 function Image_Canvas_GD_PNG($param)
 {
     parent::Image_Canvas_GD($param);
     if (isset($param['transparent']) && $param['transparent'] && $this->_gd2) {
         if ($param['transparent'] === true) {
             $transparent = '#123ABD';
         } else {
             $transparent = $param['transparent'];
         }
         $color = $this->_color($transparent);
         $trans = ImageColorTransparent($this->_canvas, $color);
         $this->rectangle(array('x0' => $this->_left, 'y0' => $this->_top, 'x1' => $this->_left + $this->_width - 1, 'y1' => $this->_top + $this->_height - 1, 'fill' => 'opague', 'line' => 'transparent'));
     } else {
         $this->rectangle(array('x0' => $this->_left, 'y0' => $this->_top, 'x1' => $this->_left + $this->_width - 1, 'y1' => $this->_top + $this->_height - 1, 'fill' => 'white', 'line' => 'transparent'));
     }
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:21,代码来源:PNG.php

示例9: image_resize

 /**
  * 将图片缩放到指定大小,并保存到指定路径,如果图片类型不支持则直接复制文件
  *
  * @param string $src 源文件的绝对路径
  * @param string $dest 目标文件的绝对路径
  * @param int $w 目标宽度
  * @param int $h 目标高度
  */
 public static function image_resize($src, $dest, $w, $h)
 {
     $img = getimagesize($src);
     switch ($img[2]) {
         case 1:
             $im_in = imagecreatefromgif($src);
             $im_out = imagecreate($w, $h);
             $bgcolor = imagecolorallocate($im_out, 0, 0, 0);
             $bgcolortrans = ImageColorTransparent($im_out, $bgcolor);
             break;
         case 2:
             $im_in = imagecreatefromjpeg($src);
             $im_out = imagecreatetruecolor($w, $h);
             break;
         case 3:
             $im_in = imagecreatefrompng($src);
             $im_out = imagecreatetruecolor($w, $h);
             imagealphablending($im_out, true);
             imagesavealpha($im_out, true);
             $trans_colour = imagecolorallocatealpha($im_out, 0, 0, 0, 127);
             imagefill($im_out, 0, 0, $trans_colour);
             break;
         default:
             copy($src, $dest);
     }
     if (!$im_in || !$im_out) {
         return false;
     }
     imagecopyresampled($im_out, $im_in, 0, 0, 0, 0, $w, $h, $img[0], $img[1]);
     switch ($img[2]) {
         case 1:
             imagegif($im_out, $dest);
             break;
         case 2:
             imagejpeg($im_out, $dest);
             break;
         case 3:
             imagepng($im_out, $dest);
             break;
         default:
             return -5;
             //保存失败
     }
     imagedestroy($im_out);
     imagedestroy($im_in);
 }
开发者ID:snje1987,项目名称:minifw,代码行数:54,代码来源:Image.php

示例10: myImageBlur

function myImageBlur($im)
{
    $width = imagesx($im);
    $height = imagesy($im);
    $temp_im = ImageCreateTrueColor($width, $height);
    $bg = ImageColorAllocate($temp_im, 150, 150, 150);
    // preserves transparency if in orig image
    ImageColorTransparent($temp_im, $bg);
    // fill bg
    ImageFill($temp_im, 0, 0, $bg);
    $distance = 1;
    // blur by merging with itself at different x/y offsets:
    ImageCopyMerge($temp_im, $im, 0, 0, 0, $distance, $width, $height - $distance, 70);
    ImageCopyMerge($im, $temp_im, 0, 0, $distance, 0, $width - $distance, $height, 70);
    ImageCopyMerge($temp_im, $im, 0, $distance, 0, 0, $width, $height, 70);
    ImageCopyMerge($im, $temp_im, $distance, 0, 0, 0, $width, $height, 70);
    // remove temp image
    ImageDestroy($temp_im);
    return $im;
}
开发者ID:wazari972,项目名称:blogotext,代码行数:20,代码来源:freecap.php

示例11: output_png

 function output_png($poll_id, $radius)
 {
     if ($radius < 20) {
         $radius = 90;
     }
     $diameter = $radius * 2;
     $img_size = $diameter + 2;
     if ($this->is_valid_poll_id($poll_id)) {
         $img = ImageCreate($img_size, $img_size);
         for (reset($this->colors); $key = key($this->colors); next($this->colors)) {
             eval("\$poll_colors[\$key]=ImageColorAllocate(\$img," . $this->colors[$key] . ");");
         }
         ImageFill($img, 0, 0, $poll_colors['blank']);
         Imagearc($img, $radius, $radius, $diameter, $diameter, 0, 360, $poll_colors['black']);
         if (!isset($this->options[$poll_id])) {
             $this->get_poll_data($poll_id);
         }
         $totalvotes = $this->options[$poll_id]['total'] == 0 ? 1 : $this->options[$poll_id]['total'];
         for ($i = 0; $i < sizeof($this->options[$poll_id]['option_id']); $i++) {
             $img_width = $this->options[$poll_id]['votes'][$i] * 360 / $totalvotes;
             $end = $this->begin + $img_width;
             $y1 = sin($end / 180 * M_PI) * $radius;
             $x1 = cos($end / 180 * M_PI) * $radius;
             Imageline($img, $radius, $radius, $radius + $x1, $radius + $y1, $poll_colors['black']);
             $end2 = $this->begin + $img_width * 0.5;
             $x2 = (int) ($radius + cos($end2 / 180 * M_PI) * 15);
             $y2 = (int) ($radius + sin($end2 / 180 * M_PI) * 15);
             Imagefilltoborder($img, $x2, $y2, $poll_colors['black'], $poll_colors[$this->options[$poll_id]['color'][$i]]);
             $this->begin += $img_width;
         }
         $this->begin = 0;
         ImageColorTransparent($img, $poll_colors['blank']);
         ImagePNG($img);
     } else {
         $loc = "{$pollvars['base_url']}/image/error.png";
         header("Location: {$loc}");
         exit;
     }
 }
开发者ID:BackupTheBerlios,项目名称:rescuedogportal-svn,代码行数:39,代码来源:class_pgfx.php

示例12: makeBlankImage

function makeBlankImage($width = 4, $height = 7)
{
    //bild generieren
    $ImageOut = ImageCreate($width, $height);
    $White = ImageColorAllocate($ImageOut, 255, 255, 255);
    $FC = $White;
    $BG = $White;
    $TC = $BG;
    ImageColorTransparent($ImageOut, $TC);
    ImageFill($ImageOut, 0, 0, $BG);
    Imageinterlace($ImageOut, 1);
    return $ImageOut;
}
开发者ID:aydancoskun,项目名称:octobercms,代码行数:13,代码来源:news_blank.png.inc.php

示例13: makeAvatarGifThumb

/**
 *  创建头像动态gif缩略图
 * @param $imageSource
 * @param $srcW
 * @param $srcH
 * @param $dstW
 * @param $dstH
 */
function makeAvatarGifThumb($imageSource, $srcW, $srcH, $dstW, $dstH)
{
    if ($srcW <= $dstW && $srcH <= $dstH) {
        return $imageSource;
    }
    $imageSource = imagecreatefromstring($imageSource);
    list($imagecreate, $imagecopyre) = GetImageCreate('gif');
    if ($srcW / $dstW < $srcH / $dstH) {
        $finalW = round($dstH / $srcH * $srcW);
        $finalH = $dstH;
    } elseif ($srcW / $dstW > $srcH / $dstH) {
        $finalW = $dstW;
        $finalH = round($dstW / $srcW * $srcH);
    } else {
        $finalW = $dstW;
        $finalH = $dstH;
    }
    $thumb = $imagecreate($finalW, $finalH);
    if (function_exists('ImageColorAllocate') && function_exists('ImageColorTransparent')) {
        //背景透明处理
        $black = ImageColorAllocate($thumb, 0, 0, 0);
        $bgTransparent = ImageColorTransparent($thumb, $black);
    }
    $imagecopyre($thumb, $imageSource, 0, 0, 0, 0, $finalW, $finalH, $srcW, $srcH);
    ob_start();
    imagegif($thumb);
    imagedestroy($thumb);
    $imageStream = ob_get_contents();
    ob_end_clean();
    return $imageStream;
}
开发者ID:sherlockhouse,项目名称:aliyun,代码行数:39,代码来源:imgfunc.php

示例14: _saveAlpha

 /**
  * Fixes saving PNG alpha channel
  *
  * @param resource $imageHandler
  * @return void
  */
 private function _saveAlpha($imageHandler)
 {
     $background = imagecolorallocate($imageHandler, 0, 0, 0);
     ImageColorTransparent($imageHandler, $background);
     imagealphablending($imageHandler, false);
     imagesavealpha($imageHandler, true);
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:13,代码来源:Gd2.php

示例15: _resizeGD

 function _resizeGD($sSrcImage, $sDstImage)
 {
     $iErr = 0;
     $src_im =& $this->_createGDImage($sSrcImage, $size, $iErr);
     $sizeOrig = $size;
     if ($iErr) {
         return $iErr;
     }
     if (!$src_im) {
         return IMAGE_ERROR_GD_OPEN_FAILED;
     }
     $xd = $yd = 0;
     $xs = $ys = 0;
     if ($this->_isCrop) {
         $size[0] = $this->_cropW;
         $size[1] = $this->_cropH;
         $xs = $this->_cropX;
         $ys = $this->_cropY;
         $destW = $this->w;
         $destH = $this->h;
     } elseif ($this->_isSquareResize) {
         $destW = $this->w;
         $destH = $this->h;
         if ($size[0] < $size[1]) {
             $d = ($size[1] - $size[0]) / 2;
             $size[1] = $size[0];
             $xs = 0;
             $ys = (int) $d;
         } else {
             $d = ($size[0] - $size[1]) / 2;
             $size[0] = $size[1];
             $xs = (int) $d;
             $ys = 0;
         }
     } else {
         // determ destination size
         $sourceRatio = (double) ($size[0] / $size[1]);
         $destRatio = (double) ($this->w / $this->h);
         if ($sourceRatio > $destRatio) {
             $resizeRatio = (double) ($this->w / $size[0]);
         } else {
             $resizeRatio = (double) ($this->h / $size[1]);
         }
         $destW = (int) ($resizeRatio * $size[0]);
         $destH = (int) ($resizeRatio * $size[1]);
     }
     // this is more qualitative function, but it doesn't exist in old GD and doesn't support GIF format
     if (function_exists('imagecreatetruecolor') && $size[2] != IMAGE_TYPE_GIF) {
         // resize only if size is larger than needed
         if ($this->_isCrop || $sizeOrig[0] > $this->w || $sizeOrig[1] > $this->h) {
             $dst_im = imagecreatetruecolor($destW, $destH);
             imagecolortransparent($dst_im, imagecolorallocate($dst_im, 0, 0, 0));
             imagealphablending($dst_im, false);
             imagesavealpha($dst_im, true);
             $convertResult = imagecopyresampled($dst_im, $src_im, $xd, $yd, $xs, $ys, $destW, $destH, $size[0], $size[1]);
         } else {
             $dst_im = $src_im;
             $convertResult = true;
         }
     } else {
         // this is for old GD versions and for GIF images
         // resize only if size is larger than needed
         if ($size[0] > $this->w || $size[1] > $this->h) {
             $dst_im = imagecreate($destW, $destH);
             if ($size[2] == IMAGE_TYPE_GIF) {
                 ImageColorTransparent($dst_im, imagecolorallocate($dst_im, 0, 0, 0));
                 imagealphablending($dst_im, false);
             }
             $convertResult = imagecopyresized($dst_im, $src_im, $xd, $yd, $xs, $ys, $destW, $destH, $size[0], $size[1]);
         } else {
             $dst_im = $src_im;
             $convertResult = true;
         }
     }
     if (!$convertResult) {
         return IMAGE_ERROR_GD_RESIZE_ERROR;
     }
     // if output always in JPG
     if ($forceJPGOutput) {
         $writeResult = imagejpeg($dst_im, $sDstImage, $this->_iJpegQuality);
     } else {
         // otherwise
         switch ($size[2]) {
             case IMAGE_TYPE_GIF:
                 $writeResult = imagegif($dst_im, $sDstImage);
                 break;
             case IMAGE_TYPE_JPG:
                 $writeResult = imagejpeg($dst_im, $sDstImage, $this->_iJpegQuality);
                 break;
             case IMAGE_TYPE_PNG:
                 $writeResult = imagepng($dst_im, $sDstImage);
                 break;
         }
     }
     // free memory
     if ($dst_im != $src_im) {
         imagedestroy($src_im);
         imagedestroy($dst_im);
     } else {
         imagedestroy($src_im);
//.........这里部分代码省略.........
开发者ID:Arvindvi,项目名称:dolphin,代码行数:101,代码来源:BxDolImageResize.php


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