本文整理汇总了PHP中WideImage_Image::getHandle方法的典型用法代码示例。如果您正苦于以下问题:PHP WideImage_Image::getHandle方法的具体用法?PHP WideImage_Image::getHandle怎么用?PHP WideImage_Image::getHandle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WideImage_Image
的用法示例。
在下文中一共展示了WideImage_Image::getHandle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* Returns an image with a resized canvas
*
* The image is filled with $color. Use $scale to determine, when to resize.
*
* @param WideImage_Image $img
* @param smart_coordinate $width
* @param smart_coordinate $height
* @param smart_coordinate $left
* @param smart_coordinate $top
* @param int $color
* @param string $scale 'up', 'down', 'any'
* @return WideImage_Image
*/
function execute($img, $width, $height, $left, $top, $color, $scale)
{
$new_width = WideImage_Coordinate::fix($width, $img->getWidth());
$new_height = WideImage_Coordinate::fix($width, $img->getHeight());
if ($scale == 'down') {
$new_width = min($new_width, $img->getWidth());
$new_height = min($new_height, $img->getHeight());
} elseif ($scale == 'up') {
$new_width = max($new_width, $img->getWidth());
$new_height = max($new_height, $img->getHeight());
}
$new = WideImage::createTrueColorImage($new_width, $new_height);
if ($img->isTrueColor()) {
if ($color === null) {
$color = $new->allocateColorAlpha(0, 0, 0, 127);
}
} else {
imagepalettecopy($new->getHandle(), $img->getHandle());
if ($color === null) {
if ($img->isTransparent()) {
$new->copyTransparencyFrom($img);
$tc_rgb = $img->getTransparentColorRGB();
$color = $new->allocateColorAlpha($tc_rgb);
} else {
$color = $new->allocateColorAlpha(255, 0, 127, 127);
}
imagecolortransparent($new->getHandle(), $color);
}
}
$new->fill(0, 0, $color);
$x = WideImage_Coordinate::fix($left, $new->getWidth(), $img->getWidth());
$y = WideImage_Coordinate::fix($top, $new->getHeight(), $img->getHeight());
$img->copyTo($new, $x, $y);
return $new;
}
示例2: filter
/**
* Returns image with every pixel changed by specififed function
*
* @param WideImage_Image $image
* @param str $function
* @param int $value
* @return WideImage_Image
*/
function filter($image, $function, $value)
{
for ($y = 0; $y < $image->getHeight(); $y++) {
for ($x = 0; $x < $image->getWidth(); $x++) {
$rgb = imagecolorat($image->getHandle(), $x, $y);
$a = $rgb >> 24 & 0xff;
$r = $rgb >> 16 & 0xff;
$g = $rgb >> 8 & 0xff;
$b = $rgb & 0xff;
self::$function($r, $g, $b, $value);
$color = imagecolorallocatealpha($image->getHandle(), $r, $g, $b, $a);
imagesetpixel($image->getHandle(), $x, $y, $color);
}
}
return $image;
}
示例3: execute
/**
* Returns rotated image
*
* @param WideImage_Image $image
* @param numeric $angle
* @param int $bgColor
* @param bool $ignoreTransparent
* @return WideImage_Image
*/
function execute($image, $angle, $bgColor, $ignoreTransparent)
{
$angle = -floatval($angle);
if ($angle < 0) {
$angle = 360 + $angle;
}
$angle = $angle % 360;
if ($angle == 0) {
return $image->copy();
}
if ($bgColor === null) {
if ($image->isTransparent()) {
$bgColor = $image->getTransparentColor();
} else {
$tc = array('red' => 255, 'green' => 255, 'blue' => 255, 'alpha' => 127);
if ($image->isTrueColor()) {
$bgColor = $image->getExactColorAlpha($tc);
if ($bgColor == -1) {
$bgColor = $image->allocateColorAlpha($tc);
}
} else {
$bgColor = $image->getExactColor($tc);
if ($bgColor == -1) {
$bgColor = $image->allocateColor($tc);
}
}
}
}
return new WideImage_TrueColorImage(imagerotate($image->getHandle(), $angle, $bgColor, $ignoreTransparent));
}
示例4: 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;
}
示例5: execute
/**
* Returns a mirrored image
*
* @param WideImage_Image $image
* @return WideImage_Image
*/
function execute($image)
{
$new = $image->copy();
$width = $image->getWidth();
$height = $image->getHeight();
for ($x = 0; $x < $width; $x++) {
imagecopy($new->getHandle(), $image->getHandle(), $x, 0, $width - $x - 1, 0, 1, $height);
}
return $new;
}
示例6: execute
/**
* Returns a flipped image
*
* @param WideImage_Image $image
* @return WideImage_Image
*/
function execute($image)
{
$new = $image->copy();
$width = $image->getWidth();
$height = $image->getHeight();
for ($y = 0; $y < $height; $y++) {
imagecopy($new->getHandle(), $image->getHandle(), 0, $y, 0, $height - $y - 1, $width, 1);
}
return $new;
}
示例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
*/
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;
}
示例8: execute
/**
* Returns a mirrored image
*
* @param WideImage_Image $image
* @return WideImage_Image
*/
function execute($image)
{
$new = $image->copy();
$width = $image->getWidth();
$height = $image->getHeight();
if ($new->isTransparent()) {
imagefilledrectangle($new->getHandle(), 0, 0, $width, $height, $new->getTransparentColor());
}
for ($x = 0; $x < $width; $x++) {
imagecopy($new->getHandle(), $image->getHandle(), $x, 0, $width - $x - 1, 0, 1, $height);
}
return $new;
}
示例9: execute
/**
* Returns a flipped image
*
* @param WideImage_Image $image
* @return WideImage_Image
*/
function execute($image)
{
$new = $image->copy();
$width = $image->getWidth();
$height = $image->getHeight();
if ($new->isTransparent()) {
imagefilledrectangle($new->getHandle(), 0, 0, $width, $height, $new->getTransparentColor());
}
for ($y = 0; $y < $height; $y++) {
imagecopy($new->getHandle(), $image->getHandle(), 0, $y, 0, $height - $y - 1, $width, 1);
}
return $new;
}
示例10: execute
/**
* Returns a mirrored image
*
* @param WideImage_Image $image
* @return WideImage_Image
*/
function execute($image)
{
$new = $image->copy();
$width = $image->getWidth();
$height = $image->getHeight();
if ($new->isTransparent()) {
imagefilledrectangle($new->getHandle(), 0, 0, $width, $height, $new->getTransparentColor());
}
for ($x = 0; $x < $width; $x++) {
if (!imagecopy($new->getHandle(), $image->getHandle(), $x, 0, $width - $x - 1, 0, 1, $height)) {
throw new WideImage_GDFunctionResultException("imagecopy() returned false");
}
}
return $new;
}
示例11: writeText
/**
* Writes text onto an image.
*
* @param WideImage_Image $image
* @param mixed $x smart coordinate
* @param mixed $y smart coordinate
* @param string $text
* @param int $angle Angle in degrees clockwise
*/
public function writeText($image, $x, $y, $text, $angle = 0)
{
if ($image->isTrueColor()) {
$image->alphaBlending(true);
}
$box = imageftbbox($this->size, $angle, $this->face, $text);
$obox = ['left' => min($box[0], $box[2], $box[4], $box[6]), 'top' => min($box[1], $box[3], $box[5], $box[7]), 'right' => max($box[0], $box[2], $box[4], $box[6]) - 1, 'bottom' => max($box[1], $box[3], $box[5], $box[7]) - 1];
$obox['width'] = abs($obox['left']) + abs($obox['right']);
$obox['height'] = abs($obox['top']) + abs($obox['bottom']);
$x = WideImage_Coordinate::fix($x, $image->getWidth(), $obox['width']);
$y = WideImage_Coordinate::fix($y, $image->getHeight(), $obox['height']);
$fixed_x = $x - $obox['left'];
$fixed_y = $y - $obox['top'];
imagettftext($image->getHandle(), $this->size, $angle, $fixed_x, $fixed_y, $this->color, $this->face, $text);
}
示例12: execute
/**
* Returns a flipped image.
*
* @param WideImage_Image $image
*
* @return WideImage_Image
*/
public function execute($image)
{
$new = $image->copy();
$width = $image->getWidth();
$height = $image->getHeight();
if ($new->isTransparent()) {
imagefilledrectangle($new->getHandle(), 0, 0, $width, $height, $new->getTransparentColor());
}
for ($y = 0; $y < $height; ++$y) {
if (!imagecopy($new->getHandle(), $image->getHandle(), 0, $y, 0, $height - $y - 1, $width, 1)) {
throw new WideImage_GDFunctionResultException('imagecopy() returned false');
}
}
return $new;
}
示例13: execute
/**
* Returns an image with a resized canvas
*
* The image is filled with $color. Use $scale to determine, when to resize.
*
* @param WideImage_Image $img
* @param smart_coordinate $width
* @param smart_coordinate $height
* @param smart_coordinate $left
* @param smart_coordinate $top
* @param int $color
* @param string $scale 'up', 'down', 'any'
* @param boolean $merge
* @return WideImage_Image
*/
function execute($img, $width, $height, $left, $top, $color, $scale, $merge)
{
$new_width = WideImage_Coordinate::fix($width, $img->getWidth());
$new_height = WideImage_Coordinate::fix($height, $img->getHeight());
if ($scale == 'down') {
$new_width = min($new_width, $img->getWidth());
$new_height = min($new_height, $img->getHeight());
} elseif ($scale == 'up') {
$new_width = max($new_width, $img->getWidth());
$new_height = max($new_height, $img->getHeight());
}
$new = WideImage::createTrueColorImage($new_width, $new_height);
if ($img->isTrueColor()) {
if ($color === null) {
$color = $new->allocateColorAlpha(0, 0, 0, 127);
}
} else {
imagepalettecopy($new->getHandle(), $img->getHandle());
if ($img->isTransparent()) {
$new->copyTransparencyFrom($img);
$tc_rgb = $img->getTransparentColorRGB();
$t_color = $new->allocateColorAlpha($tc_rgb);
}
if ($color === null) {
if ($img->isTransparent()) {
$color = $t_color;
} else {
$color = $new->allocateColorAlpha(255, 0, 127, 127);
}
imagecolortransparent($new->getHandle(), $color);
}
}
$new->fill(0, 0, $color);
$x = WideImage_Coordinate::fix($left, $new->getWidth(), $img->getWidth());
$y = WideImage_Coordinate::fix($top, $new->getHeight(), $img->getHeight());
// blending for truecolor images
if ($img->isTrueColor()) {
$new->alphaBlending($merge);
}
// not-blending for palette images
if (!$merge && !$img->isTrueColor() && isset($t_color)) {
$new->getCanvas()->filledRectangle($x, $y, $x + $img->getWidth(), $y + $img->getHeight(), $t_color);
}
$img->copyTo($new, $x, $y);
return $new;
}
示例14: 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;
}
}
示例15:
/**
* Creates a canvas object that writes to the image passed as a parameter
*
* Shouldn't be used directly, use WideImage_Image::getCanvas() instead.
*
* @param WideImage_Image $img Image object
*/
function __construct($img)
{
$this->handle = $img->getHandle();
$this->image = $img;
}