note 56984 added to function.imagecopy

From: Date: Tue, 20 Sep 2005 20:48:55 +0000
Subject: note 56984 added to function.imagecopy
Groups: php.notes 
Request: Send a blank email to php-notes+get-95504@lists.php.net to get a copy of this message
An little addon to Borszczuk's great function. I've added the imagealphablending, so it supports transperency prette nice! It worked with me (only tested with PNG files). I'm not sure if the imagesavealpha($imgdest, true); should be added, but it works fine without! No problems so far... Thanks Borszczuk! Great job... The code with the addon: <?php define("IMAGE_FLIP_HORIZONTAL", 1); define("IMAGE_FLIP_VERTICAL", 2); define("IMAGE_FLIP_BOTH", 3); function ImageFlip($imgsrc, $type) { $width = imagesx($imgsrc); $height = imagesy($imgsrc); $imgdest = imagecreatetruecolor($width, $height); ImageAlphaBlending($imgdest, false); switch( $type ) { // mirror wzgl. osi case IMAGE_FLIP_HORIZONTAL: for( $y=0 ; $y<$height ; $y++ ) imagecopy($imgdest, $imgsrc, 0, $height-$y-1, 0, $y, $width, 1); break; case IMAGE_FLIP_VERTICAL: for( $x=0 ; $x<$width ; $x++ ) imagecopy($imgdest, $imgsrc, $width-$x-1, 0, $x, 0, 1, $height); break; case IMAGE_FLIP_BOTH: for( $x=0 ; $x<$width ; $x++ ) imagecopy($imgdest, $imgsrc, $width-$x-1, 0, $x, 0, 1, $height); $rowBuffer = imagecreatetruecolor($width, 1); for( $y=0 ; $y<($height/2) ; $y++ ) { imagecopy($rowBuffer, $imgdest , 0, 0, 0, $height-$y-1, $width, 1); imagecopy($imgdest , $imgdest , 0, $height-$y-1, 0, $y, $width, 1); imagecopy($imgdest , $rowBuffer, 0, $y, 0, 0, $width, 1); } imagedestroy( $rowBuffer ); break; } return( $imgdest ); } ?> ---- Manual Page -- http://www.php.net/manual/en/function.imagecopy.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+56984 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+56984&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+56984&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+56984&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+56984&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+56984&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+56984&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+56984&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+56984&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#95504) next »