/// <inheritdoc cref="ToPng(QrCode, int, int)"/>
 /// <param name="background">The background color.</param>
 /// <param name="foreground">The foreground color.</param>
 public static byte[] ToPng(this QrCode qrCode, int scale, int border, Color foreground, Color background)
 {
     using Image image     = qrCode.ToBitmap(scale, border, foreground, background);
     using MemoryStream ms = new MemoryStream();
     image.SaveAsPng(ms);
     return(ms.ToArray());
 }
 /// <inheritdoc cref="SaveAsPng(QrCode, string, int, int)"/>
 /// <param name="background">The background color.</param>
 /// <param name="foreground">The foreground color.</param>
 public static void SaveAsPng(this QrCode qrCode, string filename, int scale, int border, SKColor foreground, SKColor background)
 {
     using SKBitmap bitmap   = qrCode.ToBitmap(scale, border, foreground, background);
     using SKData data       = bitmap.Encode(SKEncodedImageFormat.Png, 90);
     using FileStream stream = File.OpenWrite(filename);
     data.SaveTo(stream);
 }
 /// <inheritdoc cref="ToPng(QrCode, int, int)"/>
 /// <param name="background">The background color.</param>
 /// <param name="foreground">The foreground color.</param>
 public static byte[] ToPng(this QrCode qrCode, int scale, int border, Color foreground, Color background)
 {
     using Bitmap bitmap   = qrCode.ToBitmap(scale, border, foreground, background);
     using MemoryStream ms = new MemoryStream();
     bitmap.Save(ms, ImageFormat.Png);
     return(ms.ToArray());
 }
 /// <summary>
 /// Creates a bitmap (raster image) of this QR code.
 /// <para>
 /// The <paramref name="scale"/> parameter specifies the scale of the image, which is
 /// equivalent to the width and height of each QR code module. Additionally, the number
 /// of modules to add as a border to all four sides can be specified.
 /// </para>
 /// <para>
 /// For example, <c>ToBitmap(scale: 10, border: 4)</c> means to pad the QR code with 4 white
 /// border modules on all four sides, and use 10&#xD7;10 pixels to represent each module.
 /// </para>
 /// <para>
 /// The resulting bitmap uses the pixel format <see cref="PixelFormat.Format24bppRgb"/>.
 /// If not specified, the foreground color is black (0x000000) und the background color always white (0xFFFFFF).
 /// </para>
 /// </summary>
 /// <param name="scale">The width and height, in pixels, of each module.</param>
 /// <param name="border">The number of border modules to add to each of the four sides.</param>
 /// <returns>The created bitmap representing this QR code.</returns>
 /// <exception cref="ArgumentOutOfRangeException"><paramref name="scale"/> is 0 or negative, <paramref name="border"/> is negative
 /// or the resulting image is wider than 32,768 pixels.</exception>
 public static Image ToBitmap(this QrCode qrCode, int scale, int border)
 {
     return(qrCode.ToBitmap(scale, border, Color.Black, Color.White));
 }
 /// <inheritdoc cref="SaveAsPng(QrCode, string, int, int)"/>
 /// <param name="background">The background color.</param>
 /// <param name="foreground">The foreground color.</param>
 public static void SaveAsPng(this QrCode qrCode, string filename, int scale, int border, Color foreground, Color background)
 {
     using Image image = qrCode.ToBitmap(scale, border, foreground, background);
     image.SaveAsPng(filename);
 }
 /// <summary>
 /// Creates a bitmap (raster image) of this QR code.
 /// <para>
 /// The <paramref name="scale"/> parameter specifies the scale of the image, which is
 /// equivalent to the width and height of each QR code module. Additionally, the number
 /// of modules to add as a border to all four sides can be specified.
 /// </para>
 /// <para>
 /// For example, <c>ToBitmap(scale: 10, border: 4)</c> means to pad the QR code with 4 white
 /// border modules on all four sides, and use 10&#xD7;10 pixels to represent each module.
 /// </para>
 /// <para>
 /// The resulting bitmap uses the pixel format <see cref="PixelFormat.Format24bppRgb"/>.
 /// If not specified, the foreground color is black (0x000000) und the background color always white (0xFFFFFF).
 /// </para>
 /// </summary>
 /// <param name="scale">The width and height, in pixels, of each module.</param>
 /// <param name="border">The number of border modules to add to each of the four sides.</param>
 /// <returns>The created bitmap representing this QR code.</returns>
 /// <exception cref="ArgumentOutOfRangeException"><paramref name="scale"/> is 0 or negative, <paramref name="border"/> is negative
 /// or the resulting image is wider than 32,768 pixels.</exception>
 public static SKBitmap ToBitmap(this QrCode qrCode, int scale, int border)
 {
     return(qrCode.ToBitmap(scale, border, SKColors.Black, SKColors.White));
 }
 /// <inheritdoc cref="ToPng(QrCode, int, int)"/>
 /// <param name="background">The background color.</param>
 /// <param name="foreground">The foreground color.</param>
 public static byte[] ToPng(this QrCode qrCode, int scale, int border, SKColor foreground, SKColor background)
 {
     using SKBitmap bitmap = qrCode.ToBitmap(scale, border, foreground, background);
     using SKData data     = bitmap.Encode(SKEncodedImageFormat.Png, 90);
     return(data.ToArray());
 }
 /// <inheritdoc cref="SaveAsPng(QrCode, string, int, int)"/>
 /// <param name="background">The background color.</param>
 /// <param name="foreground">The foreground color.</param>
 public static void SaveAsPng(this QrCode qrCode, string filename, int scale, int border, Color foreground, Color background)
 {
     using Bitmap bitmap = qrCode.ToBitmap(scale, border, foreground, background);
     bitmap.Save(filename, ImageFormat.Png);
 }