I want to stick two images together with some overlapping space. I want this overlapping space to cross dissolve from the first to the second image.
This is the code i wrote last night:
Code: Select all
/*
* Cross dissolve transition
**************************************************/
function transition_crossdissolve($image, $image2, $dissolvespace)
{
$w1 = imagesx($image);
$h1 = imagesy($image);
$w2 = imagesx($image2);
$h2 = imagesy($image2);
if ($h1 < $h2)
{
$newheight = $h1;
}
else
{
$newheight = $h2;
}
$newwidth = ($w1 + $w2) - $dissolvespace;
//Create new container image
$newimage = @imagecreatetruecolor($newwidth, $newheight) or die("Cannot Initialize new GD image stream");
$frompixel = $w1 - $dissolvespace;
//Copy image2 onto the right side of the container image
imageCopy($newimage, $image2, $frompixel, 0, 0, 0, $w2, $h2);
//Copy part of image1 minus dissolvespace onto the left side of the container image
imageCopy($newimage, $image, 0, 0, 0, 0, $frompixel, $h1);
//Set transparency and calculate max. steps to fade
$transparency = 99;
$fadesteps = $transparency / $dissolvespace;
//copy the missing dissolvespace from image1 onto the right coordinates and fade out per line
for ($r=0; $r<$dissolvespace; $r++)
{
imageCopyMerge($newimage, $image, ($frompixel + $r), 0, $frompixel, 0, $dissolvespace, $h1, ($transparency - ($fadesteps * $r)));
}
return $newimage;
}
$image = transition_crossdissolve($image, $image2, 40);
header("Content-type: image/jpeg");
imagejpeg($image, "", 100);Instead of a cross dissolve it just sort of blurs the part that get's copied on top of $newimage.
Can someone explain to me what i am doing wrong?
Regards,
Symen

