From d9f12af739c11c70fa1e8132dba8f849395e939b Mon Sep 17 00:00:00 2001 From: Jeroen van den Enden Date: Wed, 5 Jan 2022 21:27:44 +0000 Subject: [PATCH] Fix transparency issue --- src/Writer/PngWriter.php | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/Writer/PngWriter.php b/src/Writer/PngWriter.php index 00eccc4..e944d84 100644 --- a/src/Writer/PngWriter.php +++ b/src/Writer/PngWriter.php @@ -44,16 +44,10 @@ public function write(QrCodeInterface $qrCode, LogoInterface $logo = null, Label $qrCode->getForegroundColor()->getAlpha() ); - /** @var int $backgroundColor */ - $backgroundColor = imagecolorallocatealpha( - $baseImage, - $qrCode->getBackgroundColor()->getRed(), - $qrCode->getBackgroundColor()->getGreen(), - $qrCode->getBackgroundColor()->getBlue(), - $qrCode->getBackgroundColor()->getAlpha() - ); + /** @var int $transparentColor */ + $transparentColor = imagecolorallocatealpha($baseImage, 255, 255, 255, 127); - imagefill($baseImage, 0, 0, $backgroundColor); + imagefill($baseImage, 0, 0, $transparentColor); for ($rowIndex = 0; $rowIndex < $matrix->getBlockCount(); ++$rowIndex) { for ($columnIndex = 0; $columnIndex < $matrix->getBlockCount(); ++$columnIndex) {