note 82201 added to function.imagerotate

From: Date: Mon, 31 Mar 2008 22:02:09 +0000
Subject: note 82201 added to function.imagerotate
Groups: php.notes 
Request: Send a blank email to php-notes+get-137800@lists.php.net to get a copy of this message
otimized integration from 23-Feb-2007 04:21 just put it anywhere you like to use imagerotate with 90, 180, 270 degrees. <?php if(!function_exists("imagerotate")) { function imagerotate($src_img, $angle) { $src_x = imagesx($src_img); $src_y = imagesy($src_img); if ($angle == 180) { $dest_x = $src_x; $dest_y = $src_y; } elseif ($src_x <= $src_y) { $dest_x = $src_y; $dest_y = $src_x; } elseif ($src_x >= $src_y) { $dest_x = $src_y; $dest_y = $src_x; } $rotate=imagecreatetruecolor($dest_x,$dest_y); imagealphablending($rotate, false); switch ($angle) { case 270: for ($y = 0; $y < ($src_y); $y++) { for ($x = 0; $x < ($src_x); $x++) { $color = imagecolorat($src_img, $x, $y); imagesetpixel($rotate, $dest_x - $y - 1, $x, $color); }} break; case 90: for ($y = 0; $y < ($src_y); $y++) { for ($x = 0; $x < ($src_x); $x++) { $color = imagecolorat($src_img, $x, $y); imagesetpixel($rotate, $y, $dest_y - $x - 1, $color); }} break; case 180: for ($y = 0; $y < ($src_y); $y++) { for ($x = 0; $x < ($src_x); $x++) { $color = imagecolorat($src_img, $x, $y); imagesetpixel($rotate, $dest_x - $x - 1, $dest_y - $y - 1, $color); }} break; default: $rotate = $src_img; } return $rotate; }} ?> ---- Server IP: 212.124.37.9 Probable Submitter: 84.143.154.113 ---- Manual Page -- http://www.php.net/manual/en/function.imagerotate.php Edit -- https://master.php.net/note/edit/82201 Del: integrated -- https://master.php.net/note/delete/82201/integrated Del: useless -- https://master.php.net/note/delete/82201/useless Del: bad code -- https://master.php.net/note/delete/82201/bad+code Del: spam -- https://master.php.net/note/delete/82201/spam Del: non-english -- https://master.php.net/note/delete/82201/non-english Del: in docs -- https://master.php.net/note/delete/82201/in+docs Del: other reasons-- https://master.php.net/note/delete/82201 Reject -- https://master.php.net/note/reject/82201 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#137800) next »