note 33244 deleted from function.imagecopyresized by aidan

From: Date: Mon, 04 Oct 2004 09:39:35 +0000
Subject: note 33244 deleted from function.imagecopyresized by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-77915@lists.php.net to get a copy of this message
Note Submitter: daniel dot stankewitz at onvista dot de ---- Hi, today it took me some hours to figure out this function. This one seems to be _really_ bicubic, because it calculates the rectangles of the src image fitting to one pixel of the dst image and averages them. The Quality is much better than the function with the same name above, but unfortunately its twice or triple as slow. :-( Maybe someone can enhance / tune it. Would be cool. It's still not usable for thumbnail lists. --Daniel function ImageCopyResampleBicubic (&$dst_img, &$src_img, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h) { ImagePaletteCopy ($dst_img, $src_img); $rX = $src_w / $dst_w; $rY = $src_h / $dst_h; $w = 0; for ($y = $dst_y; $y < $dst_h; $y++) { $ow = $w; $w = round(($y + 1) * $rY); $t = 0; for ($x = $dst_x; $x < $dst_w; $x++) { $r = $g = $b = 0; $a = 0; $ot = $t; $t = round(($x + 1) * $rX); for ($u = 0; $u < ($w - $ow); $u++) { for ($p = 0; $p < ($t - $ot); $p++) { $c = ImageColorsForIndex ($src_img, ImageColorAt ($src_img, $ot + $p, $ow + $u)); $r += $c['red']; $g += $c['green']; $b += $c['blue']; $a++; } } ImageSetPixel ($dst_img, $x, $y, ImageColorClosest ($dst_img, $r / $a, $g / $a, $b / $a)); } } }

« previous php.notes (#77915) next »