I have the problem if I change my calculation for alpha in imagecolorallocatealpha is it wrong.
The pictures from 1 - 3 are put together and look like this:
If pictures 4 and 5 are added, it looks like this:
You can now see the golden scales and the gray scales on the body, but that's wrong. The gray scales on the body should not be there.
In reality, the dragon should look like this:
The gray scales on the body should be bright and the golden scales should remain as they are.
@Syscall already helped with the "alpha" function in this thread and it works good but now we think the "blendmode" function is wrong.
function blendmode($dst, $src)
{
$w = imagesx($src);
$h = imagesy($src);
for ($x = 0; $x < $w; $x++) {
for ($y = 0; $y < $h; $y++) {
$rgbDst = imagecolorsforindex($dst, imagecolorat($dst, $x, $y));
$rgbSrc = imagecolorsforindex($src, imagecolorat($src, $x, $y));
$r = min($rgbSrc['red'] + $rgbDst['red'], 255);
$g = min($rgbSrc['green'] + $rgbDst['green'], 255);
$b = min($rgbSrc['blue'] + $rgbDst['blue'], 255);
imagesetpixel($src, $x, $y, imagecolorallocatealpha($src, $r, $g, $b, 204 / 255 * 105));
}
}
return $src;
}
This is how the dragon looks like with buggy "blendmode" function: