Explicitly convert float to int in GDImageAdapter's alpha values
authorSascha Greuel <github@1-2.dev>
Sat, 13 Aug 2022 19:06:28 +0000 (21:06 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Mon, 29 Aug 2022 08:58:43 +0000 (10:58 +0200)
Implicit conversion from float to int is deprecated in PHP 8.1.

Closes #4958

wcfsetup/install/files/lib/system/image/adapter/GDImageAdapter.class.php

index b53bebbaf6fead0ab016c2b74b5f2990ffb48a42..8028db8e731d850c7ea76ecda215ae7453412743 100644 (file)
@@ -261,7 +261,7 @@ class GDImageAdapter implements IImageAdapter, IWebpImageAdapter
             $this->colorData['red'],
             $this->colorData['green'],
             $this->colorData['blue'],
-            (1 - $opacity) * 127
+            \round((1 - $opacity) * 127)
         );
 
         // draw text
@@ -545,7 +545,7 @@ class GDImageAdapter implements IImageAdapter, IWebpImageAdapter
                     ($colorxy >> 16) & 0xFF,
                     ($colorxy >> 8) & 0xFF,
                     $colorxy & 0xFF,
-                    $alpha
+                    \round($alpha)
                 );
                 // set pixel with the new color + opacity
                 if (!\imagesetpixel($src_im, $x, $y, $alphacolorxy)) {