32 Comments

QR Code on a buildingHave you ever seen QR codes? QR means Quick Response. It’s has a Japanese origin. Created by Toyota initially to track car parts during manufacturing.

These days it’s getting more popular each day because of the mobile internet and the increase of maturity among mobile operating systems. Almost each mobile operating system has one or several QR Code scanners enabling the consumer to ‘mobile tag’.

[more]

 

Here is a simple workflow of mobile tagging:

 

Workflow of Mobile Tagging

Now there is this old post from 2007 about a .Net QRCode library here: http://twit88.com/home/opensource/qrcode 

But I have found this updated and extended version here:

http://twit88.com/platform/projects/show/mt-qrcode

Their last update is from 18 April 2010. So I grabbed their 1.1.0.0 version and installed it.

After installation I copied the DLL MessagingToolkit.QRCode.dllfrom

C:\Program Files (x86)\MessagingToolkit\MessagingToolkit-QRCode\QRCode\

to my Bin directory of my Asp.Net C# project and referenced it. Please note that the DLL is quite large; it’s over 6 MB.

Now you can generate a tag easily with:

string yoururl = "http://www.jphellemons.nl";
MessagingToolkit.QRCode.Codec.QRCodeEncoder qe = new MessagingToolkit.QRCode.Codec.QRCodeEncoder();
System.Drawing.Bitmap bm = qe.Encode(yoururl);

 

I made an handler (.ashx) for it so that I can get QR codes by placing this html

<img src="GetQRCode.ashx?code=abcdefghijk" alt="the code" />

on my website and use the following in my ashx:

public void ProcessRequest (HttpContext context) {
    string prodCode = context.Request.QueryString.Get("code");
    context.Response.ContentType = "image/gif";
    if (prodCode.Length > 0)
    {
        MessagingToolkit.QRCode.Codec.QRCodeEncoder qe = new MessagingToolkit.QRCode.Codec.QRCodeEncoder();
        System.Drawing.Bitmap bm = qe.Encode("http://www.yourdomain.com/product.aspx?code=" + prodCode);
        bm.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif);
    }   
}

The possibilities are endless now that you can generate QR codes. You can provide the marketing department of QR codes which they can embed on posters they spread on the streets enabling customers to scan and go to your specific offer landings page.

Happpy mobile tagging!


kick it on DotNetKicks.comShout it

 

Calvin Klein's QR Code in New York

Edit 12 April 2012: I have received an email from Reynoldo who told me that the twit88.com website is down. So you can download the DLL here now, it's almost 6mb: MessagingToolkit.QRCode.dll (5.91 mb)

Edit 18 April 2012: The 1.3.0 package is now available on NuGet

Pin on pinterest Plus on Googleplus Post on LinkedIn

Comments

Comment by DaviD

This pointed me to the right direction, but how did you managed to add the DLL?! In my site keeps telling me "missing the assembly?" error, it's driving me nuts.

DaviD
Comment by DaviD

Thanks a lot this really helped me a lot! great example by the way!

DaviD
Comment by isaac

what standar iso use this library?

isaac
Comment by isaac

as feedback supports the standard ISO / IEC 18004:2006

isaac
Comment by Ariel

Hi, if you are using the library on .net dont forguet sign the assembly before compile it!!!!

Ariel
Comment by capsoft

@mbielski Thanks for pointing that out! it's a new release from this month :)

capsoft
Comment by TonyB

Nice one, thanks!

And in VB:

Imports MessagingToolkit
Protected Sub btnEncodeURL_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnEncodeURL.Click

Dim urlToEncode As String = ""
Dim QRImagePath As String = "E:\QRImages\"
Dim QRImageName As String = "qr.gif"

urlToEncode = txtURLToEncode.Text.Trim '// user enters URL

Dim qe As New MessagingToolkit.QRCode.Codec.QRCodeEncoder()
qe.QRCodeForegroundColor = System.Drawing.ColorTranslator.FromHtml("#003153")
Dim bm As System.Drawing.Bitmap = qe.Encode(urlToEncode)
bm.Save(QRImagePath & QRImageName, System.Drawing.Imaging.ImageFormat.Gif)

imgQRCode.ImageUrl = "/qrimages/qr.gif"

bm = Nothing

End Sub

TonyB
Comment by JP Hellemons

Thanks Tony for the VB code!

JP Hellemons
Comment by Gaston

Hi to all... Can you upload any example to decode a qr image and enconde a qr image?...

Gaston
Comment by Mauricio

Thanks man!! This is usefull... but i've found a problem... that library only accepts 122 characters... Do you have any idea of why is this happening?

Mauricio
Comment by JP Hellemons

@Mauricio, do you mean that the input string cannot be longer then 122? you can always file issues at the project page: twit88.com/platform/projects/mt-qrcode/issues

@mike, Its on the second link. You can customize it with photoshop or gimp. just try stuff with different layers and test it a lot with a decent scanner on your mobile phone.

JP Hellemons
Comment by Hany Nasyr

Can you please Show how to decode a qr code image?

Hany Nasyr
Comment by Steve

How do you control the options like size under c# as a .net sample? I've used the default ashx example fine, now I want to specify some options to be passed in.

Any examples about?

Steve
Comment by sathish chandran

Hai Friends,

Im doing my final year project. I'm using asp.net as front end and sql server as back end. I implemented qrcode generator using MessagingToolkit.dll file to generate qrcode for a particular number. In my project i have to take a printout that qrcode image and i have to scan it using my webcam. I searched code for qrcode scanner, but i didn't get. So Please tell me,

1)how to scan a qrcode using asp.net
2)Is there any way to integrate any other qrcode scanner software with asp.net
3)If yes, please tell me the procedure to do that.


Thanks in Advance.

sathish chandran
Comment by Sam

Is there any support for eps or svg? QR Codes are meant to be printed in all sizes and this should be an option.

Sam
Comment by JP Hellemons

QR codes for Asp.Net with NuGet

QR codes for Asp.Net with NuGet

Comment by Nikk

Hi there fellows!
Im pretty bad in C# so pls apologize my noobines if contained...

i did everything u did till/and with ur first code example.
The code doesnt show me any mistakes and i can generate my website, but where is the QR-Code?

like i said up 2 here: (ur code)

string yoururl = "http://www.jphellemons.nl";;
MessagingToolkit.QRCode.Codec.QRCodeEncoder qe = new MessagingToolkit.QRCode.Codec.QRCodeEncoder();
System.Drawing.Bitmap bm = qe.Encode(yoururl);

what do i have 2 do now so i can open the qr-code?

Nikk
Comment by Shakishi

hi JP Hellemons,

How can I stored the decode image of qr code in database using c# in asp.net
Once I generate it.
The scenario is (I'm creating a online registration using asp.net and c#, after the submit, you must send a confirmation with the qrcode generate) How can I stored it in the database

Shakishi
Comment by JP Hellemons

Well you have your Bitmap now, You can save it to your harddisk :)

JP Hellemons
Comment by JP Hellemons

I would store the text you want to decode in the database and/or a filename as reference to the file on disk which contains the image(bitmap)

JP Hellemons
Comment by JP Hellemons

The only downside is that it will cost you about a thousand dollars for a 2d barcode control. Don't you have a discount for the readers of this blog?

JP Hellemons
Comment by Symbol Barcode Reader

I blog often and I truly thank you for your content. This great article has really peaked my interest. I will take a note of your blog and keep checking for new details about once a week. I subscribed to your Feed as well.

my website ... Symbol Barcode Reader - http://symbolbarcodereader.blogspot.com

Symbol Barcode Reader
Comment by Md.ibrahim

This is a very nice library. Thanks for the tutorial. But could you please tell me how I can define the dimensions of the qr code image being generated?

Md.ibrahim
Comment by com-lab.biz

Pingback from com-lab.biz

.NET MessagingToolkit QRCode Encode Issue | User18

Comment by com-lab.biz

Pingback from com-lab.biz

.NET MessagingToolkit QRCode Encode Issue | User18