All pastes #636416 Raw Edit

Eneas

public text v1 · immutable
#636416 ·published 2007-07-27 21:47 UTC
rendered paste body
<?
set_time_limit(120);
header("Content-type: image/png");

class Perspective{
	
	var $sup = 70;
	var $sup_x;
	
	var $x;
	var $y;
	
	var $image;
	var $dst_image;
	
	var $factor;
	
	function Perspective(){
		$this->image = imagecreatefromjpeg('bb.jpg');
		
		$this->x = imagesx($this->image);
		$this->y = imagesy($this->image);
		
		//die ('eneas'.$this->x);
		
		$this->sup_x = round($this->x * $this->sup / 100);
		
		$this->factor = round( $this->y / ($this->x - $this->sup_x));
		
		$this->dst_image = imagecreate($this->x, $this->y);
		
		$this->ResizeImage();
	}
	
	function ResizeImage(){
		$y = $this->y;
		$i = $y;
		while ($y != 0) {
			$this->LineCopy($y,$i);
			$y = $y - $this->factor;
			$i = $i - ($this->y / $this->x);
		}
		return $this->dst_image;
	}
	
	function LineCopy($line,$i){
		
		$pos_x = ($this->x - ($this->sup_x + ($this->factor * ($this->y - $i)))) / 2;
		
		//die ('eneas'.$pos_x);
		
		//imagecopyresampled ( resource $dst_image, resource $src_image, int $dst_x, int $dst_y, int $src_x, int $src_y, int $dst_w, int $dst_h, int $src_w, int $src_h )
		
		imagecopyresampled ( $this->dst_image, $this->image, $pos_x, ($this->y - $line), 0, ($this->y - $line), ($this->x - $pos_x * 2), $this->factor, $this->x, $this->factor );
	
	}
}


$teste = new Perspective();

$image = $teste->ResizeImage();

//print_r($image);

imagepng($image);
imagedestroy($image);

?>