note 55436 deleted from ref.image by tularis

From: Date: Sun, 29 Jun 2008 21:05:55 +0000
Subject: note 55436 deleted from ref.image by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-140938@lists.php.net to get a copy of this message
Note Submitter: Maarten Balliauw ---- A PHP "skew" function: <? $angle = 15; $pDirection = 1; header("Content-Type: image/png"); imagepng(ImageSkew("test.png", $angle, 1)); exit(); function ImageSkew($pImage, $pAngle, $pDirection = 0) { // Source image $iSource = ImageCreateFromPng("test.png"); // Destination image list($width, $height, $type, $attr) = getimagesize($pImage); $iCanvas = @imagecreate($width, $height); $cCyan = imagecolorallocate($iCanvas, 255, 0, 255); imagefill($iCanvas, 0, 0, $cCyan); // Pixel differences $diff = ($pAngle / 90); // Loop trough each width pixel $currentHeight = $height; $currentY = 0; if ($pDirection == 1) { $currentHeight = 0; $currentY = $height; } for ($i = 0; $i < $width; $i++) { // Take 1*height sample and copy to iCanvas if ($pDirection == 0) { imagecopyresampled($iCanvas, $iSource, $i, $currentY, $i, 0, 1, $currentHeight, 1, $height); } else { imagecopyresampled($iCanvas, $iSource, ($width - $i), $currentY, ($width - $i), 0, 1, $currentHeight, 1, $height); } // Change heights if ($pDirection == 0) { $currentHeight = $currentHeight - ($diff * 2); $currentY = ($height - $currentHeight) / 2; } else { $currentHeight = $height - ( $i * ($diff * 2) ); $currentY = ($height - $currentHeight) / 2; } } // Return return $iCanvas; } ?>

« previous php.notes (#140938) next »