note 90350 added to function.imagerotate

From: Date: Fri, 17 Apr 2009 11:47:12 +0000
Subject: note 90350 added to function.imagerotate
Groups: php.notes 
Request: Send a blank email to php-notes+get-153425@lists.php.net to get a copy of this message
There is a slight mistake in the previous post by Kae Cyphet. When setting the pixels of the new image the co-ordinates have to occasionally use the width ($wid) and height ($hei). These values must be reduced by 1 as the co-ordinates start at 0 (Not 1) so they only go up to $wid - 1 and $hei - 1 (Not $wid and $hei). Here's an example of the first function to show this: <?php function rotate_right90($im) { $wid = imagesx($im); $hei = imagesy($im); $im2 = imagecreatetruecolor($hei,$wid); for($i = 0;$i < $wid; $i++) { for($j = 0;$j < $hei; $j++) { $ref = imagecolorat($im,$i,$j); imagesetpixel($im2,($hei - 1) - $j,$i,$ref); } } return $im2; } ?> Other than that very useful functions! ---- Server IP: 92.48.74.199 Probable Submitter: 82.30.73.18 ---- Manual Page -- http://www.php.net/manual/en/function.imagerotate.php Edit -- https://master.php.net/note/edit/90350 Del: integrated -- https://master.php.net/note/delete/90350/integrated Del: useless -- https://master.php.net/note/delete/90350/useless Del: bad code -- https://master.php.net/note/delete/90350/bad+code Del: spam -- https://master.php.net/note/delete/90350/spam Del: non-english -- https://master.php.net/note/delete/90350/non-english Del: in docs -- https://master.php.net/note/delete/90350/in+docs Del: other reasons-- https://master.php.net/note/delete/90350 Reject -- https://master.php.net/note/reject/90350 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#153425) next »