本文整理汇总了PHP中sfImage::copy方法的典型用法代码示例。如果您正苦于以下问题:PHP sfImage::copy方法的具体用法?PHP sfImage::copy怎么用?PHP sfImage::copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfImage
的用法示例。
在下文中一共展示了sfImage::copy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: transform
/**
* Apply the opacity transformation to the sfImage object
*
* @param sfImage
*
* @return sfImage
*/
public function transform(sfImage $image)
{
// Get the actual image resource
$resource = $image->getAdapter()->getHolder();
//get the resource dimentions
$width = $image->getWidth();
$height = $image->getHeight();
$reflection = $image->copy();
$reflection->flip()->resize($width, $this->reflection_height);
$r_resource = $reflection->getAdapter()->getHolder();
$dest_resource = $reflection->getAdapter()->getTransparentImage($width, $height + $this->reflection_height);
imagecopymerge($dest_resource, $resource, 0, 0, 0, 0, $width, $height, 100);
imagecopymerge($dest_resource, $r_resource, 0, $height, 0, 0, $width, $this->reflection_height, 100);
// Increments we are going to increase the transparency
$increment = 100 / $this->reflection_height;
// Overlay line we use to apply the transparency
$line = imagecreatetruecolor($width, 1);
// Use white as our overlay color
imagefilledrectangle($line, 0, 0, $width, 1, imagecolorallocate($line, 255, 255, 255));
$tr = $this->start_transparency;
// Start at the bottom of the original image
for ($i = $height; $i <= $height + $this->reflection_height; $i++) {
if ($tr > 100) {
$tr = 100;
}
imagecopymerge($dest_resource, $line, 0, $i, 0, 0, $width, 1, $tr);
$tr += $increment;
}
// To set a new resource for the image object
$image->getAdapter()->setHolder($dest_resource);
return $image;
}