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


PHP WideImage_Image::asTrueColor方法代码示例

本文整理汇总了PHP中WideImage_Image::asTrueColor方法的典型用法代码示例。如果您正苦于以下问题:PHP WideImage_Image::asTrueColor方法的具体用法?PHP WideImage_Image::asTrueColor怎么用?PHP WideImage_Image::asTrueColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WideImage_Image的用法示例。


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

示例1: execute

 /**
  * Executes imageconvolution() filter.
  *
  * @param WideImage_Image $image
  * @param array           $matrix
  * @param numeric         $div
  * @param numeric         $offset
  *
  * @return WideImage_Image
  */
 public function execute($image, $matrix, $div, $offset)
 {
     $new = $image->asTrueColor();
     if (!imageconvolution($new->getHandle(), $matrix, $div, $offset)) {
         throw new WideImage_GDFunctionResultException('imageconvolution() returned false');
     }
     return $new;
 }
开发者ID:dongilbert,项目名称:mautic,代码行数:18,代码来源:ApplyConvolution.php

示例2: execute

 /**
  * Returns a greyscale copy of an image
  *
  * @param WideImage_Image $image
  * @return WideImage_Image
  */
 function execute($image)
 {
     $new = $image->asTrueColor();
     if (!imagefilter($new->getHandle(), IMG_FILTER_GRAYSCALE)) {
         throw new WideImage_GDFunctionResultException("imagefilter() returned false");
     }
     if (!$image->isTrueColor()) {
         $new = $new->asPalette();
     }
     return $new;
 }
开发者ID:NaszvadiG,项目名称:DivaSul,代码行数:17,代码来源:AsGrayscale.php

示例3: execute

 /**
  * Applies a mask on the copy of source image
  *
  * @param WideImage_Image $image
  * @param WideImage_Image $mask
  * @param smart_coordinate $left
  * @param smart_coordinate $top
  * @return WideImage_Image
  */
 function execute($image, $mask, $left = 0, $top = 0)
 {
     $left = WideImage_Coordinate::fix($left, $image->getWidth(), $mask->getWidth());
     $top = WideImage_Coordinate::fix($top, $image->getHeight(), $mask->getHeight());
     $width = $image->getWidth();
     $mask_width = $mask->getWidth();
     $height = $image->getHeight();
     $mask_height = $mask->getHeight();
     $result = $image->asTrueColor();
     $result->alphaBlending(false);
     $result->saveAlpha(true);
     $srcTransparentColor = $result->getTransparentColor();
     if ($srcTransparentColor >= 0) {
         # this was here. works without.
         #$trgb = $image->getColorRGB($srcTransparentColor);
         #$trgb['alpha'] = 127;
         #$destTransparentColor = $result->allocateColorAlpha($trgb);
         #$result->setTransparentColor($destTransparentColor);
         $destTransparentColor = $srcTransparentColor;
     } else {
         $destTransparentColor = $result->allocateColorAlpha(255, 255, 255, 127);
     }
     for ($x = 0; $x < $width; $x++) {
         for ($y = 0; $y < $height; $y++) {
             $mx = $x - $left;
             $my = $y - $top;
             if ($mx >= 0 && $mx < $mask_width && $my >= 0 && $my < $mask_height) {
                 $srcColor = $image->getColorAt($x, $y);
                 if ($srcColor == $srcTransparentColor) {
                     $destColor = $destTransparentColor;
                 } else {
                     $maskRGB = $mask->getRGBAt($mx, $my);
                     if ($maskRGB['red'] == 0) {
                         $destColor = $destTransparentColor;
                     } elseif ($srcColor >= 0) {
                         $imageRGB = $image->getRGBAt($x, $y);
                         $level = $maskRGB['red'] / 255 * (1 - $imageRGB['alpha'] / 127);
                         $imageRGB['alpha'] = 127 - round($level * 127);
                         if ($imageRGB['alpha'] == 127) {
                             $destColor = $destTransparentColor;
                         } else {
                             $destColor = $result->allocateColorAlpha($imageRGB);
                         }
                     } else {
                         $destColor = $destTransparentColor;
                     }
                 }
                 $result->setColorAt($x, $y, $destColor);
             }
         }
     }
     return $result;
 }
开发者ID:NaszvadiG,项目名称:DivaSul,代码行数:62,代码来源:ApplyMask.php

示例4: execute

 /**
  * Applies a mask on the copy of source image
  *
  * @param WideImage_Image $image
  * @param WideImage_Image $mask
  * @param smart_coordinate $left
  * @param smart_coordinate $top
  * @return WideImage_Image
  */
 function execute($image, $mask, $left = 0, $top = 0)
 {
     $left = WideImage_Coordinate::fix($image->getWidth(), $left);
     $top = WideImage_Coordinate::fix($image->getHeight(), $top);
     $width = $image->getWidth();
     if ($width > $mask->getWidth()) {
         $width = $mask->getWidth();
     }
     $height = $image->getHeight();
     if ($height > $mask->getHeight()) {
         $height = $mask->getHeight();
     }
     $result = $image->asTrueColor();
     $result->alphaBlending(false);
     $result->saveAlpha(true);
     $srcTransparentColor = $image->getTransparentColor();
     if ($srcTransparentColor >= 0) {
         $trgb = $image->getColorRGB($srcTransparentColor);
         $trgb['alpha'] = 127;
         $destTransparentColor = $result->allocateColorAlpha($trgb);
         $result->setTransparentColor($destTransparentColor);
     } else {
         $destTransparentColor = $result->allocateColorAlpha(255, 255, 255, 127);
     }
     for ($x = 0; $x < $width; $x++) {
         for ($y = 0; $y < $height; $y++) {
             if ($left + $x < $image->getWidth() && $top + $y < $image->getHeight()) {
                 $srcColor = $image->getColorAt($left + $x, $top + $y);
                 if ($srcColor == $srcTransparentColor) {
                     $destColor = $destTransparentColor;
                 } else {
                     $maskRGB = $mask->getRGBAt($x, $y);
                     if ($maskRGB['red'] == 0) {
                         $destColor = $destTransparentColor;
                     } elseif ($srcColor >= 0) {
                         $imageRGB = $image->getRGBAt($left + $x, $top + $y);
                         $level = $maskRGB['red'] / 255 * (1 - $imageRGB['alpha'] / 127);
                         $imageRGB['alpha'] = 127 - round($level * 127);
                         if ($imageRGB['alpha'] == 127) {
                             $destColor = $destTransparentColor;
                         } else {
                             $destColor = $result->allocateColorAlpha($imageRGB);
                         }
                     } else {
                         $destColor = $destTransparentColor;
                     }
                 }
                 $result->setColorAt($left + $x, $top + $y, $destColor);
             }
         }
     }
     return $result;
 }
开发者ID:eduardosilvapereira,项目名称:mcja,代码行数:62,代码来源:ApplyMask.php

示例5: execute

 /**
  * Executes imagefilter
  *
  * @param WideImage_Image $image
  * @param int $filter 
  * @param numeric $arg1
  * @param numeric $arg2
  * @param numeric $arg3
  * @return WideImage_TrueColorImage
  */
 function execute($image, $filter, $arg1 = null, $arg2 = null, $arg3 = null, $arg4 = null)
 {
     $new = $image->asTrueColor();
     if (in_array($filter, self::$one_arg_filters)) {
         imagefilter($new->getHandle(), $filter, $arg1);
     } elseif (defined('IMG_FILTER_PIXELATE') && $filter == IMG_FILTER_PIXELATE) {
         imagefilter($new->getHandle(), $filter, $arg1, $arg2);
     } elseif ($filter == IMG_FILTER_COLORIZE) {
         imagefilter($new->getHandle(), $filter, $arg1, $arg2, $arg3, $arg4);
     } else {
         imagefilter($new->getHandle(), $filter);
     }
     return $new;
 }
开发者ID:google-code-backups,项目名称:rsslounge,代码行数:24,代码来源:ApplyFilter.php

示例6: execute

 /**
  * Returns image with noise added
  *
  * @param WideImage_Image $image
  * @param float $amount
  * @param const $type
  * @param float $threshold
  * @return WideImage_Image
  */
 function execute($image, $amount, $type)
 {
     switch ($type) {
         case 'salt&pepper':
             $fun = 'saltPepperNoise_fun';
             break;
         case 'color':
             $fun = 'colorNoise_fun';
             break;
         default:
             $fun = 'monoNoise_fun';
             break;
     }
     return self::filter($image->asTrueColor(), $fun, $amount);
 }
开发者ID:baltruschat,项目名称:selectconnect,代码行数:24,代码来源:AddNoise.php

示例7: execute

 /**
  * Returns a merged image
  *
  * @param WideImage_Image $base
  * @param WideImage_Image $overlay
  * @param smart_coordinate $left
  * @param smart_coordinate $top
  * @param numeric $pct
  * @return WideImage_Image
  */
 function execute($base, $overlay, $left, $top, $pct)
 {
     $x = WideImage_Coordinate::fix($base->getWidth(), $left);
     $y = WideImage_Coordinate::fix($base->getHeight(), $top);
     $result = $base->asTrueColor();
     $result->alphaBlending(true);
     $result->saveAlpha(true);
     if ($pct == 0) {
         return $result;
     }
     if ($pct < 100) {
         imagecopymerge($result->getHandle(), $overlay->getHandle(), $x, $y, 0, 0, $overlay->getWidth(), $overlay->getHeight(), $pct);
     } else {
         imagecopy($result->getHandle(), $overlay->getHandle(), $x, $y, 0, 0, $overlay->getWidth(), $overlay->getHeight());
     }
     return $result;
 }
开发者ID:eduardosilvapereira,项目名称:mcja,代码行数:27,代码来源:Merge.php

示例8: execute

 /**
  * Executes imagefilter
  *
  * @param WideImage_Image $image
  * @param int $filter 
  * @param numeric $arg1
  * @param numeric $arg2
  * @param numeric $arg3
  * @return WideImage_TrueColorImage
  */
 function execute($image, $filter, $arg1 = null, $arg2 = null, $arg3 = null, $arg4 = null)
 {
     $new = $image->asTrueColor();
     if (in_array($filter, self::$one_arg_filters)) {
         $res = imagefilter($new->getHandle(), $filter, $arg1);
     } elseif (defined('IMG_FILTER_PIXELATE') && $filter == IMG_FILTER_PIXELATE) {
         $res = imagefilter($new->getHandle(), $filter, $arg1, $arg2);
     } elseif ($filter == IMG_FILTER_COLORIZE) {
         $res = imagefilter($new->getHandle(), $filter, $arg1, $arg2, $arg3, $arg4);
     } else {
         $res = imagefilter($new->getHandle(), $filter);
     }
     if (!$res) {
         throw new WideImage_GDFunctionResultException("imagefilter() returned false");
     }
     return $new;
 }
开发者ID:Jandersolutions,项目名称:mautic,代码行数:27,代码来源:ApplyFilter.php

示例9: execute

 /**
  * Returns a greyscale copy of an image
  *
  * @param WideImage_Image $image
  * @return WideImage_Image
  */
 function execute($image)
 {
     $palette = $image instanceof WideImage_PaletteImage;
     $transparent = $image->isTransparent();
     if ($palette && $transparent) {
         $tci = $image->getTransparentColor();
     }
     $new = $image->asTrueColor();
     imagefilter($new->getHandle(), IMG_FILTER_GRAYSCALE);
     if ($palette) {
         $new = $new->asPalette();
         if ($transparent) {
             $new->setTransparentColor($tci);
         }
     }
     return $new;
 }
开发者ID:victorborg3s,项目名称:kimera,代码行数:23,代码来源:AsGrayscale.php

示例10: execute

 /**
  * Returns a merged image.
  *
  * @param WideImage_Image  $base
  * @param WideImage_Image  $overlay
  * @param smart_coordinate $left
  * @param smart_coordinate $top
  * @param numeric          $pct
  *
  * @return WideImage_Image
  */
 public function execute($base, $overlay, $left, $top, $pct)
 {
     $x = WideImage_Coordinate::fix($left, $base->getWidth(), $overlay->getWidth());
     $y = WideImage_Coordinate::fix($top, $base->getHeight(), $overlay->getHeight());
     $result = $base->asTrueColor();
     $result->alphaBlending(true);
     $result->saveAlpha(true);
     if ($pct <= 0) {
         return $result;
     }
     if ($pct < 100) {
         if (!imagecopymerge($result->getHandle(), $overlay->getHandle(), $x, $y, 0, 0, $overlay->getWidth(), $overlay->getHeight(), $pct)) {
             throw new WideImage_GDFunctionResultException('imagecopymerge() returned false');
         }
     } else {
         if (!imagecopy($result->getHandle(), $overlay->getHandle(), $x, $y, 0, 0, $overlay->getWidth(), $overlay->getHeight())) {
             throw new WideImage_GDFunctionResultException('imagecopy() returned false');
         }
     }
     return $result;
 }
开发者ID:dongilbert,项目名称:mautic,代码行数:32,代码来源:Merge.php

示例11: execute

 /**
  * Returns a greyscale copy of an image
  *
  * @param WideImage_Image $image
  * @return WideImage_Image
  */
 function execute($image)
 {
     $palette = !$image->isTrueColor();
     $transparent = $image->isTransparent();
     if ($palette && $transparent) {
         $tcrgb = $image->getTransparentColorRGB();
     }
     $new = $image->asTrueColor();
     if (!imagefilter($new->getHandle(), IMG_FILTER_NEGATE)) {
         throw new WideImage_GDFunctionResultException("imagefilter() returned false");
     }
     if ($palette) {
         $new = $new->asPalette();
         if ($transparent) {
             $irgb = array('red' => 255 - $tcrgb['red'], 'green' => 255 - $tcrgb['green'], 'blue' => 255 - $tcrgb['blue'], 'alpha' => 127);
             // needs imagecolorexactalpha instead of imagecolorexact, otherwise doesn't work on some transparent GIF images
             $new_tci = imagecolorexactalpha($new->getHandle(), $irgb['red'], $irgb['green'], $irgb['blue'], 127);
             $new->setTransparentColor($new_tci);
         }
     }
     return $new;
 }
开发者ID:ehazell,项目名称:AZDWR,代码行数:28,代码来源:AsNegative.php

示例12: execute

 /**
  * @param WideImage_Image $image
  * @param int $radius
  * @param int $color
  * @param int $smoothness
  * @return WideImage_Image
  */
 function execute($image, $radius, $color, $smoothness, $corners)
 {
     if ($smoothness < 1) {
         $sample_ratio = 1;
     } elseif ($smoothness > 16) {
         $sample_ratio = 16;
     } else {
         $sample_ratio = $smoothness;
     }
     $corner = WideImage::createTrueColorImage($radius * $sample_ratio, $radius * $sample_ratio);
     if ($color === null) {
         imagepalettecopy($corner->getHandle(), $image->getHandle());
         $bg_color = $corner->allocateColor(0, 0, 0);
         $corner->fill(0, 0, $bg_color);
         $fg_color = $corner->allocateColor(255, 255, 255);
         $corner->getCanvas()->filledEllipse($radius * $sample_ratio, $radius * $sample_ratio, $radius * 2 * $sample_ratio, $radius * 2 * $sample_ratio, $fg_color);
         $corner = $corner->resize($radius, $radius);
         $result = $image->asTrueColor();
         $tc = $result->getTransparentColor();
         if ($tc == -1) {
             $tc = $result->allocateColorAlpha(255, 255, 255, 127);
             imagecolortransparent($result->getHandle(), $tc);
             $result->setTransparentColor($tc);
         }
         if ($corners & WideImage::SIDE_TOP_LEFT || $corners & WideImage::SIDE_LEFT || $corners & WideImage::SIDE_TOP) {
             $result = $result->applyMask($corner, -1, -1);
         }
         $corner = $corner->rotate(90);
         if ($corners & WideImage::SIDE_TOP_RIGHT || $corners & WideImage::SIDE_TOP || $corners & WideImage::SIDE_RIGHT) {
             $result = $result->applyMask($corner, $result->getWidth() - $corner->getWidth() + 1, -1, 100);
         }
         $corner = $corner->rotate(90);
         if ($corners & WideImage::SIDE_BOTTOM_RIGHT || $corners & WideImage::SIDE_RIGHT || $corners & WideImage::SIDE_BOTTOM) {
             $result = $result->applyMask($corner, $result->getWidth() - $corner->getWidth() + 1, $result->getHeight() - $corner->getHeight() + 1, 100);
         }
         $corner = $corner->rotate(90);
         if ($corners & WideImage::SIDE_BOTTOM_LEFT || $corners & WideImage::SIDE_LEFT || $corners & WideImage::SIDE_BOTTOM) {
             $result = $result->applyMask($corner, -1, $result->getHeight() - $corner->getHeight() + 1, 100);
         }
         return $result;
     } else {
         $bg_color = $color;
         $corner->fill(0, 0, $bg_color);
         $fg_color = $corner->allocateColorAlpha(127, 127, 127, 127);
         $corner->getCanvas()->filledEllipse($radius * $sample_ratio, $radius * $sample_ratio, $radius * 2 * $sample_ratio, $radius * 2 * $sample_ratio, $fg_color);
         $corner = $corner->resize($radius, $radius);
         $result = $image->copy();
         if ($corners & WideImage::SIDE_TOP_LEFT || $corners & WideImage::SIDE_LEFT || $corners & WideImage::SIDE_TOP) {
             $result = $result->merge($corner, -1, -1, 100);
         }
         $corner = $corner->rotate(90);
         if ($corners & WideImage::SIDE_TOP_RIGHT || $corners & WideImage::SIDE_TOP || $corners & WideImage::SIDE_RIGHT) {
             $result = $result->merge($corner, $result->getWidth() - $corner->getWidth() + 1, -1, 100);
         }
         $corner = $corner->rotate(90);
         if ($corners & WideImage::SIDE_BOTTOM_RIGHT || $corners & WideImage::SIDE_RIGHT || $corners & WideImage::SIDE_BOTTOM) {
             $result = $result->merge($corner, $result->getWidth() - $corner->getWidth() + 1, $result->getHeight() - $corner->getHeight() + 1, 100);
         }
         $corner = $corner->rotate(90);
         if ($corners & WideImage::SIDE_BOTTOM_LEFT || $corners & WideImage::SIDE_LEFT || $corners & WideImage::SIDE_BOTTOM) {
             $result = $result->merge($corner, -1, $result->getHeight() - $corner->getHeight() + 1, 100);
         }
         return $result;
     }
 }
开发者ID:Jandersolutions,项目名称:mautic,代码行数:72,代码来源:RoundCorners.php

示例13: execute

 /**
  * Executes imageconvolution() filter
  *
  * @param WideImage_Image $image
  * @param array $matrix
  * @param numeric $div
  * @param numeric $offset
  * @return WideImage_Image
  */
 function execute($image, $matrix, $div, $offset)
 {
     $new = $image->asTrueColor();
     imageconvolution($new->getHandle(), $matrix, $div, $offset);
     return $new;
 }
开发者ID:victorborg3s,项目名称:kimera,代码行数:15,代码来源:ApplyConvolution.php


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