note 61751 deleted from ref.image by didou

From: Date: Sun, 23 Apr 2006 23:00:44 +0000
Subject: note 61751 deleted from ref.image by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-109250@lists.php.net to get a copy of this message
Note Submitter: relsqui at chiliahedron dot com ---- Here's an improved version of the image-flipping function I added to the notes for imagecopy(), which in turn was inspired by others that seemed unnecessarily complex. It uses a bitmap for its arguments, so you can specify either direction or both with a bitwise OR. The define()s, of course, are unnecessary but helpful. Please let me know if you have any problems with it. <?php define("VERTICAL", 1); define("HORIZONTAL", 2); function imageflip($image, $mode) { $w = imagesx($image); $h = imagesy($image); $flipped = imagecreate($w, $h); if ($mode && VERTICAL) { for ($y = 0; $y < $h; $y++) { imagecopy($flipped, $image, 0, $y, 0, $h - $y - 1, $w, 1); } } if ($mode && HORIZONTAL) { for ($x = 0; $x < $w; $x++) { imagecopy($flipped, $image, $x, 0, $w - $x - 1, 0, 1, $h); } } return $flipped; } ?>

« previous php.notes (#109250) next »