Skip to content

Commit 295730d

Browse files
authored
Merge pull request #408 from Tragen/patch-1
Update ArtQRCode.cs
2 parents a24c984 + 33ae0c1 commit 295730d

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

QRCoder/ArtQRCode.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ public Bitmap GetGraphic(Bitmap backgroundImage = null)
5959
/// <param name="backgroundImageStyle">Style of the background image (if set). Fill=spanning complete graphic; DataAreaOnly=Don't paint background into quietzone</param>
6060
/// <param name="finderPatternImage">Optional image that should be used instead of the default finder patterns</param>
6161
/// <returns>QRCode graphic as bitmap</returns>
62-
public Bitmap GetGraphic(int pixelsPerModule, Color darkColor, Color lightColor, Color backgroundColor, Bitmap backgroundImage = null, double pixelSizeFactor = 0.8,
62+
public Bitmap GetGraphic(int pixelsPerModule, Color darkColor, Color lightColor, Color backgroundColor, Bitmap backgroundImage = null, double pixelSizeFactor = 1,
6363
bool drawQuietZones = true, QuietZoneStyle quietZoneRenderingStyle = QuietZoneStyle.Dotted,
6464
BackgroundImageStyle backgroundImageStyle = BackgroundImageStyle.DataAreaOnly, Bitmap finderPatternImage = null)
6565
{
6666
if (pixelSizeFactor > 1)
6767
throw new Exception("The parameter pixelSize must be between 0 and 1. (0-100%)");
68-
int pixelSize = (int)Math.Min(pixelsPerModule, Math.Floor(pixelsPerModule / pixelSizeFactor));
68+
int pixelSize = (int)Math.Min(pixelsPerModule, Math.Floor(pixelsPerModule * pixelSizeFactor));
6969

7070
var numModules = QrCodeData.ModuleMatrix.Count - (drawQuietZones ? 0 : 8);
7171
var offset = (drawQuietZones ? 0 : 4);
@@ -283,7 +283,7 @@ public static class ArtQRCodeHelper
283283
/// <param name="finderPatternImage">Optional image that should be used instead of the default finder patterns</param>
284284
/// <returns>QRCode graphic as bitmap</returns>
285285
public static Bitmap GetQRCode(string plainText, int pixelsPerModule, Color darkColor, Color lightColor, Color backgroundColor, ECCLevel eccLevel, bool forceUtf8 = false,
286-
bool utf8BOM = false, EciMode eciMode = EciMode.Default, int requestedVersion = -1, Bitmap backgroundImage = null, double pixelSizeFactor = 0.8,
286+
bool utf8BOM = false, EciMode eciMode = EciMode.Default, int requestedVersion = -1, Bitmap backgroundImage = null, double pixelSizeFactor = 1.0,
287287
bool drawQuietZones = true, QuietZoneStyle quietZoneRenderingStyle = QuietZoneStyle.Flat,
288288
BackgroundImageStyle backgroundImageStyle = BackgroundImageStyle.DataAreaOnly, Bitmap finderPatternImage = null)
289289
{
@@ -295,4 +295,4 @@ public static Bitmap GetQRCode(string plainText, int pixelsPerModule, Color dark
295295
}
296296
}
297297

298-
#endif
298+
#endif

QRCoderTests/ArtQRCodeRendererTests.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ public void should_throw_pixelfactor_oor_exception()
8383
[Category("QRRenderer/ArtQRCode")]
8484
public void can_instantate_parameterless()
8585
{
86-
var asciiCode = new ArtQRCode();
87-
asciiCode.ShouldNotBeNull();
88-
asciiCode.ShouldBeOfType<ArtQRCode>();
86+
var artCode = new ArtQRCode();
87+
artCode.ShouldNotBeNull();
88+
artCode.ShouldBeOfType<ArtQRCode>();
8989
}
9090

9191
[Fact]
@@ -94,7 +94,6 @@ public void can_render_artqrcode_from_helper()
9494
{
9595
//Create QR code
9696
var bmp = ArtQRCodeHelper.GetQRCode("A", 10, Color.Black, Color.White, Color.Transparent, QRCodeGenerator.ECCLevel.L);
97-
9897
var result = HelperFunctions.BitmapToHash(bmp);
9998
result.ShouldBe("57ecaa9bdeadcdcbeac8a19d734907ff");
10099
}

0 commit comments

Comments
 (0)