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


PHP sfImage::getAdapter方法代码示例

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


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

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

示例2: transform

 /**
  * Apply the opacity transformation to the sfImage object
  * 
  * @param sfImage
  * 
  * @return sfImage
  */
 protected function transform(sfImage $image)
 {
     $new_img = $image->getAdapter()->getTransparentImage($image->getWidth(), $image->getHeight());
     imagealphablending($new_img, false);
     imagesavealpha($new_img, true);
     $opacity = (int) round(127 - 127 / 100 * $this->getOpacity());
     // imagesavealpha($new_img, true);
     $width = $image->getWidth();
     $height = $image->getHeight();
     for ($x = 0; $x < $width; $x++) {
         for ($y = 0; $y < $height; $y++) {
             $rgb = imagecolorat($image->getAdapter()->getHolder(), $x, $y);
             $r = $rgb >> 16 & 0xff;
             $g = $rgb >> 8 & 0xff;
             $b = $rgb & 0xff;
             $alpha = ($rgb & 0x7f000000) >> 24;
             $new_opacity = $alpha + (127 - $alpha) / 100 * $this->getOpacity();
             $colors[$alpha] = $new_opacity;
             $color = imagecolorallocatealpha($new_img, $r, $g, $b, $new_opacity);
             imagesetpixel($new_img, $x, $y, $color);
         }
     }
     $image->getAdapter()->setHolder($new_img);
     return $image;
 }
开发者ID:valerio-bozzolan,项目名称:openparlamento,代码行数:32,代码来源:sfImageOpacityGD.class.php

示例3: execute

 /**
  * Apply the transform to the sfImage object.
  *
  * @param sfImage
  * @return sfImage
  */
 public function execute(sfImage $image)
 {
     // Check we have a valid image holder
     if (false === $image->getAdapter()->hasHolder()) {
         print $image->getAdapter()->hasHolder();
         print_r($image->getAdapter());
         exit;
         throw new sfImageTransformException(sprintf('Cannot perform transform: %s invalid image resource', get_class($this)));
     }
     return $this->transform($image);
 }
开发者ID:valerio-bozzolan,项目名称:openparlamento,代码行数:17,代码来源:sfImageTransformAbstract.class.php

示例4: transform

 /**
  * Apply the transform to the sfImage object.
  *
  * @param sfImage
  * @return sfImage
  */
 protected function transform(sfImage $image)
 {
     $resource = $image->getAdapter()->getHolder();
     // Set the defined color as transparent
     if ($this->color !== '') {
         $color = $image->getAdapter()->getColorByHex($resource, $this->color);
     } else {
         $color = imagecolorat($resource, 0, 0);
     }
     imagecolortransparent($resource, $color);
     return $image;
 }
开发者ID:thefkboss,项目名称:ZenTracker,代码行数:18,代码来源:sfImageTransparencyGD.class.php

示例5: transform

 /**
  * Apply the transform to the sfImage object.
  *
  * @param integer
  * @return sfImage
  */
 protected function transform(sfImage $image)
 {
     $resource = $image->getAdapter()->getHolder();
     $x = imagesx($resource);
     $y = imagesy($resource);
     $dest_resource = $image->getAdapter()->getTransparentImage($x, $y);
     for ($h = 0; $h < $y; $h++) {
         imagecopy($dest_resource, $resource, 0, $h, 0, $y - $h - 1, $x, 1);
     }
     // Tidy up
     imagedestroy($resource);
     // Replace old image with flipped version
     $image->getAdapter()->setHolder($dest_resource);
     return $image;
 }
开发者ID:valerio-bozzolan,项目名称:openparlamento,代码行数:21,代码来源:sfImageFlipGD.class.php

示例6: transform

 /**
  * Apply the transform to the sfImage object.
  *
  * @param sfImage
  * @return sfImage
  */
 protected function transform(sfImage $image)
 {
     $resource = $image->getAdapter()->getHolder();
     $resourcex = imagesx($resource);
     $resourcey = imagesy($resource);
     for ($x = 0; $x < $resourcex; ++$x) {
         for ($y = 0; $y < $resourcey; ++$y) {
             $distx = rand(-$this->scatter_factor, $this->scatter_factor);
             $disty = rand(-$this->scatter_factor, $this->scatter_factor);
             // keep inside the image boundaries
             if ($x + $distx >= $resourcex) {
                 continue;
             }
             if ($x + $distx < 0) {
                 continue;
             }
             if ($y + $disty >= $resourcey) {
                 continue;
             }
             if ($y + $disty < 0) {
                 continue;
             }
             $oldcol = imagecolorat($resource, $x, $y);
             $newcol = imagecolorat($resource, $x + $distx, $y + $disty);
             imagesetpixel($resource, $x, $y, $newcol);
             imagesetpixel($resource, $x + $distx, $y + $disty, $oldcol);
         }
     }
     return $image;
 }
开发者ID:valerio-bozzolan,项目名称:openparlamento,代码行数:36,代码来源:sfImageScatterGD.class.php

示例7: transform

 /**
  * Apply the transform to the sfImage object.
  *
  * @param integer
  * @return sfImage
  */
 protected function transform(sfImage $image)
 {
     // Check we have a valid image resource
     $resource = $image->getAdapter()->getHolder();
     $resource->flopImage();
     return $image;
 }
开发者ID:thefkboss,项目名称:ZenTracker,代码行数:13,代码来源:sfImageMirrorImageMagick.class.php

示例8: transform

 /**
  * Apply the transform to the sfImage object.
  *
  * @param integer
  * @return sfImage
  */
 protected function transform(sfImage $image)
 {
     $resource = $image->getAdapter()->getHolder();
     $x = imagesx($resource);
     $y = imagesy($resource);
     imagealphablending($resource, true);
     $dest_resource = $image->getAdapter()->getTransparentImage($x, $y);
     imagealphablending($dest_resource, true);
     for ($w = 0; $w < $x; $w++) {
         imagecopy($dest_resource, $resource, $w, 0, $x - $w - 1, 0, 1, $y);
     }
     // Tidy up
     imagedestroy($resource);
     // Replace old image with flipped version
     $image->getAdapter()->setHolder($dest_resource);
     return $image;
 }
开发者ID:valerio-bozzolan,项目名称:openparlamento,代码行数:23,代码来源:sfImageMirrorGD.class.php

示例9: transform

 /**
  * Apply the transform to the sfImage object.
  *
  * @param sfImage
  * @return sfImage
  */
 protected function transform(sfImage $image)
 {
     $resource = $image->getAdapter()->getHolder();
     $x = $resource->getImageWidth();
     $y = $resource->getImageHeight();
     $image->resize(round($x * $this->scale), round($y * $this->scale));
     return $image;
 }
开发者ID:valerio-bozzolan,项目名称:openparlamento,代码行数:14,代码来源:sfImageScaleImageMagick.class.php

示例10: transform

 /**
  * Apply the transform to the sfImage object.
  *
  * @param sfImage
  * @return sfImage
  */
 protected function transform(sfImage $image)
 {
     $resource = $image->getAdapter()->getHolder();
     $x = imagesx($resource);
     $y = imagesy($resource);
     $image->resize(round($x * $this->scale), round($y * $this->scale));
     return $image;
 }
开发者ID:valerio-bozzolan,项目名称:openparlamento,代码行数:14,代码来源:sfImageScaleGD.class.php

示例11: transform

 /**
  * Apply the transform to the sfImage object.
  *
  * @param sfImage
  * @return sfImage
  */
 protected function transform(sfImage $image)
 {
     $resource = $image->getAdapter()->getHolder();
     if (function_exists('imagefilter')) {
         imagefilter($resource, IMG_FILTER_NEGATE);
     } else {
         throw new sfImageTransformException(sprintf('Cannot perform transform, GD does not support imagefilter '));
     }
     return $image;
 }
开发者ID:thefkboss,项目名称:ZenTracker,代码行数:16,代码来源:sfImageNegateGD.class.php

示例12: transform

 /**
  * Apply the transform to the sfImage object.
  *
  * @param sfImage
  * @return sfImage
  */
 protected function transform(sfImage $image)
 {
     $resource = $image->getAdapter()->getHolder();
     $resourcex = imagesx($resource);
     $resourcey = imagesy($resource);
     for ($x = 0; $x < $resourcex; $x += $this->block_size) {
         for ($y = 0; $y < $resourcey; $y += $this->block_size) {
             $rgb = imagecolorat($resource, $x, $y);
             imagefilledrectangle($resource, $x, $y, $x + $this->block_size - 1, $y + $this->block_size - 1, $rgb);
         }
     }
     return $image;
 }
开发者ID:thefkboss,项目名称:ZenTracker,代码行数:19,代码来源:sfImagePixelizeGD.class.php

示例13: transform

 /**
  * Apply the transform to the sfImage object.
  *
  * @param sfImage
  * @return sfImage
  */
 protected function transform(sfImage $image)
 {
     // No need to do anything
     if ($this->angle == 0) {
         return $image;
     }
     $resource = $image->getAdapter()->getHolder();
     // By default use the background of the top left corner
     if ($this->background === '') {
         $this->background = $resource->getImagePixelColor(0, 0);
     }
     $resource->rotateImage($this->background, $this->angle);
     return $image;
 }
开发者ID:valerio-bozzolan,项目名称:openparlamento,代码行数:20,代码来源:sfImageRotateImageMagick.class.php

示例14: transform

 /**
  * Apply the transform to the sfImage object.
  *
  * @param sfImage
  * @return sfImage
  */
 protected function transform(sfImage $image)
 {
     $resource = $image->getAdapter()->getHolder();
     // By default use the background of the top left corner
     if (is_null($this->background)) {
         $this->background = $resource->getImagePixelColor(0, 0);
         $background = $this->background;
     } else {
         $background = new ImagickPixel();
         $background->setColor($this->background);
     }
     $resource->setBackgroundColor($background);
     $resource->trimImage($this->fuzz);
     return $image;
 }
开发者ID:valerio-bozzolan,项目名称:openparlamento,代码行数:21,代码来源:sfImageTrimImageMagick.class.php

示例15: transform

 /**
  * Apply the transform to the sfImage object.
  *
  * @access protected
  * @param sfImage
  * @return sfImage
  */
 protected function transform(sfImage $image)
 {
     $resource = $image->getAdapter()->getHolder();
     $resourcex = imagesx($resource);
     $resourcey = imagesy($resource);
     for ($x = 0; $x < $resourcex; ++$x) {
         for ($y = 0; $y < $resourcey; ++$y) {
             $newr = 0;
             $newg = 0;
             $newb = 0;
             $colours = array();
             $thiscol = imagecolorat($resource, $x, $y);
             for ($k = $x - $this->blur_pixels; $k <= $x + $this->blur_pixels; ++$k) {
                 for ($l = $y - $this->blur_pixels; $l <= $y + $this->blur_pixels; ++$l) {
                     if ($k < 0) {
                         $colours[] = $thiscol;
                         continue;
                     }
                     if ($k >= $resourcex) {
                         $colours[] = $thiscol;
                         continue;
                     }
                     if ($l < 0) {
                         $colours[] = $thiscol;
                         continue;
                     }
                     if ($l >= $resourcey) {
                         $colours[] = $thiscol;
                         continue;
                     }
                     $colours[] = imagecolorat($resource, $k, $l);
                 }
             }
             foreach ($colours as $colour) {
                 $newr += $colour >> 16 & 0xff;
                 $newg += $colour >> 8 & 0xff;
                 $newb += $colour & 0xff;
             }
             $numelements = count($colours);
             $newr /= $numelements;
             $newg /= $numelements;
             $newb /= $numelements;
             $newcol = imagecolorallocate($resource, $newr, $newg, $newb);
             imagesetpixel($resource, $x, $y, $newcol);
         }
     }
     return $image;
 }
开发者ID:thefkboss,项目名称:ZenTracker,代码行数:55,代码来源:sfImagePixelBlurGD.class.php


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