public static Image GetQRCode(byte[] data, ErrorCorrectionLevel level = ErrorCorrectionLevel.M)
        {
            bool requires16BitLength    = false;
            int  maxBytesInVersion9Code = QRErrorCorrections.GetQRVersionInfo(9).GetCorrectionInfo(level).TotalDataBytes;

            if (maxBytesInVersion9Code - 2 < data.Length)
            {
                // This data requires a version 10 or higher code; will not fit in version 9 or lower.
                // Version 10 and higher codes require 16-bit data lengths.
                requires16BitLength = true;
            }

            StreamHelper sh = new StreamHelper();

            sh.WriteNibble(0x04); // byte mode
            if (requires16BitLength)
            {
                sh.WriteWord((ushort)data.Length);
            }
            else
            {
                sh.WriteByte((byte)data.Length);
            }
            sh.WriteBytes(new ArraySegment <byte>(data));
            sh.WriteNibble(0x00); // terminator
            byte[] binaryData = sh.ToArray();

            int qrCodeVersion;
            ErrorCorrectionLevel errorCorrectionLevel;

            byte[] finalMessageSequence = QRErrorCorrections.GetMessageSequence(binaryData, level, out qrCodeVersion, out errorCorrectionLevel);

            SymbolTemplate template = SymbolTemplate.CreateTemplate(qrCodeVersion);

            template.ErrorCorrectionLevel = errorCorrectionLevel;
            template.PopulateData(finalMessageSequence);
            template.Complete();

            return(template.ToImage());
        }
        public static Image GetQRCode(byte[] data, ErrorCorrectionLevel level = ErrorCorrectionLevel.M)
        {
            bool requires16BitLength = false;
            int maxBytesInVersion9Code = QRErrorCorrections.GetQRVersionInfo(9).GetCorrectionInfo(level).TotalDataBytes;
            if (maxBytesInVersion9Code - 2 < data.Length)
            {
                // This data requires a version 10 or higher code; will not fit in version 9 or lower.
                // Version 10 and higher codes require 16-bit data lengths.
                requires16BitLength = true;
            }

            StreamHelper sh = new StreamHelper();
            sh.WriteNibble(0x04); // byte mode
            if (requires16BitLength)
            {
                sh.WriteWord((ushort)data.Length);
            }
            else
            {
                sh.WriteByte((byte)data.Length);
            }
            sh.WriteBytes(new ArraySegment<byte>(data));
            sh.WriteNibble(0x00); // terminator
            byte[] binaryData = sh.ToArray();

            int qrCodeVersion;
            ErrorCorrectionLevel errorCorrectionLevel;
            byte[] finalMessageSequence = QRErrorCorrections.GetMessageSequence(binaryData, level, out qrCodeVersion, out errorCorrectionLevel);

            SymbolTemplate template = SymbolTemplate.CreateTemplate(qrCodeVersion);
            template.ErrorCorrectionLevel = errorCorrectionLevel;
            template.PopulateData(finalMessageSequence);
            template.Complete();

            return template.ToImage();
        }