Monday, April 25, 2011

Creating your own QR C# ASP.NET website generator...

Well there aren't a whole lot of examples of how to create your own...so I decided to post how to do it here.
For starters when I wanted to create my own QR Code generator in C# .NET I found sites like google that would do it all for you with the click of a link...but this didn't generate the image file. In some instances generating that image file is important since you may want to use it later on, for instance when customers are ordering business cards and they need to keep track of the QR Code image as well as what will be on the card.
So here is a nice library I found that is open source.
http://twit88.com/platform/projects/show/mt-qrcode
It is very simple to use and requires minor setting up. After creating an object of the QR Code library you just set a few values:

MessagingToolkit.QRCode.Codec.QRCodeEncoder QREncoder = new MessagingToolkit.QRCode.Codec.QRCodeEncoder();
QREncoder.QRCodeEncodeMode = MessagingToolkit.QRCode.Codec.QRCodeEncoder.ENCODE_MODE.BYTE;
QREncoder.QRCodeErrorCorrect = MessagingToolkit.QRCode.Codec.QRCodeEncoder.ERROR_CORRECTION.H;
QRCodeBitmap = QREncoder.Encode("http://xelot.blogspot.com");

QRCodeBitmap will now hold the bitmap you want to store to your HDD...with a simple saving...

System.IO.FileStream fs = new System.IO.FileStream("/QRCode.bmp",System.IO.FileMode.Create);
QRCodeBitmap.Save(fs, System.Drawing.Imaging.ImageFormat.Bmp);
fs.Close();

I hope this can help anyone to create their own C# ASP.NET website QR Code Generator.

1 comment:

  1. qr code control help developers build qr code generator in asp.net application,
    http://www.avapose.com/aspnet_barcode/qrcode_generator.shtml

    ReplyDelete