Steeltype.QRCoderLite 1.0.0

dotnet add package Steeltype.QRCoderLite --version 1.0.0                
NuGet\Install-Package Steeltype.QRCoderLite -Version 1.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Steeltype.QRCoderLite" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Steeltype.QRCoderLite --version 1.0.0                
#r "nuget: Steeltype.QRCoderLite, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Steeltype.QRCoderLite as a Cake Addin
#addin nuget:?package=Steeltype.QRCoderLite&version=1.0.0

// Install Steeltype.QRCoderLite as a Cake Tool
#tool nuget:?package=Steeltype.QRCoderLite&version=1.0.0                

QRCoderLite

Info

QRCoderLite is a simple library, written in C#.NET, which enables you to create QR codes. It is a derivative of the popular QRCoder (https://github.com/codebude/QRCoder) library, and QRCoderLite aims for a smaller and easier to audit footprint, limited functionality, and net8 compatibility. Unlike QRCoder, it depends on the Mono SkiaSharp library (https://github.com/mono/SkiaSharp) for platform-specific graphics implementations.

Please be forewarned that this project will receive limited support and may be out-of-date in the near future. However, the project is intended to be a minimal implementation that will be easier to port to new frameworks in the future.

As with the original QRCoder library, please feel free to grab-up/fork the project and make it better!

QRCoderLite is a project by Steeltype LLC in February 2024 under the BSD-3-Clause license. The original QRCoder library from which it is derived is under the MIT license courtesy of Raffael Herrmann.


Usage

You only need four lines of code, to generate and view your first QR code.

QRCodeGenerator qrGenerator = new QRCodeGenerator();
QRCodeData qrCodeData = qrGenerator.CreateQrCode("The text which should be encoded.", QRCodeGenerator.ECCLevel.Q);
QRCode qrCode = new QRCode(qrCodeData);
Bitmap qrCodeImage = qrCode.GetGraphic(20);

Optional parameters and overloads

The GetGraphics-method has some more overloads. The first two enable you to set the color of the QR code graphic. One uses Color-class-types, the other HTML hex color notation.

//Set color by using Color-class types
Bitmap qrCodeImage = qrCode.GetGraphic(20, Color.DarkRed, Color.PaleGreen, true);

//Set color by using HTML hex color notation
Bitmap qrCodeImage = qrCode.GetGraphic(20, "#000ff0", "#0ff000");

The other overload enables you to render a logo/image in the center of the QR code.

Bitmap qrCodeImage = qrCode.GetGraphic(20, Color.Black, Color.White, (Bitmap)Bitmap.FromFile("C:\\myimage.png"));

There are a plenty of other options. So feel free to read more on that in our wiki: Wiki: How to use QRCoder

Special rendering types

Besides the normal QRCode class (which is shown in the example above) for creating QR codes in Bitmap format, there are some more QR code rendering classes, each for another special purpose.

Note: Please be aware that not all renderers are available on all target frameworks. Please check the compatibility table in our wiki, to see if a specific renderer is available on your favourite target framework.

For more information about the different rendering types click on one of the types in the list above or have a look at: Wiki: Advanced usage - QR-Code renderers

PayloadGenerator.cs - Generate QR code payloads

Technically QR code is just a visual representation of a text/string. Nevertheless most QR code readers can read "special" QR codes which trigger different actions.

For example: WiFi-QRcodes which, when scanned by smartphone, let the smartphone join an access point automatically.

This "special" QR codes are generated by using special structured payload string, when generating the QR code. The PayloadGenerator.cs class helps you to generate this payload strings. To generate a WiFi payload for example, you need just this one line of code:

PayloadGenerator.WiFi wifiPayload = new PayloadGenerator.WiFi("MyWiFi-SSID", "MyWiFi-Pass", PayloadGenerator.WiFi.Authentication.WPA);

To generate a QR code from this payload, just call the "ToString()"-method and pass it to the QRCoder.

//[...]
QRCodeData qrCodeData = qrGenerator.CreateQrCode(wifiPayload.ToString(), QRCodeGenerator.ECCLevel.Q);
//[...]

You can also use overloaded method that accepts Payload as parameter. Payload generator can have QR Code Version set (default is auto set), ECC Level (default is M) and ECI mode (default is automatic detection).

//[...]
QRCodeData qrCodeData = qrGenerator.CreateQrCode(wifiPayload);
//[...]

Or if you want to override ECC Level set by Payload generator, you can use overloaded method, that allows setting ECC Level.

//[...]
QRCodeData qrCodeData = qrGenerator.CreateQrCode(wifiPayload, QRCodeGenerator.ECCLevel.Q);
//[...]

You can learn more about the payload generator in our Wiki.

The PayloadGenerator supports the following types of payloads:

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 595 2/10/2024

Initial Release