summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKore Nordmann <github@kore-nordmann.de>2006-08-09 13:56:04 +0000
committerKore Nordmann <github@kore-nordmann.de>2006-08-09 13:56:04 +0000
commitdd733c25d1d2777c0c07490cea0c5636352c7bfb (patch)
treeefae0d1107177608a092527630413b709ba1e481 /src
parent17b8e89991a4eee0944168aa10e0c43d2753db25 (diff)
downloadzetacomponents-graph-dd733c25d1d2777c0c07490cea0c5636352c7bfb.zip
zetacomponents-graph-dd733c25d1d2777c0c07490cea0c5636352c7bfb.tar.gz
- Added inline base64 encoded images for svg driver
Diffstat (limited to 'src')
-rw-r--r--src/driver/svg.php23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/driver/svg.php b/src/driver/svg.php
index 3f4ccef..768f091 100644
--- a/src/driver/svg.php
+++ b/src/driver/svg.php
@@ -58,14 +58,13 @@ class ezcGraphSvgDriver extends ezcGraphDriver
if ( $this->dom === null )
{
$this->dom = new DOMDocument();
- $svg = $this->dom->createElement( 'svg' );
+ $svg = $this->dom->createElementNS( 'http://www.w3.org/2000/svg', 'svg' );
+ $this->dom->appendChild( $svg );
- $svg->setAttribute( 'xmlns', 'http://www.w3.org/2000/svg' );
$svg->setAttribute( 'width', $this->options->width );
$svg->setAttribute( 'height', $this->options->height );
$svg->setAttribute( 'version', '1.0' );
$svg->setAttribute( 'id', 'ezcGraph' );
- $this->dom->appendChild( $svg );
$this->defs = $this->dom->createElement( 'defs' );
$this->defs = $svg->appendChild( $this->defs );
@@ -552,19 +551,25 @@ class ezcGraphSvgDriver extends ezcGraphDriver
*/
public function drawImage( $file, ezcGraphCoordinate $position, $width, $height )
{
- $this->createDocument();
-
- // @TODO: Inline images instead of linking them
- /*
+ $this->createDocument();
+
+ $data = getimagesize( $file );
$image = $this->dom->createElement( 'image' );
+
$image->setAttribute( 'x', $position->x );
$image->setAttribute( 'y', $position->y );
$image->setAttribute( 'width', $width . 'px' );
$image->setAttribute( 'height', $height . 'px' );
- $image->setAttribute( 'xlink:href', $file );
+ $image->setAttributeNS(
+ 'http://www.w3.org/1999/xlink',
+ 'xlink:href',
+ sprintf( 'data:%s;base64,%s',
+ $data['mime'],
+ base64_encode( file_get_contents( $file ) )
+ )
+ );
$this->elements->appendChild( $image );
- */
}
/**
OpenPOWER on IntegriCloud