''*****************************************************************
'' .NET Standard QR-Code Font Encoder Version 2024
'' © Copyright 2024 IDAutomation.com, Inc. All rights reserved.
'' USA Patent 7,637,436
'' 
'' To provide the quickest implementation, consider
'' licensing this product instead of using the demo.
'' The licensed version is provided with a 30 day
'' money back satisfaction guarantee.
'' To order, please visit:
'' https://www.idautomation.com/
'' 
''*****************************************************************
'' Limitations of the Demo Version:
'' The demo version of this product includes a fully
'' functional 2D font and is designed only for the
'' purpose of testing the font in various applications
'' and point sizes. To generate dynamic symbols,
'' a font encoder is required to format the data being
'' encoded into the 2D symbol.
'' Only static data can be provided for the encoders
'' in the demo version, because providing a working
'' encoder would reveal the complete source code,
'' which is only available in the licensed version.
'' 
''*****************************************************************
''
'' Please refer to the User Manual and Included Examples
'' https://www.idautomation.com/barcode-components/dotnet-standard/
''
''*****************************************************************



Imports System.Text

Public Class QRCode

    '' <summary>
    '' Function, which creates an array of bytes, representation of raster QR-Code's image, depending on the various input options chosen. 
    '' </summary>
    '' <param name="DataToEncode">The data that Is encoded in the barcode.</param>
    '' <param name="ApplyTilde">Enables processing of tilde And parentheses characters for purposes of encoding ASCII functions And GS1 application identifiers.</param>
    '' <param name="EncodingMode">Various modes used to Data represented in the symbol may be encoded by one of these types.</param>
    '' <param name="Version">Represents the various sizes of the symbol.</param>
    '' <param name="ErrorCorrectionLevel">Four levels of Reed-Solomon error correction, which allow verification of data And recovery in the event that part of the symbol Is physically damaged.</param>
    '' <param name="BestMask">Use a best mask for pattern in the QRCode.</param>
    '' <param name="QuietZone">Define the size of a blank zone around the code.</param>
    '' <param name="ModuleSize">Define the size of each module in pixels.</param>
    '' <returns>Byte array for use with a picturebox.</returns>
    Public Function EncodeQR(DataToEncode As String, Optional ApplyTilde As Boolean = True, Optional EncodingMode As EncodingModes = EncodingModes.Bytes, Optional Version As Versions = Versions.AUTO, Optional ErrorCorrectionLevel As ErrorCorrectionLevels = ErrorCorrectionLevels.M, Optional BestMask As Boolean = True, Optional QuietZone As Integer = 2, Optional ModuleSize As Integer = 1)

        Dim Size As Integer = 21
        Dim mvarFinal(,) As Integer = {
             {1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1},
             {1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1},
             {1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1},
             {1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1},
             {1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1},
             {1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1},
             {1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1},
             {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
             {1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1},
             {0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1},
             {1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0},
             {1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1},
             {0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1},
             {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1},
             {1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0},
             {1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1},
             {1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1},
             {1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0},
             {1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1},
             {1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1},
             {1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1}
            }

        Dim Result As Byte()
        Dim k As Integer = 0
        Dim intPad As Integer = 0
        Dim pixels As Integer = 0
        Dim bit As Integer = 0
        Dim bWidth As Integer = 0
        Dim x As Integer
        Dim y As Integer
        Dim m As Integer
        Dim l As Integer

        bWidth = (Math.Floor((Size * ModuleSize) / 8) + (If((Size * ModuleSize) Mod 8 > 0, 1, 0)))
        Dim intTemp As Integer = bWidth Mod 4
        If (intTemp <> 0) Then
            intPad = 4 - intTemp
        End If

        ReDim Result(64 + Size * ModuleSize * (bWidth + intPad) - 1)


        Result(0) = &H42
        Result(1) = &H4D
        For k = 0 To 7
            Result(2 + k) = 0
        Next
        Result(10) = &H3E
        For k = 0 To 2
            Result(11 + k) = 0
        Next
        Result(14) = &H28
        For k = 0 To 2
            Result(15 + k) = 0
        Next

        '' width
        Result(18) = CByte(Math.Floor((Size * ModuleSize) Mod 256))
        Result(19) = CByte(Math.Floor((Size * ModuleSize) / 256))
        Result(20) = 0
        Result(21) = 0

        '' height
        Result(22) = Result(18)
        Result(23) = Result(19)
        Result(24) = 0
        Result(25) = 0

        Result(26) = 1
        Result(27) = 0
        Result(28) = 1
        Result(29) = 0
        For k = 0 To 7
            Result(30 + k) = 0
        Next
        Result(38) = &H25
        Result(39) = &HE
        Result(40) = 0
        Result(41) = 0

        Result(42) = &H25
        Result(43) = &HE
        Result(44) = 0
        Result(45) = 0

        For k = 0 To 7
            Result(46 + k) = 0
        Next

        For k = 0 To 2
            Result(54 + k) = &HFF
        Next
        For k = 0 To 4
            Result(57 + k) = 0
        Next

        Dim pos As Integer = 62

        For y = Size - 1 To 0 Step -1

            For m = 0 To ModuleSize - 1

                pixels = 0
                bit = 8

                For x = 0 To Size - 1
                    If ((mvarFinal(x, y) <> 0)) Then
                        For l = 0 To ModuleSize - 1
                            bit = bit - 1
                            pixels = pixels + Math.Floor(Math.Pow(2, bit))
                            If (bit = 0) Then
                                Result(pos) = CByte(pixels)
                                pos += 1
                                bit = 8
                                pixels = 0
                            End If
                        Next

                    Else
                        For l = 0 To ModuleSize - 1
                            bit = bit - 1
                            If (bit = 0) Then
                                Result(pos) = CByte(pixels)
                                pos += 1
                                bit = 8
                                pixels = 0
                            End If
                        Next

                    End If
                Next
                If (bit <> 8) Then
                    Result(pos) = CByte(pixels)
                    pos += 1
                End If
                pos = pos + intPad
            Next
        Next

        Return Result


    End Function

    '' <summary>
    '' Function, which creates a string, representation of SVG QR-Code's image, depending on the various input options chosen. 
    '' </summary>
    '' <param name="DataToEncode">The data that Is encoded in the barcode.</param>
    '' <param name="ApplyTilde">Enables processing of tilde And parentheses characters for purposes of encoding ASCII functions And GS1 application identifiers.</param>
    '' <param name="EncodingMode">Various modes used to Data represented in the symbol may be encoded by one of these types.</param>
    '' <param name="Version">Represents the various sizes of the symbol.</param>
    '' <param name="ErrorCorrectionLevel">Four levels of Reed-Solomon error correction, which allow verification of data And recovery in the event that part of the symbol Is physically damaged.</param>
    '' <param name="BestMask">Use a best mask for pattern in the QRCode.</param>
    '' <param name="VectorType">Define the type of vector image for output.</param>
    '' <param name="NewLine">String indicating EOL character. Defaults to the operating system EOL character if left NULL.</param>
    '' <param name="QuietZone">Define the size of a blank zone around the code.</param>
    '' <param name="ModuleSize">Define the size of each module.</param>
    '' <returns>Encoded text for use with the 2D barcode font.</returns>
    Public Function EncodeQR(DataToEncode As String, Optional ApplyTilde As Boolean = True, Optional EncodingMode As EncodingModes = EncodingModes.Bytes, Optional Version As Versions = Versions.AUTO, Optional ErrorCorrectionLevel As ErrorCorrectionLevels = ErrorCorrectionLevels.M, Optional BestMask As Boolean = True, Optional VectorType As VectorTypes = VectorTypes.VecEPS, Optional NewLine As String = "", Optional QuietZone As Integer = 2, Optional ModuleSize As Integer = 2)

        Dim Size As Integer = 21
        Dim mvarFinal(,) As Integer = {
             {1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1},
             {1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1},
             {1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1},
             {1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1},
             {1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1},
             {1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1},
             {1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1},
             {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
             {1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1},
             {0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1},
             {1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0},
             {1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1},
             {0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1},
             {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1},
             {1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0},
             {1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1},
             {1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1},
             {1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0},
             {1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1},
             {1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1},
             {1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1}
            }
        '' allows user to set an end-of-line (EOL) string
        If (NewLine = "") Then
            NewLine = Environment.NewLine '' Default
        End If
        Dim mvarNewLine As String = NewLine

        Dim strOut As StringBuilder = New StringBuilder("")
        Dim temp As String = ""
        Dim x As Integer
        Dim y As Integer

        ModuleSize = ModuleSize * 4
        temp = (Size * ModuleSize).ToString()

        If (VectorType = VectorTypes.VecSVG) Then

            strOut.Append("<?xml version='1.0' standalone='no'?>" + mvarNewLine)
            strOut.Append("<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'>" + mvarNewLine)
            strOut.Append("<svg width='" + temp + "' height='" + temp + "' version='1.1' xmlns='http://www.w3.org/2000/svg'>" + mvarNewLine)
            strOut.Append("  <g id='qrcode'>" + mvarNewLine)
            strOut.Append("    <g id='background' fill='#ffffff' stroke='#ffffff'>" + mvarNewLine)
            strOut.Append("      <rect x='0' y='0' width='" + temp + "' height='" + temp + "' />" + mvarNewLine)
            strOut.Append("    </g>" + mvarNewLine)
            strOut.Append("    <g id='pattern' fill='#000000' stroke='#000000'>" + mvarNewLine)

            For y = 0 To Size - 1
                For x = 0 To Size - 1
                    If (mvarFinal(x, y) <> 0) Then
                        strOut.Append("    <g id='R" + y.ToString() + "C" + x.ToString() + "' >" + mvarNewLine)
                        strOut.Append("      <rect x='" + (x * ModuleSize).ToString() + "' y='" + (y * ModuleSize).ToString() + "' width='" + (ModuleSize).ToString() + "' height='" + (ModuleSize).ToString() + "' />" + mvarNewLine)
                        strOut.Append("    </g>" + mvarNewLine)
                    End If
                Next
            Next
            strOut.Append("    </g>" + mvarNewLine)
            strOut.Append("  </g>" + mvarNewLine)
            strOut.Append("</svg>" + mvarNewLine)

        ElseIf (VectorType = VectorTypes.VecEPS) Then
            strOut.Append("%!PS-Adobe-3.0 EPSF-3.0" + mvarNewLine)
            strOut.Append("%%Creator: IDAutomation.com" + mvarNewLine)
            strOut.Append("%%Title: qrcode" + mvarNewLine)
            strOut.Append("%%CreationDate: " + DateTime.Now.ToString("ddd mmm d hh:mm:ss yyyy") + mvarNewLine)
            strOut.Append("%%BoundingBox: 0 0 " + temp + " " + temp + mvarNewLine)
            strOut.Append("%%DocumentData: Clean7Bit" + mvarNewLine)
            strOut.Append("%%EndComments" + mvarNewLine)
            strOut.Append("%%BeginProlog" + mvarNewLine)
            strOut.Append("/bd { bind def } bind def" + mvarNewLine)
            strOut.Append("/incompound false def" + mvarNewLine)
            strOut.Append("/m { moveto } bd" + mvarNewLine)
            strOut.Append("/l { lineto } bd" + mvarNewLine)
            strOut.Append("/*U { /incompound false def f} bd" + mvarNewLine)
            strOut.Append("/k { setcmykcolor } bd" + mvarNewLine)

            strOut.Append("/c { curveto } bd" + mvarNewLine)
            strOut.Append("/F { incompound not {fill} if } bd" + mvarNewLine)
            strOut.Append("/f { closepath F } bd" + mvarNewLine)
            strOut.Append("/S { stroke } bd" + mvarNewLine)
            strOut.Append("/*u { /incompound true def } bd" + mvarNewLine)
            strOut.Append("/K { k } bd" + mvarNewLine)

            strOut.Append("%%EndProlog" + mvarNewLine)
            strOut.Append("%%BeginSetup" + mvarNewLine)
            strOut.Append("%%EndSetup" + mvarNewLine)
            strOut.Append("0.000 0.000 0.000 0.000 k" + mvarNewLine)
            strOut.Append("0 0 m" + mvarNewLine)
            strOut.Append("0 0 l" + mvarNewLine)
            strOut.Append(temp + " 0 l" + mvarNewLine)
            strOut.Append(temp + " " + temp + " l" + mvarNewLine)
            strOut.Append("0 " + temp + " l" + mvarNewLine)
            strOut.Append("f" + mvarNewLine)
            strOut.Append("*U" + mvarNewLine)

            Dim n As Integer = Size * ModuleSize
            strOut.Append("0.000 0.000 0.000 1.000 k" + mvarNewLine)
            For y = 0 To Size - 1
                For x = 0 To Size - 1
                    If (mvarFinal(x, y) <> 0) Then
                        strOut.Append((x * ModuleSize).ToString() + " " + (n - y * ModuleSize).ToString() + " m" + mvarNewLine)
                        strOut.Append((x * ModuleSize).ToString() + " " + (n - y * ModuleSize).ToString() + " l" + mvarNewLine)
                        strOut.Append(((x + 1) * ModuleSize).ToString() + " " + (n - y * ModuleSize).ToString() + " l" + mvarNewLine)
                        strOut.Append(((x + 1) * ModuleSize).ToString() + " " + (n - (y + 1) * ModuleSize).ToString() + " l" + mvarNewLine)
                        strOut.Append(((x) * ModuleSize).ToString() + " " + (n - (y + 1) * ModuleSize).ToString() + " l" + mvarNewLine)
                        strOut.Append("f" + mvarNewLine)
                    End If
                Next
            Next

            strOut.Append("*U" + mvarNewLine)
            strOut.Append("%%Trailer" + mvarNewLine)
            strOut.Append("%%EOF" + mvarNewLine)

        ElseIf (VectorType = VectorTypes.VecHTML) Then
            strOut.Append("<div style='font-size:0;background-color:#ffffff;position:relative;width:" + temp + "px;height:" + temp + "px;'>" + mvarNewLine)
            For y = 0 To Size - 1
                For x = 0 To Size - 1
                    If (mvarFinal(x, y) <> 0) Then
                        strOut.Append("<div style='background-color:#000000;width:" + ModuleSize.ToString() + "px;height:" + ModuleSize.ToString() + "px;position:absolute;left:" + (x * ModuleSize).ToString() + "px;top:" + (y * ModuleSize).ToString() + "px;'>&nbsp</div>" + mvarNewLine)
                    End If
                Next
            Next

            strOut.Append("</div>" + mvarNewLine)
        End If

        Return strOut.ToString()
    End Function


    '' <summary>
    '' Function, which creates a QR-Code barcode, depending on the various input options chosen. 
    '' </summary>
    '' <param name="DataToEncode">The data that Is encoded in the barcode.</param>
    '' <param name="ApplyTilde">Enables processing of tilde And parentheses characters for purposes of encoding ASCII functions And GS1 application identifiers.</param>
    '' <param name="EncodingMode">Various modes used to Data represented in the symbol may be encoded by one of these types.</param>
    '' <param name="Version">Represents the various sizes of the symbol.</param>
    '' <param name="ErrorCorrectionLevel">Four levels of Reed-Solomon error correction, which allow verification of data And recovery in the event that part of the symbol Is physically damaged.</param>
    '' <param name="OutputType">Indicates the encoded text output for the barcode font.</param>
    '' <param name="BestMask">Use a best mask for pattern in the QRCode.</param>
    '' <param name="NewLine">String indicating EOL character. Defaults to the operating system EOL character if left NULL.</param>
    '' <param name="EndSymbolReturn">If TRUE, adds extra Newline character to output.</param>
    '' <returns>Encoded text for use with the 2D barcode font.</returns>
    Public Function EncodeQR(DataToEncode As String, Optional ApplyTilde As Boolean = True, Optional EncodingMode As EncodingModes = EncodingModes.Bytes, Optional Version As Versions = Versions.AUTO, Optional ErrorCorrectionLevel As ErrorCorrectionLevels = ErrorCorrectionLevels.M, Optional OutputType As OutputTypes = OutputTypes.IDA2DFont, Optional BestMask As Boolean = True, Optional NewLine As String = "", Optional EndSymbolReturn As Boolean = False)
        'DataToEncode must have a value; otherwise null is returned

        '' allows user to set an end-of-line (EOL) string
        If (NewLine = "") Then NewLine = Environment.NewLine '' Default

        Dim result As String = ""

        Select Case OutputType
            Case OutputTypes.IDAMonospaceFont
                result = "█▀▀▀▀▀█ ▄▄▄█▄ █▀▀▀▀▀█" + NewLine + "█ ███ █  ▄▀   █ ███ █" + NewLine + "█ ▀▀▀ █ ▀▀ █▀ █ ▀▀▀ █" + NewLine + "▀▀▀▀▀▀▀ ▀▄▀ ▀ ▀▀▀▀▀▀▀" + NewLine + "█ █▄▀▄▀  ▄ ▄▀▄▄▄▀▄ ▀▄" + NewLine + "▄▀▀▄▄▄▀▀▄▀▀█▄▀█ ▄▀▄▀█" + NewLine + " ▀ ▀▀▀▀ ▄█▄█ ▀▄▄▄▄▀ █" + NewLine + "█▀▀▀▀▀█    ▄▀██ ▀▀▀▄▀" + NewLine + "█ ███ █ ▀█▀▄▀█▄█▀ █▄ " + NewLine + "█ ▀▀▀ █ ▀█  █▄ ▀█ ▀▄█" + NewLine + "▀▀▀▀▀▀▀ ▀  ▀▀  ▀ ▀▀ ▀" + NewLine + ""

            Case OutputTypes.IDAProportionalFont
                result = "█▀▀▀▀▀█░▄▄▄█▄░█▀▀▀▀▀█" + NewLine + "█░███░█░░▄▀░░░█░███░█" + NewLine + "█░▀▀▀░█░▀▀░█▀░█░▀▀▀░█" + NewLine + "▀▀▀▀▀▀▀░▀▄▀░▀░▀▀▀▀▀▀▀" + NewLine + "█░█▄▀▄▀░░▄░▄▀▄▄▄▀▄░▀▄" + NewLine + "▄▀▀▄▄▄▀▀▄▀▀█▄▀█░▄▀▄▀█" + NewLine + "░▀░▀▀▀▀░▄█▄█░▀▄▄▄▄▀░█" + NewLine + "█▀▀▀▀▀█░░░░▄▀██░▀▀▀▄▀" + NewLine + "█░███░█░▀█▀▄▀█▄█▀░█▄░" + NewLine + "█░▀▀▀░█░▀█░░█▄░▀█░▀▄█" + NewLine + "▀▀▀▀▀▀▀░▀░░▀▀░░▀░▀▀░▀" + NewLine
            Case Else
                result = "AHEEEHAPLKJDLPAHEEEHA" + NewLine + "BNFFFNBPFGNDFPBNFFFNB" + NewLine + "CNBKGKFNOJNIGJILGJOFI" + NewLine + "MFNFFFEPLDLCNEILJJFOB" + NewLine + "APBBBPAPFAHLECLBEPBKM" + NewLine + "HHHHHHHPHPPHHPPHPHHPH" + NewLine

        End Select

        EncodeQR = result


    End Function

End Class


'' <summary>
'' Various modes used to Data represented in the symbol may be encoded by one of these types.
'' </summary>
Public Enum EncodingModes
    '' <summary>
    '' In this mode data Is encoded at 8 bits per character.
    '' </summary>
    Bytes

    '' <summary>
    '' Encodes data from a set of 45 characters 10 numeric digits 0-9, 26 capital alpha characters A-Z,
    '' And 9 symbols ( space, $, %, *, +, -, ., :, / ) 
    '' Normally, two input characters are represented by 11 bits.
    '' </summary>
    Alphanumeric

    '' <summary>
    '' Encodes data from a set of 10 numeric digits 0-9
    '' </summary>
    Numeric


End Enum

'' <summary>
'' Four levels of Reed-Solomon error correction, which allow verification of data And recovery in the event that part of the symbol Is physically damaged. 
'' </summary>
Public Enum ErrorCorrectionLevels
    '' <summary>
    '' Level M, 15% recovery capacity.
    '' </summary>
    M

    '' <summary>
    '' Level H, 30% recovery capacity.
    '' </summary>
    H

    '' <summary>
    '' Level L, 7% recovery capacity.
    '' </summary>
    L

    '' <summary>
    '' Level Q, 25% recovery capacity.
    '' </summary>
    Q
End Enum

'' <summary>
'' Represent the various sizes of the symbol.
'' </summary>
Public Enum Versions
    '' <summary>
    '' 11 x 11 Format (Micro QR-Code).
    '' </summary>
    M1 = -4

    '' <summary>
    '' 13 x 13 Format (Micro QR-Code).
    '' </summary>
    M2 = -3

    '' <summary>
    '' 15 x 15 Format (Micro QR-Code).
    '' </summary>
    M3 = -2

    '' <summary>
    '' 17 x 17 Format (Micro QR-Code).
    '' </summary>
    M4 = -1

    '' <summary>
    '' Auto (QR-Code).
    '' </summary>
    AUTO = 0

    '' <summary>
    '' 21 x 21 Format (QR-Code).
    '' </summary>
    V01
    '' <summary>
    '' 25 x 25 Format (QR-Code).
    '' </summary>
    V02
    '' <summary>
    '' 29 x 29 Format (QR-Code).
    '' </summary>
    V03
    '' <summary>
    '' 33 x 33 Format (QR-Code).
    '' </summary>
    V04
    '' <summary>
    '' 37 x 37 Format (QR-Code).
    '' </summary>
    V05
    '' <summary>
    '' 41 x 41 Format (QR-Code).
    '' </summary>
    V06
    '' <summary>
    '' 45 x 45 Format (QR-Code).
    '' </summary>
    V07
    '' <summary>
    '' 49 x 49 Format (QR-Code).
    '' </summary>
    V08
    '' <summary>
    '' 53 x 53 Format (QR-Code).
    '' </summary>
    V09
    '' <summary>
    '' 57 x 57 Format (QR-Code).
    '' </summary>
    V10
    '' <summary>
    '' 61 x 61 Format (QR-Code).
    '' </summary>
    V11
    '' <summary>
    '' 65 x 65 Format (QR-Code).
    '' </summary>
    V12
    '' <summary>
    '' 69 x 69 Format (QR-Code).
    '' </summary>
    V13
    '' <summary>
    '' 73 x 73 Format (QR-Code).
    '' </summary>
    V14
    '' <summary>
    '' 77 x 77 Format (QR-Code).
    '' </summary>
    V15
    '' <summary>
    '' 81 x 81 Format (QR-Code).
    '' </summary>
    V16
    '' <summary>
    '' 85 x 85 Format (QR-Code).
    '' </summary>
    V17
    '' <summary>
    '' 89 x 89 Format (QR-Code).
    '' </summary>
    V18
    '' <summary>
    '' 93 x 93 Format (QR-Code).
    '' </summary>
    V19
    '' <summary>
    '' 97 x 97 Format (QR-Code).
    '' </summary>
    V20
    '' <summary>
    '' 101 x 101 Format (QR-Code).
    '' </summary>
    V21
    '' <summary>
    '' 105 x 105 Format (QR-Code).
    '' </summary>
    V22
    '' <summary>
    '' 109 x 109 Format (QR-Code).
    '' </summary>
    V23
    '' <summary>
    '' 113 x 113 Format (QR-Code).
    '' </summary>
    V24
    '' <summary>
    '' 117 x 117 Format (QR-Code).
    '' </summary>
    V25
    '' <summary>
    '' 121 x 121 Format (QR-Code).
    '' </summary>
    V26
    '' <summary>
    '' 125 x 125 Format (QR-Code).
    '' </summary>
    V27
    '' <summary>
    '' 129 x 129 Format (QR-Code).
    '' </summary>
    V28
    '' <summary>
    '' 133 x 133 Format (QR-Code).
    '' </summary>
    V29
    '' <summary>
    '' 137 x 137 Format (QR-Code).
    '' </summary>
    V30
    '' <summary>
    '' 141 x 141 Format (QR-Code).
    '' </summary>
    V31
    '' <summary>
    '' 145 x 145 Format (QR-Code).
    '' </summary>
    V32
    '' <summary>
    '' 149 x 149 Format (QR-Code).
    '' </summary>
    V33
    '' <summary>
    '' 153 x 153 Format (QR-Code).
    '' </summary>
    V34
    '' <summary>
    '' 157 x 157 Format (QR-Code).
    '' </summary>
    V35
    '' <summary>
    '' 161 x 161 Format (QR-Code).
    '' </summary>
    V36
    '' <summary>
    '' 165 x 165 Format (QR-Code).
    '' </summary>
    V37
    '' <summary>
    '' 169 x 169 Format (QR-Code).
    '' </summary>
    V38
    '' <summary>
    '' 173 x 173 Format (QR-Code).
    '' </summary>
    V39
    '' <summary>
    '' 177 x 177 Format (QR-Code).
    '' </summary>
    V40
End Enum

'' <summary>
'' Various types of output.
'' </summary>
Public Enum OutputTypes

    '' <summary>
    '' For use with IDAutomation QR-Code Or 2D Barcode Fonts. Returns QR-Code encoded text. 
    '' </summary>
    IDA2DFont


#If Not ENCODER Then
    '' <summary>
    '' Returns QR-Code native object. For use with monospaced fonts.
    '' </summary>
    IDAMonospaceFont

    '' <summary>
    '' Returns QR-Code native object. For use with standard (proportional) fonts.
    '' </summary>

    IDAProportionalFont
#End If

End Enum

'' <summary>
'' Various types of vector image output.
'' </summary>
Public Enum VectorTypes

    '' <summary>
    '' Returns a string with the SVG representation. 
    '' </summary>
    VecSVG

    '' <summary>
    '' Return a string with the EPS representation.
    '' </summary>
    VecEPS

    '' <summary>
    '' Return a string with the HTML representation.
    '' </summary>
    VecHTML

End Enum