56 $this->renderingFunction = self::RENDERING_DEFAULT;
57 $this->mimeType = self::MIMETYPE_DEFAULT;
58 $this->uniqueName = md5(mt_rand(0, 9999) . time() . mt_rand(0, 9999));
61 parent::__construct();
66 if ($this->imageResource) {
67 imagedestroy($this->imageResource);
68 $this->imageResource = null;
80 if (!$this->imageResource) {
84 $width = imagesx($this->imageResource);
85 $height = imagesy($this->imageResource);
87 if (imageistruecolor($this->imageResource)) {
90 throw new Exception(
'Could not clone image resource');
93 imagealphablending($clone,
false);
94 imagesavealpha($clone,
true);
98 throw new Exception(
'Could not clone image resource');
102 $transparent = imagecolortransparent($this->imageResource);
103 if ($transparent >= 0) {
104 $rgb = imagecolorsforindex($this->imageResource, $transparent);
105 if ($rgb ===
false) {
106 throw new Exception(
'Could not get image colors');
109 imagesavealpha($clone,
true);
110 $color = imagecolorallocatealpha($clone, $rgb[
'red'], $rgb[
'green'], $rgb[
'blue'], $rgb[
'alpha']);
111 if ($color ===
false) {
112 throw new Exception(
'Could not get image alpha color');
115 imagefill($clone, 0, 0, $color);
120 imagecopy($clone, $this->imageResource, 0, 0, 0, 0,
$width,
$height);
122 $this->imageResource = $clone;
144 $this->imageResource = $value;
146 if ($this->imageResource !== null) {
148 $this->width = imagesx($this->imageResource);
149 $this->height = imagesy($this->imageResource);
174 $this->renderingFunction = $value;
198 $this->mimeType = $value;
211 $extension = explode(
'/', $extension);
212 $extension = $extension[1];
214 return $this->uniqueName . $this->
getImageIndex() .
'.' . $extension;
225 $this->renderingFunction .
228 parent::getHashCode() .
getRenderingFunction()
Get rendering function.
setMimeType($value)
Set mime type.
getIndexedFilename()
Get indexed filename (using image index).
setImageResource($value)
Set image resource.
__construct()
Create a new MemoryDrawing.
getImageIndex()
Get image index.
setRenderingFunction($value)
Set rendering function.
getImageResource()
Get image resource.
getMimeType()
Get mime type.
getHashCode()
Get hash code.