public static ErrorCorrectionLevel ToInterop(this QrCode.Internal.ErrorCorrectionLevel other) { if (other == null) { return(ErrorCorrectionLevel.L); } if (other == QrCode.Internal.ErrorCorrectionLevel.H) { return(ErrorCorrectionLevel.H); } if (other == QrCode.Internal.ErrorCorrectionLevel.L) { return(ErrorCorrectionLevel.L); } if (other == QrCode.Internal.ErrorCorrectionLevel.M) { return(ErrorCorrectionLevel.M); } if (other == QrCode.Internal.ErrorCorrectionLevel.Q) { return(ErrorCorrectionLevel.Q); } return(ErrorCorrectionLevel.L); }
internal static DecoderResult decode(byte[] bytes, Version version, QrCode.Internal.ErrorCorrectionLevel ecLevel, IDictionary <DecodeHintType, object> hints) { var bits = new BitSource(bytes); var result = new StringBuilder(50); var byteSegments = new List <byte[]>(1); var symbolSequence = -1; var parityData = -1; CharacterSetECI currentCharacterSetECI = null; bool fc1InEffect = false; Mode mode = Mode.TERMINATOR; int bitLen = Mode.NUMERIC.getBitsLength(version.VersionNumber); if (version.VersionNumber > 1) { try { mode = Mode.forBits(bits.readBits(bitLen)); } catch (System.ArgumentException iae) { throw ReaderException.Instance; } } else { mode = Mode.NUMERIC; } if (!mode.Equals(Mode.TERMINATOR)) { // How many characters will follow, encoded in this mode? int count = bits.readBits(mode.getCharacterCountBits(version)); if (mode.Equals(Mode.NUMERIC)) { decodeNumericSegment(bits, result, count); } else if (mode.Equals(Mode.ALPHANUMERIC)) { decodeAlphanumericSegment(bits, result, count, fc1InEffect); } else if (mode.Equals(Mode.BYTE)) { decodeByteSegment(bits, result, count, currentCharacterSetECI, byteSegments, hints); } else if (mode.Equals(Mode.KANJI)) { decodeKanjiSegment(bits, result, count); } else { throw ReaderException.Instance; } } return(new DecoderResult(bytes, result.ToString(), byteSegments.Count == 0 ? null : byteSegments, ecLevel == null ? null : ecLevel.ToString(), symbolSequence, parityData)); }