عکس ArdeshirV
QR Code GeneratorC#
موضوع‌ها
۰
فورک‌ها
۰
ستاره‌ها
۴
تاریخ ایجاد
۱۲ دی ۱۳۹۸
آخرین بروزرسانی
۱۲ ماه قبل
لایسنس
Other
# QR Code Generator for .NET

Source Code on My Github

Open-source library for generating QR codes from text strings and byte arrays.

The library is built for .NET Standard 2.0 and therefore runs on most modern .NET platforms (.NET Core, .NET Framework, Mono etc.).

It is mostly a translation of Project Nayuki's Java version of the QR code generator. The project provides implementations for many more programming languages, and the Project Nayuki web site has additional information about the implementation.

Features

Core features:

  • Supports encoding all 40 versions (sizes) and all 4 error correction levels, as per the QR Code Model 2 standard
  • Output formats: Raw modules/pixels of the QR symbol, SVG XML string, raster bitmap
  • Encodes numeric and special-alphanumeric text in less space than general text
  • Open source code under the permissive MIT License
  • Significantly shorter code but more documentation compared to competing libraries
  • available as a NuGet package (named Net.Codecrete.QrCodeGenerator)

Manual parameters:

  • You can specify the minimum and maximum version number allowed, and the library will automatically choose the smallest version in the range that fits the data.
  • You can specify the mask pattern manually, otherwise library will automatically evaluate all 8 masks and select the optimal one.
  • You can specify an error correction level, or optionally allow the library to boost it if it doesn't increase the version number.
  • You can create a list of data segments manually and add ECI segments.

Optional advanced features:

  • Encodes Japanese Unicode text in Kanji mode to save a lot of space compared to UTF-8 bytes
  • Computes optimal segment mode switching for text with mixed numeric/alphanumeric/general/kanji parts

Getting started

  1. Create a new Visual Studio project for .NET Core 2.x (File > New > Project... / Visual C# > .NET Core > Console App (.NET Core))

  2. Add the library via NuGet:

    Either via Project > Manage NuGet Packages... / Browse / search for qrcodegenerator / Install

    Or by running a command in the Package Manager Console

Install-Package Net.Codecrete.QrCodeGenerator -Version 1.5.0
  1. Add the code from the example below

  2. Run it

API Documention

See DocFX API Documentation

Examples

Simple operation

using Net.Codecrete.QrCodeGenerator;

namespace Examples
{
    class SimpleOperation
    {
        static void Main(string[] args)
        {
            var qr = QrCode.EncodeText("Hello, world!", QrCode.Ecc.Medium);
            using (var bitmap = qr.ToBitmap(4, 10))
            {
                bitmap.Save("qr-code.png", ImageFormat.Png);
            }
        }
    }
}

Manual operation

using Net.Codecrete.QrCodeGenerator;

namespace Examples
{
    class ManualOperation
    {
        static void Main(string[] args)
        {
            var segments = QrCode.MakeSegments("3141592653589793238462643383");
            var qr = QrCode.EncodeSegments(segments, QrCode.Ecc.High, 5, 5, 2, false);
            for (int y = 0; y < qr.Size; y++)
            {
                for (int x = 0; x < qr.Size; x++)
                {
                    ... paint qr.GetModule(x,y) ...
                }
            }
        }
    }
}

Requirements

QR Code Generator for .NET requires a .NET implementation compatible with .NET Standard 2.0 or higher, i.e. any of:

  • .NET Framework 2.0 or higher & C# 2.0 and higher

Raster Images

For generating raster images, the System.Drawing library is used. On Linux and macOS, it depends on the native shared library GDIPlus, which must be separatley installed.

macOS:

brew install mono-libgdiplus

Linux

sudo apt-get install libgdiplus

For troubleshooting, check Mono's GDIPlusInit page.

ArdeshirV Changes

This project is a downgrade of QrCodeGenerator for C# 2.0. You can find original project and more information here about latest changes

Copyright Manuel Bleichenbacher & Project Nayuki & ArdeshirV@protonmail.com, Licensed under MIT

پروژه‌های مشابه

عکس mehdihadeli
mehdihadeli/ecommerce-modular-monolith-sample

🪣 A practical e-commerce modular monolith sample, built with .Net Core, Domain-Driven Design, CQRS, Vertical Slice Architecture, Event-Driven Architecture, and the latest technologies.

۴۳
۵
۱
C#
عکس bitfoundation
bitfoundation/bitplatform

Home for C# .NET developers! ❤ Let's build public web sites, progressive web apps, android, iOS and Windows apps using bit platform!

۲۴۵
۹۰
۱۰۱
C#
عکس mehdihadeli
mehdihadeli/ecommerce-microservices-sample

🛍️ A practical e-commerce microservices sample, built with C#, .Net Core, Domain-Driven Design, CQRS, Vertical Slice Architecture, Event-Driven Architecture, and the latest technologies.

۱۸۷
۱۳
۱۲
C#
عکس meysamhadeli
meysamhadeli/awesome-dotnet-tips

List of awesome tips and tricks, resources, videos and articles in .net, software architecture, microservice and cloud-native

۱۳۳
۸۹
۰
C#
عکس hamed-shirbandi
hamed-shirbandi/TaskoMask

Task management application based on .NET 6 with DDD, CQRS, Event Sourcing and Testing Concepts

۳۷۹
۷۴
۰
C#
عکس imaun
imaun/pardakhtyari

کتابخانه ها و مستندات مربوط به روال پرداخت یاری شاپرک - طبق مستندات رسمی شاپرک

۲۲
۷
۱
C#
عکس GamEditor
GamEditor/Ballz-Brick-Breaker-Unity

A clone of "Swipe Brick Breaker" made with Unity

۱۵
۵
۰
C#
عکس meysamhadeli
meysamhadeli/booking-microservices-sample

Booking Microservices is a Sample application for booking ticket. This application based on different software architecture and technologies like .Net Core, CQRS, DDD, Vertical Slice Architecture, Docker, kubernetes, tye, masstransit, RabbitMQ, Grpc, yarp...

۲۴۸
۳۳
۳
C#