function pDraw::drawFromPicture
Search API
5.x pDraw.class.php | pDraw::drawFromPicture($PicType, $FileName, $X, $Y) |
4 calls to pDraw::drawFromPicture()
- pDraw::drawFromGIF in inc/
pchart/ pchart/ class/ pDraw.class.php - pDraw::drawFromJPG in inc/
pchart/ pchart/ class/ pDraw.class.php - pDraw::drawFromPNG in inc/
pchart/ pchart/ class/ pDraw.class.php - pDraw::drawPlotChart in inc/
pchart/ pchart/ class/ pDraw.class.php
File
- inc/
pchart/ pchart/ class/ pDraw.class.php, line 1234
Class
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);
}
}