13 * to license@zend.com so we can send you a copy immediately. |
13 * to license@zend.com so we can send you a copy immediately. |
14 * |
14 * |
15 * @category Zend |
15 * @category Zend |
16 * @package Zend_Barcode |
16 * @package Zend_Barcode |
17 * @subpackage Renderer |
17 * @subpackage Renderer |
18 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
18 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) |
19 * @license http://framework.zend.com/license/new-bsd New BSD License |
19 * @license http://framework.zend.com/license/new-bsd New BSD License |
20 * @version $Id: Image.php 24593 2012-01-05 20:35:02Z matthew $ |
20 * @version $Id$ |
21 */ |
21 */ |
22 |
22 |
23 /** @see Zend_Barcode_Renderer_RendererAbstract*/ |
23 /** @see Zend_Barcode_Renderer_RendererAbstract*/ |
24 require_once 'Zend/Barcode/Renderer/RendererAbstract.php'; |
24 require_once 'Zend/Barcode/Renderer/RendererAbstract.php'; |
25 |
25 |
26 /** |
26 /** |
27 * Class for rendering the barcode as image |
27 * Class for rendering the barcode as image |
28 * |
28 * |
29 * @category Zend |
29 * @category Zend |
30 * @package Zend_Barcode |
30 * @package Zend_Barcode |
31 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
31 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) |
32 * @license http://framework.zend.com/license/new-bsd New BSD License |
32 * @license http://framework.zend.com/license/new-bsd New BSD License |
33 */ |
33 */ |
34 class Zend_Barcode_Renderer_Image extends Zend_Barcode_Renderer_RendererAbstract |
34 class Zend_Barcode_Renderer_Image extends Zend_Barcode_Renderer_RendererAbstract |
35 { |
35 { |
36 /** |
36 /** |
89 parent::__construct($options); |
89 parent::__construct($options); |
90 } |
90 } |
91 |
91 |
92 /** |
92 /** |
93 * Set height of the result image |
93 * Set height of the result image |
|
94 * |
94 * @param null|integer $value |
95 * @param null|integer $value |
95 * @return Zend_Image_Barcode_Abstract |
96 * @return Zend_Image_Barcode_Abstract |
96 * @throw Zend_Image_Barcode_Exception |
97 * @throws Zend_Barcode_Renderer_Exception |
97 */ |
98 */ |
98 public function setHeight($value) |
99 public function setHeight($value) |
99 { |
100 { |
100 if (!is_numeric($value) || intval($value) < 0) { |
101 if (!is_numeric($value) || intval($value) < 0) { |
101 require_once 'Zend/Barcode/Renderer/Exception.php'; |
102 require_once 'Zend/Barcode/Renderer/Exception.php'; |
146 } |
148 } |
147 |
149 |
148 /** |
150 /** |
149 * Set an image resource to draw the barcode inside |
151 * Set an image resource to draw the barcode inside |
150 * |
152 * |
151 * @param resource $value |
153 * @param $image |
152 * @return Zend_Barcode_Renderer |
154 * @return Zend_Barcode_Renderer |
153 * @throw Zend_Barcode_Renderer_Exception |
155 * @throws Zend_Barcode_Renderer_Exception |
154 */ |
156 */ |
155 public function setResource($image) |
157 public function setResource($image) |
156 { |
158 { |
157 if (gettype($image) != 'resource' || get_resource_type($image) != 'gd') { |
159 if (gettype($image) != 'resource' || get_resource_type($image) != 'gd') { |
158 require_once 'Zend/Barcode/Renderer/Exception.php'; |
160 require_once 'Zend/Barcode/Renderer/Exception.php'; |
167 /** |
169 /** |
168 * Set the image type to produce (png, jpeg, gif) |
170 * Set the image type to produce (png, jpeg, gif) |
169 * |
171 * |
170 * @param string $value |
172 * @param string $value |
171 * @return Zend_Barcode_RendererAbstract |
173 * @return Zend_Barcode_RendererAbstract |
172 * @throw Zend_Barcode_Renderer_Exception |
174 * @throws Zend_Barcode_Renderer_Exception |
173 */ |
175 */ |
174 public function setImageType($value) |
176 public function setImageType($value) |
175 { |
177 { |
176 if ($value == 'jpg') { |
178 if ($value == 'jpg') { |
177 $value = 'jpeg'; |
179 $value = 'jpeg'; |
381 } |
385 } |
382 |
386 |
383 /** |
387 /** |
384 * Draw a polygon in the image resource |
388 * Draw a polygon in the image resource |
385 * |
389 * |
386 * @param string $text |
390 * @param string $text |
387 * @param float $size |
391 * @param float $size |
388 * @param array $position |
392 * @param array $position |
389 * @param string $font |
393 * @param string $font |
390 * @param integer $color |
394 * @param integer $color |
391 * @param string $alignment |
395 * @param string $alignment |
392 * @param float $orientation |
396 * @param float|int $orientation |
|
397 * @throws Zend_Barcode_Renderer_Exception |
393 */ |
398 */ |
394 protected function _drawText($text, $size, $position, $font, $color, $alignment = 'center', $orientation = 0) |
399 protected function _drawText($text, $size, $position, $font, $color, $alignment = 'center', $orientation = 0) |
395 { |
400 { |
396 $allocatedColor = imagecolorallocate( |
401 $allocatedColor = imagecolorallocate( |
397 $this->_resource, |
402 $this->_resource, |