This commit is contained in:
smiley
2023-10-15 16:28:16 +02:00
parent c0dba8dab5
commit 2327690e99
+14 -9
View File
@@ -536,10 +536,11 @@ class QRMatrix{
*/
public function setFormatInfo(MaskPattern $maskPattern = null):self{
$this->maskPattern = $maskPattern;
$bits = 0; // sets all format fields to false (test mode)
$bits = ($this->maskPattern instanceof MaskPattern)
? $this->eccLevel->getformatPattern($this->maskPattern)
: 0; // sets all format fields to false (test mode)
if($this->maskPattern instanceof MaskPattern){
$bits = $this->eccLevel->getformatPattern($this->maskPattern);
}
for($i = 0; $i < 15; $i++){
$v = (($bits >> $i) & 1) === 1;
@@ -578,6 +579,11 @@ class QRMatrix{
*/
public function setQuietZone(int $quietZoneSize):self{
// early exit if there's nothing to add
if($quietZoneSize < 1){
return $this;
}
if($this->matrix[($this->moduleCount - 1)][($this->moduleCount - 1)] === $this::M_NULL){
throw new QRCodeDataException('use only after writing data');
}
@@ -655,12 +661,6 @@ class QRMatrix{
* @throws \chillerlan\QRCode\Data\QRCodeDataException
*/
public function setLogoSpace(int $width, int $height = null, int $startX = null, int $startY = null):self{
// for logos, we operate in ECC H (30%) only
if($this->eccLevel->getLevel() !== EccLevel::H){
throw new QRCodeDataException('ECC level "H" required to add logo space');
}
$height ??= $width;
// if width and height happen to be negative or 0 (default value), just return - nothing to do
@@ -668,6 +668,11 @@ class QRMatrix{
return $this; // @codeCoverageIgnore
}
// for logos, we operate in ECC H (30%) only
if($this->eccLevel->getLevel() !== EccLevel::H){
throw new QRCodeDataException('ECC level "H" required to add logo space');
}
// $this->moduleCount includes the quiet zone (if created), we need the QR size here
$dimension = $this->version->getDimension();