Skip to content

Commit

Permalink
Fix transparency issue
Browse files Browse the repository at this point in the history
  • Loading branch information
endroid committed Jan 5, 2022
1 parent 52e064c commit d9f12af
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/Writer/PngWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit d9f12af

Please sign in to comment.