Click here to Skip to main content
Licence CPOL
First Posted 20 Sep 2007
Views 610,659
Downloads 27,428
Bookmarked 221 times

Open Source QRCode Library

By twit88 | 20 Sep 2007
How to use QRCode library to encode and decode QRCode
1 vote, 1.6%
1

2
1 vote, 1.6%
3
6 votes, 9.5%
4
55 votes, 87.3%
5
4.92/5 - 63 votes
2 removed
μ 4.62, σa 1.08 [?]
Screenshot - qrcode_app_decode.jpg

Introduction

In this article, I will briefly describe the functionalities of the QRCode library.

Background

QRCode library is a .NET component that can be used to encode and decode QRCode. QRCode is a 2 dimensional bar code that originated in Japan. Nowadays, it is widely used in a wide range of industries, e.g. for vehicle parts tracking and inventory management.

QR stands for "Quick Response". It was created by the Japanese corporation Denso-Wave in 1994 and is aimed at decoding contents at high speed. Nowadays, QR Code is used in mobile phones to ease data entry.

QRCode can also be printed on a business card or shown on any display, which can then be captured by the mobile phone provided the mobile phone has the software to read QRCode.

QRCode library provides functions to:

  1. Encode content into a QR Code image which can be saved in JPEG, GIF, PNG, or Bitmap formats
  2. Decode a QR Code image

Using the Code

The library can be used in any .NET 2.0 Windows Application, ASP.NET Web application or Windows Mobile device application.

Some sample screenshots are displayed below:

Screenshot - qrcode_app_encode.jpg

Screenshot - qrcode_mobile_encode.jpg

  QRCodeEncoder qrCodeEncoder = new QRCodeEncoder();
            String encoding = cboEncoding.Text ;
            if (encoding == "Byte") {
                qrCodeEncoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE;
            } else if (encoding == "AlphaNumeric") {
                qrCodeEncoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.ALPHA_NUMERIC;            
            } else if (encoding == "Numeric") {
                qrCodeEncoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.NUMERIC;            
            }
            try {
                int scale = Convert.ToInt16(txtSize.Text);
                qrCodeEncoder.QRCodeScale = scale;
            } catch (Exception ex) {
                MessageBox.Show("Invalid size!");
                return;
            }
            try {
                int version = Convert.ToInt16(cboVersion.Text) ;
                qrCodeEncoder.QRCodeVersion = version;
            } catch (Exception ex) {
                MessageBox.Show("Invalid version !");
            }

            string errorCorrect = cboCorrectionLevel.Text;
            if (errorCorrect == "L")
                qrCodeEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.L;
            else if (errorCorrect == "M")
                qrCodeEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M;
            else if (errorCorrect == "Q")
                qrCodeEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.Q;
            else if (errorCorrect == "H")
                qrCodeEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.H;

            Image image;
            String data = txtEncodeData.Text;
            image = qrCodeEncoder.Encode(data);                      
            picEncode.Image = image;

History

  • 20th September, 2007: Initial post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

twit88

Web Developer

Malaysia Malaysia

Member
A programmer for a long time, and still learning everyday.
 
A supporter for open source solutions, and have written quite a few open source software both in .NET and Java.
 
Homepage
http://twit88.com/home
 
Blog
http://twit88.com/blog

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
Questionthere is problem in ER-encoding/decoding Pinmembervvsarma17:22 29 Jan '12  
SuggestionNew implementation for BCH (15,5) error correction PinmemberSergeyKS2:43 27 Jan '12  
BugReed Solomon error correction is not correct PinmemberSergeyKS2:37 27 Jan '12  
QuestionQR barcode generator Pinmembersteve7g21:06 19 Jan '12  
QuestionC# qrcode library PinmemberKeepDynamic4:45 12 Jan '12  
Questionvisual studio 2010 PinmemberBruno Rezio1:36 12 Jan '12  
AnswerRe: visual studio 2010 Pinmemberomar_chavez10:00 12 Jan '12  
QuestionImage complexity ?? PinmemberMember 77911834:56 23 Dec '11  
QuestionGreat code example. How to add image to centre of QR code? Pinmemberblarney9:51 19 Dec '11  
GeneralGreat work! PinmemberClayton Rumley9:41 15 Dec '11  
QuestionDecoder not working for character such as: é à PinmemberMember 84694665:32 8 Dec '11  
Question对中文的支持还是不够! PinmemberS.Sams21:47 22 Nov '11  
AnswerRe: 对中文的支持还是不够! PinmemberHsing_Yeh21:24 20 Dec '11  
QuestionMemoryStream memoryStream = new MemoryStream(Resources.GetResource(fileName)); PinmemberS.Sams21:46 22 Nov '11  
QuestionChanging the QR foreground colour Pinmemberrambasnet326:03 10 Nov '11  
SuggestionPerformance PinmemberHavardo23:35 12 Oct '11  
BugBug in BCH15_5.cs calcSyndrome(...) ? PinmemberSergeyKS23:23 11 Oct '11  
QuestionResources.GetResource? Pinmemberak165:12 5 Oct '11  
AnswerRe: Resources.GetResource? Pinmemberak165:40 5 Oct '11  
GeneralRe: Resources.GetResource? PinmemberChupmink8:35 5 Oct '11  
GeneralRe: Resources.GetResource? PinmemberSharafadeen1:08 18 Oct '11  
GeneralRe: Resources.GetResource? PinmemberS.Sams21:48 22 Nov '11  
QuestionGreat help Pinmembermaoflo10:42 3 Oct '11  
Questionwhat's the use of resources file "qrv#_#.dat","qrvfr.dat","rsc.dat"? Pinmembertingispig23:23 28 Sep '11  
AnswerRe: what's the use of resources file "qrv#_#.dat","qrvfr.dat","rsc.dat"? Pinmemberwvd_vegt0:45 31 Jan '12  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120202.1 | Last Updated 20 Sep 2007
Article Copyright 2007 by twit88
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid