diff --git a/QRCoder/PngByteQRCode.cs b/QRCoder/PngByteQRCode.cs
index 8fa69f95..43045b1f 100644
--- a/QRCoder/PngByteQRCode.cs
+++ b/QRCoder/PngByteQRCode.cs
@@ -41,6 +41,19 @@ public byte[] GetGraphic(int pixelsPerModule, bool drawQuietZones = true)
return png.GetBytes();
}
+#if !NETSTANDARD1_3
+ ///
+ /// Creates a 2-color PNG of the QR code, using 1-bit indexed color. Colors may contain transparency.
+ ///
+ /// The number of pixels each dark/light module of the QR code will occupy in the final QR code image.
+ /// The color of the dark modules.
+ /// The color of the light modules.
+ /// Indicates if quiet zones around the QR code should be drawn.
+ /// Returns the QR code graphic as a PNG byte array.
+ public byte[] GetGraphic(int pixelsPerModule, System.Drawing.Color darkColor, System.Drawing.Color lightColor, bool drawQuietZones = true)
+ => GetGraphic(pixelsPerModule, new byte[] { darkColor.R, darkColor.G, darkColor.B, darkColor.A }, new byte[] { lightColor.R, lightColor.G, lightColor.B, lightColor.A }, drawQuietZones);
+#endif
+
///
/// Creates a 2-color PNG of the QR code, using 1-bit indexed color. Accepts 3-byte RGB colors for normal images and 4-byte RGBA-colors for transparent images.
///
diff --git a/QRCoderApiTests/net35+net40+net50+net50-windows+netstandard20/QRCoder.approved.txt b/QRCoderApiTests/net35+net40+net50+net50-windows+netstandard20/QRCoder.approved.txt
index 4bc3a2ff..0a75bc99 100644
--- a/QRCoderApiTests/net35+net40+net50+net50-windows+netstandard20/QRCoder.approved.txt
+++ b/QRCoderApiTests/net35+net40+net50+net50-windows+netstandard20/QRCoder.approved.txt
@@ -837,6 +837,7 @@ namespace QRCoder
public PngByteQRCode(QRCoder.QRCodeData data) { }
public byte[] GetGraphic(int pixelsPerModule, bool drawQuietZones = true) { }
public byte[] GetGraphic(int pixelsPerModule, byte[] darkColorRgba, byte[] lightColorRgba, bool drawQuietZones = true) { }
+ public byte[] GetGraphic(int pixelsPerModule, System.Drawing.Color darkColor, System.Drawing.Color lightColor, bool drawQuietZones = true) { }
}
public static class PngByteQRCodeHelper
{
diff --git a/QRCoderApiTests/net60-windows/QRCoder.approved.txt b/QRCoderApiTests/net60-windows/QRCoder.approved.txt
index 9f84c603..99b5f961 100644
--- a/QRCoderApiTests/net60-windows/QRCoder.approved.txt
+++ b/QRCoderApiTests/net60-windows/QRCoder.approved.txt
@@ -844,6 +844,7 @@ namespace QRCoder
public PngByteQRCode(QRCoder.QRCodeData data) { }
public byte[] GetGraphic(int pixelsPerModule, bool drawQuietZones = true) { }
public byte[] GetGraphic(int pixelsPerModule, byte[] darkColorRgba, byte[] lightColorRgba, bool drawQuietZones = true) { }
+ public byte[] GetGraphic(int pixelsPerModule, System.Drawing.Color darkColor, System.Drawing.Color lightColor, bool drawQuietZones = true) { }
}
public static class PngByteQRCodeHelper
{
diff --git a/QRCoderApiTests/net60/QRCoder.approved.txt b/QRCoderApiTests/net60/QRCoder.approved.txt
index a50f60df..6d269d08 100644
--- a/QRCoderApiTests/net60/QRCoder.approved.txt
+++ b/QRCoderApiTests/net60/QRCoder.approved.txt
@@ -788,6 +788,7 @@ namespace QRCoder
public PngByteQRCode(QRCoder.QRCodeData data) { }
public byte[] GetGraphic(int pixelsPerModule, bool drawQuietZones = true) { }
public byte[] GetGraphic(int pixelsPerModule, byte[] darkColorRgba, byte[] lightColorRgba, bool drawQuietZones = true) { }
+ public byte[] GetGraphic(int pixelsPerModule, System.Drawing.Color darkColor, System.Drawing.Color lightColor, bool drawQuietZones = true) { }
}
public static class PngByteQRCodeHelper
{
diff --git a/QRCoderTests/PngByteQRCodeRendererTests.cs b/QRCoderTests/PngByteQRCodeRendererTests.cs
index 82cabf4a..1cebf94c 100644
--- a/QRCoderTests/PngByteQRCodeRendererTests.cs
+++ b/QRCoderTests/PngByteQRCodeRendererTests.cs
@@ -61,6 +61,30 @@ public void can_render_pngbyte_qrcode_color()
#endif
}
+#if !NETCOREAPP1_1
+ [Fact]
+ [Category("QRRenderer/PngByteQRCode")]
+ public void can_render_pngbyte_qrcode_drawing_color()
+ {
+ //Create QR code
+ var gen = new QRCodeGenerator();
+ var data = gen.CreateQrCode("This is a quick test! 123#?", QRCodeGenerator.ECCLevel.L);
+ var pngCodeGfx = new PngByteQRCode(data).GetGraphic(5, Color.Red, Color.Blue);
+
+#if NETCOREAPP1_1
+ var result = HelperFunctions.ByteArrayToHash(pngCodeGfx);
+ result.ShouldBe("0144b1d40aa6eeb6cb07df42822ea0a7");
+#else
+ using (var mStream = new MemoryStream(pngCodeGfx))
+ {
+ var bmp = (Bitmap)Image.FromStream(mStream);
+ var result = HelperFunctions.BitmapToHash(bmp);
+ result.ShouldBe("88d394b2405499869feb69b81593e703");
+ }
+#endif
+ }
+#endif
+
[Fact]
[Category("QRRenderer/PngByteQRCode")]