Skip to content

Commit

Permalink
Merge pull request phpbb#5859 from rxu/ticket/16360
Browse files Browse the repository at this point in the history
[ticket/16360] Fix allocating color for GD 3D image CAPTCHA
  • Loading branch information
marc1706 committed Feb 11, 2020
2 parents 3d4af04 + b5993fc commit 10c038d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion phpBB/phpbb/captcha/gd_wave.php
Expand Up @@ -100,7 +100,12 @@ function execute($code, $seed)
{
$coeff1 = ($i + 12) / 45;
$coeff2 = 1 - $coeff1;
$colors[$i] = imagecolorallocate($img, ($coeff2 * $maxr) + ($coeff1 * $minr), ($coeff2 * $maxg) + ($coeff1 * $ming), ($coeff2 * $maxb) + ($coeff1 * $minb));

$red = ($coeff2 * $maxr) + ($coeff1 * $minr);
$green = ($coeff2 * $maxg) + ($coeff1 * $ming);
$blue = ($coeff2 * $maxb) + ($coeff1 * $minb);

$colors[$i] = imagecolorallocate($img, min([255, (int) $red]), min([255, (int) $green]), min([255, (int) $blue]));
}

// $img_buffer is the last row of 3-space positions (converted to img-space), cached
Expand Down

0 comments on commit 10c038d

Please sign in to comment.