note 40014 added to function.imagecopyresized
| From: | v1450000 at v1450 dot drago dot net | Date: | Thu, 19 Feb 2004 01:48:32 +0000 |
| Subject: | note 40014 added to function.imagecopyresized | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-65360@lists.php.net to get a copy of this message | ||
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));
}
}
}
----
Manual Page -- http://www.php.net/manual/en/function.imagecopyresized.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+40014
Delete -- http://master.php.net/manage/user-notes.php?action=delete+40014&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+40014&report=yes
Search -- http://master.php.net/manage/user-notes.php