Silverlight

Jan 12, 2012 at 8:12 PM

...does it runs even on Silverlight 5?

Coordinator
Jan 13, 2012 at 12:16 AM

Hi Sandex. 

For Silverlight, as far as I understand that it doesn't support System.Drawing. So Renderer class under Controls won't work for Silverlight. But you can inspire from code inside renderer to create your own method that drawing 2D graphic under Silverlight. 

For Silverlight drawing 2D you might want to check this post:

http://stackoverflow.com/questions/8462193/silverlight-5-drawing-sprites

 

If you already familiar with drawing 2D graphic on Silverlight, you can simply use QrEncoder which it will return a bitMatrix for you. Where you just draw blank square for false and black square for true. Pretty simple. Also don't forget to draw quiet zone outside of matrix. Quiet zone is 2 module ~ 4 module wide around matrix. (One module = one bit variable inside bit matrix). 

Drawing algorithm is under Windows.Controls.Renderer.cs. Which you just grab from source code. 

BitMatrix will return bool value for each index, and it's square matrix (x: 0 ~ width ) (y: 0 ~ width). 

Hope that helps. Ask if you have further questions. 

 

Jason

Coordinator
Jan 13, 2012 at 12:24 AM
Edited Jan 13, 2012 at 12:35 AM

oh. Sorry. Another solution probably much more simpler. 

You can use Renderer.cs to create png image file, then put that file into your Silverlight Control. That should work for anything that can accept image file. 

Renderer.cs also has method for write image to stream. 

Silverlight just same as WPF is for UI design, main code should be still under C#. So just use C# to create image files for your Silverlight control, I think that will definitely work. 

Jan 13, 2012 at 5:05 AM

Hi.

Clear... i ll create a wcf service. my sl controllo Will call the service to get the rendered image eh eh it tooks less time....

Alberto

Il giorno 13/gen/2012 02:16, "Silverlancer" <notifications@codeplex.com> ha scritto:

From: Silverlancer

Hi Sandex.

For Silverlight, as far as I understand that it doesn't support System.Drawing. So Renderer class under Controls won't work for Silverlight. But you can inspire from code inside renderer to create your own method that drawing 2D graphic under Silverlight.

For Silverlight drawing 2D you might want to check this post:

http://stackoverflow.com/questions/8462193/silverlight-5-drawing-sprites

If you already familiar with drawing 2D graphic on Silverlight, you can simply use QrEncoder which it will return a bitMatrix for you. Where you just draw blank square for false and black square for true. Pretty simple. Also don't forget to draw quiet zone outside of matrix. Quiet zone is 2 module ~ 4 module wide around matrix. (One module = one bit variable inside bit matrix).

Drawing algorithm is under Windows.Controls.Renderer.cs. Which you just grab from source code.

BitMatrix will return bool value for each index, and it's square matrix (x: 0 ~ width ) (y: 0 ~ width).

Hope that helps. Ask if you have further questions.

Jason

Read the full discussion online.

To add a post to this discussion, reply to this email (QrCodeNet@discussions.codeplex.com)

To start a new discussion for this project, email QrCodeNet@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com

Coordinator
Jan 13, 2012 at 7:25 PM
Edited Jan 13, 2012 at 7:30 PM

Cool. It looks like you have found a way to deal with Silverlight. One thing I would like to remind you is size of image file. Width of each QrCode matrix is 17 + 4 * version.  So for version 1 matrix size will be 21 x 21 modules. Where version 40 will be 177 x 177 modules. Even though normally char number under 255 will be around version 1 to version 10. 

More detail I would suggest you to download QrCode specification at our main page. Scroll to page 42 under Adobe reader or page 34 on it's page corner.  Chapter 6.4.10 Table 7.   (PDF: ISO/IEC 18004:2006(E) )  Download link I will list below. 

http://www.codeplex.com/Download?ProjectName=QrCodeNet&DownloadId=321409

On that table you can have roughly idea about how many char you can store there and then give proximate Character to create image file to measure size. 

 

I might do some test later as well and create reference page for other developer.  

Edit: By the way. I did some research for creating 2D image for Silverlight. But same as what has been said from the link I provide earlier. Silverlight doesn't support 2D image. Shapes namespace under System.Windows.Media which is used by developer to create 2D shape. But they are all UIElement. Surely you don't want few hundred of them lay on your control just for a QrCode display. Use image file is best bet for now.

Jan 13, 2012 at 7:55 PM
Very Good! in the end... i've to put just a fixed url + a GUID...

the idea is to print a qrcode generated server side containing just a link to the product itself... and store all the data server side... so a guid of fixed size should be ok!

in this way the "stupid" client as a smart phone can open the product just opening the link, an other client can take the guid as KEY for further query on the product table....

...i'm trying to handling a small warehouse..... and i choose QR Code for labeling the incoming goods....

2012/1/13 Silverlancer <notifications@codeplex.com>

From: Silverlancer

Cool. It looks like you have found a way to deal with Silverlight. One thing I would like to remind you is size of image file. Width of each QrCode matrix is 17 + 4 * version. So for version 1 matrix size will be 21 x 21 modules. Where version 40 will be 177 x 177 modules. Even though normally char number under 255 will be around version 1 to version 10.

More detail I would suggest you to download QrCode specification at our main page. Scroll to page 42 under Adobe reader or page 34 on it's page corner. Chapter 6.4.10 Table 7. (PDF: ISO/IEC 18004:2006(E) ) Download link I will list below.

http://www.codeplex.com/Download?ProjectName=QrCodeNet&DownloadId=321409

On that table you can have roughly idea about how many char you can store there and then give proximate Character to create image file to measure size.

I might do some test later as well and create reference page for other developer.

Read the full discussion online.

To add a post to this discussion, reply to this email (QrCodeNet@discussions.codeplex.com)

To start a new discussion for this project, email QrCodeNet@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com


Coordinator
Jan 13, 2012 at 8:07 PM
Edited Jan 13, 2012 at 8:07 PM

I see. well I have just performed size test. I will post result here.

(output as png files)

Version 1: 2.55 kb

Version 5: 7.30 kb

Version 10: 15.9 kb

Version 20: 44.1 kb

Version 30: 86.6 kb

Version 40: 144 kb

Even though you will probably use up to version 15, but just an guide line I guess? :)

Also for your project, I think there won't be any source to damage your image, thus use lowest error correction level will do and you can store more data with smaller version. 

Jan 13, 2012 at 8:11 PM

can you send me a sample TO generate a qrcode containing ab url?

Alberto

Il giorno 13/gen/2012 22:07, "Silverlancer" <notifications@codeplex.com> ha scritto:

From: Silverlancer

I see. well I have just performed size test. I will post result here.

Version 1: 2.55 kb

Version 5: 7.30 kb

Version 10: 15.9 kb

Version 20: 44.1 kb

Version 30: 86.6 kb

Version 40: 144 kb

Even though you will probably use up to version 15, but just an guide line I guess? :)

Also for your project, I think there won't be any source to damage your image, thus use lowest error correction level will do and you can store more data with smaller version.

Read the full discussion online.

To add a post to this discussion, reply to this email (QrCodeNet@discussions.codeplex.com)

To start a new discussion for this project, email QrCodeNet@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com

Coordinator
Jan 13, 2012 at 9:00 PM
Edited Jan 13, 2012 at 9:01 PM

Take look at this page. 

http://code.google.com/p/zxing/wiki/BarcodeContents

It should well explain how to create url string for qrcode. 

Also check out Docomo's bookmark format. 

http://www.nttdocomo.co.jp/english/service/imode/make/content/barcode/function/application/bookmark/index.html

 

For basic url qrcode just include http//: string with your url. For example, 

--------------------

QrEncoder qrEncoder = new QrEncoder(ErrorCorrectionLevel.H);
QrCode qrCode = qrEncoder.Encode("http://qrcodenet.codeplex.com");

Renderer renderer = new Renderer(5, Brushes.Black, Brushes.White);
//You can also write as: Renderer renderer = new Renderer(5);  
//as default brushes already set up as black and white. 
//Create stream for WriteToStream method. then put into following method. 
renderer.WriteToStream(qrCode.Matrix, stream, ImageFormat.Png);
//Send stream to client side. 
----------------
Hope that helps.