Skip to content

Commit

Permalink
Cast rgb values to int before bit shifting to fix an implicit cast error
Browse files Browse the repository at this point in the history
  • Loading branch information
RVxLab authored and dmester committed Jul 2, 2022
1 parent a7985cd commit 6a67ba4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Canvas/ColorUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,15 +208,15 @@ public static function over($fore, $back)
$backPA = $backA * (255 - $foreA);
$pa = ($forePA + $backPA);

$b = (
$b = (int) (
($forePA * (($fore >> 8) & 0xff) + $backPA * (($back >> 8) & 0xff)) /
$pa);

$g = (
$g = (int) (
($forePA * (($fore >> 16) & 0xff) + $backPA * (($back >> 16) & 0xff)) /
$pa);

$r = (
$r = (int) (
($forePA * (($fore >> 24) & 0xff) + $backPA * (($back >> 24) & 0xff)) /
$pa);

Expand Down

0 comments on commit 6a67ba4

Please sign in to comment.