setCurrentDimensions() public method

Sets $currentDimensions.
See also: GdThumb::$currentDimensions
public setCurrentDimensions ( object $currentDimensions )
$currentDimensions object
Exemplo n.º 1
0
 * 
 * Licensed under the MIT License
 * Redistributions of files must retain the above copyright notice.
 * 
 * @author Ian Selby <*****@*****.**>
 * @copyright Copyright (c) 2009 Gen X Design
 * @link http://phpthumb.gxdlabs.com
 * @license http://www.opensource.org/licenses/mit-license.php The MIT License
 * @version 3.0
 * @package PhpThumb
 * @filesource
 */
/**
 * GD Reflection Lib Plugin
 * 
 * This plugin allows you to create those fun Apple(tm)-style reflections in your images
 * 
 * @package PhpThumb
 * @subpackage Plugins
 */
class GdReflectionLib
{
    /**
	 * Instance of GdThumb passed to this class
	 * 
	 * @var GdThumb
	 */
    protected $parentInstance;
    protected $currentDimensions;
    protected $workingImage;
    protected $newImage;
    protected $options;
    public function createReflection($percent, $reflection, $white, $border, $borderColor, &$that)
    {
        // bring stuff from the parent class into this class...
        $this->parentInstance = $that;
        $this->currentDimensions = $this->parentInstance->getCurrentDimensions();
        $this->workingImage = $this->parentInstance->getWorkingImage();
        $this->newImage = $this->parentInstance->getOldImage();
        $this->options = $this->parentInstance->getOptions();
        $width = $this->currentDimensions['width'];
        $height = $this->currentDimensions['height'];
        $reflectionHeight = intval($height * ($reflection / 100));
        $newHeight = $height + $reflectionHeight;
        $reflectedPart = $height * ($percent / 100);
        $this->workingImage = imagecreatetruecolor($width, $newHeight);
        imagealphablending($this->workingImage, true);
        $colorToPaint = imagecolorallocatealpha($this->workingImage, 255, 255, 255, 0);
Exemplo n.º 2
0
 public function resizeStretch($width, $height, &$that)
 {
     // bring stuff from the parent class into this class...
     $this->parentInstance = $that;
     $this->oldImage = $this->parentInstance->getOldImage();
     $this->currentDimensions = $this->parentInstance->getCurrentDimensions();
     $this->workingImage = $this->parentInstance->getWorkingImage();
     $this->options = $this->parentInstance->getOptions();
     // make sure our arguments are valid
     if (!is_numeric($width)) {
         throw new InvalidArgumentException('$maxWidth must be numeric');
     }
     if (!is_numeric($height)) {
         throw new InvalidArgumentException('$maxHeight must be numeric');
     }
     // get the new dimensions...
     $this->newDimensions = array('newWidth' => $width, 'newHeight' => $height);
     // create the working image
     if (function_exists('imagecreatetruecolor')) {
         $this->workingImage = imagecreatetruecolor($this->newDimensions['newWidth'], $this->newDimensions['newHeight']);
     } else {
         $this->workingImage = imagecreate($this->newDimensions['newWidth'], $this->newDimensions['newHeight']);
     }
     //$this->parentInstance->preserveAlpha();
     // and create the newly sized image
     imagecopyresampled($this->workingImage, $this->oldImage, 0, 0, 0, 0, $this->newDimensions['newWidth'], $this->newDimensions['newHeight'], $this->currentDimensions['width'], $this->currentDimensions['height']);
     // update all the variables and resources to be correct
     $this->parentInstance->setOldImage($this->workingImage);
     $this->parentInstance->setCurrentDimensions($this->newDimensions);
     return $that;
 }
Exemplo n.º 3
0
 public function resizeFixedSize($width, $height, $color = '#FFFFFF', &$that)
 {
     $this->parentInstance = $that;
     $this->parentInstance->resize($width, $height);
     $this->currentDimensions = $this->parentInstance->getCurrentDimensions();
     $this->workingImage = $this->parentInstance->getWorkingImage();
     $this->newImage = $this->parentInstance->getOldImage();
     $this->options = $this->parentInstance->getOptions();
     $this->workingImage = imagecreatetruecolor($width, $height);
     imagealphablending($this->workingImage, true);
     $rgb = $this->hex2rgb($color, false);
     $colorToPaint = imagecolorallocatealpha($this->workingImage, $rgb[0], $rgb[1], $rgb[2], 0);
     imagefilledrectangle($this->workingImage, 0, 0, $width, $height, $colorToPaint);
     imagecopyresampled($this->workingImage, $this->newImage, intval(($width - $this->currentDimensions['width']) / 2), intval(($height - $this->currentDimensions['height']) / 2), 0, 0, $this->currentDimensions['width'], $this->currentDimensions['height'], $this->currentDimensions['width'], $this->currentDimensions['height']);
     $this->parentInstance->setOldImage($this->workingImage);
     $this->currentDimensions['width'] = $width;
     $this->currentDimensions['height'] = $height;
     $this->parentInstance->setCurrentDimensions($this->currentDimensions);
     return $that;
 }