note 40014 deleted from function.imagecopyresized by aidan
| From: | aidan@php.net | Date: | Mon, 04 Oct 2004 09:37:27 +0000 |
| Subject: | note 40014 deleted from function.imagecopyresized by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-77902@lists.php.net to get a copy of this message | ||
Note Submitter: v1450000 at v1450 dot drago dot net
----
I made a small change to make the script behave well when $dimg and $simg have different aspect.
function ImageCopyResampleBicubic (&$dimg, &$simg, $dx, $dy, $sx, $sy, $dw, $dh, $sw, $sh) {
ImagePaletteCopy ($dimg, $simg);
$rX = $sw / $dw;
$rY = $sh / $dh;
$nY = 0;
for ($y=$sy; $y<$dh; $y++) {
$oY = $nY;
$nY = intval(($y + 1) * $rY+.5);
$nX = 0;
for ($x=$sx; $x<$dw; $x++) {
$r = $g = $b = $a = 0;
$oX = $nX;
$nX = intval(($x + 1) * $rX+.5);
for ($i=$nY; --$i>=$oY;) {
for ($j=$nX; --$j>=$oX;) {
$c = ImageColorsForIndex ($simg, ImageColorAt ($simg, $j, $i));
$r += $c['red'];
$g += $c['green'];
$b += $c['blue'];
$a++;
}
}
ImageSetPixel ($dimg, ($x+$dx-$sx), ($y+$dy-$sy), ImageColorClosest ($dimg, $r/$a, $g/$a,
$b/$a));
}
}
}