From: Michael M Slusarz Date: Tue, 25 May 2010 19:57:18 +0000 (-0600) Subject: Various changes to make the PNG Image driver work. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=ff3e8d523943f55fcfac27b030f44882567657c8;p=horde.git Various changes to make the PNG Image driver work. Using EmptyIterator as the default makes it easier for the non iterable-drivers to fulfill abstract requirements (no need to define the various Iterable functions) --- diff --git a/framework/Image/lib/Horde/Image/Base.php b/framework/Image/lib/Horde/Image/Base.php index 68548030a..f914cb75b 100644 --- a/framework/Image/lib/Horde/Image/Base.php +++ b/framework/Image/lib/Horde/Image/Base.php @@ -16,7 +16,7 @@ * @TODO: - Can we depend on the Horde_Util:: class or some other solution needed? * - Exceptions */ -abstract class Horde_Image_Base Implements Iterator +abstract class Horde_Image_Base extends EmptyIterator { /** * Background color. @@ -91,6 +91,8 @@ abstract class Horde_Image_Base Implements Iterator * Constructor. * * @param string $rgb The base color for generated pixels/images. + * + * @throws InvalidArgumentException */ protected function __construct($params, $context = array()) { diff --git a/framework/Image/lib/Horde/Image/Gd.php b/framework/Image/lib/Horde/Image/Gd.php index 9701cf7e2..6c1234a34 100644 --- a/framework/Image/lib/Horde/Image/Gd.php +++ b/framework/Image/lib/Horde/Image/Gd.php @@ -789,46 +789,6 @@ class Horde_Image_Gd extends Horde_Image_Base } /** - * Return the current image from the internal iterator. - * - * @return Horde_Image_Gd - */ - public function current() - { - return clone($this); - } - - /** - * Get the index of the internal iterator. - * - * @return integer - */ - public function key() - { - return 0; - } - - /** - * Advance the iterator - * - * @return Horde_Image_Imagick - */ - public function next() - { - return null; - } - - /** - * Deterimines if the current iterator item is valid. - * - * @return boolean - */ - public function valid() - { - return false; - } - - /** * Request a specific image from the collection of images. * * @param integer $index The index to return diff --git a/framework/Image/lib/Horde/Image/Png.php b/framework/Image/lib/Horde/Image/Png.php index b42234a9c..aa9e4bda9 100644 --- a/framework/Image/lib/Horde/Image/Png.php +++ b/framework/Image/lib/Horde/Image/Png.php @@ -59,9 +59,9 @@ class Horde_Image_Png extends Horde_Image_Base { /** * PNG image constructor. */ - function Horde_Image_png($params) + public function __construct($params, $context = array()) { - parent::Horde_Image($params); + parent::__construct($params, $context); if (!empty($params['width'])) { $this->rectangle(0, 0, $params['width'], $params['height'], $this->_background, $this->_background); @@ -115,9 +115,9 @@ class Horde_Image_Png extends Horde_Image_Base { */ function rectangle($x, $y, $width, $height, $color = 'black', $fill = 'none') { - list($r, $g, $b) = $this->getRGB($color); + list($r, $g, $b) = Horde_Image::getRGB($color); if ($fill != 'none') { - list($fR, $fG, $fB) = $this->getRGB($fill); + list($fR, $fG, $fB) = Horde_Image::getRGB($fill); } $x2 = $x + $width; @@ -237,4 +237,31 @@ class Horde_Image_Png extends Horde_Image_Base { return pack('N', (($s2 << 16) | $s1)); } + /** + * Request a specific image from the collection of images. + * + * @param integer $index The index to return + * + * @return Horde_Image_Base + * @throws Horde_Image_Exception + */ + public function getImageAtIndex($index) + { + if ($index > 0) { + throw new Horde_Image_Exception('Image index out of bounds.'); + } + + return clone($this); + } + + /** + * Return the number of image pages available in the image object. + * + * @return integer + */ + public function getImagePageCount() + { + return 1; + } + }