Full Code of manuelbl/QrCodeGenerator for AI

master d5d7336a2377 cached
113 files
1.0 MB
334.0k tokens
293 symbols
1 requests
Download .txt
Showing preview only (1,084K chars total). Download the full file or copy to clipboard to get everything.
Repository: manuelbl/QrCodeGenerator
Branch: master
Commit: d5d7336a2377
Files: 113
Total size: 1.0 MB

Directory structure:
gitextract_hpw2vdf4/

├── .config/
│   └── dotnet-tools.json
├── .github/
│   └── workflows/
│       ├── continuous-integration.yml
│       └── demos.yaml
├── .gitignore
├── Demo-ASP.NET-Core/
│   ├── Demo-ASP.NET-Core.csproj
│   ├── Demo-ASP.NET-Core.sln
│   ├── Program.cs
│   ├── Properties/
│   │   └── launchSettings.json
│   ├── QrCodeBitmapExtensions.cs
│   ├── QrCodeController.cs
│   ├── README.md
│   ├── Startup.cs
│   ├── appsettings.Development.json
│   ├── appsettings.json
│   └── wwwroot/
│       ├── home.html
│       ├── styles.css
│       └── ui.js
├── Demo-ImageMagick/
│   ├── Demo-ImageMagick.csproj
│   ├── Demo-ImageMagick.sln
│   ├── Program.cs
│   ├── QrCodeImageExtensions.cs
│   └── README.md
├── Demo-ImageSharp/
│   ├── Demo-ImageSharp.csproj
│   ├── Demo-ImageSharp.sln
│   ├── Program.cs
│   ├── QrCodeBitmapExtensions.cs
│   └── README.md
├── Demo-QRCode-Variety/
│   ├── Demo-QRCode-Variety.csproj
│   ├── Demo-QRCode-Variety.sln
│   ├── Program.cs
│   └── README.md
├── Demo-SkiaSharp/
│   ├── Demo-SkiaSharp.csproj
│   ├── Demo-SkiaSharp.sln
│   ├── Program.cs
│   ├── QrCodeBitmapExtensions.cs
│   └── README.md
├── Demo-System-Drawing/
│   ├── Demo-System-Drawing.csproj
│   ├── Demo-System-Drawing.sln
│   ├── Program.cs
│   ├── QrCodeBitmapExtensions.cs
│   └── README.md
├── Demo-VCard/
│   ├── Program.cs
│   ├── VCardDemo.csproj
│   └── VCardDemo.sln
├── Demo-WinForms/
│   ├── Demo-WinForms.csproj
│   ├── Demo-WinForms.sln
│   ├── Form1.Designer.cs
│   ├── Form1.cs
│   ├── Form1.resx
│   ├── Program.cs
│   ├── QrCodeBitmapExtensions.cs
│   ├── QrCodeControl.cs
│   └── README.md
├── Demo-WinUI/
│   ├── Demo-WinUI/
│   │   ├── App.xaml
│   │   ├── App.xaml.cs
│   │   ├── Demo-WinUI.csproj
│   │   ├── MainViewModel.cs
│   │   ├── MainWindow.xaml
│   │   ├── MainWindow.xaml.cs
│   │   ├── NativeMethods.txt
│   │   ├── Package.appxmanifest
│   │   ├── Properties/
│   │   │   ├── PublishProfiles/
│   │   │   │   ├── win-arm64.pubxml
│   │   │   │   ├── win-x64.pubxml
│   │   │   │   └── win-x86.pubxml
│   │   │   └── launchSettings.json
│   │   ├── QrCodeControl.xaml
│   │   ├── QrCodeControl.xaml.cs
│   │   ├── QrCodeDrawing.cs
│   │   └── app.manifest
│   ├── Demo-WinUI.sln
│   └── README.md
├── Demo-WindowsPresentationFoundation/
│   ├── App.xaml
│   ├── App.xaml.cs
│   ├── AssemblyInfo.cs
│   ├── Demo-WindowsPresentationFoundation.csproj
│   ├── Demo-WindowsPresentationFoundation.sln
│   ├── MainWindow.xaml
│   ├── MainWindow.xaml.cs
│   ├── QrCodeDrawing.cs
│   ├── README.md
│   └── app.manifest
├── LICENSE
├── QrCodeGenerator/
│   ├── BitArrayExtensions.cs
│   ├── DataTooLongException.cs
│   ├── Graphics.cs
│   ├── Key.snk
│   ├── Objects.cs
│   ├── PngBuilder.cs
│   ├── QrCode.cs
│   ├── QrCodeGenerator.csproj
│   ├── QrSegment.cs
│   ├── QrSegmentAdvanced.cs
│   ├── ReedSolomonGenerator.cs
│   ├── docfx/
│   │   ├── api/
│   │   │   └── index.md
│   │   ├── docfx.json
│   │   └── index.md
│   └── docs/
│       └── README.md
├── QrCodeGenerator.sln
├── QrCodeGeneratorTest/
│   ├── BitArrayExtensionsTest.cs
│   ├── KanjiTest.cs
│   ├── PngTest.cs
│   ├── QrCodeBitmapTest.cs
│   ├── QrCodeDataProvider.cs
│   ├── QrCodeGeneratorTest.csproj
│   ├── QrCodeTest.cs
│   ├── QrCodeTestCase.cs
│   ├── QrSegmentEncodingTest.cs
│   ├── QrSegmentRegexTest.cs
│   ├── RandomData.cs
│   ├── StructuredAppendTest.cs
│   ├── SvgTest.cs
│   └── TestHelper.cs
└── README.md

================================================
FILE CONTENTS
================================================

================================================
FILE: .config/dotnet-tools.json
================================================
{
  "version": 1,
  "isRoot": true,
  "tools": {
    "dotnet-validate": {
      "version": "0.0.1-preview.304",
      "commands": [
        "dotnet-validate"
      ]
    }
  }
}

================================================
FILE: .github/workflows/continuous-integration.yml
================================================
name: Continuous Integration

on: [push, pull_request]

env:
  Configuration: Release
  ContinuousIntegrationBuild: true
  DOTNET_CLI_TELEMETRY_OPTOUT: true
  DOTNET_NOLOGO: true
  DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: true
  TERM: xterm-256color

jobs:
  package:
    strategy:
      matrix:
        os: [ macos-latest, ubuntu-latest, windows-latest ]
      fail-fast: false
    runs-on: ${{ matrix.os }}
    name: Build and run tests
    steps:
      - name: Checkout git repository
        uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - uses: actions/setup-dotnet@v4
        with:
          dotnet-version: |
            6.x
            8.x

      - name: Restore NuGet packages
        run: dotnet restore

      - name: Build solution
        run: dotnet build --no-restore --verbosity normal

      - name: Run tests
        run: dotnet test --no-build --verbosity normal

      - name: Upload test results
        uses: actions/upload-artifact@v4
        if: always()
        with:
          name: TestResults-${{ runner.os }}
          path: TestResults-*.html

      - name: Create and validate NuGet packages
        run: |
          dotnet tool restore
          dotnet pack --no-build --verbosity normal
        if: startsWith(matrix.os,'windows')


================================================
FILE: .github/workflows/demos.yaml
================================================
name: Demos

on: [push, pull_request]

env:
  Configuration: Release
  ContinuousIntegrationBuild: true
  DOTNET_CLI_TELEMETRY_OPTOUT: true
  DOTNET_NOLOGO: true
  DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: true
  TERM: xterm-256color

jobs:
  build:
    runs-on: windows-latest
    name: Build demo projects
    steps:
      - name: Checkout git repository
        uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - uses: actions/setup-dotnet@v4
        with:
          dotnet-version: |
            6.x
            8.x

      - name: Create local NuGet source
        run: |
          mkdir ..\LocalPackages
          $pkgdir = Resolve-Path ..\LocalPackages
          dotnet nuget add source $pkgdir --name Local

      - name: Build library package
        run: |
          dotnet restore
          dotnet tool restore
          dotnet pack --verbosity normal

      - name: Install library package
        run: |
          $pkg = Resolve-Path QrCodeGenerator\bin\Release\Net.Codecrete.QrCodeGenerator.*.nupkg
          nuget push $pkg -Source Local

      - name: Build Demo-ImageSharp
        run: dotnet build
        working-directory: Demo-ImageSharp
      - name: Build Demo-ASP.NET-Core
        run: dotnet build
        working-directory: Demo-ASP.NET-Core
      - name: Build Demo-ImageMagick
        run: dotnet build
        working-directory: Demo-ImageMagick
      - name: Build Demo-QRCode-Variety
        run: dotnet build
        working-directory: Demo-QRCode-Variety
      - name: Build Demo-SkiaSharp
        run: dotnet build
        working-directory: Demo-SkiaSharp
      - name: Build Demo-System-Drawing
        run: dotnet build
        working-directory: Demo-System-Drawing
      - name: Build Demo-VCard
        run: dotnet build
        working-directory: Demo-VCard
      - name: Build Demo-WindowsPresentationFoundation
        run: dotnet build
        working-directory: Demo-WindowsPresentationFoundation
      - name: Build Demo-WinForms
        run: dotnet build
        working-directory: Demo-WinForms
      - name: Build Demo-WinUI
        run: dotnet build
        working-directory: Demo-WinUI


================================================
FILE: .gitignore
================================================
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates

# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs


# Build results
[Bb]in/
[Oo]bj/

# Visual Studio 2015/2017 cache/options directory
.vs/

# Visual Studio Code
.vscode/

# Rider
.idea/


================================================
FILE: Demo-ASP.NET-Core/Demo-ASP.NET-Core.csproj
================================================
<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <RootNamespace>Net.Codecrete.QrCodeGenerator.Demo</RootNamespace>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Net.Codecrete.QrCodeGenerator" Version="2.1.0" />
    <PackageReference Include="SkiaSharp" Version="2.88.6" />
  </ItemGroup>

</Project>


================================================
FILE: Demo-ASP.NET-Core/Demo-ASP.NET-Core.sln
================================================

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31919.166
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demo-ASP.NET-Core", "Demo-ASP.NET-Core.csproj", "{8EA82CD7-A88E-4A93-94B0-FA0C7DD1C7F1}"
EndProject
Global
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
		Debug|Any CPU = Debug|Any CPU
		Release|Any CPU = Release|Any CPU
	EndGlobalSection
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
		{8EA82CD7-A88E-4A93-94B0-FA0C7DD1C7F1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{8EA82CD7-A88E-4A93-94B0-FA0C7DD1C7F1}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{8EA82CD7-A88E-4A93-94B0-FA0C7DD1C7F1}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{8EA82CD7-A88E-4A93-94B0-FA0C7DD1C7F1}.Release|Any CPU.Build.0 = Release|Any CPU
	EndGlobalSection
	GlobalSection(SolutionProperties) = preSolution
		HideSolutionNode = FALSE
	EndGlobalSection
	GlobalSection(ExtensibilityGlobals) = postSolution
		SolutionGuid = {2902DABB-C256-46C5-AF46-35600F5F7A0E}
	EndGlobalSection
EndGlobal


================================================
FILE: Demo-ASP.NET-Core/Program.cs
================================================
//
// QR code generator library (.NET)
// https://github.com/manuelbl/QrCodeGenerator
//
// Copyright (c) 2021 Manuel Bleichenbacher
// Licensed under MIT License
// https://opensource.org/licenses/MIT
//

using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;

namespace Net.Codecrete.QrCodeGenerator.Demo
{
    public class Program
    {
        public static void Main(string[] args)
        {
            CreateHostBuilder(args).Build().Run();
        }

        public static IHostBuilder CreateHostBuilder(string[] args) =>
            Host.CreateDefaultBuilder(args)
                .ConfigureWebHostDefaults(webBuilder =>
                {
                    webBuilder.UseStartup<Startup>();
                });
    }
}


================================================
FILE: Demo-ASP.NET-Core/Properties/launchSettings.json
================================================
{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:25726",
      "sslPort": 44337
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "Demo_ASP.NET_Core": {
      "commandName": "Project",
      "dotnetRunMessages": "true",
      "launchBrowser": true,
      "applicationUrl": "https://localhost:5001;http://localhost:5000",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  }
}


================================================
FILE: Demo-ASP.NET-Core/QrCodeBitmapExtensions.cs
================================================
//
// QR code generator library (.NET)
// https://github.com/manuelbl/QrCodeGenerator
//
// Copyright (c) 2021 Manuel Bleichenbacher
// Licensed under MIT License
// https://opensource.org/licenses/MIT
//

using SkiaSharp;
using System;
using System.IO;

namespace Net.Codecrete.QrCodeGenerator
{
    public static class QrCodeBitmapExtensions
    {
        /// <inheritdoc cref="ToBitmap(QrCode, int, int)"/>
        /// <param name="background">The background color.</param>
        /// <param name="foreground">The foreground color.</param>
        public static SKBitmap ToBitmap(this QrCode qrCode, int scale, int border, SKColor foreground, SKColor background)
        {
            // check arguments
            if (scale <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(scale), "Value out of range");
            }
            if (border < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(border), "Value out of range");
            }

            int size = qrCode.Size;
            int dim = (size + border * 2) * scale;

            if (dim > short.MaxValue)
            {
                throw new ArgumentOutOfRangeException(nameof(scale), "Scale or border too large");
            }

            // create bitmap
            SKBitmap bitmap = new SKBitmap(dim, dim, SKColorType.Rgb888x, SKAlphaType.Opaque);

            using (SKCanvas canvas = new SKCanvas(bitmap))
            {
                // draw background
                using (SKPaint paint = new SKPaint { Color = background })
                {
                    canvas.DrawRect(0, 0, dim, dim, paint);
                }

                // draw modules
                using (SKPaint paint = new SKPaint { Color = foreground })
                {
                    for (int y = 0; y < size; y++)
                    {
                        for (int x = 0; x < size; x++)
                        {
                            if (qrCode.GetModule(x, y))
                            {
                                canvas.DrawRect((x + border) * scale, (y + border) * scale, scale, scale, paint);
                            }
                        }
                    }
                }
            }

            return bitmap;
        }

        /// <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();
        }

        /// <summary>
        /// Creates a PNG image of this QR code and returns it as a byte array.
        /// <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>ToPng(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>
        /// 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 byte[] ToPng(this QrCode qrCode, int scale, int border)
        {
            return qrCode.ToPng(scale, border, SKColors.Black, SKColors.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, 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);
        }

        /// <summary>
        /// Saves this QR code as a PNG file.
        /// <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>SaveAsPng("qrcode.png", 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>
        /// 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>
        /// <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 void SaveAsPng(this QrCode qrCode, string filename, int scale, int border)
        {
            qrCode.SaveAsPng(filename, scale, border, SKColors.Black, SKColors.White);
        }
    }
}


================================================
FILE: Demo-ASP.NET-Core/QrCodeController.cs
================================================
//
// QR code generator library (.NET)
// https://github.com/manuelbl/QrCodeGenerator
//
// Copyright (c) 2021 Manuel Bleichenbacher
// Licensed under MIT License
// https://opensource.org/licenses/MIT
//

using Microsoft.AspNetCore.Mvc;
using System;
using System.Text;

namespace Net.Codecrete.QrCodeGenerator.Demo
{
    /// <summary>
    /// Controller for generating QR code as PNG or SVG images
    /// </summary>
    [ApiController]
    public class QrCodeController : ControllerBase
    {
        private static readonly QrCode.Ecc[] errorCorrectionLevels = { QrCode.Ecc.Low, QrCode.Ecc.Medium, QrCode.Ecc.Quartile, QrCode.Ecc.High };

        /// <summary>
        /// Generates QR code as PNG image
        /// </summary>
        /// <param name="text">Text to encode in QR code</param>
        /// <param name="ecc">Error correction level (0: low ... 3: high)</param>
        /// <param name="borderWidth">Border width in multiples of a module (QR code pixel)</param>
        /// <returns>PNG image</returns>
        [HttpGet("qrcode/png")]
        [ResponseCache(Duration = 2592000)]
        public ActionResult<byte[]> GeneratePng([FromQuery(Name = "text")] string text,
            [FromQuery(Name = "ecc")] int? ecc, [FromQuery(Name = "border")] int? borderWidth)
        {
            ecc = Math.Clamp(ecc ?? 1, 0, 3);
            borderWidth = Math.Clamp(borderWidth ?? 3, 0, 999999);

            var qrCode = QrCode.EncodeText(text, errorCorrectionLevels[(int)ecc]);
            byte[] png = qrCode.ToPng(20, (int)borderWidth);
            return new FileContentResult(png, "image/png");
        }

        /// <summary>
        /// Generates QR code as SVG image
        /// </summary>
        /// <param name="text">Text to encode in QR code</param>
        /// <param name="ecc">Error correction level (0: low ... 3: high)</param>
        /// <param name="borderWidth">Border width in multiples of a module (QR code pixel)</param>
        /// <returns>SVG image</returns>
        [HttpGet("qrcode/svg")]
        [ResponseCache(Duration = 2592000)]
        public ActionResult<byte[]> GenerateSvg([FromQuery(Name = "text")] string text,
            [FromQuery(Name = "ecc")] int? ecc, [FromQuery(Name = "border")] int? borderWidth)
        {
            ecc = Math.Clamp(ecc ?? 1, 0, 3);
            borderWidth = Math.Clamp(borderWidth ?? 3, 0, 999999);

            var qrCode = QrCode.EncodeText(text, errorCorrectionLevels[(int)ecc]);
            byte[] svg = Encoding.UTF8.GetBytes(qrCode.ToSvgString((int)borderWidth));
            return new FileContentResult(svg, "image/svg+xml; charset=utf-8");
        }
    }
}


================================================
FILE: Demo-ASP.NET-Core/README.md
================================================
# Sample code for ASP.NET Core

This example program shows how to create a QR codes in an ASP.NET core application.

The [`QrCodeController`](QrCodeController.cs) class receives the QR code text, border width and error correction level as query parameters and generates the QR code, either as an SVG or PNG.

For  PNG generation, the [SkiaSharp](https://github.com/mono/SkiaSharp) rasterization library is used.


================================================
FILE: Demo-ASP.NET-Core/Startup.cs
================================================
//
// QR code generator library (.NET)
// https://github.com/manuelbl/QrCodeGenerator
//
// Copyright (c) 2021 Manuel Bleichenbacher
// Licensed under MIT License
// https://opensource.org/licenses/MIT
//

using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Rewrite;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

namespace Net.Codecrete.QrCodeGenerator.Demo
{
    public class Startup
    {
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();
        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            var rewriter = new RewriteOptions();
            rewriter.AddRewrite("^$", "home.html", skipRemainingRules: false);
            app.UseRewriter(rewriter);

            app.UseStaticFiles();

            app.UseRouting();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }
    }
}


================================================
FILE: Demo-ASP.NET-Core/appsettings.Development.json
================================================
{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information"
    }
  }
}


================================================
FILE: Demo-ASP.NET-Core/appsettings.json
================================================
{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information"
    }
  },
  "AllowedHosts": "*"
}


================================================
FILE: Demo-ASP.NET-Core/wwwroot/home.html
================================================
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>QR Code</title>
    <link rel="stylesheet" href="https://unpkg.com/purecss@2.0.6/build/pure-min.css" integrity="sha384-Uu6IeWbM+gzNVXJcM9XV3SohHtmWE+3VGi496jvgX1jyvDTXfdK+rfZc8C1Aehk5" crossorigin="anonymous">
    <link rel="stylesheet" href="https://unpkg.com/purecss@2.0.6/build/grids-responsive-min.css">
    <link rel="stylesheet" href="styles.css">
    <meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
    <div class="content">
        <div class="pure-g">
            <h1>QR Code</h1>
            <form class="pure-form">
                <fieldset>
                    <div class="pure-u-1"><img id="qrcode" src="qrcode/svg?text=Hello%20world!&ecc=1&border=3" /></div>
                    <div class="pure-u-1 more-space"><input id="text" type="text" placeholder="QR code text" value="Hello world!" /></div>
                    <div class="pure-u-1 pure-u-lg-1-2 more-space">
                        <label for="ecc">
                            Error correction:
                            <select id="ecc">
                                <option value="0">Low</option>
                                <option value="1" selected>Medium</option>
                                <option value="2">Quartile</option>
                                <option value="3">High</option>
                            </select>

                        </label>
                    </div>
                    <div class="pure-u-1 pure-u-lg-1-2 more-space">
                        <label for="border">
                            Border width: <input type="number" id="border" value="3" min="0" max="99999" />
                        </label>
                    </div>
                </fieldset>
            </form>
        </div>
    </div>

    <script src="ui.js"></script>
</body>
</html>

================================================
FILE: Demo-ASP.NET-Core/wwwroot/styles.css
================================================
.content {
    max-width: 768px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 1em;
    padding-right: 1em;
    background: #eee;
}
#qrcode {
    width: 80%;
    max-width: 400px;
    margin-top: 1em;
    margin-bottom: 2em;
    margin-left: auto;
    margin-right: auto;
    display: block;
}
#text {
    width: 90%;
}
.more-space {
    margin-top: 0.5em;
    margin-bottom: 0.5em;
}
h1 {
    letter-spacing: 0;
    text-align: center;
    width: 100%;
}

================================================
FILE: Demo-ASP.NET-Core/wwwroot/ui.js
================================================
(function () {
    var qrCodeImage;
    var textField;
    var borderField;
    var eccSelect;

    function updateQrCode() {
        var url = new URL('qrcode/svg', document.baseURI);
        url.searchParams.append('text', textField.value);
        url.searchParams.append('ecc', eccSelect.value);
        url.searchParams.append('border', borderField.value);
        qrCodeImage.src = url;
    }

    function init() {
        textField = document.getElementById('text');
        qrCodeImage = document.getElementById('qrcode');
        borderField = document.getElementById('border');
        eccSelect = document.getElementById('ecc');

        textField.onchange = function () { updateQrCode(); }
        textField.oninput = function () { updateQrCode(); }
        borderField.onchange = function () { updateQrCode(); }
        borderField.oninput = function () { updateQrCode(); }
        eccSelect.onchange = function () { updateQrCode(); }
    }

    init();
})();


================================================
FILE: Demo-ImageMagick/Demo-ImageMagick.csproj
================================================
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net8.0</TargetFramework>
    <RootNamespace>Net.Codecrete.QrCodeGenerator.Demo</RootNamespace>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Magick.NET-Q16-AnyCPU" Version="14.10.4" />
    <PackageReference Include="Net.Codecrete.QrCodeGenerator" Version="2.1.0" />
  </ItemGroup>

</Project>


================================================
FILE: Demo-ImageMagick/Demo-ImageMagick.sln
================================================

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.2.32630.192
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demo-ImageMagick", "Demo-ImageMagick.csproj", "{E4F86D1E-F08C-4BFE-BC37-9BED8A411E88}"
EndProject
Global
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
		Debug|Any CPU = Debug|Any CPU
		Release|Any CPU = Release|Any CPU
	EndGlobalSection
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
		{E4F86D1E-F08C-4BFE-BC37-9BED8A411E88}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{E4F86D1E-F08C-4BFE-BC37-9BED8A411E88}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{E4F86D1E-F08C-4BFE-BC37-9BED8A411E88}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{E4F86D1E-F08C-4BFE-BC37-9BED8A411E88}.Release|Any CPU.Build.0 = Release|Any CPU
	EndGlobalSection
	GlobalSection(SolutionProperties) = preSolution
		HideSolutionNode = FALSE
	EndGlobalSection
	GlobalSection(ExtensibilityGlobals) = postSolution
		SolutionGuid = {BC2EF2FB-30F7-431B-B92C-05E9C7B7B07B}
	EndGlobalSection
EndGlobal


================================================
FILE: Demo-ImageMagick/Program.cs
================================================
//
// QR code generator library (.NET)
// https://github.com/manuelbl/QrCodeGenerator
//
// Copyright (c) 2022 suxiaobu9, Manuel Bleichenbacher
// Licensed under MIT License
// https://opensource.org/licenses/MIT
//

using ImageMagick;
using Net.Codecrete.QrCodeGenerator;

string text = "Hello, world!",
    fileName = "hello-world-QR.png";

var qr = QrCode.EncodeText(text, QrCode.Ecc.Medium);

qr.SaveAsPng(fileName, 10, 4, MagickColors.Black, MagickColors.White);


================================================
FILE: Demo-ImageMagick/QrCodeImageExtensions.cs
================================================
//
// QR code generator library (.NET)
// https://github.com/manuelbl/QrCodeGenerator
//
// Copyright (c) 2022 suxiaobu9, Manuel Bleichenbacher
// Licensed under MIT License
// https://opensource.org/licenses/MIT
//

using ImageMagick;
using ImageMagick.Drawing;

namespace Net.Codecrete.QrCodeGenerator;

public static class QrCodeImageExtensions
{
    /// <summary>
    /// Creates a 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>
    /// </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>
    /// <param name="background">The background color.</param>
    /// <param name="foreground">The foreground color.</param>
    /// <returns></returns>
    /// <exception cref="ArgumentOutOfRangeException"></exception>
    public static MagickImage ToImage(this QrCode qrCode, int scale, int border, MagickColor foreground, MagickColor background)
    {
        if (scale <= 0)
        {
            throw new ArgumentOutOfRangeException(nameof(scale), " Value out of range");
        }

        if (border < 0)
        {
            throw new ArgumentOutOfRangeException(nameof(border), " Value out of range");
        }

        var size = qrCode.Size;
        var dim = (uint)((size + border * 2) * scale);

        if (dim > short.MaxValue)
        {
            throw new ArgumentOutOfRangeException(nameof(scale), " Scale or border too large");
        }

        var image = new MagickImage(background, dim, dim)
        {
            Format = MagickFormat.Png,
        };

        var drawables = new Drawables();
        drawables.FillColor(foreground);

        for (var x = 0; x < size; x++)
        {
            var pointerX = (x + border) * scale;

            for (var y = 0; y < size; y++)
            {
                if (qrCode.GetModule(x, y))
                {
                    var pointerY = (y + border) * scale;
                    drawables.Rectangle(pointerX, pointerY, pointerX + scale - 1, pointerY + scale - 1);
                }
            }
        }
        drawables.Draw(image);
        return image;
    }

    /// <summary>
    /// Creates a PNG image of this QR code and returns it as a byte array.
    /// <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>ToPng(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>
    /// </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>
    /// <param name="foreground">The foreground color.</param>
    /// <param name="background">The background color.</param>
    /// <returns></returns>
    public static byte[] ToPng(this QrCode qrCode, int scale, int border, MagickColor foreground, MagickColor background)
    {
        using var image = qrCode.ToImage(scale, border, foreground, background);
        return image.ToByteArray();
    }

    /// <summary>
    /// Saves this QR code as a PNG file.
    /// <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>SaveAsPng("qrcode.png", 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>
    /// </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>
    /// <param name="foreground">The foreground color.</param>
    /// <param name="background">The background color.</param>
    public static void SaveAsPng(this QrCode qrCode, string fileName, int scale, int border, MagickColor foreground, MagickColor background)
    {
        using var image = qrCode.ToImage(scale, border, foreground, background);
        image.Write(fileName);
    }
}


================================================
FILE: Demo-ImageMagick/README.md
================================================
# Saving as PNG using Magick.NET

This example program shows how to create a QR code and save it as a PNG file using the [Magick.NET](https://github.com/dlemstra/Magick.NET) image manipulation library (based on ImageMagick).


================================================
FILE: Demo-ImageSharp/Demo-ImageSharp.csproj
================================================
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net8.0</TargetFramework>
    <RootNamespace>Net.Codecrete.QrCodeGenerator.Demo</RootNamespace>
    <PackageId>Net.Codecrete.QrCodeGenerator.Demo</PackageId>
    <Version>2.1.0</Version>
    <Authors>Manuel Bleichenbacher, Project Nayuki</Authors>
    <Product>QR Code Generator for .NET</Product>
    <Description>Demo application for QR Code Generation</Description>
    <Copyright>Copyright Manuel Bleichenbacher and Project Nayuki (MIT License)</Copyright>
    <PackageLicenseUrl>https://opensource.org/licenses/MIT</PackageLicenseUrl>
    <PackageProjectUrl>https://github.com/manuelbl/QrCodeGenerator</PackageProjectUrl>
    <RepositoryUrl>https://github.com/manuelbl/QrCodeGenerator</RepositoryUrl>
    <Company>Codecrete</Company>
  </PropertyGroup>

  <ItemGroup>
    <None Remove="heart.png" />
  </ItemGroup>

  <ItemGroup>
    <Content Include="heart.png">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="Net.Codecrete.QrCodeGenerator" Version="2.*" />
    <PackageReference Include="SixLabors.ImageSharp.Drawing" Version="2.1.7" />
  </ItemGroup>

</Project>


================================================
FILE: Demo-ImageSharp/Demo-ImageSharp.sln
================================================

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30611.23
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Demo-ImageSharp", "Demo-ImageSharp.csproj", "{BBB1A4A6-D82E-4233-8FC9-9300F9576FD2}"
EndProject
Global
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
		Debug|Any CPU = Debug|Any CPU
		Release|Any CPU = Release|Any CPU
	EndGlobalSection
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
		{BBB1A4A6-D82E-4233-8FC9-9300F9576FD2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{BBB1A4A6-D82E-4233-8FC9-9300F9576FD2}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{BBB1A4A6-D82E-4233-8FC9-9300F9576FD2}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{BBB1A4A6-D82E-4233-8FC9-9300F9576FD2}.Release|Any CPU.Build.0 = Release|Any CPU
	EndGlobalSection
	GlobalSection(SolutionProperties) = preSolution
		HideSolutionNode = FALSE
	EndGlobalSection
	GlobalSection(ExtensibilityGlobals) = postSolution
		SolutionGuid = {94BC47F9-3AE8-471A-AC3F-CDEFA1B21089}
	EndGlobalSection
EndGlobal


================================================
FILE: Demo-ImageSharp/Program.cs
================================================
//
// QR code generator library (.NET)
// https://github.com/manuelbl/QrCodeGenerator
//
// Copyright (c) 2021 Manuel Bleichenbacher
// Licensed under MIT License
// https://opensource.org/licenses/MIT
//

using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Processing;
using System;
using System.IO;

namespace Net.Codecrete.QrCodeGenerator.Demo
{
    internal class Program
    {
        // Create a QR code and save it as a PNG.
        internal static void Main()
        {
            HelloWorld();
            QrCodeWithImage();
        }


        internal static void HelloWorld()
        {
            var text = "Hello, world!";
            var filename = "hello-world-QR.png";

            var qr = QrCode.EncodeText(text, QrCode.Ecc.Medium); // Create the QR code symbol
            qr.SaveAsPng(filename, scale: 10, border: 4);

            Console.WriteLine($"The QR code has been saved as {Path.GetFullPath(filename)}");
        }

        internal static void QrCodeWithImage()
        {
            var text = "https://github.com/manuelbl/QrCodeGenerator";
            var filename = "qr-code-with-image.png";
            var logoFilename = "heart.png";
            const float logoWidth = 0.15f; // logo will have 15% the width of the QR code 

            var qr = QrCode.EncodeText(text, QrCode.Ecc.Medium);

            using (var bitmap = qr.ToBitmap(scale: 10, border: 4))
            using (var logo = Image.Load(logoFilename))
            {
                // resize logo
                var w = (int)Math.Round(bitmap.Width * logoWidth);
                logo.Mutate(logo => logo.Resize(w, 0));

                // draw logo in center
                var topLeft = new Point((bitmap.Width - logo.Width) / 2, (bitmap.Height - logo.Height) / 2);
                bitmap.Mutate(img => img.DrawImage(logo, topLeft, 1));

                // save as PNG
                bitmap.SaveAsPng(filename);
            }

            Console.WriteLine($"The QR code has been saved as {Path.GetFullPath(filename)}");
        }
    }
}


================================================
FILE: Demo-ImageSharp/QrCodeBitmapExtensions.cs
================================================
//
// QR code generator library (.NET)
// https://github.com/manuelbl/QrCodeGenerator
//
// Copyright (c) 2021 Manuel Bleichenbacher
// Licensed under MIT License
// https://opensource.org/licenses/MIT
//

using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Drawing.Processing;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using System;
using System.IO;

namespace Net.Codecrete.QrCodeGenerator
{
    public static class QrCodeBitmapExtensions
    {
        /// <inheritdoc cref="ToBitmap(QrCode, int, int)"/>
        /// <param name="background">The background color.</param>
        /// <param name="foreground">The foreground color.</param>
        public static Image ToBitmap(this QrCode qrCode, int scale, int border, Color foreground, Color background)
        {
            // check arguments
            if (scale <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(scale), "Value out of range");
            }
            if (border < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(border), "Value out of range");
            }

            int size = qrCode.Size;
            int dim = (size + border * 2) * scale;

            if (dim > short.MaxValue)
            {
                throw new ArgumentOutOfRangeException(nameof(scale), "Scale or border too large");
            }

            // create bitmap
            var image = new Image<Rgb24>(dim, dim);

            image.Mutate(img =>
            {
                // draw background
                img.Fill(background);

                // draw modules
                for (int y = 0; y < size; y++)
                {
                    for (int x = 0; x < size; x++)
                    {
                        if (qrCode.GetModule(x, y))
                        {
                            img.Fill(foreground, new Rectangle((x + border) * scale, (y + border) * scale, scale, scale));
                        }
                    }
                }
            });

            return image;
        }

        /// <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="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 var image = qrCode.ToBitmap(scale, border, foreground, background);
            using var ms = new MemoryStream();
            image.SaveAsPng(ms);
            return ms.ToArray();
        }

        /// <summary>
        /// Creates a PNG image of this QR code and returns it as a byte array.
        /// <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>ToPng(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>
        /// 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 byte[] ToPng(this QrCode qrCode, int scale, int border)
        {
            return qrCode.ToPng(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>
        /// Saves this QR code as a PNG file.
        /// <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>SaveAsPng("qrcode.png", 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>
        /// 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>
        /// <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 void SaveAsPng(this QrCode qrCode, string filename, int scale, int border)
        {
            qrCode.SaveAsPng(filename, scale, border, Color.Black, Color.White);
        }
    }
}


================================================
FILE: Demo-ImageSharp/README.md
================================================
# Saving as PNG using ImageSharp

This example program shows how to create a QR code and save it as a PNG file using the [ImageSharp](https://github.com/SixLabors/ImageSharp) rasterization library.

Additionally, it demonstrates how to add an image in the center of the QR code.

The use of ImageSharp is recommended if the project already uses ImageSharp.


================================================
FILE: Demo-QRCode-Variety/Demo-QRCode-Variety.csproj
================================================
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net8.0</TargetFramework>
    <RootNamespace>Demo_Basic</RootNamespace>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Net.Codecrete.QrCodeGenerator" Version="2.*" />
  </ItemGroup>

</Project>


================================================
FILE: Demo-QRCode-Variety/Demo-QRCode-Variety.sln
================================================

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demo-QRCode-Variety", "Demo-QRCode-Variety.csproj", "{CE334406-7A4A-4455-889B-200DEBB6C08C}"
EndProject
Global
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
		Debug|Any CPU = Debug|Any CPU
		Release|Any CPU = Release|Any CPU
	EndGlobalSection
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
		{CE334406-7A4A-4455-889B-200DEBB6C08C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{CE334406-7A4A-4455-889B-200DEBB6C08C}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{CE334406-7A4A-4455-889B-200DEBB6C08C}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{CE334406-7A4A-4455-889B-200DEBB6C08C}.Release|Any CPU.Build.0 = Release|Any CPU
	EndGlobalSection
	GlobalSection(SolutionProperties) = preSolution
		HideSolutionNode = FALSE
	EndGlobalSection
	GlobalSection(ExtensibilityGlobals) = postSolution
		SolutionGuid = {BB8EAC9D-6D83-4A9C-A867-300B9DD2B793}
	EndGlobalSection
EndGlobal


================================================
FILE: Demo-QRCode-Variety/Program.cs
================================================
/* 
 * QR code generator library (.NET)
 *
 * Copyright (c) Manuel Bleichenbacher (MIT License)
 * https://github.com/manuelbl/QrCodeGenerator
 * Copyright (c) Project Nayuki (MIT License)
 * https://www.nayuki.io/page/qr-code-generator-library
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 * IN THE SOFTWARE.
 */

using System.Collections.Generic;
using System.IO;
using System.Text;

namespace Net.Codecrete.QrCodeGenerator.Demo
{
    internal class Program
    {
        // The main application program.
        internal static void Main()
        {
            DoBasicDemo();
            DoVarietyDemo();
            DoSegmentDemo();
            DoMaskDemo();
            DoBinaryDemo();
        }

        #region Demo suite

        // Creates a single QR code, then writes it to an SVG file.
        private static void DoBasicDemo()
        {
            const string text = "Hello, world!"; // User-supplied Unicode text
            var errCorLvl = QrCode.Ecc.Low; // Error correction level

            var qr = QrCode.EncodeText(text, errCorLvl); // Make the QR code symbol
            SaveAsSvg(qr, "hello-world-QR.svg", border: 4); // Save as SVG
        }


        // Creates a variety of QR codes that exercise different features of the library, and writes each one to file.
        private static void DoVarietyDemo()
        {
            // Numeric mode encoding (3.33 bits per digit)
            var qr = QrCode.EncodeText("314159265358979323846264338327950288419716939937510", QrCode.Ecc.Medium);
            SaveAsSvg(qr, "pi-digits-QR.svg");

            // Alphanumeric mode encoding (5.5 bits per character)
            qr = QrCode.EncodeText("DOLLAR-AMOUNT:$39.87 PERCENTAGE:100.00% OPERATIONS:+-*/", QrCode.Ecc.High);
            SaveAsSvg(qr, "alphanumeric-QR.svg", 2);

            // Unicode text as UTF-8
            qr = QrCode.EncodeText("こんにちwa、世界! αβγδ", QrCode.Ecc.Quartile);
            SaveAsSvg(qr, "unicode-QR.svg", 3);

            // Moderately large QR code using longer text (from Lewis Carroll's Alice in Wonderland)
            qr = QrCode.EncodeText(
                "Alice was beginning to get very tired of sitting by her sister on the bank, "
                + "and of having nothing to do: once or twice she had peeped into the book her sister was reading, "
                + "but it had no pictures or conversations in it, 'and what is the use of a book,' thought Alice "
                + "'without pictures or conversations?' So she was considering in her own mind (as well as she could, "
                + "for the hot day made her feel very sleepy and stupid), whether the pleasure of making a "
                + "daisy-chain would be worth the trouble of getting up and picking the daisies, when suddenly "
                + "a White Rabbit with pink eyes ran close by her.", QrCode.Ecc.High);
            SaveAsSvg(qr, "alice-wonderland-QR.svg", 10);
        }


        // Creates QR codes with manually specified segments for better compactness.
        private static void DoSegmentDemo()
        {
            // Illustration "silver"
            const string silver0 = "THE SQUARE ROOT OF 2 IS 1.";
            const string silver1 = "41421356237309504880168872420969807856967187537694807317667973799";
            var qr = QrCode.EncodeText(silver0 + silver1, QrCode.Ecc.Low);
            SaveAsSvg(qr, "sqrt2-monolithic-QR.svg", 3);

            var segs = new List<QrSegment>
            {
                QrSegment.MakeAlphanumeric(silver0),
                QrSegment.MakeNumeric(silver1)
            };
            qr = QrCode.EncodeSegments(segs, QrCode.Ecc.Low);
            SaveAsSvg(qr, "sqrt2-segmented-QR.svg", 3);

            // Illustration "golden"
            const string golden0 = "Golden ratio φ = 1.";
            const string golden1 =
                "6180339887498948482045868343656381177203091798057628621354486227052604628189024497072072041893911374";
            const string golden2 = "......";
            qr = QrCode.EncodeText(golden0 + golden1 + golden2, QrCode.Ecc.Low);
            SaveAsSvg(qr, "phi-monolithic-QR.svg", 5);

            segs = new List<QrSegment>
            {
                QrSegment.MakeBytes(Encoding.UTF8.GetBytes(golden0)),
                QrSegment.MakeNumeric(golden1),
                QrSegment.MakeAlphanumeric(golden2)
            };

            qr = QrCode.EncodeSegments(segs, QrCode.Ecc.Low);
            SaveAsSvg(qr, "phi-segmented-QR.svg", 5);

            // Illustration "Madoka": kanji, kana, Cyrillic, full-width Latin, Greek characters
            const string madoka = "「魔法少女まどか☆マギカ」って、 ИАИ desu κα?";
            qr = QrCode.EncodeText(madoka, QrCode.Ecc.Low);
            SaveAsSvg(qr, "madoka-utf8-QR.svg", 4);

            segs = new List<QrSegment> { QrSegmentAdvanced.MakeKanji(madoka) };
            qr = QrCode.EncodeSegments(segs, QrCode.Ecc.Low);
            SaveAsSvg(qr, "madoka-kanji-QR.svg", 4);
        }


        // Creates QR codes with the same size and contents but different mask patterns.
        private static void DoMaskDemo()
        {
            // Project Nayuki URL
            var segs = QrSegment.MakeSegments("https://www.nayuki.io/");
            var qr = QrCode.EncodeSegments(segs, QrCode.Ecc.High);
            SaveAsSvg(qr, "project-nayuki-automask-QR.svg", 6);
            qr = QrCode.EncodeSegments(segs, QrCode.Ecc.High, QrCode.MinVersion, QrCode.MaxVersion, 3);  // Force mask 3
            SaveAsSvg(qr, "project-nayuki-mask3-QR.svg", 6);

            // Chinese text as UTF-8
            segs = QrSegment.MakeSegments("維基百科(Wikipedia,聆聽i/ˌwɪkᵻˈpiːdi.ə/)是一個自由內容、公開編輯且多語言的網路百科全書協作計畫");
            qr = QrCode.EncodeSegments(segs, QrCode.Ecc.Medium, QrCode.MinVersion, QrCode.MaxVersion, 0);  // Force mask 0
            SaveAsSvg(qr, "unicode-mask0-QR.svg");
            qr = QrCode.EncodeSegments(segs, QrCode.Ecc.Medium, QrCode.MinVersion, QrCode.MaxVersion, 1);  // Force mask 1
            SaveAsSvg(qr, "unicode-mask1-QR.svg");
            qr = QrCode.EncodeSegments(segs, QrCode.Ecc.Medium, QrCode.MinVersion, QrCode.MaxVersion, 5);  // Force mask 5
            SaveAsSvg(qr, "unicode-mask5-QR.svg");
            qr = QrCode.EncodeSegments(segs, QrCode.Ecc.Medium, QrCode.MinVersion, QrCode.MaxVersion, 7);  // Force mask 7
            SaveAsSvg(qr, "unicode-mask7-QR.svg");
        }

        private static void DoBinaryDemo()
        {
            // create binary data
            byte[] data = {
                0x47, 0x49, 0x46, 0x38, 0x39, 0x61, 0x01, 0x00,
                0x01, 0x00, 0x80, 0x01, 0x00, 0xff, 0xff, 0xff,
                0x00, 0x00, 0x00, 0x21, 0xf9, 0x04, 0x01, 0x0a,
                0x00, 0x01, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x00,
                0x01, 0x00, 0x01, 0x00, 0x00, 0x02, 0x02, 0x4c,
                0x01, 0x00, 0x3b
            };
            var qr = QrCode.EncodeBinary(data, QrCode.Ecc.Medium);
            SaveAsSvg(qr, "binary.svg");
        }

        #endregion

        private static void SaveAsSvg(QrCode qrCode, string filname, int border = 3)
        {
            string svg = qrCode.ToSvgString(border); // Convert to SVG XML code
            File.WriteAllText(filname, svg, Encoding.UTF8); // Write image to file
        }

    }
}


================================================
FILE: Demo-QRCode-Variety/README.md
================================================
# Demonstration of various QR code

This example program creates a series of QR code and saves them as SVG files.

Aside from a simple standard case, the examples demonstrates the use of:

- different encodings (numeric, alpha-numeric, Unicode)
- different error correction levels
- using multiple segments
- using different masks
- encoding binary data


================================================
FILE: Demo-SkiaSharp/Demo-SkiaSharp.csproj
================================================
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net8.0</TargetFramework>
    <RootNamespace>Net.Codecrete.QrCodeGenerator.Demo</RootNamespace>
    <PackageId>Net.Codecrete.QrCodeGenerator.Demo</PackageId>
    <Version>2.1.0</Version>
    <Authors>Manuel Bleichenbacher, Project Nayuki</Authors>
    <Product>QR Code Generator for .NET</Product>
    <Description>Demo application for QR Code Generation</Description>
    <Copyright>Copyright Manuel Bleichenbacher and Project Nayuki (MIT License)</Copyright>
    <PackageLicenseUrl>https://opensource.org/licenses/MIT</PackageLicenseUrl>
    <PackageProjectUrl>https://github.com/manuelbl/QrCodeGenerator</PackageProjectUrl>
    <RepositoryUrl>https://github.com/manuelbl/QrCodeGenerator</RepositoryUrl>
    <Company>Codecrete</Company>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Net.Codecrete.QrCodeGenerator" Version="2.*" />
    <PackageReference Include="SkiaSharp" Version="2.*" />
    <PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="2.*" />
  </ItemGroup>

</Project>


================================================
FILE: Demo-SkiaSharp/Demo-SkiaSharp.sln
================================================

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30611.23
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Demo-SkiaSharp", "Demo-SkiaSharp.csproj", "{BBB1A4A6-D82E-4233-8FC9-9300F9576FD2}"
EndProject
Global
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
		Debug|Any CPU = Debug|Any CPU
		Release|Any CPU = Release|Any CPU
	EndGlobalSection
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
		{BBB1A4A6-D82E-4233-8FC9-9300F9576FD2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{BBB1A4A6-D82E-4233-8FC9-9300F9576FD2}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{BBB1A4A6-D82E-4233-8FC9-9300F9576FD2}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{BBB1A4A6-D82E-4233-8FC9-9300F9576FD2}.Release|Any CPU.Build.0 = Release|Any CPU
	EndGlobalSection
	GlobalSection(SolutionProperties) = preSolution
		HideSolutionNode = FALSE
	EndGlobalSection
	GlobalSection(ExtensibilityGlobals) = postSolution
		SolutionGuid = {94BC47F9-3AE8-471A-AC3F-CDEFA1B21089}
	EndGlobalSection
EndGlobal


================================================
FILE: Demo-SkiaSharp/Program.cs
================================================
//
// QR code generator library (.NET)
// https://github.com/manuelbl/QrCodeGenerator
//
// Copyright (c) 2021 Manuel Bleichenbacher
// Licensed under MIT License
// https://opensource.org/licenses/MIT
//

using System;
using System.IO;

namespace Net.Codecrete.QrCodeGenerator.Demo
{
    internal class Program
    {
        // Create a QR code and save it as a PNG.
        internal static void Main()
        {
            var text = "Hello, world!";
            var filename = "hello-world-QR.png";

            var qr = QrCode.EncodeText(text, QrCode.Ecc.Medium); // Create the QR code symbol
            qr.SaveAsPng(filename, scale: 10, border: 4);

            Console.WriteLine($"The QR code has been saved as {Path.GetFullPath(filename)}");
        }
    }
}


================================================
FILE: Demo-SkiaSharp/QrCodeBitmapExtensions.cs
================================================
//
// QR code generator library (.NET)
// https://github.com/manuelbl/QrCodeGenerator
//
// Copyright (c) 2021 Manuel Bleichenbacher
// Licensed under MIT License
// https://opensource.org/licenses/MIT
//

using SkiaSharp;
using System;
using System.IO;

namespace Net.Codecrete.QrCodeGenerator
{
    public static class QrCodeBitmapExtensions
    {
        /// <inheritdoc cref="ToBitmap(QrCode, int, int)"/>
        /// <param name="background">The background color.</param>
        /// <param name="foreground">The foreground color.</param>
        public static SKBitmap ToBitmap(this QrCode qrCode, int scale, int border, SKColor foreground, SKColor background)
        {
            // check arguments
            if (scale <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(scale), "Value out of range");
            }
            if (border < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(border), "Value out of range");
            }

            int size = qrCode.Size;
            int dim = (size + border * 2) * scale;

            if (dim > short.MaxValue)
            {
                throw new ArgumentOutOfRangeException(nameof(scale), "Scale or border too large");
            }

            // create bitmap
            SKBitmap bitmap = new SKBitmap(dim, dim, SKColorType.Rgb888x, SKAlphaType.Opaque);

            using (SKCanvas canvas = new SKCanvas(bitmap))
            {
                // draw background
                using (SKPaint paint = new SKPaint { Color = background })
                {
                    canvas.DrawRect(0, 0, dim, dim, paint);
                }

                // draw modules
                using (SKPaint paint = new SKPaint { Color = foreground })
                {
                    for (int y = 0; y < size; y++)
                    {
                        for (int x = 0; x < size; x++)
                        {
                            if (qrCode.GetModule(x, y))
                            {
                                canvas.DrawRect((x + border) * scale, (y + border) * scale, scale, scale, paint);
                            }
                        }
                    }
                }
            }

            return bitmap;
        }

        /// <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();
        }

        /// <summary>
        /// Creates a PNG image of this QR code and returns it as a byte array.
        /// <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>ToPng(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>
        /// 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 byte[] ToPng(this QrCode qrCode, int scale, int border)
        {
            return qrCode.ToPng(scale, border, SKColors.Black, SKColors.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, 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);
        }

        /// <summary>
        /// Saves this QR code as a PNG file.
        /// <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>SaveAsPng("qrcode.png", 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>
        /// 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>
        /// <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 void SaveAsPng(this QrCode qrCode, string filename, int scale, int border)
        {
            qrCode.SaveAsPng(filename, scale, border, SKColors.Black, SKColors.White);
        }
    }
}


================================================
FILE: Demo-SkiaSharp/README.md
================================================
# Saving as PNG using SkiaSharp

This example program shows how to create a QR code and save it as a PNG file using the [SkiaSharp](https://github.com/mono/SkiaSharp) rasterization library.

The use of SkiaSharp is recommended for multi-platform and all non-Windows projects.


================================================
FILE: Demo-System-Drawing/Demo-System-Drawing.csproj
================================================
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net8.0</TargetFramework>
    <RootNamespace>Net.Codecrete.QrCodeGenerator.Demo</RootNamespace>
    <PackageId>Net.Codecrete.QrCodeGenerator.Demo</PackageId>
    <Version>2.1.0</Version>
    <Authors>Manuel Bleichenbacher, Project Nayuki</Authors>
    <Product>QR Code Generator for .NET</Product>
    <Description>Demo application for QR Code Generation</Description>
    <Copyright>Copyright Manuel Bleichenbacher and Project Nayuki (MIT License)</Copyright>
    <PackageLicenseUrl>https://opensource.org/licenses/MIT</PackageLicenseUrl>
    <PackageProjectUrl>https://github.com/manuelbl/QrCodeGenerator</PackageProjectUrl>
    <RepositoryUrl>https://github.com/manuelbl/QrCodeGenerator</RepositoryUrl>
    <Company>Codecrete</Company>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Net.Codecrete.QrCodeGenerator" Version="2.*" />
    <PackageReference Include="System.Drawing.Common" Version="5.*" />
  </ItemGroup>

</Project>


================================================
FILE: Demo-System-Drawing/Demo-System-Drawing.sln
================================================

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30611.23
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Demo-System-Drawing", "Demo-System-Drawing.csproj", "{BBB1A4A6-D82E-4233-8FC9-9300F9576FD2}"
EndProject
Global
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
		Debug|Any CPU = Debug|Any CPU
		Release|Any CPU = Release|Any CPU
	EndGlobalSection
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
		{BBB1A4A6-D82E-4233-8FC9-9300F9576FD2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{BBB1A4A6-D82E-4233-8FC9-9300F9576FD2}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{BBB1A4A6-D82E-4233-8FC9-9300F9576FD2}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{BBB1A4A6-D82E-4233-8FC9-9300F9576FD2}.Release|Any CPU.Build.0 = Release|Any CPU
	EndGlobalSection
	GlobalSection(SolutionProperties) = preSolution
		HideSolutionNode = FALSE
	EndGlobalSection
	GlobalSection(ExtensibilityGlobals) = postSolution
		SolutionGuid = {94BC47F9-3AE8-471A-AC3F-CDEFA1B21089}
	EndGlobalSection
EndGlobal


================================================
FILE: Demo-System-Drawing/Program.cs
================================================
//
// QR code generator library (.NET)
// https://github.com/manuelbl/QrCodeGenerator
//
// Copyright (c) 2021 Manuel Bleichenbacher
// Licensed under MIT License
// https://opensource.org/licenses/MIT
//

using System;
using System.IO;

namespace Net.Codecrete.QrCodeGenerator.Demo
{
    internal class Program
    {
        // Create a QR code and save it as a PNG.
        internal static void Main()
        {
            var text = "Hello, world!";
            var filename = "hello-world-QR.png";

            var qr = QrCode.EncodeText(text, QrCode.Ecc.Medium); // Create the QR code symbol
            qr.SaveAsPng(filename, scale: 10, border: 4);

            Console.WriteLine($"The QR code has been saved as {Path.GetFullPath(filename)}");
        }
    }
}


================================================
FILE: Demo-System-Drawing/QrCodeBitmapExtensions.cs
================================================
//
// QR code generator library (.NET)
// https://github.com/manuelbl/QrCodeGenerator
//
// Copyright (c) 2021 Manuel Bleichenbacher
// Licensed under MIT License
// https://opensource.org/licenses/MIT
//

using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;

namespace Net.Codecrete.QrCodeGenerator
{
    /// <summary>
    /// <c>QrCode</c> extension for creating bitmaps using <c>System.Drawing</c> classes.
    /// <para>
    /// In .NET 6 and later versions, this extension will only work on Windows.
    /// </para>
    /// </summary>
    public static class QrCodeBitmapExtensions
    {
        /// <inheritdoc cref="ToBitmap(QrCode, int, int)"/>
        /// <param name="background">The background color.</param>
        /// <param name="foreground">The foreground color.</param>
        public static Bitmap ToBitmap(this QrCode qrCode, int scale, int border, Color foreground, Color background)
        {
            // check arguments
            if (scale <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(scale), "Value out of range");
            }
            if (border < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(border), "Value out of range");
            }

            int size = qrCode.Size;
            int dim = (size + border * 2) * scale;

            if (dim > short.MaxValue)
            {
                throw new ArgumentOutOfRangeException(nameof(scale), "Scale or border too large");
            }

            // create bitmap
            Bitmap bitmap = new Bitmap(dim, dim, PixelFormat.Format24bppRgb);

            using (Graphics g = Graphics.FromImage(bitmap))
            {
                Draw(qrCode, g, scale, border, foreground, background);
            }

            return bitmap;
        }

        /// <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 Bitmap ToBitmap(this QrCode qrCode, int scale, int border)
        {
            return qrCode.ToBitmap(scale, border, Color.Black, Color.White);
        }

        /// <summary>
        /// Draws this QR code into the specified graphics context.
        /// <para>
        /// The QR code is drawn at offset (0, 0). Use <see cref="Graphics.TranslateTransform(float, float)"/>
        /// to draw it at a different position.
        /// </para>
        /// <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>Draw(graphics, 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>
        /// </summary>
        /// <param name="graphics">The graphics context to draw in.</param>
        /// <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>
        public static void Draw(this QrCode qrCode, Graphics graphics, float scale, float border)
        {
            Draw(qrCode, graphics, scale, border, Color.Black, Color.White);
        }

        /// <inheritdoc cref="Draw(QrCode, Graphics, float, float)"/>
        /// <param name="background">The background color.</param>
        /// <param name="foreground">The foreground color.</param>
        public static void Draw(this QrCode qrCode, Graphics graphics, float scale, float border, Color foreground, Color background)
        {
            if (scale <= 0 || border < 0)
            {
                return;
            }

            int size = qrCode.Size;
            float dim = (size + border * 2) * scale;

            // draw background
            if (background != Color.Transparent)
            {
                using SolidBrush brush = new SolidBrush(background);
                graphics.FillRectangle(brush, 0, 0, dim, dim);
            }

            // draw modules
            using (SolidBrush brush = new SolidBrush(foreground))
            {
                for (int y = 0; y < size; y++)
                {
                    for (int x = 0; x < size; x++)
                    {
                        if (qrCode.GetModule(x, y))
                        {
                            graphics.FillRectangle(brush, (x + border) * scale, (y + border) * scale, scale, scale);
                        }
                    }
                }
            }
        }

        /// <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 PNG image of this QR code and returns it as a byte array.
        /// <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>ToPng(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>
        /// 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 byte[] ToPng(this QrCode qrCode, int scale, int border)
        {
            return qrCode.ToPng(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 Bitmap bitmap = qrCode.ToBitmap(scale, border, foreground, background);
            bitmap.Save(filename, ImageFormat.Png);
        }

        /// <summary>
        /// Saves this QR code as a PNG file.
        /// <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>SaveAsPng("qrcode.png", 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>
        /// 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>
        /// <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 void SaveAsPng(this QrCode qrCode, string filename, int scale, int border)
        {
            qrCode.SaveAsPng(filename, scale, border, Color.Black, Color.White);
        }
    }
}


================================================
FILE: Demo-System-Drawing/README.md
================================================
# Saving as PNG using System.Drawing

This example program shows how to create a QR code and save it as a PNG file using the *System.Drawing* classes.

With .NET 6 and later, *System.Drawing* has become a Windows only technology. While *System.Drawing* is available on macOS and Linux on earlier .NET version, its use is only recommended for Windows.


================================================
FILE: Demo-VCard/Program.cs
================================================
/* 
 * QR code generator library (.NET)
 *
 * Copyright (c) Manuel Bleichenbacher (MIT License)
 * https://github.com/manuelbl/QrCodeGenerator
 * 
 * Demo creating a QR code containing a vCard.
 *
 */
using MixERP.Net.VCards;
using MixERP.Net.VCards.Models;
using MixERP.Net.VCards.Serializer;
using MixERP.Net.VCards.Types;
using Net.Codecrete.QrCodeGenerator;
using System.Collections.Generic;
using System.IO;

namespace VCardDemo
{
    class Program
    {
        static void Main()
        {
            var vcard = new VCard
            {
                Version = VCardVersion.V3,
                FirstName = "Robin",
                LastName = "Hood",
                Organization = "Sherwood Inc.",
                Addresses = new List<Address>
                {
                    new Address {
                        Type = AddressType.Work,
                        Street = "The Major Oak",
                        Locality = "Sherwood Forest",
                        PostalCode = "NG21 9RN",
                        Country = "United Kingdom",
                    }
                },
                Telephones = new List<Telephone>
                {
                    new Telephone {
                        Type = TelephoneType.Work,
                        Number = "+441623677321"
                    }
                },
                Emails = new List<Email>
                {
                    new Email
                    {
                        Type = EmailType.Smtp,
                        EmailAddress = "robin.hood@sherwoodinc.co.uk"
                    }
                }
            };

            var qrCode = QrCode.EncodeText(vcard.Serialize(), QrCode.Ecc.Medium);
            File.WriteAllText("vcard-qrcode.svg", qrCode.ToSvgString(3));
        }
    }
}


================================================
FILE: Demo-VCard/VCardDemo.csproj
================================================
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net8.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="MixERP.Net.VCards" Version="1.0.7" />
    <PackageReference Include="Net.Codecrete.QrCodeGenerator" Version="2.*" />
  </ItemGroup>

</Project>


================================================
FILE: Demo-VCard/VCardDemo.sln
================================================

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31702.278
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VCardDemo", "VCardDemo.csproj", "{5DE9E10C-E608-4661-AAE9-ABCF46C0F2F5}"
EndProject
Global
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
		Debug|Any CPU = Debug|Any CPU
		Release|Any CPU = Release|Any CPU
	EndGlobalSection
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
		{5DE9E10C-E608-4661-AAE9-ABCF46C0F2F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{5DE9E10C-E608-4661-AAE9-ABCF46C0F2F5}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{5DE9E10C-E608-4661-AAE9-ABCF46C0F2F5}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{5DE9E10C-E608-4661-AAE9-ABCF46C0F2F5}.Release|Any CPU.Build.0 = Release|Any CPU
	EndGlobalSection
	GlobalSection(SolutionProperties) = preSolution
		HideSolutionNode = FALSE
	EndGlobalSection
	GlobalSection(ExtensibilityGlobals) = postSolution
		SolutionGuid = {7E8A810C-1062-422C-B511-9634C165EB47}
	EndGlobalSection
EndGlobal


================================================
FILE: Demo-WinForms/Demo-WinForms.csproj
================================================
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net8.0-windows</TargetFramework>
    <RootNamespace>Net.Codecrete.QrCodeGenerator.Demo</RootNamespace>
    <UseWindowsForms>True</UseWindowsForms>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Net.Codecrete.QrCodeGenerator" Version="2.*" />
  </ItemGroup>

</Project>

================================================
FILE: Demo-WinForms/Demo-WinForms.sln
================================================

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demo-WinForms", "Demo-WinForms.csproj", "{A3AD57D8-ED64-40DB-8EB1-F4E1B8EF18FD}"
EndProject
Global
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
		Debug|Any CPU = Debug|Any CPU
		Release|Any CPU = Release|Any CPU
	EndGlobalSection
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
		{A3AD57D8-ED64-40DB-8EB1-F4E1B8EF18FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{A3AD57D8-ED64-40DB-8EB1-F4E1B8EF18FD}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{A3AD57D8-ED64-40DB-8EB1-F4E1B8EF18FD}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{A3AD57D8-ED64-40DB-8EB1-F4E1B8EF18FD}.Release|Any CPU.Build.0 = Release|Any CPU
	EndGlobalSection
	GlobalSection(SolutionProperties) = preSolution
		HideSolutionNode = FALSE
	EndGlobalSection
	GlobalSection(ExtensibilityGlobals) = postSolution
		SolutionGuid = {0CCE4B82-DC41-4CAA-9643-0130009B5A28}
	EndGlobalSection
EndGlobal


================================================
FILE: Demo-WinForms/Form1.Designer.cs
================================================
//
// QR code generator library (.NET)
// https://github.com/manuelbl/QrCodeGenerator
//
// Copyright (c) 2021 Manuel Bleichenbacher
// Licensed under MIT License
// https://opensource.org/licenses/MIT
//

namespace Net.Codecrete.QrCodeGenerator.Demo
{
    partial class Form1
    {
        /// <summary>
        ///  Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        ///  Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        ///  Required method for Designer support - do not modify
        ///  the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.qrCodeControl = new Net.Codecrete.QrCodeGenerator.QrCodeControl();
            this.qrCodeText = new System.Windows.Forms.TextBox();
            this.label1 = new System.Windows.Forms.Label();
            this.errorCorrectionCombo = new System.Windows.Forms.ComboBox();
            this.label2 = new System.Windows.Forms.Label();
            this.copyButton = new System.Windows.Forms.Button();
            this.borderNumericUpDown = new System.Windows.Forms.NumericUpDown();
            ((System.ComponentModel.ISupportInitialize)(this.borderNumericUpDown)).BeginInit();
            this.SuspendLayout();
            // 
            // qrCodeControl
            // 
            this.qrCodeControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
            | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.qrCodeControl.BinaryData = null;
            this.qrCodeControl.BorderWidth = 3;
            this.qrCodeControl.ErrorCorrection = 2;
            this.qrCodeControl.Location = new System.Drawing.Point(32, 32);
            this.qrCodeControl.Name = "qrCodeControl";
            this.qrCodeControl.Size = new System.Drawing.Size(712, 344);
            this.qrCodeControl.TabIndex = 0;
            this.qrCodeControl.TextData = "Test";
            // 
            // qrCodeText
            // 
            this.qrCodeText.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.qrCodeText.Location = new System.Drawing.Point(32, 420);
            this.qrCodeText.Name = "qrCodeText";
            this.qrCodeText.Size = new System.Drawing.Size(712, 39);
            this.qrCodeText.TabIndex = 1;
            this.qrCodeText.Text = "QR code text";
            this.qrCodeText.TextChanged += new System.EventHandler(this.QrCodeText_TextChanged);
            // 
            // label1
            // 
            this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(32, 488);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(187, 32);
            this.label1.TabIndex = 2;
            this.label1.Text = "Error Correction:";
            // 
            // errorCorrectionCombo
            // 
            this.errorCorrectionCombo.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
            this.errorCorrectionCombo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this.errorCorrectionCombo.FormattingEnabled = true;
            this.errorCorrectionCombo.Items.AddRange(new object[] {
            "Low",
            "Medium",
            "Quartile",
            "High"});
            this.errorCorrectionCombo.Location = new System.Drawing.Point(225, 485);
            this.errorCorrectionCombo.Name = "errorCorrectionCombo";
            this.errorCorrectionCombo.Size = new System.Drawing.Size(186, 40);
            this.errorCorrectionCombo.TabIndex = 3;
            this.errorCorrectionCombo.SelectedIndexChanged += new System.EventHandler(this.ErrorCorrectionCombo_SelectedIndexChanged);
            // 
            // label2
            // 
            this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            this.label2.AutoSize = true;
            this.label2.Location = new System.Drawing.Point(496, 488);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(90, 32);
            this.label2.TabIndex = 4;
            this.label2.Text = "Border:";
            // 
            // copyButton
            // 
            this.copyButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            this.copyButton.Location = new System.Drawing.Point(498, 568);
            this.copyButton.Name = "copyButton";
            this.copyButton.Size = new System.Drawing.Size(246, 46);
            this.copyButton.TabIndex = 6;
            this.copyButton.Text = "Copy QR Code";
            this.copyButton.UseVisualStyleBackColor = true;
            this.copyButton.Click += new System.EventHandler(this.CopyButton_Click);
            // 
            // borderNumericUpDown
            // 
            this.borderNumericUpDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            this.borderNumericUpDown.Location = new System.Drawing.Point(592, 486);
            this.borderNumericUpDown.Name = "borderNumericUpDown";
            this.borderNumericUpDown.Size = new System.Drawing.Size(152, 39);
            this.borderNumericUpDown.TabIndex = 7;
            this.borderNumericUpDown.Value = new decimal(new int[] {
            3,
            0,
            0,
            0});
            this.borderNumericUpDown.ValueChanged += new System.EventHandler(this.BorderNumericUpDown_ValueChanged);
            // 
            // Form1
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(13F, 32F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(774, 649);
            this.Controls.Add(this.borderNumericUpDown);
            this.Controls.Add(this.copyButton);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.errorCorrectionCombo);
            this.Controls.Add(this.label1);
            this.Controls.Add(this.qrCodeText);
            this.Controls.Add(this.qrCodeControl);
            this.Name = "Form1";
            this.Text = "QR Code";
            ((System.ComponentModel.ISupportInitialize)(this.borderNumericUpDown)).EndInit();
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private QrCodeControl qrCodeControl;
        private System.Windows.Forms.TextBox qrCodeText;
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.ComboBox errorCorrectionCombo;
        private System.Windows.Forms.Label label2;
        private System.Windows.Forms.Button copyButton;
        private System.Windows.Forms.NumericUpDown borderNumericUpDown;
    }
}


================================================
FILE: Demo-WinForms/Form1.cs
================================================
//
// QR code generator library (.NET)
// https://github.com/manuelbl/QrCodeGenerator
//
// Copyright (c) 2021 Manuel Bleichenbacher
// Licensed under MIT License
// https://opensource.org/licenses/MIT
//

using System;
using System.Windows.Forms;

namespace Net.Codecrete.QrCodeGenerator.Demo
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

            errorCorrectionCombo.SelectedIndex = 1;

            qrCodeControl.TextData = qrCodeText.Text;
            qrCodeControl.ErrorCorrection = errorCorrectionCombo.SelectedIndex;
            qrCodeControl.BorderWidth = (int)borderNumericUpDown.Value;
        }

        private void QrCodeText_TextChanged(object sender, EventArgs e)
        {
            qrCodeControl.TextData = qrCodeText.Text;
        }

        private void ErrorCorrectionCombo_SelectedIndexChanged(object sender, EventArgs e)
        {
            qrCodeControl.ErrorCorrection = errorCorrectionCombo.SelectedIndex;
        }

        private void BorderNumericUpDown_ValueChanged(object sender, EventArgs e)
        {
            qrCodeControl.BorderWidth = (int)borderNumericUpDown.Value;
        }

        private void CopyButton_Click(object sender, EventArgs e)
        {
            qrCodeControl.CopyToClipboard();
        }
    }
}


================================================
FILE: Demo-WinForms/Form1.resx
================================================
<root>
  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
    <xsd:element name="root" msdata:IsDataSet="true">
      <xsd:complexType>
        <xsd:choice maxOccurs="unbounded">
          <xsd:element name="metadata">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" />
              </xsd:sequence>
              <xsd:attribute name="name" use="required" type="xsd:string" />
              <xsd:attribute name="type" type="xsd:string" />
              <xsd:attribute name="mimetype" type="xsd:string" />
              <xsd:attribute ref="xml:space" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="assembly">
            <xsd:complexType>
              <xsd:attribute name="alias" type="xsd:string" />
              <xsd:attribute name="name" type="xsd:string" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="data">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
              </xsd:sequence>
              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
              <xsd:attribute ref="xml:space" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="resheader">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
              </xsd:sequence>
              <xsd:attribute name="name" type="xsd:string" use="required" />
            </xsd:complexType>
          </xsd:element>
        </xsd:choice>
      </xsd:complexType>
    </xsd:element>
  </xsd:schema>
  <resheader name="resmimetype">
    <value>text/microsoft-resx</value>
  </resheader>
  <resheader name="version">
    <value>2.0</value>
  </resheader>
  <resheader name="reader">
    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
  </resheader>
  <resheader name="writer">
    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
  </resheader>
</root>

================================================
FILE: Demo-WinForms/Program.cs
================================================
//
// QR code generator library (.NET)
// https://github.com/manuelbl/QrCodeGenerator
//
// Copyright (c) 2021 Manuel Bleichenbacher
// Licensed under MIT License
// https://opensource.org/licenses/MIT
//

using System;
using System.Windows.Forms;

namespace Net.Codecrete.QrCodeGenerator.Demo
{
    internal static class Program
    {
        /// <summary>
        ///  The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.SetHighDpiMode(HighDpiMode.SystemAware);
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
    }
}


================================================
FILE: Demo-WinForms/QrCodeBitmapExtensions.cs
================================================
//
// QR code generator library (.NET)
// https://github.com/manuelbl/QrCodeGenerator
//
// Copyright (c) 2021 Manuel Bleichenbacher
// Licensed under MIT License
// https://opensource.org/licenses/MIT
//

using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;

namespace Net.Codecrete.QrCodeGenerator
{
    /// <summary>
    /// <c>QrCode</c> extension for creating bitmaps using <c>System.Drawing</c> classes.
    /// <para>
    /// In .NET 6 and later versions, this extension will only work on Windows.
    /// </para>
    /// </summary>
    public static class QrCodeBitmapExtensions
    {
        /// <inheritdoc cref="ToBitmap(QrCode, int, int)"/>
        /// <param name="background">The background color.</param>
        /// <param name="foreground">The foreground color.</param>
        public static Bitmap ToBitmap(this QrCode qrCode, int scale, int border, Color foreground, Color background)
        {
            // check arguments
            if (scale <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(scale), "Value out of range");
            }
            if (border < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(border), "Value out of range");
            }

            int size = qrCode.Size;
            int dim = (size + border * 2) * scale;

            if (dim > short.MaxValue)
            {
                throw new ArgumentOutOfRangeException(nameof(scale), "Scale or border too large");
            }

            // create bitmap
            Bitmap bitmap = new Bitmap(dim, dim, PixelFormat.Format24bppRgb);

            using (Graphics g = Graphics.FromImage(bitmap))
            {
                Draw(qrCode, g, scale, border, foreground, background);
            }

            return bitmap;
        }

        /// <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 Bitmap ToBitmap(this QrCode qrCode, int scale, int border)
        {
            return qrCode.ToBitmap(scale, border, Color.Black, Color.White);
        }

        /// <summary>
        /// Draws this QR code into the specified graphics context.
        /// <para>
        /// The QR code is drawn at offset (0, 0). Use <see cref="Graphics.TranslateTransform(float, float)"/>
        /// to draw it at a different position.
        /// </para>
        /// <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>Draw(graphics, 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>
        /// </summary>
        /// <param name="graphics">The graphics context to draw in.</param>
        /// <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>
        public static void Draw(this QrCode qrCode, Graphics graphics, float scale, float border)
        {
            Draw(qrCode, graphics, scale, border, Color.Black, Color.White);
        }

        /// <inheritdoc cref="Draw(QrCode, Graphics, float, float)"/>
        /// <param name="background">The background color.</param>
        /// <param name="foreground">The foreground color.</param>
        public static void Draw(this QrCode qrCode, Graphics graphics, float scale, float border, Color foreground, Color background)
        {
            if (scale <= 0 || border < 0)
            {
                return;
            }

            int size = qrCode.Size;
            float dim = (size + border * 2) * scale;

            // draw background
            if (background != Color.Transparent)
            {
                using SolidBrush brush = new SolidBrush(background);
                graphics.FillRectangle(brush, 0, 0, dim, dim);
            }

            // draw modules
            using (SolidBrush brush = new SolidBrush(foreground))
            {
                for (int y = 0; y < size; y++)
                {
                    for (int x = 0; x < size; x++)
                    {
                        if (qrCode.GetModule(x, y))
                        {
                            graphics.FillRectangle(brush, (x + border) * scale, (y + border) * scale, scale, scale);
                        }
                    }
                }
            }
        }

        /// <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 PNG image of this QR code and returns it as a byte array.
        /// <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>ToPng(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>
        /// 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 byte[] ToPng(this QrCode qrCode, int scale, int border)
        {
            return qrCode.ToPng(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 Bitmap bitmap = qrCode.ToBitmap(scale, border, foreground, background);
            bitmap.Save(filename, ImageFormat.Png);
        }

        /// <summary>
        /// Saves this QR code as a PNG file.
        /// <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>SaveAsPng("qrcode.png", 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>
        /// 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>
        /// <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 void SaveAsPng(this QrCode qrCode, string filename, int scale, int border)
        {
            qrCode.SaveAsPng(filename, scale, border, Color.Black, Color.White);
        }
    }
}


================================================
FILE: Demo-WinForms/QrCodeControl.cs
================================================
//
// QR code generator library (.NET)
// https://github.com/manuelbl/QrCodeGenerator
//
// Copyright (c) 2021 Manuel Bleichenbacher
// Licensed under MIT License
// https://opensource.org/licenses/MIT
//

using System;
using System.Drawing;
using System.Windows.Forms;

namespace Net.Codecrete.QrCodeGenerator
{
    /// <summary>
    /// Custom control for displaying a QR code
    /// </summary>
    public class QrCodeControl : Control
    {

        private string _textData;
        private byte[] _binaryData;
        private int _errorCorrection;
        private int _borderWidth;

        public QrCodeControl()
        {
            _textData = "Test";
            _errorCorrection = 2;
            _borderWidth = 3;
            ResizeRedraw = true;
        }

        public string TextData
        {
            get
            {
                if (_binaryData != null)
                {
                    return "binary data";
                }
                return _textData;
            }

            set
            {
                _textData = value;
                _binaryData = null;
                if (_textData == null)
                {
                    _textData = "";
                }
                Invalidate();
            }
        }

        public byte[] BinaryData
        {
            get { return _binaryData; }
            set
            {
                _binaryData = value;
                _textData = null;
                if (_binaryData == null)
                {
                    _binaryData = new byte[0];
                }
                Invalidate();
            }
        }

        public int ErrorCorrection
        {
            get { return _errorCorrection; }
            set
            {
                _errorCorrection = Math.Min(Math.Max(value, 0), 3);
                Invalidate();
            }
        }

        public int BorderWidth
        {
            get { return _borderWidth; }
            set
            {
                _borderWidth = Math.Max(value, 0);
                Invalidate();
            }
        }


        private static readonly QrCode.Ecc[] errorCorrectionLevels = { QrCode.Ecc.Low, QrCode.Ecc.Medium, QrCode.Ecc.Quartile, QrCode.Ecc.High };

        /// <summary>
        /// Creates the <c>QrCode</c> instance with the current settings.
        /// </summary>
        /// <returns></returns>
        private QrCode CreateQrCode()
        {
            QrCode qrCode;
            var ecc = errorCorrectionLevels[_errorCorrection];

            if (_binaryData != null)
            {
                qrCode = QrCode.EncodeBinary(_binaryData, ecc);
            }
            else
            {
                qrCode = QrCode.EncodeText(_textData, ecc);
            }

            return qrCode;
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            int size = Math.Min(Width, Height);
            var graphics = e.Graphics;

            var qrCode = CreateQrCode();
            graphics.TranslateTransform((Width - size) / 2, (Height - size) / 2);
            qrCode.Draw(graphics, scale: size / (float)(qrCode.Size + 2 * _borderWidth), border: _borderWidth,
                foreground: Color.Black, background: Color.White);
        }

        /// <summary>
        /// Copy the QR code to the clipboard.
        /// <para>
        /// The QR code is copied as a bitmap. It uses a scaling factor of 20 to
        /// prevent a blurry result from upscaling.
        /// </para>
        /// </summary>
        public void CopyToClipboard()
        {
            DataObject dataObject = new DataObject();
            var qrCode = CreateQrCode();
            dataObject.SetData(DataFormats.Bitmap, qrCode.ToBitmap(20, _borderWidth));
            Clipboard.SetDataObject(dataObject);
        }
    }
}

================================================
FILE: Demo-WinForms/README.md
================================================
# Windows Forms example application

This example application shows how to use the QR code library in a Windows Forms application:

- `QrCodeControl` is a custom control that can be used in any `Form`.
- The control also implements copying the QR code to the clipboard.

![Windows Forms QR Code](QrCodeWinForms.png)


================================================
FILE: Demo-WinUI/Demo-WinUI/App.xaml
================================================
<!-- Swiss QR Bill Generator for .NET -->
<!-- Copyright (c) 2022 Manuel Bleichenbacher -->
<!-- Licensed under MIT License -->
<!-- https://opensource.org/licenses/MIT -->

<Application
    x:Class="Net.Codecrete.QrCodeGenerator.Demo.App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Net.Codecrete.QrCodeGenerator.Demo">
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
                <!-- Other merged dictionaries here -->
            </ResourceDictionary.MergedDictionaries>
            <!-- Other app resources here -->
        </ResourceDictionary>
    </Application.Resources>
</Application>


================================================
FILE: Demo-WinUI/Demo-WinUI/App.xaml.cs
================================================
//
// Swiss QR Bill Generator for .NET
// Copyright (c) 2022 Manuel Bleichenbacher
// Licensed under MIT License
// https://opensource.org/licenses/MIT
//

using Microsoft.UI;
using Microsoft.UI.Windowing;
using Microsoft.UI.Xaml;
using System;
using System.Runtime.InteropServices;
using Windows.Graphics;
using WinRT.Interop;
using Windows.Win32;
using Windows.Win32.Foundation;

namespace Net.Codecrete.QrCodeGenerator.Demo;

/// <summary>
/// QR Code application.
/// </summary>
public partial class App : Application
{
    /// <summary>
    /// Initializes the singleton application object.  This is the first line of authored code
    /// executed, and as such is the logical equivalent of main() or WinMain().
    /// </summary>
    public App()
    {
        InitializeComponent();
    }

    /// <summary>
    /// Invoked when the application is launched.
    /// </summary>
    /// <param name="args">Details about the launch request and process.</param>
    protected override void OnLaunched(LaunchActivatedEventArgs args)
    {
        m_window = new MainWindow
        {
            Title = "QR Code"
        };

        // Set initial windows size.
        Resize(500, 600);

        m_window.Activate();
    }

    private Window m_window;

    private void Resize(int x, int y)
    {
        var scalingFactor = GetDpiScalingFactor();
        GetAppWindow().Resize(new SizeInt32((int)(x * scalingFactor), (int)(y * scalingFactor)));
    }

    private AppWindow GetAppWindow()
    {
        IntPtr hWnd = WindowNative.GetWindowHandle(m_window);
        WindowId wndId = Win32Interop.GetWindowIdFromWindow(hWnd);
        return AppWindow.GetFromWindowId(wndId);
    }

    private double GetDpiScalingFactor()
    {
        IntPtr hWnd = WindowNative.GetWindowHandle(m_window);
        var dpi = PInvoke.GetDpiForWindow((HWND)hWnd);
        return (float)dpi / 96;
    }
}


================================================
FILE: Demo-WinUI/Demo-WinUI/Demo-WinUI.csproj
================================================
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net8.0-windows10.0.19041.0</TargetFramework>
    <TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
    <RootNamespace>Net.Codecrete.QrCodeGenerator.Demo</RootNamespace>
    <ApplicationManifest>app.manifest</ApplicationManifest>
    <Platforms>x86;x64;ARM64</Platforms>
    <RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers>
    <PublishProfile>win-$(Platform).pubxml</PublishProfile>
    <UseWinUI>true</UseWinUI>
    <EnableMsixTooling>true</EnableMsixTooling>
    <AssemblyName>QrCodeWinUIDemo</AssemblyName>
    <GenerateAppInstallerFile>False</GenerateAppInstallerFile>
    <AppxAutoIncrementPackageRevision>True</AppxAutoIncrementPackageRevision>
    <AppxSymbolPackageEnabled>False</AppxSymbolPackageEnabled>
    <GenerateTestArtifacts>True</GenerateTestArtifacts>
    <AppxBundle>Never</AppxBundle>
    <HoursBetweenUpdateChecks>0</HoursBetweenUpdateChecks>
  </PropertyGroup>
  <ItemGroup>
    <None Remove="QrCodeControl.xaml" />
  </ItemGroup>

  <ItemGroup>
    <Content Include="Assets\SplashScreen.scale-200.png" />
    <Content Include="Assets\LockScreenLogo.scale-200.png" />
    <Content Include="Assets\Square150x150Logo.scale-200.png" />
    <Content Include="Assets\Square44x44Logo.scale-200.png" />
    <Content Include="Assets\Square44x44Logo.targetsize-24_altform-unplated.png" />
    <Content Include="Assets\StoreLogo.png" />
    <Content Include="Assets\Wide310x150Logo.scale-200.png" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="CommunityToolkit.Mvvm" Version="8.3.2" />
    <PackageReference Include="Microsoft.Graphics.Win2D" Version="1.3.0" />
    <PackageReference Include="Microsoft.Windows.CsWin32" Version="0.3.106">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <PackageReference Include="Microsoft.WindowsAppSDK" Version="1.6.241114003" />
    <PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.1742" />
    <PackageReference Include="Net.Codecrete.QrCodeGenerator" Version="2.1.0" />
    <Manifest Include="$(ApplicationManifest)" />
  </ItemGroup>

  <!-- 
    Defining the "Msix" ProjectCapability here allows the Single-project MSIX Packaging
    Tools extension to be activated for this project even if the Windows App SDK Nuget
    package has not yet been restored.
  -->
  <ItemGroup Condition="'$(DisableMsixProjectCapabilityAddedByProject)'!='true' and '$(EnableMsixTooling)'=='true'">
    <ProjectCapability Include="Msix" />
  </ItemGroup>
  <ItemGroup>
    <Page Update="QrCodeControl.xaml">
      <Generator>MSBuild:Compile</Generator>
    </Page>
  </ItemGroup>

  <!-- 
    Defining the "HasPackageAndPublishMenuAddedByProject" property here allows the Solution 
    Explorer "Package and Publish" context menu entry to be enabled for this project even if 
    the Windows App SDK Nuget package has not yet been restored.
  -->
  <PropertyGroup Condition="'$(DisableHasPackageAndPublishMenuAddedByProject)'!='true' and '$(EnableMsixTooling)'=='true'">
    <HasPackageAndPublishMenu>true</HasPackageAndPublishMenu>
  </PropertyGroup>
</Project>


================================================
FILE: Demo-WinUI/Demo-WinUI/MainViewModel.cs
================================================
//
// Swiss QR Bill Generator for .NET
// Copyright (c) 2022 Manuel Bleichenbacher
// Licensed under MIT License
// https://opensource.org/licenses/MIT
//

using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using System;
using System.Threading.Tasks;
using Windows.ApplicationModel.DataTransfer;
using Windows.Storage.Streams;

namespace Net.Codecrete.QrCodeGenerator.Demo;

/// <summary>
/// View model for MainWindow
/// </summary>
public partial class MainViewModel : ObservableObject
{
    /// <summary>
    /// QR code text
    /// </summary>
    [ObservableProperty]
    string text = "Hello, world!";

    /// <summary>
    /// QR code error correction level
    /// </summary>
    [ObservableProperty]
    QrCode.Ecc errorCorrection = QrCode.Ecc.Medium;

    /// <summary>
    /// Width of border around QR code (in QR code pixels)
    /// </summary>
    [ObservableProperty]
    int borderWidth = 3;

    private readonly Tuple<string, QrCode.Ecc>[] errorCorrectionLevels_ =
    {
        new Tuple<string, QrCode.Ecc>("Low", QrCode.Ecc.Low),
        new Tuple<string, QrCode.Ecc>("Medium", QrCode.Ecc.Medium),
        new Tuple<string, QrCode.Ecc>("Quartile", QrCode.Ecc.Quartile),
        new Tuple<string, QrCode.Ecc>("High", QrCode.Ecc.High)
    };

    /// <summary>
    /// List of error correction levels
    /// </summary>
    public Tuple<string, QrCode.Ecc>[] ErrorCorrectionLevels => errorCorrectionLevels_;

    /// <summary>
    /// Copy the QR code to the clipboard (as a PNG image).
    /// </summary>
    /// <returns></returns>
    [RelayCommand]
    async Task CopyToClipboard()
    {
        var qrCode = QrCode.EncodeText(Text, ErrorCorrection);

        // Don't close stream; it won't work anymore
        var stream = new InMemoryRandomAccessStream();
        await QrCodeDrawing.WriteAsPng(stream, qrCode, 20, BorderWidth);

        var dataPackage = new DataPackage();
        dataPackage.SetBitmap(RandomAccessStreamReference.CreateFromStream(stream));
        Clipboard.SetContent(dataPackage);
    }
}


================================================
FILE: Demo-WinUI/Demo-WinUI/MainWindow.xaml
================================================
<!-- Swiss QR Bill Generator for .NET -->
<!-- Copyright (c) 2022 Manuel Bleichenbacher -->
<!-- Licensed under MIT License -->
<!-- https://opensource.org/licenses/MIT -->

<Window
    x:Class="Net.Codecrete.QrCodeGenerator.Demo.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Net.Codecrete.QrCodeGenerator.Demo"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">


    <Grid x:Name="RootElement" Background="#fff7f7f7">
        <Grid Margin="20,16,20,16">

            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="1*"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="1*"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <local:QrCodeControl x:Name="QrCodeControl" Grid.Row="0" Margin="0,0,0,16"
                Text="{x:Bind ViewModel.Text, Mode=TwoWay}" ErrorCorrection="{x:Bind ViewModel.ErrorCorrection, Mode=TwoWay}" BorderWidth="{x:Bind ViewModel.BorderWidth, Mode=TwoWay}" />
            <TextBox x:Name="QrCodeTextBox" Text="{x:Bind ViewModel.Text, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Grid.Row="1" Padding="5,3" Margin="0,6"/>
            <VariableSizedWrapGrid Grid.Row="2" Orientation="Horizontal">
                <StackPanel Orientation="Horizontal">
                    <TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" Padding="0,5,12,5">Error Correction:</TextBlock>
                    <ComboBox x:Name="ErrorCorrectionCombo" HorizontalAlignment="Left" VerticalAlignment="Center" Width="140" Margin="0,6,24,6"
                          ItemsSource="{x:Bind ViewModel.ErrorCorrectionLevels, Mode=OneTime}" DisplayMemberPath="Item1"  SelectedValuePath="Item2" SelectedValue="{x:Bind ViewModel.ErrorCorrection, Mode=TwoWay}" />
                </StackPanel>
                <StackPanel Orientation="Horizontal">
                    <TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" Padding="0,5,12,5">Border Width:</TextBlock>
                    <NumberBox x:Name="BorderWidthTextBox" Value="{x:Bind ViewModel.BorderWidth, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                               SpinButtonPlacementMode="Inline" Minimum="0" Maximum="999" HorizontalAlignment="Left" VerticalAlignment="Center" Width="150" Margin="0,6" Padding="5,3"/>
                </StackPanel>
            </VariableSizedWrapGrid>
            <Button x:Name="CopyButton" Command="{x:Bind ViewModel.CopyToClipboardCommand}" Content="Copy QR Code" Grid.Row="3" Margin="0,6,0,0"
                    VerticalAlignment="Center" HorizontalAlignment="Right" Padding="10,3" Grid.ColumnSpan="4" />
        </Grid>
    </Grid>
</Window>


================================================
FILE: Demo-WinUI/Demo-WinUI/MainWindow.xaml.cs
================================================
//
// Swiss QR Bill Generator for .NET
// Copyright (c) 2022 Manuel Bleichenbacher
// Licensed under MIT License
// https://opensource.org/licenses/MIT
//

using Microsoft.UI.Xaml;

namespace Net.Codecrete.QrCodeGenerator.Demo;

/// <summary>
/// Main window
/// </summary>
public sealed partial class MainWindow : Window
{

    public MainWindow()
    {
        InitializeComponent();
        RootElement.Loaded += RootElement_Loaded;
    }

    public MainViewModel ViewModel { get; } = new MainViewModel();

    private void RootElement_Loaded(object sender, RoutedEventArgs e)
    {
        // The combo box needs help to set the initial value
        ErrorCorrectionCombo.SelectedValue = ViewModel.ErrorCorrection;
    }
}


================================================
FILE: Demo-WinUI/Demo-WinUI/NativeMethods.txt
================================================
GetDpiForWindow


================================================
FILE: Demo-WinUI/Demo-WinUI/Package.appxmanifest
================================================
<?xml version="1.0" encoding="utf-8"?>

<Package
  xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
  xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
  xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
  IgnorableNamespaces="uap rescap">

  <Identity
    Name="c77c87b7-6566-498b-9b78-4b9785310689"
    Publisher="CN=Manuel"
    Version="1.0.0.0" />

  <Properties>
    <DisplayName>Qr Code Generator</DisplayName>
    <PublisherDisplayName>Manuel</PublisherDisplayName>
    <Logo>Assets\StoreLogo.png</Logo>
  </Properties>

  <Dependencies>
    <TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />
    <TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />
  </Dependencies>

  <Resources>
    <Resource Language="x-generate"/>
  </Resources>

  <Applications>
    <Application Id="App"
      Executable="$targetnametoken$.exe"
      EntryPoint="$targetentrypoint$">
      <uap:VisualElements
        DisplayName="QR Code Generator"
        Description="QR Code Generator Demo"
        BackgroundColor="transparent"
        Square150x150Logo="Assets\Square150x150Logo.png"
        Square44x44Logo="Assets\Square44x44Logo.png">
        <uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png" />
        <uap:SplashScreen Image="Assets\SplashScreen.png" />
      </uap:VisualElements>
    </Application>
  </Applications>

  <Capabilities>
    <rescap:Capability Name="runFullTrust" />
  </Capabilities>
</Package>


================================================
FILE: Demo-WinUI/Demo-WinUI/Properties/PublishProfiles/win-arm64.pubxml
================================================
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <PublishProtocol>FileSystem</PublishProtocol>
    <Platform>ARM64</Platform>
    <RuntimeIdentifier>win-arm64</RuntimeIdentifier>
    <PublishDir>bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\</PublishDir>
    <SelfContained>true</SelfContained>
    <PublishSingleFile>False</PublishSingleFile>
    <PublishReadyToRun Condition="'$(Configuration)' == 'Debug'">False</PublishReadyToRun>
    <PublishReadyToRun Condition="'$(Configuration)' != 'Debug'">True</PublishReadyToRun>
   <!-- 
    See https://github.com/microsoft/CsWinRT/issues/373
    <PublishTrimmed>True</PublishTrimmed>
    -->
  </PropertyGroup>
</Project>

================================================
FILE: Demo-WinUI/Demo-WinUI/Properties/PublishProfiles/win-x64.pubxml
================================================
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <PublishProtocol>FileSystem</PublishProtocol>
    <Platform>x64</Platform>
    <RuntimeIdentifier>win-x64</RuntimeIdentifier>
    <PublishDir>bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\</PublishDir>
    <SelfContained>true</SelfContained>
    <PublishSingleFile>False</PublishSingleFile>
    <PublishReadyToRun Condition="'$(Configuration)' == 'Debug'">False</PublishReadyToRun>
    <PublishReadyToRun Condition="'$(Configuration)' != 'Debug'">True</PublishReadyToRun>
   <!-- 
    See https://github.com/microsoft/CsWinRT/issues/373
    <PublishTrimmed>True</PublishTrimmed>
    -->
  </PropertyGroup>
</Project>

================================================
FILE: Demo-WinUI/Demo-WinUI/Properties/PublishProfiles/win-x86.pubxml
================================================
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <PublishProtocol>FileSystem</PublishProtocol>
    <Platform>x86</Platform>
    <RuntimeIdentifier>win-x86</RuntimeIdentifier>
    <PublishDir>bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\</PublishDir>
    <SelfContained>true</SelfContained>
    <PublishSingleFile>False</PublishSingleFile>
    <PublishReadyToRun Condition="'$(Configuration)' == 'Debug'">False</PublishReadyToRun>
    <PublishReadyToRun Condition="'$(Configuration)' != 'Debug'">True</PublishReadyToRun>
   <!-- 
    See https://github.com/microsoft/CsWinRT/issues/373
    <PublishTrimmed>True</PublishTrimmed>
    -->
  </PropertyGroup>
</Project>

================================================
FILE: Demo-WinUI/Demo-WinUI/Properties/launchSettings.json
================================================
{
  "profiles": {
    "Demo-WinUI (Package)": {
      "commandName": "MsixPackage"
    },
    "Demo-WinUI (Unpackaged)": {
      "commandName": "Project"
    }
  }
}

================================================
FILE: Demo-WinUI/Demo-WinUI/QrCodeControl.xaml
================================================
<!-- Swiss QR Bill Generator for .NET -->
<!-- Copyright (c) 2022 Manuel Bleichenbacher -->
<!-- Licensed under MIT License -->
<!-- https://opensource.org/licenses/MIT -->

<UserControl
    x:Class="Net.Codecrete.QrCodeGenerator.Demo.QrCodeControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:canvas="using:Microsoft.Graphics.Canvas.UI.Xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

        <canvas:CanvasControl x:Name="qrCodeCanvas" Grid.Row="0" Grid.Column="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Draw="QrCode_Draw"/>

</UserControl>


================================================
FILE: Demo-WinUI/Demo-WinUI/QrCodeControl.xaml.cs
================================================
//
// Swiss QR Bill Generator for .NET
// Copyright (c) 2022 Manuel Bleichenbacher
// Licensed under MIT License
// https://opensource.org/licenses/MIT
//

using Microsoft.Graphics.Canvas.UI.Xaml;
using Microsoft.UI;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using System;
using System.Numerics;
using Windows.Foundation;
using Windows.UI;

namespace Net.Codecrete.QrCodeGenerator.Demo;

/// <summary>
/// Control for displaying a QR code.
/// </summary>
public sealed partial class QrCodeControl : UserControl
{
    public QrCodeControl()
    {
        InitializeComponent();
    }

    /// <summary>
    /// Text contained in QR code.
    /// </summary>
    public string Text
    {
        get { return (string)GetValue(TextProperty); }
        set { SetValue(TextProperty, value); }
    }

    public static readonly DependencyProperty TextProperty = DependencyProperty.Register(
        nameof(Text),
        typeof(string),
        typeof(QrCodeControl),
        new PropertyMetadata("", (d, args) => { (d as QrCodeControl).qrCodeCanvas.Invalidate(); })
    );

    /// <summary>
    /// Width of border around QR code (in QR pixels)
    /// </summary>
    public int BorderWidth
    {
        get { return (int)GetValue(BorderWidthProperty); }
        set { SetValue(BorderWidthProperty, value); }
    }

    public static readonly DependencyProperty BorderWidthProperty = DependencyProperty.Register(
        nameof(BorderWidth),
        typeof(int),
        typeof(QrCodeControl),
        new PropertyMetadata(3, (d, args) => { (d as QrCodeControl).qrCodeCanvas.Invalidate(); })
    );

    /// <summary>
    /// Error correction level
    /// </summary>
    public QrCode.Ecc ErrorCorrection
    {
        get { return (QrCode.Ecc)GetValue(ErrorCorrectionProperty); }
        set { SetValue(ErrorCorrectionProperty, value); }
    }

    public static readonly DependencyProperty ErrorCorrectionProperty = DependencyProperty.Register(
        nameof(ErrorCorrection),
        typeof(QrCode.Ecc),
        typeof(QrCodeControl),
        new PropertyMetadata(QrCode.Ecc.Medium, (d, args) => { (d as QrCodeControl).qrCodeCanvas.Invalidate(); })
    );

    /// <summary>
    /// QR code background color
    /// </summary>
    public Color QrCodeBackgroundColor
    {
        get { return (Color)GetValue(QrCodeBackgroundColorProperty); }
        set { SetValue(QrCodeBackgroundColorProperty, value); }
    }

    public static readonly DependencyProperty QrCodeBackgroundColorProperty = DependencyProperty.Register(
        nameof(QrCodeBackgroundColor),
        typeof(Color),
        typeof(QrCodeControl),
        new PropertyMetadata(Colors.White, (d, args) => { (d as QrCodeControl).qrCodeCanvas.Invalidate(); })
    );

    /// <summary>
    /// QR code pixel color
    /// </summary>
    public Color QrCodePixelColor
    {
        get { return (Color)GetValue(QrCodePixelColorProperty); }
        set { SetValue(QrCodePixelColorProperty, value); }
    }

    public static readonly DependencyProperty QrCodePixelColorProperty = DependencyProperty.Register(
        nameof(QrCodePixelColor),
        typeof(Color),
        typeof(QrCodeControl),
        new PropertyMetadata(Colors.Black, (d, args) => { (d as QrCodeControl).qrCodeCanvas.Invalidate(); })
    );

    protected override Size ArrangeOverride(Size finalSize)
    {
        var dim = Math.Min(finalSize.Width, finalSize.Height);
        qrCodeCanvas.Arrange(new Rect(new Point((finalSize.Width - dim) / 2, (finalSize.Height - dim) / 2), new Size(dim, dim)));
        return finalSize;
    }

    protected override Size MeasureOverride(Size availableSize)
    {
        var dim = Math.Min(availableSize.Width, availableSize.Height);
        if (double.IsPositiveInfinity(dim))
            dim = 3000;
        return new Size(dim, dim);
    }

    private void QrCode_Draw(CanvasControl sender, CanvasDrawEventArgs args)
    {
        var code = QrCode.EncodeText(Text, ErrorCorrection);
        var scale = (float)(sender.ActualWidth / (code.Size + 2 * BorderWidth));
        args.DrawingSession.Transform = Matrix3x2.CreateScale(scale, scale);
        QrCodeDrawing.Draw(code, args.DrawingSession, BorderWidth, QrCodePixelColor, QrCodeBackgroundColor);
    }
}


================================================
FILE: Demo-WinUI/Demo-WinUI/QrCodeDrawing.cs
================================================
//
// Swiss QR Bill Generator for .NET
// Copyright (c) 2022 Manuel Bleichenbacher
// Licensed under MIT License
// https://opensource.org/licenses/MIT
//

using Microsoft.Graphics.Canvas;
using Microsoft.UI;
using System;
using System.Numerics;
using System.Threading.Tasks;
using Windows.Foundation;
using Windows.Storage.Streams;
using Windows.UI;

namespace Net.Codecrete.QrCodeGenerator.Demo;

public class QrCodeDrawing
{
    /// <summary>
    /// Draws the QR code in the specified drawing context.
    /// <para>
    /// The QR code is drawn with the top left corner of the border at (0, 0).
    /// Each module (QR code pixel) will be drawn with 1 unit wide and tall.
    /// If a different position or size is desired, the drawing context's transformation
    /// matrix can be setup accordingly.
    /// </para>
    /// </summary>
    /// <param name="qrCode">The QR code.</param>
    /// <param name="drawingSession">The drawing session.</param>
    /// <param name="borderWidth"></param>
    /// <param name="foreground"></param>
    /// <param name="background"></param>
    public static void Draw(QrCode qrCode, CanvasDrawingSession drawingSession, int borderWidth, Color foreground, Color? background)
    {
        int size = qrCode.Size;

        // draw the background
        if (background != null)
        {
            drawingSession.FillRectangle(new Rect(0, 0, size + 2 * borderWidth, size + 2 * borderWidth), (Color)background);
        }

        // draw the modules
        for (int y = 0; y < size; y++)
        {
            for (int x = 0; x < size; x++)
            {
                if (qrCode.GetModule(x, y))
                {
                    var rect = new Rect(x + borderWidth, y + borderWidth, 1, 1);
                    drawingSession.FillRectangle(rect, foreground);
                }
            }
        }
    }

    /// <summary>
    /// Writes a PNG for the specified QR code.
    /// <para>
    /// To achieve a crisp bitmap without any anti-aliasing, the bitmap is sized such
    /// that each QR code module is multiple pixels tall and wide.
    /// The resulting size depends on the QR code size;
    /// it is (qr-code-size + 2 * border-width) pixels tall and wide.
    /// </para>
    /// </summary>
    /// <param name="stream">The stream to write to</param>
    /// <param name="qrCode">The QR code.</param>
    /// <param name="moduleSize">The size of each module (QR code pixel), in pixels</param>
    /// <param name="borderWidth">The width of the border around the QR code, in multiples of a single module (QR code pixel).</param>
    public static Task WriteAsPng(IRandomAccessStream stream, QrCode qrCode, int moduleSize, int borderWidth = 3)
    {
        return WriteAsPng(stream, qrCode, moduleSize, borderWidth, Colors.Black, Colors.White);
    }

    /// <inheritdoc cref="CreateBitmapAsPng(QrCode, int, int)"/>
    /// <param name="foreground">The forground color.</param>
    /// <param name="background">The background color.</param>
    /// <returns>PNG image</returns>
    public static async Task WriteAsPng(IRandomAccessStream stream, QrCode qrCode, int moduleSize, int borderWidth, Color foreground, Color background)
    {
        // create offscreen bitmap
        int size = moduleSize * (qrCode.Size + 2 * borderWidth);
        var device = CanvasDevice.GetSharedDevice();
        var offscreen = new CanvasRenderTarget(device, size, size, 96);

        using (CanvasDrawingSession ds = offscreen.CreateDrawingSession())
        {
            // draw QR code
            ds.Clear(background);
            ds.Transform = Matrix3x2.CreateScale(moduleSize, moduleSize);
            Draw(qrCode, ds, borderWidth, foreground, null);
        }

        // create PNG image
        await offscreen.SaveAsync(stream, CanvasBitmapFileFormat.Png);
    }

}


================================================
FILE: Demo-WinUI/Demo-WinUI/app.manifest
================================================
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
  <assemblyIdentity version="1.0.0.0" name="Demo-WinUI.app"/>

  <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
    <application>
      <!--The ID below informs the system that this application is compatible with OS features first introduced in Windows 8. 
      For more info see https://docs.microsoft.com/windows/win32/sysinfo/targeting-your-application-at-windows-8-1 
      
      It is also necessary to support features in unpackaged applications, for example the custom titlebar implementation.-->
      <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />
    </application>
  </compatibility>
  
  <application xmlns="urn:schemas-microsoft-com:asm.v3">
    <windowsSettings>
      <!-- The combination of below two tags have the following effect:
           1) Per-Monitor for >= Windows 10 Anniversary Update
           2) System < Windows 10 Anniversary Update
      -->
      <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/PM</dpiAware>
      <dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2, PerMonitor</dpiAwareness>
    </windowsSettings>
  </application>
</assembly>

================================================
FILE: Demo-WinUI/Demo-WinUI.sln
================================================

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33122.133
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demo-WinUI", "Demo-WinUI\Demo-WinUI.csproj", "{28CEBE86-06C4-42B3-BEC9-8A8C40D2C83A}"
EndProject
Global
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
		Debug|ARM64 = Debug|ARM64
		Debug|x64 = Debug|x64
		Debug|x86 = Debug|x86
		Release|ARM64 = Release|ARM64
		Release|x64 = Release|x64
		Release|x86 = Release|x86
	EndGlobalSection
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
		{28CEBE86-06C4-42B3-BEC9-8A8C40D2C83A}.Debug|ARM64.ActiveCfg = Debug|ARM64
		{28CEBE86-06C4-42B3-BEC9-8A8C40D2C83A}.Debug|ARM64.Build.0 = Debug|ARM64
		{28CEBE86-06C4-42B3-BEC9-8A8C40D2C83A}.Debug|ARM64.Deploy.0 = Debug|ARM64
		{28CEBE86-06C4-42B3-BEC9-8A8C40D2C83A}.Debug|x64.ActiveCfg = Debug|x64
		{28CEBE86-06C4-42B3-BEC9-8A8C40D2C83A}.Debug|x64.Build.0 = Debug|x64
		{28CEBE86-06C4-42B3-BEC9-8A8C40D2C83A}.Debug|x64.Deploy.0 = Debug|x64
		{28CEBE86-06C4-42B3-BEC9-8A8C40D2C83A}.Debug|x86.ActiveCfg = Debug|x86
		{28CEBE86-06C4-42B3-BEC9-8A8C40D2C83A}.Debug|x86.Build.0 = Debug|x86
		{28CEBE86-06C4-42B3-BEC9-8A8C40D2C83A}.Debug|x86.Deploy.0 = Debug|x86
		{28CEBE86-06C4-42B3-BEC9-8A8C40D2C83A}.Release|ARM64.ActiveCfg = Release|ARM64
		{28CEBE86-06C4-42B3-BEC9-8A8C40D2C83A}.Release|ARM64.Build.0 = Release|ARM64
		{28CEBE86-06C4-42B3-BEC9-8A8C40D2C83A}.Release|ARM64.Deploy.0 = Release|ARM64
		{28CEBE86-06C4-42B3-BEC9-8A8C40D2C83A}.Release|x64.ActiveCfg = Release|x64
		{28CEBE86-06C4-42B3-BEC9-8A8C40D2C83A}.Release|x64.Build.0 = Release|x64
		{28CEBE86-06C4-42B3-BEC9-8A8C40D2C83A}.Release|x64.Deploy.0 = Release|x64
		{28CEBE86-06C4-42B3-BEC9-8A8C40D2C83A}.Release|x86.ActiveCfg = Release|x86
		{28CEBE86-06C4-42B3-BEC9-8A8C40D2C83A}.Release|x86.Build.0 = Release|x86
		{28CEBE86-06C4-42B3-BEC9-8A8C40D2C83A}.Release|x86.Deploy.0 = Release|x86
	EndGlobalSection
	GlobalSection(SolutionProperties) = preSolution
		HideSolutionNode = FALSE
	EndGlobalSection
	GlobalSection(ExtensibilityGlobals) = postSolution
		SolutionGuid = {8B01C7CA-A20C-4B84-815A-3F3519AACB3A}
	EndGlobalSection
EndGlobal


================================================
FILE: Demo-WinUI/README.md
================================================
# WinUI 3 example application

This example application shows how to use the QR code library in a WinUI 3 application:

- [`QrCodeControl`](Demo-WinUI/QrCodeControl.xaml.cs) is a user control for displaying a QR code.
- [`QrCodeDrawing`](Demo-WinUI/QrCodeDrawing.cs) is a class for drawing a QR code to [Win2D](https://github.com/microsoft/Win2D) `CanvasDrawingSession` (resolution independent) or to a PNG file.
- Copying a QR code to the clipboard is also shown.

![WinUI QR Code App](WinUI-QR-Code-App.png)


================================================
FILE: Demo-WindowsPresentationFoundation/App.xaml
================================================
<Application x:Class="Demo_WindowsPresentationFoundation.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:local="clr-namespace:Demo_WindowsPresentationFoundation"
             StartupUri="MainWindow.xaml">
    <Application.Resources>
         
    </Application.Resources>
</Application>


================================================
FILE: Demo-WindowsPresentationFoundation/App.xaml.cs
================================================
//
// QR code generator library (.NET)
// https://github.com/manuelbl/QrCodeGenerator
//
// Copyright (c) 2021 Manuel Bleichenbacher
// Licensed under MIT License
// https://opensource.org/licenses/MIT
//

using System.Windows;

namespace Net.Codecrete.QrCodeGenerator.Demo
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
    }
}


================================================
FILE: Demo-WindowsPresentationFoundation/AssemblyInfo.cs
================================================
//
// QR code generator library (.NET)
// https://github.com/manuelbl/QrCodeGenerator
//
// Copyright (c) 2021 Manuel Bleichenbacher
// Licensed under MIT License
// https://opensource.org/licenses/MIT
//

using System.Windows;

[assembly: ThemeInfo(
    ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
                                     //(used if a resource is not found in the page,
                                     // or application resource dictionaries)
    ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
                                              //(used if a resource is not found in the page,
                                              // app, or any theme specific resource dictionaries)
)]


================================================
FILE: Demo-WindowsPresentationFoundation/Demo-WindowsPresentationFoundation.csproj
================================================
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net8.0-windows</TargetFramework>
    <RootNamespace>Net.Codecrete.QrCodeGenerator.Demo</RootNamespace>
    <Nullable>enable</Nullable>
    <UseWPF>true</UseWPF>
    <ApplicationManifest>app.manifest</ApplicationManifest>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Net.Codecrete.QrCodeGenerator" Version="2.*" />
  </ItemGroup>

</Project>


================================================
FILE: Demo-WindowsPresentationFoundation/Demo-WindowsPresentationFoundation.sln
================================================

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demo-WindowsPresentationFoundation", "Demo-WindowsPresentationFoundation.csproj", "{6E8E5080-AF6E-4B4F-89A8-098B0BE6A912}"
EndProject
Global
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
		Debug|Any CPU = Debug|Any CPU
		Release|Any CPU = Release|Any CPU
	EndGlobalSection
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
		{6E8E5080-AF6E-4B4F-89A8-098B0BE6A912}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{6E8E5080-AF6E-4B4F-89A8-098B0BE6A912}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{6E8E5080-AF6E-4B4F-89A8-098B0BE6A912}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{6E8E5080-AF6E-4B4F-89A8-098B0BE6A912}.Release|Any CPU.Build.0 = Release|Any CPU
	EndGlobalSection
	GlobalSection(SolutionProperties) = preSolution
		HideSolutionNode = FALSE
	EndGlobalSection
	GlobalSection(ExtensibilityGlobals) = postSolution
		SolutionGuid = {36CE72FB-2954-40CC-B7E3-D3C496C61DF5}
	EndGlobalSection
EndGlobal


================================================
FILE: Demo-WindowsPresentationFoundation/MainWindow.xaml
================================================
<Window x:Class="Net.Codecrete.QrCodeGenerator.Demo.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:Net.Codecrete.QrCodeGenerator.Demo"
        mc:Ignorable="d"
        Title="QR Code" Height="400" Width="600"
        Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"
        DataContext="{Binding RelativeSource={RelativeSource Self}}">
    <Grid Margin="20,16,20,16">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="1*"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="1*"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <Image x:Name="QrCodeImage" Grid.Row="0" Margin="0,0,0,16"
               RenderOptions.BitmapScalingMode="NearestNeighbor" RenderOptions.EdgeMode="Aliased"/>
        <TextBox x:Name="QrCodeTextBox" Text="{Binding Path=Text, UpdateSourceTrigger=PropertyChanged}"
                 Grid.Row="1" Padding="5,3" Margin="0,6"/>
        <WrapPanel Grid.Row="2">
            <Label Content="Error Correction:" HorizontalAlignment="Left" VerticalAlignment="Center" Padding="0,5,12,5"/>
            <ComboBox x:Name="ErrorCorrectionCombo" HorizontalAlignment="Left" VerticalAlignment="Center" Width="100" Margin="0,6,24,6"
                  ItemsSource="{Binding Path=ErrorCorrectionLevels}" DisplayMemberPath="Item1" SelectedValuePath="Item2" SelectedValue="{Binding Path=ErrorCorrection}"/>
            <Label Content="Border Width:" HorizontalAlignment="Left" VerticalAlignment="Center" Padding="0,5,12,5"/>
            <TextBox x:Name="BorderWidthTextBox" Text="{Binding Path=BorderWidth, UpdateSourceTrigger=PropertyChanged}"
                 HorizontalAlignment="Left" VerticalAlignment="Center" Width="60" Margin="0,6" Padding="5,3"/>
        </WrapPanel>
        <Button x:Name="CopyButton" Content="Copy QR Code" Grid.Row="3" Margin="0,6,0,0"
                VerticalAlignment="Center" HorizontalAlignment="Right" Padding="10,3" Click="CopyButton_Click" Grid.ColumnSpan="4"/>
    </Grid>
</Window>


================================================
FILE: Demo-WindowsPresentationFoundation/MainWindow.xaml.cs
================================================
//
// QR code generator library (.NET)
// https://github.com/manuelbl/QrCodeGenerator
//
// Copyright (c) 2021 Manuel Bleichenbacher
// Licensed under MIT License
// https://opensource.org/licenses/MIT
//

using System;
using System.Windows;

namespace Net.Codecrete.QrCodeGenerator.Demo
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        private string _text = "QR code text";
        private int _borderWidth = 3;
        private QrCode.Ecc _errorCorrection = QrCode.Ecc.Medium;
        private readonly Tuple<string, QrCode.Ecc>[] _errorCorrectionLevels =
        {
            new Tuple<string, QrCode.Ecc>("Low", QrCode.Ecc.Low),
            new Tuple<string, QrCode.Ecc>("Medium", QrCode.Ecc.Medium),
            new Tuple<string, QrCode.Ecc>("Quartile", QrCode.Ecc.Quartile),
            new Tuple<string, QrCode.Ecc>("High", QrCode.Ecc.High)
        };

        public MainWindow()
        {
            InitializeComponent();
            UpdateQrCode();
        }

        public int BorderWidth
        {
            get { return _borderWidth; }
            set
            {
                _borderWidth = value;
                UpdateQrCode();
            }
        }

        public string Text
        {
            get { return _text; }
            set
            {
                _text = value;
                UpdateQrCode();
            }
        }

        public Tuple<string, QrCode.Ecc>[] ErrorCorrectionLevels
        {
            get { return _errorCorrectionLevels; }
        }

        public QrCode.Ecc ErrorCorrection
        {
            get { return _errorCorrection; }
            set
            {
                _errorCorrection = value;
                UpdateQrCode();
            }
        }

        private void UpdateQrCode()
        {
            var qrCode = QrCode.EncodeText(_text, ErrorCorrection);
            QrCodeImage.Source = QrCodeDrawing.CreateDrawing(qrCode, 192, BorderWidth);
        }

        private void CopyButton_Click(object sender, RoutedEventArgs e)
        {
            // put the QR code on the clipboard as a bitmap
            var qrCode = QrCode.EncodeText(_text, ErrorCorrection);
            var bitmap = QrCodeDrawing.CreateBitmapImage(qrCode, 20, BorderWidth);
            var dataObject = new DataObject();
            dataObject.SetData(DataFormats.Bitmap, bitmap);
            Clipboard.SetDataObject(dataObject);
        }
    }
}


================================================
FILE: Demo-WindowsPresentationFoundation/QrCodeDrawing.cs
================================================
//
// QR code generator library (.NET)
// https://github.com/manuelbl/QrCodeGenerator
//
// Copyright (c) 2021 Manuel Bleichenbacher
// Licensed under MIT License
// https://opensource.org/licenses/MIT
//

using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Imaging;

namespace Net.Codecrete.QrCodeGenerator.Demo
{
    public class QrCodeDrawing
    {
        /// <summary>
        /// Create a resolution independent drawing for the specified QR code.
        /// <para>
        /// The drawing can be used as an image's source, or for printing.
        /// </para>
        /// </summary>
        /// <param name="qrCode">The QR code.</param>
        /// <param name="size">The width and height of the resulting drawing, including the border (in dip).</param>
        /// <param name="borderWidth">The width of the border, in multiples of a single module (QR code pixel)</param>
        /// <returns>The device independent drawing.</returns>
        public static DrawingImage CreateDrawing(QrCode qrCode, double size, int borderWidth = 3)
        {
            return CreateDrawing(qrCode, size, borderWidth, Colors.Black, Colors.White);
        }

        /// <inheritdoc cref="CreateDrawing(QrCode, double, int)"/>
        /// <param name="foreground"></param>
        /// <param name="background"></param>
        /// <returns>The device independent drawing.</returns>
        public static DrawingImage CreateDrawing(QrCode qrCode, double size, int borderWidth, Color foreground, Color? background)
        {
            var group = new DrawingGroup();
            using (var drawingContext = group.Open())
            {
                var backgroundBrush = background != null ? new SolidColorBrush((Color)background) : null;
                var foregroundBrush = new SolidColorBrush(foreground);
                double scale = size / (qrCode.Size + 2 * borderWidth);
                drawingContext.PushTransform(new ScaleTransform(scale, scale));
                Draw(qrCode, drawingContext, borderWidth, foregroundBrush, backgroundBrush);
                drawingContext.Pop();
            }

            var image = new DrawingImage(group);
            image.Freeze();
            return image;
        }

        /// <summary>
        /// Draws the QR code in the specified drawing context.
        /// <para>
        /// The QR code is drawn with the top left corner of the border at (0, 0).
        /// Each module (QR code pixel) will be drawn with 1 unit wide and tall.
        /// If a different position or size is desired, the drawing context's transformation
        /// matrix can be setup accordingly.
        /// </para>
        /// </summary>
        /// <param name="qrCode">The QR code.</param>
        /// <param name="drawingContext">The drawing context.</param>
        /// <param name="borderWidth"></param>
        /// <param name="foreground"></param>
        /// <param name="background"></param>
        public static void Draw(QrCode qrCode, DrawingContext drawingContext, int borderWidth, Brush foreground, Brush? background)
        {
            int size = qrCode.Size;

            // draw the background
            if (background != null)
            {
                drawingContext.DrawRectangle(background, null, new Rect(0, 0, size + 2 * borderWidth, size + 2 * borderWidth));
            }

            // draw the modules
            for (int y = 0; y < size; y++)
            {
                for (int x = 0; x < size; x++)
                {
                    if (qrCode.GetModule(x, y))
                    {
                        var rect = new Rect(x + borderWidth, y + borderWidth, 1, 1);
                        drawingContext.DrawRectangle(foreground, null, rect);
                    }
                }
            }
        }

        /// <summary>
        /// Create a bitmap for the specified QR code.
        /// <para>
        /// To achieve a crisp bitmap without any anti-aliasing, the bitmap is sized such
        /// that each QR code module is multiple pixels tall and wide.
        /// The resulting size depends on the QR code size;
        /// it is (qr-code-size + 2 * border-width) pixels tall and wide.
        /// </para>
        /// </summary>
        /// <param name="qrCode">The QR code.</param>
        /// <param name="moduleSize">The size of each module (QR code pixel), in pixels</param>
        /// <param name="borderWidth">The width of the border around the QR code, in multiples of a single module (QR code pixel).</param>
        /// <returns>The bitmap.</returns>
        public static BitmapSource CreateBitmapImage(QrCode qrCode, int moduleSize, int borderWidth = 3)
        {
            return CreateBitmapImage(qrCode, moduleSize, borderWidth, Colors.Black, Colors.White);
        }

        /// <inheritdoc cref="CreateBitmapImage(QrCode, int, int)"/>
        /// <param name="foreground">The forground color.</param>
        /// <param name="background">The background color.</param>
        /// <returns>The bitmap.</returns>
        public static BitmapSource CreateBitmapImage(QrCode qrCode, int moduleSize, int borderWidth, Color foreground, Color background)
        {
            var drawingVisual = new AliasedDrawingVisual();
            int size = qrCode.Size + 2 * borderWidth;

            using (var drawingContext = drawingVisual.RenderOpen())
            {
                var foregroundBrush = new SolidColorBrush(foreground);
                var backgroundBrush = new SolidColorBrush(background);
                drawingContext.PushTransform(new ScaleTransform(moduleSize, moduleSize));
                drawingContext.DrawRectangle(backgroundBrush, null, new Rect(0, 0, size, size));
                Draw(qrCode, drawingContext, borderWidth, foregroundBrush, null);
            }

            var bitmap = new RenderTargetBitmap(size * moduleSize, size * moduleSize, 96, 96, PixelFormats.Pbgra32);
            bitmap.Render(drawingVisual);
            return bitmap;
        }

        /// <summary>
        /// Drawing visual using aliased edge mode.
        /// <para>
        /// This subclass is needed because the <c>VisualEdgeMode</c> property is protected
        /// and <see cref="RenderOptions"/> doesn't work for <c>DrawingVisual</c>.
        /// </para>
        /// </summary>
        class AliasedDrawingVisual : DrawingVisual
        {
            public AliasedDrawingVisual()
            {
                VisualEdgeMode = EdgeMode.Aliased;
            }
        }

    }
}


================================================
FILE: Demo-WindowsPresentationFoundation/README.md
================================================
# Windows Presentation Foundation (WPF) example application

This example application shows how to use the QR code library in a WPF application:

- `QrCodeDrawing` is a class for either creating a resolution independent `DrawingVisual` or a bitmap. Both can be displayed in an `Image` control
- The control also implements copying the QR code to the clipboard.

![WPF QR Code](Qr-Code-App.png)


================================================
FILE: Demo-WindowsPresentationFoundation/app.manifest
================================================
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
	<assemblyIdentity version="1.0.0.0" name="QR Code"/>

	<application xmlns="urn:schemas-microsoft-com:asm.v3">
		<windowsSettings>
			<!-- dpiAwareness is recognized only on Win10 1607(aka RS1)+ -->
			<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2,PerMonitor</dpiAwareness>
			<!-- Prior to Win10 1607, WPF really doesn't support per-mon DPI. Do not specify true/pm - use just true -->
			<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
		</windowsSettings>
	</application>

</assembly>


================================================
FILE: LICENSE
================================================
MIT License

Copyright (c) 2018 Manuel Bleichenbacher

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.



================================================
FILE: QrCodeGenerator/BitArrayExtensions.cs
================================================
/* 
 * QR code generator library (.NET)
 *
 * Copyright (c) Manuel Bleichenbacher (MIT License)
 * https://github.com/manuelbl/QrCodeGenerator
 * Copyright (c) Project Nayuki (MIT License)
 * https://www.nayuki.io/page/qr-code-generator-library
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 * IN THE SOFTWARE.
 */

using System;
using System.Collections;

namespace Net.Codecrete.QrCodeGenerator
{
    /// <summary>
    /// Extension methods for the <see cref="BitArray"/> class.
    /// </summary>
    public static class BitArrayExtensions
    {

        /// <summary>
        /// Appends the specified number bits of the specified value to this bit array.
        /// <para>
        /// The least significant bits of the specified value are added. They are appended in reverse order,
        /// from the most significant to the least significant one, i.e. bits 0 to <i>len-1</i>
        /// are appended in the order <i>len-1</i>, <i>len-2</i> ... 1, 0.
        /// </para>
        /// <para>
        /// Requires 0 &#x2264; len &#x2264; 31, and 0 &#x2264; val &lt; 2<sup>len</sup>.
        /// </para>
        /// </summary>
        /// <param name="bitArray">The BitArray instance that this method extends.</param>
        /// <param name="val">The value to append.</param>
        /// <param name="len">The number of low-order bits in the value to append.</param>
        /// <exception cref="ArgumentOutOfRangeException">Value or number of bits is out of range.</exception>
        public static void AppendBits(this BitArray bitArray, uint val, int len)
        {
            if (len < 0 || len > 31)
            {
                throw new ArgumentOutOfRangeException(nameof(len), "'len' out of range");
            }

            if (val >> len != 0)
            {
                throw new ArgumentOutOfRangeException(nameof(val), "'val' out of range");
            }

            var bitLength = bitArray.Length;
            bitArray.Length = bitLength + len;
            var mask = 1U << (len - 1);
            for (var i = bitLength; i < bitLength + len; i++) // Append bit by bit
            {
                if ((val & mask) != 0)
                {
                    bitArray.Set(i, true);
                }

                mask >>= 1;
            }
        }


        /// <summary>
        /// Appends the content of the specified bit array to the end of this array.
        /// </summary>
        /// <param name="bitArray">The BitArray instance that this method extends.</param>
        /// <param name="otherArray">The bit array to append</param>
        /// <exception cref="ArgumentNullException">If <c>bitArray</c> is <c>null</c>.</exception>
        public static void AppendData(this BitArray bitArray, BitArray otherArray)
        {
            Objects.RequireNonNull(otherArray);
            var bitLength = bitArray.Length;
            bitArray.Length = bitLength + otherArray.Length;
            for (var i = 0; i < otherArray.Length; i++, bitLength++)  // Append bit by bit
            {
                if (otherArray[i])
                {
                    bitArray.Set(bitLength, true);
                }
            }
        }

        /// <summary>
        /// Extracts the specified number of bits at the specified index in this bit array.
        /// <para>
        /// The bit at index <paramref name="index"/> becomes the most significant bit of the result,
        /// The bit at index <paramref name="index"/> + <paramref name="len"/> - 1 becomes the least significant bit.
        /// </para>
        /// <para>
        /// Requires 0 &#x2264; <em>len</em> &#x2264; 31, 0 &#x2264; <em>index</em>, and <em>index + len</em> &#x2264; <em>bit array length</em>.
        /// </para>
        /// </summary>
        /// <param name="bitArray">The BitArray instance that this method extends.</param>
        /// <param name="index">The index of the first bit to extract.</param>
        /// <param name="len">The number of bits to extract.</param>
        /// <returns>The extracted bits as an unsigned integer.</returns>
        /// <exception cref="ArgumentOutOfRangeException">Index or length is out of range.</exception>
        public static uint ExtractBits(this BitArray bitArray, int index, int len)
        {
            if (len < 0 || len > 31)
            {
                throw new ArgumentOutOfRangeException(nameof(len), "'len' out of range");
            }

            if (index < 0 || index + len > bitArray.Length)
            {
                throw new ArgumentOutOfRangeException(nameof(index), "'index' out of range");
            }

            uint result = 0;
            for (var i = 0; i < len; i++)
            {
                result <<= 1;
                if (bitArray.Get(index + i))
                {
                    result |= 1;
                }
            }

            return result;
        }
    }
}



================================================
FILE: QrCodeGenerator/DataTooLongException.cs
================================================
/* 
 * QR code generator library (.NET)
 *
 * Copyright (c) Manuel Bleichenbacher (MIT License)
 * https://github.com/manuelbl/QrCodeGenerator
 * Copyright (c) Project Nayuki (MIT License)
 * https://www.nayuki.io/page/qr-code-generator-library
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 * IN THE SOFTWARE.
 */

using System;
using System.Collections.Generic;

namespace Net.Codecrete.QrCodeGenerator
{
    /// <summary>
    /// The exception that is thrown when the supplied data does not fit in the QR code.
    /// </summary>
    /// <remarks>
    /// Ways to handle this exception include:
    /// <ul>
    ///   <li>Decrease the error correction level (if it was greater than <see cref="QrCode.Ecc.Low"/>)</li>
    ///   <li>Increase the <c>maxVersion</c> argument (if it was less than <see cref="QrCode.MaxVersion"/>).
    ///       This advice applies to the advanced factory functions
    ///       <see cref="QrCode.EncodeSegments"/> and
    ///       <see cref="QrSegmentAdvanced.MakeSegmentsOptimally(string, QrCode.Ecc, int, int)"/> only.
    ///       Other factory functions automatically try all versions up to <see cref="QrCode.MaxVersion"/>.</li>
    ///   <li>Split the text into several segments and encode them using different encoding modes
    ///     (see <see cref="QrSegmentAdvanced.MakeSegmentsOptimally(string, QrCode.Ecc, int, int)"/>.)</li>
    ///   <li>Make the text or binary data shorter.</li>
    ///   <li>Change the text to fit the character set of a particular segment mode (e.g. alphanumeric).</li>
    ///   <li>Reject the data and notify the caller/user.</li>
    /// </ul>
    /// </remarks>
    /// <seealso cref="QrCode.EncodeText(string, QrCode.Ecc)"/>
    /// <seealso cref="QrCode.EncodeBinary(byte[], QrCode.Ecc)"/>
    /// <seealso cref="QrCode.EncodeSegments(List{QrSegment}, QrCode.Ecc, int, int, int, bool)"/>
    /// <seealso cref="QrSegmentAdvanced.MakeSegmentsOptimally(string, QrCode.Ecc, int, int)"/>
    public class DataTooLongException : ArgumentException
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="DataTooLongException"/> class.
        /// </summary>
        /// <param name="message">The message that describes the error.</param>
        public DataTooLongException(string message)
            : base(message)
        { }
    }
}


================================================
FILE: QrCodeGenerator/Graphics.cs
================================================
/* 
 * QR code generator library (.NET)
 *
 * Copyright (c) Manuel Bleichenbacher (MIT License)
 * https://github.com/manuelbl/QrCodeGenerator
 * Copyright (c) Project Nayuki (MIT License)
 * https://www.nayuki.io/page/qr-code-generator-library
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 * IN THE SOFTWARE.
 */

using System;
using System.Globalization;
using System.Text;

namespace Net.Codecrete.QrCodeGenerator
{
    internal class Graphics
    {
        internal Graphics(int size, bool[,] modules)
        {
            _size = size;
            _modules = modules;
        }

        private readonly int _size;

        // The modules of this QR code (false = light, true = dark).
        // Immutable after constructor finishes.
        private readonly bool[,] _modules;

        internal string ToSvgString(int border, string foreground, string background)
        {
            if (border < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(border), "Border must be non-negative");
            }

            var dim = _size + border * 2;
            var sb = new StringBuilder()
                .Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n")
                .Append("<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n")
                .Append($"<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" viewBox=\"0 0 {dim} {dim}\" stroke=\"none\">\n")
                .Append($"\t<rect width=\"100%\" height=\"100%\" fill=\"{background}\"/>\n")
                .Append("\t<path d=\"");

            // Work on copy as it is destructive
            var modules = CopyModules();
            CreatePath(sb, modules, border);

            return sb
                .Append($"\" fill=\"{foreground}\"/>\n")
                .Append("</svg>\n")
                .ToString();
        }

        internal string ToGraphicsPath(int border)
        {
            if (border < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(border), "Border must be non-negative");
            }

            // Work on copy as it is destructive
            var modules = CopyModules();
            var path = new StringBuilder();
            CreatePath(path, modules, border);
            return path.ToString();
        }

        internal byte[] ToBmpBitmap(int border, int scale, int foreground, int background)
        {
            if (scale < 1)
            {
                throw new ArgumentOutOfRangeException(nameof(scale), scale, "Scale must be greater than 0.");
            }

            if (border < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(border), border, "Border must be non-negative.");
            }

            var dim = (_size + 2 * border) * scale;

            if (dim > short.MaxValue)
            {
                throw new ArgumentOutOfRangeException(nameof(scale), "Scale or border too large.");
            }

            // NOTE: Works for Size > 0
            // Modules to bytes
            // x >> 3 == x / 8
            var bytesToWrite = ((dim - 1) >> 3) + 1;

            // NOTE: Align to 4 bytes
            // This is a Bitmap requirement
            // (size + (align - 1)) & ~(align - 1)
            var aligned = (bytesToWrite + 3) & ~3;
            var fileSize = 62 + dim * aligned;

            var buf = new byte[fileSize];

            // NOTE: BMP file header
            buf[0] = (byte)'B';
            buf[1] = (byte)'M';

            buf[2] = (byte)fileSize;
            buf[3] = (byte)(fileSize >> 8);
            buf[4] = (byte)(fileSize >> 16);
            buf[5] = (byte)(fileSize >> 24);

            // NOTE: Offset to bitmap data
            buf[10] = 62;

            // NOTE: BMP info header
            buf[14] = 40;

            // NOTE: Image width
            buf[18] = (byte)dim;
            buf[19] = (byte)(dim >> 8);
            buf[20] = (byte)(dim >> 16);
            buf[21] = (byte)(dim >> 24);

            // NOTE: Image height
            buf[22] = buf[18];
            buf[23] = buf[19];
            buf[24] = buf[20];
            buf[25] = buf[21];

            // NOTE: Number of color planes (usually 1)
            // Must be non-zero
            buf[26] = 1;

            // NOTE: Number of bits per pixel (1 bpp)
            buf[28] = 1;

            // NOTE: Horizontal resolution (pixels/meter)
            // 3780 ppm (96 dpi)
            buf[38] = 196;
            buf[39] = 14;

            // NOTE: Vertical resolution (pixels/meter)
            // 3780 ppm (96 dpi)
            buf[42] = buf[38];
            buf[43] = buf[39];

            // NOTE: Color table
            // Alpha isn't useful here
            // Foreground - Dark
            buf[54] = (byte)foreground; // blue
            buf[55] = (byte)(foreground >> 8); // green
            buf[56] = (byte)(foreground >> 16); // red

            // Background - Light
            buf[58] = (byte)background; // blue
            buf[59] = (byte)(background >> 8); // green
            buf[60] = (byte)(background >> 16); // red

            var scaledBorder = border * scale;

            int i;
            int y;
            byte px;

            if (border > 0)
            {
                var scaledSize = _size * scale;

                for (i = 0; i < aligned; ++i)
                {
                    px = 255;

                    if (i == bytesToWrite - 1)
                    {
                        px = (byte)(255 << ((bytesToWrite << 3) - dim));
                    }
                    else if (i >= bytesToWrite)
                    {
                        px = 0;
                    }

                    for (y = 0; y < scaledBorder; ++y)
                    {
                        buf[62 + i + y * aligned] = px;
                        buf[62 + i + (y + scaledSize + scaledBorder) * aligned] = px;
                    }
                }
            }

            for (y = 0; y < _size; ++y)
            {
                int j;
                var yOffset = y * scale + scaledBorder;

                for (i = 0; i < aligned; ++i)
                {
                    px = 0;

                    for (j = 0; j < 8; ++j)
                    {
                        var x = ((i << 3) + j) / scale;

                        if (x >= dim)
                        {
                            continue;
                        }

                        if (x < border || x >= _size + border)
                        {
                            px |= (byte)(1 << (7 - j));
                            continue;
                        }

                        px |= (byte)(_modules[(_size - y - 1), x - border] ? 0 : 1 << (7 - j));
                    }

                    buf[62 + i + yOffset * aligned] = px;
                }

                // NOTE: Copy rows when scaling
                for (i = 1; i <= scale - 1; ++i)
                {
                    for (j = 0; j < aligned; ++j)
                    {
                        buf[62 + j + (yOffset + i) * aligned] = buf[62 + j + yOffset * aligned];
                    }
                }
            }

            return buf;
        }

        // Append a SVG/XAML path for the QR code to the provided string builder
        private static void CreatePath(StringBuilder path, bool[,] modules, int border)
        {
            // Simple algorithm to reduce the number of rectangles for drawing the QR code
            // and reduce SVG/XAML size.
            var size = modules.GetLength(0);
            for (var y = 0; y < size; y++)
            {
                for (var x = 0; x < size; x++)
                {
                    if (modules[y, x])
                    {
                        DrawLargestRectangle(path, modules, x, y, border);
                    }
                }
            }
        }

        // Find, draw and clear largest rectangle with (x, y) as the top left corner
        private static void DrawLargestRectangle(StringBuilder path, bool[,] modules, int x, int y, int border)
        {
            var size = modules.GetLength(0);

            var bestW = 1;
            var bestH = 1;
            var maxArea = 1;

            var xLimit = size;
            var iy = y;
            while (iy < size && modules[iy, x])
            {
                var w = 0;
                while (x + w < xLimit && modules[iy, x + w])
                {
                    w++;
                }

                var area = w * (iy - y + 1);
                if (area > maxArea)
                {
                    maxArea = area;
                    bestW = w;
                    bestH = iy - y + 1;
                }
                xLimit = x + w;
                iy++;
            }

            // append path command
            if (x != 0 || y != 0)
            {
                path.Append(' ');
            }

            // Different locales use different minus signs.
            FormattableString pathElement = $"M{x + border},{y + border}h{bestW}v{bestH}h{-bestW}z";
            path.Append(pathElement.ToString(CultureInfo.InvariantCulture));

            // clear processed modules
            ClearRectangle(modules, x, y, bestW, bestH);
        }

        // Clear a rectangle of modules
        private static void ClearRectangle(bool[,] modules, int x, int y, int width, int height)
        {
            for (var iy = y; iy < y + height; iy++)
            {
                for (var ix = x; ix < x + width; ix++)
                {
                    modules[iy, ix] = false;
                }
            }
        }

        // Create a copy of the modules (in row-major order)
        private bool[,] CopyModules()
        {
            var modules = new bool[_size, _size];
            for (var y = 0; y < _size; y++)
            {
                for (var x = 0; x < _size; x++)
                {
                    modules[y, x] = _modules[y, x];
                }
            }

            return modules;
        }
    }
}


================================================
FILE: QrCodeGenerator/Objects.cs
================================================
/* 
 * QR code generator library (.NET)
 *
 * Copyright (c) Manuel Bleichenbacher (MIT License)
 * https://github.com/manuelbl/QrCodeGenerator
 * Copyright (c) Project Nayuki (MIT License)
 * https://www.nayuki.io/page/qr-code-generator-library
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 * IN THE SOFTWARE.
 */

using System;

namespace Net.Codecrete.QrCodeGenerator
{
    /// <summary>
    /// Helper functions to check for valid arguments.
    /// </summary>
    internal static class Objects
    {
        /// <summary>
        /// Ensures that the specified argument is <i>not null</i>.
        /// <para>
        /// Throws a <see cref="ArgumentNullException"/> exception if the argument is <c>null</c>.
        /// </para>
        /// </summary>
        /// <typeparam name="T">The type of the argument.</typeparam>
        /// <param name="arg">The argument to check.</param>
        /// <returns>Argument passed to function.</returns>
        /// <exception cref="ArgumentNullException">The specified argument is <c>null</c>.</exception>
        internal static T RequireNonNull<T>(T arg)
        {
            if (arg == null)
            {
                throw new ArgumentNullException();
            }
            return arg;
        }
    }
}


================================================
FILE: QrCodeGenerator/PngBuilder.cs
================================================
/* 
 * QR code generator library (.NET)
 *
 * Copyright (c) Manuel Bleichenbacher (MIT License)
 * https://github.com/manuelbl/QrCodeGenerator
 * 
 */

using System;
using System.IO;
using System.IO.Compression;

namespace Net.Codecrete.QrCodeGenerator
{
    /// <summary>
    /// Creates a PNG file from a given QR code.
    /// </summary>
    internal sealed class PngBuilder
    {
        private static readonly byte[] Signature = { 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A };
        private static readonly uint[] CrcTable =
        {
            0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5, 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F, 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D,
            0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433, 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01, 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD,
            0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79, 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D,
            0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D
        };

        private static readonly byte[] IHDR = { 73, 72, 68, 82 };
        private static readonly byte[] PLTE = { 80, 76, 84, 69 };
        private static readonly byte[] IDAT = { 73, 68, 65, 84 };
        private static readonly byte[] IEND = { 73, 69, 78, 68 };

        /// <summary>
        /// Creates a PNG image for the given QR code.
        /// <para>
        /// The PNG image uses indexed colors, 1 bit per pixel and a palette with entries for the foreground and background colors.
        /// </para>
        /// </summary>
        /// <param name="qrCode">The QR code.</param>
        /// <param name="border">The border width, as a factor of the module (QR code pixel) size.</param>
        /// <param name="scale">The width and height, in pixels, of each module.</param>
        /// <param name="foreground">The foreground color (dark modules), in RGB value (little endian).</param>
        /// <param name="background">The background color (light modules), in RGB value (little endian).</param>
        /// <returns>A PNG image, as a byte array.</returns>
        /// 
        internal static byte[] ToImage(QrCode qrCode, int scale, int border, int foreground, int background)
        {
            var imageSize = (qrCode.Size + border * 2) * scale;
            var builder = new PngBuilder();
            builder.WriteHeader(imageSize, imageSize, 1, 3);
            builder.WritePalette(new int[] { background, foreground });
            builder.WriteData(CreateBitmap(qrCode, border, scale));
            builder.WriteEnd();
            return builder.GetBytes();
        }

        /// <summary>
        /// Creates an uncompressed 1-bit per pixel bitmap of the QR code.
        /// </summary>
        /// <param name="qrCode">The QR code</param>
        /// <param name="border">The border</param>
        /// <param name="scale">The scale</param>
        /// <returns>Bitmap, as a byte array</returns>
        private static byte[] CreateBitmap(QrCode qrCode, int border, int scale)
        {
            var size = qrCode.Size;
            var imageSize = (size + border * 2) * scale;

            var bytesPerLine = (imageSize + 7) / 8 + 1; // additional byte at the start for filter type
            var data = new byte[bytesPerLine * imageSize];

            for (var y = 0; y < size; y++)
            {
                var offset = (border + y) * scale * bytesPerLine;

                for (var x = 0; x < size; x++)
                {
                    if (!qrCode.GetModule(x, y))
                        continue;

                    var pos = (border + x) * scale;
                    var end = pos + scale;

                    // set pixels for module ('scale' times)
                    for (; pos < end; pos++)
                    {
                        var index = offset + pos / 8 + 1;
                        data[index] |= (byte)(0x80U >> (pos % 8));
                    }
                }

                // replicate line 'scale' times
                for (var i = 1; i < scale; i++)
                    Array.Copy(data, offset, data, offset + i * bytesPerLine, bytesPerLine);
            }

            return data;
        }

        private readonly MemoryStream stream = new MemoryStream();

        /// <summary>
        /// Returns the resulting PNG bytes.
        /// </summary>
        /// <returns>PNG file, as a byte array.</returns>
        private byte[] GetBytes()
        {
            var bytes = stream.ToArray();
            SetCRC(bytes);
            return bytes;
        }

        /// <summary>
        /// Writes the PNG header (IHDR chunk).
        /// </summary>
        /// <param name="width">The image width.</param>
        /// <param name="height">The image height.</param>
        /// <param name="bitDepth">The bits per pixel.</param>
        /// <param name="colorType">The color type (see PNG specification).</param>
        private void WriteHeader(int width, int height, byte bitDepth, byte colorType)
        {
            stream.Write(Signature, 0, Signature.Length);

            WriteChunkStart(IHDR, 13);
            WriteIntBigEndian((uint)width);
            WriteIntBigEndian((uint)height);

            stream.WriteByte(bitDepth);
            stream.WriteByte(colorType);
            stream.WriteByte(0);
            stream.WriteByte(0);
            stream.WriteByte(0);

            WriteChunkEnd();
        }

        /// <summary>
        /// Writes the palette (PLTE chunk).
        /// </summary>
        /// <param name="palette">The color palettes as an array of RGB values.</param>
        private void WritePalette(int[] palette)
        {
            WriteChunkStart(PLTE, palette.Length * 3);
            foreach (var color in palette)
            {
                stream.WriteByte((byte)((color >> 16) & 0xFF));
                stream.WriteByte((byte)((color >> 8) & 0xFF));
                stream.WriteByte((byte)(color & 0xFF));
            }
            WriteChunkEnd();
        }

        /// <summary>
        /// Writes the pixel data (IDAT chunk).
        /// </summary>
        /// <param name="data">The pixel data.</param>
        private void WriteData(byte[] data)
        {
            var compressedData = Deflate(data);
            WriteChunkStart(IDAT, compressedData.Length + 6);

            stream.WriteByte(0x78);
            stream.WriteByte(0x9C);

            stream.Write(compressedData, 0, compressedData.Length);

            var adler = CalcAdler32(data, 0, data.Length);
            WriteIntBigEndian(adler);
            WriteChunkEnd();
        }

        /// <summary>
        /// Writes the end chunk (IEND).
        /// </summary>
        private void WriteEnd()
        {
            WriteChunkStart(IEND, 0);
            WriteChunkEnd();
        }

        private static void SetCRC(byte[] bytes)
        {
            var chunkOffset = Signature.Length;
            while (chunkOffset < bytes.Length)
            {
                // calculate CRC
                var dataLength = (bytes[chunkOffset] << 24) | (bytes[chunkOffset + 1] << 16) | (bytes[chunkOffset + 2] << 8) | bytes[chunkOffset + 3];
 
Download .txt
gitextract_hpw2vdf4/

├── .config/
│   └── dotnet-tools.json
├── .github/
│   └── workflows/
│       ├── continuous-integration.yml
│       └── demos.yaml
├── .gitignore
├── Demo-ASP.NET-Core/
│   ├── Demo-ASP.NET-Core.csproj
│   ├── Demo-ASP.NET-Core.sln
│   ├── Program.cs
│   ├── Properties/
│   │   └── launchSettings.json
│   ├── QrCodeBitmapExtensions.cs
│   ├── QrCodeController.cs
│   ├── README.md
│   ├── Startup.cs
│   ├── appsettings.Development.json
│   ├── appsettings.json
│   └── wwwroot/
│       ├── home.html
│       ├── styles.css
│       └── ui.js
├── Demo-ImageMagick/
│   ├── Demo-ImageMagick.csproj
│   ├── Demo-ImageMagick.sln
│   ├── Program.cs
│   ├── QrCodeImageExtensions.cs
│   └── README.md
├── Demo-ImageSharp/
│   ├── Demo-ImageSharp.csproj
│   ├── Demo-ImageSharp.sln
│   ├── Program.cs
│   ├── QrCodeBitmapExtensions.cs
│   └── README.md
├── Demo-QRCode-Variety/
│   ├── Demo-QRCode-Variety.csproj
│   ├── Demo-QRCode-Variety.sln
│   ├── Program.cs
│   └── README.md
├── Demo-SkiaSharp/
│   ├── Demo-SkiaSharp.csproj
│   ├── Demo-SkiaSharp.sln
│   ├── Program.cs
│   ├── QrCodeBitmapExtensions.cs
│   └── README.md
├── Demo-System-Drawing/
│   ├── Demo-System-Drawing.csproj
│   ├── Demo-System-Drawing.sln
│   ├── Program.cs
│   ├── QrCodeBitmapExtensions.cs
│   └── README.md
├── Demo-VCard/
│   ├── Program.cs
│   ├── VCardDemo.csproj
│   └── VCardDemo.sln
├── Demo-WinForms/
│   ├── Demo-WinForms.csproj
│   ├── Demo-WinForms.sln
│   ├── Form1.Designer.cs
│   ├── Form1.cs
│   ├── Form1.resx
│   ├── Program.cs
│   ├── QrCodeBitmapExtensions.cs
│   ├── QrCodeControl.cs
│   └── README.md
├── Demo-WinUI/
│   ├── Demo-WinUI/
│   │   ├── App.xaml
│   │   ├── App.xaml.cs
│   │   ├── Demo-WinUI.csproj
│   │   ├── MainViewModel.cs
│   │   ├── MainWindow.xaml
│   │   ├── MainWindow.xaml.cs
│   │   ├── NativeMethods.txt
│   │   ├── Package.appxmanifest
│   │   ├── Properties/
│   │   │   ├── PublishProfiles/
│   │   │   │   ├── win-arm64.pubxml
│   │   │   │   ├── win-x64.pubxml
│   │   │   │   └── win-x86.pubxml
│   │   │   └── launchSettings.json
│   │   ├── QrCodeControl.xaml
│   │   ├── QrCodeControl.xaml.cs
│   │   ├── QrCodeDrawing.cs
│   │   └── app.manifest
│   ├── Demo-WinUI.sln
│   └── README.md
├── Demo-WindowsPresentationFoundation/
│   ├── App.xaml
│   ├── App.xaml.cs
│   ├── AssemblyInfo.cs
│   ├── Demo-WindowsPresentationFoundation.csproj
│   ├── Demo-WindowsPresentationFoundation.sln
│   ├── MainWindow.xaml
│   ├── MainWindow.xaml.cs
│   ├── QrCodeDrawing.cs
│   ├── README.md
│   └── app.manifest
├── LICENSE
├── QrCodeGenerator/
│   ├── BitArrayExtensions.cs
│   ├── DataTooLongException.cs
│   ├── Graphics.cs
│   ├── Key.snk
│   ├── Objects.cs
│   ├── PngBuilder.cs
│   ├── QrCode.cs
│   ├── QrCodeGenerator.csproj
│   ├── QrSegment.cs
│   ├── QrSegmentAdvanced.cs
│   ├── ReedSolomonGenerator.cs
│   ├── docfx/
│   │   ├── api/
│   │   │   └── index.md
│   │   ├── docfx.json
│   │   └── index.md
│   └── docs/
│       └── README.md
├── QrCodeGenerator.sln
├── QrCodeGeneratorTest/
│   ├── BitArrayExtensionsTest.cs
│   ├── KanjiTest.cs
│   ├── PngTest.cs
│   ├── QrCodeBitmapTest.cs
│   ├── QrCodeDataProvider.cs
│   ├── QrCodeGeneratorTest.csproj
│   ├── QrCodeTest.cs
│   ├── QrCodeTestCase.cs
│   ├── QrSegmentEncodingTest.cs
│   ├── QrSegmentRegexTest.cs
│   ├── RandomData.cs
│   ├── StructuredAppendTest.cs
│   ├── SvgTest.cs
│   └── TestHelper.cs
└── README.md
Download .txt
SYMBOL INDEX (293 symbols across 49 files)

FILE: Demo-ASP.NET-Core/Program.cs
  class Program (line 15) | public class Program
    method Main (line 17) | public static void Main(string[] args)
    method CreateHostBuilder (line 22) | public static IHostBuilder CreateHostBuilder(string[] args) =>

FILE: Demo-ASP.NET-Core/QrCodeBitmapExtensions.cs
  class QrCodeBitmapExtensions (line 16) | public static class QrCodeBitmapExtensions
    method ToBitmap (line 21) | public static SKBitmap ToBitmap(this QrCode qrCode, int scale, int bor...
    method ToBitmap (line 92) | public static SKBitmap ToBitmap(this QrCode qrCode, int scale, int bor...
    method ToPng (line 100) | public static byte[] ToPng(this QrCode qrCode, int scale, int border, ...
    method ToPng (line 127) | public static byte[] ToPng(this QrCode qrCode, int scale, int border)
    method SaveAsPng (line 135) | public static void SaveAsPng(this QrCode qrCode, string filename, int ...
    method SaveAsPng (line 162) | public static void SaveAsPng(this QrCode qrCode, string filename, int ...

FILE: Demo-ASP.NET-Core/QrCodeController.cs
  class QrCodeController (line 19) | [ApiController]
    method GeneratePng (line 31) | [HttpGet("qrcode/png")]
    method GenerateSvg (line 51) | [HttpGet("qrcode/svg")]

FILE: Demo-ASP.NET-Core/Startup.cs
  class Startup (line 18) | public class Startup
    method ConfigureServices (line 22) | public void ConfigureServices(IServiceCollection services)
    method Configure (line 28) | public void Configure(IApplicationBuilder app, IWebHostEnvironment env)

FILE: Demo-ASP.NET-Core/wwwroot/ui.js
  function updateQrCode (line 7) | function updateQrCode() {
  function init (line 15) | function init() {

FILE: Demo-ImageMagick/QrCodeImageExtensions.cs
  class QrCodeImageExtensions (line 15) | public static class QrCodeImageExtensions
    method ToImage (line 35) | public static MagickImage ToImage(this QrCode qrCode, int scale, int b...
    method ToPng (line 97) | public static byte[] ToPng(this QrCode qrCode, int scale, int border, ...
    method SaveAsPng (line 119) | public static void SaveAsPng(this QrCode qrCode, string fileName, int ...

FILE: Demo-ImageSharp/Program.cs
  class Program (line 17) | internal class Program
    method Main (line 20) | internal static void Main()
    method HelloWorld (line 27) | internal static void HelloWorld()
    method QrCodeWithImage (line 38) | internal static void QrCodeWithImage()

FILE: Demo-ImageSharp/QrCodeBitmapExtensions.cs
  class QrCodeBitmapExtensions (line 19) | public static class QrCodeBitmapExtensions
    method ToBitmap (line 24) | public static Image ToBitmap(this QrCode qrCode, int scale, int border...
    method ToBitmap (line 89) | public static Image ToBitmap(this QrCode qrCode, int scale, int border)
    method ToPng (line 97) | public static byte[] ToPng(this QrCode qrCode, int scale, int border, ...
    method ToPng (line 125) | public static byte[] ToPng(this QrCode qrCode, int scale, int border)
    method SaveAsPng (line 133) | public static void SaveAsPng(this QrCode qrCode, string filename, int ...
    method SaveAsPng (line 158) | public static void SaveAsPng(this QrCode qrCode, string filename, int ...

FILE: Demo-QRCode-Variety/Program.cs
  class Program (line 34) | internal class Program
    method Main (line 37) | internal static void Main()
    method DoBasicDemo (line 49) | private static void DoBasicDemo()
    method DoVarietyDemo (line 60) | private static void DoVarietyDemo()
    method DoSegmentDemo (line 88) | private static void DoSegmentDemo()
    method DoMaskDemo (line 134) | private static void DoMaskDemo()
    method DoBinaryDemo (line 155) | private static void DoBinaryDemo()
    method SaveAsSvg (line 172) | private static void SaveAsSvg(QrCode qrCode, string filname, int borde...

FILE: Demo-SkiaSharp/Program.cs
  class Program (line 15) | internal class Program
    method Main (line 18) | internal static void Main()

FILE: Demo-SkiaSharp/QrCodeBitmapExtensions.cs
  class QrCodeBitmapExtensions (line 16) | public static class QrCodeBitmapExtensions
    method ToBitmap (line 21) | public static SKBitmap ToBitmap(this QrCode qrCode, int scale, int bor...
    method ToBitmap (line 92) | public static SKBitmap ToBitmap(this QrCode qrCode, int scale, int bor...
    method ToPng (line 100) | public static byte[] ToPng(this QrCode qrCode, int scale, int border, ...
    method ToPng (line 127) | public static byte[] ToPng(this QrCode qrCode, int scale, int border)
    method SaveAsPng (line 135) | public static void SaveAsPng(this QrCode qrCode, string filename, int ...
    method SaveAsPng (line 162) | public static void SaveAsPng(this QrCode qrCode, string filename, int ...

FILE: Demo-System-Drawing/Program.cs
  class Program (line 15) | internal class Program
    method Main (line 18) | internal static void Main()

FILE: Demo-System-Drawing/QrCodeBitmapExtensions.cs
  class QrCodeBitmapExtensions (line 23) | public static class QrCodeBitmapExtensions
    method ToBitmap (line 28) | public static Bitmap ToBitmap(this QrCode qrCode, int scale, int borde...
    method ToBitmap (line 80) | public static Bitmap ToBitmap(this QrCode qrCode, int scale, int border)
    method Draw (line 105) | public static void Draw(this QrCode qrCode, Graphics graphics, float s...
    method Draw (line 113) | public static void Draw(this QrCode qrCode, Graphics graphics, float s...
    method ToPng (line 149) | public static byte[] ToPng(this QrCode qrCode, int scale, int border, ...
    method ToPng (line 177) | public static byte[] ToPng(this QrCode qrCode, int scale, int border)
    method SaveAsPng (line 185) | public static void SaveAsPng(this QrCode qrCode, string filename, int ...
    method SaveAsPng (line 210) | public static void SaveAsPng(this QrCode qrCode, string filename, int ...

FILE: Demo-VCard/Program.cs
  class Program (line 20) | class Program
    method Main (line 22) | static void Main()

FILE: Demo-WinForms/Form1.Designer.cs
  class Form1 (line 12) | partial class Form1
    method Dispose (line 23) | protected override void Dispose(bool disposing)
    method InitializeComponent (line 38) | private void InitializeComponent()

FILE: Demo-WinForms/Form1.cs
  class Form1 (line 15) | public partial class Form1 : Form
    method Form1 (line 17) | public Form1()
    method QrCodeText_TextChanged (line 28) | private void QrCodeText_TextChanged(object sender, EventArgs e)
    method ErrorCorrectionCombo_SelectedIndexChanged (line 33) | private void ErrorCorrectionCombo_SelectedIndexChanged(object sender, ...
    method BorderNumericUpDown_ValueChanged (line 38) | private void BorderNumericUpDown_ValueChanged(object sender, EventArgs e)
    method CopyButton_Click (line 43) | private void CopyButton_Click(object sender, EventArgs e)

FILE: Demo-WinForms/Program.cs
  class Program (line 15) | internal static class Program
    method Main (line 20) | [STAThread]

FILE: Demo-WinForms/QrCodeBitmapExtensions.cs
  class QrCodeBitmapExtensions (line 23) | public static class QrCodeBitmapExtensions
    method ToBitmap (line 28) | public static Bitmap ToBitmap(this QrCode qrCode, int scale, int borde...
    method ToBitmap (line 80) | public static Bitmap ToBitmap(this QrCode qrCode, int scale, int border)
    method Draw (line 105) | public static void Draw(this QrCode qrCode, Graphics graphics, float s...
    method Draw (line 113) | public static void Draw(this QrCode qrCode, Graphics graphics, float s...
    method ToPng (line 149) | public static byte[] ToPng(this QrCode qrCode, int scale, int border, ...
    method ToPng (line 177) | public static byte[] ToPng(this QrCode qrCode, int scale, int border)
    method SaveAsPng (line 185) | public static void SaveAsPng(this QrCode qrCode, string filename, int ...
    method SaveAsPng (line 210) | public static void SaveAsPng(this QrCode qrCode, string filename, int ...

FILE: Demo-WinForms/QrCodeControl.cs
  class QrCodeControl (line 19) | public class QrCodeControl : Control
    method QrCodeControl (line 27) | public QrCodeControl()
    method CreateQrCode (line 100) | private QrCode CreateQrCode()
    method OnPaint (line 117) | protected override void OnPaint(PaintEventArgs e)
    method CopyToClipboard (line 137) | public void CopyToClipboard()

FILE: Demo-WinUI/Demo-WinUI/App.xaml.cs
  class App (line 23) | public partial class App : Application
    method App (line 29) | public App()
    method OnLaunched (line 38) | protected override void OnLaunched(LaunchActivatedEventArgs args)
    method Resize (line 53) | private void Resize(int x, int y)
    method GetAppWindow (line 59) | private AppWindow GetAppWindow()
    method GetDpiScalingFactor (line 66) | private double GetDpiScalingFactor()

FILE: Demo-WinUI/Demo-WinUI/MainViewModel.cs
  class MainViewModel (line 20) | public partial class MainViewModel : ObservableObject
    method CopyToClipboard (line 57) | [RelayCommand]

FILE: Demo-WinUI/Demo-WinUI/MainWindow.xaml.cs
  class MainWindow (line 15) | public sealed partial class MainWindow : Window
    method MainWindow (line 18) | public MainWindow()
    method RootElement_Loaded (line 26) | private void RootElement_Loaded(object sender, RoutedEventArgs e)

FILE: Demo-WinUI/Demo-WinUI/QrCodeControl.xaml.cs
  class QrCodeControl (line 22) | public sealed partial class QrCodeControl : UserControl
    method QrCodeControl (line 24) | public QrCodeControl()
    method ArrangeOverride (line 109) | protected override Size ArrangeOverride(Size finalSize)
    method MeasureOverride (line 116) | protected override Size MeasureOverride(Size availableSize)
    method QrCode_Draw (line 124) | private void QrCode_Draw(CanvasControl sender, CanvasDrawEventArgs args)

FILE: Demo-WinUI/Demo-WinUI/QrCodeDrawing.cs
  class QrCodeDrawing (line 19) | public class QrCodeDrawing
    method Draw (line 35) | public static void Draw(QrCode qrCode, CanvasDrawingSession drawingSes...
    method WriteAsPng (line 72) | public static Task WriteAsPng(IRandomAccessStream stream, QrCode qrCod...
    method WriteAsPng (line 81) | public static async Task WriteAsPng(IRandomAccessStream stream, QrCode...

FILE: Demo-WindowsPresentationFoundation/App.xaml.cs
  class App (line 17) | public partial class App : Application

FILE: Demo-WindowsPresentationFoundation/MainWindow.xaml.cs
  class MainWindow (line 18) | public partial class MainWindow : Window
    method MainWindow (line 31) | public MainWindow()
    method UpdateQrCode (line 72) | private void UpdateQrCode()
    method CopyButton_Click (line 78) | private void CopyButton_Click(object sender, RoutedEventArgs e)

FILE: Demo-WindowsPresentationFoundation/QrCodeDrawing.cs
  class QrCodeDrawing (line 16) | public class QrCodeDrawing
    method CreateDrawing (line 28) | public static DrawingImage CreateDrawing(QrCode qrCode, double size, i...
    method CreateDrawing (line 37) | public static DrawingImage CreateDrawing(QrCode qrCode, double size, i...
    method Draw (line 69) | public static void Draw(QrCode qrCode, DrawingContext drawingContext, ...
    method CreateBitmapImage (line 106) | public static BitmapSource CreateBitmapImage(QrCode qrCode, int module...
    method CreateBitmapImage (line 115) | public static BitmapSource CreateBitmapImage(QrCode qrCode, int module...
    class AliasedDrawingVisual (line 141) | class AliasedDrawingVisual : DrawingVisual
      method AliasedDrawingVisual (line 143) | public AliasedDrawingVisual()

FILE: QrCodeGenerator/BitArrayExtensions.cs
  class BitArrayExtensions (line 36) | public static class BitArrayExtensions
    method AppendBits (line 54) | public static void AppendBits(this BitArray bitArray, uint val, int len)
    method AppendData (line 87) | public static void AppendData(this BitArray bitArray, BitArray otherAr...
    method ExtractBits (line 116) | public static uint ExtractBits(this BitArray bitArray, int index, int ...

FILE: QrCodeGenerator/DataTooLongException.cs
  class DataTooLongException (line 56) | public class DataTooLongException : ArgumentException
    method DataTooLongException (line 62) | public DataTooLongException(string message)

FILE: QrCodeGenerator/Graphics.cs
  class Graphics (line 34) | internal class Graphics
    method Graphics (line 36) | internal Graphics(int size, bool[,] modules)
    method ToSvgString (line 48) | internal string ToSvgString(int border, string foreground, string back...
    method ToGraphicsPath (line 73) | internal string ToGraphicsPath(int border)
    method ToBmpBitmap (line 87) | internal byte[] ToBmpBitmap(int border, int scale, int foreground, int...
    method CreatePath (line 250) | private static void CreatePath(StringBuilder path, bool[,] modules, in...
    method DrawLargestRectangle (line 268) | private static void DrawLargestRectangle(StringBuilder path, bool[,] m...
    method ClearRectangle (line 312) | private static void ClearRectangle(bool[,] modules, int x, int y, int ...
    method CopyModules (line 324) | private bool[,] CopyModules()

FILE: QrCodeGenerator/Objects.cs
  class Objects (line 35) | internal static class Objects
    method RequireNonNull (line 47) | internal static T RequireNonNull<T>(T arg)

FILE: QrCodeGenerator/PngBuilder.cs
  class PngBuilder (line 18) | internal sealed class PngBuilder
    method ToImage (line 47) | internal static byte[] ToImage(QrCode qrCode, int scale, int border, i...
    method CreateBitmap (line 65) | private static byte[] CreateBitmap(QrCode qrCode, int border, int scale)
    method GetBytes (line 107) | private byte[] GetBytes()
    method WriteHeader (line 121) | private void WriteHeader(int width, int height, byte bitDepth, byte co...
    method WritePalette (line 142) | private void WritePalette(int[] palette)
    method WriteData (line 158) | private void WriteData(byte[] data)
    method WriteEnd (line 176) | private void WriteEnd()
    method SetCRC (line 182) | private static void SetCRC(byte[] bytes)
    method WriteChunkStart (line 202) | private void WriteChunkStart(byte[] type, int length)
    method WriteChunkEnd (line 208) | private void WriteChunkEnd()
    method WriteIntBigEndian (line 214) | private void WriteIntBigEndian(uint value)
    method Deflate (line 222) | private static byte[] Deflate(byte[] data)
    method CalcAdler32 (line 232) | private static uint CalcAdler32(byte[] data, int index, int length)
    method CalcCrc32 (line 248) | private static uint CalcCrc32(byte[] data, int index, int length)

FILE: QrCodeGenerator/QrCode.cs
  class QrCode (line 68) | public class QrCode
    method EncodeText (line 87) | public static QrCode EncodeText(string text, Ecc ecl)
    method EncodeTextInMultipleCodes (line 120) | public static List<QrCode> EncodeTextInMultipleCodes(string text, Ecc ...
    method EncodeBinary (line 154) | public static QrCode EncodeBinary(byte[] data, Ecc ecl)
    method EncodeSegments (line 203) | public static QrCode EncodeSegments(List<QrSegment> segments, Ecc ecl,...
    method QrCode (line 360) | public QrCode(int version, Ecc ecl, byte[] dataCodewords, int mask = -1)
    method GetModule (line 432) | public bool GetModule(int x, int y)
    method ToSvgString (line 445) | public string ToSvgString(int border)
    method ToSvgString (line 463) | public string ToSvgString(int border, string foreground, string backgr...
    method ToGraphicsPath (line 489) | public string ToGraphicsPath(int border = 0)
    method ToBmpBitmap (line 510) | public byte[] ToBmpBitmap(int border, int scale, int foreground, int b...
    method ToBmpBitmap (line 526) | public byte[] ToBmpBitmap(int border = 0, int scale = 1)
    method ToPngBitmap (line 539) | public byte[] ToPngBitmap(int border, int scale, int foreground, int b...
    method ToPngBitmap (line 550) | public byte[] ToPngBitmap(int border = 0, int scale = 1)
    method RgbColor (line 562) | public int RgbColor(byte red, byte green, byte blue)
    method DrawFunctionPatterns (line 574) | private void DrawFunctionPatterns()
    method DrawFormatBits (line 611) | private void DrawFormatBits(uint mask)
    method DrawVersion (line 655) | private void DrawVersion()
    method DrawFinderPattern (line 685) | private void DrawFinderPattern(int x, int y)
    method DrawAlignmentPattern (line 704) | private void DrawAlignmentPattern(int x, int y)
    method SetFunctionModule (line 718) | private void SetFunctionModule(int x, int y, bool isDark)
    method AsGraphics (line 724) | private Graphics AsGraphics()
    method AddEccAndInterleave (line 736) | private byte[] AddEccAndInterleave(byte[] data)
    method DrawCodewords (line 784) | private void DrawCodewords(byte[] data)
    method ApplyMask (line 830) | private void ApplyMask(uint mask)
    method GetPenaltyScore (line 861) | private int GetPenaltyScore()
    method GetAlignmentPatternPositions (line 981) | private int[] GetAlignmentPatternPositions()
    method GetNumRawDataModules (line 1008) | private static int GetNumRawDataModules(int ver)
    method GetNumDataCodewords (line 1048) | public static int GetNumDataCodewords(int ver, Ecc ecl)
    type FinderPenalty (line 1059) | private struct FinderPenalty
      method FinderPenalty (line 1064) | public FinderPenalty(int size)
      method CountPatterns (line 1072) | internal int CountPatterns()
      method TerminateAndCount (line 1082) | internal int TerminateAndCount(bool currentRunColor, int currentRunL...
      method AddHistory (line 1096) | internal void AddHistory(int currentRunLength)
    method CopyOfRange (line 1106) | private static byte[] CopyOfRange(byte[] original, int from, int to)
    method CopyOf (line 1114) | private static byte[] CopyOf(byte[] original, int newLength)
    method GetBit (line 1123) | private static bool GetBit(uint x, int i)
    class Ecc (line 1179) | public sealed class Ecc
      method Ecc (line 1221) | private Ecc(int ordinal, uint fb)

FILE: QrCodeGenerator/QrSegment.cs
  class QrSegment (line 62) | public class QrSegment
    method MakeBytes (line 77) | public static QrSegment MakeBytes(byte[] data)
    method MakeBytes (line 101) | public static QrSegment MakeBytes(ArraySegment<byte> data)
    method MakeNumeric (line 122) | public static QrSegment MakeNumeric(string digits)
    method MakeAlphanumeric (line 154) | public static QrSegment MakeAlphanumeric(string text)
    method MakeStructuredAppend (line 188) | internal static QrSegment MakeStructuredAppend(byte parity, int positi...
    method MakeSegments (line 213) | public static List<QrSegment> MakeSegments(string text)
    method MakeEci (line 246) | public static QrSegment MakeEci(int assignVal)
    method IsNumeric (line 286) | public static bool IsNumeric(string text)
    method IsAlphanumeric (line 302) | public static bool IsAlphanumeric(string text)
    method QrSegment (line 349) | public QrSegment(Mode mode, int numChars, BitArray data)
    method GetData (line 371) | public BitArray GetData()
    method GetText (line 384) | public string GetText()
    method GetJoinedText (line 396) | public static string GetJoinedText(List<QrSegment> segments)
    method GetJoinedText (line 411) | public static string GetJoinedText(List<List<QrSegment>> segments)
    method AppendText (line 424) | private void AppendText(StringBuilder builder)
    method GetTotalBits (line 492) | internal static int GetTotalBits(List<QrSegment> segments, int version)
    method GetTotalBits (line 524) | internal static int GetTotalBits(int numChars, Mode mode, int version)
    class Mode (line 584) | public sealed class Mode
      method NumCharCountBits (line 650) | internal int NumCharCountBits(int ver)
      method Mode (line 657) | private Mode(uint modeBits, params int[] numBitsCharCount)

FILE: QrCodeGenerator/QrSegmentAdvanced.cs
  class QrSegmentAdvanced (line 43) | public static class QrSegmentAdvanced
    method MakeSegmentsOptimally (line 67) | public static List<QrSegment> MakeSegmentsOptimally(string text, QrCod...
    method MakeSegmentsOptimally (line 110) | private static List<QrSegment> MakeSegmentsOptimally(IReadOnlyList<int...
    method MeasureSegmentsOptimally (line 124) | private static int MeasureSegmentsOptimally(IReadOnlyList<int> codePoi...
    method ComputeCharacterModes (line 134) | private static Mode[] ComputeCharacterModes(IReadOnlyList<int> codePoi...
    method SplitIntoSegments (line 238) | private static List<QrSegment> SplitIntoSegments(IReadOnlyList<int> co...
    method MeasureSegments (line 276) | private static int MeasureSegments(IReadOnlyList<int> codePoints, IRea...
    method FromCodePoints (line 306) | private static string FromCodePoints(IReadOnlyList<int> codepoints, in...
    method ToCodePoints (line 327) | private static int[] ToCodePoints(string s)
    method CountUtf8Bytes (line 344) | private static int CountUtf8Bytes(int cp)
    method MakeKanji (line 374) | public static QrSegment MakeKanji(string text)
    method IsEncodableAsKanji (line 405) | public static bool IsEncodableAsKanji(string text)
    method IsKanji (line 412) | private static bool IsKanji(int c)
    method QrSegmentAdvanced (line 534) | static QrSegmentAdvanced()
    method MakeSegmentsForMultipleCodes (line 581) | public static List<List<QrSegment>> MakeSegmentsForMultipleCodes(strin...
    method SplitTextIntoMultipleCodes (line 603) | private static List<List<QrSegment>> SplitTextIntoMultipleCodes(string...
    method CalculateParity (line 651) | private static byte CalculateParity(string text)
    method GroupConsecutiveModes (line 673) | private static void GroupConsecutiveModes(IReadOnlyList<Mode> elements...

FILE: QrCodeGenerator/ReedSolomonGenerator.cs
  class ReedSolomonGenerator (line 40) | internal class ReedSolomonGenerator
    method ReedSolomonGenerator (line 61) | internal ReedSolomonGenerator(int degree)
    method GetRemainder (line 106) | internal byte[] GetRemainder(byte[] data)
    method Multiply (line 132) | private static byte Multiply(uint x, uint y)

FILE: QrCodeGeneratorTest/BitArrayExtensionsTest.cs
  class BitArrayExtensionsTest (line 34) | public class BitArrayExtensionsTest
    method AppendInt1 (line 36) | [Fact]
    method AppendInt2 (line 52) | [Fact]
    method AppendExtraBits (line 72) | [Fact]
    method ExtractBits (line 83) | [Fact]

FILE: QrCodeGeneratorTest/KanjiTest.cs
  class KanjiTest (line 35) | public class KanjiTest
    method IsKanjiEncodable (line 49) | [Fact]

FILE: QrCodeGeneratorTest/PngTest.cs
  class PngTest (line 18) | public class PngTest
    method PngTest (line 20) | static PngTest()
    method PngTest (line 31) | public PngTest()
    method PngImage (line 36) | [Fact]
    method ColorPngImage (line 49) | [Fact]

FILE: QrCodeGeneratorTest/QrCodeBitmapTest.cs
  class QrCodeBitmapTest (line 35) | public class QrCodeBitmapTest
    method EccFromOrdinal (line 37) | private static Ecc EccFromOrdinal(int val)
    method ToMonochromeBitmap_CreatesValidBitmap (line 59) | [Theory]

FILE: QrCodeGeneratorTest/QrCodeDataProvider.cs
  class QrCodeDataProvider (line 34) | public class QrCodeDataProvider : IEnumerable<object[]>
    method GetEnumerator (line 8408) | public IEnumerator<object[]> GetEnumerator()
    method GetEnumerator (line 8416) | IEnumerator IEnumerable.GetEnumerator()

FILE: QrCodeGeneratorTest/QrCodeTest.cs
  class QrCodeTest (line 33) | public class QrCodeTest
    method TestQrCode (line 35) | [Theory]

FILE: QrCodeGeneratorTest/QrCodeTestCase.cs
  class QrCodeTestCase (line 33) | public class QrCodeTestCase
    method QrCodeTestCase (line 47) | public QrCodeTestCase(int index, List<QrSegment> segments, string[] ex...
    method ToString (line 64) | public override string ToString()

FILE: QrCodeGeneratorTest/QrSegmentEncodingTest.cs
  class QrSegmentEncodingTest (line 35) | public class QrSegmentEncodingTest
    method NumericEncoding (line 60) | [Fact]
    method RejectNonNumeric (line 74) | [Fact]
    method AlphanumericEncoding (line 80) | [Fact]
    method RejectNonAlphanumeric (line 94) | [Fact]
    method AutoNumericEncoding (line 100) | [Fact]
    method AutoAlphanumericEncoding (line 117) | [Fact]
    method Utf8Encoding (line 134) | [Fact]
    method EmptyTest (line 150) | [Fact]
    method BitArrayToByteArray (line 158) | private static byte[] BitArrayToByteArray(BitArray buffer)

FILE: QrCodeGeneratorTest/QrSegmentRegexTest.cs
  class QrSegmentRegexTest (line 32) | public class QrSegmentRegexTest
    method IsNumeric (line 34) | [Fact]
    method EmptyIsNumeric (line 40) | [Fact]
    method TextIsNotNumeric (line 46) | [Fact]
    method WhitespaceIsNotNumeric (line 52) | [Fact]
    method ValidAlphanumeric (line 58) | [Fact]
    method EmptyIsAlphanumeric (line 64) | [Fact]
    method InvalidAlphanumeric (line 70) | [Fact]

FILE: QrCodeGeneratorTest/RandomData.cs
  class RandomData (line 14) | internal static class RandomData
    method MakeAlphanumericString (line 18) | internal static string MakeAlphanumericString(int length, int seed)
    method MakeString (line 31) | internal static string MakeString(int length, int seed)

FILE: QrCodeGeneratorTest/StructuredAppendTest.cs
  class StructuredAppendTest (line 13) | public class StructuredAppendTest
    method EncodeAlphanumericStringInMultipleCodes (line 15) | [Fact]
    method EncodeStringInMultipleCodes (line 24) | [Fact]
    method EncodeVeryLongStringInMultipleCodes (line 33) | [Fact]
    method RejectTooLongString (line 42) | [Fact]
    method CreateMultipleQrCodes (line 50) | [Fact]
    method CreateSingleQrCode (line 58) | [Fact]

FILE: QrCodeGeneratorTest/SvgTest.cs
  class SvgTest (line 36) | public class SvgTest
    method SvgImage (line 40) | [Fact]
    method SvgImageWithColor (line 52) | [Fact]
    method SvgPath (line 64) | [Fact]
    method SvgLocale (line 74) | [Theory]

FILE: QrCodeGeneratorTest/TestHelper.cs
  class TestHelper (line 30) | internal static class TestHelper
    method ToStringArray (line 32) | internal static string[] ToStringArray(QrCode qrCode)
Condensed preview — 113 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (1,107K chars).
[
  {
    "path": ".config/dotnet-tools.json",
    "chars": 177,
    "preview": "{\n  \"version\": 1,\n  \"isRoot\": true,\n  \"tools\": {\n    \"dotnet-validate\": {\n      \"version\": \"0.0.1-preview.304\",\n      \"c"
  },
  {
    "path": ".github/workflows/continuous-integration.yml",
    "chars": 1301,
    "preview": "name: Continuous Integration\n\non: [push, pull_request]\n\nenv:\n  Configuration: Release\n  ContinuousIntegrationBuild: true"
  },
  {
    "path": ".github/workflows/demos.yaml",
    "chars": 2170,
    "preview": "name: Demos\n\non: [push, pull_request]\n\nenv:\n  Configuration: Release\n  ContinuousIntegrationBuild: true\n  DOTNET_CLI_TEL"
  },
  {
    "path": ".gitignore",
    "chars": 276,
    "preview": "# User-specific files\n*.rsuser\n*.suo\n*.user\n*.userosscache\n*.sln.docstates\n\n# User-specific files (MonoDevelop/Xamarin S"
  },
  {
    "path": "Demo-ASP.NET-Core/Demo-ASP.NET-Core.csproj",
    "chars": 377,
    "preview": "<Project Sdk=\"Microsoft.NET.Sdk.Web\">\n\n  <PropertyGroup>\n    <TargetFramework>net8.0</TargetFramework>\n    <RootNamespac"
  },
  {
    "path": "Demo-ASP.NET-Core/Demo-ASP.NET-Core.sln",
    "chars": 1112,
    "preview": "\nMicrosoft Visual Studio Solution File, Format Version 12.00\n# Visual Studio Version 17\nVisualStudioVersion = 17.0.3191"
  },
  {
    "path": "Demo-ASP.NET-Core/Program.cs",
    "chars": 747,
    "preview": "//\n// QR code generator library (.NET)\n// https://github.com/manuelbl/QrCodeGenerator\n//\n// Copyright (c) 2021 Manuel Bl"
  },
  {
    "path": "Demo-ASP.NET-Core/Properties/launchSettings.json",
    "chars": 690,
    "preview": "{\n  \"iisSettings\": {\n    \"windowsAuthentication\": false,\n    \"anonymousAuthentication\": true,\n    \"iisExpress\": {\n     "
  },
  {
    "path": "Demo-ASP.NET-Core/QrCodeBitmapExtensions.cs",
    "chars": 7957,
    "preview": "//\n// QR code generator library (.NET)\n// https://github.com/manuelbl/QrCodeGenerator\n//\n// Copyright (c) 2021 Manuel B"
  },
  {
    "path": "Demo-ASP.NET-Core/QrCodeController.cs",
    "chars": 2644,
    "preview": "//\n// QR code generator library (.NET)\n// https://github.com/manuelbl/QrCodeGenerator\n//\n// Copyright (c) 2021 Manuel B"
  },
  {
    "path": "Demo-ASP.NET-Core/README.md",
    "chars": 412,
    "preview": "# Sample code for ASP.NET Core\n\nThis example program shows how to create a QR codes in an ASP.NET core application.\n\nThe"
  },
  {
    "path": "Demo-ASP.NET-Core/Startup.cs",
    "chars": 1508,
    "preview": "//\n// QR code generator library (.NET)\n// https://github.com/manuelbl/QrCodeGenerator\n//\n// Copyright (c) 2021 Manuel Bl"
  },
  {
    "path": "Demo-ASP.NET-Core/appsettings.Development.json",
    "chars": 159,
    "preview": "{\n  \"Logging\": {\n    \"LogLevel\": {\n      \"Default\": \"Information\",\n      \"Microsoft\": \"Warning\",\n      \"Microsoft.Hostin"
  },
  {
    "path": "Demo-ASP.NET-Core/appsettings.json",
    "chars": 182,
    "preview": "{\n  \"Logging\": {\n    \"LogLevel\": {\n      \"Default\": \"Information\",\n      \"Microsoft\": \"Warning\",\n      \"Microsoft.Hostin"
  },
  {
    "path": "Demo-ASP.NET-Core/wwwroot/home.html",
    "chars": 1896,
    "preview": "<!DOCTYPE html>\n<html>\n<head>\n    <meta charset=\"utf-8\" />\n    <title>QR Code</title>\n    <link rel=\"stylesheet\" href=\""
  },
  {
    "path": "Demo-ASP.NET-Core/wwwroot/styles.css",
    "chars": 475,
    "preview": ".content {\n    max-width: 768px;\n    margin-left: auto;\n    margin-right: auto;\n    padding-left: 1em;\n    padding-righ"
  },
  {
    "path": "Demo-ASP.NET-Core/wwwroot/ui.js",
    "chars": 975,
    "preview": "(function () {\n    var qrCodeImage;\n    var textField;\n    var borderField;\n    var eccSelect;\n\n    function updateQrCo"
  },
  {
    "path": "Demo-ImageMagick/Demo-ImageMagick.csproj",
    "chars": 495,
    "preview": "<Project Sdk=\"Microsoft.NET.Sdk\">\n\n  <PropertyGroup>\n    <OutputType>Exe</OutputType>\n    <TargetFramework>net8.0</Targe"
  },
  {
    "path": "Demo-ImageMagick/Demo-ImageMagick.sln",
    "chars": 1110,
    "preview": "\nMicrosoft Visual Studio Solution File, Format Version 12.00\n# Visual Studio Version 17\nVisualStudioVersion = 17.2.3263"
  },
  {
    "path": "Demo-ImageMagick/Program.cs",
    "chars": 469,
    "preview": "//\n// QR code generator library (.NET)\n// https://github.com/manuelbl/QrCodeGenerator\n//\n// Copyright (c) 2022 suxiaobu"
  },
  {
    "path": "Demo-ImageMagick/QrCodeImageExtensions.cs",
    "chars": 5062,
    "preview": "//\n// QR code generator library (.NET)\n// https://github.com/manuelbl/QrCodeGenerator\n//\n// Copyright (c) 2022 suxiaobu"
  },
  {
    "path": "Demo-ImageMagick/README.md",
    "chars": 225,
    "preview": "# Saving as PNG using Magick.NET\n\nThis example program shows how to create a QR code and save it as a PNG file using the"
  },
  {
    "path": "Demo-ImageSharp/Demo-ImageSharp.csproj",
    "chars": 1274,
    "preview": "<Project Sdk=\"Microsoft.NET.Sdk\">\n\n  <PropertyGroup>\n    <OutputType>Exe</OutputType>\n    <TargetFramework>net8.0</Targe"
  },
  {
    "path": "Demo-ImageSharp/Demo-ImageSharp.sln",
    "chars": 1107,
    "preview": "\nMicrosoft Visual Studio Solution File, Format Version 12.00\n# Visual Studio Version 16\nVisualStudioVersion = 16.0.3061"
  },
  {
    "path": "Demo-ImageSharp/Program.cs",
    "chars": 2047,
    "preview": "//\n// QR code generator library (.NET)\n// https://github.com/manuelbl/QrCodeGenerator\n//\n// Copyright (c) 2021 Manuel B"
  },
  {
    "path": "Demo-ImageSharp/QrCodeBitmapExtensions.cs",
    "chars": 7575,
    "preview": "//\n// QR code generator library (.NET)\n// https://github.com/manuelbl/QrCodeGenerator\n//\n// Copyright (c) 2021 Manuel B"
  },
  {
    "path": "Demo-ImageSharp/README.md",
    "chars": 357,
    "preview": "# Saving as PNG using ImageSharp\n\nThis example program shows how to create a QR code and save it as a PNG file using the"
  },
  {
    "path": "Demo-QRCode-Variety/Demo-QRCode-Variety.csproj",
    "chars": 318,
    "preview": "<Project Sdk=\"Microsoft.NET.Sdk\">\n\n  <PropertyGroup>\n    <OutputType>Exe</OutputType>\n    <TargetFramework>net8.0</Targe"
  },
  {
    "path": "Demo-QRCode-Variety/Demo-QRCode-Variety.sln",
    "chars": 1115,
    "preview": "\nMicrosoft Visual Studio Solution File, Format Version 12.00\n# Visual Studio Version 17\nVisualStudioVersion = 17.0.3190"
  },
  {
    "path": "Demo-QRCode-Variety/Program.cs",
    "chars": 8287,
    "preview": "/* \n * QR code generator library (.NET)\n *\n * Copyright (c) Manuel Bleichenbacher (MIT License)\n * https://github.com/m"
  },
  {
    "path": "Demo-QRCode-Variety/README.md",
    "chars": 354,
    "preview": "# Demonstration of various QR code\n\nThis example program creates a series of QR code and saves them as SVG files.\n\nAside"
  },
  {
    "path": "Demo-SkiaSharp/Demo-SkiaSharp.csproj",
    "chars": 1122,
    "preview": "<Project Sdk=\"Microsoft.NET.Sdk\">\n\n  <PropertyGroup>\n    <OutputType>Exe</OutputType>\n    <TargetFramework>net8.0</Targe"
  },
  {
    "path": "Demo-SkiaSharp/Demo-SkiaSharp.sln",
    "chars": 1105,
    "preview": "\nMicrosoft Visual Studio Solution File, Format Version 12.00\n# Visual Studio Version 16\nVisualStudioVersion = 16.0.3061"
  },
  {
    "path": "Demo-SkiaSharp/Program.cs",
    "chars": 770,
    "preview": "//\n// QR code generator library (.NET)\n// https://github.com/manuelbl/QrCodeGenerator\n//\n// Copyright (c) 2021 Manuel B"
  },
  {
    "path": "Demo-SkiaSharp/QrCodeBitmapExtensions.cs",
    "chars": 7957,
    "preview": "//\n// QR code generator library (.NET)\n// https://github.com/manuelbl/QrCodeGenerator\n//\n// Copyright (c) 2021 Manuel B"
  },
  {
    "path": "Demo-SkiaSharp/README.md",
    "chars": 276,
    "preview": "# Saving as PNG using SkiaSharp\n\nThis example program shows how to create a QR code and save it as a PNG file using the "
  },
  {
    "path": "Demo-System-Drawing/Demo-System-Drawing.csproj",
    "chars": 1056,
    "preview": "<Project Sdk=\"Microsoft.NET.Sdk\">\n\n  <PropertyGroup>\n    <OutputType>Exe</OutputType>\n    <TargetFramework>net8.0</Targe"
  },
  {
    "path": "Demo-System-Drawing/Demo-System-Drawing.sln",
    "chars": 1115,
    "preview": "\nMicrosoft Visual Studio Solution File, Format Version 12.00\n# Visual Studio Version 16\nVisualStudioVersion = 16.0.3061"
  },
  {
    "path": "Demo-System-Drawing/Program.cs",
    "chars": 770,
    "preview": "//\n// QR code generator library (.NET)\n// https://github.com/manuelbl/QrCodeGenerator\n//\n// Copyright (c) 2021 Manuel B"
  },
  {
    "path": "Demo-System-Drawing/QrCodeBitmapExtensions.cs",
    "chars": 10019,
    "preview": "//\n// QR code generator library (.NET)\n// https://github.com/manuelbl/QrCodeGenerator\n//\n// Copyright (c) 2021 Manuel B"
  },
  {
    "path": "Demo-System-Drawing/README.md",
    "chars": 351,
    "preview": "# Saving as PNG using System.Drawing\n\nThis example program shows how to create a QR code and save it as a PNG file using"
  },
  {
    "path": "Demo-VCard/Program.cs",
    "chars": 1804,
    "preview": "/* \n * QR code generator library (.NET)\n *\n * Copyright (c) Manuel Bleichenbacher (MIT License)\n * https://github.com/m"
  },
  {
    "path": "Demo-VCard/VCardDemo.csproj",
    "chars": 341,
    "preview": "<Project Sdk=\"Microsoft.NET.Sdk\">\n\n  <PropertyGroup>\n    <OutputType>Exe</OutputType>\n    <TargetFramework>net8.0</Targe"
  },
  {
    "path": "Demo-VCard/VCardDemo.sln",
    "chars": 1096,
    "preview": "\nMicrosoft Visual Studio Solution File, Format Version 12.00\n# Visual Studio Version 16\nVisualStudioVersion = 16.0.3170"
  },
  {
    "path": "Demo-WinForms/Demo-WinForms.csproj",
    "chars": 397,
    "preview": "<Project Sdk=\"Microsoft.NET.Sdk\">\n\n  <PropertyGroup>\n    <OutputType>WinExe</OutputType>\n    <TargetFramework>net8.0-wi"
  },
  {
    "path": "Demo-WinForms/Demo-WinForms.sln",
    "chars": 1103,
    "preview": "\nMicrosoft Visual Studio Solution File, Format Version 12.00\n# Visual Studio Version 17\nVisualStudioVersion = 17.0.3190"
  },
  {
    "path": "Demo-WinForms/Form1.Designer.cs",
    "chars": 7935,
    "preview": "//\n// QR code generator library (.NET)\n// https://github.com/manuelbl/QrCodeGenerator\n//\n// Copyright (c) 2021 Manuel B"
  },
  {
    "path": "Demo-WinForms/Form1.cs",
    "chars": 1333,
    "preview": "//\n// QR code generator library (.NET)\n// https://github.com/manuelbl/QrCodeGenerator\n//\n// Copyright (c) 2021 Manuel B"
  },
  {
    "path": "Demo-WinForms/Form1.resx",
    "chars": 2755,
    "preview": "<root>\n  <xsd:schema id=\"root\" xmlns=\"\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:msdata=\"urn:schemas-microsof"
  },
  {
    "path": "Demo-WinForms/Program.cs",
    "chars": 730,
    "preview": "//\n// QR code generator library (.NET)\n// https://github.com/manuelbl/QrCodeGenerator\n//\n// Copyright (c) 2021 Manuel Bl"
  },
  {
    "path": "Demo-WinForms/QrCodeBitmapExtensions.cs",
    "chars": 10019,
    "preview": "//\n// QR code generator library (.NET)\n// https://github.com/manuelbl/QrCodeGenerator\n//\n// Copyright (c) 2021 Manuel B"
  },
  {
    "path": "Demo-WinForms/QrCodeControl.cs",
    "chars": 3870,
    "preview": "//\n// QR code generator library (.NET)\n// https://github.com/manuelbl/QrCodeGenerator\n//\n// Copyright (c) 2021 Manuel B"
  },
  {
    "path": "Demo-WinForms/README.md",
    "chars": 316,
    "preview": "# Windows Forms example application\n\nThis example application shows how to use the QR code library in a Windows Forms ap"
  },
  {
    "path": "Demo-WinUI/Demo-WinUI/App.xaml",
    "chars": 850,
    "preview": "<!-- Swiss QR Bill Generator for .NET -->\n<!-- Copyright (c) 2022 Manuel Bleichenbacher -->\n<!-- Licensed under MIT Lice"
  },
  {
    "path": "Demo-WinUI/Demo-WinUI/App.xaml.cs",
    "chars": 1890,
    "preview": "//\n// Swiss QR Bill Generator for .NET\n// Copyright (c) 2022 Manuel Bleichenbacher\n// Licensed under MIT License\n// htt"
  },
  {
    "path": "Demo-WinUI/Demo-WinUI/Demo-WinUI.csproj",
    "chars": 3312,
    "preview": "<Project Sdk=\"Microsoft.NET.Sdk\">\n  <PropertyGroup>\n    <OutputType>WinExe</OutputType>\n    <TargetFramework>net8.0-win"
  },
  {
    "path": "Demo-WinUI/Demo-WinUI/MainViewModel.cs",
    "chars": 2068,
    "preview": "//\n// Swiss QR Bill Generator for .NET\n// Copyright (c) 2022 Manuel Bleichenbacher\n// Licensed under MIT License\n// htt"
  },
  {
    "path": "Demo-WinUI/Demo-WinUI/MainWindow.xaml",
    "chars": 3035,
    "preview": "<!-- Swiss QR Bill Generator for .NET -->\n<!-- Copyright (c) 2022 Manuel Bleichenbacher -->\n<!-- Licensed under MIT Lice"
  },
  {
    "path": "Demo-WinUI/Demo-WinUI/MainWindow.xaml.cs",
    "chars": 728,
    "preview": "//\n// Swiss QR Bill Generator for .NET\n// Copyright (c) 2022 Manuel Bleichenbacher\n// Licensed under MIT License\n// http"
  },
  {
    "path": "Demo-WinUI/Demo-WinUI/NativeMethods.txt",
    "chars": 16,
    "preview": "GetDpiForWindow\n"
  },
  {
    "path": "Demo-WinUI/Demo-WinUI/Package.appxmanifest",
    "chars": 1620,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n\n<Package\n  xmlns=\"http://schemas.microsoft.com/appx/manifest/foundation/windows"
  },
  {
    "path": "Demo-WinUI/Demo-WinUI/Properties/PublishProfiles/win-arm64.pubxml",
    "chars": 851,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\nhttps://go.microsoft.com/fwlink/?LinkID=208121.\n-->\n<Project ToolsVersion=\""
  },
  {
    "path": "Demo-WinUI/Demo-WinUI/Properties/PublishProfiles/win-x64.pubxml",
    "chars": 847,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\nhttps://go.microsoft.com/fwlink/?LinkID=208121.\n-->\n<Project ToolsVersion=\""
  },
  {
    "path": "Demo-WinUI/Demo-WinUI/Properties/PublishProfiles/win-x86.pubxml",
    "chars": 847,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\nhttps://go.microsoft.com/fwlink/?LinkID=208121.\n-->\n<Project ToolsVersion=\""
  },
  {
    "path": "Demo-WinUI/Demo-WinUI/Properties/launchSettings.json",
    "chars": 165,
    "preview": "{\n  \"profiles\": {\n    \"Demo-WinUI (Package)\": {\n      \"commandName\": \"MsixPackage\"\n    },\n    \"Demo-WinUI (Unpackaged)\":"
  },
  {
    "path": "Demo-WinUI/Demo-WinUI/QrCodeControl.xaml",
    "chars": 777,
    "preview": "<!-- Swiss QR Bill Generator for .NET -->\n<!-- Copyright (c) 2022 Manuel Bleichenbacher -->\n<!-- Licensed under MIT Lice"
  },
  {
    "path": "Demo-WinUI/Demo-WinUI/QrCodeControl.xaml.cs",
    "chars": 4255,
    "preview": "//\n// Swiss QR Bill Generator for .NET\n// Copyright (c) 2022 Manuel Bleichenbacher\n// Licensed under MIT License\n// http"
  },
  {
    "path": "Demo-WinUI/Demo-WinUI/QrCodeDrawing.cs",
    "chars": 3829,
    "preview": "//\n// Swiss QR Bill Generator for .NET\n// Copyright (c) 2022 Manuel Bleichenbacher\n// Licensed under MIT License\n// htt"
  },
  {
    "path": "Demo-WinUI/Demo-WinUI/app.manifest",
    "chars": 1293,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<assembly manifestVersion=\"1.0\" xmlns=\"urn:schemas-microsoft-com:asm.v1\">\n  <asse"
  },
  {
    "path": "Demo-WinUI/Demo-WinUI.sln",
    "chars": 2233,
    "preview": "\nMicrosoft Visual Studio Solution File, Format Version 12.00\n# Visual Studio Version 17\nVisualStudioVersion = 17.4.3312"
  },
  {
    "path": "Demo-WinUI/README.md",
    "chars": 510,
    "preview": "# WinUI 3 example application\n\nThis example application shows how to use the QR code library in a WinUI 3 application:\n\n"
  },
  {
    "path": "Demo-WindowsPresentationFoundation/App.xaml",
    "chars": 411,
    "preview": "<Application x:Class=\"Demo_WindowsPresentationFoundation.App\"\n             xmlns=\"http://schemas.microsoft.com/winfx/20"
  },
  {
    "path": "Demo-WindowsPresentationFoundation/App.xaml.cs",
    "chars": 410,
    "preview": "//\n// QR code generator library (.NET)\n// https://github.com/manuelbl/QrCodeGenerator\n//\n// Copyright (c) 2021 Manuel B"
  },
  {
    "path": "Demo-WindowsPresentationFoundation/AssemblyInfo.cs",
    "chars": 801,
    "preview": "//\n// QR code generator library (.NET)\n// https://github.com/manuelbl/QrCodeGenerator\n//\n// Copyright (c) 2021 Manuel Bl"
  },
  {
    "path": "Demo-WindowsPresentationFoundation/Demo-WindowsPresentationFoundation.csproj",
    "chars": 472,
    "preview": "<Project Sdk=\"Microsoft.NET.Sdk\">\n\n  <PropertyGroup>\n    <OutputType>WinExe</OutputType>\n    <TargetFramework>net8.0-wi"
  },
  {
    "path": "Demo-WindowsPresentationFoundation/Demo-WindowsPresentationFoundation.sln",
    "chars": 1145,
    "preview": "\nMicrosoft Visual Studio Solution File, Format Version 12.00\n# Visual Studio Version 17\nVisualStudioVersion = 17.0.3190"
  },
  {
    "path": "Demo-WindowsPresentationFoundation/MainWindow.xaml",
    "chars": 2422,
    "preview": "<Window x:Class=\"Net.Codecrete.QrCodeGenerator.Demo.MainWindow\"\n        xmlns=\"http://schemas.microsoft.com/winfx/2006/"
  },
  {
    "path": "Demo-WindowsPresentationFoundation/MainWindow.xaml.cs",
    "chars": 2507,
    "preview": "//\n// QR code generator library (.NET)\n// https://github.com/manuelbl/QrCodeGenerator\n//\n// Copyright (c) 2021 Manuel B"
  },
  {
    "path": "Demo-WindowsPresentationFoundation/QrCodeDrawing.cs",
    "chars": 6528,
    "preview": "//\n// QR code generator library (.NET)\n// https://github.com/manuelbl/QrCodeGenerator\n//\n// Copyright (c) 2021 Manuel B"
  },
  {
    "path": "Demo-WindowsPresentationFoundation/README.md",
    "chars": 394,
    "preview": "# Windows Presentation Foundation (WPF) example application\n\nThis example application shows how to use the QR code libra"
  },
  {
    "path": "Demo-WindowsPresentationFoundation/app.manifest",
    "chars": 684,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<assembly manifestVersion=\"1.0\" xmlns=\"urn:schemas-microsoft-com:asm.v1\">\n\t<asse"
  },
  {
    "path": "LICENSE",
    "chars": 1079,
    "preview": "MIT License\n\nCopyright (c) 2018 Manuel Bleichenbacher\n\nPermission is hereby granted, free of charge, to any person obtai"
  },
  {
    "path": "QrCodeGenerator/BitArrayExtensions.cs",
    "chars": 5901,
    "preview": "/* \n * QR code generator library (.NET)\n *\n * Copyright (c) Manuel Bleichenbacher (MIT License)\n * https://github.com/m"
  },
  {
    "path": "QrCodeGenerator/DataTooLongException.cs",
    "chars": 3348,
    "preview": "/* \n * QR code generator library (.NET)\n *\n * Copyright (c) Manuel Bleichenbacher (MIT License)\n * https://github.com/m"
  },
  {
    "path": "QrCodeGenerator/Graphics.cs",
    "chars": 11095,
    "preview": "/* \n * QR code generator library (.NET)\n *\n * Copyright (c) Manuel Bleichenbacher (MIT License)\n * https://github.com/m"
  },
  {
    "path": "QrCodeGenerator/Objects.cs",
    "chars": 2271,
    "preview": "/* \n * QR code generator library (.NET)\n *\n * Copyright (c) Manuel Bleichenbacher (MIT License)\n * https://github.com/m"
  },
  {
    "path": "QrCodeGenerator/PngBuilder.cs",
    "chars": 11913,
    "preview": "/* \n * QR code generator library (.NET)\n *\n * Copyright (c) Manuel Bleichenbacher (MIT License)\n * https://github.com/m"
  },
  {
    "path": "QrCodeGenerator/QrCode.cs",
    "chars": 54788,
    "preview": "/* \n * QR code generator library (.NET)\n *\n * Copyright (c) Manuel Bleichenbacher (MIT License)\n * https://github.com/m"
  },
  {
    "path": "QrCodeGenerator/QrCodeGenerator.csproj",
    "chars": 4217,
    "preview": "<Project Sdk=\"Microsoft.NET.Sdk\">\n\n  <PropertyGroup>\n    <TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>\n    "
  },
  {
    "path": "QrCodeGenerator/QrSegment.cs",
    "chars": 26746,
    "preview": "/* \n * QR code generator library (.NET)\n *\n * Copyright (c) Manuel Bleichenbacher (MIT License)\n * https://github.com/m"
  },
  {
    "path": "QrCodeGenerator/QrSegmentAdvanced.cs",
    "chars": 47960,
    "preview": "/* \n * QR code generator library (.NET)\n *\n * Copyright (c) Manuel Bleichenbacher (MIT License)\n * https://github.com/m"
  },
  {
    "path": "QrCodeGenerator/ReedSolomonGenerator.cs",
    "chars": 5888,
    "preview": "/* \n * QR code generator library (.NET)\n *\n * Copyright (c) Manuel Bleichenbacher (MIT License)\n * https://github.com/m"
  },
  {
    "path": "QrCodeGenerator/docfx/api/index.md",
    "chars": 5742,
    "preview": "# QR Code Generator for .NET\n\nOpen-source library for generating QR codes from text strings and byte arrays.\n\n\n## .NET A"
  },
  {
    "path": "QrCodeGenerator/docfx/docfx.json",
    "chars": 1019,
    "preview": "{\n  \"metadata\": [\n    {\n      \"src\": [\n        {\n          \"files\": [\n            \"**.csproj\"\n          ],\n          \"sr"
  },
  {
    "path": "QrCodeGenerator/docfx/index.md",
    "chars": 75,
    "preview": "# QR Code Generator for .NET\n\n[.NET Reference Documentation](api/index.md)\n"
  },
  {
    "path": "QrCodeGenerator/docs/README.md",
    "chars": 8297,
    "preview": "# QR Code Generator for .NET\n\nOpen-source library for generating QR codes from text strings and byte arrays.\n\nThe librar"
  },
  {
    "path": "QrCodeGenerator.sln",
    "chars": 1781,
    "preview": "\nMicrosoft Visual Studio Solution File, Format Version 12.00\n# Visual Studio Version 16\nVisualStudioVersion = 16.0.3142"
  },
  {
    "path": "QrCodeGeneratorTest/BitArrayExtensionsTest.cs",
    "chars": 2878,
    "preview": "/* \n * QR code generator library (.NET)\n *\n * Copyright (c) Manuel Bleichenbacher (MIT License)\n * https://github.com/m"
  },
  {
    "path": "QrCodeGeneratorTest/KanjiTest.cs",
    "chars": 3631,
    "preview": "/* \n * QR code generator library (.NET)\n *\n * Copyright (c) Manuel Bleichenbacher (MIT License)\n * https://github.com/m"
  },
  {
    "path": "QrCodeGeneratorTest/PngTest.cs",
    "chars": 1816,
    "preview": "/* \n * QR code generator library (.NET)\n *\n * Copyright (c) Manuel Bleichenbacher (MIT License)\n * https://github.com/m"
  },
  {
    "path": "QrCodeGeneratorTest/QrCodeBitmapTest.cs",
    "chars": 79457,
    "preview": "/* \n * QR code generator library (.NET)\n *\n * Copyright (c) Manuel Bleichenbacher (MIT License)\n * https://github.com/ma"
  },
  {
    "path": "QrCodeGeneratorTest/QrCodeDataProvider.cs",
    "chars": 593141,
    "preview": "/* \n * QR code generator library (.NET)\n *\n * Copyright (c) Manuel Bleichenbacher (MIT License)\n * https://github.com/m"
  },
  {
    "path": "QrCodeGeneratorTest/QrCodeGeneratorTest.csproj",
    "chars": 1304,
    "preview": "<Project Sdk=\"Microsoft.NET.Sdk\">\n\n  <PropertyGroup>\n    <TargetFrameworks>net6.0;net8.0</TargetFrameworks>\n    <Target"
  },
  {
    "path": "QrCodeGeneratorTest/QrCodeTest.cs",
    "chars": 2088,
    "preview": "/* \n * QR code generator library (.NET)\n *\n * Copyright (c) Manuel Bleichenbacher (MIT License)\n * https://github.com/m"
  },
  {
    "path": "QrCodeGeneratorTest/QrCodeTestCase.cs",
    "chars": 2831,
    "preview": "/* \n * QR code generator library (.NET)\n *\n * Copyright (c) Manuel Bleichenbacher (MIT License)\n * https://github.com/m"
  },
  {
    "path": "QrCodeGeneratorTest/QrSegmentEncodingTest.cs",
    "chars": 5892,
    "preview": "/* \n * QR code generator library (.NET)\n *\n * Copyright (c) Manuel Bleichenbacher (MIT License)\n * https://github.com/m"
  },
  {
    "path": "QrCodeGeneratorTest/QrSegmentRegexTest.cs",
    "chars": 2565,
    "preview": "/* \n * QR code generator library (.NET)\n *\n * Copyright (c) Manuel Bleichenbacher (MIT License)\n * https://github.com/m"
  },
  {
    "path": "QrCodeGeneratorTest/RandomData.cs",
    "chars": 2277,
    "preview": "/* \n * QR code generator library (.NET)\n *\n * Copyright (c) Manuel Bleichenbacher (MIT License)\n * https://github.com/m"
  },
  {
    "path": "QrCodeGeneratorTest/StructuredAppendTest.cs",
    "chars": 2385,
    "preview": "/* \n * QR code generator library (.NET)\n *\n * Copyright (c) Manuel Bleichenbacher (MIT License)\n * https://github.com/m"
  },
  {
    "path": "QrCodeGeneratorTest/SvgTest.cs",
    "chars": 3867,
    "preview": "/* \n * QR code generator library (.NET)\n *\n * Copyright (c) Manuel Bleichenbacher (MIT License)\n * https://github.com/m"
  },
  {
    "path": "QrCodeGeneratorTest/TestHelper.cs",
    "chars": 1920,
    "preview": "/* \n * QR code generator library (.NET)\n *\n * Copyright (c) Manuel Bleichenbacher (MIT License)\n * https://github.com/m"
  },
  {
    "path": "README.md",
    "chars": 7569,
    "preview": "# QR Code Generator for .NET\n\nOpen-source library for generating QR codes from text strings and byte arrays.\n\nThe librar"
  }
]

// ... and 1 more files (download for full content)

About this extraction

This page contains the full source code of the manuelbl/QrCodeGenerator GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 113 files (1.0 MB), approximately 334.0k tokens, and a symbol index with 293 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!