[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * PHPExcel_Worksheet_MemoryDrawing 5 * 6 * Copyright (c) 2006 - 2015 PHPExcel 7 * 8 * This library is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU Lesser General Public 10 * License as published by the Free Software Foundation; either 11 * version 2.1 of the License, or (at your option) any later version. 12 * 13 * This library is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 17 * 18 * You should have received a copy of the GNU Lesser General Public 19 * License along with this library; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 * 22 * @category PHPExcel 23 * @package PHPExcel_Worksheet 24 * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) 25 * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL 26 * @version ##VERSION##, ##DATE## 27 */ 28 class PHPExcel_Worksheet_MemoryDrawing extends PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable 29 { 30 /* Rendering functions */ 31 const RENDERING_DEFAULT = 'imagepng'; 32 const RENDERING_PNG = 'imagepng'; 33 const RENDERING_GIF = 'imagegif'; 34 const RENDERING_JPEG = 'imagejpeg'; 35 36 /* MIME types */ 37 const MIMETYPE_DEFAULT = 'image/png'; 38 const MIMETYPE_PNG = 'image/png'; 39 const MIMETYPE_GIF = 'image/gif'; 40 const MIMETYPE_JPEG = 'image/jpeg'; 41 42 /** 43 * Image resource 44 * 45 * @var resource 46 */ 47 private $imageResource; 48 49 /** 50 * Rendering function 51 * 52 * @var string 53 */ 54 private $renderingFunction; 55 56 /** 57 * Mime type 58 * 59 * @var string 60 */ 61 private $mimeType; 62 63 /** 64 * Unique name 65 * 66 * @var string 67 */ 68 private $uniqueName; 69 70 /** 71 * Create a new PHPExcel_Worksheet_MemoryDrawing 72 */ 73 public function __construct() 74 { 75 // Initialise values 76 $this->imageResource = null; 77 $this->renderingFunction = self::RENDERING_DEFAULT; 78 $this->mimeType = self::MIMETYPE_DEFAULT; 79 $this->uniqueName = md5(rand(0, 9999). time() . rand(0, 9999)); 80 81 // Initialize parent 82 parent::__construct(); 83 } 84 85 /** 86 * Get image resource 87 * 88 * @return resource 89 */ 90 public function getImageResource() 91 { 92 return $this->imageResource; 93 } 94 95 /** 96 * Set image resource 97 * 98 * @param $value resource 99 * @return PHPExcel_Worksheet_MemoryDrawing 100 */ 101 public function setImageResource($value = null) 102 { 103 $this->imageResource = $value; 104 105 if (!is_null($this->imageResource)) { 106 // Get width/height 107 $this->width = imagesx($this->imageResource); 108 $this->height = imagesy($this->imageResource); 109 } 110 return $this; 111 } 112 113 /** 114 * Get rendering function 115 * 116 * @return string 117 */ 118 public function getRenderingFunction() 119 { 120 return $this->renderingFunction; 121 } 122 123 /** 124 * Set rendering function 125 * 126 * @param string $value 127 * @return PHPExcel_Worksheet_MemoryDrawing 128 */ 129 public function setRenderingFunction($value = PHPExcel_Worksheet_MemoryDrawing::RENDERING_DEFAULT) 130 { 131 $this->renderingFunction = $value; 132 return $this; 133 } 134 135 /** 136 * Get mime type 137 * 138 * @return string 139 */ 140 public function getMimeType() 141 { 142 return $this->mimeType; 143 } 144 145 /** 146 * Set mime type 147 * 148 * @param string $value 149 * @return PHPExcel_Worksheet_MemoryDrawing 150 */ 151 public function setMimeType($value = PHPExcel_Worksheet_MemoryDrawing::MIMETYPE_DEFAULT) 152 { 153 $this->mimeType = $value; 154 return $this; 155 } 156 157 /** 158 * Get indexed filename (using image index) 159 * 160 * @return string 161 */ 162 public function getIndexedFilename() 163 { 164 $extension = strtolower($this->getMimeType()); 165 $extension = explode('/', $extension); 166 $extension = $extension[1]; 167 168 return $this->uniqueName . $this->getImageIndex() . '.' . $extension; 169 } 170 171 /** 172 * Get hash code 173 * 174 * @return string Hash code 175 */ 176 public function getHashCode() 177 { 178 return md5( 179 $this->renderingFunction . 180 $this->mimeType . 181 $this->uniqueName . 182 parent::getHashCode() . 183 __CLASS__ 184 ); 185 } 186 187 /** 188 * Implement PHP __clone to create a deep clone, not just a shallow copy. 189 */ 190 public function __clone() 191 { 192 $vars = get_object_vars($this); 193 foreach ($vars as $key => $value) { 194 if (is_object($value)) { 195 $this->$key = clone $value; 196 } else { 197 $this->$key = $value; 198 } 199 } 200 } 201 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |