note 50308 deleted from ref.image by tularis

From: Date: Sun, 29 Jun 2008 21:09:27 +0000
Subject: note 50308 deleted from ref.image by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-140957@lists.php.net to get a copy of this message
Note Submitter: domNOSPAMinic at epicwebservices dot net ---- Here's a simple function to deinterlace an entire image or a rectangular area of an image. - Parameters $image - the image to operate on $startodd - set to false to get odd lines, true to get even lines (default: false) $areax1 - start x value of rectangle (default: 0) $areay1 - start y value of rectangle (default: 0) $areax2 - end x value of rectangle (default: width of image) $areay2 - end y value of rectangle (default: height of image) <?php function image_deinterlace(&$image, $startodd, $areax1 = 0, $areay1 = 0, $areax2 = -1, $areay2 = -1) { // sanity checking if (!is_resource($image)) { return $image; } if ($areax2 == -1) { $areax2 = imagesx($image); } if ($areay2 == -1) { $areay2 = imagesy($image); } if ($areax2 <= $areax1) { return $image; } if ($areay2 - $areay1 < 2) { return $image; } // if start odd is true, we copy the 2nd line to the 1st // if start odd is false, we copy the 1st line to the 2nd if ($startodd) { for ($y = ($areay1 + 1); $y <= $areay2; $y = $y+2) { for ($x = $areax1; $x <= $areax2; $x++) { $curpixel = imagecolorat($image, $x, $y); imagesetpixel($image, $x, $y - 1, $curpixel); } } } else { for ($y = $areay1; $y <= $areay2; $y = $y+2) { for ($x = $areax1; $x <= $areax2; $x++) { $curpixel = imagecolorat($image, $x, $y); if ($y + 1 <= $areay2) { // just in case we're on the boundary imagesetpixel($image, $x, $y + 1, $curpixel); } } } } return $image; } ?>

« previous php.notes (#140957) next »