{
parent::__construct($params, $context);
if (!empty($params['width'])) {
- $this->_im = $this->_create($this->_width, $this->_height);
- $this->_call('imageFill', array($this->_im, 0, 0, $this->_allocateColor($this->_background)));
+ $this->_im = $this->create($this->_width, $this->_height);
+ $this->call('imageFill', array($this->_im, 0, 0, $this->_allocateColor($this->_background)));
}
}
{
$this->headers();
- return $this->_call('image' . $this->_type, array($this->_im));
+ return $this->call('image' . $this->_type, array($this->_im));
}
/**
{
parent::reset();
if (is_resource($this->_im)) {
- return $this->_call('imageDestroy', array($this->_im));
+ return $this->call('imageDestroy', array($this->_im));
}
return true;
public function getDimensions()
{
if (is_resource($this->_im) && $this->_width == 0 && $this->_height ==0) {
- $this->_width = $this->_call('imageSX', array($this->_im));
- $this->_height = $this->_call('imageSY', array($this->_im));
+ $this->_width = $this->call('imageSX', array($this->_im));
+ $this->_height = $this->call('imageSY', array($this->_im));
return array('width' => $this->_width,
'height' => $this->_height);
} else {
if (empty($colors[$name])) {
list($r, $g, $b) = self::getRGB($name);
- $colors[$name] = $this->_call('imageColorAllocateAlpha', array($this->_im, $r, $g, $b, $alpha));
+ $colors[$name] = $this->call('imageColorAllocateAlpha', array($this->_im, $r, $g, $b, $alpha));
}
return $colors[$name];
*/
public function loadString($image_data)
{
- $this->_im = $this->_call('imageCreateFromString', array($image_data));
+ $this->_im = $this->call('imageCreateFromString', array($image_data));
}
/**
*/
public function loadFile($filename)
{
- $info = $this->_call('getimagesize', array($filename));
+ $info = $this->call('getimagesize', array($filename));
if (is_array($info)) {
switch ($info[2]) {
case 1:
if (function_exists('imagecreatefromgif')) {
- $this->_im = $this->_call('imagecreatefromgif', array($filename));
+ $this->_im = $this->call('imagecreatefromgif', array($filename));
}
break;
case 2:
- $this->_im = $this->_call('imagecreatefromjpeg', array($filename));
+ $this->_im = $this->call('imagecreatefromjpeg', array($filename));
break;
case 3:
- $this->_im = $this->_call('imagecreatefrompng', array($filename));
+ $this->_im = $this->call('imagecreatefrompng', array($filename));
break;
case 15:
if (function_exists('imagecreatefromgwbmp')) {
- $this->_im = $this->_call('imagecreatefromgwbmp', array($filename));
+ $this->_im = $this->call('imagecreatefromgwbmp', array($filename));
}
break;
case 16:
- $this->_im = $this->_call('imagecreatefromxbm', array($filename));
+ $this->_im = $this->call('imagecreatefromxbm', array($filename));
break;
}
}
$result = parent::loadFile($filename);
- $this->_im = $this->_call('imageCreateFromString', array($this->_data));
+ $this->_im = $this->call('imageCreateFromString', array($this->_data));
}
/**
}
if ($ratio) {
- if ($width / $height > $this->_call('imageSX', array($this->_im)) / $this->_call('imageSY', array($this->_im))) {
- $width = $height * $this->_call('imageSX', array($this->_im)) / $this->_call('imageSY', array($this->_im));
+ if ($width / $height > $this->call('imageSX', array($this->_im)) / $this->call('imageSY', array($this->_im))) {
+ $width = $height * $this->call('imageSX', array($this->_im)) / $this->call('imageSY', array($this->_im));
} else {
- $height = $width * $this->_call('imageSY', array($this->_im)) / $this->_call('imageSX', array($this->_im));
+ $height = $width * $this->call('imageSY', array($this->_im)) / $this->call('imageSX', array($this->_im));
}
}
$im = $this->_im;
- $this->_im = $this->_create($width, $height);
+ $this->_im = $this->create($width, $height);
/* Reset geometry since it will change */
$this->_width = 0;
$this->_height = 0;
- $this->_call('imageFill', array($this->_im, 0, 0, $this->_call('imageColorAllocate', array($this->_im, 255, 255, 255))));
+ $this->call('imageFill', array($this->_im, 0, 0, $this->call('imageColorAllocate', array($this->_im, 255, 255, 255))));
try {
- $this->_call('imageCopyResampled', array($this->_im, $im, 0, 0, 0, 0, $width, $height, $this->_call('imageSX', array($im)), $this->_call('imageSY', array($im))));
+ $this->call('imageCopyResampled', array($this->_im, $im, 0, 0, 0, 0, $width, $height, $this->call('imageSX', array($im)), $this->call('imageSY', array($im))));
} catch (Horde_Image_Exception $e) {
- $this->_call('imageCopyResized', array($this->_im, $im, 0, 0, 0, 0, $width, $height, $this->_call('imageSX', array($im)), $this->_call('imageSY', array($im))));
+ $this->call('imageCopyResized', array($this->_im, $im, 0, 0, 0, 0, $width, $height, $this->call('imageSX', array($im)), $this->call('imageSY', array($im))));
}
}
public function crop($x1, $y1, $x2, $y2)
{
$im = $this->_im;
- $this->_im = $this->_create($x2 - $x1, $y2 - $y1);
+ $this->_im = $this->create($x2 - $x1, $y2 - $y1);
$this->_width = 0;
$this->_height = 0;
- $this->_call('imageCopy', array($this->_im, $im, 0, 0, $x1, $y1, $x2 - $x1, $y2 - $y1));
+ $this->call('imageCopy', array($this->_im, $im, 0, 0, $x1, $y1, $x2 - $x1, $y2 - $y1));
}
/**
switch ($angle) {
case '90':
- $x = $this->_call('imageSX', array($this->_im));
- $y = $this->_call('imageSY', array($this->_im));
+ $x = $this->call('imageSX', array($this->_im));
+ $y = $this->call('imageSY', array($this->_im));
$xymax = max($x, $y);
- $im = $this->_create($xymax, $xymax);
- $im = $this->_call('imageRotate', array($im, 270, $background));
+ $im = $this->create($xymax, $xymax);
+ $im = $this->call('imageRotate', array($im, 270, $background));
$this->_im = $im;
- $im = $this->_create($y, $x);
+ $im = $this->create($y, $x);
if ($x < $y) {
- $this->_call('imageCopy', array($im, $this->_im, 0, 0, 0, 0, $xymax, $xymax));
+ $this->call('imageCopy', array($im, $this->_im, 0, 0, 0, 0, $xymax, $xymax));
} elseif ($x > $y) {
- $this->_call('imageCopy', array($im, $this->_im, 0, 0, $xymax - $y, $xymax - $x, $xymax, $xymax));
+ $this->call('imageCopy', array($im, $this->_im, 0, 0, $xymax - $y, $xymax - $x, $xymax, $xymax));
}
$this->_im = $im;
break;
default:
- $this->_im = $this->_call('imageRotate', array($this->_im, 360 - $angle, $background));
+ $this->_im = $this->call('imageRotate', array($this->_im, 360 - $angle, $background));
}
}
*/
public function flip()
{
- $x = $this->_call('imageSX', array($this->_im));
- $y = $this->_call('imageSY', array($this->_im));
+ $x = $this->call('imageSX', array($this->_im));
+ $y = $this->call('imageSY', array($this->_im));
- $im = $this->_create($x, $y);
+ $im = $this->create($x, $y);
for ($curY = 0; $curY < $y; $curY++) {
- $this->_call('imageCopy', array($im, $this->_im, 0, $y - ($curY + 1), 0, $curY, $x, 1));
+ $this->call('imageCopy', array($im, $this->_im, 0, $y - ($curY + 1), 0, $curY, $x, 1));
}
$this->_im = $im;
*/
public function mirror()
{
- $x = $this->_call('imageSX', array($this->_im));
- $y = $this->_call('imageSY', array($this->_im));
+ $x = $this->call('imageSX', array($this->_im));
+ $y = $this->call('imageSY', array($this->_im));
- $im = $this->_create($x, $y);
+ $im = $this->create($x, $y);
for ($curX = 0; $curX < $x; $curX++) {
- $this->_call('imageCopy', array($im, $this->_im, $x - ($curX + 1), 0, $curX, 0, 1, $y));
+ $this->call('imageCopy', array($im, $this->_im, $x - ($curX + 1), 0, $curX, 0, 1, $y));
}
$this->_im = $im;
$rateG = .587;
$rateB = .114;
$whiteness = 3;
- if ($this->_call('imageIsTrueColor', array($this->_im)) === true) {
- $this->_call('imageTrueColorToPalette', array($this->_im, true, 256));
+ if ($this->call('imageIsTrueColor', array($this->_im)) === true) {
+ $this->call('imageTrueColorToPalette', array($this->_im, true, 256));
}
- $colors = min(256, $this->_call('imageColorsTotal', array($this->_im)));
+ $colors = min(256, $this->call('imageColorsTotal', array($this->_im)));
for ($x = 0; $x < $colors; $x++) {
- $src = $this->_call('imageColorsForIndex', array($this->_im, $x));
+ $src = $this->call('imageColorsForIndex', array($this->_im, $x));
$new = min(255, abs($src['red'] * $rateR + $src['green'] * $rateG + $src['blue'] * $rateB) + $whiteness);
- $this->_call('imageColorSet', array($this->_im, $x, $new, $new, $new));
+ $this->call('imageColorSet', array($this->_im, $x, $new, $new, $new));
}
}
$rateB = .114;
$whiteness = 3;
- if ($this->_call('imageIsTrueColor', array($this->_im)) === true) {
- $this->_call('imageTrueColorToPalette', array($this->_im, true, 256));
+ if ($this->call('imageIsTrueColor', array($this->_im)) === true) {
+ $this->call('imageTrueColorToPalette', array($this->_im, true, 256));
}
- $colors = max(256, $this->_call('imageColorsTotal', array($this->_im)));
+ $colors = max(256, $this->call('imageColorsTotal', array($this->_im)));
for ($x = 0; $x < $colors; $x++) {
- $src = $this->_call('imageColorsForIndex', array($this->_im, $x));
+ $src = $this->call('imageColorsForIndex', array($this->_im, $x));
$new = min(255, abs($src['red'] * $rateR + $src['green'] * $rateG + $src['blue'] * $rateB) + $whiteness);
$r = min(255, $new + $tintR);
$g = min(255, $new + $tintG);
$b = min(255, $new + $tintB);
- $this->_call('imageColorSet', array($this->_im, $x, $r, $g, $b));
+ $this->call('imageColorSet', array($this->_im, $x, $r, $g, $b));
}
}
*/
public function yellowize($intensityY = 50, $intensityB = 3)
{
- if ($this->_call('imageIsTrueColor', array($this->_im)) === true) {
- $this->_call('imageTrueColorToPalette', array($this->_im, true, 256));
+ if ($this->call('imageIsTrueColor', array($this->_im)) === true) {
+ $this->call('imageTrueColorToPalette', array($this->_im, true, 256));
}
- $colors = max(256, $this->_call('imageColorsTotal', array($this->_im)));
+ $colors = max(256, $this->call('imageColorsTotal', array($this->_im)));
for ($x = 0; $x < $colors; $x++) {
- $src = $this->_call('imageColorsForIndex', array($this->_im, $x));
+ $src = $this->call('imageColorsForIndex', array($this->_im, $x));
$r = min($src['red'] + $intensityY, 255);
$g = min($src['green'] + $intensityY, 255);
$b = max(($r + $g) / max($intensityB, 2), 0);
- $this->_call('imageColorSet', array($this->_im, $x, $r, $g, $b));
+ $this->call('imageColorSet', array($this->_im, $x, $r, $g, $b));
}
}
switch ($direction) {
case -90:
case 270:
- $result = $this->_call('imageStringUp', array($this->_im, $f, $x, $y, $string, $c));
+ $result = $this->call('imageStringUp', array($this->_im, $f, $x, $y, $string, $c));
break;
case 0:
default:
- $result = $this->_call('imageString', array($this->_im, $f, $x, $y, $string, $c));
+ $result = $this->call('imageString', array($this->_im, $f, $x, $y, $string, $c));
}
return $result;
{
$c = $this->_allocateColor($color);
if (is_null($fill)) {
- $result = $this->_call('imageEllipse', array($this->_im, $x, $y, $r * 2, $r * 2, $c));
+ $result = $this->call('imageEllipse', array($this->_im, $x, $y, $r * 2, $r * 2, $c));
} else {
if ($fill !== $color) {
$fillColor = $this->_allocateColor($fill);
- $this->_call('imageFilledEllipse', array($this->_im, $x, $y, $r * 2, $r * 2, $fillColor));
- $this->_call('imageEllipse', array($this->_im, $x, $y, $r * 2, $r * 2, $c));
+ $this->call('imageFilledEllipse', array($this->_im, $x, $y, $r * 2, $r * 2, $fillColor));
+ $this->call('imageEllipse', array($this->_im, $x, $y, $r * 2, $r * 2, $c));
} else {
- $this->_call('imageFilledEllipse', array($this->_im, $x, $y, $r * 2, $r * 2, $c));
+ $this->call('imageFilledEllipse', array($this->_im, $x, $y, $r * 2, $r * 2, $c));
}
}
}
if ($fill != 'none') {
$f = $this->_allocateColor($fill);
- $this->_call('imageFilledPolygon', array($this->_im, $vertices, count($verts), $f));
+ $this->call('imageFilledPolygon', array($this->_im, $vertices, count($verts), $f));
}
if ($fill == 'none' || $fill != $color) {
$c = $this->_allocateColor($color);
- $this->_call('imagePolygon', array($this->_im, $vertices, count($verts), $c));
+ $this->call('imagePolygon', array($this->_im, $vertices, count($verts), $c));
}
}
{
if ($fill != 'none') {
$f = $this->_allocateColor($fill);
- $this->_call('imageFilledRectangle', array($this->_im, $x, $y, $x + $width, $y + $height, $f));
+ $this->call('imageFilledRectangle', array($this->_im, $x, $y, $x + $width, $y + $height, $f));
}
if ($fill == 'none' || $fill != $color) {
$c = $this->_allocateColor($color);
- $this->_call('imageRectangle', array($this->_im, $x, $y, $x + $width, $y + $height, $c));
+ $this->call('imageRectangle', array($this->_im, $x, $y, $x + $width, $y + $height, $c));
}
}
// Draw the corners - upper left, upper right, lower right,
// lower left.
- $this->_call('imageArc', array($this->_im, $x1, $y1, $r, $r, 180, 270, $c));
- $this->_call('imageArc', array($this->_im, $x2, $y2, $r, $r, 270, 360, $c));
- $this->_call('imageArc', array($this->_im, $x3, $y3, $r, $r, 0, 90, $c));
- $this->_call('imageArc', array($this->_im, $x4, $y4, $r, $r, 90, 180, $c));
+ $this->call('imageArc', array($this->_im, $x1, $y1, $r, $r, 180, 270, $c));
+ $this->call('imageArc', array($this->_im, $x2, $y2, $r, $r, 270, 360, $c));
+ $this->call('imageArc', array($this->_im, $x3, $y3, $r, $r, 0, 90, $c));
+ $this->call('imageArc', array($this->_im, $x4, $y4, $r, $r, 90, 180, $c));
// Draw the connecting sides - top, right, bottom, left.
- $this->_call('imageLine', array($this->_im, $x1 + $p2['x2'], $y1 + $p2['y2'], $x2 + $p3['x1'], $y2 + $p3['y1'], $c));
- $this->_call('imageLine', array($this->_im, $x2 + $p4['x2'], $y2 + $p4['y2'], $x3 + $p5['x1'], $y3 + $p5['y1'], $c));
- $this->_call('imageLine', array($this->_im, $x3 + $p6['x2'], $y3 + $p6['y2'], $x4 + $p7['x1'], $y4 + $p7['y1'], $c));
- $this->_call('imageLine', array($this->_im, $x4 + $p8['x2'], $y4 + $p8['y2'], $x1 + $p1['x1'], $y1 + $p1['y1'], $c));
+ $this->call('imageLine', array($this->_im, $x1 + $p2['x2'], $y1 + $p2['y2'], $x2 + $p3['x1'], $y2 + $p3['y1'], $c));
+ $this->call('imageLine', array($this->_im, $x2 + $p4['x2'], $y2 + $p4['y2'], $x3 + $p5['x1'], $y3 + $p5['y1'], $c));
+ $this->call('imageLine', array($this->_im, $x3 + $p6['x2'], $y3 + $p6['y2'], $x4 + $p7['x1'], $y4 + $p7['y1'], $c));
+ $this->call('imageLine', array($this->_im, $x4 + $p8['x2'], $y4 + $p8['y2'], $x1 + $p1['x1'], $y1 + $p1['y1'], $c));
if ($fill != 'none') {
$f = $this->_allocateColor($fill);
- $this->_call('imageFillToBorder', array($this->_im, $x + ($width / 2), $y + ($height / 2), $c, $f));
+ $this->call('imageFillToBorder', array($this->_im, $x + ($width / 2), $y + ($height / 2), $c, $f));
}
}
// Don't need to do anything special for single-width lines.
if ($width == 1) {
- $this->_call('imageLine', array($this->_im, $x1, $y1, $x2, $y2, $c));
+ $this->call('imageLine', array($this->_im, $x1, $y1, $x2, $y2, $c));
} elseif ($x1 == $x2) {
// For vertical lines, we can just draw a vertical
// rectangle.
$left = $x1 - floor(($width - 1) / 2);
$right = $x1 + floor($width / 2);
- $this->_call('imageFilledRectangle', array($this->_im, $left, $y1, $right, $y2, $c));
+ $this->call('imageFilledRectangle', array($this->_im, $left, $y1, $right, $y2, $c));
} elseif ($y1 == $y2) {
// For horizontal lines, we can just draw a horizontal
// filled rectangle.
$top = $y1 - floor($width / 2);
$bottom = $y1 + floor(($width - 1) / 2);
- $this->_call('imageFilledRectangle', array($this->_im, $x1, $top, $x2, $bottom, $c));
+ $this->call('imageFilledRectangle', array($this->_im, $x1, $top, $x2, $bottom, $c));
} else {
// Angled lines.
$dy = (cos($a) * $width / 2);
$verts = array($x2 + $dx, $y2 + $dy, $x2 - $dx, $y2 - $dy, $x1 - $dx, $y1 - $dy, $x1 + $dx, $y1 + $dy);
- $this->_call('imageFilledPolygon', array($this->_im, $verts, count($verts) / 2, $c));
+ $this->call('imageFilledPolygon', array($this->_im, $verts, count($verts) / 2, $c));
}
}
$style[] = $w;
}
- $this->_call('imageSetStyle', array($this->_im, $style));
- $this->_call('imageSetThickness', array($this->_im, $width));
- $this->_call('imageLine', array($this->_im, $x0, $y0, $x1, $y1, IMG_COLOR_STYLED));
+ $this->call('imageSetStyle', array($this->_im, $style));
+ $this->call('imageSetThickness', array($this->_im, $width));
+ $this->call('imageLine', array($this->_im, $x0, $y0, $x1, $y1, IMG_COLOR_STYLED));
}
/**
{
$c = $this->_allocateColor($color);
if (is_null($fill)) {
- $this->_call('imageArc', array($this->_im, $x, $y, $r * 2, $r * 2, $start, $end, $c));
+ $this->call('imageArc', array($this->_im, $x, $y, $r * 2, $r * 2, $start, $end, $c));
} else {
if ($fill !== $color) {
$f = $this->_allocateColor($fill);
- $this->_call('imageFilledArc', array($this->_im, $x, $y, $r * 2, $r * 2, $start, $end, $f, IMG_ARC_PIE));
- $this->_call('imageFilledArc', array($this->_im, $x, $y, $r * 2, $r * 2, $start, $end, $c, IMG_ARC_EDGED | IMG_ARC_NOFILL));
+ $this->call('imageFilledArc', array($this->_im, $x, $y, $r * 2, $r * 2, $start, $end, $f, IMG_ARC_PIE));
+ $this->call('imageFilledArc', array($this->_im, $x, $y, $r * 2, $r * 2, $start, $end, $c, IMG_ARC_EDGED | IMG_ARC_NOFILL));
} else {
- $this->_call('imageFilledArc', array($this->_im, $x, $y, $r * 2, $r * 2, $start, $end, $c, IMG_ARC_PIE));
+ $this->call('imageFilledArc', array($this->_im, $x, $y, $r * 2, $r * 2, $start, $end, $c, IMG_ARC_PIE));
}
}
}
* @return resource The image handler.
* @throws Horde_Image_Exception
*/
- protected function _create($width, $height)
+ public function create($width, $height)
{
- $result = $this->_call('imageCreateTrueColor', array($width, $height));
+ $result = $this->call('imageCreateTrueColor', array($width, $height));
if (!is_resource($result)) {
throw new Horde_Image_Exception('Could not create image.');
}
* @return mixed The result of the function call
* @throws Horde_Image_Exception
*/
- protected function _call($function, $params = null)
+ public function call($function, $params = null)
{
unset($php_errormsg);
$track = ini_set('track_errors', 1);