You are here

function pDraw::drawFromPicture in Visitors 7.2

Same name and namespace in other branches
  1. 7 pChart/class/pDraw.class.php \pDraw::drawFromPicture()
4 calls to pDraw::drawFromPicture()
pDraw::drawFromGIF in pChart/class/pDraw.class.php
pDraw::drawFromJPG in pChart/class/pDraw.class.php
pDraw::drawFromPNG in pChart/class/pDraw.class.php
pDraw::drawPlotChart in pChart/class/pDraw.class.php

File

pChart/class/pDraw.class.php, line 1234

Class

pDraw

Code

function drawFromPicture($PicType, $FileName, $X, $Y) {
  if (file_exists($FileName)) {
    list($Width, $Height) = $this
      ->getPicInfo($FileName);
    if ($PicType == 1) {
      $Raster = imagecreatefrompng($FileName);
    }
    elseif ($PicType == 2) {
      $Raster = imagecreatefromgif($FileName);
    }
    elseif ($PicType == 3) {
      $Raster = imagecreatefromjpeg($FileName);
    }
    else {
      return 0;
    }
    $RestoreShadow = $this->Shadow;
    if ($this->Shadow && $this->ShadowX != 0 && $this->ShadowY != 0) {
      $this->Shadow = FALSE;
      if ($PicType == 3) {
        $this
          ->drawFilledRectangle($X + $this->ShadowX, $Y + $this->ShadowY, $X + $Width + $this->ShadowX, $Y + $Height + $this->ShadowY, array(
          "R" => $this->ShadowR,
          "G" => $this->ShadowG,
          "B" => $this->ShadowB,
          "Alpha" => $this->Shadowa,
        ));
      }
      else {
        $TranparentID = imagecolortransparent($Raster);
        for ($Xc = 0; $Xc <= $Width - 1; $Xc++) {
          for ($Yc = 0; $Yc <= $Height - 1; $Yc++) {
            $RGBa = imagecolorat($Raster, $Xc, $Yc);
            $Values = imagecolorsforindex($Raster, $RGBa);
            if ($Values["alpha"] < 120) {
              $AlphaFactor = floor($this->Shadowa / 100 * (100 / 127 * (127 - $Values["alpha"])));
              $this
                ->drawAlphaPixel($X + $Xc + $this->ShadowX, $Y + $Yc + $this->ShadowY, $AlphaFactor, $this->ShadowR, $this->ShadowG, $this->ShadowB);
            }
          }
        }
      }
    }
    $this->Shadow = $RestoreShadow;
    imagecopy($this->Picture, $Raster, $X, $Y, 0, 0, $Width, $Height);
    imagedestroy($Raster);
  }
}