Skip to content

Commit dd49148

Browse files
authored
Merge branch 'master' into support_base64_linux
2 parents c9b102b + 295730d commit dd49148

File tree

4 files changed

+36
-11
lines changed

4 files changed

+36
-11
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

QRCoder/PayloadGenerator.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ public enum Authentication
5353
{
5454
WEP,
5555
WPA,
56-
nopass
56+
nopass,
57+
WPA2
5758
}
5859
}
5960

@@ -311,7 +312,7 @@ public class Url : Payload
311312
private readonly string url;
312313

313314
/// <summary>
314-
/// Generates a link. If not given, http/https protocol will be added.
315+
/// Generates a link. If the protocol is not specified, the http protocol will be added.
315316
/// </summary>
316317
/// <param name="url">Link url target</param>
317318
public Url(string url)
@@ -321,7 +322,7 @@ public Url(string url)
321322

322323
public override string ToString()
323324
{
324-
return (!this.url.StartsWith("http") ? "http://" + this.url : this.url);
325+
return (!this.url.StartsWith("http", StringComparison.OrdinalIgnoreCase) ? "http://" + this.url : this.url);
325326
}
326327
}
327328

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
}

QRCoderTests/PayloadGeneratorTests.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,19 @@ public void wifi_should_build_wpa()
317317
generator.ToString().ShouldBe($"WIFI:T:WPA;S:MyWiFiSSID;P:7heP4assw0rd;;");
318318
}
319319

320+
[Fact]
321+
[Category("PayloadGenerator/WiFi")]
322+
public void wifi_should_build_wpa2()
323+
{
324+
var ssid = "MyWiFiSSID";
325+
var password = "7heP4assw0rd";
326+
var authmode = PayloadGenerator.WiFi.Authentication.WPA2;
327+
var hideSSID = false;
328+
329+
var generator = new PayloadGenerator.WiFi(ssid, password, authmode, hideSSID);
330+
331+
generator.ToString().ShouldBe($"WIFI:T:WPA2;S:MyWiFiSSID;P:7heP4assw0rd;;");
332+
}
320333

321334
[Fact]
322335
[Category("PayloadGenerator/WiFi")]
@@ -744,6 +757,18 @@ public void url_should_build_https()
744757
}
745758

746759

760+
[Fact]
761+
[Category("PayloadGenerator/Url")]
762+
public void url_should_build_https_all_caps()
763+
{
764+
var url = "HTTPS://CODE-BUDE.NET";
765+
766+
var generator = new PayloadGenerator.Url(url);
767+
768+
generator.ToString().ShouldBe("HTTPS://CODE-BUDE.NET");
769+
}
770+
771+
747772
[Fact]
748773
[Category("PayloadGenerator/Url")]
749774
public void url_should_add_http()

0 commit comments

Comments
 (0)