function GetMaxContrast($x, $y) { $c1; $c2; $error = 0; $max = 0; $c1 = imageColorAt($this->i0, $x - (int) $this->diffspace, $y); $c2 = imageColorAt($this->i0, $x + (int) $this->diffspace, $y); $error = Cartoonfy::gmerror($c1, $c2); if ($error > $max) { $max = $error; } $c1 = imageColorAt($this->i0, $x, $y - (int) $this->diffspace); $c2 = imageColorAt($this->i0, $x, $y + (int) $this->diffspace); $error = Cartoonfy::gmerror($c1, $c2); if ($error > $max) { $max = $error; } $c1 = imageColorAt($this->i0, $x - (int) $this->diffspace, $y - (int) $this->diffspace); $c2 = imageColorAt($this->i0, $x + (int) $this->diffspace, $y + (int) $this->diffspace); $error = Cartoonfy::gmerror($c1, $c2); if ($error > $max) { $max = $error; } $c1 = imageColorAt($this->i0, $x + (int) $this->diffspace, $y - (int) $this->diffspace); $c2 = imageColorAt($this->i0, $x - (int) $this->diffspace, $y + (int) $this->diffspace); $error = Cartoonfy::gmerror($c1, $c2); if ($error > $max) { $max = $error; } return $max; }
* <====== Include main class ======> * */ include "Cartoonfy.class.php"; /* * * <====== Create effect ======> * */ /* * * Set-up parameters * */ $params = array('Triplevel' => 1.0, 'Diffspace' => 1.0 / 32.0); /* * * Create effect * * Constructor parameters: String image source, Float triplevel, Float diffspace * * * Callback function parameters: String output image format, Boolean attachment * * * ./effect/Cartoonfy.php?source=image.jpg * */ $cartoonfy = new Cartoonfy($_GET["source"], $params['Triplevel'], $params['Diffspace']); //$cartoonfy = new Cartoonfy ( "http://www.animalisti.it/prg/upload/campagne_scheda/sched_cane.jpg", $params [ 'Triplevel' ], $params [ 'Diffspace' ] ); $cartoonfy->showCartoonfy("jpg", false);