This project is read-only.

Size of QR Code Generated

Jan 4, 2016 at 5:34 PM
I am using the code below, the QR code is very small. If I set the picture box to stretch it is very blurry. How do I set the size of the QR code generated.



Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
    PictureBox1.Image = GenerateQRCode("http://google.com", Color.Black, Color.White)



End Sub



Private Function GenerateQRCode(URL As String, DarkColor As System.Drawing.Color, LightColor As System.Drawing.Color) As Bitmap
    Dim Encoder As New Gma.QrCodeNet.Encoding.QrEncoder(Gma.QrCodeNet.Encoding.ErrorCorrectionLevel.L)
    Dim Code As Gma.QrCodeNet.Encoding.QrCode = Encoder.Encode(URL)


    Dim TempBMP As New Bitmap(Code.Matrix.Width, Code.Matrix.Height)
    For X As Integer = 0 To Code.Matrix.Width - 1
        For Y As Integer = 0 To Code.Matrix.Height - 1
            If Code.Matrix.InternalArray(X, Y) Then TempBMP.SetPixel(X, Y, DarkColor) Else TempBMP.SetPixel(X, Y, LightColor)
        Next
    Next
    Return TempBMP
End Function
May 31, 2016 at 12:37 PM
paulseven wrote:
I am using the code below, the QR code is very small. If I set the picture box to stretch it is very blurry. How do I set the size of the QR code generated.



Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
    PictureBox1.Image = GenerateQRCode("http://google.com", Color.Black, Color.White)



End Sub



Private Function GenerateQRCode(URL As String, DarkColor As System.Drawing.Color, LightColor As System.Drawing.Color) As Bitmap
    Dim Encoder As New Gma.QrCodeNet.Encoding.QrEncoder(Gma.QrCodeNet.Encoding.ErrorCorrectionLevel.L)
    Dim Code As Gma.QrCodeNet.Encoding.QrCode = Encoder.Encode(URL)


    Dim TempBMP As New Bitmap(Code.Matrix.Width, Code.Matrix.Height)
    For X As Integer = 0 To Code.Matrix.Width - 1
        For Y As Integer = 0 To Code.Matrix.Height - 1
            If Code.Matrix.InternalArray(X, Y) Then TempBMP.SetPixel(X, Y, DarkColor) Else TempBMP.SetPixel(X, Y, LightColor)
        Next
    Next
    Return TempBMP
End Function
Did you found the solution for this? I am have same problem. It is creating image by 2121 pixel while I need to create it with custom size. E.g. 300300 pixels.