From 8fd3241474b5f1a6dd043d8b1f5e3718034292b8 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 17 Feb 2007 18:32:06 +0000 Subject: [PATCH] Moved the output buffering stuff from the graph() function to _imageFlush() so that other graphing systems can use it --- Graph.php | 20 ++++++++++++++++++++ GraphPie.php | 12 +----------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/Graph.php b/Graph.php index fcc6357..c67ecdb 100644 --- a/Graph.php +++ b/Graph.php @@ -240,6 +240,26 @@ abstract class BSGraph $colors['grey'] = imagecolorallocate($this->image, 121, 121, 123); return $colors; } + + // ################################################################### + /** + * Runs the imagepng() function and returns the bytestream + * + * @return string Byte stream + */ + protected function _imageFlush() + { + ob_start(); + imagepng($this->image); + $data = ob_get_contents(); + if ($data === false) + { + $data = ob_get_clean(); + } + ob_clean(); + ob_end_clean(); + return $data; + } } /*=====================================================================* diff --git a/GraphPie.php b/GraphPie.php index ac5c574..b91293d 100644 --- a/GraphPie.php +++ b/GraphPie.php @@ -109,17 +109,7 @@ class BSGraphPie extends BSGraph imageline($this->image, $this->dimensions['width'] - self::PADDING, $graphstart, $this->dimensions['width'] - self::PADDING, $legy, $colors['black']); // right } - ob_start(); - imagepng($this->image); - $data = ob_get_contents(); - if ($data === false) - { - $data = ob_get_clean(); - } - ob_clean(); - ob_end_clean(); - - return $data; + return $this->_imageFlush(); } // ################################################################### -- 2.43.5