/// <summary> /// <p>Decodes a QR Code represented as a {@link BitMatrix}. A 1 or "true" is taken to mean a black module.</p> /// </summary> /// <param name="bits">booleans representing white/black QR Code modules</param> /// <param name="hints">decoding hints that should be used to influence decoding</param> /// <returns> /// text and bytes encoded within the QR Code /// </returns> public DecoderResult decode(BitMatrix bits, IDictionary <DecodeHintType, object> hints) { // Construct a parser and read version, error-correction level var parser = BitMatrixParser.createBitMatrixParser(bits); if (parser == null) { return(null); } var result = decode(parser, hints); if (result == null) { // Revert the bit matrix parser.remask(); // Will be attempting a mirrored reading of the version and format info. parser.setMirror(true); // Preemptively read the version. var version = parser.readVersion(); if (version == null) { return(null); } // Preemptively read the format information. var formatinfo = parser.readFormatInformation(); if (formatinfo == null) { return(null); } /* * Since we're here, this means we have successfully detected some kind * of version and format information when mirrored. This is a good sign, * that the QR code may be mirrored, and we should try once more with a * mirrored content. */ // Prepare for a mirrored reading. parser.mirror(); result = decode(parser, hints); if (result != null) { // Success! Notify the caller that the code was mirrored. result.Other = new QRCodeDecoderMetaData(true); } } return(result); }