kenzzii / mtchart

Automatically exported from code.google.com/p/mtchart
GNU General Public License v3.0
0 stars 0 forks source link

drawFromPictureResized #9

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Got an enhancement for mtChart.

If you need to draw an image to the Graph and would like to resize it
right use this function drawFromPictureResized. You can basically pass
jpg, png and gif images. PHP should autodetect on loading the image to
the image object.

   /**
    *  Load Image from any image file and resize it.
    *  */
   public function drawFromPictureResized($FileName, $X, $Y,
$W=false, $H=false) {
       if (file_exists($FileName)) {
           $Infos = getimagesize($FileName);
           $Width = $Infos[0];
           $Height = $Infos[1];
           $NewWidth = ($W) ? $W : $Width;
           $NewHeight = ($H) ? $H : $Height;

           $Raster = imagecreatefromstring(file_get_contents
($FileName));
           imagecopyresampled($this->Picture, $Raster, $X, $Y, 0, 0,
$NewWidth, $NewHeight, $Width, $Height);
           imagedestroy($Raster);
           return true;
       }
   }

Original issue reported on code.google.com by repthe...@gmail.com on 30 Sep 2009 at 8:47

GoogleCodeExporter commented 8 years ago
not a defect, this is an enhancement to mtChart... sorry for posting wrong

Original comment by repthe...@gmail.com on 30 Sep 2009 at 8:48