Exemplo n.º 1
0
        /// <summary>
        /// Make bit vector of type information. On success, store the result in "bits" and return true.
        /// Encode error correction level and mask pattern. See 8.9 of
        /// JISX0510:2004 (p.45) for details.
        /// </summary>
        /// <param name="ecLevel"></param>
        /// <param name="maskPattern"></param>
        /// <param name="bits"></param>
        /// <remarks>
        /// ISO/IEC 18004:2006(E)  6.9 Format information
        /// </remarks>
        public static void makeTypeInfoBits(ErrorCorrectionLevel ecLevel, int version, int maskPattern, BitVector bits)
        {
            if (!MicroQRCode.isValidMaskPattern(maskPattern))
            {
                throw new WriterException("Invalid mask pattern");
            }
            //ISO/IEC 18004:2006(E)  6.9 Format information
            //Symbol number 0:         000
            //Data mask pattern reference:       11
            //Data bits (symbol number, data mask pattern reference):  00011
            //BCH bits:           1101011001
            //Unmasked bit sequence:        000111101011001
            //Mask pattern for XOR operation:       100010001000101
            //Format information module pattern:      100101100011100
            int typeInfo = SYMBOL_NUMBERS_INFO[version - 1][ecLevel.ordinal()];

            if (typeInfo == -1)
            {
                throw new WriterException("Invalid Version&Level info");
            }

            typeInfo = (typeInfo << 2) | maskPattern;
            bits.appendBits(typeInfo, 5);

            int bchCode = calculateBCHCode(typeInfo, TYPE_INFO_POLY);

            bits.appendBits(bchCode, 10);

            BitVector maskBits = new BitVector();

            maskBits.appendBits(TYPE_INFO_MASK_PATTERN, 15);
            bits.xor(maskBits);

            if (bits.size() != 15)
            {
                // Just in case.
                throw new WriterException("should not happen but we got: " + bits.size());
            }
        }
 public override int GetHashCode()
 {
     return((errorCorrectionLevel.ordinal() << 3) | (int)dataMask);
 }
Exemplo n.º 3
0
 public ECBlocks getECBlocksForLevel(ErrorCorrectionLevel ecLevel)
 {
     return(ecBlocks[ecLevel.ordinal()]);
 }