Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

ezimagetextlayer.php
Go to the documentation of this file.
1 <?php
18 class eZImageTextLayer extends eZImageLayer
19 {
20 public $TextAngle;
21 public function __construct( $imageObjectRef = null, $imageObject = null,
22 $width = false, $height = false,
23 $font = false, $boundingBox = null, $text = null, $textAngle = 0 )
24 {
25 parent::__construct( $imageObjectRef, $imageObject, $width, $height, $font );
26 $this->Text = $text;
27 $this->TextAngle = $textAngle;
28 $this->TextBoundingBox = $boundingBox;
29 }
30
35 function processImage()
36 {
37 $destinationImageObject = $this->imageObjectInternal();
38 $bbox = $this->textBoundingBox();
39 $this->clear();
40 $font = $this->font();
41 $this->drawText( $font, $this->textColor(), $this->text(), $bbox[6], -$bbox[7], $this->textAngle(),
42 $destinationImageObject );
43 return true;
44 }
45
55 function mergeLayer( $image, $layerData, $lastLayerData )
56 {
57 $position = $image->calculatePosition( $layerData['parameters'], $this->width(), $this->height() );
58 $x = $position['x'];
59 $y = $position['y'];
60 $destinationImageObject = $image->imageObjectInternal( false );
61 if ( $lastLayerData === null and
62 $destinationImageObject === null )
63 {
64 $destinationImageObject = $image->imageObjectInternal();
65 $bbox = $this->textBoundingBox();
66 $font = $this->font();
67 $this->drawText( $font, $this->textColor(), $this->text(), $bbox[6], -$bbox[7], $this->textAngle(),
68 $destinationImageObject );
69 }
70 else
71 {
72 $destinationImageObject = $image->imageObjectInternal();
73 $imageObject = $this->imageObjectInternal();
74 $bbox = $this->textBoundingBox();
75 $image->copyImage( $imageObject, $destinationImageObject,
76 0, 0, $this->width(), $this->height(),
77 $x, $y );
78 $font = $this->font();
79 $this->drawText( $font, $this->textColor(), $this->text(), $bbox[6], -$bbox[7], $this->textAngle() );
80 $image->mergeImage( $destinationImageObject, $imageObject,
81 $x, $y,
82 $this->width(), $this->height(), 0, 0,
83 $image->getTransparencyPercent( $layerData['parameters'] ) );
84 }
85 }
86
90 function setText( $text )
91 {
92 $this->Text = $text;
93 }
94
98 function text()
99 {
100 return $this->Text;
101 }
102
106 function setTextAngle( $textAngle )
107 {
108 $this->TextAngle = $textAngle;
109 }
110
114 function textAngle()
115 {
116 return $this->TextAngle;
117 }
118
122 function textBoundingBox()
123 {
124 return $this->TextBoundingBox;
125 }
126
131 static function createForText( $text, &$font, $widthAdjustment, $heightAdjustment, $angle,
132 $absoluteWidth = false, $absoluteHeight = false )
133 {
134 $Return = false;
135 if ( !( $font instanceof eZImageFont ) )
136 return $Return;
137 if ( !function_exists( 'ImageTTFBBox' ) )
138 {
139 eZDebug::writeError( 'ImageTTFBBox function not in PHP, check PHP compilation', 'ezimagetextlayer.php' );
140 return $Return;
141 }
142 $bbox = ImageTTFBBox( $font->pointSize(), $angle, $font->realFile(), $text );
143
144 if ( !$bbox )
145 return $Return;
146
147 $xmin = min( $bbox[0], $bbox[2], $bbox[4], $bbox[6] );
148 $xmax = max( $bbox[0], $bbox[2], $bbox[4], $bbox[6] );
149 $ymin = min( $bbox[1], $bbox[3], $bbox[5], $bbox[7] );
150 $ymax = max( $bbox[1], $bbox[3], $bbox[5], $bbox[7] );
151
152 $width = abs( $xmax - $xmin );
153 $height = abs( $ymax - $ymin );
154 $width += $widthAdjustment;
155 $height += $heightAdjustment;
156
157 if ( $absoluteWidth !== false )
158 $width = $absoluteWidth;
159 if ( $absoluteHeight !== false)
160 $height = $absoluteHeight;
161
162 $layer = new eZImageTextLayer( null, null, $width, $height,
163 $font, $bbox, $text, $angle );
164 $layer->create( $width, $height, null );
165 return $layer;
166 }
167
169 public $TextBoundingBox;
170 public $Text;
171 public $Angle;
172 }
173
174 ?>
eZDebug\writeError
static writeError( $string, $label="", $backgroundClass="")
Definition: ezdebug.php:545
eZImageFont
Specifies a font used for drawing text.
Definition: ezimagefont.php:30
eZImageInterface\clear
clear( $color=false)
Definition: ezimageinterface.php:676
eZImageInterface\width
width()
Definition: ezimageinterface.php:555
eZImageInterface\drawText
drawText(&$font, $textColor, $text, $x, $y, $angle, $imageObject=null)
Definition: ezimageinterface.php:745
eZImageInterface\imageObjectInternal
imageObjectInternal( $createMissing=true)
Definition: ezimageinterface.php:360
eZImageInterface\textColor
textColor()
Definition: ezimageinterface.php:726
eZImageInterface\height
height()
Definition: ezimageinterface.php:563
eZImageInterface\font
font()
Definition: ezimageinterface.php:606
eZImageLayer
Defines a layer in a image object.
Definition: ezimagelayer.php:19
eZImageTextLayer
Layer for text information and rendering.
Definition: ezimagetextlayer.php:19
eZImageTextLayer\textBoundingBox
textBoundingBox()
Definition: ezimagetextlayer.php:122
eZImageTextLayer\mergeLayer
mergeLayer( $image, $layerData, $lastLayerData)
Definition: ezimagetextlayer.php:55
eZImageTextLayer\textAngle
textAngle()
Definition: ezimagetextlayer.php:114
eZImageTextLayer\$Angle
$Angle
Definition: ezimagetextlayer.php:171
eZImageTextLayer\$TextAngle
$TextAngle
Definition: ezimagetextlayer.php:20
eZImageTextLayer\$Text
$Text
Definition: ezimagetextlayer.php:170
eZImageTextLayer\setTextAngle
setTextAngle( $textAngle)
Definition: ezimagetextlayer.php:106
eZImageTextLayer\setText
setText( $text)
Definition: ezimagetextlayer.php:90
eZImageTextLayer\createForText
static createForText( $text, &$font, $widthAdjustment, $heightAdjustment, $angle, $absoluteWidth=false, $absoluteHeight=false)
Definition: ezimagetextlayer.php:131
eZImageTextLayer\__construct
__construct( $imageObjectRef=null, $imageObject=null, $width=false, $height=false, $font=false, $boundingBox=null, $text=null, $textAngle=0)
Definition: ezimagetextlayer.php:21
eZImageTextLayer\text
text()
Definition: ezimagetextlayer.php:98
eZImageTextLayer\processImage
processImage()
Definition: ezimagetextlayer.php:35
eZImageTextLayer\$TextBoundingBox
$TextBoundingBox
Definition: ezimagetextlayer.php:169
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.