Skip to content

Commit 0a3c4d3

Browse files
committed
Bugfix in viewbox calculation in quietzones=false mode
1 parent d3eb9f9 commit 0a3c4d3

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

QRCoder/SvgQRCode.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,17 @@ public string GetGraphic(int pixelsPerModule)
2323
}
2424
public string GetGraphic(int pixelsPerModule, Color darkColor, Color lightColor, bool drawQuietZones = true, SizingMode sizingMode = SizingMode.WidthHeightAttribute)
2525
{
26-
var viewBox = new Size(pixelsPerModule * this.QrCodeData.ModuleMatrix.Count, pixelsPerModule * this.QrCodeData.ModuleMatrix.Count);
26+
var offset = drawQuietZones ? 0 : 4;
27+
var edgeSize = this.QrCodeData.ModuleMatrix.Count * pixelsPerModule - (offset * 2 * pixelsPerModule);
28+
var viewBox = new Size(edgeSize, edgeSize);
2729
return this.GetGraphic(viewBox, darkColor, lightColor, drawQuietZones, sizingMode);
2830
}
2931

3032
public string GetGraphic(int pixelsPerModule, string darkColorHex, string lightColorHex, bool drawQuietZones = true, SizingMode sizingMode = SizingMode.WidthHeightAttribute)
3133
{
32-
var viewBox = new Size(pixelsPerModule * this.QrCodeData.ModuleMatrix.Count, pixelsPerModule * this.QrCodeData.ModuleMatrix.Count);
34+
var offset = drawQuietZones ? 0 : 4;
35+
var edgeSize = this.QrCodeData.ModuleMatrix.Count * pixelsPerModule - (offset * 2 * pixelsPerModule);
36+
var viewBox = new Size(edgeSize, edgeSize);
3337
return this.GetGraphic(viewBox, darkColorHex, lightColorHex, drawQuietZones, sizingMode);
3438
}
3539

0 commit comments

Comments
 (0)